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

合并分支 'dev' 到 'master'

Dev

查看合并请求 !38
# **iBiz4j Spring R7 Template ChangeLog**
## [v2020.12.13]
- 支持工作流操作视图、操作表单配置
- 支持实体数据同步(RocketMQ)
- 支持工作流流程中状态值配置
- 支持父关系等价
- 支持属性值规则
- 支持界面行为多项数据主键
- 支持token续期
- 优化:补充接口实体服务接口鉴权
- 优化:动态数据源数据连接配置优化
- 优化:数据查询支持请求方式配置(默认为get,如:改为post)
- 优化:实体搜索项是否为空配置(搭配是否逻辑代码表使用)
- 优化:微服务部署中支持配置portmap将容器端口映射到主机端口(用于定时服务回调)
- 修复:服务接口返回状态码 response code
- 修复:实体行为、逻辑支持行为所有者配置
## [v2020.11.09]
- 支持属性重复值检查
- 支持引用组件包配置
......
......@@ -55,13 +55,13 @@ import java.util.List;
com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure.class
</#if>
})
public class ${app.getPKGCodeName()}Application extends WebMvcConfigurerAdapter{
public class ${app.getPKGCodeName()}Application extends WebMvcConfigurerAdapter {
@Autowired
SearchContextHandlerMethodArgumentResolver resolver;
public static void main(String[] args) {
SpringApplication.run(${app.getPKGCodeName()}Application.class,args);
SpringApplication.run(${app.getPKGCodeName()}Application.class, args);
}
@Override
......
......@@ -115,10 +115,10 @@ public class ${app.getPKGCodeName()}SecurityConfig extends WebSecurityConfigurer
"/**/svg/**",
"/"
).permitAll()
//放行登录请求
.antMatchers( HttpMethod.POST,"/"+loginPath).permitAll()
//放行注销请求
.antMatchers( HttpMethod.GET,"/"+logoutPath).permitAll()
// 放行登录请求
.antMatchers( HttpMethod.POST, "/"+loginPath).permitAll()
// 放行注销请求
.antMatchers( HttpMethod.GET, "/"+logoutPath).permitAll()
// 文件操作
.antMatchers("/"+downloadpath+"/**").permitAll()
.antMatchers("/"+uploadpath).permitAll()
......
......@@ -50,8 +50,8 @@ import org.springframework.beans.factory.annotation.Autowired;
</#if>
})
@ComponentScan(basePackages = {"${pub.getPKGCodeName()}"}
// ,excludeFilters={
// @ComponentScan.Filter(type= org.springframework.context.annotation.FilterType.REGEX,pattern="${pub.getPKGCodeName()}.xxx.rest.xxx"),
// ,excludeFilters = {
// @ComponentScan.Filter(type= org.springframework.context.annotation.FilterType.REGEX, pattern="${pub.getPKGCodeName()}.xxx.rest.xxx"),
// }
)
@Import({
......@@ -59,13 +59,13 @@ import org.springframework.beans.factory.annotation.Autowired;
})
@EnableAsync
@EnableScheduling
public class DevBootApplication extends WebMvcConfigurerAdapter{
public class DevBootApplication extends WebMvcConfigurerAdapter {
@Autowired
SearchContextHandlerMethodArgumentResolver resolver;
public static void main(String[] args) {
SpringApplication.run(DevBootApplication.class,args);
SpringApplication.run(DevBootApplication.class, args);
}
@Override
......
......@@ -113,9 +113,9 @@ public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter {
"/v2/**"
).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("/"+uploadpath).permitAll()
......
......@@ -31,7 +31,7 @@ import org.springframework.stereotype.Component;
* 实体[${item.codeName}] 服务对象接口
*/
@Component
public class ${item.codeName}Fallback implements ${item.codeName}FeignClient{
public class ${item.codeName}Fallback implements ${item.codeName}FeignClient {
<#if item.getPSSubSysServiceAPIDEMethods()??>
<#list item.getPSSubSysServiceAPIDEMethods() as apiMethod>
......@@ -46,44 +46,44 @@ 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>); -->
<#if apiMethod.getCodeName()?lower_case == 'get'>
<#--@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;
}
<#elseif apiMethod.getCodeName()?lower_case == 'remove'>
<#--@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;
}
<#--@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;
}
<#elseif apiMethod.getCodeName()?lower_case == 'create'>
<#--@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;
}
<#--@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;
}
<#elseif apiMethod.getCodeName()?lower_case == 'save'>
<#--@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;
}
<#--@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;
}
<#elseif apiMethod.getCodeName()?lower_case == 'update'>
<#--@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;
}
<#--@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;
}
......@@ -94,7 +94,7 @@ public class ${item.codeName}Fallback implements ${item.codeName}FeignClient{
<#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;
}
......@@ -104,24 +104,24 @@ public class ${item.codeName}Fallback implements ${item.codeName}FeignClient{
<#elseif apiMethod.getCodeName()?lower_case == 'savebatch'>
<#else>
<#--@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;
}
</#if>
<#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>); -->
<#--@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;
}
<#elseif apiMethod.getActionType()=='FETCH'><#comment>数据集合</#comment>
<#--@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;
}
<#elseif apiMethod.getActionType()=='USER'><#comment>用户自定义</#comment>
public void ${apiMethod.getCodeName()?uncap_first}(){
public void ${apiMethod.getCodeName()?uncap_first}() {
return null;
}
</#if>
......
......@@ -39,7 +39,13 @@ public class ${item.codeName}SearchContext extends QueryWrapperContext<${item.co
<#if defield.getAllPSDEFSearchModes()??>
<#list defield.getAllPSDEFSearchModes() as formitem>
<#if formitem.getPSDEField()??>
<#assign formItemDataType=srfr7javatype(formitem.getPSDEField().stdDataType)>
<#assign defDataType=formitem.getPSDEField().getDataType()>
<#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")
@JSONField(format="yyyy-MM-dd HH:mm:ss")
......@@ -50,10 +56,6 @@ public class ${item.codeName}SearchContext extends QueryWrapperContext<${item.co
@JsonFormat(pattern="HH:mm", timezone="GMT+8")
@JSONField(format="HH:mm")
</#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()}]
public void set${formitem.getName()?lower_case?cap_first}(${formItemDataType} ${formitem.getName()?lower_case}) {
......@@ -78,11 +80,11 @@ public class ${item.codeName}SearchContext extends QueryWrapperContext<${item.co
<#elseif formitem.getValueOp() == "LTANDEQ">
this.getSearchCond().le("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#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}");
}
<#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}");
}
<#elseif formitem.getValueOp() == "IN">
......@@ -106,6 +108,7 @@ public class ${item.codeName}SearchContext extends QueryWrapperContext<${item.co
/**
* 启用快速搜索
*/
@Override
public void setQuery(String query)
{
this.query=query;
......@@ -150,7 +153,13 @@ public class ${item.codeName}SearchContext extends QueryBuildContext {
<#if defield.getAllPSDEFSearchModes()??>
<#list defield.getAllPSDEFSearchModes() as formitem>
<#if formitem.getPSDEField()??>
<#assign formItemDataType=srfr7javatype(formitem.getPSDEField().stdDataType)>
<#assign defDataType=formitem.getPSDEField().getDataType()>
<#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")
@JSONField(format="yyyy-MM-dd HH:mm:ss")
......@@ -161,10 +170,6 @@ public class ${item.codeName}SearchContext extends QueryBuildContext {
@JsonFormat(pattern="HH:mm", timezone="GMT+8")
@JSONField(format="HH:mm")
</#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()}]
public void set${formitem.getName()?lower_case?cap_first}(${formItemDataType} ${formitem.getName()?lower_case}) {
......@@ -192,11 +197,11 @@ public class ${item.codeName}SearchContext extends QueryBuildContext {
<#elseif formitem.getValueOp() == "LTANDEQ">
this.getSearchCond().and("${formitem.getPSDEField().getName()?lower_case}").lessThanEquals(${formitem.getName()?lower_case});
<#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);
}
<#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);
}
<#elseif formitem.getValueOp() == "IN">
......@@ -261,7 +266,7 @@ public class ${item.codeName}SearchContext extends SearchContextBase {
</#if>
<#assign formItemDataType=srfr7javatype(formitem.getPSDEField().stdDataType)>
<#comment>in条件通过String接,通过split拆后再进行查询</#comment>
<#if formitem.getValueOp() == "IN">
<#if formitem.getValueOp() == "IN" || formitem.getValueOp() == "ISNULL" || formitem.getValueOp() == "ISNOTNULL">
<#assign formItemDataType="String">
</#if>
private ${formItemDataType} ${formitem.getName()?lower_case};//[${defield.getLogicName()}]
......@@ -298,7 +303,7 @@ public class ${item.codeName}SearchContext extends SearchContextBase {
</#if>
<#assign formItemDataType=srfr7javatype(formitem.getPSDEField().stdDataType)>
<#comment>in条件通过String接,通过split拆后再进行查询</#comment>
<#if formitem.getValueOp() == "IN">
<#if formitem.getValueOp() == "IN" || formitem.getValueOp() == "ISNULL" || formitem.getValueOp() == "ISNOTNULL">
<#assign formItemDataType="String">
</#if>
private ${formItemDataType} ${formitem.getName()?lower_case};//[${defield.getLogicName()}]
......
......@@ -26,37 +26,37 @@ import com.alibaba.fastjson.JSONObject;
@com.baomidou.dynamic.datasource.annotation.DS("${item.getDSLink()?lower_case}")
</#if>
</#if>
public interface ${item.getCodeName()}Mapper extends BaseMapper<${item.getCodeName()}>{
public interface ${item.getCodeName()}Mapper extends BaseMapper<${item.getCodeName()}> {
<#if item.getAllPSDEDataSets()??>
<#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>
</#if>
<#assign keyfieldCodeName=item.getKeyPSDEField().codeName?lower_case>
@Override
<#if item.isEnableEntityCache()==true>
@Cacheable( value="${item.codeName?lower_case}",key = "'row:'+#p0")
@Cacheable(value ="${item.codeName?lower_case}", key = "'row:'+#p0")
</#if>
${item.getCodeName()} selectById(Serializable id);
@Override
<#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>
int insert(${item.getCodeName()} entity);
@Override
<#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>
int updateById(@Param(Constants.ENTITY) ${item.getCodeName()} entity);
@Override
<#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>
int update(@Param(Constants.ENTITY) ${item.getCodeName()} entity, @Param("ew") Wrapper<${item.codeName}> updateWrapper);
@Override
<#if item.isEnableEntityCache()==true>
@CacheEvict( value="${item.codeName?lower_case}",key = "'row:'+#p0")
@CacheEvict(value ="${item.codeName?lower_case}", key = "'row:'+#p0")
</#if>
int deleteById(Serializable id);
/**
......@@ -104,7 +104,7 @@ public interface ${item.getCodeName()}Mapper extends BaseMapper<${item.getCodeNa
<#if de.getDefaultPSDEDataSet()??>
<#assign deDefaultDataSet=de.getDefaultPSDEDataSet()>
<#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>
......
......@@ -12,11 +12,11 @@ public interface ${de.codeName}${item.codeName} {
<#assign keyFieldName=srfcaseformat(de.getKeyPSDEField().getCodeName(),'l_u2lC')>
<#if item.getPSDEDataImportItems?? && item.getPSDEDataImportItems()??>
@Mappings({
@Mapping(target = "${keyFieldName}",source = "${keyFieldName}"),
@Mapping(target = "${keyFieldName}", source = "${keyFieldName}"),
<#list item.getPSDEDataImportItems() as importItem>
<#if importItem.getPSDEField()?? && importItem.getPSDEField().isKeyDEField()==false>
<#assign deFieldName = srfcaseformat(importItem.getPSDEField().getCodeName(),'l_u2lC')>
@Mapping(target = "${deFieldName}",source = "${deFieldName}"),
@Mapping(target = "${deFieldName}", source = "${deFieldName}"),
</#if>
</#list>
})
......
......@@ -44,7 +44,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
/**
* 实体[${item.codeName}] 服务对象接口
*/
public interface I${item.codeName}Service extends IService<${item.codeName}>{
public interface I${item.codeName}Service extends IService<${item.codeName}> {
<@addIDESerivceBody />
/**
......@@ -63,8 +63,8 @@ public interface I${item.codeName}Service extends IService<${item.codeName}>{
boolean execute(String sql, Map param);
<#if hasDEPrefield>
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}ByIds(List<${srfr7javatype(keyfield.stdDataType)}> ids);
List<${de.codeName}> get${deCodeNameCamel}ByEntities(List<${de.codeName}> entities);
</#if>
}
<#comment>NoSQL存储-MongoDB</#comment>
......@@ -73,13 +73,13 @@ public interface I${item.codeName}Service extends IService<${item.codeName}>{
/**
* 实体[${item.codeName}] 服务对象接口
*/
public interface I${item.codeName}Service{
public interface I${item.codeName}Service {
<@addIDESerivceBody />
<#if hasDEPrefield>
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}ByIds(List<${srfr7javatype(keyfield.stdDataType)}> ids);
List<${de.codeName}> get${deCodeNameCamel}ByEntities(List<${de.codeName}> entities);
</#if>
}
......@@ -88,7 +88,7 @@ public interface I${item.codeName}Service{
/**
* 实体[${item.codeName}] 服务对象接口
*/
public interface I${item.codeName}Service{
public interface I${item.codeName}Service {
<@addIDESerivceBody />
......@@ -99,7 +99,7 @@ public interface I${item.codeName}Service{
/**
* 实体[${item.codeName}] 服务对象接口
*/
public interface I${item.codeName}Service{
public interface I${item.codeName}Service {
<@addIDESerivceBody />
......@@ -114,45 +114,46 @@ public interface I${item.codeName}Service{
<#list item.getAllPSDEActions() as deaction>
<#if deaction.isEnableBackend()>
<#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'>
${item.codeName} ${srfmethodname(deaction.getCodeName())}(${item.codeName} et) ;
${item.codeName} ${srfmethodname(deaction.getCodeName())}(${item.codeName} et);
<#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">
boolean create(${item.codeName} et) ;
boolean create(${item.codeName} et);
<#if item.isEnableEntityCache()==true>
@CacheEvict(value="${item.codeName?lower_case}",allEntries=true)
@CacheEvict(value = "${item.codeName?lower_case}", allEntries = true)
</#if>
void createBatch(List<${item.codeName}> list) ;
void createBatch(List<${item.codeName}> list);
<#elseif deaction.codeName?lower_case == "update">
boolean update(${item.codeName} et) ;
boolean update(${item.codeName} et);
<#if item.isEnableEntityCache()==true>
@CacheEvict(value="${item.codeName?lower_case}",allEntries=true)
@CacheEvict(value = "${item.codeName?lower_case}", allEntries = true)
</#if>
void updateBatch(List<${item.codeName}> list) ;
void updateBatch(List<${item.codeName}> list);
<#elseif deaction.codeName?lower_case == "remove">
boolean remove(${srfr7javatype(keyfield.stdDataType)} key) ;
boolean remove(${srfr7javatype(keyfield.stdDataType)} key);
<#if item.isEnableEntityCache()==true>
@CacheEvict(value="${item.codeName?lower_case}",allEntries=true)
@CacheEvict(value = "${item.codeName?lower_case}", allEntries = true)
</#if>
void removeBatch(Collection<${srfr7javatype(keyfield.stdDataType)}> idList) ;
void removeBatch(Collection<${srfr7javatype(keyfield.stdDataType)}> idList);
<#elseif deaction.codeName?lower_case == "save">
boolean save(${item.codeName} et) ;
boolean save(${item.codeName} et);
<#if item.isEnableEntityCache()==true>
@CacheEvict(value="${item.codeName?lower_case}",allEntries=true)
@CacheEvict(value = "${item.codeName?lower_case}",allEntries = true)
</#if>
void saveBatch(List<${item.codeName}> list) ;
void saveBatch(List<${item.codeName}> list);
<#elseif deaction.codeName?lower_case == "getdraft">
${item.codeName} getDraft(${item.codeName} et) ;
${item.codeName} getDraft(${item.codeName} et);
<#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 == "savebatch">
<#elseif deaction.codeName?lower_case == "updatebatch">
<#elseif deaction.codeName?lower_case == "removebatch">
<#else>
${item.codeName} ${srfmethodname(deaction.getCodeName())}(${item.codeName} et) ;
${item.codeName} ${srfmethodname(deaction.getCodeName())}(${item.codeName} et);
</#if>
<@outputTestActionDetail deaction />
</#if>
......@@ -160,7 +161,7 @@ public interface I${item.codeName}Service{
</#if>
<#if item.getAllPSDEDataSets()??>
<#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>
</#if>
<#comment>1N关系中,在子实体中创建父实体的实例对象</#comment>
......@@ -186,13 +187,13 @@ public interface I${item.codeName}Service{
void resetBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(Collection<${srfr7javatype(MajorField.stdDataType)}> ids);
<#elseif MinorPSDER.getRemoveActionType()?c=='1'><#comment>同时删除</#comment>
<#if item.isEnableEntityCache()==true>
@CacheEvict(value="${item.codeName?lower_case}",allEntries=true)
@CacheEvict(value = "${item.codeName?lower_case}", allEntries = true)
</#if>
void removeBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(Collection<${srfr7javatype(MajorField.stdDataType)}> ids);
</#if>
</#if>
<#if item.isEnableEntityCache()==true>
@CacheEvict(value="${item.codeName?lower_case}",allEntries=true)
@CacheEvict(value = "${item.codeName?lower_case}", allEntries = true)
</#if>
void removeBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfr7javatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case});
<#assign nested=MinorPSDER.isNestedRS()>
......@@ -205,9 +206,9 @@ public interface I${item.codeName}Service{
</#if>
<#if nested>
<#if item.isEnableEntityCache()==true>
@CacheEvict(value="${item.codeName?lower_case}",allEntries=true)
@CacheEvict(value = "${item.codeName?lower_case}", allEntries = true)
</#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>
......@@ -219,10 +220,10 @@ public interface I${item.codeName}Service{
</#if>
<#comment>实体数据导入</#comment>
<#if hasDEImport>
JSONObject importData(List<${de.codeName}> entities,int batchSize,boolean isIgnoreError);
JSONObject importData(List<${de.codeName}> entities, int batchSize, boolean isIgnoreError);
@Async("asyncExecutor")
void asyncImportData(List<${de.codeName}> entities,int batchSize,boolean isIgnoreError);
void asyncImportData(List<${de.codeName}> entities, int batchSize, boolean isIgnoreError);
</#if>
</#macro>
......
......@@ -5,19 +5,13 @@ TARGET=PSDELOGIC
<#assign startWF=false>
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.HashMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.kie.api.runtime.KieSession;
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.${de.getPSSystemModule().getCodeName()?lower_case}.domain.${de.getCodeName()};
......@@ -26,7 +20,7 @@ import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower
*/
@Slf4j
@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
private KieContainer kieContainer;
......@@ -65,11 +59,12 @@ public class ${de.codeName}${item.codeName}LogicImpl implements I${de.codeName}$
return this.iBzSysDefaultService;
}
public void execute(${de.codeName} et){
@Override
public void execute(${de.codeName} et) {
KieSession kieSession = null;
try{
kieSession=kieContainer.newKieSession();
try {
kieSession = kieContainer.newKieSession();
<#comment>插入逻辑参数</#comment>
<#if item.getPSDELogicParams?? && item.getPSDELogicParams()??>
<#assign logicName=(de.codeName+item.codeName)?lower_case>
......@@ -80,12 +75,12 @@ public class ${de.codeName}${item.codeName}LogicImpl implements I${de.codeName}$
<#assign paramObjValue="et">
<#elseif logicParam.getParamPSDataEntity?? && 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>
Map ${(logicName+logicParam.codeName)?lower_case} =new HashMap();
Map ${(logicName+logicParam.codeName)?lower_case} = new HashMap();
</#if>
kieSession.insert(${paramObjValue}); <#comment>将逻辑参数存储到fact</#comment>
kieSession.setGlobal("${paramObj}",${paramObjValue});<#comment>将逻辑参数存储到global</#comment>
kieSession.setGlobal("${paramObj}", ${paramObjValue});<#comment>将逻辑参数存储到global</#comment>
</#list>
</#if>
<#comment>插入处理逻辑中所用到的service对象</#comment>
......@@ -93,28 +88,28 @@ public class ${de.codeName}${item.codeName}LogicImpl implements I${de.codeName}$
<#list item.getPSDELogicNodes() as deLogicNode>
<#if deLogicNode.getDstPSDataEntity?? && deLogicNode.getDstPSDataEntity()??>
<#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>
</#list>
</#if>
<#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());
<#comment>插入wfclient</#comment>
<#if startWF>
kieSession.setGlobal("wfClient",wfClient);
kieSession.setGlobal("wfClient", wfClient);
</#if>
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){
throw new RuntimeException("执行[${item.getName()}]处理逻辑发生异常"+e);
} catch (Exception e) {
throw new RuntimeException("执行[${item.getName()}]处理逻辑发生异常" + e);
<#--throw new BadRequestAlertException(""+e,"","");-->
}finally {
if(kieSession!=null)
} finally {
if(kieSession != null) {
kieSession.destroy();
}
}
}
}
</#if>
\ No newline at end of file
......@@ -51,8 +51,15 @@ public class ${item.codeName}ExService extends ${item.codeName}ServiceImpl {
<#list item.getAllPSDEActions() as deaction>
<#if deaction.isEnableBackend()>
<#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
* @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 @@
TARGET=PSSYSTEM
</#ibiztemplate>
{
"systemid":"${sys.getName()}",
"systemid":"${sys.codeName}",
"unires":[
<#if sys.getAllPSSysUniReses()??>
<#list sys.getAllPSSysUniReses() as unires>
......@@ -14,18 +14,22 @@ TARGET=PSSYSTEM
</#list>
</#if>
],
<#if sys.getAllPSApps()??>
<#if sys.getAllPSDataEntities()??>
<#assign ct=0>
"entities":[
<#list sys.getAllPSApps() as app>
<#if app.getAllPSAppDataEntities?? && app.getAllPSAppDataEntities()??>
<#list app.getAllPSAppDataEntities() as appde>
<#assign de=appde.getPSDE()>
<#list sys.getAllPSDataEntities() as de>
<#if de.getAllPSDEServiceAPIs?? && de.getAllPSDEServiceAPIs()??>
<#assign hasDEApi=false>
<#list de.getAllPSDEServiceAPIs() as deapi>
<#assign hasDEApi=true>
<#break>
</#list>
<#if hasDEApi>
<#if !P.exists(de.getCodeName(),"")>
<#if (ct>0)>
,</#if><#assign ct=ct+1>
<#assign dataSetResult=getDataSet()>
<#assign deActionResult=getDEAction()>
<#assign dataSetResult=getDataSet(de)>
<#assign deActionResult=getDEAction(de)>
{
"dename":"${de.codeName}",
"delogicname":"${de.logicName}",
......@@ -35,7 +39,7 @@ TARGET=PSSYSTEM
"datascope":${getDataScope(de)}
}
</#if>
</#list>
</#if>
</#if>
</#list>
],
......@@ -55,7 +59,7 @@ TARGET=PSSYSTEM
</#if>
}
<#comment>获取实体数据集</#comment>
<#function getDataSet>
<#function getDataSet de>
<#assign result_dataSet="[" >
<#if de.getAllPSDEDataSets()??>
<#list de.getAllPSDEDataSets() as dataSet>
......@@ -70,7 +74,7 @@ TARGET=PSSYSTEM
</#function>
<#comment>获取实体行为</#comment>
<#function getDEAction>
<#function getDEAction de>
<#assign result_deAction="[" >
<#if de.getAllPSDEActions()??>
<#list de.getAllPSDEActions() as deAction>
......@@ -136,7 +140,7 @@ TARGET=PSSYSTEM
<#comment>获取数据范围</#comment>
<#function getDataScope dataEntity>
<#function getDataScope de>
<#assign result_DataScope="[">
<#assign result_DataScope=result_DataScope+"{\"id\":\"all\",\"name\":\"全部数据\"}">
<#if de.getPSDEFieldByPDT('ORGID',true)?? >
......
......@@ -122,7 +122,7 @@ TARGET=PSDELOGIC
<#assign targetDBValueOP=LogicLinkCond.getPSDBValueOPId()><#comment>表达式</#comment>
<#assign targetValue=LogicLinkCond.getValue()><#comment>值项</#comment>
<#if targetDEField!=''>
targetFieldName=srfcaseformat(targetDEField.codeName,'l_u2lC') ;
<#assign targetFieldName=srfcaseformat(targetDEField.codeName,'l_u2lC')>
</#if>
<#assign condBody="RuleUtils.test($"+logicName+targetParam.getCodeName()?lower_case+".get(\""+targetFieldName+"\"),\""+targetDBValueOP+"\","+"\""+targetValue+"\")">
<#assign fieldCond=fieldCond+condBody >
......
......@@ -14,6 +14,8 @@ TARGET=PSSYSTEM
"table_name":"${de.getTableName()}",
"system_id":"${sys.codeName}",
"system_name":"${sys.logicName}",
"module_id":"${de.getPSSystemModule().codeName}",
"module_name":"${de.getPSSystemModule().name}",
<#--"ds_id":null,-->
<#--"ds_name":"",-->
"fields":[
......
......@@ -102,6 +102,14 @@ TARGET=PSWFVERSION
<flowable:string>${(wfde.getUDStatePSDEField().getCodeName()?lower_case)}</flowable:string>
</flowable:field>
</#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()??>
<flowable:field name="wfstatefield_${srfpluralize(wfde.getPSDataEntity().getCodeName()?lower_case)}">
<flowable:string>${(wfde.getWFStatePSDEField().getCodeName()?lower_case)}</flowable:string>
......@@ -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>
<documentation>${r'${majortext}'}</documentation>
<#if (WFProcess.isSendInform()?? && WFProcess.getPSSysMsgTempl()?? ) || ((WFProcess.getFormCodeName())!'')!='' || ((WFProcess.getMobFormCodeName())!'')!='' >
<#assign msgTempl=WFProcess.getPSSysMsgTempl()>
<extensionElements>
<#if (WFProcess.isSendInform()?? && WFProcess.getPSSysMsgTempl()?? )>
<#assign msgTempl=WFProcess.getPSSysMsgTempl()>
<flowable:formProperty id="${msgTempl.getCodeName()?lower_case}" name="${msgTempl.getName()}" variable="${assignGroupCond}" type="${WFProcess.getMsgType()}" />
</#if>
<#if ((WFProcess.getFormCodeName())!'')!='' || ((WFProcess.getMobFormCodeName())!'')!='' >
......
......@@ -15,6 +15,15 @@ TARGET=PSSYSTEM
<#break>
</#if>
</#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"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
......@@ -114,6 +123,9 @@ TARGET=PSSYSTEM
</#if>
</#list>
</#if>
<#if hasMQEntity>
<rocketmq.version>4.7.0</rocketmq.version>
</#if>
</properties>
......@@ -327,7 +339,13 @@ TARGET=PSSYSTEM
</exclusions>
</dependency>
</#if>
<#if hasMQEntity>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>${r'${rocketmq.version}'}</version>
</dependency>
</#if>
</dependencies>
</dependencyManagement>
......
......@@ -10,6 +10,7 @@ TARGET=PSSYSSERVICEAPI
<#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 dbDriver="com.mysql.jdbc.Driver">
<#assign dockerPortMap="">
<#if sysrun?? && sysrun.getPSDevSlnMSDepAPI()?? >
<#assign depSysApi=sysrun.getPSDevSlnMSDepAPI()>
<#if depSysApi.getHttpPort()??>
......@@ -36,6 +37,9 @@ TARGET=PSSYSSERVICEAPI
<#elseif depSysApiPlatform.getUserParam("spring.redis.database","")?? && depSysApiPlatform.getUserParam("spring.redis.database","")!="">
<#assign redisDataBase = depSysApiPlatform.getUserParam("spring.redis.database","")>
</#if>
<#if depSysApi.getUserParam("portmap","")?? && depSysApi.getUserParam("portmap","")!="">
<#assign dockerPortMap= depSysApi.getUserParam("portmap","")>
</#if>
</#if>
</#if>
<#comment>数据库配置</#comment>
......@@ -65,6 +69,9 @@ services:
image: registry.cn-shanghai.aliyuncs.com/ibizsys/${pub.getCodeName()?lower_case}-provider-${api.getCodeName()?lower_case}:latest
ports:
- "${httpPort}:${httpPort}"
<#if dockerPortMap!=''>
- "${dockerPortMap}"
</#if>
networks:
- agent_network
<#if sysrun?? && sysrun.getPSDevSlnMSDepAPI()?? && sysrun.getPSDevSlnMSDepAPI().getPSDCMSPlatformNode()??>
......
......@@ -27,7 +27,7 @@ import org.springframework.context.annotation.Import;
@ConditionalOnClass(${item.codeName}RestConfiguration.class)
@ConditionalOnWebApplication
@EnableConfigurationProperties(${item.codeName}ServiceProperties.class)
public class ${item.codeName}AutoConfiguration implements ApplicationContextAware{
public class ${item.codeName}AutoConfiguration implements ApplicationContextAware {
protected ApplicationContext applicationContext;
......
......@@ -118,9 +118,9 @@ public class ${item.codeName}SecurityConfig extends WebSecurityConfigurerAdapter
"/v2/**"
).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("/"+uploadpath).permitAll()
......
......@@ -10,6 +10,19 @@ TARGET=PSDESERVICEAPI
<#if ((de.getPSSubSysServiceAPI().getServiceType())!'')=='MIDDLEPLATFORM'>
<#assign dtoBase="DTOClient">
</#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;
import java.sql.Timestamp;
......@@ -32,11 +45,15 @@ import javax.validation.constraints.Size;
import ${pub.getPKGCodeName()}.util.domain.DTOBase;
import ${pub.getPKGCodeName()}.util.domain.DTOClient;
import lombok.Data;
<#if hasValueRuleGroup>
import ${pub.getPKGCodeName()}.util.annotation.ValueRuleCheck;
</#if>
/**
* 服务DTO对象[${item.getCodeName()}DTO]
*/
@Data
<@valueRuleGroup/>
public class ${item.getCodeName()}DTO extends ${dtoBase} implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -159,3 +176,22 @@ public class ${item.getCodeName()}DTO extends ${dtoBase} implements Serializable
</#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>
\ No newline at end of file
......@@ -13,9 +13,8 @@ import org.mapstruct.*;
import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.domain.${de.codeName};
import ${pubPkgCodeName}.${itemSysApiCodeNameLC}.dto.${item.getCodeName()}DTO;
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,
nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface ${item.getCodeName()}Mapping extends MappingBase<${item.codeName}DTO, ${de.codeName}> {
......
......@@ -265,6 +265,10 @@ public class ${itemCodeName}Resource {
</#if>
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC}dto);
}
<#comment>自定义行为批处理</#comment>
<#if (deaction.getActionType()=='USERCUSTOM')>
<@customBatchAction deaction/>
</#if>
</#if>
<#elseif apiMethod.getActionType()=='FETCH'>
......@@ -272,7 +276,7 @@ public class ${itemCodeName}Resource {
<@DataQuerySecurityAnnotation deds/>
@ApiOperation(value = "获取${deds.getLogicName()}", tags = {"${deLogicName}" } ,notes = "获取${deds.getLogicName()}")
@RequestMapping(method= RequestMethod.${reqMtd} , value="${fullPath}/fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>")
public ResponseEntity<List<<#if deds.isEnableGroup()>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}-->
<#if deds.isEnableGroup()>
Page<HashMap> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ;
......@@ -424,12 +428,7 @@ public class ${itemCodeName}Resource {
<#if item.getPSDEServiceAPIMethods()??>
<#list item.getPSDEServiceAPIMethods() as apiMethod>
<#assign reqMtd = apiMethod.getRequestMethod()>
<#assign statusCode = "">
<#if reqMtd == "POST" >
<#assign statusCode = "HttpStatus.CREATED" >
<#else>
<#assign statusCode = "HttpStatus.OK" >
</#if>
<#if apiMethod.getActionType()=='DEACTION'>
<#assign deaction = apiMethod.getPSDEAction()>
<#assign deactionName = deaction.getName()>
......@@ -611,14 +610,17 @@ public class ${itemCodeName}Resource {
</#if>
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC}dto);
}
<#comment>自定义行为批处理</#comment>
<#if (deaction.getActionType()=='USERCUSTOM')>
<@customBatchActionRS deaction/>
</#if>
</#if>
<#elseif apiMethod.getActionType()=='FETCH'>
<#assign deds = apiMethod.getPSDEDataSet()>
<@DataQuerySecurityAnnotation deds/>
@ApiOperation(value = "${byTagParams}获取${deds.getLogicName()}", tags = {"${deLogicName}" } ,notes = "${byTagParams}获取${deds.getLogicName()}")
@RequestMapping(method= RequestMethod.${reqMtd} , value="${fullPath}/fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>")
public ResponseEntity<List<<#if deds.isEnableGroup()>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}
<#if deds.isEnableGroup()>
Page<HashMap> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ;
......@@ -677,11 +679,11 @@ public class ${itemCodeName}Resource {
else{
<#list de.getAllPSDEDataImports() as deImport>
<#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});
}
<#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});
}
</#if>
......@@ -696,7 +698,7 @@ public class ${itemCodeName}Resource {
<#comment>数据查询Security权限校验(分组不鉴权)</#comment>
<#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>
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','${sys.codeName}-${de.codeName}-search${dataset.codeName}-all')")
<#else>
......@@ -707,7 +709,7 @@ public class ${itemCodeName}Resource {
<#comment>单条数据Security权限校验</#comment>
<#macro SecurityAnnotation deaction>
<#if de.getStorageMode()==1 || de.getStorageMode()==2>
<#if de.getStorageMode()==1 || de.getStorageMode()==2 ||de.getStorageMode()==4>
<#if hasDEPrefield==false>
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','${sys.codeName}-${de.codeName}-${deaction.codeName}-all')")
<#else>
......@@ -726,7 +728,7 @@ public class ${itemCodeName}Resource {
<#comment>批量数据Security权限校验</#comment>
<#macro SecurityBatchAnnotation deaction>
<#if de.getStorageMode()==1 || de.getStorageMode()==2>
<#if de.getStorageMode()==1 || de.getStorageMode()==2 ||de.getStorageMode()==4>
<#if hasDEPrefield==false>
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','${sys.codeName}-${de.codeName}-${deaction.codeName}-all')")
<#else>
......@@ -998,6 +1000,26 @@ public class ${itemCodeName}Resource {
</#if>
</#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
*/
@AfterReturning(value = "execution(* ${pub.getPKGCodeName()}.core.*.service.*.create(..))<#if hasESEntity>&& !execution(* ${pub.getPKGCodeName()}.core.es.service.*.create*(..))</#if>")
@SneakyThrows
public void create(JoinPoint point){
HttpServletRequest request=null;
RequestAttributes requestAttributes= RequestContextHolder.getRequestAttributes();
if(requestAttributes!=null){
request=((ServletRequestAttributes)requestAttributes).getRequest();
public void create(JoinPoint point) {
HttpServletRequest request = null;
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
if(requestAttributes!=null) {
request = ((ServletRequestAttributes)requestAttributes).getRequest();
}
Object [] args = point.getArgs();
if(ObjectUtils.isEmpty(args) || args.length==0)
if(ObjectUtils.isEmpty(args) || args.length==0) {
return;
Object serviceParam =args[0];
if(serviceParam instanceof EntityBase){
EntityBase entity=(EntityBase)serviceParam;//创建数据
Map<String, Audit> auditFields= DEFieldCacheMap.getAuditFields(entity.getClass());
if(auditFields.size()==0)//是否有审计属性
}
Object serviceParam = args[0];
if(serviceParam instanceof EntityBase) {
EntityBase entity = (EntityBase)serviceParam;
Map<String, Audit> auditFields = DEFieldCacheMap.getAuditFields(entity.getClass());
//是否有审计属性
if(auditFields.size()==0) {
return;
String idField=DEFieldCacheMap.getDEKeyField(entity.getClass());
Object idValue="";
if(!StringUtils.isEmpty(idField)){
}
String idField = DEFieldCacheMap.getDEKeyField(entity.getClass());
Object idValue = "";
if(!StringUtils.isEmpty(idField)) {
idValue=entity.get(idField);
}
//记录审计日志
dataAuditService.createAudit(request,entity,idValue,auditFields);
dataAuditService.createAudit(request, entity, idValue, auditFields);
}
}
......@@ -87,39 +88,38 @@ public class AuditAspect
*/
@Around("execution(* ${pub.getPKGCodeName()}.core.*.service.*.update(..))<#if hasESEntity>&& !execution(* ${pub.getPKGCodeName()}.core.es.service.*.update*(..))</#if>")
public Object update(ProceedingJoinPoint point) throws Throwable {
HttpServletRequest request=null;
RequestAttributes requestAttributes= RequestContextHolder.getRequestAttributes();
if(requestAttributes!=null){
HttpServletRequest request = null;
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
if(requestAttributes!=null) {
request=((ServletRequestAttributes)requestAttributes).getRequest();
}
Object serviceObj=point.getTarget();
Object args[]=point.getArgs();
if(ObjectUtils.isEmpty(args) || args.length==0)
Object serviceObj = point.getTarget();
Object args[] = point.getArgs();
if(ObjectUtils.isEmpty(args) || args.length==0) {
return point.proceed();
Object arg=args[0];
if(arg instanceof EntityBase){
EntityBase entity= (EntityBase) arg;
Map<String, Audit> auditFields= DEFieldCacheMap.getAuditFields(entity.getClass());
}
Object arg = args[0];
if(arg instanceof EntityBase) {
EntityBase entity = (EntityBase) arg;
Map<String, Audit> auditFields = DEFieldCacheMap.getAuditFields(entity.getClass());
//是否有审计属性
if(auditFields.size()==0)
if(auditFields.size()==0) {
return point.proceed();
String idField=DEFieldCacheMap.getDEKeyField(entity.getClass());
Object idValue="";
}
String idField = DEFieldCacheMap.getDEKeyField(entity.getClass());
Object idValue = "";
if(!StringUtils.isEmpty(idField)){
idValue=entity.get(idField);
idValue = entity.get(idField);
}
if(ObjectUtils.isEmpty(idValue))
if(ObjectUtils.isEmpty(idValue)) {
return point.proceed();
}
//获取更新前实体
EntityBase beforeEntity=getEntity(serviceObj,idValue);
EntityBase beforeEntity = getEntity(serviceObj, idValue);
//执行更新操作
point.proceed();
//记录审计日志
dataAuditService.updateAudit(request,beforeEntity,serviceObj,idValue,auditFields);
dataAuditService.updateAudit(request, beforeEntity, serviceObj, idValue, auditFields);
return true;
}
return point.proceed();
......@@ -134,28 +134,27 @@ public class AuditAspect
*/
@Around("execution(* ${pub.getPKGCodeName()}.core.*.service.*.remove(..))<#if hasESEntity>&& !execution(* ${pub.getPKGCodeName()}.core.es.service.*.remove*(..))</#if>")
public Object remove(ProceedingJoinPoint point) throws Throwable {
HttpServletRequest request=null;
RequestAttributes requestAttributes= RequestContextHolder.getRequestAttributes();
if(requestAttributes!=null){
request=((ServletRequestAttributes)requestAttributes).getRequest();
HttpServletRequest request = null;
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
if(requestAttributes!= null) {
request = ((ServletRequestAttributes)requestAttributes).getRequest();
}
Object serviceObj=point.getTarget();
Object args[]=point.getArgs();
if(ObjectUtils.isEmpty(args) || args.length==0)
Object serviceObj = point.getTarget();
Object args[] = point.getArgs();
if(ObjectUtils.isEmpty(args) || args.length==0) {
return point.proceed();
Object idValue=args[0];
EntityBase entity=getEntity(serviceObj,idValue);
Map<String, Audit> auditFields= DEFieldCacheMap.getAuditFields(entity.getClass());
if(auditFields.size()==0){
}
Object idValue = args[0];
EntityBase entity = getEntity(serviceObj, idValue);
Map<String, Audit> auditFields = DEFieldCacheMap.getAuditFields(entity.getClass());
if(auditFields.size()==0) {
return point.proceed();
}
else{
//执行删除操作
point.proceed();
//记录审计日志
dataAuditService.removeAudit(request,entity,idValue,auditFields);
dataAuditService.removeAudit(request, entity, idValue, auditFields);
return true;
}
}
......@@ -167,12 +166,12 @@ public class AuditAspect
* @return
*/
@SneakyThrows
private EntityBase getEntity(Object service, Object id){
EntityBase entity=null;
if(!ObjectUtils.isEmpty(service)){
private EntityBase getEntity(Object service, Object id) {
EntityBase entity = null;
if(!ObjectUtils.isEmpty(service)) {
EvaluationContext oldContext = new StandardEvaluationContext();
oldContext.setVariable("service",service);
oldContext.setVariable("id",id);
oldContext.setVariable("service", service);
oldContext.setVariable("id", id);
Expression oldExp = parser.parseExpression("#service.get(#id)");
return oldExp.getValue(oldContext, EntityBase.class);
}
......
......@@ -85,19 +85,19 @@ public class DupCheckAspect {
//设置检查属性值
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);
setValue(entity,filter,dupCheckField,dupFieldValue);
setValue(entity, filter, dupCheckField, dupFieldValue);
}
searchContext.setFilter(filter);
//使用当前值到数据库中进行查询,判断是否重复
EvaluationContext oldValueMappingCtx = new StandardEvaluationContext();
oldValueMappingCtx.setVariable("service", service);
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);
if (!ObjectUtils.isEmpty(oldData) && !ObjectUtils.isEmpty(oldData.getContent()) && oldData.getContent().size() > 1) {
throw new BadRequestAlertException(String.format("数据保存失败,属性[%s]:值[%s]已存在!", fieldName, newValue), "DupCheckAspect", "DupCheck");
......@@ -113,7 +113,7 @@ public class DupCheckAspect {
* @param fieldName
* @return
*/
private Object getDEFieldValue(Object entity, String fieldName){
private Object getDEFieldValue(Object entity, String fieldName) {
EvaluationContext exMappingCtx = new StandardEvaluationContext();
exMappingCtx.setVariable("entity", entity);
Expression esMappingExp = parser.parseExpression(String.format("#entity.get(\"%s\")", fieldName));
......@@ -127,10 +127,12 @@ public class DupCheckAspect {
* @param 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));
else
filter.eq(DEFieldCacheMap.getFieldColumnName(entity.getClass(), fieldName),value);
}
else {
filter.eq(DEFieldCacheMap.getFieldColumnName(entity.getClass(), fieldName), value);
}
}
}
</#if>
......
......@@ -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*(..))")
@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}");
}
</#if>
......@@ -56,44 +56,45 @@ public class ESAspect
* 异步往es中保存数据
* @param point
*/
public void syncSaveESData(JoinPoint point,String deName){
public void syncSaveESData(JoinPoint point, String deName) {
try {
Object service=point.getTarget();
String action=point.getSignature().getName();
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;
}
EvaluationContext exServiceCtx = new StandardEvaluationContext();
exServiceCtx.setVariable("service",service);
exServiceCtx.setVariable("service", service);
Expression esServiceExp = parser.parseExpression("#service.getESService()");
Object exService=esServiceExp.getValue(exServiceCtx);
if(ObjectUtils.isEmpty(exService)){
if(ObjectUtils.isEmpty(exService)) {
log.error("获取[{}]实体全文检索服务对象失败",deName);
return;
}
Object arg=args[0];
if ("remove".equals(action) || "removeBatch".equals(action)){
executeESMethod(exService,action,arg);
if ("remove".equals(action) || "removeBatch".equals(action)) {
executeESMethod(exService, action, arg);
}
else if(arg instanceof EntityBase || arg instanceof List){
else if(arg instanceof EntityBase || arg instanceof List) {
EvaluationContext exMappingCtx = new StandardEvaluationContext();
exMappingCtx.setVariable("service",service);
exMappingCtx.setVariable("service", service);
Expression esMappingExp = parser.parseExpression("#service.getESMapping()");
Object exMapping=esMappingExp.getValue(exMappingCtx);
if(ObjectUtils.isEmpty(exMapping)){
log.error("获取[{}]实体全文检索映射对象失败",deName);
if(ObjectUtils.isEmpty(exMapping)) {
log.error("获取[{}]实体全文检索映射对象失败", deName);
return;
}
EvaluationContext exDomainCtx = new StandardEvaluationContext();
exDomainCtx.setVariable("mapping",exMapping);
exDomainCtx.setVariable("arg",arg);
exDomainCtx.setVariable("mapping", exMapping);
exDomainCtx.setVariable("arg", arg);
Expression esDomainExp = parser.parseExpression("#mapping.toESDomain(#arg)");
arg=esDomainExp.getValue(exDomainCtx);
executeESMethod(exService,action,arg);
executeESMethod(exService, action, arg);
}
} catch (Exception e) {
log.error("同步[{}]实体全文检索数据失败,{}",deName,e);
log.error("同步[{}]实体全文检索数据失败,{}", deName, e);
}
}
......@@ -103,11 +104,11 @@ public class ESAspect
* @param action
* @param arg
*/
private void executeESMethod(Object exService,Object action,Object arg){
private void executeESMethod(Object exService, Object action, Object arg) {
EvaluationContext esContext = new StandardEvaluationContext();
esContext.setVariable("exService",exService);
esContext.setVariable("arg",arg);
Expression exExp = parser.parseExpression(String.format("#exService.%s(#arg)",action));
esContext.setVariable("exService", exService);
esContext.setVariable("arg", arg);
Expression exExp = parser.parseExpression(String.format("#exService.%s(#arg)", action));
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;
public class VersionCheckAspect
{
private final ExpressionParser parser = new SpelExpressionParser();
private final String IgnoreField="ignoreversioncheck";
private final String IgnoreField = "ignoreversioncheck";
@SneakyThrows
@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 id=args[0];
Object dto=args[1];
if(ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(dto))
Object id = args[0];
Object dto = args[1];
if(ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(dto)) {
return;
String versionField=versionCheck.versionfield();
if(StringUtils.isEmpty(versionField))
}
String versionField = versionCheck.versionfield();
if(StringUtils.isEmpty(versionField)) {
return;
versionCheck(versionCheck,point.getTarget(),dto,id);
}
versionCheck(versionCheck,point.getTarget(), dto, id);
}
@SneakyThrows
@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();
if(args.length>=2){
Object id=args[args.length-2];
Object dto=args[args.length-1];
if(ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(dto))
if(args.length>=2) {
Object id = args[args.length-2];
Object dto = args[args.length-1];
if(ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(dto)) {
return;
String versionField=versionCheck.versionfield();
if(StringUtils.isEmpty(versionField))
}
String versionField = versionCheck.versionfield();
if(StringUtils.isEmpty(versionField)) {
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();
context.setVariable("dto",dto);
context.setVariable("dto", dto);
//忽略版本检查
Expression dtoParamsExp = parser.parseExpression("#dto.extensionparams");
Map dtoParam=dtoParamsExp.getValue(context, Map.class);
if(!ObjectUtils.isEmpty(dtoParam) && !ObjectUtils.isEmpty(dtoParam.get(IgnoreField)) && dtoParam.get(IgnoreField).equals(1))
Map dtoParam = dtoParamsExp.getValue(context, Map.class);
if(!ObjectUtils.isEmpty(dtoParam) && !ObjectUtils.isEmpty(dtoParam.get(IgnoreField)) && dtoParam.get(IgnoreField).equals(1)) {
return;
Expression newExp = parser.parseExpression(String.format("#dto.%s",versionCheck.versionfield()));
Object newVersion=newExp.getValue(context);
if(ObjectUtils.isEmpty(newVersion))
}
Expression newExp = parser.parseExpression(String.format("#dto.%s", versionCheck.versionfield()));
Object newVersion = newExp.getValue(context);
if(ObjectUtils.isEmpty(newVersion)) {
return;
}
//进行版本检查
Object oldVersion =getDBVersion(versionCheck,getService(resource,versionCheck.entity()),id);
if(!ObjectUtils.isEmpty(oldVersion)){
if(RuleUtils.gt(newVersion,oldVersion))
throw new BadRequestAlertException("数据已变更,可能后台数据已被修改,请重新加载数据","VersionCheckAspect","versionCheck");
Object oldVersion = getDBVersion(versionCheck,getService(resource, versionCheck.entity()), id);
if(!ObjectUtils.isEmpty(oldVersion)) {
if(RuleUtils.gt(newVersion, oldVersion)) {
throw new BadRequestAlertException("数据已变更,可能后台数据已被修改,请重新加载数据", "VersionCheckAspect", "versionCheck");
}
}
}
......@@ -94,12 +101,12 @@ public class VersionCheckAspect
* @return
*/
@SneakyThrows
private Object getService(Object resource,String entity){
private Object getService(Object resource, String entity) {
Object service = null;
Field[] fields= resource.getClass().getDeclaredFields();
for(Field field : fields){
if(field.getModifiers()==1 && field.getName().equalsIgnoreCase(String.format("%sService",entity))){
service=field.get(resource);
Field[] fields = resource.getClass().getDeclaredFields();
for(Field field : fields) {
if(field.getModifiers()==1 && field.getName().equalsIgnoreCase(String.format("%sService",entity))) {
service = field.get(resource);
break;
}
}
......@@ -114,21 +121,21 @@ public class VersionCheckAspect
* @return
*/
@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");
Timestamp dbVersion=null;
String versionField=versionCheck.versionfield();
if(!ObjectUtils.isEmpty(service)){
Timestamp dbVersion = null;
String versionField = versionCheck.versionfield();
if(!ObjectUtils.isEmpty(service)) {
EvaluationContext oldContext = new StandardEvaluationContext();
oldContext.setVariable("service",service);
oldContext.setVariable("id",id);
oldContext.setVariable("service", service);
oldContext.setVariable("id", id);
Expression oldExp = parser.parseExpression("#service.get(#id)");
EntityBase oldEntity =oldExp.getValue(oldContext, EntityBase.class);
Object oldDate=oldEntity.get(versionField);
if(oldDate!=null && oldDate instanceof Timestamp){
Timestamp db_time= (Timestamp) oldDate;
EntityBase oldEntity = oldExp.getValue(oldContext, EntityBase.class);
Object oldDate = oldEntity.get(versionField);
if(oldDate!=null && oldDate instanceof Timestamp) {
Timestamp db_time = (Timestamp) oldDate;
Date db_date = sdf.parse(sdf.format(db_time));
dbVersion=new Timestamp(db_date.getTime());
dbVersion = new Timestamp(db_date.getTime());
}
}
return dbVersion;
......
......@@ -3,16 +3,20 @@ TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.domain;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
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.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import lombok.Data;
@Data
public class DTOBase implements Serializable {
......@@ -24,33 +28,39 @@ public class DTOBase implements Serializable {
public void modify(String field,Object val) {
if(val==null)
if(val==null) {
this.getFocusNull(true).add(field.toLowerCase());
else
}
else {
this.getFocusNull(true).remove(field.toLowerCase());
}
}
public Set<String> getFocusNull() {
if(focusNull==null)
if(focusNull==null) {
focusNull=new HashSet<>();
}
if(focusNull.size()>0 && extensionparams.containsKey("dirtyflagenable"))
{
Set<String> nocheck=new HashSet<>();
for(String key:focusNull)
{
if(!extensionparams.containsKey(key+"dirtyflag"))
if(!extensionparams.containsKey(key+"dirtyflag")) {
nocheck.add(key);
}
for(String key:nocheck)
}
for(String key:nocheck) {
focusNull.remove(key);
}
}
return focusNull;
}
private Set<String> getFocusNull(boolean newflag) {
if(focusNull==null)
if(focusNull==null) {
focusNull=new HashSet<>();
}
return focusNull;
}
......@@ -70,9 +80,44 @@ public class DTOBase implements Serializable {
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
public void set(String name, Object value) {
extensionparams.put(name.toLowerCase(), value);
public void set(String field, Object 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 {
private Set<String> focusNull;
public Set<String> getFocusNull() {
if(focusNull==null)
if(focusNull==null) {
focusNull=new HashSet<>();
}
return focusNull;
}
......@@ -53,8 +54,9 @@ public class EntityBase implements Serializable {
private BeanMap getMap()
{
if(map==null)
if(map==null) {
map=BeanMap.create(this);
}
return map;
}
......@@ -71,16 +73,15 @@ public class EntityBase implements Serializable {
this.extensionparams = extensionparams;
}
public Object get(String field) {
String fieldRealName=DEFieldCacheMap.getFieldRealName(this.getClass(),field);
if(!StringUtils.isEmpty(fieldRealName))
if(!StringUtils.isEmpty(fieldRealName)) {
return getMap().get(fieldRealName);
else
}
else {
return this.extensionparams.get(field.toLowerCase());
}
}
@JsonAnyGetter
public Map<String , Object> any() {
......@@ -92,14 +93,17 @@ public class EntityBase implements Serializable {
field=field.toLowerCase();
String fieldRealName=DEFieldCacheMap.getFieldRealName(this.getClass(),field);
if(!StringUtils.isEmpty(fieldRealName)) {
if (value == null)
if (value == null) {
getMap().put(fieldRealName, null);
else
}
else {
getMap().put(fieldRealName, DEFieldCacheMap.fieldValueOf(this.getClass(), fieldRealName, value));
}
else
}
else {
this.extensionparams.put(field.toLowerCase(),value);
}
}
/**
* 复制当前对象数据到目标对象
......
......@@ -8,25 +8,26 @@ import org.springframework.util.StringUtils;
public class EntityMP extends EntityBase {
public UpdateWrapper getUpdateWrapper(boolean clean) {
UpdateWrapper wrapper=new UpdateWrapper();
for(String nullField:getFocusNull()) {
wrapper.set(nullField,null);
}
if(clean)
if(clean) {
getFocusNull().clear();
}
return wrapper;
}
@Override
public void modify(String field,Object val) {
if(val==null)
if(val==null) {
this.getFocusNull().add(field.toLowerCase());
else
}
else {
this.getFocusNull().remove(field.toLowerCase());
}
}
@Override
public void reset(String field){
......@@ -36,6 +37,5 @@ public class EntityMP extends EntityBase {
getFocusNull().remove(resetField);
}
}
}
......@@ -5,7 +5,5 @@ package ${pub.getPKGCodeName()}.util.domain;
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
*/
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;
}
QueryBuilder rsBuilder=QueryBuilder.start();
QueryBuilder fieldBuilder=parseFieldMap(queryFilter.any());
QueryBuilder orBuilder=parseOrQueryFilter(queryFilter.get$or());
......@@ -110,8 +110,9 @@ public class QueryBuildContext extends SearchContextBase implements ISearchConte
* @return
*/
private QueryBuilder parseFieldMap(Map<String , QueryFilter.SegmentCond> fieldMap) {
if(fieldMap.size()==0)
if(fieldMap.size()==0) {
return null;
}
QueryBuilder fieldBuilders=QueryBuilder.start();
for(Map.Entry<String, QueryFilter.SegmentCond> entry: fieldMap.entrySet()){
getSegmentCondSql(entry.getKey(),entry.getValue(),fieldBuilders);
......
......@@ -66,8 +66,9 @@ public class QueryFilter {
private Map<String,SegmentCond> getMap()
{
if(map==null)
if(map==null) {
map=new LinkedHashMap<>();
}
return map;
}
......@@ -135,11 +136,12 @@ public class QueryFilter {
}
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());
else
}
else {
this.getMap().put(column,segmentCond);
}
return this;
}
......@@ -158,8 +160,9 @@ public class QueryFilter {
private Map<String,Object> getMap()
{
if(map==null)
if(map==null) {
map=new LinkedHashMap<>();
}
return map;
}
......
......@@ -40,17 +40,20 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
int pageSize=getPageable().getPageSize();
//构造mybatis-plus分页
if(StringUtils.isEmpty(currentPage) || StringUtils.isEmpty(pageSize))
if(StringUtils.isEmpty(currentPage) || StringUtils.isEmpty(pageSize)) {
page=new Page(1,Short.MAX_VALUE);
else
}
else {
page=new Page(currentPage+1,pageSize);
}
//构造mybatis-plus排序
Sort sort = getPageable().getSort();
Iterator<Sort.Order> it_sort = sort.iterator();
if(ObjectUtils.isEmpty(it_sort))
if(ObjectUtils.isEmpty(it_sort)) {
return page;
}
ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
Class<T> type = (Class<T>)parameterizedType.getActualTypeArguments()[0];
......@@ -98,9 +101,9 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
* @return
*/
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;
}
Consumer<QueryWrapper<T>> consumer = queryWrapper -> {
Consumer fieldConsumer=parseFieldMap(queryFilter.any());
Consumer orConsumer=parseOrQueryFilter(queryFilter.get$or());
......@@ -124,7 +127,6 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
* @return
*/
private Consumer<QueryWrapper<T>> parseOrQueryFilter(List<QueryFilter> queryFilters) {
if(queryFilters==null || queryFilters.size()==0)
return null;
Consumer<QueryWrapper<T>> consumer = queryWrapper -> {
......@@ -142,9 +144,9 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
* @return
*/
private Consumer<QueryWrapper<T>> parseAndQueryFilter(List<QueryFilter> queryFilters) {
if(queryFilters==null || queryFilters.size()==0)
if(queryFilters==null || queryFilters.size()==0) {
return null;
}
Consumer<QueryWrapper<T>> consumer = queryWrapper -> {
for(QueryFilter queryFilter: queryFilters){
Consumer tempQueryWrapper=parseQueryFilter(queryFilter);
......@@ -160,9 +162,9 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
* @return
*/
private Consumer<QueryWrapper<T>> parseFieldMap(Map<String , QueryFilter.SegmentCond> fieldMap) {
if(fieldMap.size()==0)
if(fieldMap.size()==0) {
return null;
}
Consumer<QueryWrapper<T>> consumer = queryWrapper -> {
for(Map.Entry<String, QueryFilter.SegmentCond> field: fieldMap.entrySet()){
String fieldName=field.getKey();
......
......@@ -117,11 +117,13 @@ public class SearchContextBase implements ISearchContext{
* @return
*/
public Pageable getPageable() {
if(ObjectUtils.isEmpty(pageSort))
if(ObjectUtils.isEmpty(pageSort)) {
return PageRequest.of(page,size);
else
}
else {
return PageRequest.of(page,size,pageSort);
}
}
/**
* 设置排序值
......
......@@ -16,8 +16,9 @@ public class CachedBeanCopier {
}
public static void copy(Object srcObj, Object destObj,boolean useConverter) {
if(srcObj==null||destObj==null)
if(srcObj==null||destObj==null) {
return;
}
getCopier(srcObj,destObj,useConverter).copy(srcObj, destObj, null);
}
......@@ -32,6 +33,4 @@ public class CachedBeanCopier {
}
return copier;
}
}
......@@ -39,13 +39,16 @@ public class DEFieldCacheMap {
*/
public static <T> Hashtable<String,Field> getFieldMap(Class<T> clazz) {
String className=clazz.getName();
if(className.indexOf("_$")>0)
if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$"));
if(cacheMap.containsKey(className))
}
if(cacheMap.containsKey(className)) {
return cacheMap.get(className);
}
synchronized (objLock1) {
if(cacheMap.containsKey(className))
if(cacheMap.containsKey(className)) {
return cacheMap.get(className);
}
Hashtable<String,Field> result = new Hashtable<String,Field>();
List<Field> list=new ArrayList<Field>();
Hashtable<String,String> keys=new Hashtable<String,String>();
......@@ -61,9 +64,10 @@ public class DEFieldCacheMap {
Audit auditField=field.getAnnotation(Audit.class);
if(!ObjectUtils.isEmpty(deField)) {
defields.put(field.getName(),deField);
if(deField.isKeyField())
if(deField.isKeyField()) {
cacheDEKeyField.put(className,field.getName());
}
}
if(!ObjectUtils.isEmpty(auditField)) {
auditfields.put(field.getName(),auditField);
}
......@@ -77,10 +81,12 @@ public class DEFieldCacheMap {
}
}
public static Hashtable<String,Field> getFieldMap(String className) {
if(className.indexOf("_$")>0)
if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$"));
if(cacheMap.containsKey(className))
}
if(cacheMap.containsKey(className)) {
return cacheMap.get(className);
}
Class clazz = null;
try {
clazz = Class.forName(className);
......@@ -99,10 +105,12 @@ public class DEFieldCacheMap {
*/
public static <T> Hashtable<String,DEField> getDEFields(Class<T> clazz) {
String className=clazz.getName();
if(className.indexOf("_$")>0)
if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$"));
if(cacheDEField.containsKey(className))
}
if(cacheDEField.containsKey(className)) {
return cacheDEField.get(className);
}
else{
DEFieldCacheMap.getFieldMap(className);
return cacheDEField.get(className);
......@@ -116,10 +124,12 @@ public class DEFieldCacheMap {
*/
public static <T> Hashtable<String,Audit> getAuditFields(Class<T> clazz) {
String className=clazz.getName();
if(className.indexOf("_$")>0)
if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$"));
if(cacheAuditField.containsKey(className))
}
if(cacheAuditField.containsKey(className)) {
return cacheAuditField.get(className);
}
else{
DEFieldCacheMap.getFieldMap(className);
return cacheAuditField.get(className);
......@@ -133,10 +143,12 @@ public class DEFieldCacheMap {
*/
public static <T> String getDEKeyField(Class<T> clazz) {
String className=clazz.getName();
if(className.indexOf("_$")>0)
if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$"));
if(cacheDEKeyField.containsKey(className))
}
if(cacheDEKeyField.containsKey(className)) {
return cacheDEKeyField.get(className);
}
else{
DEFieldCacheMap.getFieldMap(className);
return cacheDEKeyField.get(className);
......@@ -151,10 +163,12 @@ public class DEFieldCacheMap {
*/
public static <T> List<Field> getFields(Class<T> clazz) {
String className=clazz.getName();
if(className.indexOf("_$")>0)
if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$"));
if(cacheList.containsKey(className))
}
if(cacheList.containsKey(className)) {
return cacheList.get(className);
}
else{
DEFieldCacheMap.getFieldMap(className);
return cacheList.get(className);
......@@ -162,10 +176,12 @@ public class DEFieldCacheMap {
}
public static List<Field> getFields(String className) {
if(className.indexOf("_$")>0)
if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$"));
if(cacheList.containsKey(className))
}
if(cacheList.containsKey(className)) {
return cacheList.get(className);
}
else{
DEFieldCacheMap.getFieldMap(className);
return cacheList.get(className);
......@@ -179,10 +195,12 @@ public class DEFieldCacheMap {
*/
public static <T> Hashtable<String,String> getFieldKeys(Class<T> clazz) {
String className=clazz.getName();
if(className.indexOf("_$")>0)
if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$"));
if(cacheKey.containsKey(className))
}
if(cacheKey.containsKey(className)) {
return cacheKey.get(className);
}
else{
DEFieldCacheMap.getFieldMap(className);
return cacheKey.get(className);
......@@ -192,21 +210,26 @@ public class DEFieldCacheMap {
public static <T> String getFieldRealName(Class<T> clazz,String fieldname) {
fieldname=fieldname.toLowerCase();
Hashtable<String,String> keys=DEFieldCacheMap.getFieldKeys(clazz);
if(keys.containsKey(fieldname))
if(keys.containsKey(fieldname)) {
return keys.get(fieldname);
else if(keys.containsKey(fieldname.replace("_","")))
}
else if(keys.containsKey(fieldname.replace("_",""))) {
return keys.get(fieldname.replace("_",""));
else
}
else {
return "";
}
}
public static <T> Field getField(Class<T> clazz,String fieldname) {
String fieldRealName=DEFieldCacheMap.getFieldRealName(clazz,fieldname);
if(!StringUtils.isEmpty(fieldRealName))
if(!StringUtils.isEmpty(fieldRealName)) {
return DEFieldCacheMap.getFieldMap(clazz).get(fieldRealName);
else
}
else {
return null;
}
}
public static <T> String getFieldColumnName(Class<T> clazz,String fieldname) {
Field field = DEFieldCacheMap.getField(clazz,fieldname);
......@@ -229,6 +252,4 @@ public class DEFieldCacheMap {
}
return resultValue;
}
}
\ No newline at end of file
......@@ -22,30 +22,34 @@ public class DataObject {
final static public DateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd");
final static public String getStringValue(Object objValue, String strDefault) {
if (objValue == null) return strDefault;
if (objValue instanceof String) return (String) objValue;
if (objValue == null) {
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) {
String rt=datetimeFormat.format(objValue);
if(rt.endsWith(" 00:00:00"))
if(rt.endsWith(" 00:00:00")) {
rt=dayFormat.format(objValue);
else if(rt.endsWith(":00"))
}
else if(rt.endsWith(":00")) {
rt=datetimeFormat2.format(objValue);
}
return rt;
}
return objValue.toString();
}
public static <T> Object objectValueOf(Class<T> type,Object fieldValue) {
if(fieldValue==null)
if(fieldValue==null) {
return null;
}
Object resultValue=fieldValue;
String targetType=type.getSimpleName();
if(targetType.equalsIgnoreCase(fieldValue.getClass().getSimpleName()))
if(targetType.equalsIgnoreCase(fieldValue.getClass().getSimpleName())){
return resultValue;
}
if(targetType.equals("Boolean")){
resultValue=getBooleanValue(fieldValue,false);
}
......@@ -82,10 +86,9 @@ public class DataObject {
else if(targetType.equals("String")) {
resultValue= getStringValue(fieldValue,null);
}
if(resultValue==null)
if(resultValue==null) {
return null;
}
return resultValue;
}
......@@ -98,8 +101,9 @@ public class DataObject {
if (objValue == null) {
return jDefault;
}
if(objValue instanceof JSONObject)
if(objValue instanceof JSONObject) {
return (JSONObject)objValue;
}
String strValue = objValue.toString();
try {
return JSONObject.parseObject(strValue);
......@@ -114,8 +118,9 @@ public class DataObject {
if (objValue == null) {
return jDefault;
}
if(objValue instanceof JSONArray)
if(objValue instanceof JSONArray) {
return (JSONArray)objValue;
}
String strValue = objValue.toString();
try {
return JSONArray.parseArray(strValue);
......@@ -136,9 +141,10 @@ public class DataObject {
List<String> chk1=new ArrayList<>();
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));
}
}
return chk1;
}
else
......@@ -149,8 +155,9 @@ public class DataObject {
}
final static public Boolean getBooleanValue(Object objValue,Boolean bDefault) {
if (objValue == null) return bDefault;
if (objValue == null) {
return bDefault;
}
if (objValue instanceof Boolean) {
return (Boolean) objValue;
}
......@@ -158,20 +165,24 @@ public class DataObject {
}
final static public char[] getCharacterValue(Object objValue,char[] cDefault) {
if (objValue == null) return cDefault;
if (objValue == null) {
return cDefault;
}
return objValue.toString().toCharArray();
}
final static public Double getDoubleValue(Object objValue,Double dDefault) {
if (objValue == null) return dDefault;
if (objValue == null) {
return dDefault;
}
if (objValue instanceof Double) {
return (Double) objValue;
}
String strValue = objValue.toString();
if (StringUtils.isEmpty(strValue)) return null;
if (StringUtils.isEmpty(strValue)) {
return null;
}
strValue = strValue.replace(",", "");
return Double.parseDouble(strValue);
}
......@@ -182,8 +193,9 @@ public class DataObject {
return nDefault;
}
if(objValue instanceof Integer)
if(objValue instanceof Integer) {
return (Integer)objValue;
}
if (objValue instanceof Double) {
return ((Double) objValue).intValue();
......@@ -194,8 +206,9 @@ public class DataObject {
}
String strValue = objValue.toString();
if(StringUtils.isEmpty(strValue))
if(StringUtils.isEmpty(strValue)) {
return nDefault;
}
strValue = strValue.replace(",", "");
return Integer.parseInt(strValue);
}
......@@ -207,12 +220,13 @@ public class DataObject {
}
try {
if(objValue instanceof Float)
if(objValue instanceof Float) {
return (Float)objValue;
}
String strValue = objValue.toString();
if(StringUtils.isEmpty(strValue))
if(StringUtils.isEmpty(strValue)) {
return fDefault;
}
strValue = strValue.replace(",", "");
return Float.parseFloat(strValue);
} catch (Exception ex) {
......@@ -236,8 +250,9 @@ public class DataObject {
return BigDecimal.valueOf((Long)objValue);
}
String strValue = objValue.toString();
if(StringUtils.isEmpty(strValue))
if(StringUtils.isEmpty(strValue)) {
return fDefault;
}
strValue = strValue.replace(",", "");
return BigDecimal.valueOf(Double.parseDouble(strValue));
} catch (Exception ex) {
......@@ -256,9 +271,10 @@ public class DataObject {
}
else {
Long l=getLongValue(objValue,null);
if(l!=null)
if(l!=null) {
return BigInteger.valueOf(l);
}
}
} catch (Exception ex) {
}
......@@ -286,8 +302,9 @@ public class DataObject {
}
String strValue = objValue.toString();
if(StringUtils.isEmpty(strValue))
if(StringUtils.isEmpty(strValue)) {
return nDefault;
}
strValue = strValue.replace(",", "");
return Long.parseLong(strValue);
} catch (Exception ex) {
......@@ -297,7 +314,9 @@ public class DataObject {
final static public byte[] getBinaryValue(Object objValue, byte[] def) {
if (objValue == null) return def;
if (objValue == null) {
return def;
}
if(objValue instanceof byte[]){
return (byte[])objValue;
}
......@@ -315,7 +334,9 @@ public class DataObject {
* @
*/
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) {
java.sql.Timestamp ti = (java.sql.Timestamp) objValue;
......@@ -335,7 +356,9 @@ public class DataObject {
if (objValue instanceof String) {
String strValue = (String) objValue;
strValue = strValue.trim();
if (StringUtils.isEmpty(strValue)) return null;
if (StringUtils.isEmpty(strValue)) {
return null;
}
try {
java.util.Date date = parse((String) objValue);
......@@ -376,7 +399,9 @@ public class DataObject {
* @
*/
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);
java.sql.Timestamp retDate = new java.sql.Timestamp(dtDate.getTime());
return retDate;
......@@ -428,8 +453,9 @@ public class DataObject {
if(strTimeString.indexOf("T")!=-1){
strPart = strTimeString.split("[T]");
}
else
else{
strPart = strTimeString.split(" ");
}
if (strPart.length == 2) {
// 两个部分
String strDate = "";
......@@ -592,6 +618,4 @@ public class DataObject {
return new Timestamp(cl.getTime().getTime());
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#assign sid = sys.getName()/>
<#assign sid = sys.getCodeName()/>
<#assign sname = sys.getLogicName()/>
<#assign hasWF=false>
<#if sys.getAllPSWorkflows()??>
......@@ -91,14 +91,14 @@ public class PermissionSyncJob implements ApplicationRunner {
public void run(ApplicationArguments args) {
try {
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");
JSONObject system= new JSONObject();
system.put("pssystemid",systemId);
system.put("pssystemname",systemName);
system.put("sysstructure",JSONObject.parseObject(permissionResult));
system.put("md5check",DigestUtils.md5DigestAsHex(permissionResult.getBytes()));
if(client.syncSysAuthority(system)){
if(client.syncSysAuthority(system)) {
log.info("向[UAA]同步系统资源成功");
}else{
log.error("向[UAA]同步系统资源失败");
......@@ -109,9 +109,9 @@ public class PermissionSyncJob implements ApplicationRunner {
}
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");
if(liteFeignClient.syncSysModel(JSONObject.parseObject(strSysModel))){
if(liteFeignClient.syncSysModel(JSONObject.parseObject(strSysModel))) {
log.info("向[lite]同步系统模型成功");
}else{
log.error("向[lite]同步系统模型失败");
......@@ -123,7 +123,7 @@ public class PermissionSyncJob implements ApplicationRunner {
<#if hasWF>
try{
List<Map<String,Object>> bpmnfiles=new ArrayList();
List<Map<String,Object>> bpmnfiles = new ArrayList();
<#list sys.getAllPSWorkflows() as wf>
<#if wf.getPSWFVersions()??>
<#list wf.getPSWFVersions() as wfvs>
......@@ -131,23 +131,23 @@ public class PermissionSyncJob implements ApplicationRunner {
</#list>
</#if>
</#list>
if(client2.deployBpmnFile(bpmnfiles)){
if(client2.deployBpmnFile(bpmnfiles)) {
log.info("部署流程成功");
}else{
log.error("部署流程失败");
}
}catch(Exception ex){
}catch(Exception ex) {
log.error(String.format("部署流程失败,请检查[WF]服务是否正常! [%s]",ex));
}
</#if>
<#if hasMsgTemplate>
try {
InputStream msgTemplate= this.getClass().getResourceAsStream("/msgtempl/systemMsgTempl.json"); //获取当前系统所有实体资源能力
InputStream msgTemplate = this.getClass().getResourceAsStream("/msgtempl/systemMsgTempl.json"); //获取当前系统所有实体资源能力
String strMsgTemplate = IOUtils.toString(msgTemplate,"UTF-8");
JSONObject template= new JSONObject();
template.put("template",JSONArray.parseArray(strMsgTemplate));
if(notifyFeignClient.createMsgTemplate(template)){
JSONObject template = new JSONObject();
template.put("template", JSONArray.parseArray(strMsgTemplate));
if(notifyFeignClient.createMsgTemplate(template)) {
log.info("推送消息模板成功");
}else{
log.error("推送消息模板失败");
......@@ -159,9 +159,9 @@ public class PermissionSyncJob implements ApplicationRunner {
<#if hasPredefinedCodeList>
try {
InputStream runtimeDict= this.getClass().getResourceAsStream("/sysmodel/RuntimeDict.json"); //获取当前系统所有实体资源能力
InputStream runtimeDict = this.getClass().getResourceAsStream("/sysmodel/RuntimeDict.json"); //获取当前系统所有实体资源能力
String strRuntimeDict = IOUtils.toString(runtimeDict,"UTF-8");
if(dictFeignClient.syncRuntimeDict(JSONArray.parseArray(strRuntimeDict))){
if(dictFeignClient.syncRuntimeDict(JSONArray.parseArray(strRuntimeDict))) {
log.info("推送系统预置代码表成功");
}else{
log.error("推送系统预置代码表失败");
......
......@@ -45,12 +45,14 @@ public class AppController {
while(it.hasNext()) {
GrantedAuthority authority = (GrantedAuthority)it.next();
String strAuthority=authority.getAuthority();
if(strAuthority.startsWith("UNIRES_"+systemId))
if(strAuthority.startsWith("UNIRES_"+systemId)) {
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));
}
}
}
Map<String,Object> context = new HashMap<>();
context.putAll(curUser.getSessionParams());
context.put("srfusername",curUser.getPersonname());
......@@ -58,10 +60,12 @@ public class AppController {
appData.put("unires",uniRes);
appData.put("appmenu",appMenu);
appData.put("enablepermissionvalid",enablePermissionValid);
if(curUser.getSuperuser()==1)
if(curUser.getSuperuser()==1){
appData.put("enablepermissionvalid",false);
else
}
else{
appData.put("enablepermissionvalid",enablePermissionValid);
}
fillAppData(appData);
return ResponseEntity.status(HttpStatus.OK).body(appData);
}
......@@ -79,16 +83,18 @@ public class AppController {
@RequestMapping(method = RequestMethod.PUT, value = "/configs/{configType}/{targetType}")
public ResponseEntity<Boolean> saveConfig(@PathVariable("configType") String configType, @PathVariable("targetType") String targetType, @RequestBody JSONObject config) {
String userId=AuthenticationUser.getAuthenticationUser().getUserid();
if(StringUtils.isEmpty(userId))
if(StringUtils.isEmpty(userId)){
throw new BadRequestAlertException("保存配置失败,参数缺失","IBZConfig",configType);
}
return ResponseEntity.ok(ibzConfigService.saveConfig(configType,targetType,userId,config));
}
@RequestMapping(method = RequestMethod.GET, value = "/configs/{configType}/{targetType}")
public ResponseEntity<JSONObject> getConfig(@PathVariable("configType") String configType, @PathVariable("targetType") String targetType) {
String userId=AuthenticationUser.getAuthenticationUser().getUserid();
if(StringUtils.isEmpty(userId))
if(StringUtils.isEmpty(userId)){
throw new BadRequestAlertException("获取配置失败,参数缺失","IBZConfig",configType);
}
return ResponseEntity.ok(ibzConfigService.getConfig(configType,targetType,userId));
}
......
......@@ -41,18 +41,22 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
@Override
@SneakyThrows
public boolean hasPermission(Authentication authentication, Object entity, Object action) {
if(!enablePermissionValid)
if(!enablePermissionValid){
return true;
}
Object principal = authentication.getPrincipal();
if(ObjectUtils.isEmpty(principal))
if(ObjectUtils.isEmpty(principal)){
return false;
}
AuthenticationUser authenticationUser= (AuthenticationUser) authentication.getPrincipal();
if(authenticationUser.getSuperuser()==1)
if(authenticationUser.getSuperuser()==1){
return true;
}
String strAction=String.valueOf(action);
Set<String> userAuthorities = getAuthorities(authentication,strAction);
if(userAuthorities.size()==0)
if(userAuthorities.size()==0){
return false;
}
if(isAllData(strAction,userAuthorities)){
return true;
}
......@@ -105,8 +109,9 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
*/
@SneakyThrows
private void setPermissionCondToSearchContext(EntityBase entity, QueryWrapperContext qc , Set<String> userAuthorities ,AuthenticationUser authenticationUser){
if(entity==null)
if(entity==null){
return ;
}
Map<String,String> permissionField=getPermissionField(entity);//获取组织、部门预置属性
String orgField=permissionField.get("orgfield");
String orgDeptField=permissionField.get("orgsecfield");
......@@ -188,9 +193,10 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
Iterator it = authorities.iterator();
while(it.hasNext()) {
GrantedAuthority authority = (GrantedAuthority)it.next();
if(authority.getAuthority().contains(action))
if(authority.getAuthority().contains(action)){
userAuthorities.add(authority.getAuthority());
}
}
return userAuthorities;
}
......@@ -256,23 +262,27 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
}
if(action.endsWith("Create") || action.endsWith("Save")){
if(!ObjectUtils.isEmpty(orgFieldValue) && !userOrg.contains(orgFieldValue))
if(!ObjectUtils.isEmpty(orgFieldValue) && !userOrg.contains(orgFieldValue)){
return false;
if(!ObjectUtils.isEmpty(orgDeptFieldValue) && !userOrgDept.contains(orgDeptFieldValue))
}
if(!ObjectUtils.isEmpty(orgDeptFieldValue) && !userOrgDept.contains(orgDeptFieldValue)){
return false;
if(!ObjectUtils.isEmpty(crateManFieldValue) && !authenticationUser.getUserid().equals(crateManFieldValue))
}
if(!ObjectUtils.isEmpty(crateManFieldValue) && !authenticationUser.getUserid().equals(crateManFieldValue)){
return false;
}
return true;
}
else{
if(!ObjectUtils.isEmpty(orgFieldValue) && userOrg.contains(orgFieldValue))
if(!ObjectUtils.isEmpty(orgFieldValue) && userOrg.contains(orgFieldValue)){
return true;
if(!ObjectUtils.isEmpty(orgDeptFieldValue) && userOrgDept.contains(orgDeptFieldValue))
}
if(!ObjectUtils.isEmpty(orgDeptFieldValue) && userOrgDept.contains(orgDeptFieldValue)){
return true;
if(!ObjectUtils.isEmpty(crateManFieldValue) && authenticationUser.getUserid().equals(crateManFieldValue))
}
if(!ObjectUtils.isEmpty(crateManFieldValue) && authenticationUser.getUserid().equals(crateManFieldValue)){
return true;
}
return false;
}
}
......@@ -296,13 +306,19 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
String fieldName=entry.getKey();//获取注解字段
DEField fieldAnnotation=entry.getValue();//获取注解值
DEPredefinedFieldType prefieldType=fieldAnnotation.preType();
if(prefieldType==prefieldType.ORGID)//用户配置系统预置属性-组织机构标识
//用户配置系统预置属性-组织机构标识
if(prefieldType==prefieldType.ORGID){
orgField=fieldName;
if(prefieldType==prefieldType.ORGSECTORID)//用户配置系统预置属性-部门标识
}
//用户配置系统预置属性-部门标识
if(prefieldType==prefieldType.ORGSECTORID){
orgDeptField=fieldName;
if(prefieldType==prefieldType.CREATEMAN)//用户配置系统预置属性-部门标识
}
//用户配置系统预置属性-部门标识
if(prefieldType==prefieldType.CREATEMAN){
createManField=fieldName;
}
}
permissionFiled.put("orgfield",orgField);
permissionFiled.put("orgsecfield",orgDeptField);
permissionFiled.put("createmanfield",createManField);
......
......@@ -263,11 +263,13 @@ public class AuthenticationUser implements UserDetails
return this.sessionParams;
}
private Map<String, Object> getUserSessionParam() {
if(userSessionParam!=null)
if(userSessionParam!=null){
return userSessionParam;
else
}
else{
return new HashMap<>();
}
}
public void setOrgInfo(Map<String, Set<String>> orgInfo) {
this.orgInfo = orgInfo;
......
<#ibiztemplate>
TARGET=PSSYSTEM
</#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;
import io.jsonwebtoken.ExpiredJwtException;
......@@ -23,15 +31,20 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.*;
<#if validExpiredToken>
import org.springframework.util.StringUtils;
import org.springframework.util.ObjectUtils;
</#if>
@Slf4j
@Component
public class AuthorizationTokenFilter extends OncePerRequestFilter {
<#if validExpiredToken>
@Value(${r'"${ibiz.jwt.expiration:7200000}"'})
private Long expiration;
</#if>
private final UserDetailsService userDetailsService;
private final AuthTokenUtil authTokenUtil;
private final String tokenHeader;
......@@ -71,6 +84,9 @@ public class AuthorizationTokenFilter extends OncePerRequestFilter {
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
SecurityContextHolder.getContext().setAuthentication(authentication);
<#if validExpiredToken>
validExpiredToken(authToken,response);
</#if>
}
}
chain.doFilter(request, response);
......@@ -99,4 +115,25 @@ public class AuthorizationTokenFilter extends OncePerRequestFilter {
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 {
</#if>
@Override
@Cacheable( value="${cachename}",key = "'getByUsername:'+#p0")
@Cacheable( value="${cachename}", key = "'getByUsername:'+#p0")
AuthenticationUser loadUserByUsername(String username);
@Cacheable( value="${cachename}",key = "'getByUsername:'+#p0")
@Cacheable( value="${cachename}", key = "'getByUsername:'+#p0")
AuthenticationUser loadUserByLogin(String username,String password);
@CacheEvict( value="${cachename}",key = "'getByUsername:'+#p0")
@CacheEvict( value="${cachename}", key = "'getByUsername:'+#p0")
void resetByUsername(String username);
}
......@@ -34,37 +34,41 @@ public class IBZConfigService extends ServiceImpl<IBZConfigMapper, IBZConfig> im
@Value("${r'${'}ibiz.admin.userid:0100}")
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)
{
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);
IBZConfig config=this.getOne(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).build()),false);
if(config==null) {
config=this.getOne(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(adminuserid).build()),false);
if(config==null) {
}
IBZConfig config = this.getOne(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).build()), false);
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 JSON.parseObject(config.getCfg());
}
@CacheEvict( value="${cachename}",key = "'cfgid:'+#p0+'||'+#p1+'||'+#p2")
public boolean saveConfig(String cfgType,String targetType,String userId,JSONObject config)
@CacheEvict(value="${cachename}", key = "'cfgid:'+#p0+'||'+#p1+'||'+#p2")
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);
String cfg="{}";
if(config!=null)
cfg=JSONObject.toJSONString(config);
}
String cfg = "{}";
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());
}
@CacheEvict( value="${cachename}",key = "'cfgid:'+#p0+'||'+#p1+'||'+#p2")
public void resetConfig(String cfgType,String targetType,String userId)
@CacheEvict(value = "${cachename}", key = "'cfgid:'+#p0+'||'+#p1+'||'+#p2")
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);
}
this.remove(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).build()));
}
......
......@@ -14,9 +14,9 @@ import java.util.Map;
*/
public interface IBZDataAuditService {
@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")
void updateAudit(HttpServletRequest request, EntityBase beforeEntity, Object serviceObj, Object idValue, Map<String, Audit> auditFields);
@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{
@Override
public AuthenticationUser loadUserByUsername(String username) {
AuthenticationUser user=uaaFeignClient.loginByUsername(username);
if(user==null)
AuthenticationUser user = uaaFeignClient.loginByUsername(username);
if(user == null) {
throw new BadRequestAlertException("登录失败","IBZUAAUser",username);
}
return user;
}
@Override
public AuthenticationUser loadUserByLogin(String username, String password) {
String[] data=username.split("[|]");
String loginname=username;
String domains="";
String[] data = username.split("[|]");
String loginname = username;
String domains = "";
if(data.length==2) {
loginname=data[0].trim();
......@@ -50,9 +50,10 @@ public class IBZUAAUserService implements AuthenticationUserService{
logininfo.setDomain(domains);
logininfo.setLoginname(loginname);
logininfo.setPassword(password);
AuthenticationUser user=uaaFeignClient.login(logininfo);
if(user==null)
throw new BadRequestAlertException("登录失败","IBZUAAUser",username);
AuthenticationUser user = uaaFeignClient.login(logininfo);
if(user == null){
throw new BadRequestAlertException("登录失败","IBZUAAUser", username);
}
return user;
}
......
......@@ -31,20 +31,25 @@ public class IBZUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> impl
@Override
public AuthenticationUser loadUserByUsername(String username) {
if(StringUtils.isEmpty(username))
if(StringUtils.isEmpty(username)) {
throw new UsernameNotFoundException("用户名为空");
QueryWrapper<IBZUSER> conds=new QueryWrapper<IBZUSER>();
String[] data=username.split("[|]");
String loginname="";
String domains="";
if(data.length>0)
loginname=data[0].trim();
if(data.length>1)
domains=data[1].trim();
if(!StringUtils.isEmpty(loginname))
}
QueryWrapper<IBZUSER> conds = new QueryWrapper<IBZUSER>();
String[] data = username.split("[|]");
String loginname = "";
String domains = "";
if(data.length>0) {
loginname = data[0].trim();
}
if(data.length>1) {
domains = data[1].trim();
}
if(!StringUtils.isEmpty(loginname)) {
conds.eq("loginname",loginname);
if(!StringUtils.isEmpty(domains))
}
if(!StringUtils.isEmpty(domains)) {
conds.eq("domains",domains);
}
IBZUSER user = this.getOne(conds);
if (user == null) {
throw new UsernameNotFoundException("用户" + username + "未找到");
......@@ -58,11 +63,13 @@ public class IBZUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> impl
@Override
public AuthenticationUser loadUserByLogin(String username, String password){
AuthenticationUser authuserdetail = loadUserByUsername(username);
if(pwencrymode==1)
if(pwencrymode == 1){
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());
if(!authuserdetail.getPassword().equals( password )){
}
if(!authuserdetail.getPassword().equals(password)) {
throw new BadRequestAlertException("用户名密码错误","IBZUSER",username);
}
return authuserdetail;
......@@ -76,7 +83,7 @@ public class IBZUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> impl
public AuthenticationUser createUserDetails(IBZUSER user) {
AuthenticationUser userdatail = new AuthenticationUser();
CachedBeanCopier.copy(user,userdatail);
if(userdatail.getSuperuser()==1){
if(userdatail.getSuperuser() == 1){
userdatail.setAuthorities(AuthorityUtils.createAuthorityList("ROLE_SUPERADMIN"));
}
return userdatail;
......
......@@ -52,10 +52,10 @@ public class RemoteService {
*/
public interface RemoteFeignClient {
@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}")
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}")
JSONObject get( @PathVariable("path") String path, @RequestHeader("Authorization") String token);
......@@ -64,7 +64,7 @@ public class RemoteService {
JSONObject put( @PathVariable("path") String path, @RequestHeader("Authorization") String token,@RequestBody Map param);
@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 {
final HttpMessageConverters httpMessageConverters = new HttpMessageConverters(jsonConverter);
return () -> httpMessageConverters;
}
}
\ No newline at end of file
......@@ -26,20 +26,21 @@ public class SimpleFileService implements FileService {
@Override
public FileItem saveFile(MultipartFile multipartFile) {
FileItem item=null;
FileItem item = null;
// 获取文件名
String fileName = multipartFile.getOriginalFilename();
// 获取文件后缀
String extname="."+getExtensionName(fileName);
String extname = "."+getExtensionName(fileName);
try {
String fileid= DigestUtils.md5DigestAsHex(multipartFile.getInputStream());
String fileid = DigestUtils.md5DigestAsHex(multipartFile.getInputStream());
String fileFullPath = this.fileRoot+"ibizutil"+File.separator+fileid+File.separator+fileName;
File file = new File(fileFullPath);
File parent = new File(file.getParent());
if(!parent.exists())
if(!parent.exists()) {
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) {
throw new InternalServerErrorException("文件上传失败,"+e);
}
......
......@@ -27,19 +27,19 @@ import org.springframework.security.core.authority.AuthorityUtils;
@Primary
@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')")
public class SimpleUserService implements AuthenticationUserService{
public class SimpleUserService implements AuthenticationUserService {
@Override
public AuthenticationUser loadUserByUsername(String username) {
AuthenticationUser user = new AuthenticationUser();
String[] data=username.split("[|]");
String loginname=username;
String domains="";
String password="";
String[] data = username.split("[|]");
String loginname = username;
String domains = "";
String password = "";
if(data.length==2) {
loginname=data[0].trim();
domains=data[1].trim();
loginname = data[0].trim();
domains = data[1].trim();
}
user.setUserid(username);
......
......@@ -32,8 +32,9 @@ public class FeignRequestInterceptor implements RequestInterceptor {
if (headerNames != null) {
while (headerNames.hasMoreElements()) {
String name = headerNames.nextElement();
if(name.equalsIgnoreCase("transfer-encoding"))
if(name.equalsIgnoreCase("transfer-encoding")){
continue;
}
String values = request.getHeader(name);
requestTemplate.header(name, values);
}
......
......@@ -34,17 +34,14 @@ public class SearchContextHandlerMethodArgumentResolver implements HandlerMethod
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
Map<String, String[]> params = webRequest.getParameterMap();
LinkedHashMap<String,Object> set=new LinkedHashMap<>();
LinkedHashMap<String,Object> set = new LinkedHashMap<>();
for (String key : params.keySet()) {
set.put(key,params.get(key)[0]);
}
if((!set.containsKey("size")) ){
set.put("size",pageLimit);
set.put("size", pageLimit);
}
String json=objectMapper.writeValueAsString(set);
return objectMapper.readValue(json,parameter.getParameterType());
String json = objectMapper.writeValueAsString(set);
return objectMapper.readValue(json, parameter.getParameterType());
}
}
\ No newline at end of file
......@@ -15,3 +15,4 @@ TARGET=PSSYSTEM
**.iml
*.jar
*.log
.DS_Store
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册