提交 a03c6ef1 编写于 作者: xignzi006's avatar xignzi006

Resource发布

上级 d2544b9f
......@@ -156,7 +156,7 @@
<dependency>
<groupId>net.ibizsys.model</groupId>
<artifactId>ibiz-model</artifactId>
<version>0.2.6</version>
<version>0.2.8</version>
<exclusions>
<exclusion>
<artifactId>slf4j-simple</artifactId>
......
......@@ -6,6 +6,9 @@ import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.dataentity.service.IPSDEMethodDTO;
import net.ibizsys.model.dataentity.service.IPSDEServiceAPI;
import net.ibizsys.model.dataentity.service.IPSDEServiceAPIMethod;
import net.ibizsys.model.dataentity.service.IPSDEServiceAPIRS;
import org.apache.commons.collections.CollectionUtils;
import java.util.*;
......@@ -15,6 +18,8 @@ import java.util.*;
@Accessors(chain = true)
public class ApiEntityModel extends BaseModel {
private List<ApiDtoModel> dtos = new ArrayList<>();
public ApiEntityModel(ApiModel apiModel, IPSDEServiceAPI apiDataEntity) {
this.opt = apiDataEntity;
this.api = apiModel;
......@@ -23,9 +28,10 @@ public class ApiEntityModel extends BaseModel {
this.setId(String.format("%1$s-%2$s", api.getCodeName(), apiDataEntity.getCodeName()));
if (apiDataEntity.getPSDataEntity() != null && apiDataEntity.getPSDataEntity().getAllPSDEMethodDTOs() != null) {
for (IPSDEMethodDTO iPSDEMethodDTO : apiDataEntity.getPSDataEntity().getAllPSDEMethodDTOs()) {
apiDtosMap.put(iPSDEMethodDTO.getName(), new ApiDtoModel(this,iPSDEMethodDTO));
dtos.add(new ApiDtoModel(this, iPSDEMethodDTO));
}
}
}
public IPSDEServiceAPI getApiDataEntity() {
......@@ -50,10 +56,72 @@ public class ApiEntityModel extends BaseModel {
return properties;
}
private Map<String, ApiDtoModel> apiDtosMap = new LinkedHashMap<>();
public Collection<ApiDtoModel> getDtos() {
return apiDtosMap.values();
public boolean isMajor() {
return getApiDataEntity().isMajor();
}
public List<ApiMethodModel> getMethods() {
if (this.getCodeName().equals("District")) {
getApiDataEntity().isMajor();
}
List<ApiMethodModel> methods = new ArrayList<>();
//主接口方法
if (getApiDataEntity().isMajor() && getApiDataEntity().getPSDEServiceAPIMethods() != null) {
for (IPSDEServiceAPIMethod iPSDEServiceAPIMethod : getApiDataEntity().getPSDEServiceAPIMethods()) {
methods.add(new ApiMethodModel(this, null, iPSDEServiceAPIMethod));
}
}
//接口关系方法
if (getApiDataEntity().getMinorPSDEServiceAPIRSs() != null) {
for (IPSDEServiceAPIRS iPSDEServiceAPIRS : getApiDataEntity().getMinorPSDEServiceAPIRSs()) {
if (iPSDEServiceAPIRS.getPSDEServiceAPIMethods() != null) {
ApiEntityRSModel apiEntityRSModel = api.getApiEntityRS(iPSDEServiceAPIRS.getName());
//计算父路径
List<List<ApiEntityRSModel>> parentApiEntityList = new ArrayList<>();
fillDEAPIRSPath(parentApiEntityList, apiEntityRSModel, null);
for (List<ApiEntityRSModel> parentApiEntities : parentApiEntityList) {
for (IPSDEServiceAPIMethod iPSDEServiceAPIMethod : iPSDEServiceAPIRS.getPSDEServiceAPIMethods()) {
methods.add(new ApiMethodModel(this, parentApiEntities, iPSDEServiceAPIMethod));
}
}
}
}
}
return methods;
}
/**
* 递归计算接口关系path
* 注意自身关系
*
* @param parentApiEntityList
* @param apiEntityRSModel
* @param parentApiEntities
*/
private void fillDEAPIRSPath(List<List<ApiEntityRSModel>> parentApiEntityList, ApiEntityRSModel apiEntityRSModel, List<ApiEntityRSModel> parentApiEntities) {
if (parentApiEntities == null) {
parentApiEntities = new ArrayList<>();
}
//防止递归
if (parentApiEntities.stream().anyMatch(rs -> rs.getName().equals(apiEntityRSModel.getName()))) {
return;
}
parentApiEntities.add(apiEntityRSModel);
if (apiEntityRSModel.isMajorEntityMajor()) {
List<ApiEntityRSModel> temp = new ArrayList<>();
temp.addAll(parentApiEntities);
parentApiEntityList.add(temp);
}
//递归
List<ApiEntityRSModel> parents = api.getApiEntityParentRSes(apiEntityRSModel.getMajorEntityCodeName());
if (!CollectionUtils.isEmpty(parents)) {
for (ApiEntityRSModel parentRs : parents) {
fillDEAPIRSPath(parentApiEntityList, parentRs, parentApiEntities);
}
}
}
}
package cn.ibizlab.codegen.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.dataentity.service.IPSDEMethodDTO;
import net.ibizsys.model.dataentity.service.IPSDEServiceAPI;
import net.ibizsys.model.dataentity.service.IPSDEServiceAPIMethod;
import net.ibizsys.model.dataentity.service.IPSDEServiceAPIRS;
import java.util.ArrayList;
import java.util.List;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class ApiEntityRSModel extends BaseModel {
public ApiEntityRSModel(ApiModel apiModel, IPSDEServiceAPIRS iPSDEServiceAPIRS) {
this.opt = iPSDEServiceAPIRS;
this.api = apiModel;
this.setCodeName(iPSDEServiceAPIRS.getCodeName());
this.setName(iPSDEServiceAPIRS.getName());
}
private ApiModel api;
public String getParentIdFieldCodeName() {
if (getPSDEServiceAPIRS().getParentIdPSDEField() != null)
return getPSDEServiceAPIRS().getParentIdPSDEField().getCodeName();
return "";
}
public int getParentIdFieldType() {
if (getPSDEServiceAPIRS().getParentIdPSDEField() != null)
return getPSDEServiceAPIRS().getParentIdPSDEField().getStdDataType();
return PropType.VARCHAR.code;
}
public String getMajorEntityCodeName() {
return getPSDEServiceAPIRS().getMajorPSDEServiceAPI().getCodeName();
}
public boolean isMajorEntityMajor() {
return getPSDEServiceAPIRS().getMajorPSDEServiceAPI().isMajor();
}
public String getMinorEntityCodeName() {
return getPSDEServiceAPIRS().getMinorPSDEServiceAPI().getCodeName();
}
private IPSDEServiceAPIRS getPSDEServiceAPIRS() {
return (IPSDEServiceAPIRS) opt;
}
}
package cn.ibizlab.codegen.model;
import cn.ibizlab.codegen.utils.Inflector;
import cn.ibizlab.codegen.utils.StringAdvUtils;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.dataentity.IPSDataEntity;
import net.ibizsys.model.dataentity.service.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class ApiMethodModel extends BaseModel {
private String[] ignoreMethodNames = new String[]{"GET", "CREATE", "UPDATE", "REMOVE"};
private ApiModel api;
private ApiEntityModel apiEntity;
private List<ApiEntityRSModel> parentApiEntities;
public ApiMethodModel(ApiEntityModel apiEntityModel, List<ApiEntityRSModel> parentApiEntities, IPSDEServiceAPIMethod iPSDEServiceAPIMethod) {
this.opt = iPSDEServiceAPIMethod;
this.apiEntity = apiEntityModel;
this.api = apiEntityModel.getApi();
this.parentApiEntities = parentApiEntities;
this.setCodeName(iPSDEServiceAPIMethod.getCodeName());
this.setName(iPSDEServiceAPIMethod.getName());
}
public IPSDEServiceAPIMethod getPSDEServiceAPIMethod() {
return (IPSDEServiceAPIMethod) opt;
}
public String getRequestPath() {
String path = "";
if (!CollectionUtils.isEmpty(parentApiEntities)) {
for (ApiEntityRSModel apiRs : parentApiEntities) {
String strMajorEntityPlurlize = Inflector.getInstance().pluralize(StringAdvUtils.camelcase(apiRs.getMajorEntityCodeName()).toLowerCase());
path = String.format("/%s/{%s}", strMajorEntityPlurlize,StringAdvUtils.camelcase(apiRs.getParentIdFieldCodeName())) + path;
}
}
//主键
String strPlurlize = Inflector.getInstance().pluralize(StringAdvUtils.camelcase(apiEntity.getCodeName()).toLowerCase());
if (getPSDEServiceAPIMethod().isNeedResourceKey()) {
path = path + String.format("/%s/{%s}", strPlurlize, StringAdvUtils.camelcase(apiEntity.getEntity().getKeyField().getCodeName()));
} else {
path = path + String.format("/%s", strPlurlize);
}
//方法名
if (!ArrayUtils.contains(ignoreMethodNames, this.getName().toUpperCase())) {
path = path + String.format("/%s", this.getName().toLowerCase());
}
return path;
}
public List getPathVariables() {
List pathVariables = new ArrayList();
if (!CollectionUtils.isEmpty(parentApiEntities)) {
for (ApiEntityRSModel apiRs : parentApiEntities) {
String strMajorEntityPlurlize = Inflector.getInstance().pluralize(StringAdvUtils.camelcase(apiRs.getMajorEntityCodeName()).toLowerCase());
JSONObject pathVariable = new JSONObject();
pathVariable.put("name", apiRs.getParentIdFieldCodeName());
pathVariable.put("type", PropType.findType(apiRs.getParentIdFieldType()));
pathVariables.add(pathVariable);
}
}
if (getPSDEServiceAPIMethod().isNeedResourceKey()) {
JSONObject pathVariable = new JSONObject();
pathVariable.put("name", apiEntity.getEntity().getKeyField().getCodeName());
pathVariable.put("type", apiEntity.getEntity().getKeyField().getType());
pathVariables.add(pathVariable);
}
return pathVariables;
}
public String getBody() {
IPSDEServiceAPIMethodInput iPSDEServiceAPIMethodInput = getPSDEServiceAPIMethod().getPSDEServiceAPIMethodInput();
if (iPSDEServiceAPIMethodInput != null) {
if ("DTO".equals(iPSDEServiceAPIMethodInput.getType())) {
try {
iPSDEServiceAPIMethodInput.getPSDEMethodDTO();
} catch (Exception e) {
int i = 0;
}
if ("DEFAULT".equals(iPSDEServiceAPIMethodInput.getPSDEMethodDTO().getType()))
return iPSDEServiceAPIMethodInput.getPSDEMethodDTO().getName();
else if ("DEFILTER".equals(iPSDEServiceAPIMethodInput.getPSDEMethodDTO().getType()))
return iPSDEServiceAPIMethodInput.getPSDEMethodDTO().getName().replace("FilterDTO", "SearchContext");
}
}
return null;
}
public IPSDEServiceAPIMethodInput getInput() {
return getPSDEServiceAPIMethod().getPSDEServiceAPIMethodInput();
}
public IPSDEServiceAPIMethodReturn getReturn() {
return getPSDEServiceAPIMethod().getPSDEServiceAPIMethodReturn();
}
}
......@@ -12,38 +12,62 @@ import java.util.*;
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class ApiModel extends BaseModel{
public class ApiModel extends BaseModel {
public ApiModel(IPSSysServiceAPI api)
{
this.opt=api;
public ApiModel(IPSSysServiceAPI api) {
this.opt = api;
this.setCodeName(api.getCodeName());
this.setName(api.getName());
if(getSysServiceApi().getPSDEServiceAPIs()!=null)
{
getSysServiceApi().getPSDEServiceAPIs().forEach(item->{
apiEntitiesMap.put(item.getCodeName(),new ApiEntityModel(this, item));
if (getSysServiceApi().getPSDEServiceAPIs() != null) {
getSysServiceApi().getPSDEServiceAPIs().forEach(item -> {
apiEntitiesMap.put(item.getCodeName(), new ApiEntityModel(this, item));
});
}
if (getSysServiceApi().getPSDEServiceAPIRSs() != null) {
getSysServiceApi().getPSDEServiceAPIRSs().forEach(item -> {
ApiEntityRSModel apiEntityRSModel = new ApiEntityRSModel(this, item);
apiEntityRSMap.put(item.getName(), apiEntityRSModel);
if (!apiEntityParentRSMap.containsKey(apiEntityRSModel.getMinorEntityCodeName())) {
apiEntityParentRSMap.put(apiEntityRSModel.getMinorEntityCodeName(), new ArrayList<>());
}
apiEntityParentRSMap.get(apiEntityRSModel.getMinorEntityCodeName()).add(apiEntityRSModel);
});
}
}
private SystemModel system;
public IPSSysServiceAPI getSysServiceApi()
{
return (IPSSysServiceAPI)opt;
public IPSSysServiceAPI getSysServiceApi() {
return (IPSSysServiceAPI) opt;
}
private Map<String,ApiEntityModel> apiEntitiesMap=new LinkedHashMap<>();
private Map<String, ApiEntityModel> apiEntitiesMap = new LinkedHashMap<>();
public Collection<ApiEntityModel> getApiEntities() {
return apiEntitiesMap.values();
}
public ApiEntityModel getApiEntity(String codeName)
{
public ApiEntityModel getApiEntity(String codeName) {
return apiEntitiesMap.get(codeName);
}
private Map<String, ApiEntityRSModel> apiEntityRSMap = new LinkedHashMap<>();
public Collection<ApiEntityRSModel> getapiEntityRSes() {
return apiEntityRSMap.values();
}
public ApiEntityRSModel getApiEntityRS(String name) {
return apiEntityRSMap.get(name);
}
private Map<String, List<ApiEntityRSModel>> apiEntityParentRSMap = new LinkedHashMap<>();
public List<ApiEntityRSModel> getApiEntityParentRSes(String name) {
return apiEntityParentRSMap.get(name);
}
}
......@@ -102,16 +102,7 @@ public class ModelStorage {
if(!templateData.containsKey(type))
{
CliData rt=new CliData();
if(type.equals(TemplateFileType.api))
{
getSystemModel().getApis().forEach(item->{
CliOption opt=newCliOption(TemplateFileType.api).baseData(item,item.getCodeName().toLowerCase());
rt.addOption(opt);
});
}
else if(type.equals(TemplateFileType.apiEntity))
if(type.equals(TemplateFileType.apiEntity))
{
getSystemModel().getApis().forEach(api->{
api.getApiEntities().forEach(item->{
......@@ -120,79 +111,97 @@ public class ModelStorage {
});
});
}
else if (type.equals(TemplateFileType.apiDto)) {
getSystemModel().getApis().forEach(api -> {
api.getApiEntities().forEach(item -> {
item.getDtos().forEach(dto -> {
CliOption opt = newCliOption(TemplateFileType.apiDto)
.setCliSubType(dto.getType())
.baseData(dto, dto.getCodeName())
.set("apiDtos",dto.getCodeName()).set("apis",dto.getApi().getCodeName().toLowerCase());
rt.addOption(opt);
});
});
});
}
else if(type.equals(TemplateFileType.app))
{
getSystemModel().getApps().forEach(item->{
CliOption opt=newCliOption(TemplateFileType.app).baseData(item,item.getCodeName().toLowerCase());
rt.addOption(opt);
});
}
else if(type.equals(TemplateFileType.appEntity))
{
getSystemModel().getApps().forEach(app->{
app.getAppEntities().forEach(item->{
CliOption opt=newCliOption(TemplateFileType.appEntity).baseData(item, StringAdvUtils.spinalcase(item.getCodeName())).set("apps",app.getCodeName().toLowerCase());
rt.addOption(opt);
});
});
}
else if(type.equals(TemplateFileType.entity))
{
getSystemModel().getEntities().forEach(item->{
CliOption opt=newCliOption(TemplateFileType.entity).setCliSubType(item.getStorage()).setModule(item.getModule())
.baseData(item,item.getCodeName().toString());
rt.addOption(opt);
});
}
else if(type.equals(TemplateFileType.module))
{
getSystemModel().getSystem().getAllPSSystemModules().forEach(item->{
CliOption opt=newCliOption(TemplateFileType.module)
.baseData(item,item.getCodeName());
rt.addOption(opt);
});
}
else if(type.equals(TemplateFileType.page))
{
getSystemModel().getApps().forEach(app->{
app.getPages().forEach(item->{
CliOption opt=newCliOption(TemplateFileType.page).setCliSubType(item.getAppView().getViewType()).baseData(item,StringAdvUtils.spinalcase(item.getCodeName())).set("apps",app.getCodeName().toLowerCase()).set("appModules",item.getAppModule().toSpinalCase());
rt.addOption(opt);
});
});
}
else if(type.equals(TemplateFileType.ctrl))
{
getSystemModel().getApps().forEach(app->{
app.getCtrls().forEach(item->{
CliOption opt=newCliOption(TemplateFileType.ctrl).setCliSubType(item.getControl().getControlType()).baseData(item,StringAdvUtils.spinalcase(item.getCodeName())).set("apps",app.getCodeName().toLowerCase()).set("appEntities",item.getFolder().toSpinalCase());
rt.addOption(opt);
});
});
}
else if(type.equals(TemplateFileType.supportingFiles))
{
CliOption opt=newCliOption(TemplateFileType.supportingFiles)
.set(TemplateFileType.app.value(),getTemplateData(TemplateFileType.app).getOptions())
.set(TemplateFileType.api.value(),getTemplateData(TemplateFileType.api).getOptions())
.set(TemplateFileType.module.value(),getTemplateData(TemplateFileType.module).getOptions());
rt.addOption(opt);
}
// if(type.equals(TemplateFileType.api))
// {
//
// getSystemModel().getApis().forEach(item->{
// CliOption opt=newCliOption(TemplateFileType.api).baseData(item,item.getCodeName().toLowerCase());
// rt.addOption(opt);
// });
//
// }
// else if(type.equals(TemplateFileType.apiEntity))
// {
// getSystemModel().getApis().forEach(api->{
// api.getApiEntities().forEach(item->{
// CliOption opt=newCliOption(TemplateFileType.apiEntity).baseData(item,item.getCodeName().toString()).set("apis",api.getCodeName().toLowerCase());
// rt.addOption(opt);
// });
// });
// }
// else if (type.equals(TemplateFileType.apiDto)) {
// getSystemModel().getApis().forEach(api -> {
// api.getApiEntities().forEach(item -> {
// item.getDtos().forEach(dto -> {
// CliOption opt = newCliOption(TemplateFileType.apiDto)
// .setCliSubType(dto.getType())
// .baseData(dto, dto.getCodeName())
// .set("apiDtos",dto.getCodeName()).set("apis",dto.getApi().getCodeName().toLowerCase());
// rt.addOption(opt);
// });
// });
// });
// }
// else if(type.equals(TemplateFileType.app))
// {
// getSystemModel().getApps().forEach(item->{
// CliOption opt=newCliOption(TemplateFileType.app).baseData(item,item.getCodeName().toLowerCase());
// rt.addOption(opt);
// });
// }
// else if(type.equals(TemplateFileType.appEntity))
// {
// getSystemModel().getApps().forEach(app->{
// app.getAppEntities().forEach(item->{
// CliOption opt=newCliOption(TemplateFileType.appEntity).baseData(item, StringAdvUtils.spinalcase(item.getCodeName())).set("apps",app.getCodeName().toLowerCase());
// rt.addOption(opt);
// });
// });
// }
// else if(type.equals(TemplateFileType.entity))
// {
// getSystemModel().getEntities().forEach(item->{
// CliOption opt=newCliOption(TemplateFileType.entity).setCliSubType(item.getStorage()).setModule(item.getModule())
// .baseData(item,item.getCodeName().toString());
// rt.addOption(opt);
// });
// }
// else if(type.equals(TemplateFileType.module))
// {
// getSystemModel().getSystem().getAllPSSystemModules().forEach(item->{
// CliOption opt=newCliOption(TemplateFileType.module)
// .baseData(item,item.getCodeName());
// rt.addOption(opt);
// });
// }
// else if(type.equals(TemplateFileType.page))
// {
// getSystemModel().getApps().forEach(app->{
// app.getPages().forEach(item->{
// CliOption opt=newCliOption(TemplateFileType.page).setCliSubType(item.getAppView().getViewType()).baseData(item,StringAdvUtils.spinalcase(item.getCodeName())).set("apps",app.getCodeName().toLowerCase()).set("appModules",item.getAppModule().toSpinalCase());
//
// rt.addOption(opt);
// });
// });
// }
// else if(type.equals(TemplateFileType.ctrl))
// {
// getSystemModel().getApps().forEach(app->{
// app.getCtrls().forEach(item->{
// CliOption opt=newCliOption(TemplateFileType.ctrl).setCliSubType(item.getControl().getControlType()).baseData(item,StringAdvUtils.spinalcase(item.getCodeName())).set("apps",app.getCodeName().toLowerCase()).set("appEntities",item.getFolder().toSpinalCase());
// rt.addOption(opt);
// });
// });
// }
// else if(type.equals(TemplateFileType.supportingFiles))
// {
// CliOption opt=newCliOption(TemplateFileType.supportingFiles)
// .set(TemplateFileType.app.value(),getTemplateData(TemplateFileType.app).getOptions())
// .set(TemplateFileType.api.value(),getTemplateData(TemplateFileType.api).getOptions())
// .set(TemplateFileType.module.value(),getTemplateData(TemplateFileType.module).getOptions());
//
// rt.addOption(opt);
// }
templateData.put(type,rt);
}
return templateData.get(type);
......
{{#if apiEntity.major}}
{{#neq apiEntity.entity.storage "NONE"}}
{{#unless nested}}
{{#neq apiEntity.entity.storage "NONE"}}
package {{packageName}}.{{lowerCase apiEntity.api.codeName}}.rest;
import java.sql.Timestamp;
......@@ -43,150 +43,74 @@ import cn.ibizlab.util.annotation.VersionCheck;
public class {{apiEntity.codeName}}Resource {
@Autowired
public I{{apiEntity.entity.codeName}}Service service;
public I{{apiEntity.entity.codeName}}Service {{camelCase apiEntity.entity.codeName}}Service;
{{#each apiEntity.dtos}}
{{#eq type "DEFAULT"}}
@Autowired
@Lazy
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);
}
@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);
}
@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));
}
@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);
}
{{#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);
}
@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)));
}
@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)));
}
@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));
}
@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);
}
{{#each apiEntity.entity.dataSets as |dataSet|}}
@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(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}}
@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()));
}
{{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}}
public {{codeName}}Mapping {{camelCase codeName}}Mapping;
{{/eq}}
{{/each}}
{{#each apiEntity.methods}}
@ApiOperation(value = "{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.{{requestMethod}}, value = "{{requestPath}}")
public ResponseEntity {{camelCase name}}({{#each pathVariables}}{{#gt @index 0}}, {{/gt}}@PathVariable("{{camelCase name}}") {{type.java}} {{camelCase name}}{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}@Validated @RequestBody {{body}} {{camelCase body}}{{/if}}) {
{{!行为}}
{{#eq methodType "DEACTION"}}
{{!行为参数准备}}
{{#eq input.type "DTO"}}
{{apiEntity.entity.codeName}} {{camelCase apiEntity.entity.codeName}} = {{camelCase input.pSDEMethodDTO.name}}Mapping.toDomain({{camelCase body}});
{{#each pathVariables}}
{{camelCase apiEntity.entity.codeName}}.set{{pascalCase name}}({{camelCase name}});
{{/each}}
{{camelCase apiEntity.entity.codeName}}Service.{{camelCase name}}({{camelCase apiEntity.entity.codeName}});
{{/eq}}
{{#eq input.type "KEYFIELD"}}
{{#neq name "Get"}}
{{camelCase apiEntity.entity.codeName}}Service.{{camelCase name}}({{camelCase apiEntity.entity.keyField.codeName}});
{{/neq}}
{{#eq name "Get"}}
{{apiEntity.entity.codeName}} {{camelCase apiEntity.entity.codeName}} = {{camelCase apiEntity.entity.codeName}}Service.{{camelCase name}}({{camelCase apiEntity.entity.keyField.codeName}});
{{/eq}}
{{/eq}}
{{!返回处理}}
{{#eq return.type "DTO"}}
return ResponseEntity.status(HttpStatus.OK).body({{camelCase return.pSDEMethodDTO.name}}Mapping.toDto({{camelCase apiEntity.entity.codeName}}));
{{/eq}}
{{#eq return.type "SIMPLE"}}
return ResponseEntity.status(HttpStatus.OK).body(0);
{{/eq}}
{{#eq return.type "KEYFIELD"}}
{{/eq}}
{{#eq return.type "VOID"}}
return ResponseEntity.status(HttpStatus.OK).body(true);
{{/eq}}
{{/eq}}
{{!数据集}}
{{#eq methodType "FETCH"}}
{{#each pathVariables}}
{{camelCase body}}.set{{pascalCase name}}EQ({{camelCase name}});
{{/each}}
Page<{{apiEntity.entity.codeName}}> domains = {{camelCase apiEntity.entity.codeName}}Service.search{{pSDEDataSet.codeName}}({{camelCase body}}) ;
List<{{return.pSDEMethodDTO.name}}> list = {{camelCase return.pSDEMethodDTO.name}}Mapping.toDto(domains.getContent());
return ResponseEntity.status(HttpStatus.OK)
.header("x-page", String.valueOf({{camelCase body}}.getPageable().getPageNumber()))
.header("x-per-page", String.valueOf({{camelCase body}}.getPageable().getPageSize()))
.header("x-total", String.valueOf(domains.getTotalElements()))
.body(list);
{{/eq}}
{{!SELECT法}}
{{#eq methodType "SELECT"}}
return ResponseEntity.status(HttpStatus.OK).body(null);
{{/eq}}
}
{{/each}}
}
{{/neq}}
{{/if}}
\ No newline at end of file
{{/neq}}
{{/unless}}
\ No newline at end of file
{{#eq apiEntity.code ""}}
{{#if apiEntity.major}}
{{#neq apiEntity.entity.storage "NONE"}}
package {{packageName}}.{{lowerCase apiEntity.api.codeName}}.rest;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.math.BigInteger;
import java.util.HashMap;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.ServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.http.HttpStatus;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.validation.annotation.Validated;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import {{packageName}}.{{lowerCase apiEntity.api.codeName}}.dto.*;
import {{packageName}}.{{lowerCase apiEntity.api.codeName}}.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 = {"{{apiEntity.entity.logicName}}" })
@RestController("{{lowerCase apiEntity.api.codeName}}-{{lowerCase apiEntity.codeName}}")
@RequestMapping("")
public class {{apiEntity.codeName}}Resource {
@Autowired
public I{{apiEntity.entity.codeName}}Service service;
@Autowired
@Lazy
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);
}
@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);
}
@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));
}
@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);
}
{{#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);
}
@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)));
}
@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)));
}
@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));
}
@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);
}
{{#each apiEntity.entity.dataSets as |dataSet|}}
@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(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}}
@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()));
}
{{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}}
}
{{/neq}}
{{/if}}
{{/eq}}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册