生成模版修改

This commit is contained in:
guoshengxiong 2024-05-14 20:28:21 +08:00
parent e33377724f
commit e9809f79c5
3 changed files with 12 additions and 9 deletions

View File

@ -126,15 +126,7 @@ public class ${entityName}Controller {
@ApiImplicitParam(name = "id", value = "${tableVo.ftlDescription}ID", paramType = "query", required = true, dataType = "Integer")
@GetMapping(value = "/queryById")
public Result<${entityName}> queryById(@RequestParam(name="id",required=true) String id) {
Result<${entityName}> result = new Result<${entityName}>();
${entityName} ${entityName?uncap_first} = ${entityName?uncap_first}Service.getById(id);
if(${entityName?uncap_first}==null) {
result.error500("未找到对应实体");
}else {
result.setResult(${entityName?uncap_first});
result.setSuccess(true);
}
return result;
return Result.success(${entityName?uncap_first}Service.queryById(id));
}
}

View File

@ -23,4 +23,7 @@ public interface I${entityName}Service extends IService<${entityName}> {
void edit(${entityName} ${entityName?uncap_first});
void delete(String id);
${entityName} queryById(String id);
}

View File

@ -78,5 +78,13 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
baseMapper.deleteById(id);
}
@Override
public ${entityName} queryById(String id) {
${entityName} entity = getById(id);
if (entity == null) {
throw new OpenAlertException("未找到对应实体");
}
return entity;
}
}