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

update:客户端模板

上级 a5680144
......@@ -34,7 +34,12 @@ public class {{apiEntity.codeName}}SubSysServiceAPIDERuntime extends {{packageNa
}
@Override
public Object invokeMethod(IPSSubSysServiceAPIDEMethod iPSSubSysServiceAPIDEMethod, Map<String, Object> context, IDataEntityRuntime iDataEntityRuntime, IPSDEAction iPSDEAction, Object[] args) throws Throwable {
public IEntityDTO createClientEntity() {
return new {{apiEntity.codeName}}DTO();
}
@Override
public Object onInvokeMethod(IPSSubSysServiceAPIDEMethod iPSSubSysServiceAPIDEMethod, Map<String, Object> context, IDataEntityRuntime iDataEntityRuntime, IPSDEAction iPSDEAction, Object[] args) throws Throwable {
Object key;
if (args[0] instanceof IEntityDTO) {
key = ((IEntityDTO) args[0]).get(iDataEntityRuntime.getKeyPSDEField().getName().toLowerCase());
......@@ -51,7 +56,7 @@ public class {{apiEntity.codeName}}SubSysServiceAPIDERuntime extends {{packageNa
{{#each method.parentApiEntities as |parent|}}
{{#if (and (eq @index 0) @last)}}
if (context != null && context.containsKey("{{parent.majorPSDEServiceAPI.name}}")) {
{{#eq return.type "DTO"}}obj = {{/eq}}{{#eq return.type "SIMPLE"}}obj = {{/eq}}{{#eq return.type "USER"}}obj = {{/eq}}getClient().{{camelCase method.name}}{{#each pathVariables as |pathVariable|}}{{#if @first}}By{{else}}And{{/if}}{{pascalCase pathVariable.name}}{{/each}}({{#each pathVariables as |pathVariable|}}{{#unless @first}}, {{/unless}}({{type.java}}) key{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}{{#eq input.type "DTO"}}({{body}}){{/eq}}{{#eq input.type "KEYFIELD"}}{{#eq pSDEAction.actionType "USERCUSTOM"}}({{body}}){{/eq}}{{/eq}}{{#eq input.type "DTOS"}}(List<{{body}}>){{/eq}}args[0]{{/if}});
{{#eq return.type "DTO"}}obj = {{/eq}}{{#eq return.type "SIMPLE"}}obj = {{/eq}}{{#eq return.type "USER"}}obj = {{/eq}}getClient().{{camelCase method.name}}{{#each pathVariables as |pathVariable|}}{{#if @first}}By{{else}}And{{/if}}{{pascalCase pathVariable.name}}{{/each}}({{#each pathVariables as |pathVariable|}}{{#unless @first}}, {{/unless}}({{type.java}}) {{#unless (and @last method.pSDEServiceAPIMethod.isNeedResourceKey)}}context.get("{{parent.majorPSDEServiceAPI.name}}"){{/unless}}{{#if (and @last method.pSDEServiceAPIMethod.isNeedResourceKey)}}key{{/if}}{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}{{#eq input.type "DTO"}}({{body}}){{/eq}}{{#eq input.type "KEYFIELD"}}{{#eq pSDEAction.actionType "USERCUSTOM"}}({{body}}){{/eq}}{{/eq}}{{#eq input.type "DTOS"}}(List<{{body}}>){{/eq}}convert2ClientEntity(args[0]){{/if}});
break;
}
{{/if}}
......@@ -61,7 +66,7 @@ public class {{apiEntity.codeName}}SubSysServiceAPIDERuntime extends {{packageNa
{{#each apiEntity.methods as |method|}}
{{#if (and (eq methodType "DEACTION") (eq method.pSDEServiceAPIMethod.pSDEAction.name deAction.name))}}
{{#unless method.parentApiEntities}}
{{#eq return.type "DTO"}}obj = {{/eq}}{{#eq return.type "SIMPLE"}}obj = {{/eq}}{{#eq return.type "USER"}}obj = {{/eq}}getClient().{{camelCase method.name}}{{#each pathVariables as |pathVariables|}}{{#if @first}}By{{else}}And{{/if}}{{pascalCase pathVariables.name}}{{/each}}({{#each pathVariables as |pathVariable|}}{{#unless @first}}, {{/unless}}({{type.java}}) key{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}{{#eq input.type "DTO"}}({{body}}){{/eq}}{{#eq input.type "KEYFIELD"}}{{#eq pSDEAction.actionType "USERCUSTOM"}}({{body}}){{/eq}}{{/eq}}{{#eq input.type "DTOS"}}(List<{{body}}>){{/eq}}args[0]{{/if}});
{{#eq return.type "DTO"}}obj = {{/eq}}{{#eq return.type "SIMPLE"}}obj = {{/eq}}{{#eq return.type "USER"}}obj = {{/eq}}getClient().{{camelCase method.name}}{{#each pathVariables as |pathVariables|}}{{#if @first}}By{{else}}And{{/if}}{{pascalCase pathVariables.name}}{{/each}}({{#each pathVariables as |pathVariable|}}{{#unless @first}}, {{/unless}}({{type.java}}) key{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}{{#eq input.type "DTO"}}({{body}}){{/eq}}{{#eq input.type "KEYFIELD"}}{{#eq pSDEAction.actionType "USERCUSTOM"}}({{body}}){{/eq}}{{/eq}}{{#eq input.type "DTOS"}}(List<{{body}}>){{/eq}}convert2ClientEntity(args[0]){{/if}});
break;
{{/unless}}
{{/if}}
......@@ -70,7 +75,9 @@ public class {{apiEntity.codeName}}SubSysServiceAPIDERuntime extends {{packageNa
{{#each apiEntity.methods}}
{{/each}}
}
return obj;
IEntityDTO entityDTO = iDataEntityRuntime.createEntity();
entityDTO.reload(obj, true, false);
return entityDTO;
}
@Override
......@@ -111,36 +118,10 @@ public class {{apiEntity.codeName}}SubSysServiceAPIDERuntime extends {{packageNa
if (obj != null && obj instanceof Page) {
Page ret = (Page) obj;
for (Object item : ret.getContent()) {
IEntityDTO entityDTO = iDataEntityRuntime.createEntity();
entityDTO.reload(item, true, false);
recodes.add(entityDTO);
recodes.add(convert2Entity(item));
}
return new PageImpl(recodes, dto.getPageable(), ret.getTotalElements());
}
return new PageImpl(recodes, dto.getPageable(), 0);
}
private void convertCondition(ISearchContextDTO dto){
dto.any().put("page", dto.getPageable().getPageNumber());
dto.any().put("size", dto.getPageable().getPageSize());
if (dto.getPageSort() != null&& dto.getPageSort()!=Sort.unsorted()) {
String strSort = "";
Iterator<Sort.Order> iterator = dto.getPageSort().iterator();
if (iterator.hasNext()) {
Sort.Order order = iterator.next();
if (StringUtils.isNotEmpty(strSort)) {
strSort += ";";
}
strSort += order.getProperty();
if (order.isAscending()) {
strSort += ",asc";
} else if (order.isDescending()) {
strSort += ",desc";
}
}
if (StringUtils.isNotEmpty(strSort)) {
dto.any().put("sort", strSort);
}
}
}
}
\ No newline at end of file
package {{packageName}}.client.{{lowerCase api.codeName}}.runtime.service;
import lombok.extern.slf4j.Slf4j;
import net.ibizsys.central.r8.service.R8SubSysServiceAPIDERuntime;
import net.ibizsys.central.service.SubSysServiceAPIDERuntimeException;
import net.ibizsys.central.util.EntityDTO;
import net.ibizsys.central.util.IEntityDTO;
import net.ibizsys.central.util.ISearchContextDTO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Sort;
import java.util.Iterator;
/**
* 提供外部容器启动服务能力
......@@ -10,5 +17,56 @@ import net.ibizsys.central.r8.service.R8SubSysServiceAPIDERuntime;
@Slf4j
public class {{api.codeName}}R8SubSysServiceAPIDERuntime extends R8SubSysServiceAPIDERuntime {
protected IEntityDTO createClientEntity() {
return new EntityDTO();
}
protected IEntityDTO convert2ClientEntity(Object entityDTO) {
if (entityDTO == null)
return null;
IEntityDTO clientEntityDTO = createClientEntity();
try {
clientEntityDTO.reload(entityDTO, true);
} catch (Exception e) {
throw new SubSysServiceAPIDERuntimeException(this, String.format("调用外部系统接口参数转换发异常:%s", e.getMessage()));
}
return clientEntityDTO;
}
protected IEntityDTO convert2Entity(Object clientEntityDTO) {
if (clientEntityDTO == null)
return null;
IEntityDTO entityDTO = createClientEntity();
try {
entityDTO.reload(clientEntityDTO, true);
} catch (Exception e) {
throw new SubSysServiceAPIDERuntimeException(this, String.format("调用外部系统接口参数转换发异常:%s", e.getMessage()));
}
return entityDTO;
}
protected void convertCondition(ISearchContextDTO dto) {
dto.any().put("page", dto.getPageable().getPageNumber());
dto.any().put("size", dto.getPageable().getPageSize());
if (dto.getPageSort() != null && dto.getPageSort() != Sort.unsorted()) {
String strSort = "";
Iterator<Sort.Order> iterator = dto.getPageSort().iterator();
if (iterator.hasNext()) {
Sort.Order order = iterator.next();
if (StringUtils.isNotEmpty(strSort)) {
strSort += ";";
}
strSort += order.getProperty();
if (order.isAscending()) {
strSort += ",asc";
} else if (order.isDescending()) {
strSort += ",desc";
}
}
if (StringUtils.isNotEmpty(strSort)) {
dto.any().put("sort", strSort);
}
}
}
}
\ No newline at end of file
package {{packageName}}.{{lowerCase apiEntity.api.codeName}}.client;
import {{packageName}}.{{lowerCase apiEntity.api.codeName}}.dto.{{apiEntity.codeName}}DTO;
import com.netflix.hystrix.exception.HystrixTimeoutException;
import feign.FeignException;
import feign.hystrix.FallbackFactory;
import net.ibizsys.central.util.SearchContextDTO;
import net.ibizsys.runtime.dataentity.DataEntityRuntimeException;
import net.ibizsys.runtime.util.Errors;
import org.springframework.data.domain.Page;
import java.util.Collection;
import java.util.List;
/**
* 实体[{{apiEntity.codeName}}] 服务对象接口
*
*/
public class {{apiEntity.codeName}}Fallback implements FallbackFactory<{{apiEntity.codeName}}FeignClient> {
@Override
public {{apiEntity.codeName}}FeignClient create(Throwable cause) {
String errorMessage = "";
if (cause instanceof FeignException) {
FeignException ex = (FeignException) cause;
errorMessage = "[iBizRT客户端]调用异常,错误状态:" + ex.status() + "." + cause.getMessage();
} else if (cause instanceof HystrixTimeoutException) {
errorMessage = "[RT服务接口]调用超时。";
} else {
errorMessage = "[iBizRT客户端]异常,错误:" + cause.getMessage();
}
String finalErrorMessage = errorMessage;
return new {{apiEntity.codeName}}FeignClient(){
{{#each apiEntity.methods}}
{{!行为}}
{{#eq methodType "DEACTION"}}
public {{#eq return.type "DTO"}}{{apiEntity.codeName}}DTO{{/eq}}{{#eq return.type "DTOS"}}Page<{{apiEntity.codeName}}DTO>{{/eq}}{{#eq return.type "SIMPLE"}}Integer{{/eq}}{{#eq return.type "KEYFIELD"}}{{/eq}}{{#eq return.type "VOID"}}void{{/eq}}{{#eq return.type "USER"}}Object{{/eq}} {{camelCase name}}{{#each pathVariables}}{{#if @first}}By{{else}}And{{/if}}{{pascalCase name}}{{/each}}({{#each pathVariables}}{{#unless @first}}, {{/unless}}{{type.java}} {{camelCase name}}{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}{{#eq input.type "DTO"}}{{body}}{{/eq}}{{#eq input.type "KEYFIELD"}}{{#eq pSDEAction.actionType "USERCUSTOM"}}{{body}}{{/eq}}{{/eq}}{{#eq input.type "DTOS"}}List<{{body}}>{{/eq}} {{#eq input.type "DTO"}}{{camelCase body}}{{/eq}}{{#eq input.type "KEYFIELD"}}{{#eq pSDEAction.actionType "USERCUSTOM"}}{{camelCase body}}{{/eq}}{{/eq}}{{#eq input.type "DTOS"}}list{{/eq}}{{/if}}){
throw new DataEntityRuntimeException(null,finalErrorMessage, Errors.INTERNALERROR, null);
}
{{/eq}}
{{!数据集}}
{{#eq methodType "FETCH"}}
public Page<{{apiEntity.codeName}}DTO> {{camelCase name}}{{#each pathVariables}}{{#if @first}}By{{else}}And{{/if}}{{pascalCase name}}{{/each}}({{#each pathVariables}}{{#unless @first}}, {{/unless}}{{type.java}} {{camelCase name}}{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}SearchContextDTO context{{/if}}){
throw new DataEntityRuntimeException(null,finalErrorMessage, Errors.INTERNALERROR, null);
}
{{/eq}}
{{!SELECT法}}
{{#eq methodType "SELECT"}}
public Page<{{apiEntity.codeName}}DTO> {{camelCase name}}{{#each pathVariables}}{{#if @first}}By{{else}}And{{/if}}{{pascalCase name}}{{/each}}({{#each pathVariables}}{{#unless @first}}, {{/unless}}{{type.java}} {{camelCase name}}{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}SearchContextDTO context{{/if}}){
throw new DataEntityRuntimeException(null,finalErrorMessage, Errors.INTERNALERROR, null);
}
{{/eq}}
{{/each}}
};
}
}
\ No newline at end of file
package {{packageName}}.{{lowerCase apiEntity.api.codeName}}.client;
import {{packageName}}.{{lowerCase apiEntity.api.codeName}}.dto.{{apiEntity.codeName}}DTO;
import net.ibizsys.central.util.SearchContextDTO;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.Collection;
import java.util.List;
/**
* 实体[{{apiEntity.codeName}}] 服务对象接口
*
*/
public interface {{apiEntity.codeName}}FeignClient {
{{#each apiEntity.methods}}
@RequestMapping(method = RequestMethod.{{requestMethod}}, value = "{{requestPath}}")
{{!行为}}
{{#eq methodType "DEACTION"}}
{{#eq return.type "DTO"}}{{apiEntity.codeName}}DTO{{/eq}}{{#eq return.type "DTOS"}}Page<{{apiEntity.codeName}}DTO>{{/eq}}{{#eq return.type "SIMPLE"}}Integer{{/eq}}{{#eq return.type "KEYFIELD"}}{{/eq}}{{#eq return.type "VOID"}}void{{/eq}}{{#eq return.type "USER"}}Object{{/eq}} {{camelCase name}}{{#each pathVariables}}{{#if @first}}By{{else}}And{{/if}}{{pascalCase name}}{{/each}}({{#each pathVariables}}{{#unless @first}}, {{/unless}}@PathVariable("{{camelCase name}}") {{type.java}} {{camelCase name}}{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}@RequestBody {{#eq input.type "DTO"}}{{body}}{{/eq}}{{#eq input.type "KEYFIELD"}}{{#eq pSDEAction.actionType "USERCUSTOM"}}{{body}}{{/eq}}{{/eq}}{{#eq input.type "DTOS"}}List<{{body}}>{{/eq}} {{#eq input.type "DTO"}}{{camelCase body}}{{/eq}}{{#eq input.type "KEYFIELD"}}{{#eq pSDEAction.actionType "USERCUSTOM"}}{{camelCase body}}{{/eq}}{{/eq}}{{#eq input.type "DTOS"}}list{{/eq}}{{/if}});
{{/eq}}
{{!数据集}}
{{#eq methodType "FETCH"}}
Page<{{apiEntity.codeName}}DTO> {{camelCase name}}{{#each pathVariables}}{{#if @first}}By{{else}}And{{/if}}{{pascalCase name}}{{/each}}({{#each pathVariables}}{{#unless @first}}, {{/unless}}@PathVariable("{{camelCase name}}") {{type.java}} {{camelCase name}}{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}@RequestBody SearchContextDTO context{{/if}});
{{/eq}}
{{!SELECT法}}
{{#eq methodType "SELECT"}}
Page<{{apiEntity.codeName}}DTO> {{camelCase name}}{{#each pathVariables}}{{#if @first}}By{{else}}And{{/if}}{{pascalCase name}}{{/each}}({{#each pathVariables}}{{#unless @first}}, {{/unless}}@PathVariable("{{camelCase name}}") {{type.java}} {{camelCase name}}{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}@RequestBody SearchContextDTO context{{/if}});
{{/eq}}
{{/each}}
}
\ No newline at end of file
package {{packageName}}.{{lowerCase apiEntity.api.codeName}}.client;
import net.ibizsys.api.helper.IgnorePrivInterceptor;
import net.ibizsys.api.helper.OutsideAccessorUtils;
import net.ibizsys.api.helper.SuperLoginClient;
import feign.Feign;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* {{apiEntity.entity.logicName}}
*
*/
@Configuration
public class {{apiEntity.codeName}}FeignClientConfiguration {
@Value("${ibiz.ref.service.ibizrt4ebsx-rt4ebsx.name:ibizrt4ebsx-rt4ebsx}")
String serviceValue;
@Value("${ibiz.ref.service.ibizrt4ebsx-rt4ebsx.system:f7ad7e05-9031-11eb-b882-00163e06e68c}")
String serviceSystem;
@Value("${ibiz.ref.service.ibizrt4ebsx-rt4ebsx.super:false}")
boolean superapi;
@Value("${ibiz.ref.service.uaa:ibizrt4ebsx-rt4ebsx}")
String uaaservice;
@Value("${ibiz.ref.service.ibizrt4ebsx-rt4ebsx.login:}")
String login;
@Value("${ibiz.ref.service.ibizrt4ebsx-rt4ebsx.password:}")
String password;
@Autowired
Feign.Builder builder;
@Autowired
OutsideAccessorUtils outsideAccessorUtils;
@Autowired
List<RequestInterceptor> defaultInterceptors;
@Bean
public {{apiEntity.codeName}}FeignClient {{camelCase apiEntity.codeName}}FeignClient() {
List<RequestInterceptor> requestInterceptors = new ArrayList<>();
requestInterceptors.addAll(defaultInterceptors);
RequestInterceptor systemInterceptor = new RequestInterceptor() {
@Override
public void apply(RequestTemplate requestTemplate) {
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
requestTemplate.header("srfsystemid", Collections.emptyList());
requestTemplate.header("srfsystemid", serviceSystem);
}
};
requestInterceptors.add(systemInterceptor);
//忽略权限
if (superapi) {
SuperLoginClient superLoginClient = outsideAccessorUtils.buildAccessor(SuperLoginClient.class, null, uaaservice, Arrays.asList(new RequestInterceptor() {
@Override
public void apply(RequestTemplate requestTemplate) {
requestTemplate.header("srfsystemid", Collections.emptyList());
requestTemplate.header("srforgid", Collections.emptyList());
requestTemplate.header("Authorization", Collections.emptyList());
}
}));
RequestInterceptor ignorePrivInterceptor = new IgnorePrivInterceptor(superLoginClient, login, password);
requestInterceptors.add(ignorePrivInterceptor);
}
return outsideAccessorUtils.buildAccessor({{apiEntity.codeName}}FeignClient.class, new {{apiEntity.codeName}}Fallback(), serviceValue, requestInterceptors);
}
}
\ No newline at end of file
package {{packageName}}.{{lowerCase apiEntity.api.codeName}}.client;
import {{packageName}}.{{lowerCase apiEntity.api.codeName}}.dto.{{apiEntity.codeName}}DTO;
import net.ibizsys.central.dataentity.IDataEntityRuntime;
import net.ibizsys.central.util.IEntityDTO;
import net.ibizsys.central.util.SearchContextDTO;
import net.ibizsys.model.dataentity.action.IPSDEAction;
import net.ibizsys.model.dataentity.ds.IPSDEDataSet;
import net.ibizsys.model.service.IPSSubSysServiceAPIDEMethod;
import net.ibizsys.runtime.util.DataTypeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageImpl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 实体[{{apiEntity.codeName}}] 对象
*
*/
public class {{apiEntity.codeName}}SubSysServiceAPIDERuntime extends {{packageName}}.{{lowerCase apiEntity.api.codeName}}.{{apiEntity.api.codeName}}R8SubSysServiceAPIDERuntime{
@Autowired
private {{apiEntity.codeName}}FeignClient client;
@Override
public Object invokeMethod(IPSSubSysServiceAPIDEMethod iPSSubSysServiceAPIDEMethod, IDataEntityRuntime iDataEntityRuntime, IPSDEAction iPSDEAction, Object[] args) throws Throwable {
Object key;
if (args[0] instanceof IEntityDTO) {
key = ((IEntityDTO) args[0]).get(iDataEntityRuntime.getKeyPSDEField().getName().toLowerCase());
} else {
key = args[0];
}
Object obj = null;
String strActionName = iPSDEAction.getName();
switch (strActionName){
{{#each apiEntity.methods}}
{{#unless parentApiEntities}}
{{#eq methodType "DEACTION"}}
case "{{name}}":
{{#eq return.type "DTO"}}obj = {{/eq}}{{#eq return.type "SIMPLE"}}obj = {{/eq}}{{#eq return.type "USER"}}obj = {{/eq}}client.{{camelCase name}}{{#each pathVariables}}{{#if @first}}By{{else}}And{{/if}}{{pascalCase name}}{{/each}}({{#each pathVariables}}{{#unless @first}}, {{/unless}}({{type.java}})key{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}{{#eq input.type "DTO"}}({{body}}){{/eq}}{{#eq input.type "KEYFIELD"}}{{#eq pSDEAction.actionType "USERCUSTOM"}}({{body}}){{/eq}}{{/eq}}{{#eq input.type "DTOS"}}(List<{{body}}>){{/eq}}args[0]{{/if}});
break;
{{/eq}}
{{/unless}}
{{/each}}
}
return obj;
}
@Override
public Object invokeMethod(IPSSubSysServiceAPIDEMethod iPSSubSysServiceAPIDEMethod, IDataEntityRuntime iDataEntityRuntime, IPSDEDataSet iPSDEDataSet, Object[] args) throws Throwable {
Object obj = null;
String strActionName = iPSDEDataSet.getName();
switch (strActionName){
{{#each apiEntity.methods}}
{{#unless parentApiEntities}}
{{#eq methodType "FETCH"}}
case "{{name}}":
obj = client.{{camelCase name}}{{#each pathVariables}}{{#if @first}}By{{else}}And{{/if}}{{pascalCase name}}{{/each}}({{#each pathVariables}}{{#unless @first}}, {{/unless}}({{type.java}})key{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}(SearchContextDTO)args[0]{{/if}});
break;
{{/eq}}
{{#eq methodType "SELECT"}}
case "{{name}}":
obj = client.{{camelCase name}}{{#each pathVariables}}{{#if @first}}By{{else}}And{{/if}}{{pascalCase name}}{{/each}}();
break;
{{/eq}}
{{/unless}}
{{/each}}
}
Map map = (Map) obj;
List recodes = new ArrayList();
long total = 0L;
if (map.containsKey("content")) {
List content = (List) map.get("content");
for (Object item : content) {
IEntityDTO entityDTO = iDataEntityRuntime.createEntity();
entityDTO.reload(item, true, false);
recodes.add(entityDTO);
}
}
if (map.containsKey("totalElements")) {
DataTypeUtils.getLongValue(map.get("totalElements"), 0L);
}
SearchContextDTO dto = (SearchContextDTO) args[0];
PageImpl page = new PageImpl(recodes, dto.getPageable(), total);
return page;
}
}
\ No newline at end of file
package {{packageName}}.{{apis}}.dto;
import java.sql.Timestamp;
import java.util.List;
import java.math.BigDecimal;
import net.ibizsys.central.util.EntityDTO;
import com.fasterxml.jackson.annotation.JsonIgnore;
import net.ibizsys.runtime.util.DataTypeUtils;
public class {{apiDto.codeName}} extends EntityDTO {
{{#each apiDto.apiDtoFields as |field|}}
/**
* {{field.logicName}}
*/
public final static String FIELD_{{upperCase field.codeName}} = "{{field.codeName}}";
/**
* 设置「{{field.logicName}}
*
* @param {{camelCase codeName}}
*/
@JsonIgnore
public {{apiDto.codeName}} set{{pascalCase codeName}}({{javaType}} {{camelCase codeName}}) {
this._set(FIELD_{{upperCase field.codeName}}, {{camelCase codeName}});
return this;
}
/**
* 获取「{{field.logicName}}」值
*
*/
@JsonIgnore
public {{javaType}} get{{pascalCase codeName}}() {
{{#if (or (eq javaType 'Integer') (eq javaType 'Long') (eq javaType 'Double') (eq javaType 'BigInteger') (eq javaType 'BigDecimal') (eq javaType 'Timestamp'))}}
try{
{{#if (eq javaType 'Timestamp')}}
return DataTypeUtils.getDateTimeValue(this._get(FIELD_{{upperCase field.codeName}}),null);
{{else}}
return DataTypeUtils.get{{javaType}}Value(this._get(FIELD_{{upperCase field.codeName}}),null);
{{/if}}
}catch (Exception e){
throw new RuntimeException(e);
}
{{else}}
return ({{javaType}}) this._get(FIELD_{{upperCase field.codeName}});
{{/if}}
}
/**
* 判断 「{{field.logicName}}」是否有值
*
*/
@JsonIgnore
public boolean contains{{pascalCase codeName}}() {
return this._contains(FIELD_{{upperCase field.codeName}});
}
/**
* 重置 「{{field.logicName}}
*
*/
@JsonIgnore
public {{apiDto.codeName}} reset{{pascalCase codeName}}() {
this._reset(FIELD_{{upperCase field.codeName}});
return this;
}
{{/each}}
}
package {{packageName}}.{{lowerCase api.codeName}};
import lombok.extern.slf4j.Slf4j;
import net.ibizsys.central.r8.service.R8SubSysServiceAPIDERuntime;
/**
* 提供外部容器启动服务能力
*/
@Slf4j
public class {{api.codeName}}R8SubSysServiceAPIDERuntime extends R8SubSysServiceAPIDERuntime {
}
\ No newline at end of file
package {{packageName}}.{{lowerCase api.codeName}};
import lombok.extern.slf4j.Slf4j;
import net.ibizsys.central.r8.service.R8SubSysServiceAPIRuntime;
import net.ibizsys.central.service.ISubSysServiceAPIDERuntime;
import net.ibizsys.model.service.IPSSubSysServiceAPIDE;
import net.ibizsys.api.rt4ebsx.client.*;
/**
* 提供外部容器启动服务能力
*/
@Slf4j
public class {{api.codeName}}R8SubSysServiceAPIRuntime extends R8SubSysServiceAPIRuntime {
@Override
protected ISubSysServiceAPIDERuntime createSubSysServiceAPIDERuntime(IPSSubSysServiceAPIDE iPSSubSysServiceAPIDE) throws Exception {
String strEntityName = iPSSubSysServiceAPIDE.getName();
switch (strEntityName){
{{#each api.apiEntities}}
case "{{apiDataEntity.name}}":
return new {{apiDataEntity.codeName}}SubSysServiceAPIDERuntime();
{{/each}}
default:
return new RT4EBSXR8SubSysServiceAPIDERuntime();
}
}
}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册