package ${code.packageName}.controller; import com.inkasso.auth.interfaces.Permissions; import com.inkasso.auth.interfaces.PermissionAndCheck; import com.inkasso.adapter.page.PageResult; import ${code.packageName}.model.dto.${code.className}DTO; import ${code.packageName}.model.request.Add${code.className}Request; import ${code.packageName}.model.request.Edit${code.className}Request; import ${code.packageName}.model.request.Query${code.className}Request; import ${code.packageName}.service.${code.className}Service; import com.inkasso.adapter.exception.ServiceException; import com.inkasso.adapter.response.ResponseData; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import com.inkasso.adapter.exception.enums.ExceptionEnum; import java.util.List; /** * @author ${code.author} * @date ${.now?string('yyyy-MM-dd')} */ @RestController @RequestMapping(path = "${code.className?lower_case}") @Permissions(name="${code.label}",code = "${code.className?lower_case}Manage") public class ${code.className}Controller { @Autowired private ${code.className}Service ${code.className?uncap_first}Service; @PostMapping(path = "${code.className?lower_case}") @PermissionAndCheck(name="添加${code.label}",code="${code.className}Controller:add") public ResponseData add(@Validated @RequestBody Add${code.className}Request add${code.className}Request) { ${code.className?uncap_first}Service.add${code.className}(add${code.className}Request); return ResponseData.success(); } @PutMapping(path = "${code.className?lower_case}") @PermissionAndCheck(name="更新${code.label}",code="${code.className}Controller:update") public ResponseData edit(@Validated @RequestBody Edit${code.className}Request edit${code.className}Request) { ${code.className?uncap_first}Service.edit${code.className}(edit${code.className}Request); return ResponseData.success(); } <#if code.parentName = "BaseBean"> @GetMapping(path = "${code.className?lower_case}") @PermissionAndCheck(name = "分页查询列表", code="${code.className}Controller:pageList") public ResponseData pageQuery(@RequestBody Query${code.className}Request query${code.className}Request){ ResponseData> result = ${code.className?uncap_first}Service.pageQuery(query${code.className}Request); return ResponseData.success(result); } @GetMapping(path = "${code.className?lower_case}s") @PermissionAndCheck(name = "查询全部列表", code="${code.className}Controller:allList") public ResponseData queryList(@RequestBody Query${code.className}Request query${code.className}Request) { List result = ${code.className?uncap_first}Service.queryList(query${code.className}Request); return ResponseData.success(result); } @GetMapping(path = "${code.className?lower_case}/{id}") @PermissionAndCheck(name = "查询${code.label}详细信息", code="${code.className}Controller:detail") public ResponseData getById(@PathVariable("id") Long id){ if(id==null){ throw new ServiceException(400, ExceptionEnum.SYSTEM_DATE_ERROR); } ${code.className}DTO ${code.className?uncap_first}DTO = ${code.className?uncap_first}Service.get${code.className}DtoById(id); return ResponseData.success(${code.className?uncap_first}DTO); } @DeleteMapping(path = "${code.className?lower_case}/{id}") @PermissionAndCheck(name = "删除${code.label}", code="${code.className}Controller:delete") public ResponseData deleteById(@PathVariable("id") Long id){ if(id==null){ throw new ServiceException(400, ExceptionEnum.SYSTEM_DATE_ERROR); } ${code.className?uncap_first}Service.delete${code.className}(id); return ResponseData.success(); } }