提交 56054369 编写于 作者: zhouweidong's avatar zhouweidong

合并分支 'dev' 到 'master'

Dev

查看合并请求 !38
# **iBiz4j Spring R7 Template ChangeLog** # **iBiz4j Spring R7 Template ChangeLog**
## [v2020.12.13]
- 支持工作流操作视图、操作表单配置
- 支持实体数据同步(RocketMQ)
- 支持工作流流程中状态值配置
- 支持父关系等价
- 支持属性值规则
- 支持界面行为多项数据主键
- 支持token续期
- 优化:补充接口实体服务接口鉴权
- 优化:动态数据源数据连接配置优化
- 优化:数据查询支持请求方式配置(默认为get,如:改为post)
- 优化:实体搜索项是否为空配置(搭配是否逻辑代码表使用)
- 优化:微服务部署中支持配置portmap将容器端口映射到主机端口(用于定时服务回调)
- 修复:服务接口返回状态码 response code
- 修复:实体行为、逻辑支持行为所有者配置
## [v2020.11.09] ## [v2020.11.09]
- 支持属性重复值检查 - 支持属性重复值检查
- 支持引用组件包配置 - 支持引用组件包配置
......
...@@ -55,13 +55,13 @@ import java.util.List; ...@@ -55,13 +55,13 @@ import java.util.List;
com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure.class com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure.class
</#if> </#if>
}) })
public class ${app.getPKGCodeName()}Application extends WebMvcConfigurerAdapter{ public class ${app.getPKGCodeName()}Application extends WebMvcConfigurerAdapter {
@Autowired @Autowired
SearchContextHandlerMethodArgumentResolver resolver; SearchContextHandlerMethodArgumentResolver resolver;
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(${app.getPKGCodeName()}Application.class,args); SpringApplication.run(${app.getPKGCodeName()}Application.class, args);
} }
@Override @Override
......
...@@ -115,10 +115,10 @@ public class ${app.getPKGCodeName()}SecurityConfig extends WebSecurityConfigurer ...@@ -115,10 +115,10 @@ public class ${app.getPKGCodeName()}SecurityConfig extends WebSecurityConfigurer
"/**/svg/**", "/**/svg/**",
"/" "/"
).permitAll() ).permitAll()
//放行登录请求 // 放行登录请求
.antMatchers( HttpMethod.POST,"/"+loginPath).permitAll() .antMatchers( HttpMethod.POST, "/"+loginPath).permitAll()
//放行注销请求 // 放行注销请求
.antMatchers( HttpMethod.GET,"/"+logoutPath).permitAll() .antMatchers( HttpMethod.GET, "/"+logoutPath).permitAll()
// 文件操作 // 文件操作
.antMatchers("/"+downloadpath+"/**").permitAll() .antMatchers("/"+downloadpath+"/**").permitAll()
.antMatchers("/"+uploadpath).permitAll() .antMatchers("/"+uploadpath).permitAll()
......
...@@ -50,8 +50,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -50,8 +50,8 @@ import org.springframework.beans.factory.annotation.Autowired;
</#if> </#if>
}) })
@ComponentScan(basePackages = {"${pub.getPKGCodeName()}"} @ComponentScan(basePackages = {"${pub.getPKGCodeName()}"}
// ,excludeFilters={ // ,excludeFilters = {
// @ComponentScan.Filter(type= org.springframework.context.annotation.FilterType.REGEX,pattern="${pub.getPKGCodeName()}.xxx.rest.xxx"), // @ComponentScan.Filter(type= org.springframework.context.annotation.FilterType.REGEX, pattern="${pub.getPKGCodeName()}.xxx.rest.xxx"),
// } // }
) )
@Import({ @Import({
...@@ -59,13 +59,13 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -59,13 +59,13 @@ import org.springframework.beans.factory.annotation.Autowired;
}) })
@EnableAsync @EnableAsync
@EnableScheduling @EnableScheduling
public class DevBootApplication extends WebMvcConfigurerAdapter{ public class DevBootApplication extends WebMvcConfigurerAdapter {
@Autowired @Autowired
SearchContextHandlerMethodArgumentResolver resolver; SearchContextHandlerMethodArgumentResolver resolver;
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(DevBootApplication.class,args); SpringApplication.run(DevBootApplication.class, args);
} }
@Override @Override
......
...@@ -113,9 +113,9 @@ public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -113,9 +113,9 @@ public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter {
"/v2/**" "/v2/**"
).permitAll() ).permitAll()
//放行登录请求 //放行登录请求
.antMatchers( HttpMethod.POST,"/"+loginPath).permitAll() .antMatchers( HttpMethod.POST, "/"+loginPath).permitAll()
//放行注销请求 //放行注销请求
.antMatchers( HttpMethod.GET,"/"+logoutPath).permitAll() .antMatchers( HttpMethod.GET, "/"+logoutPath).permitAll()
// 文件操作 // 文件操作
.antMatchers("/"+downloadpath+"/**").permitAll() .antMatchers("/"+downloadpath+"/**").permitAll()
.antMatchers("/"+uploadpath).permitAll() .antMatchers("/"+uploadpath).permitAll()
......
...@@ -31,7 +31,7 @@ import org.springframework.stereotype.Component; ...@@ -31,7 +31,7 @@ import org.springframework.stereotype.Component;
* 实体[${item.codeName}] 服务对象接口 * 实体[${item.codeName}] 服务对象接口
*/ */
@Component @Component
public class ${item.codeName}Fallback implements ${item.codeName}FeignClient{ public class ${item.codeName}Fallback implements ${item.codeName}FeignClient {
<#if item.getPSSubSysServiceAPIDEMethods()??> <#if item.getPSSubSysServiceAPIDEMethods()??>
<#list item.getPSSubSysServiceAPIDEMethods() as apiMethod> <#list item.getPSSubSysServiceAPIDEMethods() as apiMethod>
...@@ -46,57 +46,57 @@ public class ${item.codeName}Fallback implements ${item.codeName}FeignClient{ ...@@ -46,57 +46,57 @@ public class ${item.codeName}Fallback implements ${item.codeName}FeignClient{
<#-- ${return_type} ${srfmethodname(apiMethod.getCodeName())}(<#if req_param_type?? && req_param_type=='ENTITY'><#if apiMethod.getPSDEName()??>${apiMethod.getPSDEName()} entity</#if></#if>); --> <#-- ${return_type} ${srfmethodname(apiMethod.getCodeName())}(<#if req_param_type?? && req_param_type=='ENTITY'><#if apiMethod.getPSDEName()??>${apiMethod.getPSDEName()} entity</#if></#if>); -->
<#if apiMethod.getCodeName()?lower_case == 'get'> <#if apiMethod.getCodeName()?lower_case == 'get'>
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}")--> <#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}")-->
public ${refDE.codeName} get(${srfr7javatype(refDE.getKeyDEField().stdDataType)} ${refDE.getKeyDEField().getCodeName()?lower_case}){ public ${refDE.codeName} get(${srfr7javatype(refDE.getKeyDEField().stdDataType)} ${refDE.getKeyDEField().getCodeName()?lower_case}) {
return null; return null;
} }
<#elseif apiMethod.getCodeName()?lower_case == 'remove'> <#elseif apiMethod.getCodeName()?lower_case == 'remove'>
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}")--> <#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}")-->
public Boolean remove(${srfr7javatype(refDE.getKeyDEField().stdDataType)} ${refDE.getKeyDEField().getCodeName()?lower_case}){ public Boolean remove(${srfr7javatype(refDE.getKeyDEField().stdDataType)} ${refDE.getKeyDEField().getCodeName()?lower_case}) {
return false; return false;
} }
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")--> <#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")-->
public Boolean removeBatch(Collection<${srfr7javatype(refDE.getKeyDEField().stdDataType)}> idList){ public Boolean removeBatch(Collection<${srfr7javatype(refDE.getKeyDEField().stdDataType)}> idList) {
return false; return false;
} }
<#elseif apiMethod.getCodeName()?lower_case == 'create'> <#elseif apiMethod.getCodeName()?lower_case == 'create'>
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}")--> <#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}")-->
public ${refDE.codeName} create(${refDE.codeName} ${refDE.codeName?lower_case}){ public ${refDE.codeName} create(${refDE.codeName} ${refDE.codeName?lower_case}) {
return null; return null;
} }
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")--> <#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")-->
public Boolean createBatch(List<${refDE.codeName}> ${srfpluralize(refDE.getCodeName()?lower_case)}){ public Boolean createBatch(List<${refDE.codeName}> ${srfpluralize(refDE.getCodeName()?lower_case)}) {
return false; return false;
} }
<#elseif apiMethod.getCodeName()?lower_case == 'save'> <#elseif apiMethod.getCodeName()?lower_case == 'save'>
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}")--> <#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}")-->
public Boolean save(${refDE.codeName} ${refDE.codeName?lower_case}){ public Boolean save(${refDE.codeName} ${refDE.codeName?lower_case}) {
return false; return false;
} }
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")--> <#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")-->
public Boolean saveBatch(List<${refDE.codeName}> ${srfpluralize(refDE.getCodeName()?lower_case)}){ public Boolean saveBatch(List<${refDE.codeName}> ${srfpluralize(refDE.getCodeName()?lower_case)}) {
return false; return false;
} }
<#elseif apiMethod.getCodeName()?lower_case == 'update'> <#elseif apiMethod.getCodeName()?lower_case == 'update'>
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}")--> <#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}")-->
public ${refDE.codeName} update(${srfr7javatype(refDE.getKeyDEField().stdDataType)} ${refDE.getKeyDEField().getCodeName()?lower_case}, ${refDE.codeName} ${refDE.codeName?lower_case}){ public ${refDE.codeName} update(${srfr7javatype(refDE.getKeyDEField().stdDataType)} ${refDE.getKeyDEField().getCodeName()?lower_case}, ${refDE.codeName} ${refDE.codeName?lower_case}) {
return null; return null;
} }
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")--> <#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")-->
public Boolean updateBatch(List<${refDE.codeName}> ${srfpluralize(refDE.getCodeName()?lower_case)}){ public Boolean updateBatch(List<${refDE.codeName}> ${srfpluralize(refDE.getCodeName()?lower_case)}) {
return false; return false;
} }
<#elseif apiMethod.getCodeName()?lower_case == 'getdraft'> <#elseif apiMethod.getCodeName()?lower_case == 'getdraft'>
public ${refDE.codeName} getDraft(){ public ${refDE.codeName} getDraft(){
return null; return null;
} }
<#elseif apiMethod.getCodeName()?lower_case == 'checkkey'> <#elseif apiMethod.getCodeName()?lower_case == 'checkkey'>
public Boolean checkKey(${refDE.codeName} ${refDE.codeName?lower_case}){ public Boolean checkKey(${refDE.codeName} ${refDE.codeName?lower_case}) {
return false; return false;
} }
<#elseif apiMethod.getCodeName()?lower_case == 'createbatch'> <#elseif apiMethod.getCodeName()?lower_case == 'createbatch'>
<#elseif apiMethod.getCodeName()?lower_case == 'updatebatch'> <#elseif apiMethod.getCodeName()?lower_case == 'updatebatch'>
...@@ -104,26 +104,26 @@ public class ${item.codeName}Fallback implements ${item.codeName}FeignClient{ ...@@ -104,26 +104,26 @@ public class ${item.codeName}Fallback implements ${item.codeName}FeignClient{
<#elseif apiMethod.getCodeName()?lower_case == 'savebatch'> <#elseif apiMethod.getCodeName()?lower_case == 'savebatch'>
<#else> <#else>
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}/${apiMethod.getCodeName()?lower_case}")--> <#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}/${apiMethod.getCodeName()?lower_case}")-->
public ${refDE.codeName} ${apiMethod.getCodeName()?uncap_first}( ${srfr7javatype(refDE.getKeyDEField().stdDataType)} ${refDE.getKeyDEField().getCodeName()?lower_case}, ${refDE.codeName} ${refDE.codeName?lower_case}){ public ${refDE.codeName} ${apiMethod.getCodeName()?uncap_first}( ${srfr7javatype(refDE.getKeyDEField().stdDataType)} ${refDE.getKeyDEField().getCodeName()?lower_case}, ${refDE.codeName} ${refDE.codeName?lower_case}) {
return null; return null;
} }
</#if> </#if>
<#elseif apiMethod.getActionType()=='SELECT'><#comment>简单查询</#comment> <#elseif apiMethod.getActionType()=='SELECT'><#comment>简单查询</#comment>
<#-- List<${item.codeName}> ${srfmethodname(apiMethod.getCodeName())}(<#if req_param_type?? && req_param_type=='ENTITY'><#if apiMethod.getPSDEName()??>${apiMethod.getPSDEName()} entity</#if></#if>); --> <#-- List<${item.codeName}> ${srfmethodname(apiMethod.getCodeName())}(<#if req_param_type?? && req_param_type=='ENTITY'><#if apiMethod.getPSDEName()??>${apiMethod.getPSDEName()} entity</#if></#if>); -->
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")--> <#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")-->
public Page<${refDE.codeName}> ${apiMethod.getCodeName()?uncap_first}(){ public Page<${refDE.codeName}> ${apiMethod.getCodeName()?uncap_first}() {
return null; return null;
} }
<#elseif apiMethod.getActionType()=='FETCH'><#comment>数据集合</#comment> <#elseif apiMethod.getActionType()=='FETCH'><#comment>数据集合</#comment>
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")--> <#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")-->
public Page<${refDE.codeName}> ${apiMethod.getCodeName()?uncap_first?replace("fetch","search")}(${refDE.getCodeName()}SearchContext context){ public Page<${refDE.codeName}> ${apiMethod.getCodeName()?uncap_first?replace("fetch","search")}(${refDE.getCodeName()}SearchContext context) {
return null; return null;
} }
<#elseif apiMethod.getActionType()=='USER'><#comment>用户自定义</#comment> <#elseif apiMethod.getActionType()=='USER'><#comment>用户自定义</#comment>
public void ${apiMethod.getCodeName()?uncap_first}(){ public void ${apiMethod.getCodeName()?uncap_first}() {
return null; return null;
} }
</#if> </#if>
</#list> </#list>
......
...@@ -45,7 +45,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker; ...@@ -45,7 +45,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
@Setter @Setter
@NoArgsConstructor @NoArgsConstructor
@JsonIgnoreProperties(value = "handler") @JsonIgnoreProperties(value = "handler")
@TableName(value = "${item.getTableName()}",resultMap = "${item.codeName}ResultMap") @TableName(value = "${item.getTableName()}", resultMap = "${item.codeName}ResultMap")
public class ${item.getCodeName()} extends EntityMP implements Serializable { public class ${item.getCodeName()} extends EntityMP implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -69,25 +69,25 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable { ...@@ -69,25 +69,25 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
</#if> </#if>
<#if defield.getDefaultValueType()?? && defield.getDefaultValueType()!=''> <#if defield.getDefaultValueType()?? && defield.getDefaultValueType()!=''>
<#if defieldano?? && defieldano!=''> <#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , "> <#assign defieldano = defieldano+", ">
</#if> </#if>
<#assign defieldano = defieldano+"defaultValueType = DEFieldDefaultValueType."+defield.getDefaultValueType()?upper_case> <#assign defieldano = defieldano+"defaultValueType = DEFieldDefaultValueType."+defield.getDefaultValueType()?upper_case>
</#if> </#if>
<#if defield.isKeyDEField()==true> <#if defield.isKeyDEField()==true>
<#if defieldano?? && defieldano!=''> <#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , "> <#assign defieldano = defieldano+", ">
</#if> </#if>
<#assign defieldano = defieldano+"isKeyField=true"> <#assign defieldano = defieldano+"isKeyField = true">
<#elseif defield.getPredefinedType()?? && defield.getPredefinedType()!=''> <#elseif defield.getPredefinedType()?? && defield.getPredefinedType()!=''>
<#if defieldano?? && defieldano!=''> <#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , "> <#assign defieldano = defieldano+", ">
</#if> </#if>
<#assign defieldano = defieldano+"preType = DEPredefinedFieldType."+defield.getPredefinedType()?upper_case> <#assign defieldano = defieldano+"preType = DEPredefinedFieldType."+defield.getPredefinedType()?upper_case>
<#if defield.getPredefinedType()?lower_case =='createdate'||defield.getPredefinedType()?lower_case =='createman'> <#if defield.getPredefinedType()?lower_case =='createdate'||defield.getPredefinedType()?lower_case =='createman'>
<#assign tablefieldano = tablefieldano+" , fill = FieldFill.INSERT"> <#assign tablefieldano = tablefieldano+", fill = FieldFill.INSERT">
<#elseif defield.getPredefinedType()?lower_case =='logicvalid'> <#elseif defield.getPredefinedType()?lower_case =='logicvalid'>
<#if de.getLogicValidPSDEField()?? && de.isLogicValid()==true> <#if de.getLogicValidPSDEField()?? && de.isLogicValid()==true>
<#assign defieldano = defieldano+", logicval = \""+((item.getValidLogicValue())!'1')+"\" , logicdelval=\""+((item.getInvalidLogicValue())!'0')+"\""> <#assign defieldano = defieldano+", logicval = \""+((item.getValidLogicValue())!'1')+"\", logicdelval = \""+((item.getInvalidLogicValue())!'0')+"\"">
</#if> </#if>
</#if> </#if>
</#if> </#if>
...@@ -95,34 +95,34 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable { ...@@ -95,34 +95,34 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
<#if defield.isEnableAudit()==true && de.getAuditMode()!=0> <#if defield.isEnableAudit()==true && de.getAuditMode()!=0>
<#assign defStdType=srfr7javatype(defield.stdDataType)> <#assign defStdType=srfr7javatype(defield.stdDataType)>
<#if defieldano?? && defieldano!='' > <#if defieldano?? && defieldano!='' >
<#assign defieldano = defieldano+" , "> <#assign defieldano = defieldano+", ">
</#if> </#if>
<#assign defieldano = defieldano+"value = \""+jsonfield+"\""> <#assign defieldano = defieldano+"value = \""+jsonfield+"\"">
<#if defield.getPSCodeList?? && defield.getPSCodeList()??> <#if defield.getPSCodeList?? && defield.getPSCodeList()??>
<#if ((defield.getPredefinedType())!'')!='LOGICVALID'> <#if ((defield.getPredefinedType())!'')!='LOGICVALID'>
<#assign defieldano=defieldano+",dict=\""+defield.getPSCodeList().codeName+"\""> <#assign defieldano=defieldano+", dict = \""+defield.getPSCodeList().codeName+"\"">
</#if> </#if>
</#if> </#if>
<#if defDataType == "DATETIME"|| defDataType == "DATE" || defDataType == "TIME" || (defDataType=='PICKUPDATA'||defDataType=='INHERIT')&& defStdType=='Timestamp'> <#if defDataType == "DATETIME"|| defDataType == "DATE" || defDataType == "TIME" || (defDataType=='PICKUPDATA'||defDataType=='INHERIT')&& defStdType=='Timestamp'>
<#if defDataType == "DATETIME"> <#if defDataType == "DATETIME">
<#assign defieldano=defieldano+",fieldType=\"DATETIME\",format=\"yyyy-MM-dd HH:mm:ss\""> <#assign defieldano=defieldano+", fieldType = \"DATETIME\", format = \"yyyy-MM-dd HH:mm:ss\"">
<#elseif defDataType == "DATE"> <#elseif defDataType == "DATE">
<#assign defieldano=defieldano+",fieldType=\"DATE\",format=\"yyyy-MM-dd\""> <#assign defieldano=defieldano+", fieldType = \"DATE\", format = \"yyyy-MM-dd\"">
<#elseif defDataType == "TIME"> <#elseif defDataType == "TIME">
<#assign defieldano=defieldano+",fieldType=\"TIME\",format=\"HH:mm:ss\""> <#assign defieldano=defieldano+", fieldType = \"TIME\", format = \"HH:mm:ss\"">
<#elseif (defDataType=='PICKUPDATA'||defDataType=='INHERIT')&& defStdType=='Timestamp'><#comment>外键值附加数据,数据类型为时间</#comment> <#elseif (defDataType=='PICKUPDATA'||defDataType=='INHERIT')&& defStdType=='Timestamp'><#comment>外键值附加数据,数据类型为时间</#comment>
<#assign defieldano=defieldano+",fieldType=\"DATETIME\",format=\"yyyy-MM-dd HH:mm:ss\""> <#assign defieldano=defieldano+", fieldType = \"DATETIME\", format = \"yyyy-MM-dd HH:mm:ss\"">
</#if> </#if>
</#if> </#if>
</#if> </#if>
<#comment>重复值检查</#comment> <#comment>重复值检查</#comment>
<#if defield.getDupCheckMode?? && defield.getDupCheckMode()?? && defield.getDupCheckMode()=='ALL'> <#if defield.getDupCheckMode?? && defield.getDupCheckMode()?? && defield.getDupCheckMode()=='ALL'>
<#if defieldano?? && defieldano!='' > <#if defieldano?? && defieldano!='' >
<#assign defieldano = defieldano+" , "> <#assign defieldano = defieldano+", ">
</#if> </#if>
<#if defield.getDupCheckPSDEField?? && defield.getDupCheckPSDEField()??> <#if defield.getDupCheckPSDEField?? && defield.getDupCheckPSDEField()??>
<#assign dupCheckField = srfcaseformat(defield.getDupCheckPSDEField().getCodeName(),'l_u2lC') > <#assign dupCheckField = srfcaseformat(defield.getDupCheckPSDEField().getCodeName(),'l_u2lC') >
<#assign defieldano=defieldano+"dupCheck = DupCheck.ALL , dupCheckField=\""+dupCheckField+"\""> <#assign defieldano=defieldano+"dupCheck = DupCheck.ALL, dupCheckField = \""+dupCheckField+"\"">
<#else> <#else>
<#assign defieldano=defieldano+"dupCheck = DupCheck.ALL" > <#assign defieldano=defieldano+"dupCheck = DupCheck.ALL" >
</#if> </#if>
...@@ -141,11 +141,11 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable { ...@@ -141,11 +141,11 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
<#comment>主键</#comment> <#comment>主键</#comment>
<#if defield.isKeyDEField()==true && defield.isPhisicalDEField()==true> <#if defield.isKeyDEField()==true && defield.isPhisicalDEField()==true>
<#if defield.getDataType() == "ACID"> <#if defield.getDataType() == "ACID">
@TableId(value= "${columnname}",type=IdType.AUTO) @TableId(value = "${columnname}", type = IdType.AUTO)
<#elseif defield.getDataType() == "BIGINT"> <#elseif defield.getDataType() == "BIGINT">
@TableId(value= "${columnname}",type=IdType.ASSIGN_ID) @TableId(value = "${columnname}", type = IdType.ASSIGN_ID)
<#else> <#else>
@TableId(value= "${columnname}",type=IdType.ASSIGN_UUID) @TableId(value = "${columnname}", type = IdType.ASSIGN_UUID)
</#if> </#if>
<#elseif defield.isPhisicalDEField()==false> <#elseif defield.isPhisicalDEField()==false>
@TableField(exist = false) @TableField(exist = false)
...@@ -153,7 +153,7 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable { ...@@ -153,7 +153,7 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
<#comment>逻辑有效默认值-用于mybatis-plus删除时update逻辑有效值</#comment> <#comment>逻辑有效默认值-用于mybatis-plus删除时update逻辑有效值</#comment>
<#if de.getLogicValidPSDEField()?? && de.isLogicValid()==true> <#if de.getLogicValidPSDEField()?? && de.isLogicValid()==true>
<#if (((item.getValidLogicValue())!'')!='') && (((item.getInvalidLogicValue())!'')!='')> <#if (((item.getValidLogicValue())!'')!='') && (((item.getInvalidLogicValue())!'')!='')>
@TableLogic(value= "${item.getValidLogicValue()}",delval="${item.getInvalidLogicValue()}") @TableLogic(value = "${item.getValidLogicValue()}", delval = "${item.getInvalidLogicValue()}")
<#else> <#else>
@TableLogic @TableLogic
</#if> </#if>
...@@ -163,14 +163,14 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable { ...@@ -163,14 +163,14 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
@TableField(${tablefieldano}) @TableField(${tablefieldano})
</#if> </#if>
<#if defDataType == "DATETIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS")> <#if defDataType == "DATETIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
@JSONField(name = "${jsonfield}" , format="yyyy-MM-dd HH:mm:ss") @JSONField(name = "${jsonfield}", format = "yyyy-MM-dd HH:mm:ss")
<#elseif defDataType == "DATE" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td")> <#elseif defDataType == "DATE" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td")>
@JsonFormat(pattern="yyyy-MM-dd", locale = "zh" , timezone="GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", locale = "zh", timezone = "GMT+8")
@JSONField(name = "${jsonfield}" , format="yyyy-MM-dd") @JSONField(name = "${jsonfield}", format = "yyyy-MM-dd")
<#elseif defDataType == "TIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tH:%1$tM:%1$tS")> <#elseif defDataType == "TIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="HH:mm:ss", locale = "zh" , timezone="GMT+8") @JsonFormat(pattern = "HH:mm:ss", locale = "zh", timezone = "GMT+8")
@JSONField(name = "${jsonfield}" , format="HH:mm:ss") @JSONField(name = "${jsonfield}", format = "HH:mm:ss")
<#else> <#else>
@JSONField(name = "${jsonfield}") @JSONField(name = "${jsonfield}")
</#if> </#if>
...@@ -216,7 +216,7 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable { ...@@ -216,7 +216,7 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
</#if> </#if>
</#list> </#list>
</#if> </#if>
<#if nested> <#if nested && !P.exists(de.codeName,"nested",listcode)>
/** /**
* ${der.getMinorPSDataEntity().getLogicName()} * ${der.getMinorPSDataEntity().getLogicName()}
*/ */
...@@ -240,9 +240,9 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable { ...@@ -240,9 +240,9 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
/** /**
* 设置 [${der.getMinorPSDataEntity().getLogicName()}] * 设置 [${der.getMinorPSDataEntity().getLogicName()}]
*/ */
public void set${srfcaseformat(listcode,'l_u2lC')?cap_first}(List<${pub.getPKGCodeName()}.core.${der.getMinorPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.domain.${der.getMinorPSDataEntity().getCodeName()}> ${srfcaseformat(listcode,'l_u2lC')}){ public void set${srfcaseformat(listcode,'l_u2lC')?cap_first}(List<${pub.getPKGCodeName()}.core.${der.getMinorPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.domain.${der.getMinorPSDataEntity().getCodeName()}> ${srfcaseformat(listcode,'l_u2lC')}) {
this.${srfcaseformat(listcode,'l_u2lC')} = ${srfcaseformat(listcode,'l_u2lC')} ; this.${srfcaseformat(listcode,'l_u2lC')} = ${srfcaseformat(listcode,'l_u2lC')};
this.modify("${columnname}",(${srfcaseformat(listcode,'l_u2lC')}!=null)?${srfcaseformat(listcode,'l_u2lC')}:(new ArrayList())); this.modify("${columnname}", (${srfcaseformat(listcode,'l_u2lC')}!=null)?${srfcaseformat(listcode,'l_u2lC')}:(new ArrayList()));
} }
</#if> </#if>
</#if> </#if>
...@@ -265,9 +265,9 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable { ...@@ -265,9 +265,9 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
/** /**
* 设置 [${defield.getLogicName()}] * 设置 [${defield.getLogicName()}]
*/ */
public void set${publicCodeName}(${srfr7javatype(defield.getStdDataType())} ${prvateCodeName}){ public void set${publicCodeName}(${srfr7javatype(defield.getStdDataType())} ${prvateCodeName}) {
this.${prvateCodeName} = ${prvateCodeName} ; this.${prvateCodeName} = ${prvateCodeName};
this.modify("${columnname}",${prvateCodeName}); this.modify("${columnname}", ${prvateCodeName});
} }
<#if defDataType == "DATETIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS")> <#if defDataType == "DATETIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS")>
...@@ -284,7 +284,7 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable { ...@@ -284,7 +284,7 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
/** /**
* 格式化日期 [${defield.getLogicName()}] * 格式化日期 [${defield.getLogicName()}]
*/ */
public String format${publicCodeName}(){ public String format${publicCodeName}() {
if (this.${prvateCodeName} == null) { if (this.${prvateCodeName} == null) {
return null; return null;
} }
...@@ -311,7 +311,7 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable { ...@@ -311,7 +311,7 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
/** /**
* 获取 [${keyField.getLogicName()}] * 获取 [${keyField.getLogicName()}]
*/ */
public ${srfr7javatype(keyField.getStdDataType())} get${publicCodeName}(){ public ${srfr7javatype(keyField.getStdDataType())} get${publicCodeName}() {
Object id=getDefaultKey(true); Object id=getDefaultKey(true);
return ObjectUtils.isEmpty(id)?null:(${srfr7javatype(keyField.getStdDataType())})id; return ObjectUtils.isEmpty(id)?null:(${srfr7javatype(keyField.getStdDataType())})id;
} }
...@@ -320,18 +320,18 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable { ...@@ -320,18 +320,18 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
* 设置 [${keyField.getLogicName()}] * 设置 [${keyField.getLogicName()}]
*/ */
public void set${publicCodeName}(${srfr7javatype(keyField.getStdDataType())} ${prvateCodeName}) { public void set${publicCodeName}(${srfr7javatype(keyField.getStdDataType())} ${prvateCodeName}) {
if(!ObjectUtils.isEmpty(${prvateCodeName})){ if(!ObjectUtils.isEmpty(${prvateCodeName})) {
String [] args=${prvateCodeName}.split("\\|\\|"); String [] args=${prvateCodeName}.split("\\|\\|");
if(args.length==${unionKeySize}){ if(args.length == ${unionKeySize}){
${checkUnionKey2(item.getUnionKeyValuePSDEFields())}{ ${checkUnionKey2(item.getUnionKeyValuePSDEFields())} {
<#list item.getUnionKeyValuePSDEFields() as defield> <#list item.getUnionKeyValuePSDEFields() as defield>
<#assign unionKeyPrivateCodeName = srfcaseformat(defield.getCodeName(),'l_u2lC') > <#assign unionKeyPrivateCodeName = srfcaseformat(defield.getCodeName(),'l_u2lC') >
<#assign unionKeyPublicCodeName = unionKeyPrivateCodeName?cap_first > <#assign unionKeyPublicCodeName = unionKeyPrivateCodeName?cap_first >
this.set("${unionKeyPrivateCodeName}",args[${defield_index}]); this.set("${unionKeyPrivateCodeName}", args[${defield_index}]);
</#list> </#list>
} }
} }
this.${prvateCodeName} = ${prvateCodeName} ; this.${prvateCodeName} = ${prvateCodeName};
} }
} }
...@@ -346,8 +346,8 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable { ...@@ -346,8 +346,8 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
/** /**
* 获取 [${keyField.getLogicName()}] * 获取 [${keyField.getLogicName()}]
*/ */
public ${srfr7javatype(keyField.getStdDataType())} get${publicCodeName}(){ public ${srfr7javatype(keyField.getStdDataType())} get${publicCodeName}() {
if(ObjectUtils.isEmpty(${prvateCodeName})){ if(ObjectUtils.isEmpty(${prvateCodeName})) {
${prvateCodeName}=(${srfr7javatype(keyField.stdDataType)})getDefaultKey(true); ${prvateCodeName}=(${srfr7javatype(keyField.stdDataType)})getDefaultKey(true);
} }
return ${prvateCodeName}; return ${prvateCodeName};
...@@ -364,7 +364,7 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable { ...@@ -364,7 +364,7 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
<#elseif srfr7javatype(keyField.getStdDataType())=='Long'> <#elseif srfr7javatype(keyField.getStdDataType())=='Long'>
@Override @Override
public Serializable getDefaultKey(boolean gen) { public Serializable getDefaultKey(boolean gen) {
return IdWorker.getId(); return IdWorker.getId();
} }
</#if> </#if>
<#comment>判断是否有拷贝重置属性</#comment> <#comment>判断是否有拷贝重置属性</#comment>
...@@ -393,7 +393,7 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable { ...@@ -393,7 +393,7 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
this.reset("${columnname}"); this.reset("${columnname}");
</#if> </#if>
</#list> </#list>
return super.copyTo(targetEntity,bIncEmpty); return super.copyTo(targetEntity, bIncEmpty);
} }
</#if> </#if>
} }
...@@ -439,17 +439,17 @@ public class ${item.getCodeName()} extends EntityMongo implements Serializable { ...@@ -439,17 +439,17 @@ public class ${item.getCodeName()} extends EntityMongo implements Serializable {
</#if> </#if>
<#if defield.isKeyDEField()==true> <#if defield.isKeyDEField()==true>
<#if defieldano?? && defieldano!=''> <#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , "> <#assign defieldano = defieldano+", ">
</#if> </#if>
<#assign defieldano = defieldano+"isKeyField=true"> <#assign defieldano = defieldano+"isKeyField = true">
<#elseif defield.getPredefinedType()?? && defield.getPredefinedType()!=''> <#elseif defield.getPredefinedType()?? && defield.getPredefinedType()!=''>
<#if defieldano?? && defieldano!=''> <#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , "> <#assign defieldano = defieldano+", ">
</#if> </#if>
<#assign defieldano = defieldano+"preType = DEPredefinedFieldType."+defield.getPredefinedType()?upper_case> <#assign defieldano = defieldano+"preType = DEPredefinedFieldType."+defield.getPredefinedType()?upper_case>
<#if defield.getPredefinedType()?lower_case =='logicvalid'> <#if defield.getPredefinedType()?lower_case =='logicvalid'>
<#if de.getLogicValidPSDEField()?? && de.isLogicValid()==true> <#if de.getLogicValidPSDEField()?? && de.isLogicValid()==true>
<#assign defieldano = defieldano+", logicval = \""+((item.getValidLogicValue())!'1')+"\" , logicdelval=\""+((item.getInvalidLogicValue())!'0')+"\""> <#assign defieldano = defieldano+", logicval = \""+((item.getValidLogicValue())!'1')+"\" , logicdelval = \""+((item.getInvalidLogicValue())!'0')+"\"">
</#if> </#if>
</#if> </#if>
</#if> </#if>
...@@ -469,14 +469,14 @@ public class ${item.getCodeName()} extends EntityMongo implements Serializable { ...@@ -469,14 +469,14 @@ public class ${item.getCodeName()} extends EntityMongo implements Serializable {
</#if> </#if>
<#assign defDataType = (defield.getDataType())!""> <#assign defDataType = (defield.getDataType())!"">
<#if defDataType == "DATETIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS")> <#if defDataType == "DATETIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
@JSONField(name = "${jsonfield}" , format="yyyy-MM-dd HH:mm:ss") @JSONField(name = "${jsonfield}" , format = "yyyy-MM-dd HH:mm:ss")
<#elseif defDataType == "DATE" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td")> <#elseif defDataType == "DATE" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td")>
@JsonFormat(pattern="yyyy-MM-dd", locale = "zh" , timezone="GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", locale = "zh", timezone = "GMT+8")
@JSONField(name = "${jsonfield}" , format="yyyy-MM-dd") @JSONField(name = "${jsonfield}" , format="yyyy-MM-dd")
<#elseif defDataType == "TIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tH:%1$tM:%1$tS")> <#elseif defDataType == "TIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="HH:mm:ss", locale = "zh" , timezone="GMT+8") @JsonFormat(pattern = "HH:mm:ss", locale = "zh", timezone = "GMT+8")
@JSONField(name = "${jsonfield}" , format="HH:mm:ss") @JSONField(name = "${jsonfield}", format = "HH:mm:ss")
<#else> <#else>
@JSONField(name = "${jsonfield}") @JSONField(name = "${jsonfield}")
</#if> </#if>
...@@ -525,7 +525,7 @@ public class ${item.getCodeName()} extends EntityMongo implements Serializable { ...@@ -525,7 +525,7 @@ public class ${item.getCodeName()} extends EntityMongo implements Serializable {
</#if> </#if>
</#list> </#list>
</#if> </#if>
<#if nested> <#if nested && !P.exists(de.codeName,"nested",listcode)>
/** /**
* ${der.getMinorPSDataEntity().getLogicName()} * ${der.getMinorPSDataEntity().getLogicName()}
*/ */
...@@ -558,7 +558,7 @@ public class ${item.getCodeName()} extends EntityMongo implements Serializable { ...@@ -558,7 +558,7 @@ public class ${item.getCodeName()} extends EntityMongo implements Serializable {
/** /**
* 获取 [${keyField.getLogicName()}] * 获取 [${keyField.getLogicName()}]
*/ */
public ${srfr7javatype(keyField.getStdDataType())} get${publicCodeName}(){ public ${srfr7javatype(keyField.getStdDataType())} get${publicCodeName}() {
if(ObjectUtils.isEmpty(${privateCodeName})){ if(ObjectUtils.isEmpty(${privateCodeName})){
${privateCodeName}=(${srfr7javatype(keyField.stdDataType)})getDefaultKey(true); ${privateCodeName}=(${srfr7javatype(keyField.stdDataType)})getDefaultKey(true);
} }
...@@ -604,7 +604,7 @@ public class ${item.getCodeName()} extends EntityClient implements Serializable ...@@ -604,7 +604,7 @@ public class ${item.getCodeName()} extends EntityClient implements Serializable
</#if> </#if>
<#if defield.getDefaultValueType()?? && defield.getDefaultValueType()!=''> <#if defield.getDefaultValueType()?? && defield.getDefaultValueType()!=''>
<#if defieldano?? && defieldano!=''> <#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , "> <#assign defieldano = defieldano+", ">
</#if> </#if>
<#assign defieldano = defieldano+"defaultValueType = DEFieldDefaultValueType."+defield.getDefaultValueType()?upper_case> <#assign defieldano = defieldano+"defaultValueType = DEFieldDefaultValueType."+defield.getDefaultValueType()?upper_case>
</#if> </#if>
...@@ -612,15 +612,15 @@ public class ${item.getCodeName()} extends EntityClient implements Serializable ...@@ -612,15 +612,15 @@ public class ${item.getCodeName()} extends EntityClient implements Serializable
<#if defieldano?? && defieldano!=''> <#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , "> <#assign defieldano = defieldano+" , ">
</#if> </#if>
<#assign defieldano = defieldano+"isKeyField=true"> <#assign defieldano = defieldano+"isKeyField = true">
<#elseif defield.getPredefinedType()?? && defield.getPredefinedType()!=''> <#elseif defield.getPredefinedType()?? && defield.getPredefinedType()!=''>
<#if defieldano?? && defieldano!=''> <#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , "> <#assign defieldano = defieldano+", ">
</#if> </#if>
<#assign defieldano = defieldano+"preType = DEPredefinedFieldType."+defield.getPredefinedType()?upper_case> <#assign defieldano = defieldano+"preType = DEPredefinedFieldType."+defield.getPredefinedType()?upper_case>
<#if defield.getPredefinedType()?lower_case =='logicvalid'> <#if defield.getPredefinedType()?lower_case =='logicvalid'>
<#if de.getLogicValidPSDEField()?? && de.isLogicValid()==true> <#if de.getLogicValidPSDEField()?? && de.isLogicValid()==true>
<#assign defieldano = defieldano+", logicval = \""+((item.getValidLogicValue())!'1')+"\" , logicdelval=\""+((item.getInvalidLogicValue())!'0')+"\""> <#assign defieldano = defieldano+", logicval = \""+((item.getValidLogicValue())!'1')+"\" , logicdelval = \""+((item.getInvalidLogicValue())!'0')+"\"">
</#if> </#if>
</#if> </#if>
</#if> </#if>
...@@ -637,14 +637,14 @@ public class ${item.getCodeName()} extends EntityClient implements Serializable ...@@ -637,14 +637,14 @@ public class ${item.getCodeName()} extends EntityClient implements Serializable
</#if> </#if>
<#assign defDataType = (defield.getDataType())!""> <#assign defDataType = (defield.getDataType())!"">
<#if defDataType == "DATETIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS")> <#if defDataType == "DATETIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
@JSONField(name = "${jsonfield}" , format="yyyy-MM-dd HH:mm:ss") @JSONField(name = "${jsonfield}" , format = "yyyy-MM-dd HH:mm:ss")
<#elseif defDataType == "DATE" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td")> <#elseif defDataType == "DATE" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td")>
@JsonFormat(pattern="yyyy-MM-dd", locale = "zh" , timezone="GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", locale = "zh", timezone = "GMT+8")
@JSONField(name = "${jsonfield}" , format="yyyy-MM-dd") @JSONField(name = "${jsonfield}" , format = "yyyy-MM-dd")
<#elseif defDataType == "TIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tH:%1$tM:%1$tS")> <#elseif defDataType == "TIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="HH:mm:ss", locale = "zh" , timezone="GMT+8") @JsonFormat(pattern = "HH:mm:ss", locale = "zh", timezone = "GMT+8")
@JSONField(name = "${jsonfield}" , format="HH:mm:ss") @JSONField(name = "${jsonfield}", format = "HH:mm:ss")
<#else> <#else>
@JSONField(name = "${jsonfield}") @JSONField(name = "${jsonfield}")
</#if> </#if>
...@@ -689,7 +689,7 @@ public class ${item.getCodeName()} extends EntityClient implements Serializable ...@@ -689,7 +689,7 @@ public class ${item.getCodeName()} extends EntityClient implements Serializable
</#if> </#if>
</#list> </#list>
</#if> </#if>
<#if nested> <#if nested && !P.exists(de.codeName,"nested",listcode)>
/** /**
* ${der.getMinorPSDataEntity().getLogicName()} * ${der.getMinorPSDataEntity().getLogicName()}
*/ */
...@@ -718,7 +718,7 @@ public class ${item.getCodeName()} extends EntityClient implements Serializable ...@@ -718,7 +718,7 @@ public class ${item.getCodeName()} extends EntityClient implements Serializable
/** /**
* 设置 [${defield.getLogicName()}] * 设置 [${defield.getLogicName()}]
*/ */
public void set${publicCodeName}(${srfr7javatype(defield.getStdDataType())} ${prvateCodeName}){ public void set${publicCodeName}(${srfr7javatype(defield.getStdDataType())} ${prvateCodeName}) {
this.${prvateCodeName} = ${prvateCodeName} ; this.${prvateCodeName} = ${prvateCodeName} ;
this.modify("${columnname}",${prvateCodeName}); this.modify("${columnname}",${prvateCodeName});
} }
...@@ -737,7 +737,7 @@ public class ${item.getCodeName()} extends EntityClient implements Serializable ...@@ -737,7 +737,7 @@ public class ${item.getCodeName()} extends EntityClient implements Serializable
/** /**
* 格式化日期 [${defield.getLogicName()}] * 格式化日期 [${defield.getLogicName()}]
*/ */
public String format${publicCodeName}(){ public String format${publicCodeName}() {
if (this.${prvateCodeName} == null) { if (this.${prvateCodeName} == null) {
return null; return null;
} }
...@@ -812,23 +812,23 @@ public class ${item.getCodeName()} extends EntityBase implements Serializable { ...@@ -812,23 +812,23 @@ public class ${item.getCodeName()} extends EntityBase implements Serializable {
</#if> </#if>
<#if defield.getDefaultValueType()?? && defield.getDefaultValueType()!=''> <#if defield.getDefaultValueType()?? && defield.getDefaultValueType()!=''>
<#if defieldano?? && defieldano!=''> <#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , "> <#assign defieldano = defieldano+", ">
</#if> </#if>
<#assign defieldano = defieldano+"defaultValueType = DEFieldDefaultValueType."+defield.getDefaultValueType()?upper_case> <#assign defieldano = defieldano+"defaultValueType = DEFieldDefaultValueType."+defield.getDefaultValueType()?upper_case>
</#if> </#if>
<#if defield.isKeyDEField()==true> <#if defield.isKeyDEField()==true>
<#if defieldano?? && defieldano!=''> <#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , "> <#assign defieldano = defieldano+", ">
</#if> </#if>
<#assign defieldano = defieldano+"isKeyField=true"> <#assign defieldano = defieldano+"isKeyField = true">
<#elseif defield.getPredefinedType()?? && defield.getPredefinedType()!=''> <#elseif defield.getPredefinedType()?? && defield.getPredefinedType()!=''>
<#if defieldano?? && defieldano!=''> <#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , "> <#assign defieldano = defieldano+", ">
</#if> </#if>
<#assign defieldano = defieldano+"preType = DEPredefinedFieldType."+defield.getPredefinedType()?upper_case> <#assign defieldano = defieldano+"preType = DEPredefinedFieldType."+defield.getPredefinedType()?upper_case>
<#if defield.getPredefinedType()?lower_case =='logicvalid'> <#if defield.getPredefinedType()?lower_case =='logicvalid'>
<#if de.getLogicValidPSDEField()?? && de.isLogicValid()==true> <#if de.getLogicValidPSDEField()?? && de.isLogicValid()==true>
<#assign defieldano = defieldano+", logicval = \""+((item.getValidLogicValue())!'1')+"\" , logicdelval=\""+((item.getInvalidLogicValue())!'0')+"\""> <#assign defieldano = defieldano+", logicval = \""+((item.getValidLogicValue())!'1')+"\" , logicdelval = \""+((item.getInvalidLogicValue())!'0')+"\"">
</#if> </#if>
</#if> </#if>
</#if> </#if>
...@@ -845,14 +845,14 @@ public class ${item.getCodeName()} extends EntityBase implements Serializable { ...@@ -845,14 +845,14 @@ public class ${item.getCodeName()} extends EntityBase implements Serializable {
</#if> </#if>
<#assign defDataType = (defield.getDataType())!""> <#assign defDataType = (defield.getDataType())!"">
<#if defDataType == "DATETIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS")> <#if defDataType == "DATETIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
@JSONField(name = "${jsonfield}" , format="yyyy-MM-dd HH:mm:ss") @JSONField(name = "${jsonfield}", format = "yyyy-MM-dd HH:mm:ss")
<#elseif defDataType == "DATE" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td")> <#elseif defDataType == "DATE" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td")>
@JsonFormat(pattern="yyyy-MM-dd", locale = "zh" , timezone="GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", locale = "zh", timezone = "GMT+8")
@JSONField(name = "${jsonfield}" , format="yyyy-MM-dd") @JSONField(name = "${jsonfield}", format = "yyyy-MM-dd")
<#elseif defDataType == "TIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tH:%1$tM:%1$tS")> <#elseif defDataType == "TIME" || ((defDataType=='PICKUPDATA'||defDataType=='INHERIT') && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="HH:mm:ss", locale = "zh" , timezone="GMT+8") @JsonFormat(pattern = "HH:mm:ss", locale = "zh", timezone = "GMT+8")
@JSONField(name = "${jsonfield}" , format="HH:mm:ss") @JSONField(name = "${jsonfield}", format = "HH:mm:ss")
<#else> <#else>
@JSONField(name = "${jsonfield}") @JSONField(name = "${jsonfield}")
</#if> </#if>
...@@ -897,7 +897,7 @@ public class ${item.getCodeName()} extends EntityBase implements Serializable { ...@@ -897,7 +897,7 @@ public class ${item.getCodeName()} extends EntityBase implements Serializable {
</#if> </#if>
</#list> </#list>
</#if> </#if>
<#if nested> <#if nested && !P.exists(de.codeName,"nested",listcode)>
/** /**
* ${der.getMinorPSDataEntity().getLogicName()} * ${der.getMinorPSDataEntity().getLogicName()}
*/ */
...@@ -935,7 +935,7 @@ public class ${item.getCodeName()} extends EntityBase implements Serializable { ...@@ -935,7 +935,7 @@ public class ${item.getCodeName()} extends EntityBase implements Serializable {
/** /**
* 格式化日期 [${defield.getLogicName()}] * 格式化日期 [${defield.getLogicName()}]
*/ */
public String format${publicCodeName}(){ public String format${publicCodeName}() {
if (this.${prvateCodeName} == null) { if (this.${prvateCodeName} == null) {
return null; return null;
} }
......
...@@ -39,22 +39,24 @@ public class ${item.codeName}SearchContext extends QueryWrapperContext<${item.co ...@@ -39,22 +39,24 @@ public class ${item.codeName}SearchContext extends QueryWrapperContext<${item.co
<#if defield.getAllPSDEFSearchModes()??> <#if defield.getAllPSDEFSearchModes()??>
<#list defield.getAllPSDEFSearchModes() as formitem> <#list defield.getAllPSDEFSearchModes() as formitem>
<#if formitem.getPSDEField()??> <#if formitem.getPSDEField()??>
<#assign formItemDataType=srfr7javatype(formitem.getPSDEField().stdDataType)>
<#assign defDataType=formitem.getPSDEField().getDataType()> <#assign defDataType=formitem.getPSDEField().getDataType()>
<#if defDataType == "DATETIME"> <#comment>in条件通过String接,通过split拆后再进行查询</#comment>
<#if formitem.getValueOp() == "IN" || formitem.getValueOp() == "ISNULL" || formitem.getValueOp() == "ISNOTNULL">
<#assign formItemDataType="String">
</#if>
<#if formItemDataType !="String">
<#if defDataType == "DATETIME">
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8") @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
@JSONField(format="yyyy-MM-dd HH:mm:ss") @JSONField(format="yyyy-MM-dd HH:mm:ss")
<#elseif defDataType == "DATE"> <#elseif defDataType == "DATE">
@JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+8") @JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+8")
@JSONField(format="yyyy-MM-dd") @JSONField(format="yyyy-MM-dd")
<#elseif defDataType == "TIME"> <#elseif defDataType == "TIME">
@JsonFormat(pattern="HH:mm", timezone="GMT+8") @JsonFormat(pattern="HH:mm", timezone="GMT+8")
@JSONField(format="HH:mm") @JSONField(format="HH:mm")
</#if>
</#if> </#if>
<#assign formItemDataType=srfr7javatype(formitem.getPSDEField().stdDataType)>
<#comment>in条件通过String接,通过split拆后再进行查询</#comment>
<#if formitem.getValueOp() == "IN">
<#assign formItemDataType="String">
</#if>
private ${formItemDataType} ${formitem.getName()?lower_case};//[${defield.getLogicName()}] private ${formItemDataType} ${formitem.getName()?lower_case};//[${defield.getLogicName()}]
public void set${formitem.getName()?lower_case?cap_first}(${formItemDataType} ${formitem.getName()?lower_case}) { public void set${formitem.getName()?lower_case?cap_first}(${formItemDataType} ${formitem.getName()?lower_case}) {
this.${formitem.getName()?lower_case} = ${formitem.getName()?lower_case}; this.${formitem.getName()?lower_case} = ${formitem.getName()?lower_case};
...@@ -78,11 +80,11 @@ public class ${item.codeName}SearchContext extends QueryWrapperContext<${item.co ...@@ -78,11 +80,11 @@ public class ${item.codeName}SearchContext extends QueryWrapperContext<${item.co
<#elseif formitem.getValueOp() == "LTANDEQ"> <#elseif formitem.getValueOp() == "LTANDEQ">
this.getSearchCond().le("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case}); this.getSearchCond().le("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "ISNOTNULL"> <#elseif formitem.getValueOp() == "ISNOTNULL">
if(this.${formitem.getName()?lower_case}.toString().equals("1")){ if(this.${formitem.getName()?lower_case}.equals("1")){
this.getSearchCond().isNotNull("${formitem.getPSDEField().getName()?lower_case}"); this.getSearchCond().isNotNull("${formitem.getPSDEField().getName()?lower_case}");
} }
<#elseif formitem.getValueOp() == "ISNULL"> <#elseif formitem.getValueOp() == "ISNULL">
if(this.${formitem.getName()?lower_case}.toString().equals("1")){ if(this.${formitem.getName()?lower_case}.equals("1")){
this.getSearchCond().isNull("${formitem.getPSDEField().getName()?lower_case}"); this.getSearchCond().isNull("${formitem.getPSDEField().getName()?lower_case}");
} }
<#elseif formitem.getValueOp() == "IN"> <#elseif formitem.getValueOp() == "IN">
...@@ -106,6 +108,7 @@ public class ${item.codeName}SearchContext extends QueryWrapperContext<${item.co ...@@ -106,6 +108,7 @@ public class ${item.codeName}SearchContext extends QueryWrapperContext<${item.co
/** /**
* 启用快速搜索 * 启用快速搜索
*/ */
@Override
public void setQuery(String query) public void setQuery(String query)
{ {
this.query=query; this.query=query;
...@@ -117,10 +120,10 @@ public class ${item.codeName}SearchContext extends QueryWrapperContext<${item.co ...@@ -117,10 +120,10 @@ public class ${item.codeName}SearchContext extends QueryWrapperContext<${item.co
<#assign bHasSearch = true > <#assign bHasSearch = true >
<#if bFisrtLoop> <#if bFisrtLoop>
this.getSearchCond().and( wrapper -> this.getSearchCond().and( wrapper ->
wrapper.like("${defield.name?lower_case}", query) wrapper.like("${defield.name?lower_case}", query)
<#assign bFisrtLoop = false > <#assign bFisrtLoop = false >
<#else> <#else>
.or().like("${defield.name?lower_case}", query) .or().like("${defield.name?lower_case}", query)
</#if> </#if>
</#if> </#if>
</#list> </#list>
...@@ -150,22 +153,24 @@ public class ${item.codeName}SearchContext extends QueryBuildContext { ...@@ -150,22 +153,24 @@ public class ${item.codeName}SearchContext extends QueryBuildContext {
<#if defield.getAllPSDEFSearchModes()??> <#if defield.getAllPSDEFSearchModes()??>
<#list defield.getAllPSDEFSearchModes() as formitem> <#list defield.getAllPSDEFSearchModes() as formitem>
<#if formitem.getPSDEField()??> <#if formitem.getPSDEField()??>
<#assign formItemDataType=srfr7javatype(formitem.getPSDEField().stdDataType)>
<#assign defDataType=formitem.getPSDEField().getDataType()> <#assign defDataType=formitem.getPSDEField().getDataType()>
<#if defDataType == "DATETIME"> <#comment>in条件通过String接,通过split拆后再进行查询</#comment>
<#if formitem.getValueOp() == "IN" || formitem.getValueOp() == "ISNULL" || formitem.getValueOp() == "ISNOTNULL">
<#assign formItemDataType="String">
</#if>
<#if formItemDataType !="String">
<#if defDataType == "DATETIME">
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8") @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
@JSONField(format="yyyy-MM-dd HH:mm:ss") @JSONField(format="yyyy-MM-dd HH:mm:ss")
<#elseif defDataType == "DATE"> <#elseif defDataType == "DATE">
@JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+8") @JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+8")
@JSONField(format="yyyy-MM-dd") @JSONField(format="yyyy-MM-dd")
<#elseif defDataType == "TIME"> <#elseif defDataType == "TIME">
@JsonFormat(pattern="HH:mm", timezone="GMT+8") @JsonFormat(pattern="HH:mm", timezone="GMT+8")
@JSONField(format="HH:mm") @JSONField(format="HH:mm")
</#if>
</#if> </#if>
<#assign formItemDataType=srfr7javatype(formitem.getPSDEField().stdDataType)>
<#comment>in条件通过String接,通过split拆后再进行查询</#comment>
<#if formitem.getValueOp() == "IN">
<#assign formItemDataType="String">
</#if>
private ${formItemDataType} ${formitem.getName()?lower_case};//[${defield.getLogicName()}] private ${formItemDataType} ${formitem.getName()?lower_case};//[${defield.getLogicName()}]
public void set${formitem.getName()?lower_case?cap_first}(${formItemDataType} ${formitem.getName()?lower_case}) { public void set${formitem.getName()?lower_case?cap_first}(${formItemDataType} ${formitem.getName()?lower_case}) {
this.${formitem.getName()?lower_case} = ${formitem.getName()?lower_case}; this.${formitem.getName()?lower_case} = ${formitem.getName()?lower_case};
...@@ -192,11 +197,11 @@ public class ${item.codeName}SearchContext extends QueryBuildContext { ...@@ -192,11 +197,11 @@ public class ${item.codeName}SearchContext extends QueryBuildContext {
<#elseif formitem.getValueOp() == "LTANDEQ"> <#elseif formitem.getValueOp() == "LTANDEQ">
this.getSearchCond().and("${formitem.getPSDEField().getName()?lower_case}").lessThanEquals(${formitem.getName()?lower_case}); this.getSearchCond().and("${formitem.getPSDEField().getName()?lower_case}").lessThanEquals(${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "ISNOTNULL"> <#elseif formitem.getValueOp() == "ISNOTNULL">
if(this.${formitem.getName()?lower_case}.toString().equals("1")){ if(this.${formitem.getName()?lower_case}.equals("1")){
this.getSearchCond().and("${formitem.getPSDEField().getName()?lower_case}").exists(true).and("${formitem.getPSDEField().getName()?lower_case}").notEquals("").and("${formitem.getPSDEField().getName()?lower_case}").notEquals(null); this.getSearchCond().and("${formitem.getPSDEField().getName()?lower_case}").exists(true).and("${formitem.getPSDEField().getName()?lower_case}").notEquals("").and("${formitem.getPSDEField().getName()?lower_case}").notEquals(null);
} }
<#elseif formitem.getValueOp() == "ISNULL"> <#elseif formitem.getValueOp() == "ISNULL">
if(this.${formitem.getName()?lower_case}.toString().equals("1")){ if(this.${formitem.getName()?lower_case}.equals("1")){
this.getSearchCond().and("${formitem.getPSDEField().getName()?lower_case}").exists(null); this.getSearchCond().and("${formitem.getPSDEField().getName()?lower_case}").exists(null);
} }
<#elseif formitem.getValueOp() == "IN"> <#elseif formitem.getValueOp() == "IN">
...@@ -261,7 +266,7 @@ public class ${item.codeName}SearchContext extends SearchContextBase { ...@@ -261,7 +266,7 @@ public class ${item.codeName}SearchContext extends SearchContextBase {
</#if> </#if>
<#assign formItemDataType=srfr7javatype(formitem.getPSDEField().stdDataType)> <#assign formItemDataType=srfr7javatype(formitem.getPSDEField().stdDataType)>
<#comment>in条件通过String接,通过split拆后再进行查询</#comment> <#comment>in条件通过String接,通过split拆后再进行查询</#comment>
<#if formitem.getValueOp() == "IN"> <#if formitem.getValueOp() == "IN" || formitem.getValueOp() == "ISNULL" || formitem.getValueOp() == "ISNOTNULL">
<#assign formItemDataType="String"> <#assign formItemDataType="String">
</#if> </#if>
private ${formItemDataType} ${formitem.getName()?lower_case};//[${defield.getLogicName()}] private ${formItemDataType} ${formitem.getName()?lower_case};//[${defield.getLogicName()}]
...@@ -298,7 +303,7 @@ public class ${item.codeName}SearchContext extends SearchContextBase { ...@@ -298,7 +303,7 @@ public class ${item.codeName}SearchContext extends SearchContextBase {
</#if> </#if>
<#assign formItemDataType=srfr7javatype(formitem.getPSDEField().stdDataType)> <#assign formItemDataType=srfr7javatype(formitem.getPSDEField().stdDataType)>
<#comment>in条件通过String接,通过split拆后再进行查询</#comment> <#comment>in条件通过String接,通过split拆后再进行查询</#comment>
<#if formitem.getValueOp() == "IN"> <#if formitem.getValueOp() == "IN" || formitem.getValueOp() == "ISNULL" || formitem.getValueOp() == "ISNOTNULL">
<#assign formItemDataType="String"> <#assign formItemDataType="String">
</#if> </#if>
private ${formItemDataType} ${formitem.getName()?lower_case};//[${defield.getLogicName()}] private ${formItemDataType} ${formitem.getName()?lower_case};//[${defield.getLogicName()}]
......
...@@ -26,46 +26,46 @@ import com.alibaba.fastjson.JSONObject; ...@@ -26,46 +26,46 @@ import com.alibaba.fastjson.JSONObject;
@com.baomidou.dynamic.datasource.annotation.DS("${item.getDSLink()?lower_case}") @com.baomidou.dynamic.datasource.annotation.DS("${item.getDSLink()?lower_case}")
</#if> </#if>
</#if> </#if>
public interface ${item.getCodeName()}Mapper extends BaseMapper<${item.getCodeName()}>{ public interface ${item.getCodeName()}Mapper extends BaseMapper<${item.getCodeName()}> {
<#if item.getAllPSDEDataSets()??> <#if item.getAllPSDEDataSets()??>
<#list item.getAllPSDEDataSets() as dedataset> <#list item.getAllPSDEDataSets() as dedataset>
Page<<#if dedataset.isEnableGroup()>HashMap<#else>${item.getCodeName()}</#if>> search${dedataset.getCodeName()}(IPage page, @Param("srf") ${de.codeName}SearchContext context, @Param("ew") Wrapper<${item.getCodeName()}> wrapper) ; Page<<#if dedataset.isEnableGroup()>HashMap<#else>${item.getCodeName()}</#if>> search${dedataset.getCodeName()}(IPage page, @Param("srf") ${de.codeName}SearchContext context, @Param("ew") Wrapper<${item.getCodeName()}> wrapper);
</#list> </#list>
</#if> </#if>
<#assign keyfieldCodeName=item.getKeyPSDEField().codeName?lower_case> <#assign keyfieldCodeName=item.getKeyPSDEField().codeName?lower_case>
@Override @Override
<#if item.isEnableEntityCache()==true> <#if item.isEnableEntityCache()==true>
@Cacheable( value="${item.codeName?lower_case}",key = "'row:'+#p0") @Cacheable(value ="${item.codeName?lower_case}", key = "'row:'+#p0")
</#if> </#if>
${item.getCodeName()} selectById(Serializable id); ${item.getCodeName()} selectById(Serializable id);
@Override @Override
<#if item.isEnableEntityCache()==true> <#if item.isEnableEntityCache()==true>
@CacheEvict( value="${item.codeName?lower_case}",key = "'row:'+#p0.${keyfieldCodeName}") @CacheEvict(value ="${item.codeName?lower_case}", key = "'row:'+#p0.${keyfieldCodeName}")
</#if> </#if>
int insert(${item.getCodeName()} entity); int insert(${item.getCodeName()} entity);
@Override @Override
<#if item.isEnableEntityCache()==true> <#if item.isEnableEntityCache()==true>
@CacheEvict( value="${item.codeName?lower_case}",key = "'row:'+#p0.${keyfieldCodeName}") @CacheEvict(value ="${item.codeName?lower_case}", key = "'row:'+#p0.${keyfieldCodeName}")
</#if> </#if>
int updateById(@Param(Constants.ENTITY) ${item.getCodeName()} entity); int updateById(@Param(Constants.ENTITY) ${item.getCodeName()} entity);
@Override @Override
<#if item.isEnableEntityCache()==true> <#if item.isEnableEntityCache()==true>
@CacheEvict(value="${item.codeName?lower_case}",key = "'row:'+#p0.${keyfieldCodeName}") @CacheEvict(value ="${item.codeName?lower_case}", key = "'row:'+#p0.${keyfieldCodeName}")
</#if> </#if>
int update(@Param(Constants.ENTITY) ${item.getCodeName()} entity, @Param("ew") Wrapper<${item.codeName}> updateWrapper); int update(@Param(Constants.ENTITY) ${item.getCodeName()} entity, @Param("ew") Wrapper<${item.codeName}> updateWrapper);
@Override @Override
<#if item.isEnableEntityCache()==true> <#if item.isEnableEntityCache()==true>
@CacheEvict( value="${item.codeName?lower_case}",key = "'row:'+#p0") @CacheEvict(value ="${item.codeName?lower_case}", key = "'row:'+#p0")
</#if> </#if>
int deleteById(Serializable id); int deleteById(Serializable id);
/** /**
* 自定义查询SQL * 自定义查询SQL
* @param sql * @param sql
* @return * @return
*/ */
@Select("${r'${sql}'}") @Select("${r'${sql}'}")
List<JSONObject> selectBySQL(@Param("sql") String sql, @Param("et")Map param); List<JSONObject> selectBySQL(@Param("sql") String sql, @Param("et")Map param);
/** /**
* 自定义更新SQL * 自定义更新SQL
...@@ -104,7 +104,7 @@ public interface ${item.getCodeName()}Mapper extends BaseMapper<${item.getCodeNa ...@@ -104,7 +104,7 @@ public interface ${item.getCodeName()}Mapper extends BaseMapper<${item.getCodeNa
<#if de.getDefaultPSDEDataSet()??> <#if de.getDefaultPSDEDataSet()??>
<#assign deDefaultDataSet=de.getDefaultPSDEDataSet()> <#assign deDefaultDataSet=de.getDefaultPSDEDataSet()>
<#if deDefaultDataSet.getPSDEDataQueries()??> <#if deDefaultDataSet.getPSDEDataQueries()??>
List<${item.getCodeName()}> selectBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(@Param("${MajorkeyField.codeName?lower_case}") Serializable ${MajorkeyField.codeName?lower_case}) ; List<${item.getCodeName()}> selectBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(@Param("${MajorkeyField.codeName?lower_case}") Serializable ${MajorkeyField.codeName?lower_case});
</#if> </#if>
</#if> </#if>
......
...@@ -12,11 +12,11 @@ public interface ${de.codeName}${item.codeName} { ...@@ -12,11 +12,11 @@ public interface ${de.codeName}${item.codeName} {
<#assign keyFieldName=srfcaseformat(de.getKeyPSDEField().getCodeName(),'l_u2lC')> <#assign keyFieldName=srfcaseformat(de.getKeyPSDEField().getCodeName(),'l_u2lC')>
<#if item.getPSDEDataImportItems?? && item.getPSDEDataImportItems()??> <#if item.getPSDEDataImportItems?? && item.getPSDEDataImportItems()??>
@Mappings({ @Mappings({
@Mapping(target = "${keyFieldName}",source = "${keyFieldName}"), @Mapping(target = "${keyFieldName}", source = "${keyFieldName}"),
<#list item.getPSDEDataImportItems() as importItem> <#list item.getPSDEDataImportItems() as importItem>
<#if importItem.getPSDEField()?? && importItem.getPSDEField().isKeyDEField()==false> <#if importItem.getPSDEField()?? && importItem.getPSDEField().isKeyDEField()==false>
<#assign deFieldName = srfcaseformat(importItem.getPSDEField().getCodeName(),'l_u2lC')> <#assign deFieldName = srfcaseformat(importItem.getPSDEField().getCodeName(),'l_u2lC')>
@Mapping(target = "${deFieldName}",source = "${deFieldName}"), @Mapping(target = "${deFieldName}", source = "${deFieldName}"),
</#if> </#if>
</#list> </#list>
}) })
......
...@@ -44,7 +44,7 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -44,7 +44,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
/** /**
* 实体[${item.codeName}] 服务对象接口 * 实体[${item.codeName}] 服务对象接口
*/ */
public interface I${item.codeName}Service extends IService<${item.codeName}>{ public interface I${item.codeName}Service extends IService<${item.codeName}> {
<@addIDESerivceBody /> <@addIDESerivceBody />
/** /**
...@@ -63,8 +63,8 @@ public interface I${item.codeName}Service extends IService<${item.codeName}>{ ...@@ -63,8 +63,8 @@ public interface I${item.codeName}Service extends IService<${item.codeName}>{
boolean execute(String sql, Map param); boolean execute(String sql, Map param);
<#if hasDEPrefield> <#if hasDEPrefield>
List<${de.codeName}> get${deCodeNameCamel}ByIds(List<${srfr7javatype(keyfield.stdDataType)}> ids) ; List<${de.codeName}> get${deCodeNameCamel}ByIds(List<${srfr7javatype(keyfield.stdDataType)}> ids);
List<${de.codeName}> get${deCodeNameCamel}ByEntities(List<${de.codeName}> entities) ; List<${de.codeName}> get${deCodeNameCamel}ByEntities(List<${de.codeName}> entities);
</#if> </#if>
} }
<#comment>NoSQL存储-MongoDB</#comment> <#comment>NoSQL存储-MongoDB</#comment>
...@@ -73,13 +73,13 @@ public interface I${item.codeName}Service extends IService<${item.codeName}>{ ...@@ -73,13 +73,13 @@ public interface I${item.codeName}Service extends IService<${item.codeName}>{
/** /**
* 实体[${item.codeName}] 服务对象接口 * 实体[${item.codeName}] 服务对象接口
*/ */
public interface I${item.codeName}Service{ public interface I${item.codeName}Service {
<@addIDESerivceBody /> <@addIDESerivceBody />
<#if hasDEPrefield> <#if hasDEPrefield>
List<${de.codeName}> get${deCodeNameCamel}ByIds(List<${srfr7javatype(keyfield.stdDataType)}> ids) ; List<${de.codeName}> get${deCodeNameCamel}ByIds(List<${srfr7javatype(keyfield.stdDataType)}> ids);
List<${de.codeName}> get${deCodeNameCamel}ByEntities(List<${de.codeName}> entities) ; List<${de.codeName}> get${deCodeNameCamel}ByEntities(List<${de.codeName}> entities);
</#if> </#if>
} }
...@@ -88,7 +88,7 @@ public interface I${item.codeName}Service{ ...@@ -88,7 +88,7 @@ public interface I${item.codeName}Service{
/** /**
* 实体[${item.codeName}] 服务对象接口 * 实体[${item.codeName}] 服务对象接口
*/ */
public interface I${item.codeName}Service{ public interface I${item.codeName}Service {
<@addIDESerivceBody /> <@addIDESerivceBody />
...@@ -99,7 +99,7 @@ public interface I${item.codeName}Service{ ...@@ -99,7 +99,7 @@ public interface I${item.codeName}Service{
/** /**
* 实体[${item.codeName}] 服务对象接口 * 实体[${item.codeName}] 服务对象接口
*/ */
public interface I${item.codeName}Service{ public interface I${item.codeName}Service {
<@addIDESerivceBody /> <@addIDESerivceBody />
...@@ -114,45 +114,46 @@ public interface I${item.codeName}Service{ ...@@ -114,45 +114,46 @@ public interface I${item.codeName}Service{
<#list item.getAllPSDEActions() as deaction> <#list item.getAllPSDEActions() as deaction>
<#if deaction.isEnableBackend()> <#if deaction.isEnableBackend()>
<#if (deaction.getActionType()=='USERCUSTOM') > <#if (deaction.getActionType()=='USERCUSTOM') >
${item.codeName} ${srfmethodname(deaction.getCodeName())}(${item.codeName} et) ; ${item.codeName} ${srfmethodname(deaction.getCodeName())}(${item.codeName} et);
boolean ${srfmethodname(deaction.getCodeName())}Batch(List<${item.codeName}> etList);
<#elseif deaction.getActionType()=='DELOGIC'> <#elseif deaction.getActionType()=='DELOGIC'>
${item.codeName} ${srfmethodname(deaction.getCodeName())}(${item.codeName} et) ; ${item.codeName} ${srfmethodname(deaction.getCodeName())}(${item.codeName} et);
<#elseif deaction.codeName?lower_case == 'get'> <#elseif deaction.codeName?lower_case == 'get'>
${item.codeName} get(${srfr7javatype(keyfield.stdDataType)} key) ; ${item.codeName} get(${srfr7javatype(keyfield.stdDataType)} key);
<#elseif deaction.codeName?lower_case == "create"> <#elseif deaction.codeName?lower_case == "create">
boolean create(${item.codeName} et) ; boolean create(${item.codeName} et);
<#if item.isEnableEntityCache()==true> <#if item.isEnableEntityCache()==true>
@CacheEvict(value="${item.codeName?lower_case}",allEntries=true) @CacheEvict(value = "${item.codeName?lower_case}", allEntries = true)
</#if> </#if>
void createBatch(List<${item.codeName}> list) ; void createBatch(List<${item.codeName}> list);
<#elseif deaction.codeName?lower_case == "update"> <#elseif deaction.codeName?lower_case == "update">
boolean update(${item.codeName} et) ; boolean update(${item.codeName} et);
<#if item.isEnableEntityCache()==true> <#if item.isEnableEntityCache()==true>
@CacheEvict(value="${item.codeName?lower_case}",allEntries=true) @CacheEvict(value = "${item.codeName?lower_case}", allEntries = true)
</#if> </#if>
void updateBatch(List<${item.codeName}> list) ; void updateBatch(List<${item.codeName}> list);
<#elseif deaction.codeName?lower_case == "remove"> <#elseif deaction.codeName?lower_case == "remove">
boolean remove(${srfr7javatype(keyfield.stdDataType)} key) ; boolean remove(${srfr7javatype(keyfield.stdDataType)} key);
<#if item.isEnableEntityCache()==true> <#if item.isEnableEntityCache()==true>
@CacheEvict(value="${item.codeName?lower_case}",allEntries=true) @CacheEvict(value = "${item.codeName?lower_case}", allEntries = true)
</#if> </#if>
void removeBatch(Collection<${srfr7javatype(keyfield.stdDataType)}> idList) ; void removeBatch(Collection<${srfr7javatype(keyfield.stdDataType)}> idList);
<#elseif deaction.codeName?lower_case == "save"> <#elseif deaction.codeName?lower_case == "save">
boolean save(${item.codeName} et) ; boolean save(${item.codeName} et);
<#if item.isEnableEntityCache()==true> <#if item.isEnableEntityCache()==true>
@CacheEvict(value="${item.codeName?lower_case}",allEntries=true) @CacheEvict(value = "${item.codeName?lower_case}",allEntries = true)
</#if> </#if>
void saveBatch(List<${item.codeName}> list) ; void saveBatch(List<${item.codeName}> list);
<#elseif deaction.codeName?lower_case == "getdraft"> <#elseif deaction.codeName?lower_case == "getdraft">
${item.codeName} getDraft(${item.codeName} et) ; ${item.codeName} getDraft(${item.codeName} et);
<#elseif deaction.codeName?lower_case == "checkkey"> <#elseif deaction.codeName?lower_case == "checkkey">
boolean checkKey(${item.codeName} et) ; boolean checkKey(${item.codeName} et);
<#elseif deaction.codeName?lower_case == "createbatch"> <#elseif deaction.codeName?lower_case == "createbatch">
<#elseif deaction.codeName?lower_case == "savebatch"> <#elseif deaction.codeName?lower_case == "savebatch">
<#elseif deaction.codeName?lower_case == "updatebatch"> <#elseif deaction.codeName?lower_case == "updatebatch">
<#elseif deaction.codeName?lower_case == "removebatch"> <#elseif deaction.codeName?lower_case == "removebatch">
<#else> <#else>
${item.codeName} ${srfmethodname(deaction.getCodeName())}(${item.codeName} et) ; ${item.codeName} ${srfmethodname(deaction.getCodeName())}(${item.codeName} et);
</#if> </#if>
<@outputTestActionDetail deaction /> <@outputTestActionDetail deaction />
</#if> </#if>
...@@ -160,7 +161,7 @@ public interface I${item.codeName}Service{ ...@@ -160,7 +161,7 @@ public interface I${item.codeName}Service{
</#if> </#if>
<#if item.getAllPSDEDataSets()??> <#if item.getAllPSDEDataSets()??>
<#list item.getAllPSDEDataSets() as dedataset> <#list item.getAllPSDEDataSets() as dedataset>
Page<<#if dedataset.isEnableGroup()>HashMap<#else>${item.getCodeName()}</#if>> search${dedataset.getCodeName()}(${item.codeName}SearchContext context) ; Page<<#if dedataset.isEnableGroup()>HashMap<#else>${item.getCodeName()}</#if>> search${dedataset.getCodeName()}(${item.codeName}SearchContext context);
</#list> </#list>
</#if> </#if>
<#comment>1N关系中,在子实体中创建父实体的实例对象</#comment> <#comment>1N关系中,在子实体中创建父实体的实例对象</#comment>
...@@ -186,13 +187,13 @@ public interface I${item.codeName}Service{ ...@@ -186,13 +187,13 @@ public interface I${item.codeName}Service{
void resetBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(Collection<${srfr7javatype(MajorField.stdDataType)}> ids); void resetBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(Collection<${srfr7javatype(MajorField.stdDataType)}> ids);
<#elseif MinorPSDER.getRemoveActionType()?c=='1'><#comment>同时删除</#comment> <#elseif MinorPSDER.getRemoveActionType()?c=='1'><#comment>同时删除</#comment>
<#if item.isEnableEntityCache()==true> <#if item.isEnableEntityCache()==true>
@CacheEvict(value="${item.codeName?lower_case}",allEntries=true) @CacheEvict(value = "${item.codeName?lower_case}", allEntries = true)
</#if> </#if>
void removeBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(Collection<${srfr7javatype(MajorField.stdDataType)}> ids); void removeBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(Collection<${srfr7javatype(MajorField.stdDataType)}> ids);
</#if> </#if>
</#if> </#if>
<#if item.isEnableEntityCache()==true> <#if item.isEnableEntityCache()==true>
@CacheEvict(value="${item.codeName?lower_case}",allEntries=true) @CacheEvict(value = "${item.codeName?lower_case}", allEntries = true)
</#if> </#if>
void removeBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfr7javatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case}); void removeBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfr7javatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case});
<#assign nested=MinorPSDER.isNestedRS()> <#assign nested=MinorPSDER.isNestedRS()>
...@@ -205,9 +206,9 @@ public interface I${item.codeName}Service{ ...@@ -205,9 +206,9 @@ public interface I${item.codeName}Service{
</#if> </#if>
<#if nested> <#if nested>
<#if item.isEnableEntityCache()==true> <#if item.isEnableEntityCache()==true>
@CacheEvict(value="${item.codeName?lower_case}",allEntries=true) @CacheEvict(value = "${item.codeName?lower_case}", allEntries = true)
</#if> </#if>
void saveBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfr7javatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case},List<${item.getCodeName()}> list) ; void saveBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfr7javatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case}, List<${item.getCodeName()}> list) ;
</#if> </#if>
</#if> </#if>
</#if> </#if>
...@@ -219,10 +220,10 @@ public interface I${item.codeName}Service{ ...@@ -219,10 +220,10 @@ public interface I${item.codeName}Service{
</#if> </#if>
<#comment>实体数据导入</#comment> <#comment>实体数据导入</#comment>
<#if hasDEImport> <#if hasDEImport>
JSONObject importData(List<${de.codeName}> entities,int batchSize,boolean isIgnoreError); JSONObject importData(List<${de.codeName}> entities, int batchSize, boolean isIgnoreError);
@Async("asyncExecutor") @Async("asyncExecutor")
void asyncImportData(List<${de.codeName}> entities,int batchSize,boolean isIgnoreError); void asyncImportData(List<${de.codeName}> entities, int batchSize, boolean isIgnoreError);
</#if> </#if>
</#macro> </#macro>
......
...@@ -164,16 +164,18 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -164,16 +164,18 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<#if de.getAllPSDEActions()??> <#if de.getAllPSDEActions()??>
<#list de.getAllPSDEActions() as deAction> <#list de.getAllPSDEActions() as deAction>
<#comment>实体行为调用处理逻辑</#comment> <#comment>实体行为调用处理逻辑</#comment>
<#if deAction.getActionType() =='DELOGIC' > <#if deAction.getActionType() =='DELOGIC' && deAction.isEnableBackend()>
<#assign deLogic=deAction.getPSDELogic()> <#assign deLogic=deAction.getPSDELogic()>
<@importDELogic deLogic /> <@importDELogic deLogic />
</#if> </#if>
<#comment>实体行为附加逻辑</#comment> <#comment>实体行为附加逻辑</#comment>
<#if deAction.getPSDEActionLogics()??> <#if deAction.getPSDEActionLogics()?? && deAction.isEnableBackend()>
<#list deAction.getPSDEActionLogics() as deActionLogic> <#list deAction.getPSDEActionLogics() as deActionLogic>
<#if deActionLogic.isInternalLogic()> <#if deActionLogic.isInternalLogic() >
<#assign deLogic=deActionLogic.getPSDELogic()> <#assign deLogic=deActionLogic.getPSDELogic()>
<@importDELogic deLogic /> <@importDELogic deLogic />
<#elseif (deActionLogic.getDstPSDE()!'')!='' && (deActionLogic.getDstPSDEAction()!'')!=''>
<@importDEAction deActionLogic />
</#if> </#if>
</#list> </#list>
</#if> </#if>
...@@ -203,6 +205,9 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -203,6 +205,9 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
return et; return et;
} }
<#comment>自定义行为批处理</#comment>
<@customBatchAction deaction/>
<#elseif deaction.getActionType()=='DELOGIC'> <#elseif deaction.getActionType()=='DELOGIC'>
@Override @Override
<@transactionalAnno deaction/> <@transactionalAnno deaction/>
...@@ -227,11 +232,11 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -227,11 +232,11 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<@buildEntityParam deaction/> <@buildEntityParam deaction/>
<@addGetActionBoforeLogic deaction/> <@addGetActionBoforeLogic deaction/>
${item.getCodeName()} et = getById(key); ${item.getCodeName()} et = getById(key);
if(et==null){ if(et == null){
et=new ${item.getCodeName()}(); et = new ${item.getCodeName()}();
et.set${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(key); et.set${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(key);
} }
else{ else {
<#comment>1N关系中,在父实体中创建子实体的List集合</#comment> <#comment>1N关系中,在父实体中创建子实体的List集合</#comment>
<#if de.getMajorPSDERs?? && de.getMajorPSDERs()??> <#if de.getMajorPSDERs?? && de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as MajorPSDER> <#list de.getMajorPSDERs() as MajorPSDER>
...@@ -282,11 +287,14 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -282,11 +287,14 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
createIndexMajorEntityData(et); createIndexMajorEntityData(et);
</#if> </#if>
<#if isLogicInheritDE> <#if isLogicInheritDE>
if(!update(et,(Wrapper) et.getUpdateWrapper(true).eq("${keyfield.name?lower_case}",et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()))) if(!update(et, (Wrapper) et.getUpdateWrapper(true).eq("${keyfield.name?lower_case}", et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()))) {
return false;
}
<#else> <#else>
if(!this.retBool(this.baseMapper.insert(et))) if(!this.retBool(this.baseMapper.insert(et))) {
</#if>
return false; return false;
}
</#if>
<#comment>1N关系中,在父实体中创建子实体的List集合</#comment> <#comment>1N关系中,在父实体中创建子实体的List集合</#comment>
<#if de.getMajorPSDERs?? && de.getMajorPSDERs()??> <#if de.getMajorPSDERs?? && de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as MajorPSDER> <#list de.getMajorPSDERs() as MajorPSDER>
...@@ -305,14 +313,14 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -305,14 +313,14 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
</#list> </#list>
</#if> </#if>
<#if nested> <#if nested>
${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(),et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}()); ${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(), et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
</#if> </#if>
</#if> </#if>
</#if> </#if>
</#list> </#list>
</#if> </#if>
<#comment>成功后get填充一次完整信息</#comment> <#comment>成功后get填充一次完整信息</#comment>
CachedBeanCopier.copy(get(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()),et); CachedBeanCopier.copy(get(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()), et);
<#if hasPSDERsMapping> <#if hasPSDERsMapping>
updateParentData(et); updateParentData(et);
</#if> </#if>
...@@ -333,7 +341,7 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -333,7 +341,7 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<#if item.getUnionKeyValuePSDEFields()??> <#if item.getUnionKeyValuePSDEFields()??>
this.saveOrUpdateBatch(list,batchSize); this.saveOrUpdateBatch(list,batchSize);
<#else> <#else>
this.saveBatch(list,batchSize); this.saveBatch(list, batchSize);
</#if> </#if>
<#comment>批量更新父数据(实体关系属性映射)</#comment> <#comment>批量更新父数据(实体关系属性映射)</#comment>
<#if hasPSDERsMapping> <#if hasPSDERsMapping>
...@@ -359,11 +367,13 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -359,11 +367,13 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<#if de.getKeyPSDEField()??> <#if de.getKeyPSDEField()??>
<#if de.getKeyPSDEField().isPhisicalDEField()==false && de.getUnionKeyValuePSDEFields()??> <#if de.getKeyPSDEField().isPhisicalDEField()==false && de.getUnionKeyValuePSDEFields()??>
<#comment>虚拟联合主键</#comment> <#comment>虚拟联合主键</#comment>
if(!updateById(et)) if(!updateById(et)) {
return false; return false;
}
<#else> <#else>
if(!update(et,(Wrapper) et.getUpdateWrapper(true).eq("${keyfield.name?lower_case}",et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()))) if(!update(et, (Wrapper) et.getUpdateWrapper(true).eq("${keyfield.name?lower_case}", et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()))) {
return false; return false;
}
</#if> </#if>
<#comment>1N关系中,在父实体中创建子实体的List集合</#comment> <#comment>1N关系中,在父实体中创建子实体的List集合</#comment>
<#if de.getMajorPSDERs?? && de.getMajorPSDERs()??> <#if de.getMajorPSDERs?? && de.getMajorPSDERs()??>
...@@ -383,14 +393,14 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -383,14 +393,14 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
</#list> </#list>
</#if> </#if>
<#if nested> <#if nested>
${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(),et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}()); ${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(), et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
</#if> </#if>
</#if> </#if>
</#if> </#if>
</#list> </#list>
</#if> </#if>
<#comment>成功后get填充一次完整信息</#comment> <#comment>成功后get填充一次完整信息</#comment>
CachedBeanCopier.copy(get(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()),et); CachedBeanCopier.copy(get(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()), et);
<#if hasPSDERsMapping> <#if hasPSDERsMapping>
updateParentData(et); updateParentData(et);
</#if> </#if>
...@@ -410,7 +420,7 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -410,7 +420,7 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<#if hasMinorPSDERs gt 0> <#if hasMinorPSDERs gt 0>
list.forEach(item->fillParentData(item)); list.forEach(item->fillParentData(item));
</#if> </#if>
updateBatchById(list,batchSize); updateBatchById(list, batchSize);
<#comment>批量更新父数据(实体关系属性映射)</#comment> <#comment>批量更新父数据(实体关系属性映射)</#comment>
<#if hasPSDERsMapping> <#if hasPSDERsMapping>
updateParentDataBatch(list); updateParentDataBatch(list);
...@@ -425,8 +435,9 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -425,8 +435,9 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<@outputTestAction deaction "save"/> <@outputTestAction deaction "save"/>
<#comment>附加数据逻辑-操作前</#comment> <#comment>附加数据逻辑-操作前</#comment>
<@addBoforeLogic deaction/> <@addBoforeLogic deaction/>
if(!saveOrUpdate(et)) if(!saveOrUpdate(et)) {
return false; return false;
}
<#comment>附加数据逻辑-操作后</#comment> <#comment>附加数据逻辑-操作后</#comment>
<@addAfterLogic deaction/> <@addAfterLogic deaction/>
return true; return true;
...@@ -477,7 +488,7 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -477,7 +488,7 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<@buildEntityParam deaction/> <@buildEntityParam deaction/>
<@addBoforeLogic deaction/> <@addBoforeLogic deaction/>
<#if hasPSDERsMapping> <#if hasPSDERsMapping>
${item.getCodeName()} entity=this.get(key); ${item.getCodeName()} entity = this.get(key);
</#if> </#if>
<#if de.getMajorPSDERs()??> <#if de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as der> <#list de.getMajorPSDERs() as der>
...@@ -494,7 +505,7 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -494,7 +505,7 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<#if isIndexSubDE> <#if isIndexSubDE>
${srfcaseformat(majorIndexDECodeName,'l_u2lC')}Service.remove(key); ${srfcaseformat(majorIndexDECodeName,'l_u2lC')}Service.remove(key);
</#if> </#if>
boolean result=removeById(key); boolean result = removeById(key);
<#if hasPSDERsMapping> <#if hasPSDERsMapping>
updateParentData(entity); updateParentData(entity);
</#if> </#if>
...@@ -540,7 +551,7 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -540,7 +551,7 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
public boolean checkKey(${item.getCodeName()} et) { public boolean checkKey(${item.getCodeName()} et) {
<#comment>输出测试行为</#comment> <#comment>输出测试行为</#comment>
<@outputTestAction deaction "checkkey"/> <@outputTestAction deaction "checkkey"/>
return (!ObjectUtils.isEmpty(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()))&&(!Objects.isNull(this.getById(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()))); return (!ObjectUtils.isEmpty(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}())) && (!Objects.isNull(this.getById(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}())));
} }
<#comment>用户扩展新建、更新</#comment> <#comment>用户扩展新建、更新</#comment>
<#elseif deaction.getActionType()== "USERCREATE" || deaction.getActionType()== "USERUPDATE"> <#elseif deaction.getActionType()== "USERCREATE" || deaction.getActionType()== "USERUPDATE">
...@@ -741,6 +752,20 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -741,6 +752,20 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
et.set${minorFieldCodeName}(${MajorEntityName}.get${majorFieldCodeName}()); et.set${minorFieldCodeName}(${MajorEntityName}.get${majorFieldCodeName}());
</#if> </#if>
</#list> </#list>
<#comment>实体父关系等价</#comment>
<#if MinorPSDER.isEnablePDEREQ()?? && MinorPSDER.isEnablePDEREQ()==true && MinorPSDER.getMajorPPSDER1N()?? && MinorPSDER.getMinorPPSDER1N()?? >
// 父关系等价
<#assign marjorPPSDer1n=MinorPSDER.getMajorPPSDER1N()>
<#assign minorPPSDer1n=MinorPSDER.getMinorPPSDER1N()>
<#assign marjorkeyFieldCodeName=srfcaseformat(marjorPPSDer1n.getPSPickupDEField().codeName,'l_u2lC')?cap_first>
<#assign minorkeyFieldCodeName=srfcaseformat(minorPPSDer1n.getPSPickupDEField().codeName,'l_u2lC')?cap_first>
et.set${minorkeyFieldCodeName}(${MajorEntityName}.get${marjorkeyFieldCodeName}());
<#if marjorPPSDer1n.getPSPickupTextDEField()?? && minorPPSDer1n.getPSPickupTextDEField()??>
<#assign marjorPickupTextCodeName=srfcaseformat(marjorPPSDer1n.getPSPickupTextDEField().codeName,'l_u2lC')?cap_first>
<#assign minorPickupTextCodeName=srfcaseformat(minorPPSDer1n.getPSPickupTextDEField().codeName,'l_u2lC')?cap_first>
et.set${minorPickupTextCodeName}(${MajorEntityName}.get${marjorPickupTextCodeName}());
</#if>
</#if>
} }
</#if> </#if>
</#if> </#if>
...@@ -895,10 +920,12 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -895,10 +920,12 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
ids.add(id); ids.add(id);
} }
} }
if(ids.size()>0) if(ids.size()>0) {
return this.listByIds(ids); return this.listByIds(ids);
else }
return entities; else {
return entities;
}
} }
</#if> </#if>
...@@ -1014,6 +1041,8 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -1014,6 +1041,8 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<#if deActionLogic.isInternalLogic()> <#if deActionLogic.isInternalLogic()>
<#assign deLogic=deActionLogic.getPSDELogic()> <#assign deLogic=deActionLogic.getPSDELogic()>
<@importDELogic deLogic /> <@importDELogic deLogic />
<#elseif (deActionLogic.getDstPSDE()!'')!='' && (deActionLogic.getDstPSDEAction()!'')!=''>
<@importDEAction deActionLogic />
</#if> </#if>
</#list> </#list>
</#if> </#if>
...@@ -1040,6 +1069,9 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -1040,6 +1069,9 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
return et; return et;
} }
<#comment>自定义行为批处理</#comment>
<@customBatchAction deaction/>
<#elseif deaction.getActionType()=='DELOGIC'> <#elseif deaction.getActionType()=='DELOGIC'>
@Override @Override
<@transactionalAnno deaction/> <@transactionalAnno deaction/>
...@@ -1061,8 +1093,8 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -1061,8 +1093,8 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<@buildEntityParam deaction/> <@buildEntityParam deaction/>
<@addGetActionBoforeLogic deaction/> <@addGetActionBoforeLogic deaction/>
Optional<${item.getCodeName()}> result = repository.findById(key); Optional<${item.getCodeName()}> result = repository.findById(key);
if(!result.isPresent()){ if(!result.isPresent()) {
${item.getCodeName()} et=new ${item.getCodeName()}(); ${item.getCodeName()} et = new ${item.getCodeName()}();
et.set${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(key); et.set${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(key);
<@addAfterLogic deaction/> <@addAfterLogic deaction/>
return et; return et;
...@@ -1128,14 +1160,14 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -1128,14 +1160,14 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
</#list> </#list>
</#if> </#if>
<#if nested> <#if nested>
${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(),et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}()); ${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(), et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
</#if> </#if>
</#if> </#if>
</#if> </#if>
</#list> </#list>
</#if> </#if>
<#comment>成功后get填充一次完整信息</#comment> <#comment>成功后get填充一次完整信息</#comment>
CachedBeanCopier.copy(get(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()),et); CachedBeanCopier.copy(get(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()), et);
<#comment>附加数据逻辑-操作后</#comment> <#comment>附加数据逻辑-操作后</#comment>
<@addAfterLogic deaction/> <@addAfterLogic deaction/>
return true ; return true ;
...@@ -1179,14 +1211,14 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -1179,14 +1211,14 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
</#list> </#list>
</#if> </#if>
<#if nested> <#if nested>
${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(),et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}()); ${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(), et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
</#if> </#if>
</#if> </#if>
</#if> </#if>
</#list> </#list>
</#if> </#if>
<#comment>成功后get填充一次完整信息</#comment> <#comment>成功后get填充一次完整信息</#comment>
CachedBeanCopier.copy(get(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()),et); CachedBeanCopier.copy(get(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()), et);
<#comment>附加数据逻辑-操作后</#comment> <#comment>附加数据逻辑-操作后</#comment>
<@addAfterLogic deaction/> <@addAfterLogic deaction/>
return true ; return true ;
...@@ -1228,14 +1260,14 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -1228,14 +1260,14 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
</#list> </#list>
</#if> </#if>
<#if nested> <#if nested>
${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(),et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}()); ${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(), et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
</#if> </#if>
</#if> </#if>
</#if> </#if>
</#list> </#list>
</#if> </#if>
<#comment>成功后get填充一次完整信息</#comment> <#comment>成功后get填充一次完整信息</#comment>
CachedBeanCopier.copy(get(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()),et); CachedBeanCopier.copy(get(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()), et);
<#comment>附加数据逻辑-操作后</#comment> <#comment>附加数据逻辑-操作后</#comment>
<@addAfterLogic deaction/> <@addAfterLogic deaction/>
return true ; return true ;
...@@ -1517,6 +1549,9 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -1517,6 +1549,9 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
return et; return et;
} }
<#comment>自定义行为批处理</#comment>
<@customBatchAction deaction/>
<#elseif deaction.getActionType()=='DELOGIC'> <#elseif deaction.getActionType()=='DELOGIC'>
@Override @Override
<@transactionalAnno deaction/> <@transactionalAnno deaction/>
...@@ -1612,14 +1647,14 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -1612,14 +1647,14 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
</#list> </#list>
</#if> </#if>
<#if nested> <#if nested>
${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(rt.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(),et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}()); ${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(rt.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(), et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
rt.set${srfcaseformat(listcode,'l_u2lC')?cap_first}(et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}()); rt.set${srfcaseformat(listcode,'l_u2lC')?cap_first}(et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
</#if> </#if>
</#if> </#if>
</#if> </#if>
</#list> </#list>
</#if> </#if>
CachedBeanCopier.copy(rt,et); CachedBeanCopier.copy(rt, et);
<#comment>附加数据逻辑-操作后</#comment> <#comment>附加数据逻辑-操作后</#comment>
<@addAfterLogic deaction/> <@addAfterLogic deaction/>
return true; return true;
...@@ -1669,14 +1704,14 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -1669,14 +1704,14 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
</#list> </#list>
</#if> </#if>
<#if nested> <#if nested>
${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(),et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}())); ${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(), et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}()));
rt.set${srfcaseformat(listcode,'l_u2lC')?cap_first}(et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}()); rt.set${srfcaseformat(listcode,'l_u2lC')?cap_first}(et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
</#if> </#if>
</#if> </#if>
</#if> </#if>
</#list> </#list>
</#if> </#if>
CachedBeanCopier.copy(rt,et); CachedBeanCopier.copy(rt, et);
<#comment>附加数据逻辑-操作后</#comment> <#comment>附加数据逻辑-操作后</#comment>
<@addAfterLogic deaction/> <@addAfterLogic deaction/>
return true; return true;
...@@ -2045,6 +2080,9 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2045,6 +2080,9 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
return et; return et;
} }
<#comment>自定义行为批处理</#comment>
<@customBatchAction deaction/>
<#elseif deaction.getActionType()=='DELOGIC'> <#elseif deaction.getActionType()=='DELOGIC'>
@Override @Override
<@transactionalAnno deaction/> <@transactionalAnno deaction/>
...@@ -2295,7 +2333,7 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2295,7 +2333,7 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<#assign tempEntityName="et"> <#assign tempEntityName="et">
<#if deaction.getPSDEActionLogics()??> <#if deaction.getPSDEActionLogics()??>
<#list deaction.getPSDEActionLogics() as actionlogic> <#list deaction.getPSDEActionLogics() as actionlogic>
<#if actionlogic.isValid()==true> <#if actionlogic.isValid()==true && actionlogic.isInternalLogic() && actionlogic.getPSDELogic().isEnableBackend()>
<#if deaction.getCodeName()?lower_case == "get"> <#if deaction.getCodeName()?lower_case == "get">
<#assign tempEntityName="tempET"> <#assign tempEntityName="tempET">
</#if> </#if>
...@@ -2314,7 +2352,7 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2314,7 +2352,7 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<#if deaction.getPSDEActionLogics()??> <#if deaction.getPSDEActionLogics()??>
<#list deaction.getPSDEActionLogics() as actionlogic> <#list deaction.getPSDEActionLogics() as actionlogic>
<#if actionlogic.getAttachMode()=='BEFORE' && actionlogic.isValid()==true> <#if actionlogic.getAttachMode()=='BEFORE' && actionlogic.isValid()==true>
<#if actionlogic.isInternalLogic()> <#if actionlogic.isInternalLogic() && actionlogic.getPSDELogic().isEnableBackend()>
${actionlogic.getPSDELogic().getCodeName()?lower_case}Logic.execute(tempET); ${actionlogic.getPSDELogic().getCodeName()?lower_case}Logic.execute(tempET);
</#if> </#if>
</#if> </#if>
...@@ -2329,7 +2367,7 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2329,7 +2367,7 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<#if actionlogic.isValid()==true> <#if actionlogic.isValid()==true>
<#if actionlogic.isInternalLogic() && actionlogic.getPSDELogic().isEnableBackend()> <#if actionlogic.isInternalLogic() && actionlogic.getPSDELogic().isEnableBackend()>
${actionlogic.getPSDELogic().getCodeName()?lower_case}Logic.execute(et); ${actionlogic.getPSDELogic().getCodeName()?lower_case}Logic.execute(et);
<#elseif (actionlogic.getDstPSDE()!'')!='' && (actionlogic.getDstPSDEAction()!'')!=''> <#elseif (actionlogic.getDstPSDE()!'')!='' && (actionlogic.getDstPSDEAction()!'')!='' && actionlogic.getDstPSDEAction().isEnableBackend()>
<@addActionLogic deaction actionlogic/> <@addActionLogic deaction actionlogic/>
</#if> </#if>
</#if> </#if>
...@@ -2350,10 +2388,10 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2350,10 +2388,10 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
((targetActionType=='USERCUSTOM')|| targetActionType=='DELOGIC'|| targetCodeName == "create" || targetCodeName == "update" || ((targetActionType=='USERCUSTOM')|| targetActionType=='DELOGIC'|| targetCodeName == "create" || targetCodeName == "update" ||
targetCodeName == "save" || targetCodeName == "getdraft" || targetCodeName == "checkkey")> targetCodeName == "save" || targetCodeName == "getdraft" || targetCodeName == "checkkey")>
<#if actionlogic.isIgnoreException()?? && actionlogic.isIgnoreException()==true> <#if actionlogic.isIgnoreException()?? && actionlogic.isIgnoreException()==true>
try{ try {
<@actionLogic_entity actionlogic/> <@actionLogic_entity actionlogic/>
} }
catch(Exception e){ catch(Exception e) {
log.error("执行[${srfmethodname(actionLogicDEAction.getCodeName())}]行为附加逻辑发生异常"); log.error("执行[${srfmethodname(actionLogicDEAction.getCodeName())}]行为附加逻辑发生异常");
} }
<#else> <#else>
...@@ -2361,10 +2399,10 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2361,10 +2399,10 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
</#if> </#if>
<#elseif sourceCodeName=='remove' && targetCodeName == "remove"> <#elseif sourceCodeName=='remove' && targetCodeName == "remove">
<#if actionlogic.isIgnoreException()?? && actionlogic.isIgnoreException()==true> <#if actionlogic.isIgnoreException()?? && actionlogic.isIgnoreException()==true>
try{ try {
<@actionLogic_remove actionlogic/> <@actionLogic_remove actionlogic/>
} }
catch(Exception e){ catch(Exception e) {
log.error("执行[${srfmethodname(actionLogicDEAction.getCodeName())}]行为附加逻辑发生异常"); log.error("执行[${srfmethodname(actionLogicDEAction.getCodeName())}]行为附加逻辑发生异常");
} }
<#else> <#else>
...@@ -2396,7 +2434,7 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2396,7 +2434,7 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<#if actionlogic.isValid()==true> <#if actionlogic.isValid()==true>
<#if actionlogic.isInternalLogic() && actionlogic.getPSDELogic().isEnableBackend()> <#if actionlogic.isInternalLogic() && actionlogic.getPSDELogic().isEnableBackend()>
${actionlogic.getPSDELogic().getCodeName()?lower_case}Logic.execute(et); ${actionlogic.getPSDELogic().getCodeName()?lower_case}Logic.execute(et);
<#elseif (actionlogic.getDstPSDE()!'')!='' && (actionlogic.getDstPSDEAction()!'')!=''> <#elseif (actionlogic.getDstPSDE()!'')!='' && (actionlogic.getDstPSDEAction()!'')!='' && actionlogic.getDstPSDEAction().isEnableBackend()>
<@addActionLogic deaction actionlogic/> <@addActionLogic deaction actionlogic/>
</#if> </#if>
</#if> </#if>
...@@ -2404,23 +2442,27 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2404,23 +2442,27 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
</#if> </#if>
</#macro> </#macro>
<#macro importDELogic deLogic> <#macro importDELogic deLogic>
<#if deLogic.isEnableBackend()>
<#if !P.exists('DELOGIC',deLogic.getCodeName())> <#if !P.exists('DELOGIC',deLogic.getCodeName())>
@Autowired @Autowired
@Lazy @Lazy
protected ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.service.logic.I${de.getCodeName()}${deLogic.codeName}Logic ${deLogic.getCodeName()?lower_case}Logic; protected ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.service.logic.I${de.getCodeName()}${deLogic.codeName}Logic ${deLogic.getCodeName()?lower_case}Logic;
</#if> </#if>
</#if>
</#macro> </#macro>
<#macro importDEAction actionLogic> <#macro importDEAction actionLogic>
<#assign actionLogicDE=actionLogic.getDstPSDE()> <#assign actionLogicDE=actionLogic.getDstPSDE()>
<#assign actionLogicDEAction=actionLogic.getDstPSDEAction()> <#assign actionLogicDEAction=actionLogic.getDstPSDEAction()>
<#if !P.exists('DER1N',actionLogicDE.getCodeName())> <#if actionLogicDEAction.isEnableBackend()>
<#if !P.exists('DER1N',actionLogicDE.getCodeName())>
@Autowired @Autowired
@Lazy @Lazy
protected ${pub.getPKGCodeName()}.core.${actionLogicDE.getPSSystemModule().getCodeName()?lower_case}.service.I${actionLogicDE.getCodeName()}Service ${srfcaseformat(actionLogicDE.getCodeName(),'l_u2lC')}Service; protected ${pub.getPKGCodeName()}.core.${actionLogicDE.getPSSystemModule().getCodeName()?lower_case}.service.I${actionLogicDE.getCodeName()}Service ${srfcaseformat(actionLogicDE.getCodeName(),'l_u2lC')}Service;
</#if> </#if>
</#if>
</#macro> </#macro>
<#comment>实体行为参数</#comment> <#comment>实体行为参数</#comment>
...@@ -2529,16 +2571,19 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2529,16 +2571,19 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<#if deaction.isEnableBackend() && deaction.getTestActionMode?? && deaction.getTestActionMode()??> <#if deaction.isEnableBackend() && deaction.getTestActionMode?? && deaction.getTestActionMode()??>
<#if deaction.getTestActionMode() ==1 || deaction.getTestActionMode() ==3> <#if deaction.getTestActionMode() ==1 || deaction.getTestActionMode() ==3>
<#if (deaction.getActionType()=='USERCUSTOM')> <#if (deaction.getActionType()=='USERCUSTOM')>
@Override
public boolean test${srfmethodname(deaction.getCodeName())?cap_first}(${item.getCodeName()} et) { public boolean test${srfmethodname(deaction.getCodeName())?cap_first}(${item.getCodeName()} et) {
return true; return true;
} }
<#elseif deaction.getActionType()=='DELOGIC'> <#elseif deaction.getActionType()=='DELOGIC'>
@Override
public boolean test${srfmethodname(deaction.getCodeName())?cap_first}(${item.getCodeName()} et) { public boolean test${srfmethodname(deaction.getCodeName())?cap_first}(${item.getCodeName()} et) {
return true; return true;
} }
<#elseif deaction.getCodeName()?lower_case == 'get'> <#elseif deaction.getCodeName()?lower_case == 'get'>
@Override
public boolean testGet(${srfr7javatype(keyfield.stdDataType)} key) { public boolean testGet(${srfr7javatype(keyfield.stdDataType)} key) {
return true; return true;
} }
...@@ -2548,60 +2593,73 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2548,60 +2593,73 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<#elseif deaction.getCodeName()?lower_case == "removebatch"> <#elseif deaction.getCodeName()?lower_case == "removebatch">
<#elseif deaction.getCodeName()?lower_case == "savebatch"> <#elseif deaction.getCodeName()?lower_case == "savebatch">
<#elseif deaction.getCodeName()?lower_case == "create"> <#elseif deaction.getCodeName()?lower_case == "create">
@Override
public boolean testCreate(${item.getCodeName()} et) { public boolean testCreate(${item.getCodeName()} et) {
return true; return true;
} }
@Override
public boolean testCreateBatch(List<${item.getCodeName()}> list) { public boolean testCreateBatch(List<${item.getCodeName()}> list) {
return true; return true;
} }
<#elseif deaction.getCodeName()?lower_case == "update"> <#elseif deaction.getCodeName()?lower_case == "update">
@Override
public boolean testUpdate(${item.getCodeName()} et) { public boolean testUpdate(${item.getCodeName()} et) {
return true; return true;
} }
@Override
public boolean testUpdateBatch(List<${item.getCodeName()}> list) { public boolean testUpdateBatch(List<${item.getCodeName()}> list) {
return true; return true;
} }
<#elseif deaction.getCodeName()?lower_case == "save"> <#elseif deaction.getCodeName()?lower_case == "save">
@Override
public boolean testSave(${item.getCodeName()} et) { public boolean testSave(${item.getCodeName()} et) {
return true; return true;
} }
@Override
public boolean testSaveOrUpdate(${item.getCodeName()} et) { public boolean testSaveOrUpdate(${item.getCodeName()} et) {
return true; return true;
} }
@Override
public boolean testSaveBatch(Collection<${item.getCodeName()}> list) { public boolean testSaveBatch(Collection<${item.getCodeName()}> list) {
return true; return true;
} }
@Override
public boolean testSaveBatch(List<${item.getCodeName()}> list) { public boolean testSaveBatch(List<${item.getCodeName()}> list) {
return true; return true;
} }
<#elseif deaction.getCodeName()?lower_case == "remove"> <#elseif deaction.getCodeName()?lower_case == "remove">
@Override
public boolean testRemove(${srfr7javatype(keyfield.stdDataType)} key) { public boolean testRemove(${srfr7javatype(keyfield.stdDataType)} key) {
return true; return true;
} }
@Override
public boolean testRemoveBatch(Collection<${srfr7javatype(keyfield.stdDataType)}> idList) { public boolean testRemoveBatch(Collection<${srfr7javatype(keyfield.stdDataType)}> idList) {
return true; return true;
} }
<#elseif deaction.getCodeName()?lower_case == "getdraft"> <#elseif deaction.getCodeName()?lower_case == "getdraft">
@Override
public boolean testGetDraft(${item.getCodeName()} et) { public boolean testGetDraft(${item.getCodeName()} et) {
return true; return true;
} }
<#elseif deaction.getCodeName()?lower_case == "checkkey"> <#elseif deaction.getCodeName()?lower_case == "checkkey">
@Override
public boolean testCheckKey(${item.getCodeName()} et) { public boolean testCheckKey(${item.getCodeName()} et) {
return true; return true;
} }
<#else> <#else>
@Override
public boolean test${srfmethodname(deaction.getCodeName())?cap_first}(${item.getCodeName()} et) { public boolean test${srfmethodname(deaction.getCodeName())?cap_first}(${item.getCodeName()} et) {
return true; return true;
} }
...@@ -2749,6 +2807,7 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2749,6 +2807,7 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
} }
} }
@Override
@Transactional @Transactional
public void asyncImportData(List<${de.codeName}> entities, int batchSize ,boolean isIgnoreError){ public void asyncImportData(List<${de.codeName}> entities, int batchSize ,boolean isIgnoreError){
executeImportData(entities,batchSize,isIgnoreError); executeImportData(entities,batchSize,isIgnoreError);
...@@ -2762,8 +2821,9 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2762,8 +2821,9 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
@Transactional @Transactional
public JSONObject executeImportData(List<${de.codeName}> entities, int batchSize ,boolean isIgnoreError) { public JSONObject executeImportData(List<${de.codeName}> entities, int batchSize ,boolean isIgnoreError) {
JSONObject rs=testImportData(entities,isIgnoreError); JSONObject rs=testImportData(entities,isIgnoreError);
if(rs.getInteger("rst")==1 && !isIgnoreError) if(rs.getInteger("rst")==1 && !isIgnoreError) {
return rs; return rs;
}
List<${de.codeName}> tempDEList=new ArrayList<>(); List<${de.codeName}> tempDEList=new ArrayList<>();
Set tempIds=new HashSet<>(); Set tempIds=new HashSet<>();
...@@ -2771,8 +2831,9 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2771,8 +2831,9 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
${de.codeName} entity = entities.get(i); ${de.codeName} entity = entities.get(i);
tempDEList.add(entity); tempDEList.add(entity);
Object id=entity.get${keyfieldPublicCodeName}(); Object id=entity.get${keyfieldPublicCodeName}();
if(!ObjectUtils.isEmpty(id)) if(!ObjectUtils.isEmpty(id)) {
tempIds.add(id); tempIds.add(id);
}
if(tempDEList.size()>=batchSize || (tempDEList.size()<batchSize && i==entities.size()-1)){ if(tempDEList.size()>=batchSize || (tempDEList.size()<batchSize && i==entities.size()-1)){
commit(tempDEList,tempIds); commit(tempDEList,tempIds);
tempDEList.clear(); tempDEList.clear();
...@@ -2802,15 +2863,19 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2802,15 +2863,19 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
} }
for(${de.codeName} entity:entities){ for(${de.codeName} entity:entities){
Object id=entity.get${keyfieldPublicCodeName}(); Object id=entity.get${keyfieldPublicCodeName}();
if(oldIds.contains(id)) if(oldIds.contains(id)) {
_update.add(entity); _update.add(entity);
else }
else {
_create.add(entity); _create.add(entity);
}
} }
if(_update.size()>0) if(_update.size()>0) {
proxyService.updateBatch(_update); proxyService.updateBatch(_update);
if(_create.size()>0) }
if(_create.size()>0) {
proxyService.createBatch(_create); proxyService.createBatch(_create);
}
} }
</#if> </#if>
</#macro> </#macro>
...@@ -2992,4 +3057,17 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2992,4 +3057,17 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<#return dupCheck> <#return dupCheck>
</#function> </#function>
<#comment>用户自定义行为批处理</#comment>
<#macro customBatchAction deaction>
@Override
<@transactionalAnno deaction/>
public boolean ${srfmethodname(deaction.getCodeName())}Batch(List<${item.codeName}> etList) {
for(${item.getCodeName()} et : etList) {
${srfmethodname(deaction.getCodeName())}(et);
}
return true;
}
</#macro>
</#if> </#if>
...@@ -5,19 +5,13 @@ TARGET=PSDELOGIC ...@@ -5,19 +5,13 @@ TARGET=PSDELOGIC
<#assign startWF=false> <#assign startWF=false>
package ${pub.getPKGCodeName()}.core.${item.getPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.service.logic.impl; package ${pub.getPKGCodeName()}.core.${item.getPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.service.logic.impl;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.kie.api.runtime.KieSession; import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.KieContainer; import org.kie.api.runtime.KieContainer;
import ${pub.getPKGCodeName()}.core.${item.getPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.service.logic.I${de.codeName}${item.codeName}Logic; import ${pub.getPKGCodeName()}.core.${item.getPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.service.logic.I${de.codeName}${item.codeName}Logic;
import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.domain.${de.getCodeName()}; import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.domain.${de.getCodeName()};
...@@ -26,7 +20,7 @@ import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower ...@@ -26,7 +20,7 @@ import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower
*/ */
@Slf4j @Slf4j
@Service @Service
public class ${de.codeName}${item.codeName}LogicImpl implements I${de.codeName}${item.codeName}Logic{ public class ${de.codeName}${item.codeName}LogicImpl implements I${de.codeName}${item.codeName}Logic {
@Autowired @Autowired
private KieContainer kieContainer; private KieContainer kieContainer;
...@@ -65,11 +59,12 @@ public class ${de.codeName}${item.codeName}LogicImpl implements I${de.codeName}$ ...@@ -65,11 +59,12 @@ public class ${de.codeName}${item.codeName}LogicImpl implements I${de.codeName}$
return this.iBzSysDefaultService; return this.iBzSysDefaultService;
} }
public void execute(${de.codeName} et){ @Override
public void execute(${de.codeName} et) {
KieSession kieSession = null; KieSession kieSession = null;
try{ try {
kieSession=kieContainer.newKieSession(); kieSession = kieContainer.newKieSession();
<#comment>插入逻辑参数</#comment> <#comment>插入逻辑参数</#comment>
<#if item.getPSDELogicParams?? && item.getPSDELogicParams()??> <#if item.getPSDELogicParams?? && item.getPSDELogicParams()??>
<#assign logicName=(de.codeName+item.codeName)?lower_case> <#assign logicName=(de.codeName+item.codeName)?lower_case>
...@@ -80,12 +75,12 @@ public class ${de.codeName}${item.codeName}LogicImpl implements I${de.codeName}$ ...@@ -80,12 +75,12 @@ public class ${de.codeName}${item.codeName}LogicImpl implements I${de.codeName}$
<#assign paramObjValue="et"> <#assign paramObjValue="et">
<#elseif logicParam.getParamPSDataEntity?? && logicParam.getParamPSDataEntity()??> <#elseif logicParam.getParamPSDataEntity?? && logicParam.getParamPSDataEntity()??>
<#assign ParamPSDataEntity=logicParam.getParamPSDataEntity()> <#assign ParamPSDataEntity=logicParam.getParamPSDataEntity()>
${pub.getPKGCodeName()}.core.${ParamPSDataEntity.getPSSystemModule().codeName?lower_case}.domain.${ParamPSDataEntity.codeName} ${(logicName+logicParam.codeName)?lower_case} =new ${pub.getPKGCodeName()}.core.${ParamPSDataEntity.getPSSystemModule().codeName?lower_case}.domain.${ParamPSDataEntity.codeName}(); ${pub.getPKGCodeName()}.core.${ParamPSDataEntity.getPSSystemModule().codeName?lower_case}.domain.${ParamPSDataEntity.codeName} ${(logicName+logicParam.codeName)?lower_case} = new ${pub.getPKGCodeName()}.core.${ParamPSDataEntity.getPSSystemModule().codeName?lower_case}.domain.${ParamPSDataEntity.codeName}();
<#else> <#else>
Map ${(logicName+logicParam.codeName)?lower_case} =new HashMap(); Map ${(logicName+logicParam.codeName)?lower_case} = new HashMap();
</#if> </#if>
kieSession.insert(${paramObjValue}); <#comment>将逻辑参数存储到fact</#comment> kieSession.insert(${paramObjValue}); <#comment>将逻辑参数存储到fact</#comment>
kieSession.setGlobal("${paramObj}",${paramObjValue});<#comment>将逻辑参数存储到global</#comment> kieSession.setGlobal("${paramObj}", ${paramObjValue});<#comment>将逻辑参数存储到global</#comment>
</#list> </#list>
</#if> </#if>
<#comment>插入处理逻辑中所用到的service对象</#comment> <#comment>插入处理逻辑中所用到的service对象</#comment>
...@@ -93,28 +88,28 @@ public class ${de.codeName}${item.codeName}LogicImpl implements I${de.codeName}$ ...@@ -93,28 +88,28 @@ public class ${de.codeName}${item.codeName}LogicImpl implements I${de.codeName}$
<#list item.getPSDELogicNodes() as deLogicNode> <#list item.getPSDELogicNodes() as deLogicNode>
<#if deLogicNode.getDstPSDataEntity?? && deLogicNode.getDstPSDataEntity()??> <#if deLogicNode.getDstPSDataEntity?? && deLogicNode.getDstPSDataEntity()??>
<#if !P.exists(item.codeName,"kieSessionGlobalService",deLogicNode.getDstPSDataEntity().getCodeName()?lower_case)> <#if !P.exists(item.codeName,"kieSessionGlobalService",deLogicNode.getDstPSDataEntity().getCodeName()?lower_case)>
kieSession.setGlobal("${deLogicNode.getDstPSDataEntity().getCodeName()?lower_case}service",${deLogicNode.getDstPSDataEntity().getCodeName()?lower_case}service);<#comment>将逻辑中引用到的service存储到global</#comment> kieSession.setGlobal("${deLogicNode.getDstPSDataEntity().getCodeName()?lower_case}service", ${deLogicNode.getDstPSDataEntity().getCodeName()?lower_case}service);<#comment>将逻辑中引用到的service存储到global</#comment>
</#if> </#if>
</#if> </#if>
</#list> </#list>
</#if> </#if>
<#comment>插入当前实体的defaultService对象,供自定义查询使用</#comment> <#comment>插入当前实体的defaultService对象,供自定义查询使用</#comment>
kieSession.setGlobal("iBzSys${de.codeName?lower_case?cap_first}DefaultService",iBzSysDefaultService);<#comment>将逻辑中引用到的service存储到global</#comment> kieSession.setGlobal("iBzSys${de.codeName?lower_case?cap_first}DefaultService", iBzSysDefaultService);<#comment>将逻辑中引用到的service存储到global</#comment>
kieSession.setGlobal("curuser", ${pub.getPKGCodeName()}.util.security.AuthenticationUser.getAuthenticationUser()); kieSession.setGlobal("curuser", ${pub.getPKGCodeName()}.util.security.AuthenticationUser.getAuthenticationUser());
<#comment>插入wfclient</#comment> <#comment>插入wfclient</#comment>
<#if startWF> <#if startWF>
kieSession.setGlobal("wfClient",wfClient); kieSession.setGlobal("wfClient", wfClient);
</#if> </#if>
kieSession.startProcess("${pub.getPKGCodeName()}.core.${de.getPSSystemModule().codeName?lower_case}.service.logic.${de.codeName?lower_case}${item.getCodeName()?lower_case}");<#comment>执行所要执行的流程</#comment> kieSession.startProcess("${pub.getPKGCodeName()}.core.${de.getPSSystemModule().codeName?lower_case}.service.logic.${de.codeName?lower_case}${item.getCodeName()?lower_case}");<#comment>执行所要执行的流程</#comment>
}catch(Exception e){ } catch (Exception e) {
throw new RuntimeException("执行[${item.getName()}]处理逻辑发生异常"+e); throw new RuntimeException("执行[${item.getName()}]处理逻辑发生异常" + e);
<#--throw new BadRequestAlertException(""+e,"","");--> <#--throw new BadRequestAlertException(""+e,"","");-->
}finally { } finally {
if(kieSession!=null) if(kieSession != null) {
kieSession.destroy(); kieSession.destroy();
}
} }
} }
} }
</#if> </#if>
\ No newline at end of file
...@@ -51,8 +51,15 @@ public class ${item.codeName}ExService extends ${item.codeName}ServiceImpl { ...@@ -51,8 +51,15 @@ public class ${item.codeName}ExService extends ${item.codeName}ServiceImpl {
<#list item.getAllPSDEActions() as deaction> <#list item.getAllPSDEActions() as deaction>
<#if deaction.isEnableBackend()> <#if deaction.isEnableBackend()>
<#if deaction.getActionType()=='USERCUSTOM'> <#if deaction.getActionType()=='USERCUSTOM'>
<#assign actionAnno="["+deaction.getCodeName()+"] 行为扩展">
<#if ((deaction.getLogicName())!'')!=''>
<#assign actionAnno="["+deaction.getCodeName()+":"+deaction.getLogicName()+"] 行为扩展">
</#if>
<#if ((deaction.getMemo())!'')!=''>
<#assign actionAnno=actionAnno+":"+deaction.getMemo()>
</#if>
/** /**
* 自定义行为[${deaction.getCodeName()}]用户扩展 * ${actionAnno}
* @param et * @param et
* @return * @return
*/ */
......
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#assign hasMQEntity=false>
<#list sys.getAllPSDataEntities() as dataEntity>
<#if dataEntity.getAllPSDEDataSyncs?? && dataEntity.getAllPSDEDataSyncs()??>
<#list dataEntity.getAllPSDEDataSyncs() as dataSync>
<#assign hasMQEntity=true>
<#break>
</#list>
</#if>
</#list>
<#if hasMQEntity>
<#assign nameAddress="127.0.0.1:9876">
<#assign instanceName="rmq-instance">
package ${pub.getPKGCodeName()}.core.util.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
import com.alibaba.rocketmq.common.message.MessageExt;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import java.util.List;
@Slf4j
@Configuration
public class RocketMQConfig {
<#list sys.getAllPSDataEntities() as dataEntity>
<#if dataEntity.getAllPSDEDataSyncs?? && dataEntity.getAllPSDEDataSyncs()??>
<#list dataEntity.getAllPSDEDataSyncs() as dataSync>
<#if dataSync.getOutPSSysDataSyncAgent?? && dataSync.getOutPSSysDataSyncAgent()??>
<#assign syncAgent=dataSync.getOutPSSysDataSyncAgent()>
<#assign producer=dataEntity.codeName+syncAgent.codeName+"producer">
<#if ((syncAgent.getAgentTag())!'')!=''>
<#assign nameAddress=syncAgent.getAgentTag()>
</#if>
<#if ((syncAgent.getAgentTag2())!'')!=''>
<#assign instanceName=syncAgent.getAgentTag2()>
</#if>
@Bean("${producer}")
public DefaultMQProducer ${srfmethodname(producer)}(){
DefaultMQProducer producer = null;
try{
producer= new DefaultMQProducer();
producer.setSendMsgTimeout(6000);
producer.setNamesrvAddr("${nameAddress}");
producer.setInstanceName("${instanceName}");
}
catch(Exception e){
log.error("初始化消息发送对象异常!");
}
return producer;
}
</#if>
</#list>
</#if>
</#list>
<#list sys.getAllPSDataEntities() as dataEntity>
<#if dataEntity.getAllPSDEDataSyncs?? && dataEntity.getAllPSDEDataSyncs()??>
<#list dataEntity.getAllPSDEDataSyncs() as dataSync>
<#if dataSync.getInPSSysDataSyncAgent?? && dataSync.getInPSSysDataSyncAgent()??>
<#assign syncAgent=dataSync.getInPSSysDataSyncAgent()>
<#assign consumer=dataEntity.codeName+syncAgent.codeName+"consumer">
<#assign entityName=dataEntity.getCodeName()>
<#if ((syncAgent.getAgentTag())!'')!=''>
<#assign nameAddress=syncAgent.getAgentTag()>
</#if>
<#if ((syncAgent.getAgentTag2())!'')!=''>
<#assign instanceName=syncAgent.getAgentTag2()>
</#if>
@Autowired
@Lazy
${pub.getPKGCodeName()}.core.${dataEntity.getPSSystemModule().getCodeName()?lower_case}.service.I${entityName}Service ${entityName}Service;
@Bean("${consumer}")
public DefaultMQPushConsumer ${srfmethodname(consumer)}(){
DefaultMQPushConsumer consumer = null;
try {
consumer = new DefaultMQPushConsumer();
consumer.setNamesrvAddr("${nameAddress}");
consumer.setInstanceName("${instanceName}");
consumer.subscribe("${dataSync.codeName}", "${dataSync.codeName}");
consumer.registerMessageListener(new MessageListenerConcurrently() {
public ConsumeConcurrentlyStatus consumeMessage(
List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
for (MessageExt msg : msgs) {
<#if dataSync.getInTestPSDEAction()??>
<#assign inputAction=srfmethodname(dataSync.getInTestPSDEAction().codeName)>
${pub.getPKGCodeName()}.core.${dataEntity.getPSSystemModule().getCodeName()?lower_case}.domain.${entityName} domain = JSON.parseObject(new String(msg.getBody()),${pub.getPKGCodeName()}.core.${dataEntity.getPSSystemModule().getCodeName()?lower_case}.domain.${entityName}.class);
${entityName}Service.${inputAction}(domain);
<#else>
log.info("接收到[]消息,但未配置实体输入过滤行为,消息将被忽略。"+new String(msg.getBody()));
</#if>
}
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
});
consumer.start();
}catch (Exception e){
log.error("初始化消息接收对象异常!");
}
return consumer;
}
</#if>
</#list>
</#if>
</#list>
}
</#if>
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
TARGET=PSSYSTEM TARGET=PSSYSTEM
</#ibiztemplate> </#ibiztemplate>
{ {
"systemid":"${sys.getName()}", "systemid":"${sys.codeName}",
"unires":[ "unires":[
<#if sys.getAllPSSysUniReses()??> <#if sys.getAllPSSysUniReses()??>
<#list sys.getAllPSSysUniReses() as unires> <#list sys.getAllPSSysUniReses() as unires>
...@@ -14,18 +14,22 @@ TARGET=PSSYSTEM ...@@ -14,18 +14,22 @@ TARGET=PSSYSTEM
</#list> </#list>
</#if> </#if>
], ],
<#if sys.getAllPSApps()??> <#if sys.getAllPSDataEntities()??>
<#assign ct=0> <#assign ct=0>
"entities":[ "entities":[
<#list sys.getAllPSApps() as app> <#list sys.getAllPSDataEntities() as de>
<#if app.getAllPSAppDataEntities?? && app.getAllPSAppDataEntities()??> <#if de.getAllPSDEServiceAPIs?? && de.getAllPSDEServiceAPIs()??>
<#list app.getAllPSAppDataEntities() as appde> <#assign hasDEApi=false>
<#assign de=appde.getPSDE()> <#list de.getAllPSDEServiceAPIs() as deapi>
<#if !P.exists(de.getCodeName(),"")> <#assign hasDEApi=true>
<#break>
</#list>
<#if hasDEApi>
<#if !P.exists(de.getCodeName(),"")>
<#if (ct>0)> <#if (ct>0)>
,</#if><#assign ct=ct+1> ,</#if><#assign ct=ct+1>
<#assign dataSetResult=getDataSet()> <#assign dataSetResult=getDataSet(de)>
<#assign deActionResult=getDEAction()> <#assign deActionResult=getDEAction(de)>
{ {
"dename":"${de.codeName}", "dename":"${de.codeName}",
"delogicname":"${de.logicName}", "delogicname":"${de.logicName}",
...@@ -33,9 +37,9 @@ TARGET=PSSYSTEM ...@@ -33,9 +37,9 @@ TARGET=PSSYSTEM
"dedataset":${dataSetResult}, "dedataset":${dataSetResult},
"deaction":${deActionResult}, "deaction":${deActionResult},
"datascope":${getDataScope(de)} "datascope":${getDataScope(de)}
} }
</#if> </#if>
</#list> </#if>
</#if> </#if>
</#list> </#list>
], ],
...@@ -55,7 +59,7 @@ TARGET=PSSYSTEM ...@@ -55,7 +59,7 @@ TARGET=PSSYSTEM
</#if> </#if>
} }
<#comment>获取实体数据集</#comment> <#comment>获取实体数据集</#comment>
<#function getDataSet> <#function getDataSet de>
<#assign result_dataSet="[" > <#assign result_dataSet="[" >
<#if de.getAllPSDEDataSets()??> <#if de.getAllPSDEDataSets()??>
<#list de.getAllPSDEDataSets() as dataSet> <#list de.getAllPSDEDataSets() as dataSet>
...@@ -70,7 +74,7 @@ TARGET=PSSYSTEM ...@@ -70,7 +74,7 @@ TARGET=PSSYSTEM
</#function> </#function>
<#comment>获取实体行为</#comment> <#comment>获取实体行为</#comment>
<#function getDEAction> <#function getDEAction de>
<#assign result_deAction="[" > <#assign result_deAction="[" >
<#if de.getAllPSDEActions()??> <#if de.getAllPSDEActions()??>
<#list de.getAllPSDEActions() as deAction> <#list de.getAllPSDEActions() as deAction>
...@@ -136,7 +140,7 @@ TARGET=PSSYSTEM ...@@ -136,7 +140,7 @@ TARGET=PSSYSTEM
<#comment>获取数据范围</#comment> <#comment>获取数据范围</#comment>
<#function getDataScope dataEntity> <#function getDataScope de>
<#assign result_DataScope="["> <#assign result_DataScope="[">
<#assign result_DataScope=result_DataScope+"{\"id\":\"all\",\"name\":\"全部数据\"}"> <#assign result_DataScope=result_DataScope+"{\"id\":\"all\",\"name\":\"全部数据\"}">
<#if de.getPSDEFieldByPDT('ORGID',true)?? > <#if de.getPSDEFieldByPDT('ORGID',true)?? >
......
...@@ -122,7 +122,7 @@ TARGET=PSDELOGIC ...@@ -122,7 +122,7 @@ TARGET=PSDELOGIC
<#assign targetDBValueOP=LogicLinkCond.getPSDBValueOPId()><#comment>表达式</#comment> <#assign targetDBValueOP=LogicLinkCond.getPSDBValueOPId()><#comment>表达式</#comment>
<#assign targetValue=LogicLinkCond.getValue()><#comment>值项</#comment> <#assign targetValue=LogicLinkCond.getValue()><#comment>值项</#comment>
<#if targetDEField!=''> <#if targetDEField!=''>
targetFieldName=srfcaseformat(targetDEField.codeName,'l_u2lC') ; <#assign targetFieldName=srfcaseformat(targetDEField.codeName,'l_u2lC')>
</#if> </#if>
<#assign condBody="RuleUtils.test($"+logicName+targetParam.getCodeName()?lower_case+".get(\""+targetFieldName+"\"),\""+targetDBValueOP+"\","+"\""+targetValue+"\")"> <#assign condBody="RuleUtils.test($"+logicName+targetParam.getCodeName()?lower_case+".get(\""+targetFieldName+"\"),\""+targetDBValueOP+"\","+"\""+targetValue+"\")">
<#assign fieldCond=fieldCond+condBody > <#assign fieldCond=fieldCond+condBody >
......
...@@ -14,6 +14,8 @@ TARGET=PSSYSTEM ...@@ -14,6 +14,8 @@ TARGET=PSSYSTEM
"table_name":"${de.getTableName()}", "table_name":"${de.getTableName()}",
"system_id":"${sys.codeName}", "system_id":"${sys.codeName}",
"system_name":"${sys.logicName}", "system_name":"${sys.logicName}",
"module_id":"${de.getPSSystemModule().codeName}",
"module_name":"${de.getPSSystemModule().name}",
<#--"ds_id":null,--> <#--"ds_id":null,-->
<#--"ds_name":"",--> <#--"ds_name":"",-->
"fields":[ "fields":[
......
...@@ -102,6 +102,14 @@ TARGET=PSWFVERSION ...@@ -102,6 +102,14 @@ TARGET=PSWFVERSION
<flowable:string>${(wfde.getUDStatePSDEField().getCodeName()?lower_case)}</flowable:string> <flowable:string>${(wfde.getUDStatePSDEField().getCodeName()?lower_case)}</flowable:string>
</flowable:field> </flowable:field>
</#if> </#if>
<#if item.getPSWorkflow().getEntityWFStates?? && item.getPSWorkflow().getEntityWFStates()??>
<#list item.getPSWorkflow().getEntityWFStates() as wfStatus>
<flowable:field name="udstateingval_${srfpluralize(wfde.getPSDataEntity().getCodeName()?lower_case)}">
<flowable:string>${wfStatus}</flowable:string>
</flowable:field>
<#break>
</#list>
</#if>
<#if wfde.getWFStatePSDEField()??> <#if wfde.getWFStatePSDEField()??>
<flowable:field name="wfstatefield_${srfpluralize(wfde.getPSDataEntity().getCodeName()?lower_case)}"> <flowable:field name="wfstatefield_${srfpluralize(wfde.getPSDataEntity().getCodeName()?lower_case)}">
<flowable:string>${(wfde.getWFStatePSDEField().getCodeName()?lower_case)}</flowable:string> <flowable:string>${(wfde.getWFStatePSDEField().getCodeName()?lower_case)}</flowable:string>
...@@ -206,9 +214,9 @@ TARGET=PSWFVERSION ...@@ -206,9 +214,9 @@ TARGET=PSWFVERSION
<userTask flowable:category="${r'${businessKey}'}" flowable:candidateUsers="${assignCond}" flowable:exclusive="true" id="tid-${WFProcess.getWFStepValue()}-${WFProcess.getDeployId()}" name="${WFProcess.getName()}" <#if WFProcess.getWFProcessType()?? && (WFProcess.getWFProcessType()=="CALLORGACTIVITY" || WFProcess.getWFProcessType()=="EMBED")>flowable:formKey="${WFProcess.getWFProcessType()}"</#if>><#comment>标记子流程节点</#comment> <userTask flowable:category="${r'${businessKey}'}" flowable:candidateUsers="${assignCond}" flowable:exclusive="true" id="tid-${WFProcess.getWFStepValue()}-${WFProcess.getDeployId()}" name="${WFProcess.getName()}" <#if WFProcess.getWFProcessType()?? && (WFProcess.getWFProcessType()=="CALLORGACTIVITY" || WFProcess.getWFProcessType()=="EMBED")>flowable:formKey="${WFProcess.getWFProcessType()}"</#if>><#comment>标记子流程节点</#comment>
<documentation>${r'${majortext}'}</documentation> <documentation>${r'${majortext}'}</documentation>
<#if (WFProcess.isSendInform()?? && WFProcess.getPSSysMsgTempl()?? ) || ((WFProcess.getFormCodeName())!'')!='' || ((WFProcess.getMobFormCodeName())!'')!='' > <#if (WFProcess.isSendInform()?? && WFProcess.getPSSysMsgTempl()?? ) || ((WFProcess.getFormCodeName())!'')!='' || ((WFProcess.getMobFormCodeName())!'')!='' >
<#assign msgTempl=WFProcess.getPSSysMsgTempl()>
<extensionElements> <extensionElements>
<#if (WFProcess.isSendInform()?? && WFProcess.getPSSysMsgTempl()?? )> <#if (WFProcess.isSendInform()?? && WFProcess.getPSSysMsgTempl()?? )>
<#assign msgTempl=WFProcess.getPSSysMsgTempl()>
<flowable:formProperty id="${msgTempl.getCodeName()?lower_case}" name="${msgTempl.getName()}" variable="${assignGroupCond}" type="${WFProcess.getMsgType()}" /> <flowable:formProperty id="${msgTempl.getCodeName()?lower_case}" name="${msgTempl.getName()}" variable="${assignGroupCond}" type="${WFProcess.getMsgType()}" />
</#if> </#if>
<#if ((WFProcess.getFormCodeName())!'')!='' || ((WFProcess.getMobFormCodeName())!'')!='' > <#if ((WFProcess.getFormCodeName())!'')!='' || ((WFProcess.getMobFormCodeName())!'')!='' >
......
...@@ -15,6 +15,15 @@ TARGET=PSSYSTEM ...@@ -15,6 +15,15 @@ TARGET=PSSYSTEM
<#break> <#break>
</#if> </#if>
</#list> </#list>
<#assign hasMQEntity=false>
<#list sys.getAllPSDataEntities() as dataEntity>
<#if dataEntity.getAllPSDEDataSyncs?? && dataEntity.getAllPSDEDataSyncs()??>
<#list dataEntity.getAllPSDEDataSyncs() as dataSync>
<#assign hasMQEntity=true>
<#break>
</#list>
</#if>
</#list>
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
...@@ -114,6 +123,9 @@ TARGET=PSSYSTEM ...@@ -114,6 +123,9 @@ TARGET=PSSYSTEM
</#if> </#if>
</#list> </#list>
</#if> </#if>
<#if hasMQEntity>
<rocketmq.version>4.7.0</rocketmq.version>
</#if>
</properties> </properties>
...@@ -327,7 +339,13 @@ TARGET=PSSYSTEM ...@@ -327,7 +339,13 @@ TARGET=PSSYSTEM
</exclusions> </exclusions>
</dependency> </dependency>
</#if> </#if>
<#if hasMQEntity>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>${r'${rocketmq.version}'}</version>
</dependency>
</#if>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
......
...@@ -10,6 +10,7 @@ TARGET=PSSYSSERVICEAPI ...@@ -10,6 +10,7 @@ TARGET=PSSYSSERVICEAPI
<#assign dbPassWord="123456"> <#assign dbPassWord="123456">
<#assign dbUrl="jdbc:mysql://127.0.0.1:3306/"+sys.name+"?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&allowMultiQueries=true"> <#assign dbUrl="jdbc:mysql://127.0.0.1:3306/"+sys.name+"?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&allowMultiQueries=true">
<#assign dbDriver="com.mysql.jdbc.Driver"> <#assign dbDriver="com.mysql.jdbc.Driver">
<#assign dockerPortMap="">
<#if sysrun?? && sysrun.getPSDevSlnMSDepAPI()?? > <#if sysrun?? && sysrun.getPSDevSlnMSDepAPI()?? >
<#assign depSysApi=sysrun.getPSDevSlnMSDepAPI()> <#assign depSysApi=sysrun.getPSDevSlnMSDepAPI()>
<#if depSysApi.getHttpPort()??> <#if depSysApi.getHttpPort()??>
...@@ -36,6 +37,9 @@ TARGET=PSSYSSERVICEAPI ...@@ -36,6 +37,9 @@ TARGET=PSSYSSERVICEAPI
<#elseif depSysApiPlatform.getUserParam("spring.redis.database","")?? && depSysApiPlatform.getUserParam("spring.redis.database","")!=""> <#elseif depSysApiPlatform.getUserParam("spring.redis.database","")?? && depSysApiPlatform.getUserParam("spring.redis.database","")!="">
<#assign redisDataBase = depSysApiPlatform.getUserParam("spring.redis.database","")> <#assign redisDataBase = depSysApiPlatform.getUserParam("spring.redis.database","")>
</#if> </#if>
<#if depSysApi.getUserParam("portmap","")?? && depSysApi.getUserParam("portmap","")!="">
<#assign dockerPortMap= depSysApi.getUserParam("portmap","")>
</#if>
</#if> </#if>
</#if> </#if>
<#comment>数据库配置</#comment> <#comment>数据库配置</#comment>
...@@ -65,6 +69,9 @@ services: ...@@ -65,6 +69,9 @@ services:
image: registry.cn-shanghai.aliyuncs.com/ibizsys/${pub.getCodeName()?lower_case}-provider-${api.getCodeName()?lower_case}:latest image: registry.cn-shanghai.aliyuncs.com/ibizsys/${pub.getCodeName()?lower_case}-provider-${api.getCodeName()?lower_case}:latest
ports: ports:
- "${httpPort}:${httpPort}" - "${httpPort}:${httpPort}"
<#if dockerPortMap!=''>
- "${dockerPortMap}"
</#if>
networks: networks:
- agent_network - agent_network
<#if sysrun?? && sysrun.getPSDevSlnMSDepAPI()?? && sysrun.getPSDevSlnMSDepAPI().getPSDCMSPlatformNode()??> <#if sysrun?? && sysrun.getPSDevSlnMSDepAPI()?? && sysrun.getPSDevSlnMSDepAPI().getPSDCMSPlatformNode()??>
......
...@@ -27,7 +27,7 @@ import org.springframework.context.annotation.Import; ...@@ -27,7 +27,7 @@ import org.springframework.context.annotation.Import;
@ConditionalOnClass(${item.codeName}RestConfiguration.class) @ConditionalOnClass(${item.codeName}RestConfiguration.class)
@ConditionalOnWebApplication @ConditionalOnWebApplication
@EnableConfigurationProperties(${item.codeName}ServiceProperties.class) @EnableConfigurationProperties(${item.codeName}ServiceProperties.class)
public class ${item.codeName}AutoConfiguration implements ApplicationContextAware{ public class ${item.codeName}AutoConfiguration implements ApplicationContextAware {
protected ApplicationContext applicationContext; protected ApplicationContext applicationContext;
......
...@@ -118,9 +118,9 @@ public class ${item.codeName}SecurityConfig extends WebSecurityConfigurerAdapter ...@@ -118,9 +118,9 @@ public class ${item.codeName}SecurityConfig extends WebSecurityConfigurerAdapter
"/v2/**" "/v2/**"
).permitAll() ).permitAll()
//放行登录请求 //放行登录请求
.antMatchers( HttpMethod.POST,"/"+loginPath).permitAll() .antMatchers( HttpMethod.POST, "/"+loginPath).permitAll()
//放行注销请求 //放行注销请求
.antMatchers( HttpMethod.GET,"/"+logoutPath).permitAll() .antMatchers( HttpMethod.GET, "/"+logoutPath).permitAll()
// 文件操作 // 文件操作
.antMatchers("/"+downloadpath+"/**").permitAll() .antMatchers("/"+downloadpath+"/**").permitAll()
.antMatchers("/"+uploadpath).permitAll() .antMatchers("/"+uploadpath).permitAll()
......
...@@ -10,6 +10,19 @@ TARGET=PSDESERVICEAPI ...@@ -10,6 +10,19 @@ TARGET=PSDESERVICEAPI
<#if ((de.getPSSubSysServiceAPI().getServiceType())!'')=='MIDDLEPLATFORM'> <#if ((de.getPSSubSysServiceAPI().getServiceType())!'')=='MIDDLEPLATFORM'>
<#assign dtoBase="DTOClient"> <#assign dtoBase="DTOClient">
</#if> </#if>
<#assign hasValueRuleGroup=false>
<#if sys.codeName == 'Sample'>
<#if de.getAllPSDEFValueRules()??>
<#list de.getAllPSDEFValueRules() as deRule>
<#if deRule.codeName!='Default'>
<#if deRule.getPSDEFVRGroupCondition()??>
<#assign hasValueRuleGroup=true>
<#break>
</#if>
</#if>
</#list>
</#if>
</#if>
package ${pubPkgCodeName}.${itemSysApiCodeNameLC}.dto; package ${pubPkgCodeName}.${itemSysApiCodeNameLC}.dto;
import java.sql.Timestamp; import java.sql.Timestamp;
...@@ -32,11 +45,15 @@ import javax.validation.constraints.Size; ...@@ -32,11 +45,15 @@ import javax.validation.constraints.Size;
import ${pub.getPKGCodeName()}.util.domain.DTOBase; import ${pub.getPKGCodeName()}.util.domain.DTOBase;
import ${pub.getPKGCodeName()}.util.domain.DTOClient; import ${pub.getPKGCodeName()}.util.domain.DTOClient;
import lombok.Data; import lombok.Data;
<#if hasValueRuleGroup>
import ${pub.getPKGCodeName()}.util.annotation.ValueRuleCheck;
</#if>
/** /**
* 服务DTO对象[${item.getCodeName()}DTO] * 服务DTO对象[${item.getCodeName()}DTO]
*/ */
@Data @Data
<@valueRuleGroup/>
public class ${item.getCodeName()}DTO extends ${dtoBase} implements Serializable { public class ${item.getCodeName()}DTO extends ${dtoBase} implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -158,4 +175,23 @@ public class ${item.getCodeName()}DTO extends ${dtoBase} implements Serializable ...@@ -158,4 +175,23 @@ public class ${item.getCodeName()}DTO extends ${dtoBase} implements Serializable
</#list> </#list>
</#if> </#if>
</#if> </#if>
</#macro>
<#comment>属性值规则(规则组)</#comment>
<#macro valueRuleGroup>
<#if hasValueRuleGroup>
<#assign ruleMsg="">
@ValueRuleCheck.List({
<#list de.getAllPSDEFValueRules() as deRule>
<#if deRule.codeName!='Default'>
<#if deRule.getPSDEFVRGroupCondition()??>
<#assign ruleName=(de.codeName+"_"+deRule.getPSDEField().codeName+"_"+deRule.codeName)?lower_case>
<#assign ruleField=(deRule.getPSDEField().codeName)?lower_case>
<#assign group=deRule.getPSDEFVRGroupCondition()>
@ValueRuleCheck(field = "${ruleField}", rule = "${ruleName}"),
</#if>
</#if>
</#list>
})
</#if>
</#macro> </#macro>
\ No newline at end of file
...@@ -13,11 +13,10 @@ import org.mapstruct.*; ...@@ -13,11 +13,10 @@ import org.mapstruct.*;
import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.domain.${de.codeName}; import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.domain.${de.codeName};
import ${pubPkgCodeName}.${itemSysApiCodeNameLC}.dto.${item.getCodeName()}DTO; import ${pubPkgCodeName}.${itemSysApiCodeNameLC}.dto.${item.getCodeName()}DTO;
import ${pub.getPKGCodeName()}.util.domain.MappingBase; import ${pub.getPKGCodeName()}.util.domain.MappingBase;
import org.mapstruct.factory.Mappers;
@Mapper(componentModel = "spring", uses = {},implementationName="${mappingName}", @Mapper(componentModel = "spring", uses = {}, implementationName = "${mappingName}",
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE, nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE,
nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS) nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface ${item.getCodeName()}Mapping extends MappingBase<${item.codeName}DTO, ${de.codeName}> { public interface ${item.getCodeName()}Mapping extends MappingBase<${item.codeName}DTO, ${de.codeName}> {
<#--<#comment>输出关系数据(子实体)</#comment>--> <#--<#comment>输出关系数据(子实体)</#comment>-->
......
...@@ -265,6 +265,10 @@ public class ${itemCodeName}Resource { ...@@ -265,6 +265,10 @@ public class ${itemCodeName}Resource {
</#if> </#if>
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC}dto); return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC}dto);
} }
<#comment>自定义行为批处理</#comment>
<#if (deaction.getActionType()=='USERCUSTOM')>
<@customBatchAction deaction/>
</#if>
</#if> </#if>
<#elseif apiMethod.getActionType()=='FETCH'> <#elseif apiMethod.getActionType()=='FETCH'>
...@@ -272,7 +276,7 @@ public class ${itemCodeName}Resource { ...@@ -272,7 +276,7 @@ public class ${itemCodeName}Resource {
<@DataQuerySecurityAnnotation deds/> <@DataQuerySecurityAnnotation deds/>
@ApiOperation(value = "获取${deds.getLogicName()}", tags = {"${deLogicName}" } ,notes = "获取${deds.getLogicName()}") @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>") @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()>HashMap<#else>${itemCodeName}DTO</#if>>> fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()}<#else>${deds.getCodeName()}</#if>(${deCodeName}SearchContext context) { public ResponseEntity<List<<#if deds.isEnableGroup()>HashMap<#else>${itemCodeName}DTO</#if>>> fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()}<#else>${deds.getCodeName()}</#if>(<#if reqMtd!='GET'>@RequestBody </#if>${deCodeName}SearchContext context) {
<#--${parentSearchParams}--> <#--${parentSearchParams}-->
<#if deds.isEnableGroup()> <#if deds.isEnableGroup()>
Page<HashMap> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ; Page<HashMap> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ;
...@@ -424,12 +428,7 @@ public class ${itemCodeName}Resource { ...@@ -424,12 +428,7 @@ public class ${itemCodeName}Resource {
<#if item.getPSDEServiceAPIMethods()??> <#if item.getPSDEServiceAPIMethods()??>
<#list item.getPSDEServiceAPIMethods() as apiMethod> <#list item.getPSDEServiceAPIMethods() as apiMethod>
<#assign reqMtd = apiMethod.getRequestMethod()> <#assign reqMtd = apiMethod.getRequestMethod()>
<#assign statusCode = ""> <#assign statusCode = "HttpStatus.OK" >
<#if reqMtd == "POST" >
<#assign statusCode = "HttpStatus.CREATED" >
<#else>
<#assign statusCode = "HttpStatus.OK" >
</#if>
<#if apiMethod.getActionType()=='DEACTION'> <#if apiMethod.getActionType()=='DEACTION'>
<#assign deaction = apiMethod.getPSDEAction()> <#assign deaction = apiMethod.getPSDEAction()>
<#assign deactionName = deaction.getName()> <#assign deactionName = deaction.getName()>
...@@ -611,14 +610,17 @@ public class ${itemCodeName}Resource { ...@@ -611,14 +610,17 @@ public class ${itemCodeName}Resource {
</#if> </#if>
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC}dto); return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC}dto);
} }
<#comment>自定义行为批处理</#comment>
<#if (deaction.getActionType()=='USERCUSTOM')>
<@customBatchActionRS deaction/>
</#if>
</#if> </#if>
<#elseif apiMethod.getActionType()=='FETCH'> <#elseif apiMethod.getActionType()=='FETCH'>
<#assign deds = apiMethod.getPSDEDataSet()> <#assign deds = apiMethod.getPSDEDataSet()>
<@DataQuerySecurityAnnotation deds/> <@DataQuerySecurityAnnotation deds/>
@ApiOperation(value = "${byTagParams}获取${deds.getLogicName()}", tags = {"${deLogicName}" } ,notes = "${byTagParams}获取${deds.getLogicName()}") @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>") @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()>HashMap<#else>${itemCodeName}DTO</#if>>> fetch${itemCodeName}<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()}<#else>${deds.getCodeName()}</#if>${byParams}(<#if parentParams!="">${parentParams},</#if>${deCodeName}SearchContext context) { public ResponseEntity<List<<#if deds.isEnableGroup()>HashMap<#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} ${parentSearchParams}
<#if deds.isEnableGroup()> <#if deds.isEnableGroup()>
Page<HashMap> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ; Page<HashMap> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ;
...@@ -677,11 +679,11 @@ public class ${itemCodeName}Resource { ...@@ -677,11 +679,11 @@ public class ${itemCodeName}Resource {
else{ else{
<#list de.getAllPSDEDataImports() as deImport> <#list de.getAllPSDEDataImports() as deImport>
<#if deImport_index==0> <#if deImport_index==0>
if(config.equals("${deImport.codeName}")){ if("${deImport.codeName}".equals(config)){
rs=${deCodeNameLC}Service.importData(${deImport.codeName?lower_case}ImpMapping.toDomain(dtos),${deImport.getBatchSize()?c},${deImport.isIgnoreError()?c}); rs=${deCodeNameLC}Service.importData(${deImport.codeName?lower_case}ImpMapping.toDomain(dtos),${deImport.getBatchSize()?c},${deImport.isIgnoreError()?c});
} }
<#else> <#else>
else if(config.equals("${deImport.codeName}")){ else if("${deImport.codeName}".equals(config)){
rs=${deCodeNameLC}Service.importData(${deImport.codeName?lower_case}ImpMapping.toDomain(dtos),${deImport.getBatchSize()?c},${deImport.isIgnoreError()?c}); rs=${deCodeNameLC}Service.importData(${deImport.codeName?lower_case}ImpMapping.toDomain(dtos),${deImport.getBatchSize()?c},${deImport.isIgnoreError()?c});
} }
</#if> </#if>
...@@ -696,7 +698,7 @@ public class ${itemCodeName}Resource { ...@@ -696,7 +698,7 @@ public class ${itemCodeName}Resource {
<#comment>数据查询Security权限校验(分组不鉴权)</#comment> <#comment>数据查询Security权限校验(分组不鉴权)</#comment>
<#macro DataQuerySecurityAnnotation dataset> <#macro DataQuerySecurityAnnotation dataset>
<#if (de.getStorageMode()==1 || de.getStorageMode()==2 ) && dataset.isEnableGroup()==false> <#if (de.getStorageMode()==1 || de.getStorageMode()==2 ||de.getStorageMode()==4) && dataset.isEnableGroup()==false>
<#if hasDEPrefield==false> <#if hasDEPrefield==false>
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','${sys.codeName}-${de.codeName}-search${dataset.codeName}-all')") @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','${sys.codeName}-${de.codeName}-search${dataset.codeName}-all')")
<#else> <#else>
...@@ -707,7 +709,7 @@ public class ${itemCodeName}Resource { ...@@ -707,7 +709,7 @@ public class ${itemCodeName}Resource {
<#comment>单条数据Security权限校验</#comment> <#comment>单条数据Security权限校验</#comment>
<#macro SecurityAnnotation deaction> <#macro SecurityAnnotation deaction>
<#if de.getStorageMode()==1 || de.getStorageMode()==2> <#if de.getStorageMode()==1 || de.getStorageMode()==2 ||de.getStorageMode()==4>
<#if hasDEPrefield==false> <#if hasDEPrefield==false>
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','${sys.codeName}-${de.codeName}-${deaction.codeName}-all')") @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','${sys.codeName}-${de.codeName}-${deaction.codeName}-all')")
<#else> <#else>
...@@ -726,7 +728,7 @@ public class ${itemCodeName}Resource { ...@@ -726,7 +728,7 @@ public class ${itemCodeName}Resource {
<#comment>批量数据Security权限校验</#comment> <#comment>批量数据Security权限校验</#comment>
<#macro SecurityBatchAnnotation deaction> <#macro SecurityBatchAnnotation deaction>
<#if de.getStorageMode()==1 || de.getStorageMode()==2> <#if de.getStorageMode()==1 || de.getStorageMode()==2 ||de.getStorageMode()==4>
<#if hasDEPrefield==false> <#if hasDEPrefield==false>
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','${sys.codeName}-${de.codeName}-${deaction.codeName}-all')") @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','${sys.codeName}-${de.codeName}-${deaction.codeName}-all')")
<#else> <#else>
...@@ -998,6 +1000,26 @@ public class ${itemCodeName}Resource { ...@@ -998,6 +1000,26 @@ public class ${itemCodeName}Resource {
</#if> </#if>
</#macro> </#macro>
<#comment>用户自定义行为批处理-主实体关系</#comment>
<#macro customBatchAction deaction>
<@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}batch")
public ResponseEntity<Boolean> ${deactionCodeName?uncap_first}Batch(${etParamsList}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.${srfmethodname(deactionCodeName)}Batch(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos)));
}
</#macro>
<#comment>用户自定义行为批处理-从实体关系</#comment>
<#macro customBatchActionRS 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}batch")
public ResponseEntity<Boolean> ${deactionCodeName?uncap_first}${byParams}(${etParamsList}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.${srfmethodname(deactionCodeName)}Batch(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos)));
}
</#macro>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#if sys.codeName == 'Sample'>
package ${pub.getPKGCodeName()}.util.annotation;
import ${pub.getPKGCodeName()}.util.service.ValueRuleValidator;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({FIELD, METHOD, PARAMETER, ANNOTATION_TYPE, TYPE_USE})
@Retention(RUNTIME)
@Constraint(validatedBy = {ValueRuleValidator.class})
@Documented
public @interface ValueRuleCheck {
String field();
String rule();
String message() default "值规则检查异常!";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
@Target({TYPE_USE})
@Retention(RUNTIME)
@Documented
@interface List {
ValueRuleCheck[] value();
}
}
</#if>
\ No newline at end of file
...@@ -53,30 +53,31 @@ public class AuditAspect ...@@ -53,30 +53,31 @@ public class AuditAspect
*/ */
@AfterReturning(value = "execution(* ${pub.getPKGCodeName()}.core.*.service.*.create(..))<#if hasESEntity>&& !execution(* ${pub.getPKGCodeName()}.core.es.service.*.create*(..))</#if>") @AfterReturning(value = "execution(* ${pub.getPKGCodeName()}.core.*.service.*.create(..))<#if hasESEntity>&& !execution(* ${pub.getPKGCodeName()}.core.es.service.*.create*(..))</#if>")
@SneakyThrows @SneakyThrows
public void create(JoinPoint point){ public void create(JoinPoint point) {
HttpServletRequest request=null; HttpServletRequest request = null;
RequestAttributes requestAttributes= RequestContextHolder.getRequestAttributes(); RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
if(requestAttributes!=null){ if(requestAttributes!=null) {
request=((ServletRequestAttributes)requestAttributes).getRequest(); request = ((ServletRequestAttributes)requestAttributes).getRequest();
} }
Object [] args = point.getArgs(); Object [] args = point.getArgs();
if(ObjectUtils.isEmpty(args) || args.length==0) if(ObjectUtils.isEmpty(args) || args.length==0) {
return; return;
}
Object serviceParam =args[0]; Object serviceParam = args[0];
if(serviceParam instanceof EntityBase){ if(serviceParam instanceof EntityBase) {
EntityBase entity=(EntityBase)serviceParam;//创建数据 EntityBase entity = (EntityBase)serviceParam;
Map<String, Audit> auditFields= DEFieldCacheMap.getAuditFields(entity.getClass()); Map<String, Audit> auditFields = DEFieldCacheMap.getAuditFields(entity.getClass());
if(auditFields.size()==0)//是否有审计属性 //是否有审计属性
if(auditFields.size()==0) {
return; return;
}
String idField=DEFieldCacheMap.getDEKeyField(entity.getClass()); String idField = DEFieldCacheMap.getDEKeyField(entity.getClass());
Object idValue=""; Object idValue = "";
if(!StringUtils.isEmpty(idField)){ if(!StringUtils.isEmpty(idField)) {
idValue=entity.get(idField); idValue=entity.get(idField);
} }
//记录审计日志 //记录审计日志
dataAuditService.createAudit(request,entity,idValue,auditFields); dataAuditService.createAudit(request, entity, idValue, auditFields);
} }
} }
...@@ -87,39 +88,38 @@ public class AuditAspect ...@@ -87,39 +88,38 @@ public class AuditAspect
*/ */
@Around("execution(* ${pub.getPKGCodeName()}.core.*.service.*.update(..))<#if hasESEntity>&& !execution(* ${pub.getPKGCodeName()}.core.es.service.*.update*(..))</#if>") @Around("execution(* ${pub.getPKGCodeName()}.core.*.service.*.update(..))<#if hasESEntity>&& !execution(* ${pub.getPKGCodeName()}.core.es.service.*.update*(..))</#if>")
public Object update(ProceedingJoinPoint point) throws Throwable { public Object update(ProceedingJoinPoint point) throws Throwable {
HttpServletRequest request=null; HttpServletRequest request = null;
RequestAttributes requestAttributes= RequestContextHolder.getRequestAttributes(); RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
if(requestAttributes!=null){ if(requestAttributes!=null) {
request=((ServletRequestAttributes)requestAttributes).getRequest(); request=((ServletRequestAttributes)requestAttributes).getRequest();
} }
Object serviceObj=point.getTarget(); Object serviceObj = point.getTarget();
Object args[]=point.getArgs(); Object args[] = point.getArgs();
if(ObjectUtils.isEmpty(args) || args.length==0) {
if(ObjectUtils.isEmpty(args) || args.length==0)
return point.proceed(); return point.proceed();
}
Object arg=args[0]; Object arg = args[0];
if(arg instanceof EntityBase){ if(arg instanceof EntityBase) {
EntityBase entity= (EntityBase) arg; EntityBase entity = (EntityBase) arg;
Map<String, Audit> auditFields= DEFieldCacheMap.getAuditFields(entity.getClass()); Map<String, Audit> auditFields = DEFieldCacheMap.getAuditFields(entity.getClass());
//是否有审计属性 //是否有审计属性
if(auditFields.size()==0) if(auditFields.size()==0) {
return point.proceed(); return point.proceed();
String idField=DEFieldCacheMap.getDEKeyField(entity.getClass()); }
Object idValue=""; String idField = DEFieldCacheMap.getDEKeyField(entity.getClass());
Object idValue = "";
if(!StringUtils.isEmpty(idField)){ if(!StringUtils.isEmpty(idField)){
idValue=entity.get(idField); idValue = entity.get(idField);
} }
if(ObjectUtils.isEmpty(idValue)) if(ObjectUtils.isEmpty(idValue)) {
return point.proceed(); return point.proceed();
}
//获取更新前实体 //获取更新前实体
EntityBase beforeEntity=getEntity(serviceObj,idValue); EntityBase beforeEntity = getEntity(serviceObj, idValue);
//执行更新操作 //执行更新操作
point.proceed(); point.proceed();
//记录审计日志 //记录审计日志
dataAuditService.updateAudit(request,beforeEntity,serviceObj,idValue,auditFields); dataAuditService.updateAudit(request, beforeEntity, serviceObj, idValue, auditFields);
return true; return true;
} }
return point.proceed(); return point.proceed();
...@@ -134,28 +134,27 @@ public class AuditAspect ...@@ -134,28 +134,27 @@ public class AuditAspect
*/ */
@Around("execution(* ${pub.getPKGCodeName()}.core.*.service.*.remove(..))<#if hasESEntity>&& !execution(* ${pub.getPKGCodeName()}.core.es.service.*.remove*(..))</#if>") @Around("execution(* ${pub.getPKGCodeName()}.core.*.service.*.remove(..))<#if hasESEntity>&& !execution(* ${pub.getPKGCodeName()}.core.es.service.*.remove*(..))</#if>")
public Object remove(ProceedingJoinPoint point) throws Throwable { public Object remove(ProceedingJoinPoint point) throws Throwable {
HttpServletRequest request=null; HttpServletRequest request = null;
RequestAttributes requestAttributes= RequestContextHolder.getRequestAttributes(); RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
if(requestAttributes!=null){ if(requestAttributes!= null) {
request=((ServletRequestAttributes)requestAttributes).getRequest(); request = ((ServletRequestAttributes)requestAttributes).getRequest();
} }
Object serviceObj=point.getTarget(); Object serviceObj = point.getTarget();
Object args[]=point.getArgs(); Object args[] = point.getArgs();
if(ObjectUtils.isEmpty(args) || args.length==0) {
if(ObjectUtils.isEmpty(args) || args.length==0)
return point.proceed(); return point.proceed();
}
Object idValue=args[0]; Object idValue = args[0];
EntityBase entity=getEntity(serviceObj,idValue); EntityBase entity = getEntity(serviceObj, idValue);
Map<String, Audit> auditFields= DEFieldCacheMap.getAuditFields(entity.getClass()); Map<String, Audit> auditFields = DEFieldCacheMap.getAuditFields(entity.getClass());
if(auditFields.size()==0){ if(auditFields.size()==0) {
return point.proceed(); return point.proceed();
} }
else{ else{
//执行删除操作 //执行删除操作
point.proceed(); point.proceed();
//记录审计日志 //记录审计日志
dataAuditService.removeAudit(request,entity,idValue,auditFields); dataAuditService.removeAudit(request, entity, idValue, auditFields);
return true; return true;
} }
} }
...@@ -167,12 +166,12 @@ public class AuditAspect ...@@ -167,12 +166,12 @@ public class AuditAspect
* @return * @return
*/ */
@SneakyThrows @SneakyThrows
private EntityBase getEntity(Object service, Object id){ private EntityBase getEntity(Object service, Object id) {
EntityBase entity=null; EntityBase entity = null;
if(!ObjectUtils.isEmpty(service)){ if(!ObjectUtils.isEmpty(service)) {
EvaluationContext oldContext = new StandardEvaluationContext(); EvaluationContext oldContext = new StandardEvaluationContext();
oldContext.setVariable("service",service); oldContext.setVariable("service", service);
oldContext.setVariable("id",id); oldContext.setVariable("id", id);
Expression oldExp = parser.parseExpression("#service.get(#id)"); Expression oldExp = parser.parseExpression("#service.get(#id)");
return oldExp.getValue(oldContext, EntityBase.class); return oldExp.getValue(oldContext, EntityBase.class);
} }
......
...@@ -82,29 +82,31 @@ public class DEFieldDefaultValueAspect ...@@ -82,29 +82,31 @@ public class DEFieldDefaultValueAspect
Object[] args = joinPoint.getArgs(); Object[] args = joinPoint.getArgs();
if (args.length > 0) { if (args.length > 0) {
Object obj = args[0]; Object obj = args[0];
String actionName=joinPoint.getSignature().getName(); String actionName = joinPoint.getSignature().getName();
if(obj instanceof EntityBase) { if(obj instanceof EntityBase) {
Map<String, DEField> deFields = DEFieldCacheMap.getDEFields(obj.getClass()); Map<String, DEField> deFields = DEFieldCacheMap.getDEFields(obj.getClass());
AuthenticationUser curUser = AuthenticationUser.getAuthenticationUser(); AuthenticationUser curUser = AuthenticationUser.getAuthenticationUser();
String keyField=DEFieldCacheMap.getDEKeyField(obj.getClass()); String keyField = DEFieldCacheMap.getDEKeyField(obj.getClass());
if(StringUtils.isEmpty(keyField)) if(StringUtils.isEmpty(keyField)) {
return true; return true;
fillDEField((EntityBase)obj, deFields,actionName,curUser,keyField); }
fillDEField((EntityBase)obj, deFields, actionName, curUser, keyField);
} }
else if (obj instanceof List) { else if (obj instanceof List) {
Map<String, DEField> deFields = null; Map<String, DEField> deFields = null;
AuthenticationUser curUser = null; AuthenticationUser curUser = null;
String keyField = ""; String keyField = "";
for(Object item:(List)obj) { for(Object item : (List)obj) {
if(item instanceof EntityBase) { if(item instanceof EntityBase) {
if(deFields==null) { if(deFields == null) {
deFields = DEFieldCacheMap.getDEFields(item.getClass()); deFields = DEFieldCacheMap.getDEFields(item.getClass());
curUser = AuthenticationUser.getAuthenticationUser(); curUser = AuthenticationUser.getAuthenticationUser();
keyField=DEFieldCacheMap.getDEKeyField(item.getClass()); keyField = DEFieldCacheMap.getDEKeyField(item.getClass());
if(StringUtils.isEmpty(keyField)) if(StringUtils.isEmpty(keyField)) {
return true; return true;
}
} }
fillDEField((EntityBase)item, deFields,actionName,curUser,keyField); fillDEField((EntityBase)item, deFields, actionName, curUser, keyField);
} }
} }
} }
...@@ -118,15 +120,15 @@ public class DEFieldDefaultValueAspect ...@@ -118,15 +120,15 @@ public class DEFieldDefaultValueAspect
* 填充系统预置属性 * 填充系统预置属性
* @param et 当前实体对象 * @param et 当前实体对象
*/ */
private void fillDEField(EntityBase et, Map<String, DEField> deFields, String actionName,AuthenticationUser curUser,String keyField) throws Exception { private void fillDEField(EntityBase et, Map<String, DEField> deFields, String actionName, AuthenticationUser curUser, String keyField) throws Exception {
if(deFields.size()==0) if(deFields.size()==0) {
return ; return;
}
if(actionName.toLowerCase().startsWith("save")) { if(actionName.toLowerCase().startsWith("save")) {
if(ObjectUtils.isEmpty(et.get(keyField))) if(ObjectUtils.isEmpty(et.get(keyField))) {
actionName="create"; actionName="create";
}
} }
for (Map.Entry<String, DEField> entry : deFields.entrySet()) { for (Map.Entry<String, DEField> entry : deFields.entrySet()) {
String fieldname=entry.getKey(); String fieldname=entry.getKey();
//获取注解 //获取注解
...@@ -139,12 +141,12 @@ public class DEFieldDefaultValueAspect ...@@ -139,12 +141,12 @@ public class DEFieldDefaultValueAspect
DEPredefinedFieldType predefinedFieldType = fieldAnnotation.preType(); DEPredefinedFieldType predefinedFieldType = fieldAnnotation.preType();
//填充系统默认值 //填充系统默认值
if(actionName.toLowerCase().startsWith("create") && ( deFieldType!= DEFieldDefaultValueType.NONE || (!StringUtils.isEmpty(deFieldDefaultValue)) )){ if(actionName.toLowerCase().startsWith("create") && (deFieldType!= DEFieldDefaultValueType.NONE || (!StringUtils.isEmpty(deFieldDefaultValue)))) {
fillFieldDefaultValue(fieldname, deFieldType, deFieldDefaultValue, et , curUser) ; fillFieldDefaultValue(fieldname, deFieldType, deFieldDefaultValue, et , curUser) ;
} }
//填充系统预置属性 //填充系统预置属性
if(predefinedFieldType != DEPredefinedFieldType.NONE){ if(predefinedFieldType != DEPredefinedFieldType.NONE) {
fillPreFieldValue( fieldname, predefinedFieldType , et ,actionName ,fieldAnnotation.logicval(),curUser); fillPreFieldValue(fieldname, predefinedFieldType , et ,actionName ,fieldAnnotation.logicval(),curUser);
} }
} }
} }
...@@ -157,17 +159,17 @@ public class DEFieldDefaultValueAspect ...@@ -157,17 +159,17 @@ public class DEFieldDefaultValueAspect
* @param et 当前实体对象 * @param et 当前实体对象
* @throws Exception * @throws Exception
*/ */
private void fillFieldDefaultValue(String fieldname , DEFieldDefaultValueType deFieldType,String deFieldDefaultValue,EntityBase et ,AuthenticationUser curUser) throws Exception { private void fillFieldDefaultValue(String fieldname, DEFieldDefaultValueType deFieldType, String deFieldDefaultValue, EntityBase et , AuthenticationUser curUser) throws Exception {
Object fieldValue = et.get(fieldname); Object fieldValue = et.get(fieldname);
if(org.springframework.util.ObjectUtils.isEmpty(fieldValue)){ if(org.springframework.util.ObjectUtils.isEmpty(fieldValue)) {
//填充直接值及其余默认值类型 //填充直接值及其余默认值类型
if( (deFieldType== DEFieldDefaultValueType.NONE && !StringUtils.isEmpty(deFieldDefaultValue)) || (deFieldType != DEFieldDefaultValueType.NONE) ){ if( (deFieldType== DEFieldDefaultValueType.NONE && !StringUtils.isEmpty(deFieldDefaultValue)) || (deFieldType != DEFieldDefaultValueType.NONE)) {
switch(deFieldType){ switch(deFieldType) {
case SESSION: case SESSION:
if(!StringUtils.isEmpty(deFieldDefaultValue)){ if(!StringUtils.isEmpty(deFieldDefaultValue)) {
Object sessionFieldValue = curUser.getSessionParams().get(deFieldDefaultValue.toLowerCase()); Object sessionFieldValue = curUser.getSessionParams().get(deFieldDefaultValue.toLowerCase());
if(!ObjectUtils.isEmpty(sessionFieldValue)){ if(!ObjectUtils.isEmpty(sessionFieldValue)) {
et.set(fieldname,sessionFieldValue); et.set(fieldname, sessionFieldValue);
} }
} }
break; break;
...@@ -175,91 +177,95 @@ public class DEFieldDefaultValueAspect ...@@ -175,91 +177,95 @@ public class DEFieldDefaultValueAspect
//暂未实现 //暂未实现
break; break;
case UNIQUEID: case UNIQUEID:
et.set(fieldname,(new AlternativeJdkIdGenerator()).generateId().toString().replace("-", "")); et.set(fieldname, (new AlternativeJdkIdGenerator()).generateId().toString().replace("-", ""));
break; break;
case CONTEXT: case CONTEXT:
if(!StringUtils.isEmpty(deFieldDefaultValue)){ if(!StringUtils.isEmpty(deFieldDefaultValue)) {
Object paramFieldValue=et.get(deFieldDefaultValue); Object paramFieldValue=et.get(deFieldDefaultValue);
if(!ObjectUtils.isEmpty(paramFieldValue)){ if(!ObjectUtils.isEmpty(paramFieldValue)) {
et.set(fieldname,paramFieldValue); et.set(fieldname, paramFieldValue);
} }
} }
break; break;
case PARAM: case PARAM:
if(!StringUtils.isEmpty(deFieldDefaultValue)){ if(!StringUtils.isEmpty(deFieldDefaultValue)) {
Object paramFieldValue=et.get(deFieldDefaultValue); Object paramFieldValue=et.get(deFieldDefaultValue);
if(!ObjectUtils.isEmpty(paramFieldValue)){ if(!ObjectUtils.isEmpty(paramFieldValue)) {
et.set(fieldname,paramFieldValue); et.set(fieldname, paramFieldValue);
} }
} }
break; break;
case OPERATOR: case OPERATOR:
et.set(fieldname,curUser.getUserid()); et.set(fieldname, curUser.getUserid());
break; break;
case OPERATORNAME: case OPERATORNAME:
et.set(fieldname,curUser.getPersonname()); et.set(fieldname, curUser.getPersonname());
break; break;
case CURTIME: case CURTIME:
et.set(fieldname,new Timestamp(new Date().getTime())); et.set(fieldname, new Timestamp(new Date().getTime()));
break; break;
case APPDATA: case APPDATA:
//暂未实现 //暂未实现
break; break;
case NONE: case NONE:
et.set(fieldname,deFieldDefaultValue); et.set(fieldname, deFieldDefaultValue);
break; break;
} }
} }
} }
} }
private void fillPreFieldValue(String fieldname , DEPredefinedFieldType preFieldType ,EntityBase et , String actionName,String logicValue ,AuthenticationUser curUser) throws Exception { private void fillPreFieldValue(String fieldname, DEPredefinedFieldType preFieldType, EntityBase et, String actionName, String logicValue, AuthenticationUser curUser) throws Exception {
Object fieldValue = et.get(fieldname); Object fieldValue = et.get(fieldname);
//为预置属性进行赋值 //为预置属性进行赋值
if( actionName.toLowerCase().startsWith("create") || if(actionName.toLowerCase().startsWith("create") ||
preFieldType== DEPredefinedFieldType.UPDATEDATE|| preFieldType== DEPredefinedFieldType.UPDATEMAN|| preFieldType== DEPredefinedFieldType.UPDATEDATE|| preFieldType== DEPredefinedFieldType.UPDATEMAN||
preFieldType== DEPredefinedFieldType.UPDATEMANNAME){ preFieldType== DEPredefinedFieldType.UPDATEMANNAME) {
switch(preFieldType){//根据注解给预置属性填充值 switch(preFieldType) {
case CREATEMAN: case CREATEMAN:
et.set(fieldname,curUser.getUserid()); et.set(fieldname, curUser.getUserid());
break; break;
case CREATEMANNAME: case CREATEMANNAME:
et.set(fieldname,curUser.getPersonname()); et.set(fieldname, curUser.getPersonname());
break; break;
case UPDATEMAN: case UPDATEMAN:
et.set(fieldname,curUser.getUserid()); et.set(fieldname, curUser.getUserid());
break; break;
case UPDATEMANNAME: case UPDATEMANNAME:
et.set(fieldname,curUser.getPersonname()); et.set(fieldname, curUser.getPersonname());
break; break;
case CREATEDATE: case CREATEDATE:
et.set(fieldname,new Timestamp(new Date().getTime())); et.set(fieldname, new Timestamp(new Date().getTime()));
break; break;
case UPDATEDATE: case UPDATEDATE:
et.set(fieldname,new Timestamp(new Date().getTime())); et.set(fieldname, new Timestamp(new Date().getTime()));
break; break;
case ORGID: case ORGID:
if(org.springframework.util.StringUtils.isEmpty(fieldValue)) if(org.springframework.util.StringUtils.isEmpty(fieldValue)) {
et.set(fieldname,curUser.getOrgid()); et.set(fieldname, curUser.getOrgid());
}
break; break;
case ORGNAME: case ORGNAME:
if(org.springframework.util.StringUtils.isEmpty(fieldValue)) if(org.springframework.util.StringUtils.isEmpty(fieldValue)) {
et.set(fieldname,curUser.getOrgname()); et.set(fieldname, curUser.getOrgname());
}
break; break;
case ORGSECTORID: case ORGSECTORID:
if(org.springframework.util.StringUtils.isEmpty(fieldValue)) if(org.springframework.util.StringUtils.isEmpty(fieldValue)) {
et.set(fieldname,curUser.getMdeptid()); et.set(fieldname, curUser.getMdeptid());
}
break; break;
case ORGSECTORNAME: case ORGSECTORNAME:
if(org.springframework.util.StringUtils.isEmpty(fieldValue)) if(org.springframework.util.StringUtils.isEmpty(fieldValue)) {
et.set(fieldname,curUser.getMdeptname()); et.set(fieldname, curUser.getMdeptname());
}
break; break;
case LOGICVALID: case LOGICVALID:
if(StringUtils.isEmpty(logicValue)){ if(StringUtils.isEmpty(logicValue)) {
logicValue="1"; logicValue="1";
} }
et.set(fieldname,logicValue); et.set(fieldname, logicValue);
break; break;
} }
} }
......
...@@ -85,19 +85,19 @@ public class DupCheckAspect { ...@@ -85,19 +85,19 @@ public class DupCheckAspect {
//设置检查属性值 //设置检查属性值
QueryFilter filter = new QueryFilter(); QueryFilter filter = new QueryFilter();
setValue(entity,filter,fieldName,newValue); setValue(entity, filter, fieldName, newValue);
//设定重复值检查范围 //设定重复值检查范围
if(!StringUtils.isEmpty(dupCheckField)){ if(!StringUtils.isEmpty(dupCheckField)) {
Object dupFieldValue=getDEFieldValue(entity,dupCheckField); Object dupFieldValue=getDEFieldValue(entity,dupCheckField);
setValue(entity,filter,dupCheckField,dupFieldValue); setValue(entity, filter, dupCheckField, dupFieldValue);
} }
searchContext.setFilter(filter); searchContext.setFilter(filter);
//使用当前值到数据库中进行查询,判断是否重复 //使用当前值到数据库中进行查询,判断是否重复
EvaluationContext oldValueMappingCtx = new StandardEvaluationContext(); EvaluationContext oldValueMappingCtx = new StandardEvaluationContext();
oldValueMappingCtx.setVariable("service", service); oldValueMappingCtx.setVariable("service", service);
oldValueMappingCtx.setVariable("searchContext", searchContext); oldValueMappingCtx.setVariable("searchContext", searchContext);
Expression oldValueMappingExp = parser.parseExpression(String.format("#service.%s(#searchContext)",defaultDS)); Expression oldValueMappingExp = parser.parseExpression(String.format("#service.%s(#searchContext)", defaultDS));
Page oldData = oldValueMappingExp.getValue(oldValueMappingCtx, Page.class); Page oldData = oldValueMappingExp.getValue(oldValueMappingCtx, Page.class);
if (!ObjectUtils.isEmpty(oldData) && !ObjectUtils.isEmpty(oldData.getContent()) && oldData.getContent().size() > 1) { if (!ObjectUtils.isEmpty(oldData) && !ObjectUtils.isEmpty(oldData.getContent()) && oldData.getContent().size() > 1) {
throw new BadRequestAlertException(String.format("数据保存失败,属性[%s]:值[%s]已存在!", fieldName, newValue), "DupCheckAspect", "DupCheck"); throw new BadRequestAlertException(String.format("数据保存失败,属性[%s]:值[%s]已存在!", fieldName, newValue), "DupCheckAspect", "DupCheck");
...@@ -113,7 +113,7 @@ public class DupCheckAspect { ...@@ -113,7 +113,7 @@ public class DupCheckAspect {
* @param fieldName * @param fieldName
* @return * @return
*/ */
private Object getDEFieldValue(Object entity, String fieldName){ private Object getDEFieldValue(Object entity, String fieldName) {
EvaluationContext exMappingCtx = new StandardEvaluationContext(); EvaluationContext exMappingCtx = new StandardEvaluationContext();
exMappingCtx.setVariable("entity", entity); exMappingCtx.setVariable("entity", entity);
Expression esMappingExp = parser.parseExpression(String.format("#entity.get(\"%s\")", fieldName)); Expression esMappingExp = parser.parseExpression(String.format("#entity.get(\"%s\")", fieldName));
...@@ -127,10 +127,12 @@ public class DupCheckAspect { ...@@ -127,10 +127,12 @@ public class DupCheckAspect {
* @param value * @param value
*/ */
private void setValue(Object entity , QueryFilter filter, String fieldName, Object value){ private void setValue(Object entity , QueryFilter filter, String fieldName, Object value){
if(ObjectUtils.isEmpty(value)) if(ObjectUtils.isEmpty(value)) {
filter.isnull(DEFieldCacheMap.getFieldColumnName(entity.getClass(), fieldName)); filter.isnull(DEFieldCacheMap.getFieldColumnName(entity.getClass(), fieldName));
else }
filter.eq(DEFieldCacheMap.getFieldColumnName(entity.getClass(), fieldName),value); else {
filter.eq(DEFieldCacheMap.getFieldColumnName(entity.getClass(), fieldName), value);
}
} }
} }
</#if> </#if>
......
...@@ -46,7 +46,7 @@ public class ESAspect ...@@ -46,7 +46,7 @@ public class ESAspect
*/ */
@AfterReturning(value = "(execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.create*(..))||execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.update*(..))||execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.save*(..)) ||execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.remove*(..))) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.create*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.update*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.save*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.remove*(..))") @AfterReturning(value = "(execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.create*(..))||execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.update*(..))||execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.save*(..)) ||execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.remove*(..))) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.create*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.update*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.save*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.remove*(..))")
@Async @Async
public void Sync${dataEntity.codeName?lower_case?cap_first}(JoinPoint point){ public void Sync${dataEntity.codeName?lower_case?cap_first}(JoinPoint point) {
syncSaveESData(point,"${dataEntity.codeName}"); syncSaveESData(point,"${dataEntity.codeName}");
} }
</#if> </#if>
...@@ -56,44 +56,45 @@ public class ESAspect ...@@ -56,44 +56,45 @@ public class ESAspect
* 异步往es中保存数据 * 异步往es中保存数据
* @param point * @param point
*/ */
public void syncSaveESData(JoinPoint point,String deName){ public void syncSaveESData(JoinPoint point, String deName) {
try { try {
Object service=point.getTarget(); Object service=point.getTarget();
String action=point.getSignature().getName(); String action=point.getSignature().getName();
Object [] args = point.getArgs(); Object [] args = point.getArgs();
if(ObjectUtils.isEmpty(args) || args.length==0 || StringUtils.isEmpty(action)) if(ObjectUtils.isEmpty(args) || args.length==0 || StringUtils.isEmpty(action)) {
return; return;
}
EvaluationContext exServiceCtx = new StandardEvaluationContext(); EvaluationContext exServiceCtx = new StandardEvaluationContext();
exServiceCtx.setVariable("service",service); exServiceCtx.setVariable("service", service);
Expression esServiceExp = parser.parseExpression("#service.getESService()"); Expression esServiceExp = parser.parseExpression("#service.getESService()");
Object exService=esServiceExp.getValue(exServiceCtx); Object exService=esServiceExp.getValue(exServiceCtx);
if(ObjectUtils.isEmpty(exService)){ if(ObjectUtils.isEmpty(exService)) {
log.error("获取[{}]实体全文检索服务对象失败",deName); log.error("获取[{}]实体全文检索服务对象失败",deName);
return; return;
} }
Object arg=args[0]; Object arg=args[0];
if ("remove".equals(action) || "removeBatch".equals(action)){ if ("remove".equals(action) || "removeBatch".equals(action)) {
executeESMethod(exService,action,arg); executeESMethod(exService, action, arg);
} }
else if(arg instanceof EntityBase || arg instanceof List){ else if(arg instanceof EntityBase || arg instanceof List) {
EvaluationContext exMappingCtx = new StandardEvaluationContext(); EvaluationContext exMappingCtx = new StandardEvaluationContext();
exMappingCtx.setVariable("service",service); exMappingCtx.setVariable("service", service);
Expression esMappingExp = parser.parseExpression("#service.getESMapping()"); Expression esMappingExp = parser.parseExpression("#service.getESMapping()");
Object exMapping=esMappingExp.getValue(exMappingCtx); Object exMapping=esMappingExp.getValue(exMappingCtx);
if(ObjectUtils.isEmpty(exMapping)){ if(ObjectUtils.isEmpty(exMapping)) {
log.error("获取[{}]实体全文检索映射对象失败",deName); log.error("获取[{}]实体全文检索映射对象失败", deName);
return; return;
} }
EvaluationContext exDomainCtx = new StandardEvaluationContext(); EvaluationContext exDomainCtx = new StandardEvaluationContext();
exDomainCtx.setVariable("mapping",exMapping); exDomainCtx.setVariable("mapping", exMapping);
exDomainCtx.setVariable("arg",arg); exDomainCtx.setVariable("arg", arg);
Expression esDomainExp = parser.parseExpression("#mapping.toESDomain(#arg)"); Expression esDomainExp = parser.parseExpression("#mapping.toESDomain(#arg)");
arg=esDomainExp.getValue(exDomainCtx); arg=esDomainExp.getValue(exDomainCtx);
executeESMethod(exService,action,arg); executeESMethod(exService, action, arg);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("同步[{}]实体全文检索数据失败,{}",deName,e); log.error("同步[{}]实体全文检索数据失败,{}", deName, e);
} }
} }
...@@ -103,11 +104,11 @@ public class ESAspect ...@@ -103,11 +104,11 @@ public class ESAspect
* @param action * @param action
* @param arg * @param arg
*/ */
private void executeESMethod(Object exService,Object action,Object arg){ private void executeESMethod(Object exService, Object action, Object arg) {
EvaluationContext esContext = new StandardEvaluationContext(); EvaluationContext esContext = new StandardEvaluationContext();
esContext.setVariable("exService",exService); esContext.setVariable("exService", exService);
esContext.setVariable("arg",arg); esContext.setVariable("arg", arg);
Expression exExp = parser.parseExpression(String.format("#exService.%s(#arg)",action)); Expression exExp = parser.parseExpression(String.format("#exService.%s(#arg)", action));
exExp.getValue(esContext); exExp.getValue(esContext);
} }
} }
......
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#assign hasMQEntity=false>
<#list sys.getAllPSDataEntities() as dataEntity>
<#if dataEntity.getAllPSDEDataSyncs?? && dataEntity.getAllPSDEDataSyncs()??>
<#list dataEntity.getAllPSDEDataSyncs() as dataSync>
<#if dataSync.getOutPSSysDataSyncAgent?? && dataSync.getOutPSSysDataSyncAgent()??>
<#assign hasMQEntity=true>
<#break>
</#if>
</#list>
</#if>
</#list>
<#if hasMQEntity>
package ${pub.getPKGCodeName()}.util.aspect;
import com.alibaba.fastjson.JSON;
import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
import com.alibaba.rocketmq.common.message.Message;
import lombok.extern.slf4j.Slf4j;
import ${pub.getPKGCodeName()}.util.domain.EntityBase;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.util.List;
/**
* rocketMQ消息切面
*/
@Aspect
@Component
@Slf4j
public class RocketMQAspect
{
private final ExpressionParser parser = new SpelExpressionParser();
<#list sys.getAllPSDataEntities() as dataEntity>
<#if dataEntity.getAllPSDEDataSyncs?? && dataEntity.getAllPSDEDataSyncs()??>
<#list dataEntity.getAllPSDEDataSyncs() as dataSync>
<#if dataSync.getOutPSSysDataSyncAgent?? && dataSync.getOutPSSysDataSyncAgent()??>
<#assign syncAgent=dataSync.getOutPSSysDataSyncAgent()>
<#assign producer=dataEntity.codeName+syncAgent.codeName+"producer">
@Autowired
@Qualifier("${producer}")
@Lazy
DefaultMQProducer ${producer};
@AfterReturning(value = "(execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.create*(..))||execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.update*(..))||execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.save*(..)) ||execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.remove*(..))) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.create*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.update*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.save*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.remove*(..))")
@Async
public void ${srfmethodname(producer)}(JoinPoint point) {
<#if dataSync.getOutTestPSDEAction?? && dataSync.getOutTestPSDEAction()??>
<#assign actionName=srfmethodname(dataSync.getOutTestPSDEAction().codeName)>
outputAction(point, "${actionName}");
</#if>
sendMsg(${producer}, "${dataSync.codeName}", "${dataSync.codeName}", getEntity(point));
}
</#if>
</#list>
</#if>
</#list>
/**
* 输出过滤行为
* @param point
* @param actionName
*/
private void outputAction(JoinPoint point,String actionName) {
Object [] args = point.getArgs();
if(ObjectUtils.isEmpty(args) || args.length==0) {
return;
}
Object arg = args[0];
Object service = point.getTarget();
EvaluationContext serviceCtx = new StandardEvaluationContext();
serviceCtx.setVariable("service", service);
serviceCtx.setVariable("arg", arg);
Expression serviceExp = parser.parseExpression(String.format("#service.%s(#arg)", actionName));
serviceExp.getValue(serviceCtx);
}
/**
* 获取实体对象
* @param point
* @return
*/
private Object getEntity(JoinPoint point) {
Object entity=null;
String action=point.getSignature().getName();
Object [] args = point.getArgs();
if(ObjectUtils.isEmpty(args) || args.length==0 || StringUtils.isEmpty(action)) {
return entity;
}
Object arg=args[0];
if(arg instanceof EntityBase || arg instanceof List) {
return arg;
}
else {
return null;
}
}
/**
* 发送消息
* @param producer
* @param topic
* @param tag
* @param body
*/
private void sendMsg(DefaultMQProducer producer, String topic, String tag, Object body) {
if(ObjectUtils.isEmpty(body)) {
log.error("发送消息失败,无法获取到要发送的消息内容!");
return;
}
try {
producer.start();
Message message = new Message(topic, tag, JSON.toJSONString(body).getBytes());
producer.send(message);
producer.shutdown();
} catch (Exception e) {
log.error("消息发送异常,"+e);
}
}
}
</#if>
\ No newline at end of file
...@@ -35,55 +35,62 @@ import java.util.Map; ...@@ -35,55 +35,62 @@ import java.util.Map;
public class VersionCheckAspect public class VersionCheckAspect
{ {
private final ExpressionParser parser = new SpelExpressionParser(); private final ExpressionParser parser = new SpelExpressionParser();
private final String IgnoreField="ignoreversioncheck"; private final String IgnoreField = "ignoreversioncheck";
@SneakyThrows @SneakyThrows
@Before("execution(* ${pub.getPKGCodeName()}.*.rest.*.update(..)) && @annotation(versionCheck)") @Before("execution(* ${pub.getPKGCodeName()}.*.rest.*.update(..)) && @annotation(versionCheck)")
public void BeforeUpdate(JoinPoint point, VersionCheck versionCheck){ public void BeforeUpdate(JoinPoint point, VersionCheck versionCheck) {
Object[] args = point.getArgs(); Object[] args = point.getArgs();
Object id=args[0]; Object id = args[0];
Object dto=args[1]; Object dto = args[1];
if(ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(dto)) if(ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(dto)) {
return; return;
String versionField=versionCheck.versionfield(); }
if(StringUtils.isEmpty(versionField)) String versionField = versionCheck.versionfield();
if(StringUtils.isEmpty(versionField)) {
return; return;
versionCheck(versionCheck,point.getTarget(),dto,id); }
versionCheck(versionCheck,point.getTarget(), dto, id);
} }
@SneakyThrows @SneakyThrows
@Before("execution(* ${pub.getPKGCodeName()}.*.rest.*.updateBy*(..)) && @annotation(versionCheck)") @Before("execution(* ${pub.getPKGCodeName()}.*.rest.*.updateBy*(..)) && @annotation(versionCheck)")
public void BeforeUpdateBy(JoinPoint point, VersionCheck versionCheck){ public void BeforeUpdateBy(JoinPoint point, VersionCheck versionCheck) {
Object[] args = point.getArgs(); Object[] args = point.getArgs();
if(args.length>=2){ if(args.length>=2) {
Object id=args[args.length-2]; Object id = args[args.length-2];
Object dto=args[args.length-1]; Object dto = args[args.length-1];
if(ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(dto)) if(ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(dto)) {
return; return;
String versionField=versionCheck.versionfield(); }
if(StringUtils.isEmpty(versionField)) String versionField = versionCheck.versionfield();
if(StringUtils.isEmpty(versionField)) {
return; return;
versionCheck(versionCheck,point.getTarget(),dto,id); }
versionCheck(versionCheck, point.getTarget(), dto, id);
} }
} }
private void versionCheck(VersionCheck versionCheck,Object resource,Object dto,Object id ){ private void versionCheck(VersionCheck versionCheck, Object resource, Object dto, Object id) {
EvaluationContext context = new StandardEvaluationContext(); EvaluationContext context = new StandardEvaluationContext();
context.setVariable("dto",dto); context.setVariable("dto", dto);
//忽略版本检查 //忽略版本检查
Expression dtoParamsExp = parser.parseExpression("#dto.extensionparams"); Expression dtoParamsExp = parser.parseExpression("#dto.extensionparams");
Map dtoParam=dtoParamsExp.getValue(context, Map.class); Map dtoParam = dtoParamsExp.getValue(context, Map.class);
if(!ObjectUtils.isEmpty(dtoParam) && !ObjectUtils.isEmpty(dtoParam.get(IgnoreField)) && dtoParam.get(IgnoreField).equals(1)) if(!ObjectUtils.isEmpty(dtoParam) && !ObjectUtils.isEmpty(dtoParam.get(IgnoreField)) && dtoParam.get(IgnoreField).equals(1)) {
return; return;
Expression newExp = parser.parseExpression(String.format("#dto.%s",versionCheck.versionfield())); }
Object newVersion=newExp.getValue(context); Expression newExp = parser.parseExpression(String.format("#dto.%s", versionCheck.versionfield()));
if(ObjectUtils.isEmpty(newVersion)) Object newVersion = newExp.getValue(context);
if(ObjectUtils.isEmpty(newVersion)) {
return; return;
}
//进行版本检查 //进行版本检查
Object oldVersion =getDBVersion(versionCheck,getService(resource,versionCheck.entity()),id); Object oldVersion = getDBVersion(versionCheck,getService(resource, versionCheck.entity()), id);
if(!ObjectUtils.isEmpty(oldVersion)){ if(!ObjectUtils.isEmpty(oldVersion)) {
if(RuleUtils.gt(newVersion,oldVersion)) if(RuleUtils.gt(newVersion, oldVersion)) {
throw new BadRequestAlertException("数据已变更,可能后台数据已被修改,请重新加载数据","VersionCheckAspect","versionCheck"); throw new BadRequestAlertException("数据已变更,可能后台数据已被修改,请重新加载数据", "VersionCheckAspect", "versionCheck");
}
} }
} }
...@@ -94,12 +101,12 @@ public class VersionCheckAspect ...@@ -94,12 +101,12 @@ public class VersionCheckAspect
* @return * @return
*/ */
@SneakyThrows @SneakyThrows
private Object getService(Object resource,String entity){ private Object getService(Object resource, String entity) {
Object service = null; Object service = null;
Field[] fields= resource.getClass().getDeclaredFields(); Field[] fields = resource.getClass().getDeclaredFields();
for(Field field : fields){ for(Field field : fields) {
if(field.getModifiers()==1 && field.getName().equalsIgnoreCase(String.format("%sService",entity))){ if(field.getModifiers()==1 && field.getName().equalsIgnoreCase(String.format("%sService",entity))) {
service=field.get(resource); service = field.get(resource);
break; break;
} }
} }
...@@ -114,21 +121,21 @@ public class VersionCheckAspect ...@@ -114,21 +121,21 @@ public class VersionCheckAspect
* @return * @return
*/ */
@SneakyThrows @SneakyThrows
private Object getDBVersion(VersionCheck versionCheck,Object service,Object id){ private Object getDBVersion(VersionCheck versionCheck, Object service, Object id) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Timestamp dbVersion=null; Timestamp dbVersion = null;
String versionField=versionCheck.versionfield(); String versionField = versionCheck.versionfield();
if(!ObjectUtils.isEmpty(service)){ if(!ObjectUtils.isEmpty(service)) {
EvaluationContext oldContext = new StandardEvaluationContext(); EvaluationContext oldContext = new StandardEvaluationContext();
oldContext.setVariable("service",service); oldContext.setVariable("service", service);
oldContext.setVariable("id",id); oldContext.setVariable("id", id);
Expression oldExp = parser.parseExpression("#service.get(#id)"); Expression oldExp = parser.parseExpression("#service.get(#id)");
EntityBase oldEntity =oldExp.getValue(oldContext, EntityBase.class); EntityBase oldEntity = oldExp.getValue(oldContext, EntityBase.class);
Object oldDate=oldEntity.get(versionField); Object oldDate = oldEntity.get(versionField);
if(oldDate!=null && oldDate instanceof Timestamp){ if(oldDate!=null && oldDate instanceof Timestamp) {
Timestamp db_time= (Timestamp) oldDate; Timestamp db_time = (Timestamp) oldDate;
Date db_date = sdf.parse(sdf.format(db_time)); Date db_date = sdf.parse(sdf.format(db_time));
dbVersion=new Timestamp(db_date.getTime()); dbVersion = new Timestamp(db_date.getTime());
} }
} }
return dbVersion; return dbVersion;
......
...@@ -3,16 +3,20 @@ TARGET=PSSYSTEM ...@@ -3,16 +3,20 @@ TARGET=PSSYSTEM
</#ibiztemplate> </#ibiztemplate>
package ${pub.getPKGCodeName()}.util.domain; package ${pub.getPKGCodeName()}.util.domain;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.alibaba.fastjson.annotation.JSONField; import lombok.Data;
import ${pub.getPKGCodeName()}.util.helper.DEFieldCacheMap;
import org.springframework.cglib.beans.BeanMap;
import org.springframework.data.annotation.Transient;
import org.springframework.util.StringUtils;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import lombok.Data;
@Data @Data
public class DTOBase implements Serializable { public class DTOBase implements Serializable {
...@@ -24,33 +28,39 @@ public class DTOBase implements Serializable { ...@@ -24,33 +28,39 @@ public class DTOBase implements Serializable {
public void modify(String field,Object val) { public void modify(String field,Object val) {
if(val==null) if(val==null) {
this.getFocusNull(true).add(field.toLowerCase()); this.getFocusNull(true).add(field.toLowerCase());
else }
else {
this.getFocusNull(true).remove(field.toLowerCase()); this.getFocusNull(true).remove(field.toLowerCase());
}
} }
public Set<String> getFocusNull() { public Set<String> getFocusNull() {
if(focusNull==null) if(focusNull==null) {
focusNull=new HashSet<>(); focusNull=new HashSet<>();
}
if(focusNull.size()>0 && extensionparams.containsKey("dirtyflagenable")) if(focusNull.size()>0 && extensionparams.containsKey("dirtyflagenable"))
{ {
Set<String> nocheck=new HashSet<>(); Set<String> nocheck=new HashSet<>();
for(String key:focusNull) for(String key:focusNull)
{ {
if(!extensionparams.containsKey(key+"dirtyflag")) if(!extensionparams.containsKey(key+"dirtyflag")) {
nocheck.add(key); nocheck.add(key);
}
} }
for(String key:nocheck) for(String key:nocheck) {
focusNull.remove(key); focusNull.remove(key);
}
} }
return focusNull; return focusNull;
} }
private Set<String> getFocusNull(boolean newflag) { private Set<String> getFocusNull(boolean newflag) {
if(focusNull==null) if(focusNull==null) {
focusNull=new HashSet<>(); focusNull=new HashSet<>();
}
return focusNull; return focusNull;
} }
...@@ -70,9 +80,44 @@ public class DTOBase implements Serializable { ...@@ -70,9 +80,44 @@ public class DTOBase implements Serializable {
return extensionparams; return extensionparams;
} }
@JsonIgnore
@JSONField(serialize = false)
@Transient
private BeanMap map;
private BeanMap getMap()
{
if(map==null) {
map=BeanMap.create(this);
}
return map;
}
public Object get(String field) {
String fieldRealName= DEFieldCacheMap.getFieldRealName(this.getClass(),field);
if(!StringUtils.isEmpty(fieldRealName)) {
return getMap().get(fieldRealName);
}
else {
return this.extensionparams.get(field.toLowerCase());
}
}
@JsonAnySetter @JsonAnySetter
public void set(String name, Object value) { public void set(String field, Object value) {
extensionparams.put(name.toLowerCase(), value); field=field.toLowerCase();
String fieldRealName=DEFieldCacheMap.getFieldRealName(this.getClass(),field);
if(!StringUtils.isEmpty(fieldRealName)) {
if (value == null) {
getMap().put(fieldRealName, null);
}
else {
getMap().put(fieldRealName, DEFieldCacheMap.fieldValueOf(this.getClass(), fieldRealName, value));
}
}
else {
this.extensionparams.put(field.toLowerCase(),value);
}
} }
} }
...@@ -27,8 +27,9 @@ public class EntityBase implements Serializable { ...@@ -27,8 +27,9 @@ public class EntityBase implements Serializable {
private Set<String> focusNull; private Set<String> focusNull;
public Set<String> getFocusNull() { public Set<String> getFocusNull() {
if(focusNull==null) if(focusNull==null) {
focusNull=new HashSet<>(); focusNull=new HashSet<>();
}
return focusNull; return focusNull;
} }
...@@ -53,8 +54,9 @@ public class EntityBase implements Serializable { ...@@ -53,8 +54,9 @@ public class EntityBase implements Serializable {
private BeanMap getMap() private BeanMap getMap()
{ {
if(map==null) if(map==null) {
map=BeanMap.create(this); map=BeanMap.create(this);
}
return map; return map;
} }
...@@ -71,17 +73,16 @@ public class EntityBase implements Serializable { ...@@ -71,17 +73,16 @@ public class EntityBase implements Serializable {
this.extensionparams = extensionparams; this.extensionparams = extensionparams;
} }
public Object get(String field) { public Object get(String field) {
String fieldRealName=DEFieldCacheMap.getFieldRealName(this.getClass(),field); String fieldRealName=DEFieldCacheMap.getFieldRealName(this.getClass(),field);
if(!StringUtils.isEmpty(fieldRealName)) if(!StringUtils.isEmpty(fieldRealName)) {
return getMap().get(fieldRealName); return getMap().get(fieldRealName);
else }
else {
return this.extensionparams.get(field.toLowerCase()); return this.extensionparams.get(field.toLowerCase());
}
} }
@JsonAnyGetter @JsonAnyGetter
public Map<String , Object> any() { public Map<String , Object> any() {
return extensionparams; return extensionparams;
...@@ -92,13 +93,16 @@ public class EntityBase implements Serializable { ...@@ -92,13 +93,16 @@ public class EntityBase implements Serializable {
field=field.toLowerCase(); field=field.toLowerCase();
String fieldRealName=DEFieldCacheMap.getFieldRealName(this.getClass(),field); String fieldRealName=DEFieldCacheMap.getFieldRealName(this.getClass(),field);
if(!StringUtils.isEmpty(fieldRealName)) { if(!StringUtils.isEmpty(fieldRealName)) {
if (value == null) if (value == null) {
getMap().put(fieldRealName, null); getMap().put(fieldRealName, null);
else }
else {
getMap().put(fieldRealName, DEFieldCacheMap.fieldValueOf(this.getClass(), fieldRealName, value)); getMap().put(fieldRealName, DEFieldCacheMap.fieldValueOf(this.getClass(), fieldRealName, value));
}
} }
else else {
this.extensionparams.put(field.toLowerCase(),value); this.extensionparams.put(field.toLowerCase(),value);
}
} }
/** /**
......
...@@ -8,24 +8,25 @@ import org.springframework.util.StringUtils; ...@@ -8,24 +8,25 @@ import org.springframework.util.StringUtils;
public class EntityMP extends EntityBase { public class EntityMP extends EntityBase {
public UpdateWrapper getUpdateWrapper(boolean clean) { public UpdateWrapper getUpdateWrapper(boolean clean) {
UpdateWrapper wrapper=new UpdateWrapper(); UpdateWrapper wrapper=new UpdateWrapper();
for(String nullField:getFocusNull()) { for(String nullField:getFocusNull()) {
wrapper.set(nullField,null); wrapper.set(nullField,null);
} }
if(clean) if(clean) {
getFocusNull().clear(); getFocusNull().clear();
}
return wrapper; return wrapper;
} }
@Override @Override
public void modify(String field,Object val) { public void modify(String field,Object val) {
if(val==null) if(val==null) {
this.getFocusNull().add(field.toLowerCase()); this.getFocusNull().add(field.toLowerCase());
else }
else {
this.getFocusNull().remove(field.toLowerCase()); this.getFocusNull().remove(field.toLowerCase());
}
} }
@Override @Override
...@@ -36,6 +37,5 @@ public class EntityMP extends EntityBase { ...@@ -36,6 +37,5 @@ public class EntityMP extends EntityBase {
getFocusNull().remove(resetField); getFocusNull().remove(resetField);
} }
} }
} }
...@@ -5,7 +5,5 @@ package ${pub.getPKGCodeName()}.util.domain; ...@@ -5,7 +5,5 @@ package ${pub.getPKGCodeName()}.util.domain;
public class EntityMongo extends EntityBase { public class EntityMongo extends EntityBase {
} }
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#if sys.codeName == 'Sample'>
package ${pub.getPKGCodeName()}.util.domain;
import lombok.Data;
/**
* 属性值规则实体对象
*/
@Data
public class ValueRule {
public String cond;
public String message;
public ValueRule(String cond, String message) {
this.cond = cond;
this.message = message;
}
}
</#if>
\ No newline at end of file
...@@ -47,9 +47,9 @@ public class QueryBuildContext extends SearchContextBase implements ISearchConte ...@@ -47,9 +47,9 @@ public class QueryBuildContext extends SearchContextBase implements ISearchConte
*/ */
private QueryBuilder parseQueryFilter(QueryFilter queryFilter){ private QueryBuilder parseQueryFilter(QueryFilter queryFilter){
if( ObjectUtils.isEmpty(queryFilter.get$and()) && ObjectUtils.isEmpty(queryFilter.get$or()) && ObjectUtils.isEmpty(queryFilter.any())) if(ObjectUtils.isEmpty(queryFilter.get$and()) && ObjectUtils.isEmpty(queryFilter.get$or()) && ObjectUtils.isEmpty(queryFilter.any())) {
return null; return null;
}
QueryBuilder rsBuilder=QueryBuilder.start(); QueryBuilder rsBuilder=QueryBuilder.start();
QueryBuilder fieldBuilder=parseFieldMap(queryFilter.any()); QueryBuilder fieldBuilder=parseFieldMap(queryFilter.any());
QueryBuilder orBuilder=parseOrQueryFilter(queryFilter.get$or()); QueryBuilder orBuilder=parseOrQueryFilter(queryFilter.get$or());
...@@ -110,8 +110,9 @@ public class QueryBuildContext extends SearchContextBase implements ISearchConte ...@@ -110,8 +110,9 @@ public class QueryBuildContext extends SearchContextBase implements ISearchConte
* @return * @return
*/ */
private QueryBuilder parseFieldMap(Map<String , QueryFilter.SegmentCond> fieldMap) { private QueryBuilder parseFieldMap(Map<String , QueryFilter.SegmentCond> fieldMap) {
if(fieldMap.size()==0) if(fieldMap.size()==0) {
return null; return null;
}
QueryBuilder fieldBuilders=QueryBuilder.start(); QueryBuilder fieldBuilders=QueryBuilder.start();
for(Map.Entry<String, QueryFilter.SegmentCond> entry: fieldMap.entrySet()){ for(Map.Entry<String, QueryFilter.SegmentCond> entry: fieldMap.entrySet()){
getSegmentCondSql(entry.getKey(),entry.getValue(),fieldBuilders); getSegmentCondSql(entry.getKey(),entry.getValue(),fieldBuilders);
......
...@@ -66,8 +66,9 @@ public class QueryFilter { ...@@ -66,8 +66,9 @@ public class QueryFilter {
private Map<String,SegmentCond> getMap() private Map<String,SegmentCond> getMap()
{ {
if(map==null) if(map==null) {
map=new LinkedHashMap<>(); map=new LinkedHashMap<>();
}
return map; return map;
} }
...@@ -135,11 +136,12 @@ public class QueryFilter { ...@@ -135,11 +136,12 @@ public class QueryFilter {
} }
private QueryFilter op(String column, SegmentCond segmentCond) { private QueryFilter op(String column, SegmentCond segmentCond) {
if(this.getMap().containsKey(column)) {
if(this.getMap().containsKey(column))
((SegmentCond)this.getMap().get(column)).getMap().putAll(segmentCond.getMap()); ((SegmentCond)this.getMap().get(column)).getMap().putAll(segmentCond.getMap());
else }
else {
this.getMap().put(column,segmentCond); this.getMap().put(column,segmentCond);
}
return this; return this;
} }
...@@ -158,8 +160,9 @@ public class QueryFilter { ...@@ -158,8 +160,9 @@ public class QueryFilter {
private Map<String,Object> getMap() private Map<String,Object> getMap()
{ {
if(map==null) if(map==null) {
map=new LinkedHashMap<>(); map=new LinkedHashMap<>();
}
return map; return map;
} }
......
...@@ -40,17 +40,20 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch ...@@ -40,17 +40,20 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
int pageSize=getPageable().getPageSize(); int pageSize=getPageable().getPageSize();
//构造mybatis-plus分页 //构造mybatis-plus分页
if(StringUtils.isEmpty(currentPage) || StringUtils.isEmpty(pageSize)) if(StringUtils.isEmpty(currentPage) || StringUtils.isEmpty(pageSize)) {
page=new Page(1,Short.MAX_VALUE); page=new Page(1,Short.MAX_VALUE);
else }
else {
page=new Page(currentPage+1,pageSize); page=new Page(currentPage+1,pageSize);
}
//构造mybatis-plus排序 //构造mybatis-plus排序
Sort sort = getPageable().getSort(); Sort sort = getPageable().getSort();
Iterator<Sort.Order> it_sort = sort.iterator(); Iterator<Sort.Order> it_sort = sort.iterator();
if(ObjectUtils.isEmpty(it_sort)) if(ObjectUtils.isEmpty(it_sort)) {
return page; return page;
}
ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass(); ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
Class<T> type = (Class<T>)parameterizedType.getActualTypeArguments()[0]; Class<T> type = (Class<T>)parameterizedType.getActualTypeArguments()[0];
...@@ -98,9 +101,9 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch ...@@ -98,9 +101,9 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
* @return * @return
*/ */
private Consumer<QueryWrapper<T>> parseQueryFilter(QueryFilter queryFilter){ private Consumer<QueryWrapper<T>> parseQueryFilter(QueryFilter queryFilter){
if(queryFilter.any().size()==0 && queryFilter.get$or()==null && queryFilter.get$and()==null) {
if(queryFilter.any().size()==0 && queryFilter.get$or()==null && queryFilter.get$and()==null) return null;
return null; }
Consumer<QueryWrapper<T>> consumer = queryWrapper -> { Consumer<QueryWrapper<T>> consumer = queryWrapper -> {
Consumer fieldConsumer=parseFieldMap(queryFilter.any()); Consumer fieldConsumer=parseFieldMap(queryFilter.any());
Consumer orConsumer=parseOrQueryFilter(queryFilter.get$or()); Consumer orConsumer=parseOrQueryFilter(queryFilter.get$or());
...@@ -124,7 +127,6 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch ...@@ -124,7 +127,6 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
* @return * @return
*/ */
private Consumer<QueryWrapper<T>> parseOrQueryFilter(List<QueryFilter> queryFilters) { private Consumer<QueryWrapper<T>> parseOrQueryFilter(List<QueryFilter> queryFilters) {
if(queryFilters==null || queryFilters.size()==0) if(queryFilters==null || queryFilters.size()==0)
return null; return null;
Consumer<QueryWrapper<T>> consumer = queryWrapper -> { Consumer<QueryWrapper<T>> consumer = queryWrapper -> {
...@@ -142,10 +144,10 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch ...@@ -142,10 +144,10 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
* @return * @return
*/ */
private Consumer<QueryWrapper<T>> parseAndQueryFilter(List<QueryFilter> queryFilters) { private Consumer<QueryWrapper<T>> parseAndQueryFilter(List<QueryFilter> queryFilters) {
if(queryFilters==null || queryFilters.size()==0) {
if(queryFilters==null || queryFilters.size()==0)
return null; return null;
Consumer<QueryWrapper<T>> consumer = queryWrapper -> { }
Consumer<QueryWrapper<T>> consumer = queryWrapper -> {
for(QueryFilter queryFilter: queryFilters){ for(QueryFilter queryFilter: queryFilters){
Consumer tempQueryWrapper=parseQueryFilter(queryFilter); Consumer tempQueryWrapper=parseQueryFilter(queryFilter);
queryWrapper.and(tempQueryWrapper); queryWrapper.and(tempQueryWrapper);
...@@ -160,9 +162,9 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch ...@@ -160,9 +162,9 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
* @return * @return
*/ */
private Consumer<QueryWrapper<T>> parseFieldMap(Map<String , QueryFilter.SegmentCond> fieldMap) { private Consumer<QueryWrapper<T>> parseFieldMap(Map<String , QueryFilter.SegmentCond> fieldMap) {
if(fieldMap.size()==0) {
if(fieldMap.size()==0)
return null; return null;
}
Consumer<QueryWrapper<T>> consumer = queryWrapper -> { Consumer<QueryWrapper<T>> consumer = queryWrapper -> {
for(Map.Entry<String, QueryFilter.SegmentCond> field: fieldMap.entrySet()){ for(Map.Entry<String, QueryFilter.SegmentCond> field: fieldMap.entrySet()){
String fieldName=field.getKey(); String fieldName=field.getKey();
......
...@@ -117,10 +117,12 @@ public class SearchContextBase implements ISearchContext{ ...@@ -117,10 +117,12 @@ public class SearchContextBase implements ISearchContext{
* @return * @return
*/ */
public Pageable getPageable() { public Pageable getPageable() {
if(ObjectUtils.isEmpty(pageSort)) if(ObjectUtils.isEmpty(pageSort)) {
return PageRequest.of(page,size); return PageRequest.of(page,size);
else }
return PageRequest.of(page,size,pageSort); else {
return PageRequest.of(page,size,pageSort);
}
} }
/** /**
......
...@@ -16,8 +16,9 @@ public class CachedBeanCopier { ...@@ -16,8 +16,9 @@ public class CachedBeanCopier {
} }
public static void copy(Object srcObj, Object destObj,boolean useConverter) { public static void copy(Object srcObj, Object destObj,boolean useConverter) {
if(srcObj==null||destObj==null) if(srcObj==null||destObj==null) {
return; return;
}
getCopier(srcObj,destObj,useConverter).copy(srcObj, destObj, null); getCopier(srcObj,destObj,useConverter).copy(srcObj, destObj, null);
} }
...@@ -32,6 +33,4 @@ public class CachedBeanCopier { ...@@ -32,6 +33,4 @@ public class CachedBeanCopier {
} }
return copier; return copier;
} }
} }
...@@ -39,13 +39,16 @@ public class DEFieldCacheMap { ...@@ -39,13 +39,16 @@ public class DEFieldCacheMap {
*/ */
public static <T> Hashtable<String,Field> getFieldMap(Class<T> clazz) { public static <T> Hashtable<String,Field> getFieldMap(Class<T> clazz) {
String className=clazz.getName(); String className=clazz.getName();
if(className.indexOf("_$")>0) if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$")); className=className.substring(0, className.lastIndexOf("_$"));
if(cacheMap.containsKey(className)) }
return cacheMap.get(className); if(cacheMap.containsKey(className)) {
return cacheMap.get(className);
}
synchronized (objLock1) { synchronized (objLock1) {
if(cacheMap.containsKey(className)) if(cacheMap.containsKey(className)) {
return cacheMap.get(className); return cacheMap.get(className);
}
Hashtable<String,Field> result = new Hashtable<String,Field>(); Hashtable<String,Field> result = new Hashtable<String,Field>();
List<Field> list=new ArrayList<Field>(); List<Field> list=new ArrayList<Field>();
Hashtable<String,String> keys=new Hashtable<String,String>(); Hashtable<String,String> keys=new Hashtable<String,String>();
...@@ -61,8 +64,9 @@ public class DEFieldCacheMap { ...@@ -61,8 +64,9 @@ public class DEFieldCacheMap {
Audit auditField=field.getAnnotation(Audit.class); Audit auditField=field.getAnnotation(Audit.class);
if(!ObjectUtils.isEmpty(deField)) { if(!ObjectUtils.isEmpty(deField)) {
defields.put(field.getName(),deField); defields.put(field.getName(),deField);
if(deField.isKeyField()) if(deField.isKeyField()) {
cacheDEKeyField.put(className,field.getName()); cacheDEKeyField.put(className,field.getName());
}
} }
if(!ObjectUtils.isEmpty(auditField)) { if(!ObjectUtils.isEmpty(auditField)) {
auditfields.put(field.getName(),auditField); auditfields.put(field.getName(),auditField);
...@@ -77,10 +81,12 @@ public class DEFieldCacheMap { ...@@ -77,10 +81,12 @@ public class DEFieldCacheMap {
} }
} }
public static Hashtable<String,Field> getFieldMap(String className) { public static Hashtable<String,Field> getFieldMap(String className) {
if(className.indexOf("_$")>0) if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$")); className=className.substring(0, className.lastIndexOf("_$"));
if(cacheMap.containsKey(className)) }
return cacheMap.get(className); if(cacheMap.containsKey(className)) {
return cacheMap.get(className);
}
Class clazz = null; Class clazz = null;
try { try {
clazz = Class.forName(className); clazz = Class.forName(className);
...@@ -99,10 +105,12 @@ public class DEFieldCacheMap { ...@@ -99,10 +105,12 @@ public class DEFieldCacheMap {
*/ */
public static <T> Hashtable<String,DEField> getDEFields(Class<T> clazz) { public static <T> Hashtable<String,DEField> getDEFields(Class<T> clazz) {
String className=clazz.getName(); String className=clazz.getName();
if(className.indexOf("_$")>0) if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$")); className=className.substring(0, className.lastIndexOf("_$"));
if(cacheDEField.containsKey(className)) }
if(cacheDEField.containsKey(className)) {
return cacheDEField.get(className); return cacheDEField.get(className);
}
else{ else{
DEFieldCacheMap.getFieldMap(className); DEFieldCacheMap.getFieldMap(className);
return cacheDEField.get(className); return cacheDEField.get(className);
...@@ -116,10 +124,12 @@ public class DEFieldCacheMap { ...@@ -116,10 +124,12 @@ public class DEFieldCacheMap {
*/ */
public static <T> Hashtable<String,Audit> getAuditFields(Class<T> clazz) { public static <T> Hashtable<String,Audit> getAuditFields(Class<T> clazz) {
String className=clazz.getName(); String className=clazz.getName();
if(className.indexOf("_$")>0) if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$")); className=className.substring(0, className.lastIndexOf("_$"));
if(cacheAuditField.containsKey(className)) }
if(cacheAuditField.containsKey(className)) {
return cacheAuditField.get(className); return cacheAuditField.get(className);
}
else{ else{
DEFieldCacheMap.getFieldMap(className); DEFieldCacheMap.getFieldMap(className);
return cacheAuditField.get(className); return cacheAuditField.get(className);
...@@ -133,10 +143,12 @@ public class DEFieldCacheMap { ...@@ -133,10 +143,12 @@ public class DEFieldCacheMap {
*/ */
public static <T> String getDEKeyField(Class<T> clazz) { public static <T> String getDEKeyField(Class<T> clazz) {
String className=clazz.getName(); String className=clazz.getName();
if(className.indexOf("_$")>0) if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$")); className=className.substring(0, className.lastIndexOf("_$"));
if(cacheDEKeyField.containsKey(className)) }
if(cacheDEKeyField.containsKey(className)) {
return cacheDEKeyField.get(className); return cacheDEKeyField.get(className);
}
else{ else{
DEFieldCacheMap.getFieldMap(className); DEFieldCacheMap.getFieldMap(className);
return cacheDEKeyField.get(className); return cacheDEKeyField.get(className);
...@@ -151,10 +163,12 @@ public class DEFieldCacheMap { ...@@ -151,10 +163,12 @@ public class DEFieldCacheMap {
*/ */
public static <T> List<Field> getFields(Class<T> clazz) { public static <T> List<Field> getFields(Class<T> clazz) {
String className=clazz.getName(); String className=clazz.getName();
if(className.indexOf("_$")>0) if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$")); className=className.substring(0, className.lastIndexOf("_$"));
if(cacheList.containsKey(className)) }
if(cacheList.containsKey(className)) {
return cacheList.get(className); return cacheList.get(className);
}
else{ else{
DEFieldCacheMap.getFieldMap(className); DEFieldCacheMap.getFieldMap(className);
return cacheList.get(className); return cacheList.get(className);
...@@ -162,10 +176,12 @@ public class DEFieldCacheMap { ...@@ -162,10 +176,12 @@ public class DEFieldCacheMap {
} }
public static List<Field> getFields(String className) { public static List<Field> getFields(String className) {
if(className.indexOf("_$")>0) if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$")); className=className.substring(0, className.lastIndexOf("_$"));
if(cacheList.containsKey(className)) }
if(cacheList.containsKey(className)) {
return cacheList.get(className); return cacheList.get(className);
}
else{ else{
DEFieldCacheMap.getFieldMap(className); DEFieldCacheMap.getFieldMap(className);
return cacheList.get(className); return cacheList.get(className);
...@@ -179,10 +195,12 @@ public class DEFieldCacheMap { ...@@ -179,10 +195,12 @@ public class DEFieldCacheMap {
*/ */
public static <T> Hashtable<String,String> getFieldKeys(Class<T> clazz) { public static <T> Hashtable<String,String> getFieldKeys(Class<T> clazz) {
String className=clazz.getName(); String className=clazz.getName();
if(className.indexOf("_$")>0) if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$")); className=className.substring(0, className.lastIndexOf("_$"));
if(cacheKey.containsKey(className)) }
if(cacheKey.containsKey(className)) {
return cacheKey.get(className); return cacheKey.get(className);
}
else{ else{
DEFieldCacheMap.getFieldMap(className); DEFieldCacheMap.getFieldMap(className);
return cacheKey.get(className); return cacheKey.get(className);
...@@ -192,20 +210,25 @@ public class DEFieldCacheMap { ...@@ -192,20 +210,25 @@ public class DEFieldCacheMap {
public static <T> String getFieldRealName(Class<T> clazz,String fieldname) { public static <T> String getFieldRealName(Class<T> clazz,String fieldname) {
fieldname=fieldname.toLowerCase(); fieldname=fieldname.toLowerCase();
Hashtable<String,String> keys=DEFieldCacheMap.getFieldKeys(clazz); Hashtable<String,String> keys=DEFieldCacheMap.getFieldKeys(clazz);
if(keys.containsKey(fieldname)) if(keys.containsKey(fieldname)) {
return keys.get(fieldname); return keys.get(fieldname);
else if(keys.containsKey(fieldname.replace("_",""))) }
else if(keys.containsKey(fieldname.replace("_",""))) {
return keys.get(fieldname.replace("_","")); return keys.get(fieldname.replace("_",""));
else }
else {
return ""; return "";
}
} }
public static <T> Field getField(Class<T> clazz,String fieldname) { public static <T> Field getField(Class<T> clazz,String fieldname) {
String fieldRealName=DEFieldCacheMap.getFieldRealName(clazz,fieldname); String fieldRealName=DEFieldCacheMap.getFieldRealName(clazz,fieldname);
if(!StringUtils.isEmpty(fieldRealName)) if(!StringUtils.isEmpty(fieldRealName)) {
return DEFieldCacheMap.getFieldMap(clazz).get(fieldRealName); return DEFieldCacheMap.getFieldMap(clazz).get(fieldRealName);
else }
else {
return null; return null;
}
} }
public static <T> String getFieldColumnName(Class<T> clazz,String fieldname) { public static <T> String getFieldColumnName(Class<T> clazz,String fieldname) {
...@@ -229,6 +252,4 @@ public class DEFieldCacheMap { ...@@ -229,6 +252,4 @@ public class DEFieldCacheMap {
} }
return resultValue; return resultValue;
} }
} }
\ No newline at end of file
...@@ -22,30 +22,34 @@ public class DataObject { ...@@ -22,30 +22,34 @@ public class DataObject {
final static public DateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd"); final static public DateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd");
final static public String getStringValue(Object objValue, String strDefault) { final static public String getStringValue(Object objValue, String strDefault) {
if (objValue == null) return strDefault; if (objValue == null) {
if (objValue instanceof String) return (String) objValue; return strDefault;
}
if (objValue instanceof String) {
return (String) objValue;
}
if (objValue instanceof java.sql.Timestamp||objValue instanceof java.sql.Date||objValue instanceof java.util.Date) { if (objValue instanceof java.sql.Timestamp||objValue instanceof java.sql.Date||objValue instanceof java.util.Date) {
String rt=datetimeFormat.format(objValue); String rt=datetimeFormat.format(objValue);
if(rt.endsWith(" 00:00:00")) if(rt.endsWith(" 00:00:00")) {
rt=dayFormat.format(objValue); rt=dayFormat.format(objValue);
else if(rt.endsWith(":00")) }
else if(rt.endsWith(":00")) {
rt=datetimeFormat2.format(objValue); rt=datetimeFormat2.format(objValue);
}
return rt; return rt;
} }
return objValue.toString(); return objValue.toString();
} }
public static <T> Object objectValueOf(Class<T> type,Object fieldValue) { public static <T> Object objectValueOf(Class<T> type,Object fieldValue) {
if(fieldValue==null) if(fieldValue==null) {
return null; return null;
}
Object resultValue=fieldValue; Object resultValue=fieldValue;
String targetType=type.getSimpleName(); String targetType=type.getSimpleName();
if(targetType.equalsIgnoreCase(fieldValue.getClass().getSimpleName())) if(targetType.equalsIgnoreCase(fieldValue.getClass().getSimpleName())){
return resultValue; return resultValue;
}
if(targetType.equals("Boolean")){ if(targetType.equals("Boolean")){
resultValue=getBooleanValue(fieldValue,false); resultValue=getBooleanValue(fieldValue,false);
} }
...@@ -82,10 +86,9 @@ public class DataObject { ...@@ -82,10 +86,9 @@ public class DataObject {
else if(targetType.equals("String")) { else if(targetType.equals("String")) {
resultValue= getStringValue(fieldValue,null); resultValue= getStringValue(fieldValue,null);
} }
if(resultValue==null) {
if(resultValue==null)
return null; return null;
}
return resultValue; return resultValue;
} }
...@@ -98,8 +101,9 @@ public class DataObject { ...@@ -98,8 +101,9 @@ public class DataObject {
if (objValue == null) { if (objValue == null) {
return jDefault; return jDefault;
} }
if(objValue instanceof JSONObject) if(objValue instanceof JSONObject) {
return (JSONObject)objValue; return (JSONObject)objValue;
}
String strValue = objValue.toString(); String strValue = objValue.toString();
try { try {
return JSONObject.parseObject(strValue); return JSONObject.parseObject(strValue);
...@@ -114,8 +118,9 @@ public class DataObject { ...@@ -114,8 +118,9 @@ public class DataObject {
if (objValue == null) { if (objValue == null) {
return jDefault; return jDefault;
} }
if(objValue instanceof JSONArray) if(objValue instanceof JSONArray) {
return (JSONArray)objValue; return (JSONArray)objValue;
}
String strValue = objValue.toString(); String strValue = objValue.toString();
try { try {
return JSONArray.parseArray(strValue); return JSONArray.parseArray(strValue);
...@@ -136,8 +141,9 @@ public class DataObject { ...@@ -136,8 +141,9 @@ public class DataObject {
List<String> chk1=new ArrayList<>(); List<String> chk1=new ArrayList<>();
for(int i=0;i<arr.size();i++) for(int i=0;i<arr.size();i++)
{ {
if(arr.get(i) instanceof String) if(arr.get(i) instanceof String) {
chk1.add(arr.getString(i)); chk1.add(arr.getString(i));
}
} }
return chk1; return chk1;
} }
...@@ -149,8 +155,9 @@ public class DataObject { ...@@ -149,8 +155,9 @@ public class DataObject {
} }
final static public Boolean getBooleanValue(Object objValue,Boolean bDefault) { final static public Boolean getBooleanValue(Object objValue,Boolean bDefault) {
if (objValue == null) return bDefault; if (objValue == null) {
return bDefault;
}
if (objValue instanceof Boolean) { if (objValue instanceof Boolean) {
return (Boolean) objValue; return (Boolean) objValue;
} }
...@@ -158,20 +165,24 @@ public class DataObject { ...@@ -158,20 +165,24 @@ public class DataObject {
} }
final static public char[] getCharacterValue(Object objValue,char[] cDefault) { final static public char[] getCharacterValue(Object objValue,char[] cDefault) {
if (objValue == null) return cDefault; if (objValue == null) {
return cDefault;
}
return objValue.toString().toCharArray(); return objValue.toString().toCharArray();
} }
final static public Double getDoubleValue(Object objValue,Double dDefault) { final static public Double getDoubleValue(Object objValue,Double dDefault) {
if (objValue == null) return dDefault; if (objValue == null) {
return dDefault;
}
if (objValue instanceof Double) { if (objValue instanceof Double) {
return (Double) objValue; return (Double) objValue;
} }
String strValue = objValue.toString(); String strValue = objValue.toString();
if (StringUtils.isEmpty(strValue)) return null; if (StringUtils.isEmpty(strValue)) {
return null;
}
strValue = strValue.replace(",", ""); strValue = strValue.replace(",", "");
return Double.parseDouble(strValue); return Double.parseDouble(strValue);
} }
...@@ -182,8 +193,9 @@ public class DataObject { ...@@ -182,8 +193,9 @@ public class DataObject {
return nDefault; return nDefault;
} }
if(objValue instanceof Integer) if(objValue instanceof Integer) {
return (Integer)objValue; return (Integer)objValue;
}
if (objValue instanceof Double) { if (objValue instanceof Double) {
return ((Double) objValue).intValue(); return ((Double) objValue).intValue();
...@@ -194,8 +206,9 @@ public class DataObject { ...@@ -194,8 +206,9 @@ public class DataObject {
} }
String strValue = objValue.toString(); String strValue = objValue.toString();
if(StringUtils.isEmpty(strValue)) if(StringUtils.isEmpty(strValue)) {
return nDefault; return nDefault;
}
strValue = strValue.replace(",", ""); strValue = strValue.replace(",", "");
return Integer.parseInt(strValue); return Integer.parseInt(strValue);
} }
...@@ -207,12 +220,13 @@ public class DataObject { ...@@ -207,12 +220,13 @@ public class DataObject {
} }
try { try {
if(objValue instanceof Float) if(objValue instanceof Float) {
return (Float)objValue; return (Float)objValue;
}
String strValue = objValue.toString(); String strValue = objValue.toString();
if(StringUtils.isEmpty(strValue)) if(StringUtils.isEmpty(strValue)) {
return fDefault; return fDefault;
}
strValue = strValue.replace(",", ""); strValue = strValue.replace(",", "");
return Float.parseFloat(strValue); return Float.parseFloat(strValue);
} catch (Exception ex) { } catch (Exception ex) {
...@@ -236,8 +250,9 @@ public class DataObject { ...@@ -236,8 +250,9 @@ public class DataObject {
return BigDecimal.valueOf((Long)objValue); return BigDecimal.valueOf((Long)objValue);
} }
String strValue = objValue.toString(); String strValue = objValue.toString();
if(StringUtils.isEmpty(strValue)) if(StringUtils.isEmpty(strValue)) {
return fDefault; return fDefault;
}
strValue = strValue.replace(",", ""); strValue = strValue.replace(",", "");
return BigDecimal.valueOf(Double.parseDouble(strValue)); return BigDecimal.valueOf(Double.parseDouble(strValue));
} catch (Exception ex) { } catch (Exception ex) {
...@@ -256,8 +271,9 @@ public class DataObject { ...@@ -256,8 +271,9 @@ public class DataObject {
} }
else { else {
Long l=getLongValue(objValue,null); Long l=getLongValue(objValue,null);
if(l!=null) if(l!=null) {
return BigInteger.valueOf(l); return BigInteger.valueOf(l);
}
} }
} catch (Exception ex) { } catch (Exception ex) {
...@@ -286,8 +302,9 @@ public class DataObject { ...@@ -286,8 +302,9 @@ public class DataObject {
} }
String strValue = objValue.toString(); String strValue = objValue.toString();
if(StringUtils.isEmpty(strValue)) if(StringUtils.isEmpty(strValue)) {
return nDefault; return nDefault;
}
strValue = strValue.replace(",", ""); strValue = strValue.replace(",", "");
return Long.parseLong(strValue); return Long.parseLong(strValue);
} catch (Exception ex) { } catch (Exception ex) {
...@@ -297,7 +314,9 @@ public class DataObject { ...@@ -297,7 +314,9 @@ public class DataObject {
final static public byte[] getBinaryValue(Object objValue, byte[] def) { final static public byte[] getBinaryValue(Object objValue, byte[] def) {
if (objValue == null) return def; if (objValue == null) {
return def;
}
if(objValue instanceof byte[]){ if(objValue instanceof byte[]){
return (byte[])objValue; return (byte[])objValue;
} }
...@@ -315,7 +334,9 @@ public class DataObject { ...@@ -315,7 +334,9 @@ public class DataObject {
* @ * @
*/ */
final static public java.sql.Timestamp getTimestampValue(Object objValue,java.sql.Timestamp tDefault) { final static public java.sql.Timestamp getTimestampValue(Object objValue,java.sql.Timestamp tDefault) {
if (objValue == null) return tDefault; if (objValue == null) {
return tDefault;
}
if (objValue instanceof java.sql.Timestamp) { if (objValue instanceof java.sql.Timestamp) {
java.sql.Timestamp ti = (java.sql.Timestamp) objValue; java.sql.Timestamp ti = (java.sql.Timestamp) objValue;
...@@ -335,7 +356,9 @@ public class DataObject { ...@@ -335,7 +356,9 @@ public class DataObject {
if (objValue instanceof String) { if (objValue instanceof String) {
String strValue = (String) objValue; String strValue = (String) objValue;
strValue = strValue.trim(); strValue = strValue.trim();
if (StringUtils.isEmpty(strValue)) return null; if (StringUtils.isEmpty(strValue)) {
return null;
}
try { try {
java.util.Date date = parse((String) objValue); java.util.Date date = parse((String) objValue);
...@@ -376,7 +399,9 @@ public class DataObject { ...@@ -376,7 +399,9 @@ public class DataObject {
* @ * @
*/ */
public static Object testDateTime(String strInput, TimeZone timeZone) throws Exception{ public static Object testDateTime(String strInput, TimeZone timeZone) throws Exception{
if (StringUtils.isEmpty(strInput)) return null; if (StringUtils.isEmpty(strInput)) {
return null;
}
Date dtDate = parse(strInput, timeZone); Date dtDate = parse(strInput, timeZone);
java.sql.Timestamp retDate = new java.sql.Timestamp(dtDate.getTime()); java.sql.Timestamp retDate = new java.sql.Timestamp(dtDate.getTime());
return retDate; return retDate;
...@@ -428,8 +453,9 @@ public class DataObject { ...@@ -428,8 +453,9 @@ public class DataObject {
if(strTimeString.indexOf("T")!=-1){ if(strTimeString.indexOf("T")!=-1){
strPart = strTimeString.split("[T]"); strPart = strTimeString.split("[T]");
} }
else else{
strPart = strTimeString.split(" "); strPart = strTimeString.split(" ");
}
if (strPart.length == 2) { if (strPart.length == 2) {
// 两个部分 // 两个部分
String strDate = ""; String strDate = "";
...@@ -592,6 +618,4 @@ public class DataObject { ...@@ -592,6 +618,4 @@ public class DataObject {
return new Timestamp(cl.getTime().getTime()); return new Timestamp(cl.getTime().getTime());
} }
} }
...@@ -21,8 +21,9 @@ public class RuleUtils ...@@ -21,8 +21,9 @@ public class RuleUtils
public static Object getObj(Object object, String members) public static Object getObj(Object object, String members)
{ {
if(object==null) if(object==null) {
return null; return null;
}
Object currentObj = object; Object currentObj = object;
String[] arrayOfString = members.split("\\."); String[] arrayOfString = members.split("\\.");
int i = arrayOfString.length; int i = arrayOfString.length;
...@@ -34,20 +35,23 @@ public class RuleUtils ...@@ -34,20 +35,23 @@ public class RuleUtils
if(currentObj instanceof EntityBase) if(currentObj instanceof EntityBase)
{ {
currentObj=((EntityBase) currentObj).get(methodName); currentObj=((EntityBase) currentObj).get(methodName);
if (currentObj == null) if (currentObj == null) {
return null; return null;
}
} }
else if(currentObj instanceof JSONObject) else if(currentObj instanceof JSONObject)
{ {
currentObj=((JSONObject) currentObj).get(methodName); currentObj=((JSONObject) currentObj).get(methodName);
if (currentObj == null) if (currentObj == null) {
return null; return null;
}
} }
else if(currentObj instanceof Map) else if(currentObj instanceof Map)
{ {
currentObj=((Map) currentObj).get(methodName); currentObj=((Map) currentObj).get(methodName);
if (currentObj == null) if (currentObj == null) {
return null; return null;
}
} }
else else
{ {
...@@ -63,10 +67,10 @@ public class RuleUtils ...@@ -63,10 +67,10 @@ public class RuleUtils
} }
currentObj = method.invoke(currentObj, methodName); currentObj = method.invoke(currentObj, methodName);
if (currentObj == null) if (currentObj == null){
return null; return null;
}
} }
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -80,44 +84,63 @@ public class RuleUtils ...@@ -80,44 +84,63 @@ public class RuleUtils
public static boolean test(Object finalObject,String option,Object exp) public static boolean test(Object finalObject,String option,Object exp)
{ {
if(option.equalsIgnoreCase("eq")||option.equalsIgnoreCase("equal")||option.equalsIgnoreCase("=")) if(option.equalsIgnoreCase("eq")||option.equalsIgnoreCase("equal")||option.equalsIgnoreCase("=")){
return equal(exp,finalObject); return equal(exp,finalObject);
else if (option.equalsIgnoreCase("noteq")||option.equalsIgnoreCase("notequal")||option.equalsIgnoreCase("<>")||option.equalsIgnoreCase("!=")) }
else if (option.equalsIgnoreCase("noteq")||option.equalsIgnoreCase("notequal")||option.equalsIgnoreCase("<>")||option.equalsIgnoreCase("!=")){
return !equal(exp,finalObject); return !equal(exp,finalObject);
else if (option.equalsIgnoreCase("gt")||option.equalsIgnoreCase(">")) }
else if (option.equalsIgnoreCase("gt")||option.equalsIgnoreCase(">")){
return gt(exp,finalObject); return gt(exp,finalObject);
else if (option.equalsIgnoreCase("lt")||option.equalsIgnoreCase("<")) }
else if (option.equalsIgnoreCase("lt")||option.equalsIgnoreCase("<")){
return lt(exp,finalObject); return lt(exp,finalObject);
else if (option.equalsIgnoreCase("gtandeq")||option.equalsIgnoreCase("ge")||option.equalsIgnoreCase(">=")) }
else if (option.equalsIgnoreCase("gtandeq")||option.equalsIgnoreCase("ge")||option.equalsIgnoreCase(">=")){
return ge(exp,finalObject); return ge(exp,finalObject);
else if (option.equalsIgnoreCase("ltandeq")||option.equalsIgnoreCase("le")||option.equalsIgnoreCase("<=")) }
else if (option.equalsIgnoreCase("ltandeq")||option.equalsIgnoreCase("le")||option.equalsIgnoreCase("<=")){
return le(exp,finalObject); return le(exp,finalObject);
else if (option.equalsIgnoreCase("null")||option.equalsIgnoreCase("isnull")) }
else if (option.equalsIgnoreCase("null")||option.equalsIgnoreCase("isnull")){
return isNull(finalObject); return isNull(finalObject);
else if (option.equalsIgnoreCase("notnull")||option.equalsIgnoreCase("isnotnull")) }
else if (option.equalsIgnoreCase("notnull")||option.equalsIgnoreCase("isnotnull")){
return isNotNull(finalObject); return isNotNull(finalObject);
else if (option.equalsIgnoreCase("like")||option.equalsIgnoreCase("matchor")) }
else if (option.equalsIgnoreCase("like")||option.equalsIgnoreCase("matchor")){
return matchor(exp,finalObject); return matchor(exp,finalObject);
else if (option.equalsIgnoreCase("leftlike")||option.equalsIgnoreCase("startswith")||option.equalsIgnoreCase("begin")) }
else if (option.equalsIgnoreCase("leftlike")||option.equalsIgnoreCase("startswith")||option.equalsIgnoreCase("begin")){
return leftmatchor(exp,finalObject); return leftmatchor(exp,finalObject);
else if (option.equalsIgnoreCase("rightlike")||option.equalsIgnoreCase("endswith")||option.equalsIgnoreCase("end")) }
else if (option.equalsIgnoreCase("rightlike")||option.equalsIgnoreCase("endswith")||option.equalsIgnoreCase("end")){
return rightmatchor(exp,finalObject); return rightmatchor(exp,finalObject);
else if (option.equalsIgnoreCase("match")||option.equalsIgnoreCase("matchand")||option.equalsIgnoreCase("matches")) }
else if (option.equalsIgnoreCase("match")||option.equalsIgnoreCase("matchand")||option.equalsIgnoreCase("matches")){
return matchand(exp,finalObject); return matchand(exp,finalObject);
else if (option.equalsIgnoreCase("in")) }
else if (option.equalsIgnoreCase("in")){
return in(exp,finalObject); return in(exp,finalObject);
else if (option.equalsIgnoreCase("notin")) }
else if (option.equalsIgnoreCase("notin")){
return notin(exp,finalObject); return notin(exp,finalObject);
else if (option.equalsIgnoreCase("NOTLIKE")) }
else if (option.equalsIgnoreCase("NOTLIKE")){
return notmatchor(exp,finalObject); return notmatchor(exp,finalObject);
else if (option.equalsIgnoreCase("LEFTNOTLIKE")) }
else if (option.equalsIgnoreCase("LEFTNOTLIKE")){
return !leftmatchor(exp,finalObject); return !leftmatchor(exp,finalObject);
else if (option.equalsIgnoreCase("RIGHTNOTLIKE")) }
else if (option.equalsIgnoreCase("RIGHTNOTLIKE")){
return !rightmatchor(exp,finalObject); return !rightmatchor(exp,finalObject);
else if (option.equalsIgnoreCase("NOTMATCHES")) }
else if (option.equalsIgnoreCase("NOTMATCHES")){
return notmatchand(exp,finalObject); return notmatchand(exp,finalObject);
else }
else{
return false; return false;
}
} }
...@@ -128,10 +151,12 @@ public class RuleUtils ...@@ -128,10 +151,12 @@ public class RuleUtils
public static boolean equal(Object exp, Object finalObject) public static boolean equal(Object exp, Object finalObject)
{ {
if(exp==null) if(exp==null){
return false; return false;
if(finalObject ==null) }
if(finalObject ==null){
return false; return false;
}
if(exp instanceof String && ((String) exp).length()==10 && finalObject instanceof Timestamp) if(exp instanceof String && ((String) exp).length()==10 && finalObject instanceof Timestamp)
{ {
...@@ -148,10 +173,12 @@ public class RuleUtils ...@@ -148,10 +173,12 @@ public class RuleUtils
return ObjectUtils.nullSafeEquals(tm,finalObject); return ObjectUtils.nullSafeEquals(tm,finalObject);
} }
if(ObjectUtils.nullSafeEquals(exp,finalObject)) if(ObjectUtils.nullSafeEquals(exp,finalObject)){
return true; return true;
if(exp.toString().equalsIgnoreCase(finalObject.toString())) }
if(exp.toString().equalsIgnoreCase(finalObject.toString())){
return true; return true;
}
return false; return false;
} }
...@@ -161,10 +188,12 @@ public class RuleUtils ...@@ -161,10 +188,12 @@ public class RuleUtils
} }
public static boolean gt(Object exp, Object finalObject) public static boolean gt(Object exp, Object finalObject)
{ {
if(ObjectUtils.isEmpty(exp)) if(ObjectUtils.isEmpty(exp)){
return false; return false;
if(ObjectUtils.isEmpty(finalObject)) }
if(ObjectUtils.isEmpty(finalObject)){
return false; return false;
}
try try
{ {
if(finalObject instanceof java.sql.Timestamp) if(finalObject instanceof java.sql.Timestamp)
...@@ -179,8 +208,9 @@ public class RuleUtils ...@@ -179,8 +208,9 @@ public class RuleUtils
else else
{ {
tm=DataObject.getTimestampValue(exp,null); tm=DataObject.getTimestampValue(exp,null);
if(tm==null) if(tm==null){
return false; return false;
}
} }
return finalTime.getTime()>tm.getTime(); return finalTime.getTime()>tm.getTime();
} }
...@@ -212,15 +242,14 @@ public class RuleUtils ...@@ -212,15 +242,14 @@ public class RuleUtils
{ {
return finalObject.toString().compareToIgnoreCase(exp.toString())>0; return finalObject.toString().compareToIgnoreCase(exp.toString())>0;
} }
else else{
return false; return false;
}
} }
catch(Exception ex) catch(Exception ex)
{ {
return false; return false;
} }
} }
public static boolean lt(Object exp, Object object, String members) public static boolean lt(Object exp, Object object, String members)
...@@ -229,10 +258,12 @@ public class RuleUtils ...@@ -229,10 +258,12 @@ public class RuleUtils
} }
public static boolean lt(Object exp, Object finalObject) public static boolean lt(Object exp, Object finalObject)
{ {
if(ObjectUtils.isEmpty(exp)) if(ObjectUtils.isEmpty(exp)){
return false; return false;
if(ObjectUtils.isEmpty(finalObject)) }
if(ObjectUtils.isEmpty(finalObject)){
return false; return false;
}
try try
{ {
if(finalObject instanceof java.sql.Timestamp) if(finalObject instanceof java.sql.Timestamp)
...@@ -314,8 +345,9 @@ public class RuleUtils ...@@ -314,8 +345,9 @@ public class RuleUtils
return false; return false;
String tvs=expObj.toString().trim(); String tvs=expObj.toString().trim();
if(StringUtils.isEmpty(tvs)) if(StringUtils.isEmpty(tvs)){
return false; return false;
}
if (finalObject instanceof Integer) if (finalObject instanceof Integer)
{ {
...@@ -355,8 +387,9 @@ public class RuleUtils ...@@ -355,8 +387,9 @@ public class RuleUtils
} }
public static boolean isNull(Object finalObject) public static boolean isNull(Object finalObject)
{ {
if(finalObject instanceof String) if(finalObject instanceof String){
return StringUtils.isEmpty(finalObject.toString().trim()); return StringUtils.isEmpty(finalObject.toString().trim());
}
return (ObjectUtils.isEmpty(finalObject)); return (ObjectUtils.isEmpty(finalObject));
} }
...@@ -385,11 +418,13 @@ public class RuleUtils ...@@ -385,11 +418,13 @@ public class RuleUtils
} }
public static boolean matchor(Object expObj, Object obj) public static boolean matchor(Object expObj, Object obj)
{ {
if(obj==null) if(obj==null){
return false; return false;
}
String exp=expObj.toString().trim(); String exp=expObj.toString().trim();
if(StringUtils.isEmpty(exp)) if(StringUtils.isEmpty(exp)){
return false; return false;
}
exp=exp.replace(";", ","); exp=exp.replace(";", ",");
exp=exp.replace(";", ","); exp=exp.replace(";", ",");
exp=exp.replace(",", ","); exp=exp.replace(",", ",");
...@@ -406,11 +441,13 @@ public class RuleUtils ...@@ -406,11 +441,13 @@ public class RuleUtils
public static boolean leftmatchor(Object expObj, Object obj) public static boolean leftmatchor(Object expObj, Object obj)
{ {
if(obj==null) if(obj==null){
return false; return false;
}
String exp=expObj.toString().trim(); String exp=expObj.toString().trim();
if(StringUtils.isEmpty(exp)) if(StringUtils.isEmpty(exp)){
return false; return false;
}
exp=exp.replace(";", ","); exp=exp.replace(";", ",");
exp=exp.replace(";", ","); exp=exp.replace(";", ",");
exp=exp.replace(",", ","); exp=exp.replace(",", ",");
...@@ -419,19 +456,22 @@ public class RuleUtils ...@@ -419,19 +456,22 @@ public class RuleUtils
for(String strExp:arr) for(String strExp:arr)
{ {
bRt=obj.toString().matches(strExp+"(.*)"); bRt=obj.toString().matches(strExp+"(.*)");
if(bRt) if(bRt){
return true; return true;
}
} }
return bRt; return bRt;
} }
public static boolean rightmatchor(Object expObj, Object obj) public static boolean rightmatchor(Object expObj, Object obj)
{ {
if(obj==null) if(obj==null){
return false; return false;
}
String exp=expObj.toString().trim(); String exp=expObj.toString().trim();
if(StringUtils.isEmpty(exp)) if(StringUtils.isEmpty(exp)){
return false; return false;
}
exp=exp.replace(";", ","); exp=exp.replace(";", ",");
exp=exp.replace(";", ","); exp=exp.replace(";", ",");
exp=exp.replace(",", ","); exp=exp.replace(",", ",");
...@@ -440,8 +480,9 @@ public class RuleUtils ...@@ -440,8 +480,9 @@ public class RuleUtils
for(String strExp:arr) for(String strExp:arr)
{ {
bRt=obj.toString().matches("(.*)"+strExp); bRt=obj.toString().matches("(.*)"+strExp);
if(bRt) if(bRt){
return true; return true;
}
} }
return bRt; return bRt;
} }
...@@ -452,13 +493,16 @@ public class RuleUtils ...@@ -452,13 +493,16 @@ public class RuleUtils
} }
public static boolean matchand(Object expObj,Object obj) public static boolean matchand(Object expObj,Object obj)
{ {
if(obj==null) if(obj==null){
return false; return false;
if(expObj==null) }
if(expObj==null){
return false; return false;
}
String exp=expObj.toString().trim(); String exp=expObj.toString().trim();
if(StringUtils.isEmpty(exp)) if(StringUtils.isEmpty(exp)){
return false; return false;
}
exp=exp.replace(";", ","); exp=exp.replace(";", ",");
exp=exp.replace(";", ","); exp=exp.replace(";", ",");
exp=exp.replace(",", ","); exp=exp.replace(",", ",");
...@@ -467,11 +511,13 @@ public class RuleUtils ...@@ -467,11 +511,13 @@ public class RuleUtils
boolean bRt=true; boolean bRt=true;
for(String strExp:arr) for(String strExp:arr)
{ {
if(strExp.trim().length()==0) if(strExp.trim().length()==0){
continue; continue;
}
bRt=(obj.toString()).matches("(.*)"+(strExp)+"(.*)"); bRt=(obj.toString()).matches("(.*)"+(strExp)+"(.*)");
if(!bRt) if(!bRt){
return false; return false;
}
} }
return bRt; return bRt;
} }
...@@ -506,12 +552,14 @@ public class RuleUtils ...@@ -506,12 +552,14 @@ public class RuleUtils
switch (str1.hashCode()) switch (str1.hashCode())
{ {
case 105: case 105:
if (str1.equals("i")) if (str1.equals("i")){
i = 0; i = 0;
}
break; break;
case 115: case 115:
if (str1.equals("s")) if (str1.equals("s")){
i = 1; i = 1;
}
} }
switch (i) switch (i)
{ {
......
<#ibiztemplate> <#ibiztemplate>
TARGET=PSSYSTEM TARGET=PSSYSTEM
</#ibiztemplate> </#ibiztemplate>
<#assign sid = sys.getName()/> <#assign sid = sys.getCodeName()/>
<#assign sname = sys.getLogicName()/> <#assign sname = sys.getLogicName()/>
<#assign hasWF=false> <#assign hasWF=false>
<#if sys.getAllPSWorkflows()??> <#if sys.getAllPSWorkflows()??>
...@@ -91,14 +91,14 @@ public class PermissionSyncJob implements ApplicationRunner { ...@@ -91,14 +91,14 @@ public class PermissionSyncJob implements ApplicationRunner {
public void run(ApplicationArguments args) { public void run(ApplicationArguments args) {
try { try {
Thread.sleep(10000); Thread.sleep(10000);
InputStream permission= this.getClass().getResourceAsStream("/permission/systemResource.json"); //获取当前系统所有实体资源能力 InputStream permission = this.getClass().getResourceAsStream("/permission/systemResource.json"); //获取当前系统所有实体资源能力
String permissionResult = IOUtils.toString(permission,"UTF-8"); String permissionResult = IOUtils.toString(permission,"UTF-8");
JSONObject system= new JSONObject(); JSONObject system= new JSONObject();
system.put("pssystemid",systemId); system.put("pssystemid",systemId);
system.put("pssystemname",systemName); system.put("pssystemname",systemName);
system.put("sysstructure",JSONObject.parseObject(permissionResult)); system.put("sysstructure",JSONObject.parseObject(permissionResult));
system.put("md5check",DigestUtils.md5DigestAsHex(permissionResult.getBytes())); system.put("md5check",DigestUtils.md5DigestAsHex(permissionResult.getBytes()));
if(client.syncSysAuthority(system)){ if(client.syncSysAuthority(system)) {
log.info("向[UAA]同步系统资源成功"); log.info("向[UAA]同步系统资源成功");
}else{ }else{
log.error("向[UAA]同步系统资源失败"); log.error("向[UAA]同步系统资源失败");
...@@ -109,9 +109,9 @@ public class PermissionSyncJob implements ApplicationRunner { ...@@ -109,9 +109,9 @@ public class PermissionSyncJob implements ApplicationRunner {
} }
try { try {
InputStream sysModel= this.getClass().getResourceAsStream("/sysmodel/${sys.codeName}.json"); //获取当前系统所有实体资源能力 InputStream sysModel = this.getClass().getResourceAsStream("/sysmodel/${sys.codeName}.json"); //获取当前系统所有实体资源能力
String strSysModel = IOUtils.toString(sysModel,"UTF-8"); String strSysModel = IOUtils.toString(sysModel,"UTF-8");
if(liteFeignClient.syncSysModel(JSONObject.parseObject(strSysModel))){ if(liteFeignClient.syncSysModel(JSONObject.parseObject(strSysModel))) {
log.info("向[lite]同步系统模型成功"); log.info("向[lite]同步系统模型成功");
}else{ }else{
log.error("向[lite]同步系统模型失败"); log.error("向[lite]同步系统模型失败");
...@@ -123,7 +123,7 @@ public class PermissionSyncJob implements ApplicationRunner { ...@@ -123,7 +123,7 @@ public class PermissionSyncJob implements ApplicationRunner {
<#if hasWF> <#if hasWF>
try{ try{
List<Map<String,Object>> bpmnfiles=new ArrayList(); List<Map<String,Object>> bpmnfiles = new ArrayList();
<#list sys.getAllPSWorkflows() as wf> <#list sys.getAllPSWorkflows() as wf>
<#if wf.getPSWFVersions()??> <#if wf.getPSWFVersions()??>
<#list wf.getPSWFVersions() as wfvs> <#list wf.getPSWFVersions() as wfvs>
...@@ -131,23 +131,23 @@ public class PermissionSyncJob implements ApplicationRunner { ...@@ -131,23 +131,23 @@ public class PermissionSyncJob implements ApplicationRunner {
</#list> </#list>
</#if> </#if>
</#list> </#list>
if(client2.deployBpmnFile(bpmnfiles)){ if(client2.deployBpmnFile(bpmnfiles)) {
log.info("部署流程成功"); log.info("部署流程成功");
}else{ }else{
log.error("部署流程失败"); log.error("部署流程失败");
} }
}catch(Exception ex){ }catch(Exception ex) {
log.error(String.format("部署流程失败,请检查[WF]服务是否正常! [%s]",ex)); log.error(String.format("部署流程失败,请检查[WF]服务是否正常! [%s]",ex));
} }
</#if> </#if>
<#if hasMsgTemplate> <#if hasMsgTemplate>
try { try {
InputStream msgTemplate= this.getClass().getResourceAsStream("/msgtempl/systemMsgTempl.json"); //获取当前系统所有实体资源能力 InputStream msgTemplate = this.getClass().getResourceAsStream("/msgtempl/systemMsgTempl.json"); //获取当前系统所有实体资源能力
String strMsgTemplate = IOUtils.toString(msgTemplate,"UTF-8"); String strMsgTemplate = IOUtils.toString(msgTemplate,"UTF-8");
JSONObject template= new JSONObject(); JSONObject template = new JSONObject();
template.put("template",JSONArray.parseArray(strMsgTemplate)); template.put("template", JSONArray.parseArray(strMsgTemplate));
if(notifyFeignClient.createMsgTemplate(template)){ if(notifyFeignClient.createMsgTemplate(template)) {
log.info("推送消息模板成功"); log.info("推送消息模板成功");
}else{ }else{
log.error("推送消息模板失败"); log.error("推送消息模板失败");
...@@ -159,9 +159,9 @@ public class PermissionSyncJob implements ApplicationRunner { ...@@ -159,9 +159,9 @@ public class PermissionSyncJob implements ApplicationRunner {
<#if hasPredefinedCodeList> <#if hasPredefinedCodeList>
try { try {
InputStream runtimeDict= this.getClass().getResourceAsStream("/sysmodel/RuntimeDict.json"); //获取当前系统所有实体资源能力 InputStream runtimeDict = this.getClass().getResourceAsStream("/sysmodel/RuntimeDict.json"); //获取当前系统所有实体资源能力
String strRuntimeDict = IOUtils.toString(runtimeDict,"UTF-8"); String strRuntimeDict = IOUtils.toString(runtimeDict,"UTF-8");
if(dictFeignClient.syncRuntimeDict(JSONArray.parseArray(strRuntimeDict))){ if(dictFeignClient.syncRuntimeDict(JSONArray.parseArray(strRuntimeDict))) {
log.info("推送系统预置代码表成功"); log.info("推送系统预置代码表成功");
}else{ }else{
log.error("推送系统预置代码表失败"); log.error("推送系统预置代码表失败");
......
...@@ -45,10 +45,12 @@ public class AppController { ...@@ -45,10 +45,12 @@ public class AppController {
while(it.hasNext()) { while(it.hasNext()) {
GrantedAuthority authority = (GrantedAuthority)it.next(); GrantedAuthority authority = (GrantedAuthority)it.next();
String strAuthority=authority.getAuthority(); String strAuthority=authority.getAuthority();
if(strAuthority.startsWith("UNIRES_"+systemId)) if(strAuthority.startsWith("UNIRES_"+systemId)) {
uniRes.add(strAuthority.substring(systemId.length()+8)); uniRes.add(strAuthority.substring(systemId.length()+8));
else if(strAuthority.startsWith("APPMENU_"+systemId)) }
else if(strAuthority.startsWith("APPMENU_"+systemId)){
appMenu.add(strAuthority.substring(systemId.length()+9)); appMenu.add(strAuthority.substring(systemId.length()+9));
}
} }
} }
Map<String,Object> context = new HashMap<>(); Map<String,Object> context = new HashMap<>();
...@@ -58,10 +60,12 @@ public class AppController { ...@@ -58,10 +60,12 @@ public class AppController {
appData.put("unires",uniRes); appData.put("unires",uniRes);
appData.put("appmenu",appMenu); appData.put("appmenu",appMenu);
appData.put("enablepermissionvalid",enablePermissionValid); appData.put("enablepermissionvalid",enablePermissionValid);
if(curUser.getSuperuser()==1) if(curUser.getSuperuser()==1){
appData.put("enablepermissionvalid",false); appData.put("enablepermissionvalid",false);
else }
else{
appData.put("enablepermissionvalid",enablePermissionValid); appData.put("enablepermissionvalid",enablePermissionValid);
}
fillAppData(appData); fillAppData(appData);
return ResponseEntity.status(HttpStatus.OK).body(appData); return ResponseEntity.status(HttpStatus.OK).body(appData);
} }
...@@ -79,16 +83,18 @@ public class AppController { ...@@ -79,16 +83,18 @@ public class AppController {
@RequestMapping(method = RequestMethod.PUT, value = "/configs/{configType}/{targetType}") @RequestMapping(method = RequestMethod.PUT, value = "/configs/{configType}/{targetType}")
public ResponseEntity<Boolean> saveConfig(@PathVariable("configType") String configType, @PathVariable("targetType") String targetType, @RequestBody JSONObject config) { public ResponseEntity<Boolean> saveConfig(@PathVariable("configType") String configType, @PathVariable("targetType") String targetType, @RequestBody JSONObject config) {
String userId=AuthenticationUser.getAuthenticationUser().getUserid(); String userId=AuthenticationUser.getAuthenticationUser().getUserid();
if(StringUtils.isEmpty(userId)) if(StringUtils.isEmpty(userId)){
throw new BadRequestAlertException("保存配置失败,参数缺失","IBZConfig",configType); throw new BadRequestAlertException("保存配置失败,参数缺失","IBZConfig",configType);
}
return ResponseEntity.ok(ibzConfigService.saveConfig(configType,targetType,userId,config)); return ResponseEntity.ok(ibzConfigService.saveConfig(configType,targetType,userId,config));
} }
@RequestMapping(method = RequestMethod.GET, value = "/configs/{configType}/{targetType}") @RequestMapping(method = RequestMethod.GET, value = "/configs/{configType}/{targetType}")
public ResponseEntity<JSONObject> getConfig(@PathVariable("configType") String configType, @PathVariable("targetType") String targetType) { public ResponseEntity<JSONObject> getConfig(@PathVariable("configType") String configType, @PathVariable("targetType") String targetType) {
String userId=AuthenticationUser.getAuthenticationUser().getUserid(); String userId=AuthenticationUser.getAuthenticationUser().getUserid();
if(StringUtils.isEmpty(userId)) if(StringUtils.isEmpty(userId)){
throw new BadRequestAlertException("获取配置失败,参数缺失","IBZConfig",configType); throw new BadRequestAlertException("获取配置失败,参数缺失","IBZConfig",configType);
}
return ResponseEntity.ok(ibzConfigService.getConfig(configType,targetType,userId)); return ResponseEntity.ok(ibzConfigService.getConfig(configType,targetType,userId));
} }
......
...@@ -59,5 +59,5 @@ public class AuthenticationController ...@@ -59,5 +59,5 @@ public class AuthenticationController
authuserdetail= userDetailsService.loadUserByUsername(userDetails.getUsername()); authuserdetail= userDetailsService.loadUserByUsername(userDetails.getUsername());
} }
return ResponseEntity.ok().body(authuserdetail); return ResponseEntity.ok().body(authuserdetail);
} }
} }
...@@ -41,18 +41,22 @@ public class AuthPermissionEvaluator implements PermissionEvaluator { ...@@ -41,18 +41,22 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
@Override @Override
@SneakyThrows @SneakyThrows
public boolean hasPermission(Authentication authentication, Object entity, Object action) { public boolean hasPermission(Authentication authentication, Object entity, Object action) {
if(!enablePermissionValid) if(!enablePermissionValid){
return true; return true;
}
Object principal = authentication.getPrincipal(); Object principal = authentication.getPrincipal();
if(ObjectUtils.isEmpty(principal)) if(ObjectUtils.isEmpty(principal)){
return false; return false;
}
AuthenticationUser authenticationUser= (AuthenticationUser) authentication.getPrincipal(); AuthenticationUser authenticationUser= (AuthenticationUser) authentication.getPrincipal();
if(authenticationUser.getSuperuser()==1) if(authenticationUser.getSuperuser()==1){
return true; return true;
}
String strAction=String.valueOf(action); String strAction=String.valueOf(action);
Set<String> userAuthorities = getAuthorities(authentication,strAction); Set<String> userAuthorities = getAuthorities(authentication,strAction);
if(userAuthorities.size()==0) if(userAuthorities.size()==0){
return false; return false;
}
if(isAllData(strAction,userAuthorities)){ if(isAllData(strAction,userAuthorities)){
return true; return true;
} }
...@@ -105,8 +109,9 @@ public class AuthPermissionEvaluator implements PermissionEvaluator { ...@@ -105,8 +109,9 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
*/ */
@SneakyThrows @SneakyThrows
private void setPermissionCondToSearchContext(EntityBase entity, QueryWrapperContext qc , Set<String> userAuthorities ,AuthenticationUser authenticationUser){ private void setPermissionCondToSearchContext(EntityBase entity, QueryWrapperContext qc , Set<String> userAuthorities ,AuthenticationUser authenticationUser){
if(entity==null) if(entity==null){
return ; return ;
}
Map<String,String> permissionField=getPermissionField(entity);//获取组织、部门预置属性 Map<String,String> permissionField=getPermissionField(entity);//获取组织、部门预置属性
String orgField=permissionField.get("orgfield"); String orgField=permissionField.get("orgfield");
String orgDeptField=permissionField.get("orgsecfield"); String orgDeptField=permissionField.get("orgsecfield");
...@@ -188,8 +193,9 @@ public class AuthPermissionEvaluator implements PermissionEvaluator { ...@@ -188,8 +193,9 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
Iterator it = authorities.iterator(); Iterator it = authorities.iterator();
while(it.hasNext()) { while(it.hasNext()) {
GrantedAuthority authority = (GrantedAuthority)it.next(); GrantedAuthority authority = (GrantedAuthority)it.next();
if(authority.getAuthority().contains(action)) if(authority.getAuthority().contains(action)){
userAuthorities.add(authority.getAuthority()); userAuthorities.add(authority.getAuthority());
}
} }
return userAuthorities; return userAuthorities;
} }
...@@ -256,23 +262,27 @@ public class AuthPermissionEvaluator implements PermissionEvaluator { ...@@ -256,23 +262,27 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
} }
if(action.endsWith("Create") || action.endsWith("Save")){ if(action.endsWith("Create") || action.endsWith("Save")){
if(!ObjectUtils.isEmpty(orgFieldValue) && !userOrg.contains(orgFieldValue)) if(!ObjectUtils.isEmpty(orgFieldValue) && !userOrg.contains(orgFieldValue)){
return false; return false;
if(!ObjectUtils.isEmpty(orgDeptFieldValue) && !userOrgDept.contains(orgDeptFieldValue)) }
if(!ObjectUtils.isEmpty(orgDeptFieldValue) && !userOrgDept.contains(orgDeptFieldValue)){
return false; return false;
if(!ObjectUtils.isEmpty(crateManFieldValue) && !authenticationUser.getUserid().equals(crateManFieldValue)) }
if(!ObjectUtils.isEmpty(crateManFieldValue) && !authenticationUser.getUserid().equals(crateManFieldValue)){
return false; return false;
}
return true; return true;
} }
else{ else{
if(!ObjectUtils.isEmpty(orgFieldValue) && userOrg.contains(orgFieldValue)) if(!ObjectUtils.isEmpty(orgFieldValue) && userOrg.contains(orgFieldValue)){
return true; return true;
if(!ObjectUtils.isEmpty(orgDeptFieldValue) && userOrgDept.contains(orgDeptFieldValue)) }
if(!ObjectUtils.isEmpty(orgDeptFieldValue) && userOrgDept.contains(orgDeptFieldValue)){
return true; return true;
if(!ObjectUtils.isEmpty(crateManFieldValue) && authenticationUser.getUserid().equals(crateManFieldValue)) }
if(!ObjectUtils.isEmpty(crateManFieldValue) && authenticationUser.getUserid().equals(crateManFieldValue)){
return true; return true;
}
return false; return false;
} }
} }
...@@ -296,12 +306,18 @@ public class AuthPermissionEvaluator implements PermissionEvaluator { ...@@ -296,12 +306,18 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
String fieldName=entry.getKey();//获取注解字段 String fieldName=entry.getKey();//获取注解字段
DEField fieldAnnotation=entry.getValue();//获取注解值 DEField fieldAnnotation=entry.getValue();//获取注解值
DEPredefinedFieldType prefieldType=fieldAnnotation.preType(); DEPredefinedFieldType prefieldType=fieldAnnotation.preType();
if(prefieldType==prefieldType.ORGID)//用户配置系统预置属性-组织机构标识 //用户配置系统预置属性-组织机构标识
if(prefieldType==prefieldType.ORGID){
orgField=fieldName; orgField=fieldName;
if(prefieldType==prefieldType.ORGSECTORID)//用户配置系统预置属性-部门标识 }
//用户配置系统预置属性-部门标识
if(prefieldType==prefieldType.ORGSECTORID){
orgDeptField=fieldName; orgDeptField=fieldName;
if(prefieldType==prefieldType.CREATEMAN)//用户配置系统预置属性-部门标识 }
//用户配置系统预置属性-部门标识
if(prefieldType==prefieldType.CREATEMAN){
createManField=fieldName; createManField=fieldName;
}
} }
permissionFiled.put("orgfield",orgField); permissionFiled.put("orgfield",orgField);
permissionFiled.put("orgsecfield",orgDeptField); permissionFiled.put("orgsecfield",orgDeptField);
......
...@@ -263,10 +263,12 @@ public class AuthenticationUser implements UserDetails ...@@ -263,10 +263,12 @@ public class AuthenticationUser implements UserDetails
return this.sessionParams; return this.sessionParams;
} }
private Map<String, Object> getUserSessionParam() { private Map<String, Object> getUserSessionParam() {
if(userSessionParam!=null) if(userSessionParam!=null){
return userSessionParam; return userSessionParam;
else }
else{
return new HashMap<>(); return new HashMap<>();
}
} }
public void setOrgInfo(Map<String, Set<String>> orgInfo) { public void setOrgInfo(Map<String, Set<String>> orgInfo) {
......
<#ibiztemplate> <#ibiztemplate>
TARGET=PSSYSTEM TARGET=PSSYSTEM
</#ibiztemplate> </#ibiztemplate>
<#assign validExpiredToken=false>
<#if sys.getAllPSDevSlnMSDepAPIs()??>
<#list sys.getAllPSDevSlnMSDepAPIs() as depSysApi>
<#if ((depSysApi.getUserParam("ibiz.refreshtoken",""))!'') =="true">
<#assign validExpiredToken=true>
</#if>
</#list>
</#if>
package ${pub.getPKGCodeName()}.util.security; package ${pub.getPKGCodeName()}.util.security;
import io.jsonwebtoken.ExpiredJwtException; import io.jsonwebtoken.ExpiredJwtException;
...@@ -23,15 +31,20 @@ import javax.servlet.ServletException; ...@@ -23,15 +31,20 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.*;
import java.util.HashSet; <#if validExpiredToken>
import java.util.Iterator; import org.springframework.util.StringUtils;
import java.util.Set; import org.springframework.util.ObjectUtils;
</#if>
@Slf4j @Slf4j
@Component @Component
public class AuthorizationTokenFilter extends OncePerRequestFilter { public class AuthorizationTokenFilter extends OncePerRequestFilter {
<#if validExpiredToken>
@Value(${r'"${ibiz.jwt.expiration:7200000}"'})
private Long expiration;
</#if>
private final UserDetailsService userDetailsService; private final UserDetailsService userDetailsService;
private final AuthTokenUtil authTokenUtil; private final AuthTokenUtil authTokenUtil;
private final String tokenHeader; private final String tokenHeader;
...@@ -71,6 +84,9 @@ public class AuthorizationTokenFilter extends OncePerRequestFilter { ...@@ -71,6 +84,9 @@ public class AuthorizationTokenFilter extends OncePerRequestFilter {
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities()); UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
SecurityContextHolder.getContext().setAuthentication(authentication); SecurityContextHolder.getContext().setAuthentication(authentication);
<#if validExpiredToken>
validExpiredToken(authToken,response);
</#if>
} }
} }
chain.doFilter(request, response); chain.doFilter(request, response);
...@@ -99,4 +115,25 @@ public class AuthorizationTokenFilter extends OncePerRequestFilter { ...@@ -99,4 +115,25 @@ public class AuthorizationTokenFilter extends OncePerRequestFilter {
return true; return true;
} }
} }
<#if validExpiredToken>
/**
* 检查token是否到期
*
* @param authToken
* @param response
*/
private void validExpiredToken(String authToken, HttpServletResponse response) {
try {
Date token = authTokenUtil.getExpirationDateFromToken(authToken);
if (!ObjectUtils.isEmpty(token) && !ObjectUtils.isEmpty(expiration) &&
token.getTime() - (expiration / 4) <= System.currentTimeMillis()) {
if (StringUtils.isEmpty(response.getHeader("RefreshToken"))) {
response.setHeader("RefreshToken", "true");
}
}
} catch (Exception e) {
log.error("token有效期检查发生异常," + e);
}
}
</#if>
} }
...@@ -23,12 +23,12 @@ public interface AuthenticationUserService extends UserDetailsService { ...@@ -23,12 +23,12 @@ public interface AuthenticationUserService extends UserDetailsService {
</#if> </#if>
@Override @Override
@Cacheable( value="${cachename}",key = "'getByUsername:'+#p0") @Cacheable( value="${cachename}", key = "'getByUsername:'+#p0")
AuthenticationUser loadUserByUsername(String username); AuthenticationUser loadUserByUsername(String username);
@Cacheable( value="${cachename}",key = "'getByUsername:'+#p0") @Cacheable( value="${cachename}", key = "'getByUsername:'+#p0")
AuthenticationUser loadUserByLogin(String username,String password); AuthenticationUser loadUserByLogin(String username,String password);
@CacheEvict( value="${cachename}",key = "'getByUsername:'+#p0") @CacheEvict( value="${cachename}", key = "'getByUsername:'+#p0")
void resetByUsername(String username); void resetByUsername(String username);
} }
...@@ -34,37 +34,41 @@ public class IBZConfigService extends ServiceImpl<IBZConfigMapper, IBZConfig> im ...@@ -34,37 +34,41 @@ public class IBZConfigService extends ServiceImpl<IBZConfigMapper, IBZConfig> im
@Value("${r'${'}ibiz.admin.userid:0100}") @Value("${r'${'}ibiz.admin.userid:0100}")
private String adminuserid; private String adminuserid;
@Cacheable( value="${cachename}",key = "'cfgid:'+#p0+'||'+#p1+'||'+#p2") @Cacheable(value="${cachename}",key = "'cfgid:'+#p0+'||'+#p1+'||'+#p2")
public JSONObject getConfig(String cfgType,String targetType,String userId) public JSONObject getConfig(String cfgType,String targetType,String userId)
{ {
if(StringUtils.isEmpty(userId)||StringUtils.isEmpty(cfgType)||StringUtils.isEmpty(targetType)) if(StringUtils.isEmpty(userId) || StringUtils.isEmpty(cfgType) || StringUtils.isEmpty(targetType)) {
throw new BadRequestAlertException("获取配置失败,参数缺失","IBZConfig",cfgType); throw new BadRequestAlertException("获取配置失败,参数缺失","IBZConfig",cfgType);
IBZConfig config=this.getOne(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).build()),false); }
if(config==null) { IBZConfig config = this.getOne(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).build()), false);
config=this.getOne(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(adminuserid).build()),false); if(config == null) {
if(config==null) { config = this.getOne(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(adminuserid).build()), false);
if(config == null) {
return new JSONObject(); return new JSONObject();
} }
} }
return JSON.parseObject(config.getCfg()); return JSON.parseObject(config.getCfg());
} }
@CacheEvict( value="${cachename}",key = "'cfgid:'+#p0+'||'+#p1+'||'+#p2") @CacheEvict(value="${cachename}", key = "'cfgid:'+#p0+'||'+#p1+'||'+#p2")
public boolean saveConfig(String cfgType,String targetType,String userId,JSONObject config) public boolean saveConfig(String cfgType, String targetType, String userId, JSONObject config)
{ {
if(StringUtils.isEmpty(userId)||StringUtils.isEmpty(cfgType)||StringUtils.isEmpty(targetType)) if(StringUtils.isEmpty(userId) || StringUtils.isEmpty(cfgType) || StringUtils.isEmpty(targetType)) {
throw new BadRequestAlertException("保存配置失败,参数缺失","IBZConfig",cfgType); throw new BadRequestAlertException("保存配置失败,参数缺失","IBZConfig",cfgType);
String cfg="{}"; }
if(config!=null) String cfg = "{}";
cfg=JSONObject.toJSONString(config); if(config != null) {
cfg = JSONObject.toJSONString(config);
}
return this.saveOrUpdate(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).cfg(cfg).updateDate(DataObject.getNow()).build()); return this.saveOrUpdate(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).cfg(cfg).updateDate(DataObject.getNow()).build());
} }
@CacheEvict( value="${cachename}",key = "'cfgid:'+#p0+'||'+#p1+'||'+#p2") @CacheEvict(value = "${cachename}", key = "'cfgid:'+#p0+'||'+#p1+'||'+#p2")
public void resetConfig(String cfgType,String targetType,String userId) public void resetConfig(String cfgType, String targetType, String userId)
{ {
if(StringUtils.isEmpty(userId)||StringUtils.isEmpty(cfgType)||StringUtils.isEmpty(targetType)) if(StringUtils.isEmpty(userId) || StringUtils.isEmpty(cfgType) || StringUtils.isEmpty(targetType)) {
throw new BadRequestAlertException("重置配置失败,参数缺失","IBZConfig",cfgType); throw new BadRequestAlertException("重置配置失败,参数缺失","IBZConfig",cfgType);
}
this.remove(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).build())); this.remove(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).build()));
} }
......
...@@ -14,9 +14,9 @@ import java.util.Map; ...@@ -14,9 +14,9 @@ import java.util.Map;
*/ */
public interface IBZDataAuditService { public interface IBZDataAuditService {
@Async("asyncExecutor") @Async("asyncExecutor")
void createAudit(HttpServletRequest request,EntityBase entity,Object idValue,Map<String, Audit> auditFields); void createAudit(HttpServletRequest request, EntityBase entity, Object idValue, Map<String, Audit> auditFields);
@Async("asyncExecutor") @Async("asyncExecutor")
void updateAudit(HttpServletRequest request, EntityBase beforeEntity, Object serviceObj, Object idValue, Map<String, Audit> auditFields); void updateAudit(HttpServletRequest request, EntityBase beforeEntity, Object serviceObj, Object idValue, Map<String, Audit> auditFields);
@Async("asyncExecutor") @Async("asyncExecutor")
void removeAudit(HttpServletRequest request,EntityBase entity,Object idValue,Map<String, Audit> auditFields); void removeAudit(HttpServletRequest request, EntityBase entity, Object idValue, Map<String, Audit> auditFields);
} }
\ No newline at end of file
...@@ -29,18 +29,18 @@ public class IBZUAAUserService implements AuthenticationUserService{ ...@@ -29,18 +29,18 @@ public class IBZUAAUserService implements AuthenticationUserService{
@Override @Override
public AuthenticationUser loadUserByUsername(String username) { public AuthenticationUser loadUserByUsername(String username) {
AuthenticationUser user = uaaFeignClient.loginByUsername(username);
AuthenticationUser user=uaaFeignClient.loginByUsername(username); if(user == null) {
if(user==null)
throw new BadRequestAlertException("登录失败","IBZUAAUser",username); throw new BadRequestAlertException("登录失败","IBZUAAUser",username);
}
return user; return user;
} }
@Override @Override
public AuthenticationUser loadUserByLogin(String username, String password) { public AuthenticationUser loadUserByLogin(String username, String password) {
String[] data=username.split("[|]"); String[] data = username.split("[|]");
String loginname=username; String loginname = username;
String domains=""; String domains = "";
if(data.length==2) { if(data.length==2) {
loginname=data[0].trim(); loginname=data[0].trim();
...@@ -50,9 +50,10 @@ public class IBZUAAUserService implements AuthenticationUserService{ ...@@ -50,9 +50,10 @@ public class IBZUAAUserService implements AuthenticationUserService{
logininfo.setDomain(domains); logininfo.setDomain(domains);
logininfo.setLoginname(loginname); logininfo.setLoginname(loginname);
logininfo.setPassword(password); logininfo.setPassword(password);
AuthenticationUser user=uaaFeignClient.login(logininfo); AuthenticationUser user = uaaFeignClient.login(logininfo);
if(user==null) if(user == null){
throw new BadRequestAlertException("登录失败","IBZUAAUser",username); throw new BadRequestAlertException("登录失败","IBZUAAUser", username);
}
return user; return user;
} }
......
...@@ -31,20 +31,25 @@ public class IBZUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> impl ...@@ -31,20 +31,25 @@ public class IBZUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> impl
@Override @Override
public AuthenticationUser loadUserByUsername(String username) { public AuthenticationUser loadUserByUsername(String username) {
if(StringUtils.isEmpty(username)) if(StringUtils.isEmpty(username)) {
throw new UsernameNotFoundException("用户名为空"); throw new UsernameNotFoundException("用户名为空");
QueryWrapper<IBZUSER> conds=new QueryWrapper<IBZUSER>(); }
String[] data=username.split("[|]"); QueryWrapper<IBZUSER> conds = new QueryWrapper<IBZUSER>();
String loginname=""; String[] data = username.split("[|]");
String domains=""; String loginname = "";
if(data.length>0) String domains = "";
loginname=data[0].trim(); if(data.length>0) {
if(data.length>1) loginname = data[0].trim();
domains=data[1].trim(); }
if(!StringUtils.isEmpty(loginname)) if(data.length>1) {
domains = data[1].trim();
}
if(!StringUtils.isEmpty(loginname)) {
conds.eq("loginname",loginname); conds.eq("loginname",loginname);
if(!StringUtils.isEmpty(domains)) }
if(!StringUtils.isEmpty(domains)) {
conds.eq("domains",domains); conds.eq("domains",domains);
}
IBZUSER user = this.getOne(conds); IBZUSER user = this.getOne(conds);
if (user == null) { if (user == null) {
throw new UsernameNotFoundException("用户" + username + "未找到"); throw new UsernameNotFoundException("用户" + username + "未找到");
...@@ -58,11 +63,13 @@ public class IBZUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> impl ...@@ -58,11 +63,13 @@ public class IBZUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> impl
@Override @Override
public AuthenticationUser loadUserByLogin(String username, String password){ public AuthenticationUser loadUserByLogin(String username, String password){
AuthenticationUser authuserdetail = loadUserByUsername(username); AuthenticationUser authuserdetail = loadUserByUsername(username);
if(pwencrymode==1) if(pwencrymode == 1){
password = DigestUtils.md5DigestAsHex(password.getBytes()); password = DigestUtils.md5DigestAsHex(password.getBytes());
else if(pwencrymode==2) }
else if(pwencrymode == 2){
password = DigestUtils.md5DigestAsHex(String.format("%1$s||%2$s", username, password).getBytes()); password = DigestUtils.md5DigestAsHex(String.format("%1$s||%2$s", username, password).getBytes());
if(!authuserdetail.getPassword().equals( password )){ }
if(!authuserdetail.getPassword().equals(password)) {
throw new BadRequestAlertException("用户名密码错误","IBZUSER",username); throw new BadRequestAlertException("用户名密码错误","IBZUSER",username);
} }
return authuserdetail; return authuserdetail;
...@@ -76,7 +83,7 @@ public class IBZUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> impl ...@@ -76,7 +83,7 @@ public class IBZUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> impl
public AuthenticationUser createUserDetails(IBZUSER user) { public AuthenticationUser createUserDetails(IBZUSER user) {
AuthenticationUser userdatail = new AuthenticationUser(); AuthenticationUser userdatail = new AuthenticationUser();
CachedBeanCopier.copy(user,userdatail); CachedBeanCopier.copy(user,userdatail);
if(userdatail.getSuperuser()==1){ if(userdatail.getSuperuser() == 1){
userdatail.setAuthorities(AuthorityUtils.createAuthorityList("ROLE_SUPERADMIN")); userdatail.setAuthorities(AuthorityUtils.createAuthorityList("ROLE_SUPERADMIN"));
} }
return userdatail; return userdatail;
......
...@@ -52,19 +52,19 @@ public class RemoteService { ...@@ -52,19 +52,19 @@ public class RemoteService {
*/ */
public interface RemoteFeignClient { public interface RemoteFeignClient {
@RequestMapping(method = RequestMethod.POST, value = "/{path}") @RequestMapping(method = RequestMethod.POST, value = "/{path}")
JSONObject post( @PathVariable("path") String path, @RequestHeader("Authorization") String token,@RequestBody Map param); JSONObject post( @PathVariable("path") String path, @RequestHeader("Authorization") String token, @RequestBody Map param);
@RequestMapping(method = RequestMethod.GET, value = "/{path}") @RequestMapping(method = RequestMethod.GET, value = "/{path}")
JSONObject request( @PathVariable("path") String path, @RequestHeader("Authorization") String token,Map param); JSONObject request( @PathVariable("path") String path, @RequestHeader("Authorization") String token, Map param);
@RequestMapping(method = RequestMethod.GET, value = "/{path}") @RequestMapping(method = RequestMethod.GET, value = "/{path}")
JSONObject get( @PathVariable("path") String path, @RequestHeader("Authorization") String token); JSONObject get( @PathVariable("path") String path, @RequestHeader("Authorization") String token);
@RequestMapping(method = RequestMethod.PUT, value = "/{path}") @RequestMapping(method = RequestMethod.PUT, value = "/{path}")
JSONObject put( @PathVariable("path") String path, @RequestHeader("Authorization") String token,@RequestBody Map param); JSONObject put( @PathVariable("path") String path, @RequestHeader("Authorization") String token,@RequestBody Map param);
@RequestMapping(method = RequestMethod.DELETE, value = "/{path}") @RequestMapping(method = RequestMethod.DELETE, value = "/{path}")
JSONObject delete( @PathVariable("path") String path, @RequestHeader("Authorization") String token); JSONObject delete(@PathVariable("path") String path, @RequestHeader("Authorization") String token);
} }
/** /**
...@@ -118,6 +118,4 @@ public class RemoteService { ...@@ -118,6 +118,4 @@ public class RemoteService {
final HttpMessageConverters httpMessageConverters = new HttpMessageConverters(jsonConverter); final HttpMessageConverters httpMessageConverters = new HttpMessageConverters(jsonConverter);
return () -> httpMessageConverters; return () -> httpMessageConverters;
} }
} }
\ No newline at end of file
...@@ -45,13 +45,15 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -45,13 +45,15 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
*/ */
@Scheduled(fixedRate = 10000) @Scheduled(fixedRate = 10000)
public void saveAudit() { public void saveAudit() {
if(cacheMap.size()>0){ if(cacheMap.size()>0) {
log.info(String.format("正在保存审计数据,当前审计集合数量为[%s]",cacheMap.size())); log.info(String.format("正在保存审计数据,当前审计集合数量为[%s]",cacheMap.size()));
List temp=new ArrayList(); List temp=new ArrayList();
if(cacheMap.size()<500) if(cacheMap.size()<500) {
temp.addAll(cacheMap); temp.addAll(cacheMap);
else }
else {
temp.addAll(cacheMap.subList(0,500)); temp.addAll(cacheMap.subList(0,500));
}
this.saveBatch(temp); this.saveBatch(temp);
cacheMap.removeAll(temp); cacheMap.removeAll(temp);
log.info(String.format("保存完成,当前审计集合数量为[%s]",cacheMap.size())); log.info(String.format("保存完成,当前审计集合数量为[%s]",cacheMap.size()));
...@@ -67,16 +69,17 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -67,16 +69,17 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
*/ */
@Override @Override
public void createAudit(HttpServletRequest request, EntityBase entity, Object idValue, Map<String, Audit> auditFields) { public void createAudit(HttpServletRequest request, EntityBase entity, Object idValue, Map<String, Audit> auditFields) {
IBZDataAudit dataAudit =new IBZDataAudit(); IBZDataAudit dataAudit = new IBZDataAudit();
dataAudit.setOppersonid(AuthenticationUser.getAuthenticationUser().getUserid()); dataAudit.setOppersonid(AuthenticationUser.getAuthenticationUser().getUserid());
dataAudit.setOppersonname(String.format("%s[%s]",AuthenticationUser.getAuthenticationUser().getPersonname(),AuthenticationUser.getAuthenticationUser().getOrgname())); dataAudit.setOppersonname(String.format("%s[%s]", AuthenticationUser.getAuthenticationUser().getPersonname(), AuthenticationUser.getAuthenticationUser().getOrgname()));
dataAudit.setAudittype("CREATE"); dataAudit.setAudittype("CREATE");
dataAudit.setAuditobject(entity.getClass().getSimpleName()); dataAudit.setAuditobject(entity.getClass().getSimpleName());
dataAudit.setAuditobjectdata(idValue); dataAudit.setAuditobjectdata(idValue);
dataAudit.setOptime(new Timestamp(new Date().getTime())); dataAudit.setOptime(new Timestamp(new Date().getTime()));
if(request!=null) if(request != null) {
dataAudit.setIpaddress(getIpAddress(request, AuthenticationUser.getAuthenticationUser())); dataAudit.setIpaddress(getIpAddress(request, AuthenticationUser.getAuthenticationUser()));
dataAudit.setAuditinfo(getAuditInfo(entity,auditFields)); }
dataAudit.setAuditinfo(getAuditInfo(entity, auditFields));
dataAudit.setIsdatachanged(1); dataAudit.setIsdatachanged(1);
cacheMap.add(dataAudit); cacheMap.add(dataAudit);
} }
...@@ -90,24 +93,26 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -90,24 +93,26 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
* @param auditFields * @param auditFields
*/ */
@SneakyThrows @SneakyThrows
public void updateAudit(HttpServletRequest request, EntityBase beforeEntity, Object serviceObj, Object idValue, Map<String, Audit> auditFields){ public void updateAudit(HttpServletRequest request, EntityBase beforeEntity, Object serviceObj, Object idValue, Map<String, Audit> auditFields) {
//获取更新后的实体 //获取更新后的实体
EntityBase afterEntity=getEntity(serviceObj,idValue); EntityBase afterEntity = getEntity(serviceObj, idValue);
//获取更新后的审计内容 //获取更新后的审计内容
String auditInfo=getUpdateAuditInfo(beforeEntity,afterEntity,auditFields);//比较更新前后差异内容 String auditInfo = getUpdateAuditInfo(beforeEntity, afterEntity, auditFields);//比较更新前后差异内容
int isDataChanged=1; int isDataChanged = 1;
if(StringUtils.isEmpty(auditInfo))//审计内容是否发生变化 //审计内容是否发生变化
isDataChanged=0; if(StringUtils.isEmpty(auditInfo)) {
isDataChanged = 0;
IBZDataAudit dataAudit =new IBZDataAudit(); }
IBZDataAudit dataAudit = new IBZDataAudit();
dataAudit.setOppersonid(AuthenticationUser.getAuthenticationUser().getUserid()); dataAudit.setOppersonid(AuthenticationUser.getAuthenticationUser().getUserid());
dataAudit.setOppersonname(String.format("%s[%s]",AuthenticationUser.getAuthenticationUser().getPersonname(),AuthenticationUser.getAuthenticationUser().getOrgname())); dataAudit.setOppersonname(String.format("%s[%s]", AuthenticationUser.getAuthenticationUser().getPersonname(), AuthenticationUser.getAuthenticationUser().getOrgname()));
dataAudit.setAudittype("UPDATE"); dataAudit.setAudittype("UPDATE");
dataAudit.setAuditobject(afterEntity.getClass().getSimpleName()); dataAudit.setAuditobject(afterEntity.getClass().getSimpleName());
dataAudit.setAuditobjectdata(idValue); dataAudit.setAuditobjectdata(idValue);
dataAudit.setOptime(new Timestamp(new Date().getTime())); dataAudit.setOptime(new Timestamp(new Date().getTime()));
if(request!=null) if(request!=null) {
dataAudit.setIpaddress(getIpAddress(request, AuthenticationUser.getAuthenticationUser())); dataAudit.setIpaddress(getIpAddress(request, AuthenticationUser.getAuthenticationUser()));
}
dataAudit.setAuditinfo(auditInfo); dataAudit.setAuditinfo(auditInfo);
dataAudit.setIsdatachanged(isDataChanged); dataAudit.setIsdatachanged(isDataChanged);
cacheMap.add(dataAudit); cacheMap.add(dataAudit);
...@@ -120,53 +125,55 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -120,53 +125,55 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
* @param idValue * @param idValue
* @param auditFields * @param auditFields
*/ */
public void removeAudit(HttpServletRequest request,EntityBase entity,Object idValue,Map<String, Audit> auditFields){ public void removeAudit(HttpServletRequest request, EntityBase entity, Object idValue, Map<String, Audit> auditFields) {
IBZDataAudit dataAudit =new IBZDataAudit(); IBZDataAudit dataAudit = new IBZDataAudit();
dataAudit.setOppersonid(AuthenticationUser.getAuthenticationUser().getUserid()); dataAudit.setOppersonid(AuthenticationUser.getAuthenticationUser().getUserid());
dataAudit.setOppersonname(String.format("%s[%s]",AuthenticationUser.getAuthenticationUser().getPersonname(),AuthenticationUser.getAuthenticationUser().getOrgname())); dataAudit.setOppersonname(String.format("%s[%s]", AuthenticationUser.getAuthenticationUser().getPersonname(), AuthenticationUser.getAuthenticationUser().getOrgname()));
dataAudit.setAudittype("REMOVE"); dataAudit.setAudittype("REMOVE");
dataAudit.setAuditobject(entity.getClass().getSimpleName()); dataAudit.setAuditobject(entity.getClass().getSimpleName());
dataAudit.setAuditobjectdata(idValue); dataAudit.setAuditobjectdata(idValue);
dataAudit.setOptime(new Timestamp(new Date().getTime())); dataAudit.setOptime(new Timestamp(new Date().getTime()));
if(request!=null) if(request!=null) {
dataAudit.setIpaddress(getIpAddress(request, AuthenticationUser.getAuthenticationUser())); dataAudit.setIpaddress(getIpAddress(request, AuthenticationUser.getAuthenticationUser()));
dataAudit.setAuditinfo(getAuditInfo(entity,auditFields)); }
dataAudit.setAuditinfo(getAuditInfo(entity, auditFields));
dataAudit.setIsdatachanged(1); dataAudit.setIsdatachanged(1);
cacheMap.add(dataAudit); cacheMap.add(dataAudit);
} }
private String getAuditInfo(EntityBase entity, Map<String, Audit> auditFields){ private String getAuditInfo(EntityBase entity, Map<String, Audit> auditFields) {
String auditResult=""; String auditResult = "";
if(auditFields.size()==0) if(auditFields.size() == 0) {
return auditResult; return auditResult;
}
Map<String, DEField> deFields= DEFieldCacheMap.getDEFields(entity.getClass()); Map<String, DEField> deFields = DEFieldCacheMap.getDEFields(entity.getClass());
if(deFields.size()==0) if(deFields.size() == 0) {
return auditResult; return auditResult;
}
JSONArray auditFieldArray=new JSONArray(); JSONArray auditFieldArray = new JSONArray();
for (Map.Entry<String, Audit> auditField : auditFields.entrySet()) { for (Map.Entry<String, Audit> auditField : auditFields.entrySet()) {
Object objFieldName=auditField.getKey(); Object objFieldName = auditField.getKey();
String fieldName=String.valueOf(objFieldName); String fieldName = String.valueOf(objFieldName);
DEField deField=null; DEField deField = null;
if(deFields.containsKey(fieldName)){ if(deFields.containsKey(fieldName)) {
deField= deFields.get(fieldName); deField = deFields.get(fieldName);
} }
if(ObjectUtils.isEmpty(deField)) if(ObjectUtils.isEmpty(deField)) {
continue; continue;
Object value=dataTransfer(entity.get(fieldName),deField.fieldType(),deField.format()); }
if(!StringUtils.isEmpty(value)){ Object value = dataTransfer(entity.get(fieldName), deField.fieldType(), deField.format());
JSONObject auditFieldObj=new JSONObject(); if(!StringUtils.isEmpty(value)) {
auditFieldObj.put("field",deField.value()); JSONObject auditFieldObj = new JSONObject();
auditFieldObj.put("value",value); auditFieldObj.put("field", deField.value());
if(!StringUtils.isEmpty(deField.dict())){ auditFieldObj.put("value", value);
auditFieldObj.put("dict",deField.dict()); if(!StringUtils.isEmpty(deField.dict())) {
auditFieldObj.put("dict", deField.dict());
} }
auditFieldArray.add(auditFieldObj); auditFieldArray.add(auditFieldObj);
} }
} }
if(auditFieldArray.size()>0){ if(auditFieldArray.size()>0) {
auditResult=auditFieldArray.toString(); auditResult = auditFieldArray.toString();
} }
return auditResult; return auditResult;
} }
...@@ -179,41 +186,44 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -179,41 +186,44 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
* @return * @return
*/ */
private String getUpdateAuditInfo(EntityBase oldData, EntityBase newData, Map<String, Audit> auditFields){ private String getUpdateAuditInfo(EntityBase oldData, EntityBase newData, Map<String, Audit> auditFields){
String auditResult=""; String auditResult = "";
JSONArray auditFieldArray=new JSONArray(); JSONArray auditFieldArray = new JSONArray();
if(auditFields.size()==0) if(auditFields.size() == 0) {
return auditResult; return auditResult;
}
Map<String, DEField> deFields= DEFieldCacheMap.getDEFields(oldData.getClass()); Map<String, DEField> deFields = DEFieldCacheMap.getDEFields(oldData.getClass());
if(deFields.size()==0) if(deFields.size() == 0){
return auditResult; return auditResult;
}
for (Map.Entry<String, Audit> auditField : auditFields.entrySet()) { for (Map.Entry<String, Audit> auditField : auditFields.entrySet()) {
Object objFieldName=auditField.getKey();//获取注解字段 Object objFieldName = auditField.getKey();//获取注解字段
String fieldName=String.valueOf(objFieldName); //属性名称 String fieldName = String.valueOf(objFieldName); //属性名称
DEField deField=null; DEField deField = null;
if(deFields.containsKey(fieldName)){ if(deFields.containsKey(fieldName)) {
deField= deFields.get(fieldName); deField = deFields.get(fieldName);
} }
if(ObjectUtils.isEmpty(deField)) if(ObjectUtils.isEmpty(deField)) {
continue; continue;
Object oldValue=oldData.get(fieldName);//老属性值 }
Object newValue=newData.get(fieldName);//新属性值 Object oldValue = oldData.get(fieldName);//老属性值
if(!compare(oldValue,newValue)){ Object newValue = newData.get(fieldName);//新属性值
oldValue=dataTransfer(oldValue,deField.fieldType(),deField.format());//属性值转换 if(!compare(oldValue, newValue)) {
newValue=dataTransfer(newValue,deField.fieldType(),deField.format());//属性值转换 oldValue = dataTransfer(oldValue, deField.fieldType(), deField.format());//属性值转换
JSONObject auditFieldObj=new JSONObject(); newValue = dataTransfer(newValue, deField.fieldType(), deField.format());//属性值转换
auditFieldObj.put("field",deField.value()); JSONObject auditFieldObj = new JSONObject();
auditFieldObj.put("beforevalue",oldValue); auditFieldObj.put("field", deField.value());
auditFieldObj.put("value",newValue); auditFieldObj.put("beforevalue", oldValue);
if(!StringUtils.isEmpty(deField.dict())){ auditFieldObj.put("value", newValue);
auditFieldObj.put("dict",deField.dict()); if(!StringUtils.isEmpty(deField.dict())) {
auditFieldObj.put("dict", deField.dict());
} }
auditFieldArray.add(auditFieldObj); auditFieldArray.add(auditFieldObj);
} }
} }
if(auditFieldArray.size()>0){ if(auditFieldArray.size()>0) {
auditResult=auditFieldArray.toString(); auditResult = auditFieldArray.toString();
} }
return auditResult; return auditResult;
} }
...@@ -225,15 +235,16 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -225,15 +235,16 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
* @param strFormat 转换字段格式化文本 * @param strFormat 转换字段格式化文本
* @return * @return
*/ */
private String dataTransfer(Object value,String dataType, String strFormat){ private String dataTransfer(Object value, String dataType, String strFormat) {
if(value==null) if(value==null) {
return ""; return "";
}
String transResult=value.toString(); String transResult=value.toString();
if((dataType.equals("DATE") || dataType.equals("DATETIME") || dataType.equals("TIME")) && (!StringUtils.isEmpty(strFormat))){ //时间类型转换 if((dataType.equals("DATE") || dataType.equals("DATETIME") || dataType.equals("TIME")) && (!StringUtils.isEmpty(strFormat))) { //时间类型转换
Timestamp timestamp =(Timestamp)value; Timestamp timestamp = (Timestamp)value;
Date date =timestamp; Date date = timestamp;
SimpleDateFormat format =new SimpleDateFormat(strFormat); SimpleDateFormat format = new SimpleDateFormat(strFormat);
transResult=format.format(date); transResult = format.format(date);
} }
return transResult; return transResult;
} }
...@@ -244,11 +255,13 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -244,11 +255,13 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
* @param targetObj 比较目标对象 * @param targetObj 比较目标对象
* @return * @return
*/ */
private boolean compare(Object sourceObj,Object targetObj){ private boolean compare(Object sourceObj, Object targetObj) {
if(sourceObj==null && targetObj==null) if(sourceObj == null && targetObj == null) {
return true; return true;
if(sourceObj==null && targetObj!=null) }
if(sourceObj == null && targetObj != null) {
return false; return false;
}
return sourceObj.equals(targetObj); return sourceObj.equals(targetObj);
} }
...@@ -259,9 +272,9 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -259,9 +272,9 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
* @return * @return
*/ */
@SneakyThrows @SneakyThrows
private EntityBase getEntity(Object service, Object id){ private EntityBase getEntity(Object service, Object id) {
EntityBase entity=null; EntityBase entity = null;
if(!ObjectUtils.isEmpty(service)){ if(!ObjectUtils.isEmpty(service)) {
EvaluationContext oldContext = new StandardEvaluationContext(); EvaluationContext oldContext = new StandardEvaluationContext();
oldContext.setVariable("service",service); oldContext.setVariable("service",service);
oldContext.setVariable("id",id); oldContext.setVariable("id",id);
...@@ -278,14 +291,15 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -278,14 +291,15 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
*/ */
public String getIpAddress(HttpServletRequest request, AuthenticationUser authenticationUser) { public String getIpAddress(HttpServletRequest request, AuthenticationUser authenticationUser) {
//客户端有提交ip,以提交的ip为准 //客户端有提交ip,以提交的ip为准
if(authenticationUser != null && !StringUtils.isEmpty(authenticationUser.getAddr())){ if(authenticationUser != null && !StringUtils.isEmpty(authenticationUser.getAddr())) {
return authenticationUser.getAddr(); return authenticationUser.getAddr();
} }
if(request == null) if(request == null) {
return ""; return "";
}
String Xip = request.getHeader("X-Real-IP"); String Xip = request.getHeader("X-Real-IP");
String XFor = request.getHeader("X-Forwarded-For"); String XFor = request.getHeader("X-Forwarded-For");
if(!StringUtils.isEmpty(XFor) && !"unKnown".equalsIgnoreCase(XFor)){ if(!StringUtils.isEmpty(XFor) && !"unKnown".equalsIgnoreCase(XFor)) {
//多次反向代理后会有多个ip值,第一个ip才是真实ip //多次反向代理后会有多个ip值,第一个ip才是真实ip
int index = XFor.indexOf(","); int index = XFor.indexOf(",");
if(index != -1){ if(index != -1){
...@@ -295,7 +309,7 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -295,7 +309,7 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
} }
} }
XFor = Xip; XFor = Xip;
if(!StringUtils.isEmpty(XFor) && !"unKnown".equalsIgnoreCase(XFor)){ if(!StringUtils.isEmpty(XFor) && !"unKnown".equalsIgnoreCase(XFor)) {
return XFor; return XFor;
} }
if (StringUtils.isEmpty(XFor) || "unknown".equalsIgnoreCase(XFor)) { if (StringUtils.isEmpty(XFor) || "unknown".equalsIgnoreCase(XFor)) {
......
...@@ -26,20 +26,21 @@ public class SimpleFileService implements FileService { ...@@ -26,20 +26,21 @@ public class SimpleFileService implements FileService {
@Override @Override
public FileItem saveFile(MultipartFile multipartFile) { public FileItem saveFile(MultipartFile multipartFile) {
FileItem item=null; FileItem item = null;
// 获取文件名 // 获取文件名
String fileName = multipartFile.getOriginalFilename(); String fileName = multipartFile.getOriginalFilename();
// 获取文件后缀 // 获取文件后缀
String extname="."+getExtensionName(fileName); String extname = "."+getExtensionName(fileName);
try { try {
String fileid= DigestUtils.md5DigestAsHex(multipartFile.getInputStream()); String fileid = DigestUtils.md5DigestAsHex(multipartFile.getInputStream());
String fileFullPath = this.fileRoot+"ibizutil"+File.separator+fileid+File.separator+fileName; String fileFullPath = this.fileRoot+"ibizutil"+File.separator+fileid+File.separator+fileName;
File file = new File(fileFullPath); File file = new File(fileFullPath);
File parent = new File(file.getParent()); File parent = new File(file.getParent());
if(!parent.exists()) if(!parent.exists()) {
parent.mkdirs(); parent.mkdirs();
FileCopyUtils.copy(multipartFile.getInputStream(),Files.newOutputStream(file.toPath())); }
item=new FileItem(fileid,fileName,fileid,fileName,(int)multipartFile.getSize(),extname); FileCopyUtils.copy(multipartFile.getInputStream(), Files.newOutputStream(file.toPath()));
item = new FileItem(fileid, fileName, fileid, fileName, (int)multipartFile.getSize(), extname);
} catch (IOException e) { } catch (IOException e) {
throw new InternalServerErrorException("文件上传失败,"+e); throw new InternalServerErrorException("文件上传失败,"+e);
} }
......
...@@ -27,19 +27,19 @@ import org.springframework.security.core.authority.AuthorityUtils; ...@@ -27,19 +27,19 @@ import org.springframework.security.core.authority.AuthorityUtils;
@Primary @Primary
@Service("SimpleUserService") @Service("SimpleUserService")
@ConditionalOnExpression("(!${r'${ibiz.enablePermissionValid:false}'})&&'${r'${ibiz.auth.service:'}<#if sys.getPSSystemSetting()?? && sys.getPSSystemSetting().getDataAccCtrlArch()?? && sys.getPSSystemSetting().getDataAccCtrlArch()==1>IBZUAAUserService<#else>SimpleUserService</#if>${r'}'}'.equals('SimpleUserService')") @ConditionalOnExpression("(!${r'${ibiz.enablePermissionValid:false}'})&&'${r'${ibiz.auth.service:'}<#if sys.getPSSystemSetting()?? && sys.getPSSystemSetting().getDataAccCtrlArch()?? && sys.getPSSystemSetting().getDataAccCtrlArch()==1>IBZUAAUserService<#else>SimpleUserService</#if>${r'}'}'.equals('SimpleUserService')")
public class SimpleUserService implements AuthenticationUserService{ public class SimpleUserService implements AuthenticationUserService {
@Override @Override
public AuthenticationUser loadUserByUsername(String username) { public AuthenticationUser loadUserByUsername(String username) {
AuthenticationUser user = new AuthenticationUser(); AuthenticationUser user = new AuthenticationUser();
String[] data=username.split("[|]"); String[] data = username.split("[|]");
String loginname=username; String loginname = username;
String domains=""; String domains = "";
String password=""; String password = "";
if(data.length==2) { if(data.length==2) {
loginname=data[0].trim(); loginname = data[0].trim();
domains=data[1].trim(); domains = data[1].trim();
} }
user.setUserid(username); user.setUserid(username);
......
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#if sys.codeName == 'Sample'>
package ${pub.getPKGCodeName()}.util.service;
import ${pub.getPKGCodeName()}.util.annotation.ValueRuleCheck;
import ${pub.getPKGCodeName()}.util.domain.DTOBase;
import ${pub.getPKGCodeName()}.util.domain.ValueRule;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.util.ObjectUtils;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.HashMap;
import java.util.Map;
public class ValueRuleValidator implements ConstraintValidator<ValueRuleCheck, DTOBase> {
private static Map<String, ValueRule> sysRule = new HashMap<>();
private final ExpressionParser parser = new SpelExpressionParser();
private String field;
private String ruleName;
@Override
public void initialize(ValueRuleCheck constraintAnnotation) {
this.field = constraintAnnotation.field();
this.ruleName = constraintAnnotation.rule();
}
@Override
public boolean isValid(DTOBase dto, ConstraintValidatorContext context) {
if (!ObjectUtils.isEmpty(dto) && !ObjectUtils.isEmpty(ruleName) && !ObjectUtils.isEmpty(sysRule.get(ruleName)) && !ObjectUtils.isEmpty(dto.get(field))) {
ValueRule rule = sysRule.get(ruleName);
String ruleCond = rule.getCond();
String ruleMessage = rule.getMessage();
EvaluationContext searchContextCtx = new StandardEvaluationContext();
searchContextCtx.setVariable("dto", dto);
Expression searchContextExp = parser.parseExpression(ruleCond);
boolean isValid = searchContextExp.getValue(searchContextCtx, Boolean.class);
if (!isValid) {
context.disableDefaultConstraintViolation();
context.buildConstraintViolationWithTemplate(String.format("执行[%s]属性[%s]值规则发生异常,%s", field, ruleName, ruleMessage))
.addConstraintViolation();
return false;
}
}
return true;
}
static {
<#if sys.getAllPSDataEntities()??>
<#list sys.getAllPSDataEntities() as de>
<#if de.getAllPSDEFValueRules()??>
<#list de.getAllPSDEFValueRules() as deRule>
<#if deRule.codeName!='Default'>
<#if deRule.getPSDEFVRGroupCondition()??>
<#assign group=deRule.getPSDEFVRGroupCondition()>
<#assign ruleName=(de.codeName+"_"+deRule.getPSDEField().codeName+"_"+deRule.codeName)?lower_case>
<#assign ruleCond=getGroupCond(group)>
<#assign ruleMessage=getGroupMessage(group)>
<#if ruleCond!="">
sysRule.put("${ruleName}", new ValueRule("${ruleCond}","${ruleMessage}"));
</#if>
</#if>
</#if>
</#list>
</#if>
</#list>
</#if>
}
}
</#if>
<#comment>获取组条件表达式</#comment>
<#function getGroupCond group>
<#assign strRuleCond="">
<#if group.getPSDEFVRConditions()??>
<#assign condOp=group.getCondOp()?replace("AND","&&")?replace("OR","||")>
<#list group.getPSDEFVRConditions() as childRule>
<#assign childRuleType=childRule.getCondType()>
<#if childRuleType=='GROUP'>
<#assign strRuleCond=strRuleCond+getGroupCond(childRule)>
<#else>
<#assign strRuleCond=strRuleCond+getFieldCond(childRule)>
</#if>
<#if childRule_has_next>
<#assign strRuleCond=strRuleCond+condOp>//拼接连接符
</#if>
</#list>
</#if>
<#if strRuleCond!="">
<#assign strRuleCond="("+strRuleCond+")">
</#if>
<#return strRuleCond/>
</#function>
<#comment>获取单项条件表达式</#comment>
<#function getFieldCond fieldRule>
<#assign childRuleType=fieldRule.getCondType()>
<#assign fieldCond="(" >
<#assign condBody="1==1">
<#comment>常规规则</#comment>
<#if childRuleType=='SIMPLE'>
<#assign targetFieldName=fieldRule.getDEFName()><#comment>目标属性名称</#comment>
<#assign targetDEField=((de.getPSDEField(targetFieldName,true))!'')><#comment>目标属性</#comment>
<#assign targetDBValueOP=fieldRule.getCondOp()><#comment>表达式</#comment>
<#assign targetValue=((fieldRule.getParamValue())!'')><#comment>值项</#comment>
<#if targetDEField!=''>
<#assign targetFieldName=srfcaseformat(targetDEField.codeName,'l_u2lC')>
</#if>
<#assign condBody="T(${pub.getPKGCodeName()}.util.helper.RuleUtils).test(#dto.get(\\\""+targetFieldName+"\\\"),\\\""+targetDBValueOP+"\\\","+"\\\""+targetValue+"\\\")">
</#if>
<#assign fieldCond=fieldCond+condBody >
<#assign fieldCond=fieldCond+")" >
<#return fieldCond/>
</#function>
<#comment>获取group规则信息</#comment>
<#function getGroupMessage group>
<#assign ruleMessage="(">
<#if group.getPSDEFVRConditions()??>
<#assign op=group.getCondOp()?replace("AND","并且")?replace("OR","或者")>
<#list group.getPSDEFVRConditions() as childRule>
<#assign childRuleType=childRule.getCondType()>
<#if childRuleType=='GROUP'>
<#assign ruleMessage=ruleMessage+getGroupMessage(childRule)>
<#else>
<#assign ruleMessage=ruleMessage+getFieldMessage(childRule)>
</#if>
<#if childRule_has_next>
<#assign ruleMessage=ruleMessage+op>
</#if>
</#list>
</#if>
<#assign ruleMessage=ruleMessage+")">
<#return ruleMessage/>
</#function>
<#comment>获取field规则信息</#comment>
<#function getFieldMessage fieldRule>
<#assign fieldMessage="">
<#if fieldRule.getRuleInfo?? && fieldRule.getRuleInfo()??>
<#assign fieldMessage=fieldRule.getRuleInfo()>
</#if>
<#return fieldMessage/>
</#function>
\ No newline at end of file
...@@ -32,8 +32,9 @@ public class FeignRequestInterceptor implements RequestInterceptor { ...@@ -32,8 +32,9 @@ public class FeignRequestInterceptor implements RequestInterceptor {
if (headerNames != null) { if (headerNames != null) {
while (headerNames.hasMoreElements()) { while (headerNames.hasMoreElements()) {
String name = headerNames.nextElement(); String name = headerNames.nextElement();
if(name.equalsIgnoreCase("transfer-encoding")) if(name.equalsIgnoreCase("transfer-encoding")){
continue; continue;
}
String values = request.getHeader(name); String values = request.getHeader(name);
requestTemplate.header(name, values); requestTemplate.header(name, values);
} }
......
...@@ -52,19 +52,19 @@ public class IBZOperationParameterReader implements OperationBuilderPlugin { ...@@ -52,19 +52,19 @@ public class IBZOperationParameterReader implements OperationBuilderPlugin {
public IBZOperationParameterReader( public IBZOperationParameterReader(
ModelAttributeParameterExpander expander, ModelAttributeParameterExpander expander,
EnumTypeDeterminer enumTypeDeterminer) { EnumTypeDeterminer enumTypeDeterminer) {
this.expander = expander; this.expander = expander;
this.enumTypeDeterminer = enumTypeDeterminer; this.enumTypeDeterminer = enumTypeDeterminer;
} }
@Override @Override
public void apply(OperationContext context) { public void apply(OperationContext context) {
context.operationBuilder().parameters(context.getGlobalOperationParameters()); context.operationBuilder().parameters(context.getGlobalOperationParameters());
context.operationBuilder().parameters(readParameters(context)); context.operationBuilder().parameters(readParameters(context));
} }
@Override @Override
public boolean supports(DocumentationType delimiter) { public boolean supports(DocumentationType delimiter) {
return true; return true;
} }
private List<Parameter> readParameters(final OperationContext context) { private List<Parameter> readParameters(final OperationContext context) {
......
...@@ -34,17 +34,14 @@ public class SearchContextHandlerMethodArgumentResolver implements HandlerMethod ...@@ -34,17 +34,14 @@ public class SearchContextHandlerMethodArgumentResolver implements HandlerMethod
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
Map<String, String[]> params = webRequest.getParameterMap(); Map<String, String[]> params = webRequest.getParameterMap();
LinkedHashMap<String,Object> set=new LinkedHashMap<>(); LinkedHashMap<String,Object> set = new LinkedHashMap<>();
for (String key : params.keySet()) { for (String key : params.keySet()) {
set.put(key,params.get(key)[0]); set.put(key,params.get(key)[0]);
} }
if((!set.containsKey("size")) ){ if((!set.containsKey("size")) ){
set.put("size",pageLimit); set.put("size", pageLimit);
} }
String json=objectMapper.writeValueAsString(set); String json = objectMapper.writeValueAsString(set);
return objectMapper.readValue(json,parameter.getParameterType()); return objectMapper.readValue(json, parameter.getParameterType());
} }
} }
\ No newline at end of file
...@@ -354,6 +354,12 @@ seata: ...@@ -354,6 +354,12 @@ seata:
<#macro dynamicDatasourceConfig> <#macro dynamicDatasourceConfig>
datasource: datasource:
username: ${dbUserName}
password: '${dbPassWord}'
url: ${dbUrl}
driver-class-name: ${dbDriver}
isSyncDBSchema: false
defaultSchema: <#if dbUserName=='root'>${sys.name}<#else>${dbUserName}</#if>
dynamic: dynamic:
druid: #以下是全局默认值,可以全局更改 druid: #以下是全局默认值,可以全局更改
filters: stat,wall,log4j2 filters: stat,wall,log4j2
...@@ -376,25 +382,25 @@ seata: ...@@ -376,25 +382,25 @@ seata:
max-pool-prepared-statement-per-connection-size: 20 max-pool-prepared-statement-per-connection-size: 20
datasource: datasource:
master: master:
username: ${dbUserName} username: ${r'${spring.datasource.username}'}
password: '${dbPassWord}' password: ${r'${spring.datasource.password}'}
url: ${dbUrl} url: ${r'${spring.datasource.url}'}
driver-class-name: ${dbDriver} driver-class-name: ${r'${spring.datasource.driver-class-name}'}
conf: classpath:liquibase/master.xml conf: classpath:liquibase/master.xml
isSyncDBSchema: false isSyncDBSchema: ${r'${spring.datasource.isSyncDBSchema}'}
defaultSchema: <#if dbUserName=='root'>${sys.name}<#else>${dbUserName}</#if> defaultSchema: ${r'${spring.datasource.defaultSchema}'}
<#list sys.getAllPSDataEntities() as entity> <#list sys.getAllPSDataEntities() as entity>
<#if (entity.getStorageMode()==1 || entity.getStorageMode()==2) && entity.getDSLink()!='DEFAULT'> <#if (entity.getStorageMode()==1 || entity.getStorageMode()==2) && entity.getDSLink()!='DEFAULT'>
<#assign dbLink=entity.getDSLink()?lower_case> <#assign dbLink=entity.getDSLink()?lower_case>
<#if !P.exists('dynamicDatasource',dbLink)> <#if !P.exists('dynamicDatasource',dbLink)>
${dbLink}: ${dbLink}:
username: ${dbUserName} username: ${r'${spring.datasource.username}'}
password: '${dbPassWord}' password: ${r'${spring.datasource.password}'}
url: ${dbUrl} url: ${r'${spring.datasource.url}'}
driver-class-name: ${dbDriver} driver-class-name: ${r'${spring.datasource.driver-class-name}'}
conf: classpath:liquibase/master.xml conf: classpath:liquibase/master.xml
isSyncDBSchema: false isSyncDBSchema: ${r'${spring.datasource.isSyncDBSchema}'}
defaultSchema: <#if dbUserName=='root'>${sys.name}<#else>${dbUserName}</#if> defaultSchema: ${r'${spring.datasource.defaultSchema}'}
</#if> </#if>
</#if> </#if>
</#list> </#list>
......
...@@ -15,3 +15,4 @@ TARGET=PSSYSTEM ...@@ -15,3 +15,4 @@ TARGET=PSSYSTEM
**.iml **.iml
*.jar *.jar
*.log *.log
.DS_Store
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册