package ${packageName}.controller; import java.util.List; import lombok.RequiredArgsConstructor; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.constraints.*; import cn.dev33.satoken.annotation.SaCheckPermission; import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated; import org.dromara.common.idempotent.annotation.RepeatSubmit; import org.dromara.common.log.annotation.Log; import org.dromara.common.web.core.BaseController; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.core.domain.R; import org.dromara.common.core.validate.AddGroup; import org.dromara.common.core.validate.EditGroup; import org.dromara.common.log.enums.BusinessType; import org.dromara.common.excel.utils.ExcelUtil; import ${packageName}.domain.vo.${ClassName}Vo; import ${packageName}.domain.bo.${ClassName}Bo; import ${packageName}.service.I${ClassName}Service; #if($table.crud) import org.dromara.common.mybatis.core.page.TableDataInfo; #elseif($table.tree) #end /** * ${functionName} * 前端访问路由地址为:/${moduleName}/${businessName} * * @author ${author} * @date ${datetime} */ @Validated @RequiredArgsConstructor @RestController @RequestMapping("/${businessName}") public class ${ClassName}Controller extends BaseController { private final I${ClassName}Service ${className}Service; /** * 查询${functionName}列表 */ @SaCheckPermission("${permissionPrefix}:list") @GetMapping("/list") #if($table.crud) public TableDataInfo<${ClassName}Vo> list(${ClassName}Bo bo, PageQuery pageQuery) { return ${className}Service.queryPageList(bo, pageQuery); } #elseif($table.tree) public R> list(${ClassName}Bo bo) { List<${ClassName}Vo> list = ${className}Service.queryList(bo); return R.ok(list); } #end /** * 导出${functionName}列表 */ @SaCheckPermission("${permissionPrefix}:export") @Log(title = "${functionName}", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(${ClassName}Bo bo, HttpServletResponse response) { List<${ClassName}Vo> list = ${className}Service.queryList(bo); ExcelUtil.exportExcel(list, "${functionName}", ${ClassName}Vo.class, response); } /** * 获取${functionName}详细信息 * * @param ${pkColumn.javaField} 主键 */ @SaCheckPermission("${permissionPrefix}:query") @GetMapping("/{${pkColumn.javaField}}") public R<${ClassName}Vo> getInfo(@NotNull(message = "主键不能为空") @PathVariable ${pkColumn.javaType} ${pkColumn.javaField}) { return R.ok(${className}Service.queryById(${pkColumn.javaField})); } /** * 新增${functionName} */ @SaCheckPermission("${permissionPrefix}:add") @Log(title = "${functionName}", businessType = BusinessType.INSERT) @RepeatSubmit() @PostMapping() public R add(@Validated(AddGroup.class) @RequestBody ${ClassName}Bo bo) { return toAjax(${className}Service.insertByBo(bo)); } /** * 修改${functionName} */ @SaCheckPermission("${permissionPrefix}:edit") @Log(title = "${functionName}", businessType = BusinessType.UPDATE) @RepeatSubmit() @PutMapping() public R edit(@Validated(EditGroup.class) @RequestBody ${ClassName}Bo bo) { return toAjax(${className}Service.updateByBo(bo)); } /** * 删除${functionName} * * @param ${pkColumn.javaField}s 主键串 */ @SaCheckPermission("${permissionPrefix}:remove") @Log(title = "${functionName}", businessType = BusinessType.DELETE) @DeleteMapping("/{${pkColumn.javaField}s}") public R remove(@NotEmpty(message = "主键不能为空") @PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) { return toAjax(${className}Service.deleteWithValidByIds(List.of(${pkColumn.javaField}s), true)); } /** * 下拉框查询${functionName}列表 */ #* @SaCheckPermission("${permissionPrefix}:list")*# @GetMapping("get${ClassName}List") public R> get${ClassName}List(${ClassName}Bo bo) { List<${ClassName}Vo> list = ${className}Service.queryList(bo); return R.ok(list); } }