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

合并分支 'dev' 到 '2020.10.28【673】'

Dev

查看合并请求 !39
# **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>
......
...@@ -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>
......
...@@ -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);
} }
......
...@@ -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());
} }
} }
<#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
...@@ -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
...@@ -15,3 +15,4 @@ TARGET=PSSYSTEM ...@@ -15,3 +15,4 @@ TARGET=PSSYSTEM
**.iml **.iml
*.jar *.jar
*.log *.log
.DS_Store
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册