提交 8e83cc8d 编写于 作者: ibiz4j's avatar ibiz4j

mapper

上级 29cf621c
......@@ -188,7 +188,7 @@ ribbon:
ibiz:
enablePermissionValid: true
cacheLevel: L1 #(L1)一级本地caffeine缓存;(L2)caffeine缓存+Redis缓存
{{#eq system.saaSMode() 4}}
{{#eq system.saaSMode 4}}
saas:
column: SRFDCID
sys-tables: ACT_RU_TASK,act_re_procdef,databasechangelog,databasechangeloglock{{#each system.entities as |entity|}}{{#if (and (eq entity.storage "SQL") (entity.saaSMode 0))}},{{entity.tableName}}{{/if}}{{/each}}
......
<#ibiztemplate>
TARGET=PSDESERVICEAPI
</#ibiztemplate>
<#comment>引入驼峰配置</#comment>
<#ibizinclude>/SLN/globalfunc.cfg</#ibizinclude>
<#comment>不发布子系统实体</#comment>
<#if de.isSubSysDE()==false>
<#-- SYSAPIRESTFUL,主从接口(非嵌套) -->
<#if api.getAPIType() == "RESTFUL" && !item.isNested()>
<#assign pubPkgCodeName = pub.getPKGCodeName()>
<#assign itemCodeName = item.getCodeName()>
<#assign itemCodeNameLC = itemCodeName?lower_case>
<#assign deCodeName = de.getCodeName()>
<#assign deLogicName = de.getLogicName()>
<#assign deCodeNameCamel = srfr7templcaseformat(deCodeName)?cap_first>
<#assign deCodeNameLC = deCodeName?lower_case>
<#assign dePKCodeNameLC = srfr7templcaseformat(de.getKeyPSDEField().getCodeName())>
<#assign dePKCodeName = (dePKCodeNameLC)?cap_first>
<#assign deModelCodeNameLC = de.getPSSystemModule().getCodeName()?lower_case>
<#assign itemSysApiCodeName = item.getPSSysServiceAPI().getCodeName()>
<#assign itemSysApiCodeNameLC = item.getPSSysServiceAPI().getCodeName()?lower_case>
<#assign keyCNLC = "_id">
<#assign hasDEPrefield=false>
<#if de.getPSDEFieldByPDT('ORGID',true)?? || de.getPSDEFieldByPDT('ORGSECTORID',true)?? || de.getPSDEFieldByPDT('CREATEMAN',true)?? >
<#assign hasDEPrefield=true>
</#if>
<#assign hasDEImport=false>
<#comment>实体数据导入</#comment>
<#if de.getAllPSDEDataImports?? && de.getAllPSDEDataImports()??>
<#list de.getAllPSDEDataImports() as deImport>
<#assign hasDEImport=true>
<#break>
</#list>
</#if>
package ${pubPkgCodeName}.${itemSysApiCodeNameLC}.rest;
{{#if apiEntity.major}}
{{#neq apiEntity.entity.storage "NONE"}}
package {{packageName}}.{{apis}}.rest;
import java.sql.Timestamp;
import java.util.ArrayList;
......@@ -61,1037 +29,164 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import ${pubPkgCodeName}.${itemSysApiCodeNameLC}.dto.*;
import ${pubPkgCodeName}.${itemSysApiCodeNameLC}.mapping.*;
import ${pubPkgCodeName}.core.${deModelCodeNameLC}.domain.${deCodeName};
import ${pubPkgCodeName}.core.${deModelCodeNameLC}.service.I${deCodeName}Service;
import ${pubPkgCodeName}.core.${deModelCodeNameLC}.filter.${deCodeName}SearchContext;
import ${pubPkgCodeName}.util.annotation.VersionCheck;
<#if item.getPSDEServiceAPIRSs()??>
<#list item.getPSDEServiceAPIRSs() as apider>
<#assign deapide=apider.getMinorPSDEServiceAPI().getPSDataEntity()>
<#assign deapideCN=deapide.getCodeName()>
<#assign deapideModuleCNLC=deapide.getPSSystemModule().getCodeName()?lower_case>
<#if apider.getMinorPSDEServiceAPI().isNested() && (deapide.getStorageMode()==1||deapide.getStorageMode()==2||deapide.getStorageMode()==4) >
import ${pubPkgCodeName}.core.${deapideModuleCNLC}.filter.${deapideCN}SearchContext;
import ${pubPkgCodeName}.core.${deapideModuleCNLC}.domain.${deapideCN};
import ${pubPkgCodeName}.core.${deapideModuleCNLC}.service.I${deapideCN}Service;
</#if>
</#list>
</#if>
import {{packageName}}.{{apis}}.dto.*;
import {{packageName}}.{{apis}}.mapping.*;
import {{packageName}}.core.{{apiEntity.entity.module}}.domain.{{apiEntity.entity.codeName}};
import {{packageName}}.core.{{apiEntity.entity.module}}.service.I{{apiEntity.entity.codeName}}Service;
import {{packageName}}.core.{{apiEntity.entity.module}}.filter.{{apiEntity.entity.codeName}}SearchContext;
import cn.ibizlab.util.annotation.VersionCheck;
@Slf4j
@Api(tags = {"${deLogicName}" })
<#comment>两个服务接口引用同一个实体时,会产生两个Resource,通过dev模式代理启动两个服务时,会产生bean同名冲突,所以需要进行区分</#comment>
@RestController("${itemSysApiCodeName}-${itemCodeName?lower_case}")
@Api(tags = {"{{apiEntity.entity.logicName}}" })
@RestController("{{apis}}-{{lowerCase apiEntity.codeName}}")
@RequestMapping("")
public class ${itemCodeName}Resource {
public class {{apiEntity.codeName}}Resource {
@Autowired
public I${deCodeName}Service ${deCodeNameLC}Service;
public I{{apiEntity.entity.codeName}}Service service;
@Autowired
@Lazy
public ${itemCodeName}Mapping ${itemCodeNameLC}Mapping;
<#-- 嵌套服务对象 -->
<#if item.getPSDEServiceAPIRSs()??>
<#list item.getPSDEServiceAPIRSs() as apider>
<#assign deapide=apider.getMinorPSDEServiceAPI().getPSDataEntity()>
<#assign deapideCN=deapide.getCodeName()>
<#assign deapideModuleCNLC=deapide.getPSSystemModule().getCodeName()?lower_case>
<#if apider.getMinorPSDEServiceAPI().isNested() && (deapide.getStorageMode()==1||deapide.getStorageMode()==2||deapide.getStorageMode()==4)>
<#if deapideCN != deCodeName>
@Autowired
private I${deapideCN}Service ${deapideCN?lower_case}Service;
</#if>
</#if>
</#list>
</#if>
<#-- 主接口 start -->
<#if item.isMajor()>
<#--<#assign parentPath = "/" + item.getPSSysServiceAPI().getCodeName()?lower_case >-->
<#--<#assign selfPath="/" + srfpluralize(itemCodeNameLC) >-->
<#assign parentPath = "" >
<#assign selfPath= "/" +srfpluralize(itemCodeNameLC) >
<#assign parentParams = "">
<#assign parentSearchParams = "" >
<#assign parentParams2 = "">
<#assign parentParams3 = "">
<#assign idParams = "">
<#assign idParams2 = "">
<#assign idParams3 = "">
<#assign etParams = "">
<#assign etParamsList = "">
<#assign etParams2 = "">
<#assign etParams3 = "">
<#assign id_etParams = "">
<#assign id_etParams_get = "">
<#assign id_etParams4 = "">
<#assign id_etParams4_batch = "">
<#assign etParams = etParams + "@RequestBody " + itemCodeName + "DTO " + itemCodeNameLC + "dto">
<#assign etParamsList = etParamsList + "@RequestBody List<" + itemCodeName + "DTO> " + itemCodeNameLC + "dtos">
<#assign etParams2 = etParams2 + itemCodeName + "DTO " + itemCodeNameLC + "dto">
<#assign etParams3 = etParams3 + itemCodeNameLC + "dto">
<#assign idParams = idParams + "@PathVariable(\"" + itemCodeNameLC + keyCNLC + "\") " + srfr7javatype(de.getKeyPSDEField().getStdDataType()) + " " + itemCodeNameLC + keyCNLC >
<#assign idParams2 = idParams2 + " " + srfr7javatype(de.getKeyPSDEField().getStdDataType()) + " " + itemCodeNameLC + keyCNLC >
<#assign idParams3 = idParams3 + " " + itemCodeNameLC + keyCNLC >
<#assign id_etParams_get = id_etParams + "@PathVariable(\"" + itemCodeNameLC + keyCNLC + "\") " + srfr7javatype(de.getKeyPSDEField().getStdDataType())+" " + itemCodeNameLC + keyCNLC + ", " + itemCodeName + "DTO " + itemCodeNameLC + "dto" >
<#assign id_etParams = id_etParams + "@PathVariable(\"" + itemCodeNameLC + keyCNLC + "\") " + srfr7javatype(de.getKeyPSDEField().getStdDataType())+" " + itemCodeNameLC + keyCNLC + ", @RequestBody " + itemCodeName + "DTO " + itemCodeNameLC + "dto" >
<#assign id_etParams4 = id_etParams4 + "@RequestBody " + itemCodeName + "DTO " + itemCodeNameLC + "dto" >
<#assign id_etParams4_batch = id_etParams4_batch + "@RequestBody List<" + itemCodeName + "DTO> " + itemCodeNameLC + "dtos" >
<#assign dtoCodeName=itemCodeName + "DTO">
<#assign fullPath = parentPath + selfPath>
<#if item.getPSDEServiceAPIMethods()??>
<#list item.getPSDEServiceAPIMethods() as apiMethod>
<#assign reqMtd = apiMethod.getRequestMethod()>
<#assign statusCode = "HttpStatus.OK">
<#if apiMethod.getActionType()=='DEACTION'>
<#assign deaction = apiMethod.getPSDEAction()>
<#assign deactionName = deaction.getName()>
<#assign deactionCodeName = deaction.getCodeName()>
<#assign apiReturnValueType=itemCodeName+"DTO">
<#if apiMethod.getReturnValueType()?? && apiMethod.getReturnValueType()?lower_case =='void' >
<#assign apiReturnValueType = "Void">
</#if>
<#comment>输出主接口测试行为</#comment>
<@outputTestActionDetail deaction/>
<#if deaction.codeName?lower_case == 'create'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "新建${deLogicName}", tags = {"${deLogicName}" }, notes = "新建${deLogicName}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}")
public ResponseEntity<${itemCodeName}DTO> create(@Validated ${etParams}) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
${deCodeNameLC}Service.create(domain);
${itemCodeName}DTO dto = ${itemCodeNameLC}Mapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
<@SecurityBatchAnnotation deaction/>
@ApiOperation(value = "批量新建${deLogicName}", tags = {"${deLogicName}" }, notes = "批量新建${deLogicName}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/batch")
public ResponseEntity<Boolean> createBatch(${etParamsList}) {
${deCodeNameLC}Service.createBatch(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
<#elseif deaction.codeName?lower_case == 'update'>
<@VersionCheckAnnotation/>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "更新${deLogicName}", tags = {"${deLogicName}" }, notes = "更新${deLogicName}")
@RequestMapping(method = RequestMethod.PUT, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
public ResponseEntity<${itemCodeName}DTO> update(${id_etParams}) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
domain .set${dePKCodeName}(${itemCodeNameLC + keyCNLC});
${deCodeNameLC}Service.update(domain );
${itemCodeName}DTO dto = ${itemCodeNameLC}Mapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
<@SecurityBatchAnnotation deaction/>
@ApiOperation(value = "批量更新${deLogicName}", tags = {"${deLogicName}" }, notes = "批量更新${deLogicName}")
@RequestMapping(method = RequestMethod.PUT, value = "${fullPath}/batch")
public ResponseEntity<Boolean> updateBatch(${etParamsList}) {
${deCodeNameLC}Service.updateBatch(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
<#elseif deaction.codeName?lower_case == 'save'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "保存${deLogicName}", tags = {"${deLogicName}" }, notes = "保存${deLogicName}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}")
public ResponseEntity<${itemCodeName}DTO> save(${etParams}) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
${deCodeNameLC}Service.save(domain);
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC}Mapping.toDto(domain));
}
<@SecurityBatchAnnotation deaction/>
@ApiOperation(value = "批量保存${deLogicName}", tags = {"${deLogicName}" }, notes = "批量保存${deLogicName}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/savebatch")
public ResponseEntity<Boolean> saveBatch(${etParamsList}) {
${deCodeNameLC}Service.saveBatch(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
<#elseif deaction.codeName?lower_case == 'remove'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "删除${deLogicName}", tags = {"${deLogicName}" }, notes = "删除${deLogicName}")
@RequestMapping(method = RequestMethod.DELETE, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
public ResponseEntity<Boolean> remove(${idParams}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.remove(${itemCodeNameLC + keyCNLC}));
}
<@SecurityBatchAnnotation deaction/>
@ApiOperation(value = "批量删除${deLogicName}", tags = {"${deLogicName}" }, notes = "批量删除${deLogicName}")
@RequestMapping(method = RequestMethod.DELETE, value = "${fullPath}/batch")
public ResponseEntity<Boolean> removeBatch(@RequestBody List<${srfr7javatype(de.getKeyPSDEField().getStdDataType())}> ids) {
${deCodeNameLC}Service.removeBatch(ids);
public {{apiEntity.codeName}}Mapping mapping;
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-Create-all')")
@ApiOperation(value = "新建{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "新建{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.POST, value = "/{{pluralize apiEntity.codeName}}")
public ResponseEntity<{{apiEntity.codeName}}DTO> create(@Validated @RequestBody {{apiEntity.codeName}}DTO dto) {
{{apiEntity.entity.codeName}} domain = mapping.toDomain(dto);
service.create(domain);
return ResponseEntity.status(HttpStatus.OK).body(mapping.toDto(domain));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-Create-all')")
@ApiOperation(value = "批量新建{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "批量新建{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.POST, value = "/{{pluralize apiEntity.codeName}}/batch")
public ResponseEntity<Boolean> createBatch(@RequestBody List<{{apiEntity.codeName}}DTO> dtos) {
service.createBatch(mapping.toDomain(dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
<#elseif deaction.codeName?lower_case == 'get'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "获取${deLogicName}", tags = {"${deLogicName}" }, notes = "获取${deLogicName}")
@RequestMapping(method = RequestMethod.GET, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
public ResponseEntity<${itemCodeName}DTO> get(${idParams}) {
${deCodeName} domain = ${deCodeNameLC}Service.get(${itemCodeNameLC + keyCNLC});
${itemCodeName}DTO dto = ${itemCodeNameLC}Mapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
<#elseif deaction.codeName?lower_case == 'checkkey'>
@ApiOperation(value = "检查${deLogicName}", tags = {"${deLogicName}" }, notes = "检查${deLogicName}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}")
public ResponseEntity<Boolean> checkKey(${etParams}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.checkKey(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto)));
}
<#elseif deaction.codeName?lower_case == 'getdraft'><#comment>前端支持临时模式,后台不做处理</#comment>
@ApiOperation(value = "获取${deLogicName}草稿", tags = {"${deLogicName}" }, notes = "获取${deLogicName}草稿")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}")
public ResponseEntity<${itemCodeName}DTO> ${deactionCodeName?uncap_first}(${itemCodeName}DTO dto) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(dto);
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC}Mapping.toDto(${deCodeNameLC}Service.getDraft(domain)));
}
<#elseif deaction.codeName?lower_case == 'createbatch'>
<#elseif deaction.codeName?lower_case == 'updatebatch'>
<#elseif deaction.codeName?lower_case == 'removebatch'>
<#elseif deaction.codeName?lower_case == 'savebatch'>
<#elseif deaction.getUserTag()?? && deaction.getActionType()?? && deaction.getUserTag() == 'REGIST' && deaction.getActionType() == 'USERCREATE'>
<#else>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "${deaction.getLogicName()}", tags = {"${deLogicName}" }, notes = "${deaction.getLogicName()}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}<#if deaction.getRequestParamType() == 'NONE'><#else>/{${itemCodeNameLC + keyCNLC}}</#if>/${deactionCodeName?lower_case}")
public ResponseEntity<${apiReturnValueType}> ${deactionCodeName?uncap_first}(<#if deaction.getRequestParamType() == 'NONE'><#else><#if reqMtd?lower_case =='get'>${id_etParams_get}<#else>${id_etParams}</#if></#if>) {
<#if deaction.getRequestParamType() == 'NONE'>
${deCodeName} domain =new ${deCodeName}();
domain = ${deCodeNameLC}Service.${srfmethodname(deactionCodeName)}(domain);
${dtoCodeName} ${itemCodeNameLC}dto = ${itemCodeNameLC}Mapping.toDto(domain);
<#else>
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
domain.set${dePKCodeName}(${itemCodeNameLC + keyCNLC});
domain = ${deCodeNameLC}Service.${srfmethodname(deactionCodeName)}(domain);
${itemCodeNameLC}dto = ${itemCodeNameLC}Mapping.toDto(domain);
</#if>
<#if apiReturnValueType?lower_case =='void'>
return ResponseEntity.status(HttpStatus.OK).build();
<#else>
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC}dto);
</#if>
}
<#comment>自定义行为批处理</#comment>
<#if (deaction.getActionType()=='USERCUSTOM' || deaction.getActionType()=='DELOGIC')>
<@customBatchAction deaction/>
</#if>
</#if>
<#elseif apiMethod.getActionType()=='FETCH'>
<#assign deds = apiMethod.getPSDEDataSet()>
<@DataQuerySecurityAnnotation deds/>
@ApiOperation(value = "获取${deds.getLogicName()}", tags = {"${deLogicName}" } ,notes = "获取${deds.getLogicName()}")
@RequestMapping(method= RequestMethod.${reqMtd} , value="${fullPath}/fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>")
public ResponseEntity<List<<#if deds.isEnableGroup()>Map<#else>${itemCodeName}DTO</#if>>> fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()}<#else>${deds.getCodeName()}</#if>(<#if reqMtd!='GET'>@RequestBody </#if>${deCodeName}SearchContext context) {
<#--${parentSearchParams}-->
<#if deds.isEnableGroup()>
Page<Map> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ;
return ResponseEntity.status(${statusCode})
.header("x-page", String.valueOf(context.getPageable().getPageNumber()))
.header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
.header("x-total", String.valueOf(domains.getTotalElements()))
.body(domains.getContent());
<#else>
Page<${deCodeName}> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ;
List<${itemCodeName}DTO> list = ${itemCodeNameLC}Mapping.toDto(domains.getContent());
return ResponseEntity.status(${statusCode})
.header("x-page", String.valueOf(context.getPageable().getPageNumber()))
.header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
.header("x-total", String.valueOf(domains.getTotalElements()))
.body(list);
</#if>
}
<@DataQuerySecurityAnnotation deds/>
@ApiOperation(value = "查询${deds.getLogicName()}", tags = {"${deLogicName}" } ,notes = "查询${deds.getLogicName()}")
@RequestMapping(method= RequestMethod.POST , value="${fullPath}/search<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>")
public ResponseEntity<Page<<#if deds.isEnableGroup()>Map<#else>${itemCodeName}DTO</#if>>> search<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()}<#else>${deds.getCodeName()}</#if>(@RequestBody ${deCodeName}SearchContext context) {
<#--${parentSearchParams}-->
<#if deds.isEnableGroup()>
Page<Map> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ;
return ResponseEntity.status(${statusCode})
.body(new PageImpl(domains.getContent(), context.getPageable(), domains.getTotalElements()));
<#else>
Page<${deCodeName}> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ;
return ResponseEntity.status(${statusCode})
.body(new PageImpl(${itemCodeNameLC}Mapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
</#if>
}
<#if de.getUserTag()?? && de.getUserTag()=='elasticsearch'>
<@DataQuerySecurityAnnotation deds/>
@ApiOperation(value = "获取${deds.getLogicName()}", tags = {"${deLogicName}" } ,notes = "获取${deds.getLogicName()}")
@RequestMapping(method= RequestMethod.${reqMtd} , value="${fullPath}/fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>/es")
public ResponseEntity<List<${itemCodeName}DTO>> esFetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()}<#else>${deds.getCodeName()}</#if>(${deCodeName}SearchContext context) {
Page<{{packageName}}.core.es.domain.${item.codeName}> domains = esService.search${deds.getCodeName()}(context) ;
List<${itemCodeName}DTO> list = ${itemCodeNameLC}Mapping.toDto(esMapping.toDomain(domains.getContent()));
return ResponseEntity.status(${statusCode})
.header("x-page", String.valueOf(context.getPageable().getPageNumber()))
.header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
.header("x-total", String.valueOf(domains.getTotalElements()))
.body(list);
}
</#if>
</#if>
</#list>
</#if>
<#comment>es get行为</#comment>
<#if de.getUserTag()?? && de.getUserTag()=='elasticsearch'>
@Autowired
@Lazy
{{packageName}}.core.es.service.I${de.codeName}ESService esService;
@Autowired
@Lazy
{{packageName}}.core.${de.getPSSystemModule().codeName?lower_case}.mapping.${de.codeName}ESMapping esMapping;
@PostAuthorize("hasPermission(this.${itemCodeNameLC}Mapping.toDomain(returnObject.body),'${sys.codeName}-${de.codeName}-Get')")
@ApiOperation(value = "获取${deLogicName}", tags = {"${deLogicName}" }, notes = "获取${deLogicName}")
@RequestMapping(method = RequestMethod.GET, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/es")
public ResponseEntity<${itemCodeName}DTO> esGet(${idParams}) {
{{packageName}}.core.es.domain.${item.codeName} domain = esService.get(${itemCodeNameLC + keyCNLC});
${itemCodeName}DTO dto = ${itemCodeNameLC}Mapping.toDto(esMapping.toDomain(domain));
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-Get-all')")
@ApiOperation(value = "获取{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "获取{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.GET, value = "/{{pluralize apiEntity.codeName}}/{id}")
public ResponseEntity<{{apiEntity.codeName}}DTO> get(@PathVariable("id") {{apiEntity.entity.keyField.type.java}} id) {
{{apiEntity.entity.codeName}} domain = service.get(id);
{{apiEntity.codeName}}DTO dto = mapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
</#if>
<#comment>动态行为服务接口</#comment>
<#if pub.isEnableDynaModel()?? && pub.isEnableDynaModel()== true>
<#assign dynamic_id_Params ="@PathVariable(\"" + itemCodeNameLC + keyCNLC + "\") " + srfr7javatype(de.getKeyPSDEField().getStdDataType())+" " + itemCodeNameLC + keyCNLC +" , @PathVariable(\"action\") String action , @RequestBody " + itemCodeName + "DTO " + itemCodeNameLC + "dto" >
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN')")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/{action}")
public ResponseEntity<${itemCodeName}DTO> dynamicCall(${dynamic_id_Params}) {
${deCodeName} domain = ${deCodeNameLC}Service.dynamicCall(${itemCodeNameLC + keyCNLC}, action, ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC + "dto"}));
${itemCodeNameLC}dto = ${itemCodeNameLC}Mapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC + "dto"});
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-Remove-all')")
@ApiOperation(value = "删除{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "删除{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.DELETE, value = "/{{pluralize apiEntity.codeName}}/{id}")
public ResponseEntity<Boolean> remove(@PathVariable("id") {{apiEntity.entity.keyField.type.java}} id) {
return ResponseEntity.status(HttpStatus.OK).body(service.remove(id));
}
</#if>
</#if>
<#-- 主接口 end -->
<#-- 关系接口 start -->
<#if item.getPSDEServiceAPIRSPathCount() gt 0>
<#list 0..1000 as x>
<#if x gte item.getPSDEServiceAPIRSPathCount()>
<#break>
<#else>
<#assign parentPath = "">
<#assign selfPath="/" + srfpluralize(itemCodeNameLC) >
<#assign parentParams = "">
<#assign byParams = "By">
<#assign byTagParams = "根据">
<#assign parentSearchParams = "" >
<#assign parentSetParams = "" >
<#assign parentParams2 = "">
<#assign parentParams3 = "">
<#assign idParams = "">
<#assign idParams2 = "">
<#assign idParams3 = "">
<#assign etParams = "">
<#assign etParamsList = "">
<#assign etParams2 = "">
<#assign etParams3 = "">
<#assign id_etParams = "">
<#assign id_etParams_get= "">
<#assign id_etParams4 = "">
<#assign id_etParams4_batch = "">
<#assign apiRsPathLast = item.getPSDEServiceAPIRSPathLast(x)>
<#list item.getPSDEServiceAPIRSPath(x) as rs>
<#assign rsMainDEServiceAPI = rs.getMajorPSDEServiceAPI()>
<#assign rsMainDe = rsMainDEServiceAPI.getPSDataEntity()>
<#assign rsMainDeCN = rsMainDe.codeName >
<#assign rsMainDeLogicName = rsMainDe.getLogicName() >
<#assign rsMainDeCNLC = rsMainDeCN?lower_case >
<#assign rsMainDePKCN = rsMainDe.getKeyPSDEField().codeName >
<#assign rsMainDePKCNLC = rsMainDePKCN?lower_case >
<#assign rsMainDePKDataType = rsMainDe.getKeyPSDEField().getStdDataType() >
<#assign parentPath += "/" + srfpluralize(rsMainDEServiceAPI.codeName)?lower_case + "/{" + rsMainDeCNLC + keyCNLC + "}" >
<#if rs_index != 0 && parentParams!= "">
<#assign parentParams += ", ">
</#if>
<#assign parentParams += "@PathVariable(\"" + rsMainDeCNLC + keyCNLC + "\") " + srfr7javatype(rsMainDePKDataType) + " " + rsMainDeCNLC + keyCNLC >
<#assign byParams += rsMainDeCN >
<#assign byTagParams += rsMainDeLogicName >
<#if rs.getPSDER1N()?? && apiRsPathLast.getCodeName() == rs.getCodeName()>
<#assign parentSearchParams += "context.setN_" + rs.getPSDER1N().getPSPickupDEField().getName()?lower_case + "_eq("+ rsMainDeCNLC + keyCNLC +");" >
<#assign parentSetParams += "domain.set" + srfr7templcaseformat(rs.getPSDER1N().getPSPickupDEField().getCodeName())?cap_first + "("+ rsMainDeCNLC + keyCNLC +");" >
</#if>
<#assign parentParams2 += "" + srfr7javatype(rsMainDePKDataType)+" " + rsMainDeCNLC + keyCNLC >
<#assign parentParams3 += "" + rsMainDeCNLC + keyCNLC >
</#list>
<#if parentParams != "" >
<#assign idParams = parentParams + ", ">
<#assign idParams2 = parentParams2 + ", ">
<#assign idParams3 = parentParams3 + ", ">
<#assign etParams = parentParams + ", ">
<#assign etParamsList = parentParams + ", ">
<#assign etParams2 = parentParams2 + ", ">
<#assign etParams3 = parentParams3 + ", ">
<#assign id_etParams = parentParams + ", ">
<#assign id_etParams4 = parentParams + ", ">
<#assign id_etParams4_batch = parentParams + ", ">
</#if>
<#assign etParams = etParams + "@RequestBody " + itemCodeName + "DTO " + itemCodeNameLC + "dto">
<#assign etParamsList = etParamsList + "@RequestBody List<" + itemCodeName + "DTO> " + itemCodeNameLC + "dtos">
<#assign etParams2 = etParams2 + itemCodeName + "DTO " + itemCodeNameLC + "dto">
<#assign etParams3 = etParams3 + itemCodeNameLC + "dto">
<#assign idParams = idParams + "@PathVariable(\"" + itemCodeNameLC + keyCNLC + "\") " + srfr7javatype(de.getKeyPSDEField().getStdDataType()) + " " + itemCodeNameLC + keyCNLC >
<#assign idParams2 = idParams2 + " " + srfr7javatype(de.getKeyPSDEField().getStdDataType()) + " " + itemCodeNameLC + keyCNLC >
<#assign idParams3 = idParams3 + " " + itemCodeNameLC + keyCNLC >
<#assign id_etParams_get = id_etParams + "@PathVariable(\"" + itemCodeNameLC + keyCNLC + "\") " + srfr7javatype(de.getKeyPSDEField().getStdDataType())+" " + itemCodeNameLC + keyCNLC + ", " + itemCodeName + "DTO " + itemCodeNameLC + "dto" >
<#assign id_etParams = id_etParams + "@PathVariable(\"" + itemCodeNameLC + keyCNLC + "\") " + srfr7javatype(de.getKeyPSDEField().getStdDataType())+" " + itemCodeNameLC + keyCNLC + ", @RequestBody " + itemCodeName + "DTO " + itemCodeNameLC + "dto" >
<#assign id_etParams4 = id_etParams4 + "@RequestBody " + itemCodeName + "DTO " + itemCodeNameLC + "dto" >
<#assign id_etParams4_batch = id_etParams4_batch + "@RequestBody List<" + itemCodeName + "DTO> " + itemCodeNameLC + "dtos" >
<#assign fullPath = parentPath + selfPath>
<#if item.getPSDEServiceAPIMethods()??>
<#list item.getPSDEServiceAPIMethods() as apiMethod>
<#assign reqMtd = apiMethod.getRequestMethod()>
<#assign statusCode = "HttpStatus.OK" >
<#if apiMethod.getActionType()=='DEACTION'>
<#assign deaction = apiMethod.getPSDEAction()>
<#assign deactionName = deaction.getName()>
<#assign deactionCodeName = deaction.getCodeName()>
<#assign apiReturnValueType=itemCodeName+"DTO">
<#if apiMethod.getReturnValueType()?? && apiMethod.getReturnValueType()?lower_case =='void' >
<#assign apiReturnValueType = "Void">
</#if>
<#comment>输出从接口测试行为</#comment>
<@outputTestActionDetail2 deaction/>
<#if deaction.codeName?lower_case == 'create'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "${byTagParams}建立${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}建立${deLogicName}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}")
public ResponseEntity<${itemCodeName}DTO> ${deactionCodeName?uncap_first}${byParams}(${etParams}) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
${parentSetParams}
${deCodeNameLC}Service.create(domain);
${itemCodeName}DTO dto = ${itemCodeNameLC}Mapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
<@SecurityBatchAnnotation deaction/>
@ApiOperation(value = "${byTagParams}批量建立${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}批量建立${deLogicName}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/batch")
public ResponseEntity<Boolean> createBatch${byParams}(${etParamsList}) {
List<${deCodeName}> domainlist=${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos);
for(${deCodeName} domain:domainlist){
${parentSetParams}
}
${deCodeNameLC}Service.createBatch(domainlist);
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-Remove-all')")
@ApiOperation(value = "批量删除{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "批量删除{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.DELETE, value = "/{{pluralize apiEntity.codeName}}/batch")
public ResponseEntity<Boolean> removeBatch(@RequestBody List<{{apiEntity.entity.keyField.type.java}}> ids) {
service.removeBatch(ids);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
<#elseif deaction.codeName?lower_case == 'update'>
<@VersionCheckAnnotation/>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "${byTagParams}更新${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}更新${deLogicName}")
@RequestMapping(method = RequestMethod.PUT, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
public ResponseEntity<${itemCodeName}DTO> ${deactionCodeName?uncap_first}${byParams}(${id_etParams}) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
${parentSetParams}
domain.set${dePKCodeName}(${itemCodeNameLC + keyCNLC});
${deCodeNameLC}Service.update(domain);
${itemCodeName}DTO dto = ${itemCodeNameLC}Mapping.toDto(domain);
<#--
<#if item.getPSDEServiceAPIRSs()??>
<#list item.getPSDEServiceAPIRSs() as apider>
<#assign deMinApi = apider.getMinorPSDEServiceAPI()>
<#assign deMinApiCN = deMinApi.getCodeName()>
<#assign deMinApiCNLC = deMinApi.getCodeName()?lower_case>
<#assign deapide=deMinApi.getPSDataEntity()>
<#if deMinApi.isNested()>
<#assign subDTOs = srfpluralize(deMinApiCN)?lower_case >
List<${deMinApiCN}DTO> ${deMinApiCNLC}dtos = ${itemCodeNameLC}dto.get${subDTOs?cap_first}();
Page<${deapide.getCodeName()}> ${deMinApiCNLC}DOs = ${deapide.getCodeName()?lower_case}Service.selectBy${apider.getPSDER1N().getCodeName()}(${itemCodeNameLC + keyCNLC});
List<${srfr7javatype(deapide.getKeyPSDEField().getStdDataType())}> ${deMinApiCNLC}Ids = new ArrayList<${srfr7javatype(deapide.getKeyPSDEField().getStdDataType())}>();
if (${deMinApiCNLC}DOs != null && !${deMinApiCNLC}DOs.isEmpty()) {
for (${deapide.getCodeName()} minorDO : ${deMinApiCNLC}DOs) {
${deMinApiCNLC}Ids.add(minorDO.get${deapide.getKeyPSDEField().getCodeName()?cap_first}());
}
}
List<${deMinApiCN}DTO> ${deMinApiCNLC}dtos2 = new ArrayList<${deapide.getCodeName()}DTO>();
if (${deapide.getCodeName()?lower_case}dtos != null && ${deapide.getCodeName()?lower_case}dtos.size() > 0) {
for (${deMinApiCN}DTO ${deapide.getCodeName()?lower_case}dto : ${deapide.getCodeName()?lower_case}dtos) {
${deapide.getCodeName()} ${deapide.getCodeName()?lower_case}Do = ${deapide.getCodeName()?lower_case}dto.toDO();
${deapide.getCodeName()?lower_case}Do.set${dePKCodeName?cap_first}(dto.get${dePKCodeName?cap_first}());
if ( StringUtils.isEmpty( ${deapide.getCodeName()?lower_case}Do.get${deapide.getKeyPSDEField().getCodeName()?cap_first}()) || (${deMinApiCNLC}Ids != null && !${deMinApiCNLC}Ids.isEmpty() && ${deMinApiCNLC}Ids.contains(${deapide.getCodeName()?lower_case}Do.get${deapide.getKeyPSDEField().getCodeName()?cap_first}()))) {
${deapide.getCodeName()?lower_case}Service.save(${deapide.getCodeName()?lower_case}Do);
${deapide.getCodeName()?lower_case}dto.fromDO(${deapide.getCodeName()?lower_case}Do);
${deapide.getCodeName()?lower_case}dtos2.add(${deapide.getCodeName()?lower_case}dto);
} else {
${deapide.getCodeName()?lower_case}Service.remove(${deapide.getCodeName()?lower_case}Do.get${deapide.getKeyPSDEField().getCodeName()?cap_first}());
}
}
} else {
${deapide.getCodeName()?lower_case}dtos2 = ${deapide.getCodeName()?lower_case}dtos;
}
dto.set${subDTOs?cap_first}(${deapide.getCodeName()?lower_case}dtos2);
</#if>
</#list>
</#if>
-->
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
<@SecurityBatchAnnotation deaction/>
@ApiOperation(value = "${byTagParams}批量更新${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}批量更新${deLogicName}")
@RequestMapping(method = RequestMethod.PUT, value = "${fullPath}/batch")
public ResponseEntity<Boolean> updateBatch${byParams}(${etParamsList}) {
List<${deCodeName}> domainlist=${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos);
for(${deCodeName} domain:domainlist){
${parentSetParams}
}
${deCodeNameLC}Service.updateBatch(domainlist);
{{#if apiEntity.entity.lastModifyField}}
@VersionCheck(entity = "{{lowerCase apiEntity.entity.codeName}}" , versionfield = "{{camelCase apiEntity.entity.lastModifyField.codeName}}")
{{/if}}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-Update-all')")
@ApiOperation(value = "更新{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "更新{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.PUT, value = "/{{pluralize apiEntity.codeName}}/{id}")
public ResponseEntity<{{apiEntity.codeName}}DTO> update(@PathVariable("id") {{apiEntity.entity.keyField.type.java}} id, @RequestBody {{apiEntity.codeName}}DTO dto) {
{{apiEntity.entity.codeName}} domain = mapping.toDomain(dto);
domain.set{{pascalCase apiEntity.entity.keyField.codeName}}(id);
service.update(domain);
return ResponseEntity.status(HttpStatus.OK).body(mapping.toDto(domain));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-Update-all')")
@ApiOperation(value = "批量更新{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "批量更新{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.PUT, value = "/{{pluralize apiEntity.codeName}}/batch")
public ResponseEntity<Boolean> updateBatch(@RequestBody List<{{apiEntity.codeName}}DTO> dtos) {
service.updateBatch(mapping.toDomain(dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
<#elseif deaction.codeName?lower_case == 'remove'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "${byTagParams}删除${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}删除${deLogicName}")
@RequestMapping(method = RequestMethod.DELETE, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
public ResponseEntity<Boolean> ${deactionCodeName?uncap_first}${byParams}(${idParams}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.remove(${itemCodeNameLC + keyCNLC}));
@ApiOperation(value = "检查{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "检查{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.POST, value = "/{{pluralize apiEntity.codeName}}/checkkey")
public ResponseEntity<Boolean> checkKey(@RequestBody {{apiEntity.codeName}}DTO dto) {
return ResponseEntity.status(HttpStatus.OK).body(service.checkKey(mapping.toDomain(dto)));
}
<@SecurityBatchAnnotation deaction/>
@ApiOperation(value = "${byTagParams}批量删除${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}批量删除${deLogicName}")
@RequestMapping(method = RequestMethod.DELETE, value = "${fullPath}/batch")
public ResponseEntity<Boolean> removeBatch${byParams}(@RequestBody List<${srfr7javatype(de.getKeyPSDEField().getStdDataType())}> ids) {
${deCodeNameLC}Service.removeBatch(ids);
return ResponseEntity.status(HttpStatus.OK).body(true);
@ApiOperation(value = "获取{{apiEntity.entity.logicName}}草稿", tags = {"{{apiEntity.entity.logicName}}" }, notes = "获取{{apiEntity.entity.logicName}}草稿")
@RequestMapping(method = RequestMethod.GET, value = "/{{pluralize apiEntity.codeName}}/getdraft")
public ResponseEntity<{{apiEntity.codeName}}DTO> getDraft({{apiEntity.codeName}}DTO dto) {
{{apiEntity.entity.codeName}} domain = mapping.toDomain(dto);
return ResponseEntity.status(HttpStatus.OK).body(mapping.toDto(service.getDraft(domain)));
}
<#elseif deaction.codeName?lower_case == 'save'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "${byTagParams}保存${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}保存${deLogicName}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}")
public ResponseEntity<${itemCodeName}DTO> ${deactionCodeName?uncap_first}${byParams}(${etParams}) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
${parentSetParams}
${deCodeNameLC}Service.save(domain);
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC}Mapping.toDto(domain));
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-Save-all')")
@ApiOperation(value = "保存{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "保存{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.POST, value = "/{{pluralize apiEntity.codeName}}/save")
public ResponseEntity<{{apiEntity.codeName}}DTO> save(@RequestBody {{apiEntity.codeName}}DTO dto) {
{{apiEntity.entity.codeName}} domain = mapping.toDomain(dto);
service.save(domain);
return ResponseEntity.status(HttpStatus.OK).body(mapping.toDto(domain));
}
<@SecurityBatchAnnotation deaction/>
@ApiOperation(value = "${byTagParams}批量保存${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}批量保存${deLogicName}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/savebatch")
public ResponseEntity<Boolean> saveBatch${byParams}(${etParamsList}) {
List<${deCodeName}> domainlist=${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos);
for(${deCodeName} domain:domainlist){
${parentSetParams}
}
${deCodeNameLC}Service.saveBatch(domainlist);
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-Save-all')")
@ApiOperation(value = "批量保存{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "批量保存{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.POST, value = "/{{pluralize apiEntity.codeName}}/savebatch")
public ResponseEntity<Boolean> saveBatch(@RequestBody List<{{apiEntity.codeName}}DTO> dtos) {
service.saveBatch(mapping.toDomain(dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
<#elseif deaction.codeName?lower_case == 'get'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "${byTagParams}获取${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}获取${deLogicName}")
@RequestMapping(method = RequestMethod.GET, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
public ResponseEntity<${itemCodeName}DTO> ${deactionCodeName?uncap_first}${byParams}(${idParams}) {
${deCodeName} domain = ${deCodeNameLC}Service.get(${itemCodeNameLC + keyCNLC});
${itemCodeName}DTO dto = ${itemCodeNameLC}Mapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
<#elseif deaction.codeName?lower_case == 'checkkey'>
@ApiOperation(value = "${byTagParams}检查${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}检查${deLogicName}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}")
public ResponseEntity<Boolean> ${deactionCodeName?uncap_first}${byParams}(${etParams}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.checkKey(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto)));
}
{{#each apiEntity.entity.dataSets as |dataSet|}}
<#elseif deaction.codeName?lower_case == 'getdraft'>
@ApiOperation(value = "${byTagParams}获取${deLogicName}草稿", tags = {"${deLogicName}" }, notes = "${byTagParams}获取${deLogicName}草稿")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}")
public ResponseEntity<${itemCodeName}DTO> ${deactionCodeName?uncap_first}${byParams}(${parentParams}, ${itemCodeName}DTO dto) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(dto);
${parentSetParams}
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC}Mapping.toDto(${deCodeNameLC}Service.getDraft(domain)));
}
<#elseif deaction.codeName?lower_case == 'createbatch'>
<#elseif deaction.codeName?lower_case == 'updatebatch'>
<#elseif deaction.codeName?lower_case == 'removebatch'>
<#elseif deaction.codeName?lower_case == 'savebatch'>
<#elseif deaction.getUserTag()?? && deaction.getActionType()?? && deaction.getUserTag() == 'REGIST' && deaction.getActionType() == 'USERCREATE'>
<#else>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "${byTagParams}${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}${deLogicName}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}<#if deaction.getRequestParamType() == 'NONE'><#else>/{${itemCodeNameLC + keyCNLC}}</#if>/${deactionCodeName?lower_case}")
public ResponseEntity<${apiReturnValueType}> ${deactionCodeName?uncap_first}${byParams}(<#if deaction.getRequestParamType() == 'NONE'><#else><#if reqMtd?lower_case =='get'>${id_etParams_get}<#else>${id_etParams}</#if></#if>) {
<#if deaction.getRequestParamType() == 'NONE'>
${deCodeName} domain =new ${deCodeName}();
domain = ${deCodeNameLC}Service.${srfmethodname(deactionCodeName)}(domain) ;
${dtoCodeName} ${itemCodeNameLC}dto = ${itemCodeNameLC}Mapping.toDto(domain);
<#else>
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
${parentSetParams}
domain = ${deCodeNameLC}Service.${srfmethodname(deactionCodeName)}(domain) ;
${itemCodeNameLC}dto = ${itemCodeNameLC}Mapping.toDto(domain);
</#if>
<#if apiReturnValueType?lower_case =='void'>
return ResponseEntity.status(HttpStatus.OK).build();
<#else>
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC}dto);
</#if>
}
<#comment>自定义行为批处理</#comment>
<#if (deaction.getActionType()=='USERCUSTOM' || deaction.getActionType()=='DELOGIC')>
<@customBatchActionRS deaction/>
</#if>
</#if>
<#elseif apiMethod.getActionType()=='FETCH'>
<#assign deds = apiMethod.getPSDEDataSet()>
<@DataQuerySecurityAnnotation deds/>
@ApiOperation(value = "${byTagParams}获取${deds.getLogicName()}", tags = {"${deLogicName}" } ,notes = "${byTagParams}获取${deds.getLogicName()}")
@RequestMapping(method= RequestMethod.${reqMtd} , value="${fullPath}/fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>")
public ResponseEntity<List<<#if deds.isEnableGroup()>Map<#else>${itemCodeName}DTO</#if>>> fetch${itemCodeName}<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()}<#else>${deds.getCodeName()}</#if>${byParams}(<#if parentParams!="">${parentParams},</#if><#if reqMtd!='GET'>@RequestBody </#if>${deCodeName}SearchContext context) {
${parentSearchParams}
<#if deds.isEnableGroup()>
Page<Map> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ;
return ResponseEntity.status(${statusCode})
@ApiOperation(value = "获取{{dataSet.name}}", tags = {"{{apiEntity.entity.logicName}}" } ,notes = "获取{{dataSet.name}}")
@RequestMapping(method= RequestMethod.GET , value="/{{pluralize apiEntity.codeName}}/fetch{{lowerCase dataSet.codeName}}")
{{#if dataSet.enableGroup}}
public ResponseEntity<List<Map>> fetch{{dataSet.codeName}}({{apiEntity.entity.codeName}}SearchContext context) {
Page<Map> page = service.search{{dataSet.codeName}}(context) ;
return ResponseEntity.status(HttpStatus.OK)
.header("x-page", String.valueOf(context.getPageable().getPageNumber()))
.header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
.header("x-total", String.valueOf(domains.getTotalElements()))
.body(domains.getContent());
<#else>
Page<${deCodeName}> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ;
List<${itemCodeName}DTO> list = ${itemCodeNameLC}Mapping.toDto(domains.getContent());
return ResponseEntity.status(${statusCode})
.header("x-total", String.valueOf(page.getTotalElements()))
.body(page.getContent());
}
{{else}}
public ResponseEntity<List<{{apiEntity.codeName}}DTO>> fetch{{dataSet.codeName}}({{apiEntity.entity.codeName}}SearchContext context) {
Page<{{apiEntity.entity.codeName}}> domains = service.search{{dataSet.codeName}}(context) ;
List<{{apiEntity.codeName}}DTO> list = mapping.toDto(domains.getContent());
return ResponseEntity.status(HttpStatus.OK)
.header("x-page", String.valueOf(context.getPageable().getPageNumber()))
.header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
.header("x-total", String.valueOf(domains.getTotalElements()))
.body(list);
</#if>
}
<@DataQuerySecurityAnnotation deds/>
@ApiOperation(value = "${byTagParams}查询${deds.getLogicName()}", tags = {"${deLogicName}" } ,notes = "${byTagParams}查询${deds.getLogicName()}")
@RequestMapping(method= RequestMethod.POST , value="${fullPath}/search<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>")
public ResponseEntity<Page<<#if deds.isEnableGroup()>Map<#else>${itemCodeName}DTO</#if>>> search${itemCodeName}<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()}<#else>${deds.getCodeName()}</#if>${byParams}(<#if parentParams!="">${parentParams}, @RequestBody </#if>${deCodeName}SearchContext context) {
${parentSearchParams}
<#if deds.isEnableGroup()>
Page<Map> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ;
return ResponseEntity.status(${statusCode})
.body(new PageImpl(domains.getContent(), context.getPageable(), domains.getTotalElements()));
<#else>
Page<${deCodeName}> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ;
return ResponseEntity.status(${statusCode})
.body(new PageImpl(${itemCodeNameLC}Mapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
</#if>
}
</#if>
</#list>
</#if>
</#if>
</#list>
</#if>
<#comment>实体数据导入</#comment>
<#if hasDEImport>
<#list de.getAllPSDEDataImports() as deImport>
@Autowired
{{packageName}}.core.${de.getPSSystemModule().codeName?lower_case}.mapping.${deCodeName}${deImport.codeName} ${deImport.codeName?lower_case}ImpMapping;
</#list>
@RequestMapping(method = RequestMethod.POST, value = "/${srfpluralize(itemCodeNameLC)}/import")
public ResponseEntity<JSONObject> importData(@RequestParam(value = "config") String config , @RequestBody List<${deCodeName}> dtos){
JSONObject rs=new JSONObject();
if(dtos.size()==0){
rs.put("rst", 1);
rs.put("msg", "未传入内容");
return ResponseEntity.status(HttpStatus.NO_CONTENT).body(rs);
}
else{
<#list de.getAllPSDEDataImports() as deImport>
<#if deImport_index==0>
if("${deImport.codeName}".equals(config)){
rs=${deCodeNameLC}Service.importData(${deImport.codeName?lower_case}ImpMapping.toDomain(dtos),${deImport.getBatchSize()?c},${deImport.isIgnoreError()?c});
}
<#else>
else if("${deImport.codeName}".equals(config)){
rs=${deCodeNameLC}Service.importData(${deImport.codeName?lower_case}ImpMapping.toDomain(dtos),${deImport.getBatchSize()?c},${deImport.isIgnoreError()?c});
}
</#if>
</#list>
return ResponseEntity.status(HttpStatus.OK).body(rs);
}
}
</#if>
}
</#if>
</#if>
<#comment>数据查询Security权限校验(分组不鉴权、配置[NONE]操作标识不鉴权)</#comment>
<#macro DataQuerySecurityAnnotation dataset>
<#if ((dataset.getPSDEOPPriv().getName())!'')!='NONE' >
<#if (de.getStorageMode()==1 || de.getStorageMode()==2 ||de.getStorageMode()==4) && dataset.isEnableGroup()==false>
<#if hasDEPrefield==false>
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','${sys.codeName}-${de.codeName}-search${dataset.codeName}-all')")
<#else>
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','${sys.codeName}-${de.codeName}-search${dataset.codeName}-all') and hasPermission(#context,'${sys.codeName}-${de.codeName}-Get')")
</#if>
</#if>
</#if>
</#macro>
<#comment>单条数据Security权限校验(配置[NONE]操作标识不鉴权)</#comment>
<#macro SecurityAnnotation deaction>
<#if ((deaction.getPSDEOPPriv().getName())!'')!='NONE' >
<#if de.getStorageMode()==1 || de.getStorageMode()==2 ||de.getStorageMode()==4>
<#if hasDEPrefield==false>
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','${sys.codeName}-${de.codeName}-${deaction.codeName}-all')")
<#else>
<#if deaction.codeName?lower_case=='create' || deaction.codeName?lower_case=='save'>
@PreAuthorize("hasPermission(this.${itemCodeNameLC}Mapping.toDomain(#${itemCodeNameLC}dto),'${sys.codeName}-${de.codeName}-${deaction.codeName}')")
<#elseif deaction.codeName?lower_case=='update' || deaction.codeName?lower_case=='remove'>
@PreAuthorize("hasPermission(this.${deCodeNameLC}Service.get(#${itemCodeNameLC + keyCNLC}),'${sys.codeName}-${de.codeName}-${deaction.codeName}')")
<#elseif deaction.codeName?lower_case=='get'>
@PostAuthorize("hasPermission(this.${itemCodeNameLC}Mapping.toDomain(returnObject.body),'${sys.codeName}-${de.codeName}-${deaction.codeName}')")
<#else>
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','${sys.codeName}-${de.codeName}-${deaction.codeName}-all')")
</#if>
</#if>
</#if>
</#if>
</#macro>
<#comment>批量数据Security权限校验(配置[NONE]操作标识不鉴权)</#comment>
<#macro SecurityBatchAnnotation deaction>
<#if ((deaction.getPSDEOPPriv().getName())!'')!='NONE' >
<#if de.getStorageMode()==1 || de.getStorageMode()==2 ||de.getStorageMode()==4>
<#if hasDEPrefield==false>
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','${sys.codeName}-${de.codeName}-${deaction.codeName}-all')")
<#else>
<#if deaction.codeName?lower_case=='remove'>
@PreAuthorize("hasPermission(this.${deCodeNameLC}Service.get${deCodeNameCamel}ByIds(#ids),'${sys.codeName}-${de.codeName}-${deaction.codeName}')")
<#elseif deaction.codeName?lower_case=='update'>
@PreAuthorize("hasPermission(this.${deCodeNameLC}Service.get${deCodeNameCamel}ByEntities(this.${itemCodeNameLC}Mapping.toDomain(#${itemCodeNameLC}dtos)),'${sys.codeName}-${de.codeName}-${deaction.codeName}')")
<#else>
@PreAuthorize("hasPermission(this.${itemCodeNameLC}Mapping.toDomain(#${itemCodeNameLC}dtos),'${sys.codeName}-${de.codeName}-${deaction.codeName}')")
</#if>
</#if>
</#if>
</#if>
</#macro>
<#comment>数据库版本检查注解</#comment>
<#macro VersionCheckAnnotation>
<#if item.getPSDEServiceAPIFields()??>
<#list item.getPSDEServiceAPIFields() as apifield>
<#if apifield.getPSDEField?? && apifield.getPSDEField()??>
<#assign defield=apifield.getPSDEField()>
<#if defield.getPredefinedType?? && defield.getPredefinedType()??>
<#if defield.getPredefinedType()=='UPDATEDATE'>
<#assign updatedateField=srfr7templcaseformat(defield.codeName)>
@VersionCheck(entity = "${deCodeNameLC}" , versionfield = "${updatedateField}")
<#break>
</#if>
</#if>
</#if>
</#list>
</#if>
</#macro>
<#comment>输出主接口测试行为</#comment>
<#macro outputTestActionDetail deaction>
<#if deaction.getTestActionMode?? && deaction.getTestActionMode()?? && (deaction.getTestActionMode() ==3) >
<#assign deactionName = deaction.getName()>
<#assign deactionCodeName = deaction.getCodeName()>
<#if deaction.codeName?lower_case == 'create'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "新建${deLogicName}", tags = {"${deLogicName}" }, notes = "新建${deLogicName}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/test")
public ResponseEntity<Boolean> testCreate(${etParams}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testCreate(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto)));
}
<@SecurityBatchAnnotation deaction/>
@ApiOperation(value = "批量新建${deLogicName}", tags = {"${deLogicName}" }, notes = "批量新建${deLogicName}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/batch/test")
public ResponseEntity<Boolean> testCreateBatch(${etParamsList}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testCreateBatch(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos)));
}
<#elseif deaction.codeName?lower_case == 'update'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "更新${deLogicName}", tags = {"${deLogicName}" }, notes = "更新${deLogicName}")
@RequestMapping(method = RequestMethod.PUT, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/test")
public ResponseEntity<Boolean> testUpdate(${id_etParams}) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
domain .set${dePKCodeName}(${itemCodeNameLC + keyCNLC});
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testUpdate(domain));
}
<@SecurityBatchAnnotation deaction/>
@ApiOperation(value = "批量更新${deLogicName}", tags = {"${deLogicName}" }, notes = "批量更新${deLogicName}")
@RequestMapping(method = RequestMethod.PUT, value = "${fullPath}/batch/test")
public ResponseEntity<Boolean> testUpdateBatch(${etParamsList}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testUpdateBatch(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos)));
}
<#elseif deaction.codeName?lower_case == 'save'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "保存${deLogicName}", tags = {"${deLogicName}" }, notes = "保存${deLogicName}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}/test")
public ResponseEntity<Boolean> testSave(${etParams}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testSave(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto)));
}
<@SecurityBatchAnnotation deaction/>
@ApiOperation(value = "批量保存${deLogicName}", tags = {"${deLogicName}" }, notes = "批量保存${deLogicName}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/savebatch/test")
public ResponseEntity<Boolean> testSaveBatch(${etParamsList}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testSaveBatch(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos)));
}
<#elseif deaction.codeName?lower_case == 'remove'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "删除${deLogicName}", tags = {"${deLogicName}" }, notes = "删除${deLogicName}")
@RequestMapping(method = RequestMethod.DELETE, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/test")
public ResponseEntity<Boolean> testRemove(${idParams}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testRemove(${itemCodeNameLC + keyCNLC}));
}
<@SecurityBatchAnnotation deaction/>
@ApiOperation(value = "批量删除${deLogicName}", tags = {"${deLogicName}" }, notes = "批量删除${deLogicName}")
@RequestMapping(method = RequestMethod.DELETE, value = "${fullPath}/batch/test")
public ResponseEntity<Boolean> testRemoveBatch(@RequestBody List<${srfr7javatype(de.getKeyPSDEField().getStdDataType())}> ids) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testRemoveBatch(ids));
}
{{/if}}
<#elseif deaction.codeName?lower_case == 'get'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "获取${deLogicName}", tags = {"${deLogicName}" }, notes = "获取${deLogicName}")
@RequestMapping(method = RequestMethod.GET, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/test")
public ResponseEntity<Boolean> testGet(${idParams}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testGet(${itemCodeNameLC + keyCNLC}));
}
<#elseif deaction.codeName?lower_case == 'checkkey'>
@ApiOperation(value = "检查${deLogicName}", tags = {"${deLogicName}" }, notes = "检查${deLogicName}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}/test")
public ResponseEntity<Boolean> testCheckKey(${etParams}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testCheckKey(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto)));
}
<#elseif deaction.codeName?lower_case == 'getdraft'><#comment>前端支持临时模式,后台不做处理</#comment>
@ApiOperation(value = "获取${deLogicName}草稿", tags = {"${deLogicName}" }, notes = "获取${deLogicName}草稿")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}/test")
public ResponseEntity<Boolean> testGetDraft(${itemCodeName}DTO dto) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(dto);
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testGetDraft(domain));
}
<#elseif deaction.codeName?lower_case == 'createbatch'>
<#elseif deaction.codeName?lower_case == 'updatebatch'>
<#elseif deaction.codeName?lower_case == 'removebatch'>
<#elseif deaction.codeName?lower_case == 'savebatch'>
<#elseif deaction.getUserTag()?? && deaction.getActionType()?? && deaction.getUserTag() == 'REGIST' && deaction.getActionType() == 'USERCREATE'>
<#else>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "${deaction.getLogicName()}", tags = {"${deLogicName}" }, notes = "${deaction.getLogicName()}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}<#if deaction.getRequestParamType() == 'NONE'><#else>/{${itemCodeNameLC + keyCNLC}}</#if>/${deactionCodeName?lower_case}/test")
public ResponseEntity<Boolean> test${deactionCodeName?cap_first}(<#if deaction.getRequestParamType() == 'NONE'><#else>${id_etParams}</#if>) {
<#if deaction.getRequestParamType() == 'NONE'>
${deCodeName} domain = new ${deCodeName}();
<#else>
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
</#if>
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.test${srfmethodname(deactionCodeName)?cap_first}(domain));
}
</#if>
</#if>
</#macro>
<#comment>输出关系接口测试行为</#comment>
<#macro outputTestActionDetail2 deaction>
<#if deaction.getTestActionMode?? && deaction.getTestActionMode()?? && (deaction.getTestActionMode() ==3) >
<#assign deactionName = deaction.getName()>
<#assign deactionCodeName = deaction.getCodeName()>
<#if deaction.codeName?lower_case == 'create'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "${byTagParams}建立${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}建立${deLogicName}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/test")
public ResponseEntity<Boolean> testCreate${byParams}(${etParams}) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
${parentSetParams}
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testCreate(domain));
}
<@SecurityBatchAnnotation deaction/>
@ApiOperation(value = "${byTagParams}批量建立${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}批量建立${deLogicName}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/batch/test")
public ResponseEntity<Boolean> testCreateBatch${byParams}(${etParamsList}) {
List<${deCodeName}> domainlist=${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos);
for(${deCodeName} domain:domainlist){
${parentSetParams}
}
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testCreateBatch(domainlist));
}
<#elseif deaction.codeName?lower_case == 'update'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "${byTagParams}更新${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}更新${deLogicName}")
@RequestMapping(method = RequestMethod.PUT, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/test")
public ResponseEntity<Boolean> testUpdate${byParams}(${id_etParams}) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
${parentSetParams}
domain.set${dePKCodeName}(${itemCodeNameLC + keyCNLC});
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testUpdate(domain));
}
<@SecurityBatchAnnotation deaction/>
@ApiOperation(value = "${byTagParams}批量更新${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}批量更新${deLogicName}")
@RequestMapping(method = RequestMethod.PUT, value = "${fullPath}/batch/test")
public ResponseEntity<Boolean> testUpdateBatch${byParams}(${etParamsList}) {
List<${deCodeName}> domainlist=${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos);
for(${deCodeName} domain:domainlist){
${parentSetParams}
}
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testUpdateBatch(domainlist));
}
<#elseif deaction.codeName?lower_case == 'remove'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "${byTagParams}删除${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}删除${deLogicName}")
@RequestMapping(method = RequestMethod.DELETE, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/test")
public ResponseEntity<Boolean> testRemove${byParams}(${idParams}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testRemove(${itemCodeNameLC + keyCNLC}));
}
<@SecurityBatchAnnotation deaction/>
@ApiOperation(value = "${byTagParams}批量删除${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}批量删除${deLogicName}")
@RequestMapping(method = RequestMethod.DELETE, value = "${fullPath}/batch/test")
public ResponseEntity<Boolean> testRemoveBatch${byParams}(@RequestBody List<${srfr7javatype(de.getKeyPSDEField().getStdDataType())}> ids) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testRemoveBatch(ids));
}
<#elseif deaction.codeName?lower_case == 'save'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "${byTagParams}保存${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}保存${deLogicName}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}/test")
public ResponseEntity<Boolean> testSave${byParams}(${etParams}) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
${parentSetParams}
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testSave(domain));
}
<@SecurityBatchAnnotation deaction/>
@ApiOperation(value = "${byTagParams}批量保存${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}批量保存${deLogicName}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/savebatch/test")
public ResponseEntity<Boolean> testSaveBatch${byParams}(${etParamsList}) {
List<${deCodeName}> domainlist=${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos);
for(${deCodeName} domain:domainlist){
${parentSetParams}
}
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testSaveBatch(domainlist));
}
<#elseif deaction.codeName?lower_case == 'get'>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "${byTagParams}获取${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}获取${deLogicName}")
@RequestMapping(method = RequestMethod.GET, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/test")
public ResponseEntity<Boolean> testGet${byParams}(${idParams}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testGet(${itemCodeNameLC + keyCNLC}));
@ApiOperation(value = "查询{{dataSet.name}}", tags = {"{{apiEntity.entity.logicName}}" } ,notes = "查询{{dataSet.name}}")
@RequestMapping(method= RequestMethod.POST , value="/{{pluralize apiEntity.codeName}}/search{{lowerCase dataSet.codeName}}")
{{#if dataSet.enableGroup}}
public ResponseEntity<Page<Map>> search{{dataSet.codeName}}(@RequestBody {{apiEntity.entity.codeName}}SearchContext context) {
Page<Map> page = service.search{{dataSet.codeName}}(context) ;
return ResponseEntity.status(HttpStatus.OK)
.body(new PageImpl(page.getContent(), context.getPageable(), page.getTotalElements()));
}
<#elseif deaction.codeName?lower_case == 'checkkey'>
@ApiOperation(value = "${byTagParams}检查${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}检查${deLogicName}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}/test")
public ResponseEntity<Boolean> testCheckKey${byParams}(${etParams}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.testCheckKey(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto)));
{{else}}
public ResponseEntity<Page<{{apiEntity.codeName}}DTO>> search{{dataSet.codeName}}(@RequestBody {{apiEntity.entity.codeName}}SearchContext context) {
Page<{{apiEntity.entity.codeName}}> domains = service.search{{dataSet.codeName}}(context) ;
return ResponseEntity.status(HttpStatus.OK)
.body(new PageImpl(mapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
}
{{/if}}
{{/each}}
<#elseif deaction.codeName?lower_case == 'getdraft'>
@ApiOperation(value = "${byTagParams}获取${deLogicName}草稿", tags = {"${deLogicName}" }, notes = "${byTagParams}获取${deLogicName}草稿")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}/test")
public ResponseEntity<Boolean> testGetDraft${byParams}(${parentParams}, ${itemCodeName}DTO dto) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(dto);
${parentSetParams}
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC}Mapping.toDto(${deCodeNameLC}Service.testGetDraft(domain)));
}
<#elseif deaction.codeName?lower_case == 'createbatch'>
<#elseif deaction.codeName?lower_case == 'updatebatch'>
<#elseif deaction.codeName?lower_case == 'removebatch'>
<#elseif deaction.codeName?lower_case == 'savebatch'>
<#elseif deaction.getUserTag()?? && deaction.getActionType()?? && deaction.getUserTag() == 'REGIST' && deaction.getActionType() == 'USERCREATE'>
<#else>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "${byTagParams}${deLogicName}", tags = {"${deLogicName}" }, notes = "${byTagParams}${deLogicName}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/${deactionCodeName?lower_case}/test")
public ResponseEntity<Boolean> test${deactionCodeName?cap_first}${byParams}(${id_etParams}) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
${parentSetParams}
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.test${srfmethodname(deactionCodeName)?cap_first}(domain));
}
</#if>
</#if>
</#macro>
<#comment>用户自定义行为批处理-主实体关系</#comment>
<#macro customBatchAction deaction>
<#assign resultValueType="Boolean">
<#if apiReturnValueType?? && apiReturnValueType?lower_case=='void'>
<#assign resultValueType='Void'>
</#if>
<@SecurityAnnotation deaction/>
@ApiOperation(value = "批量处理[${deaction.getLogicName()}]", tags = {"${deLogicName}" }, notes = "批量处理[${deaction.getLogicName()}]")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}batch")
public ResponseEntity<${resultValueType}> ${deactionCodeName?uncap_first}Batch(<#if deaction.getRequestParamType() == 'NONE'><#else>${etParamsList}</#if>) {
<#if deaction.getRequestParamType() == 'NONE'>
List<${deCodeName}> domains = new ArrayList<${deCodeName}>();
boolean result = ${deCodeNameLC}Service.${srfmethodname(deactionCodeName)}Batch(domains);
<#else>
List<${deCodeName}> domains = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos);
boolean result = ${deCodeNameLC}Service.${srfmethodname(deactionCodeName)}Batch(domains);
</#if>
<#if resultValueType?lower_case =='void'>
return ResponseEntity.status(HttpStatus.OK).build();
<#else>
return ResponseEntity.status(HttpStatus.OK).body(result);
</#if>
}
</#macro>
<#comment>用户自定义行为批处理-从实体关系</#comment>
<#macro customBatchActionRS deaction>
<#assign resultValueType="Boolean">
<#if apiReturnValueType?? && apiReturnValueType?lower_case=='void'>
<#assign resultValueType='Void'>
</#if>
@ApiOperation(value = "批量处理[${byTagParams}${deLogicName}]", tags = {"${deLogicName}" }, notes = "批量处理[${byTagParams}${deLogicName}]")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}batch")
public ResponseEntity<${resultValueType}> ${deactionCodeName?uncap_first}${byParams}(<#if deaction.getRequestParamType() == 'NONE'><#else>${etParamsList}</#if>) {
<#if deaction.getRequestParamType() == 'NONE'>
List<${deCodeName}> domains = new ArrayList<${deCodeName}>();
boolean result = ${deCodeNameLC}Service.${srfmethodname(deactionCodeName)}Batch(domains);
<#else>
List<${deCodeName}> domains = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos);
boolean result = ${deCodeNameLC}Service.${srfmethodname(deactionCodeName)}Batch(domains);
</#if>
<#if resultValueType?lower_case =='void'>
return ResponseEntity.status(HttpStatus.OK).build();
<#else>
return ResponseEntity.status(HttpStatus.OK).body(result);
</#if>
}
</#macro>
\ No newline at end of file
}
{{/neq}}
{{/if}}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册