Compare commits
2 Commits
f9bf0df1e1
...
026a490125
| Author | SHA1 | Date | |
|---|---|---|---|
| 026a490125 | |||
| c46cb06391 |
@@ -35,33 +35,66 @@ class ParameterChange:
|
|||||||
old_description: Optional[str] = None
|
old_description: Optional[str] = None
|
||||||
source: str = "query"
|
source: str = "query"
|
||||||
|
|
||||||
def _escape_cell(self, text: str) -> str:
|
def _change_tag(self) -> str:
|
||||||
"""表格单元格转义。"""
|
"""变更类型标签(企微颜色)。"""
|
||||||
return text.replace("|", "\\|").replace("\n", " ")
|
tags = {
|
||||||
|
ChangeType.ADDED: '<font color="info">**新增**</font>',
|
||||||
|
ChangeType.REMOVED: '<font color="warning">**删除**</font>',
|
||||||
|
ChangeType.RENAMED: '<font color="comment">**重命名**</font>',
|
||||||
|
ChangeType.MODIFIED: '<font color="warning">**修改**</font>',
|
||||||
|
}
|
||||||
|
return tags.get(self.change_type, "")
|
||||||
|
|
||||||
def _change_label(self) -> str:
|
def _required_tag(self) -> str:
|
||||||
"""变更列文案,对齐 model.md。"""
|
"""必填/可选标签。"""
|
||||||
if self.change_type == ChangeType.ADDED:
|
if self.required is True:
|
||||||
|
return '<font color="warning">必填</font>'
|
||||||
if self.required is False:
|
if self.required is False:
|
||||||
return "新增可选"
|
return '<font color="comment">可选</font>'
|
||||||
return "新增必填"
|
return ""
|
||||||
if self.change_type == ChangeType.REMOVED:
|
|
||||||
return "删除"
|
def to_markdown_block(self, index: int = 1) -> str:
|
||||||
|
"""格式化为企微友好的参数变更卡片(列表式,非表格)。"""
|
||||||
|
lines: List[str] = []
|
||||||
|
desc = self.description or self.old_description
|
||||||
|
|
||||||
if self.change_type == ChangeType.RENAMED:
|
if self.change_type == ChangeType.RENAMED:
|
||||||
return f"重命名 {self.old_name} → {self.param_name}"
|
lines.append(f"**{index}. `{self.param_name}`** {self._change_tag()}")
|
||||||
if self.change_type == ChangeType.MODIFIED:
|
lines.append(f"> `{self.old_name}` → `{self.param_name}`")
|
||||||
return self.detail or "修改"
|
if desc:
|
||||||
return "-"
|
lines.append(f"> 说明:{desc}")
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
if self.change_type == ChangeType.ADDED:
|
||||||
|
type_part = f" · `{self.param_type}`" if self.param_type else ""
|
||||||
|
req_part = f" · {self._required_tag()}" if self._required_tag() else ""
|
||||||
|
lines.append(
|
||||||
|
f"**{index}. `{self.param_name}`**{type_part}{req_part} {self._change_tag()}"
|
||||||
|
)
|
||||||
|
if desc:
|
||||||
|
lines.append(f"> 说明:{desc}")
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
if self.change_type == ChangeType.REMOVED:
|
||||||
|
type_part = f" · `{self.param_type}`" if self.param_type else ""
|
||||||
|
lines.append(
|
||||||
|
f"**{index}. `{self.param_name}`**{type_part} {self._change_tag()}"
|
||||||
|
)
|
||||||
|
if desc:
|
||||||
|
lines.append(f"> 说明:{desc}")
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
# MODIFIED
|
||||||
|
lines.append(f"**{index}. `{self.param_name}`** {self._change_tag()}")
|
||||||
|
if desc:
|
||||||
|
lines.append(f"> 说明:{desc}")
|
||||||
|
if self.detail:
|
||||||
|
lines.append(f"> 变更:{self.detail}")
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
def to_table_row(self) -> str:
|
def to_table_row(self) -> str:
|
||||||
"""格式化为 model.md 参数变更表格行。"""
|
"""兼容旧调用,委托至卡片块。"""
|
||||||
desc = self._escape_cell(self.description or "-")
|
return self.to_markdown_block(1)
|
||||||
change = self._escape_cell(self._change_label())
|
|
||||||
return f"| `{self.param_name}` | {desc} | {change} |"
|
|
||||||
|
|
||||||
def to_markdown_line(self, *, plain: bool = False) -> str:
|
|
||||||
"""兼容旧调用,委托至表格行。"""
|
|
||||||
return self.to_table_row()
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
@@ -22,38 +22,32 @@ def truncate_text(text: str, max_length: int = MAX_MD_LENGTH) -> str:
|
|||||||
return text[:max_length] + "\n\n<font color=\"comment\">... 消息过长,已截断</font>"
|
return text[:max_length] + "\n\n<font color=\"comment\">... 消息过长,已截断</font>"
|
||||||
|
|
||||||
|
|
||||||
def _format_param_table(changes: List) -> List[str]:
|
def _format_param_change_list(changes: List) -> List[str]:
|
||||||
"""按 model.md 生成参数变更 Markdown 表格。"""
|
"""生成企微友好的参数变更列表(卡片式)。"""
|
||||||
if not changes:
|
if not changes:
|
||||||
return ['<font color="comment">无</font>']
|
return ['<font color="comment">无</font>']
|
||||||
lines = [
|
lines = ["", f"共 **{len(changes)}** 项变更", ""]
|
||||||
"",
|
for i, change in enumerate(changes, 1):
|
||||||
"| 字段 | 说明 | 变更 |",
|
lines.append(change.to_markdown_block(i))
|
||||||
"|------|------|------|",
|
if i < len(changes):
|
||||||
]
|
lines.append("")
|
||||||
for change in changes:
|
|
||||||
lines.append(change.to_table_row())
|
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
|
|
||||||
def _format_param_details_section(report: EndpointChangeReport) -> List[str]:
|
def _format_param_details_section(report: EndpointChangeReport) -> List[str]:
|
||||||
"""生成接口参数变动详情区块(对齐 model.md)。"""
|
"""生成接口参数变动详情区块。"""
|
||||||
body_changes = [c for c in report.parameter_changes if c.source == "body"]
|
body_changes = [c for c in report.parameter_changes if c.source == "body"]
|
||||||
regular_changes = [c for c in report.parameter_changes if c.source != "body"]
|
regular_changes = [c for c in report.parameter_changes if c.source != "body"]
|
||||||
lines = ["", "---", "", "## 接口参数变动详情", "", "---", ""]
|
lines = ["", "---------------------------------------", "", "#### 【接口参数变动详情】", ""]
|
||||||
|
|
||||||
if body_changes:
|
if body_changes:
|
||||||
lines.append("### 类对象变更")
|
lines.append("**类对象变更**")
|
||||||
lines.append("")
|
lines.extend(_format_param_change_list(body_changes))
|
||||||
lines.append("- **参数变更列表:**")
|
|
||||||
lines.extend(_format_param_table(body_changes))
|
|
||||||
lines.append("")
|
lines.append("")
|
||||||
|
|
||||||
if regular_changes:
|
if regular_changes:
|
||||||
lines.append("### 普通参数变更(非对象字段)")
|
lines.append("**普通参数变更**")
|
||||||
lines.append("")
|
lines.extend(_format_param_change_list(regular_changes))
|
||||||
lines.append("- **参数变更列表:**")
|
|
||||||
lines.extend(_format_param_table(regular_changes))
|
|
||||||
lines.append("")
|
lines.append("")
|
||||||
|
|
||||||
if not body_changes and not regular_changes:
|
if not body_changes and not regular_changes:
|
||||||
|
|||||||
@@ -22,8 +22,8 @@
|
|||||||
- [删除] 属性: `attr2` 说明: {说明}
|
- [删除] 属性: `attr2` 说明: {说明}
|
||||||
- [修改] 属性: `attr3` 说明: {说明}
|
- [修改] 属性: `attr3` 说明: {说明}
|
||||||
|
|
||||||
### 普通参数变更(非对象字段)
|
### 【参数变更】
|
||||||
- **参数变更列表:**
|
- **变更列表:**
|
||||||
|
|
||||||
| 字段 | 说明 | 变更 |
|
| 字段 | 说明 | 变更 |
|
||||||
|------|------|------|
|
|------|------|------|
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ public class CultureClockInController {
|
|||||||
* @return jnpf.base.ActionResult<jnpf.model.culture.vo.RecordListVo>
|
* @return jnpf.base.ActionResult<jnpf.model.culture.vo.RecordListVo>
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/dynamic1")
|
@GetMapping(value = "/dynamic1")
|
||||||
public ActionResult<RecordListVo> getRecordList(@RequestParam(value = "cursorDate", required = false) Boolean cursorDate,
|
public ActionResult<RecordListVo> getRecordList(@RequestParam(value = "cursorDate1", required = false) Boolean cursorDate,
|
||||||
@RequestParam(value = "limitNum", required = false, defaultValue = "10") Integer limitNum) {
|
@RequestParam(value = "limitNum", required = false, defaultValue = "10") Integer limitNum) {
|
||||||
|
|
||||||
limitNum = Math.max(10, Math.min(limitNum, 30));
|
limitNum = Math.max(10, Math.min(limitNum, 30));
|
||||||
|
|||||||
Reference in New Issue
Block a user