Loading...
Loading...
Proxy2.0 API 接口设计规范:RESTful URL 约定、Controller 模板、VO 设计、Swagger 文档注解、 错误码设计、响应格式。Use when: (1) Creating new Controller/API endpoints, (2) Designing VO classes (PageReqVO/SaveReqVO/RespVO), (3) Writing Swagger annotations, (4) Defining error codes, (5) Reviewing API design compliance.
npx skill4agent add kevinqpeng/proxy-skills proxy-backend-api-design管理后台:/admin-api/{模块}/{实体}/{操作}
用户端: /app-api/{模块}/{实体}/{操作}dict-typeorder-item| 操作 | 方法 | URL | 说明 |
|---|---|---|---|
| 创建 | | | |
| 修改 | | | |
| 删除 | | | |
| 批量删除 | | | |
| 单条查询 | | | |
| 分页 | | | Query String |
| 列表 | | | Query String |
| 导出 | | | 无 |
@Tag(name = "管理后台 - {实体名}")
@RestController
@RequestMapping("/{模块}/{实体-kebab}")
@Validated
public class {Entity}Controller {
@Resource
private {Entity}Service {entity}Service;
@PostMapping("/create")
@Operation(summary = "创建{实体名}")
@PreAuthorize("@ss.hasPermission('{模块}:{实体}:create')")
public CommonResult<Long> create{Entity}(@Valid @RequestBody {Entity}SaveReqVO createReqVO) {
return success({entity}Service.create{Entity}(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "修改{实体名}")
@PreAuthorize("@ss.hasPermission('{模块}:{实体}:update')")
public CommonResult<Boolean> update{Entity}(@Valid @RequestBody {Entity}SaveReqVO updateReqVO) {
{entity}Service.update{Entity}(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除{实体名}")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('{模块}:{实体}:delete')")
public CommonResult<Boolean> delete{Entity}(@RequestParam("id") Long id) {
{entity}Service.delete{Entity}(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得{实体名}详情")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('{模块}:{实体}:query')")
public CommonResult<{Entity}RespVO> get{Entity}(@RequestParam("id") Long id) {
return success(BeanUtils.toBean({entity}Service.get{Entity}(id), {Entity}RespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得{实体名}分页")
@PreAuthorize("@ss.hasPermission('{模块}:{实体}:query')")
public CommonResult<PageResult<{Entity}RespVO>> get{Entity}Page(@Valid {Entity}PageReqVO pageReqVO) {
return success(BeanUtils.toBean({entity}Service.get{Entity}Page(pageReqVO), {Entity}RespVO.class));
}
}| VO 类型 | 后缀 | 用途 |
|---|---|---|
| 分页请求 | | 继承 |
| 保存请求 | | 创建+更新共用( |
| 响应 | | 详情/列表/分页返回 |
| 精简响应 | | 下拉选项等轻量返回 |
SaveReqVO@NotNull@NotBlankmessage@Schema@ValidBeanUtils.toBean(){ "code": 0, "msg": "", "data": { ... } }{ "code": 0, "data": { "total": 100, "list": [...] } }@Tag(name = "管理后台 - xxx")@Operation(summary = "xxx")@Parameter(name, description, required, example)@Schema(description, requiredMode, example)REQUIREDexample// 格式:1-{模块编号}-{实体编号}-{序号}
ErrorCode {ENTITY}_NOT_EXISTS = new ErrorCode(1_0XX_0YY_000, "当前{实体}不存在");{模块}:{实体}:{操作}