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

合并分支 'dev' 到 'master'

Dev

查看合并请求 !34
# **iBiz4j Spring R7 Template ChangeLog**
## [v2020.11.09]
- 支持属性重复值检查
- 支持引用组件包配置
- 支持定时任务中调用实体行为
- 修复serviceApi实体update脏检查处理
- 添加全局异常处理,数据库级异常补充errorKey
- 补充appData user扩展
- 系统预定义代码表推送RT
## [v2020.10.28]
- 修复虚拟联合主键模板错误
......
......@@ -52,10 +52,10 @@ zuul:
<#assign serviceUrl=srfpluralize(appDataEntity.name?lower_case)>
<#if serviceId!="">
<#assign serviceId="$"+"{ibiz.ref.service."+serviceId?lower_case+":"+serviceId+"}">
${appEntity}:
path: /${serviceUrl}/**
serviceId: ${serviceId}
stripPrefix: false
${appEntity}:
path: /${serviceUrl}/**
serviceId: ${serviceId}
stripPrefix: false
</#if>
</#if>
</#list>
......@@ -66,59 +66,59 @@ zuul:
stripPrefix: true
</#if>
<#if sys.getPSSystemSetting()?? && sys.getPSSystemSetting().getDataAccCtrlArch()?? && sys.getPSSystemSetting().getDataAccCtrlArch()==1>
loginv7:
path: /v7/login
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
changepwd:
path: /v7/changepwd
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
uaa:
path: /uaa/**
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
config:
path: /configs/**
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
loginv7:
path: /v7/login
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
changepwd:
path: /v7/changepwd
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
uaa:
path: /uaa/**
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
config:
path: /configs/**
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
<#if sys.getCodeName()!='ibzou' && sys.getCodeName()!='ibzrt'>
oucore:
path: /ibzorganizations/**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
oudict:
path: /dictionarys/**/Ibzou**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
ou:
path: /ibzdepartments/**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
uaadict:
path: /dictionarys/**/SysOperator
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
dict:
path: /dictionarys/**
serviceId: ${r'${ibiz.ref.service.dict:ibzdict-api}'}
stripPrefix: false
disk:
path: /net-disk/**
serviceId: ${r'${ibiz.ref.service.disk:ibzdisk-api}'}
stripPrefix: false
ou_sys_org:
path: /sysorganizations/**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
ou_sys_dept:
path: /sysdepartments/**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
lite-core:
path: /lite/**
serviceId: ${r'${ibiz.ref.service.lite:ibzlite-api}'}
stripPrefix: false
oucore:
path: /ibzorganizations/**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
oudict:
path: /dictionarys/**/Ibzou**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
ou:
path: /ibzdepartments/**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
uaadict:
path: /dictionarys/**/SysOperator
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
dict:
path: /dictionarys/**
serviceId: ${r'${ibiz.ref.service.dict:ibzdict-api}'}
stripPrefix: false
disk:
path: /net-disk/**
serviceId: ${r'${ibiz.ref.service.disk:ibzdisk-api}'}
stripPrefix: false
ou_sys_org:
path: /sysorganizations/**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
ou_sys_dept:
path: /sysdepartments/**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
lite-core:
path: /lite/**
serviceId: ${r'${ibiz.ref.service.lite:ibzlite-api}'}
stripPrefix: false
</#if>
</#if>
<#comment>通过设置该参数,避免Zuul转发请求时丢失Authorization请求头信息</#comment>
......
......@@ -23,6 +23,7 @@ import ${pub.getPKGCodeName()}.util.annotation.DEField;
import ${pub.getPKGCodeName()}.util.enums.DEPredefinedFieldType;
import ${pub.getPKGCodeName()}.util.enums.DEFieldDefaultValueType;
import ${pub.getPKGCodeName()}.util.helper.DataObject;
import ${pub.getPKGCodeName()}.util.enums.DupCheck;
import java.io.Serializable;
import lombok.*;
import org.springframework.data.annotation.Transient;
......@@ -114,6 +115,18 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
</#if>
</#if>
</#if>
<#comment>重复值检查</#comment>
<#if defield.getDupCheckMode?? && defield.getDupCheckMode()?? && defield.getDupCheckMode()=='ALL'>
<#if defieldano?? && defieldano!='' >
<#assign defieldano = defieldano+" , ">
</#if>
<#if defield.getDupCheckPSDEField?? && defield.getDupCheckPSDEField()??>
<#assign dupCheckField = srfcaseformat(defield.getDupCheckPSDEField().getCodeName(),'l_u2lC') >
<#assign defieldano=defieldano+"dupCheck = DupCheck.ALL , dupCheckField=\""+dupCheckField+"\"">
<#else>
<#assign defieldano=defieldano+"dupCheck = DupCheck.ALL" >
</#if>
</#if>
/**
* ${defield.getLogicName()}
*/
......
......@@ -38,7 +38,7 @@ import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower
<#comment>SQL存储-Mybatis</#comment>
<#if de.getStorageMode()==1>
<#assign keyfield=item.getKeyPSDEField()>
import com.baomidou.mybatisplus.extension.service.IService;
/**
......@@ -63,13 +63,13 @@ 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<String> ids) ;
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>
<#elseif de.getStorageMode()==2>
<#assign keyfield=item.getKeyPSDEField()>
/**
* 实体[${item.codeName}] 服务对象接口
*/
......@@ -78,7 +78,7 @@ public interface I${item.codeName}Service{
<@addIDESerivceBody />
<#if hasDEPrefield>
List<${de.codeName}> get${deCodeNameCamel}ByIds(List<String> ids) ;
List<${de.codeName}> get${deCodeNameCamel}ByIds(List<${srfr7javatype(keyfield.stdDataType)}> ids) ;
List<${de.codeName}> get${deCodeNameCamel}ByEntities(List<${de.codeName}> entities) ;
</#if>
}
......
......@@ -66,6 +66,7 @@ TARGET=PSDATAENTITY
<#break>
</#list>
</#if>
<#assign isDupCheck=isDupCheckEntity(de)>
package ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.service.impl;
import java.io.Serializable;
......@@ -881,7 +882,7 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<#if hasDEPrefield>
@Override
public List<${de.codeName}> get${deCodeNameCamel}ByIds(List<String> ids) {
public List<${de.codeName}> get${deCodeNameCamel}ByIds(List<${srfr7javatype(keyfield.stdDataType)}> ids) {
return this.listByIds(ids);
}
......@@ -962,6 +963,9 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<#comment>发布es服务对象</#comment>
<@esAnno/>
<#comment>重复值检查-searchContext</#comment>
<@outputSearchContext/>
}
<#comment>NOSQL存储</#comment>
......@@ -1422,7 +1426,7 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<#if hasDEPrefield>
@Override
public List<${de.codeName}> get${deCodeNameCamel}ByIds(List<String> ids) {
public List<${de.codeName}> get${deCodeNameCamel}ByIds(List<${srfr7javatype(keyfield.stdDataType)}> ids) {
QueryBuilder permissionCond=new QueryBuilder();
permissionCond.and("${keyfield.codeName?lower_case}").in(ids);
Query query = new BasicQuery(permissionCond.get().toString());
......@@ -1455,6 +1459,9 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<#comment>发布es服务对象</#comment>
<@esAnno/>
<#comment>重复值检查-SearchContext</#comment>
<@outputSearchContext/>
}
......@@ -1965,6 +1972,9 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<#comment>实体数据导入</#comment>
<@deImportData/>
<#comment>重复值检查-SearchContext</#comment>
<@outputSearchContext/>
}
<#comment>无存储</#comment>
......@@ -2955,4 +2965,31 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
</#macro>
<#comment>输出SearchContext,用于属性重复值检查</#comment>
<#macro outputSearchContext>
<#if isDupCheck>
/**
* 获取searchContext
* @return
*/
public ${de.codeName}SearchContext getSearchContext(){
return new ${de.codeName}SearchContext();
}
</#if>
</#macro>
<#comment>判断属性是否配置了重复值检查</#comment>
<#function isDupCheckEntity dataEntity>
<#assign dupCheck=false>
<#if dataEntity.getAllPSDEFields()??>
<#list dataEntity.getAllPSDEFields() as defield>
<#if defield.getDupCheckMode?? && defield.getDupCheckMode()?? && defield.getDupCheckMode()=='ALL'>
<#assign dupCheck=true>
<#break>
</#if>
</#list>
</#if>
<#return dupCheck>
</#function>
</#if>
......@@ -7,13 +7,35 @@ import com.baomidou.jobs.api.JobsResponse;
import com.baomidou.jobs.exception.JobsException;
import com.baomidou.jobs.handler.IJobsHandler;
import org.springframework.stereotype.Component;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import lombok.extern.slf4j.Slf4j;
<#assign hasDEAction=false>
<#if item.getPSDataEntity?? && item.getPSDataEntity()?? && item.getPSDEAction?? && item.getPSDEAction()??>
<#assign hasDEAction=true>
<#assign de=item.getPSDataEntity()>
<#assign deaction=item.getPSDEAction()>
</#if>
@Slf4j
@Component("${item.codeName}JobHandler")
public class ${item.codeName}JobHandler implements IJobsHandler {
public class ${item.codeName}JobHandler implements IJobsHandler {
<#if hasDEAction>
@Autowired
@Lazy
protected ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.service.I${de.getCodeName()}Service ${srfcaseformat(de.getCodeName(),'l_u2lC')}Service;
</#if>
@Override
public JobsResponse execute(String tenantId, String param) throws JobsException {
System.out.println("执行 DemoJobHandler tenantId=" + tenantId + ",param=" + param);
<#if hasDEAction>
${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.domain.${de.codeName} entity=new ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.domain.${de.codeName}();
entity.set("tenantid",tenantId);
entity.set("param",param);
${srfcaseformat(de.getCodeName(),'l_u2lC')}Service.${srfmethodname(deaction.getCodeName())}(entity);
</#if>
log.info("执行 DemoJobHandler tenantId=" + tenantId + ",param=" + param);
return JobsResponse.ok();
}
}
......@@ -45,7 +45,7 @@ TARGET=PSSYSTEM
<#if defield.getPrecision()?c!='0'>
"data_preci":${defield.getPrecision()?c},
</#if>
<#if defield.getDefaultPSDEFDTColumn()?? && defield.getDefaultPSDEFDTColumn().isFormula()==true>
<#if defield.getDefaultPSDEFDTColumn?? && defield.getDefaultPSDEFDTColumn()?? && defield.getDefaultPSDEFDTColumn().isFormula()==true>
"expression":"${defield.getDefaultPSDEFDTColumn().getFormulaFormat()}",
</#if>
<#if defield.getPredefinedType()?? && defield.getPredefinedType()!=''>
......
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#comment>系统是否包含预定义代码表</#comment>
<#assign hasPredefinedCodeList=false>
<#list sys.getAllPSCodeLists() as codelist>
<#if codelist.getPredefinedType()?? && codelist.getPredefinedType()=='RUNTIME'>
<#assign hasPredefinedCodeList=true>
<#break>
</#if>
</#list>
<#if hasPredefinedCodeList>
<#assign isFirstCodeList=true>
[ <#list sys.getAllPSCodeLists() as codelist>
<#if codelist.getPredefinedType()?? && codelist.getPredefinedType()=='RUNTIME'>
<#if isFirstCodeList==false>,</#if>
{
"name":"${codelist.name}",
"code":"${codelist.codeName}",
"group":"",
"memo":"",
"enable":"",
<#if codelist.getAllPSCodeItems()??>
"items":[<#list codelist.getAllPSCodeItems() as codeItem>
{
"catalog_id":"${codelist.codeName}",
"catalog_name":"${codelist.name}",
"value_key":"${codelist.codeName}-${codeItem.codeName}",
"value":"${codeItem.value}",
"label":"${codeItem.text}",
"disabled":"",
"showorder":""
<#if codeItem.getParentCodeItem?? && codeItem.getParentCodeItem()??>
,"parent":"${codeItem.getParentCodeItem().value}"
</#if>
}<#if codeItem_has_next>,</#if>
</#list>
]
</#if>
}
<#assign isFirstCodeList=false>
</#if>
</#list>
]
</#if>
\ No newline at end of file
......@@ -270,12 +270,6 @@ TARGET=PSSYSTEM
<version>${r'${jsonwebtoken-jjwt.version}'}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${r'${alibaba-druid.version}'}</version>
</dependency>
<dependency>
<groupId>org.zalando</groupId>
<artifactId>problem-spring-web</artifactId>
......@@ -435,6 +429,16 @@ TARGET=PSSYSTEM
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
</#if>
<#comment>引用组件包</#comment>
<#if pub.getPSSysSFPubPkgs?? && pub.getPSSysSFPubPkgs()??>
<#list pub.getPSSysSFPubPkgs() as package>
<#if package.getPkgParam?? && package.getPkgParam()??>
${package.getPkgParam()}
</#if>
</#list>
</#if>
</dependencies>
</project>
......@@ -5,6 +5,7 @@ package ${pub.getPKGCodeName()}.util.annotation;
import ${pub.getPKGCodeName()}.util.enums.DEFieldDefaultValueType;
import ${pub.getPKGCodeName()}.util.enums.DEPredefinedFieldType;
import ${pub.getPKGCodeName()}.util.enums.DupCheck;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
......@@ -69,5 +70,14 @@ public @interface DEField
* @return
*/
String format() default "";
/**
* 重复性检查
* @return
*/
DupCheck dupCheck() default DupCheck.NONE;
/**
* 范围属性
*/
String dupCheckField() default "";
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#assign hasDupCheckEntity=false>
<#list sys.getAllPSDataEntities() as dataEntity>
<#assign isDupCheck=isDupCheckEntity(dataEntity)>
<#if isDupCheck>
<#assign hasDupCheckEntity=true>
<#break>
</#if>
</#list>
<#if hasDupCheckEntity>
package ${pub.getPKGCodeName()}.util.aspect;
import lombok.extern.slf4j.Slf4j;
import ${pub.getPKGCodeName()}.util.annotation.DEField;
import ${pub.getPKGCodeName()}.util.enums.DupCheck;
import ${pub.getPKGCodeName()}.util.errors.BadRequestAlertException;
import ${pub.getPKGCodeName()}.util.filter.QueryFilter;
import ${pub.getPKGCodeName()}.util.filter.SearchContextBase;
import ${pub.getPKGCodeName()}.util.helper.DEFieldCacheMap;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.data.domain.Page;
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.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.util.Map;
/**
* 属性重复值检查切面
*/
@Aspect
@Component
@Slf4j
public class DupCheckAspect {
private final ExpressionParser parser = new SpelExpressionParser();
<#list sys.getAllPSDataEntities() as dataEntity>
<#assign isDupCheck=isDupCheckEntity(dataEntity)>
<#assign hasDefaultDS=checkDefaultDS(dataEntity)>
<#if isDupCheck && hasDefaultDS>
/**
* 实体[${dataEntity.codeName}]
*
* @param point
*/
@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.es.service.*.create*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.update*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.save*(..)) ")
public void check${dataEntity.codeName?lower_case?cap_first}(JoinPoint point) {
check(point, "search${dataEntity.getDefaultPSDEDataSet().codeName}");
}
</#if>
</#list>
/**
* 实体属性重复值检查
* @param point 切点
* @param defaultDS 实体默认数据集名称
*/
private void check(JoinPoint point, String defaultDS) {
Object[] args = point.getArgs();
if (args.length > 0) {
Object entity = args[0];
Object service = point.getTarget();
Map<String, DEField> deFields = DEFieldCacheMap.getDEFields(entity.getClass());
for (Map.Entry<String, DEField> deField : deFields.entrySet()) {
String fieldName = deField.getKey();
DEField fieldAnnotation = deField.getValue();
DupCheck dupCheck = fieldAnnotation.dupCheck();
String dupCheckField=fieldAnnotation.dupCheckField();
if (dupCheck == DupCheck.ALL) {
Object newValue =getDEFieldValue(entity,fieldName);
//获取searchContext
EvaluationContext searchContextCtx = new StandardEvaluationContext();
searchContextCtx.setVariable("service", service);
Expression searchContextExp = parser.parseExpression("#service.getSearchContext()");
SearchContextBase searchContext = searchContextExp.getValue(searchContextCtx, SearchContextBase.class);
//设置检查属性值
QueryFilter filter = new QueryFilter();
setValue(entity,filter,fieldName,newValue);
//设定重复值检查范围
if(!StringUtils.isEmpty(dupCheckField)){
Object dupFieldValue=getDEFieldValue(entity,dupCheckField);
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));
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");
}
}
}
}
}
/**
* 获取实体属性值
* @param entity
* @param fieldName
* @return
*/
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));
return esMappingExp.getValue(exMappingCtx);
}
/**
* 设置filter
* @param entity
* @param filter
* @param value
*/
private void setValue(Object entity , QueryFilter filter, String fieldName, Object value){
if(ObjectUtils.isEmpty(value))
filter.isnull(DEFieldCacheMap.getFieldColumnName(entity.getClass(), fieldName));
else
filter.eq(DEFieldCacheMap.getFieldColumnName(entity.getClass(), fieldName),value);
}
}
</#if>
<#comment>判断属性是否配置了重复值检查</#comment>
<#function isDupCheckEntity dataEntity>
<#assign dupCheck=false>
<#if dataEntity.getAllPSDEFields()??>
<#list dataEntity.getAllPSDEFields() as defield>
<#if defield.getDupCheckMode?? && defield.getDupCheckMode()?? && defield.getDupCheckMode()=='ALL'>
<#assign dupCheck=true>
<#break>
</#if>
</#list>
</#if>
<#return dupCheck>
</#function>
<#comment>判断实体中是否配置了默认数据集</#comment>
<#function checkDefaultDS dataEntity>
<#assign defaultDS=false>
<#if dataEntity.getDefaultPSDEDataSet?? && dataEntity.getDefaultPSDEDataSet()?? && dataEntity.getDefaultPSDEDataSet().getPSDEDataQueries()??>
<#list dataEntity.getDefaultPSDEDataSet().getPSDEDataQueries() as dq>
<#assign defaultDS=true>
<#break>
</#list>
</#if>
<#return defaultDS>
</#function>
\ No newline at end of file
<#ibiztemplate>
TARGET=PSDATAENTITY
TARGET=PSSYSTEM
</#ibiztemplate>
<#assign hasESEntity=false>
<#list sys.getAllPSDataEntities() as dataEntity>
......@@ -9,7 +9,7 @@ TARGET=PSDATAENTITY
</#if>
</#list>
<#if hasESEntity==true>
package ${pub.getPKGCodeName()}.util.es.aspect;
package ${pub.getPKGCodeName()}.util.aspect;
import lombok.extern.slf4j.Slf4j;
import ${pub.getPKGCodeName()}.util.domain.EntityBase;
......
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#comment>系统是否包含预定义代码表</#comment>
<#assign hasPredefinedCodeList=false>
<#list sys.getAllPSCodeLists() as codelist>
<#if codelist.getPredefinedType()?? && codelist.getPredefinedType()=='RUNTIME'>
<#assign hasPredefinedCodeList=true>
<#break>
</#if>
</#list>
<#if hasPredefinedCodeList>
package ${pub.getPKGCodeName()}.util.client;
import com.alibaba.fastjson.JSONArray;
import org.springframework.stereotype.Component;
@Component
public class IBZDictFallback implements IBZDictFeignClient {
@Override
public Boolean syncRuntimeDict(JSONArray catalogs) {
return null;
}
}
</#if>
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#comment>系统是否包含预定义代码表</#comment>
<#assign hasPredefinedCodeList=false>
<#list sys.getAllPSCodeLists() as codelist>
<#if codelist.getPredefinedType()?? && codelist.getPredefinedType()=='RUNTIME'>
<#assign hasPredefinedCodeList=true>
<#break>
</#if>
</#list>
<#if hasPredefinedCodeList>
package ${pub.getPKGCodeName()}.util.client;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.List;
import java.util.Map;
@FeignClient(value = "${r'${ibiz.ref.service.dict:ibzdict-api}'}",contextId = "dict",fallback = IBZDictFallback.class)
public interface IBZDictFeignClient
{
@RequestMapping(method = RequestMethod.POST, value = "/dictionarys/catalogs/sync")
Boolean syncRuntimeDict(@RequestBody JSONArray catalogs);
}
</#if>
\ No newline at end of file
......@@ -9,9 +9,9 @@ public class EntityClient extends EntityBase {
@Override
public void modify(String field,Object val) {
getExtensionparams().put("dirtyflagenable",true);
if(val==null){
this.getFocusNull().add(field.toLowerCase());
getExtensionparams().put("dirtyflagenable",true);
getExtensionparams().put(field.toLowerCase()+"dirtyflag",true);
}
else{
......
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.enums;
/**
* 属性重复值检查
*/
public enum DupCheck {
/**
* 不检查
*/
NONE,
/**
* 全部检查
*/
ALL,
/**
* 非空检查
*/
NOTNULL,
/**
* 指定范围检查
*/
RANGE,
}
......@@ -4,7 +4,7 @@ TARGET=PSSYSTEM
package ${pub.getPKGCodeName()}.util.errors;
import org.springframework.dao.ConcurrencyFailureException;
import org.springframework.dao.*;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
......@@ -93,9 +93,18 @@ public class ExceptionTranslator implements ProblemHandling {
return create(ex, problem, request);
}
@ExceptionHandler(DataAccessException.class)
public ResponseEntity<Problem> handlerDataAccessFailure(DataAccessException ex, NativeWebRequest request){
Problem problem = Problem.builder()
.withStatus(Status.INTERNAL_SERVER_ERROR)
.with("message", ex.getMessage())
.build();
return create(ex, problem, request,createFailureAlert(ex.getClass().getSimpleName(), ex.getClass().getSimpleName(), ex.getMessage()));
}
public static HttpHeaders createFailureAlert(String entityName, String errorKey, String defaultMessage) {
HttpHeaders headers = new HttpHeaders();
headers.add("X-ibz-error", "error." + errorKey);
headers.add("X-ibz-error", errorKey);
headers.add("X-ibz-params", entityName);
return headers;
}
......
......@@ -20,6 +20,14 @@ TARGET=PSSYSTEM
<#break>
</#list>
</#if>
<#comment>系统是否包含预定义代码表</#comment>
<#assign hasPredefinedCodeList=false>
<#list sys.getAllPSCodeLists() as codelist>
<#if codelist.getPredefinedType()?? && codelist.getPredefinedType()=='RUNTIME'>
<#assign hasPredefinedCodeList=true>
<#break>
</#if>
</#list>
package ${pub.getPKGCodeName()}.util.job;
import ${pub.getPKGCodeName()}.util.client.IBZUAAFeignClient;
......@@ -73,6 +81,12 @@ public class PermissionSyncJob implements ApplicationRunner {
@Lazy
IBZLiteFeignClient liteFeignClient;
<#if hasPredefinedCodeList>
@Autowired
@Lazy
${pub.getPKGCodeName()}.util.client.IBZDictFeignClient dictFeignClient;
</#if>
@Override
public void run(ApplicationArguments args) {
try {
......@@ -142,5 +156,19 @@ public class PermissionSyncJob implements ApplicationRunner {
log.error("推送消息模板失败");
}
</#if>
<#if hasPredefinedCodeList>
try {
InputStream runtimeDict= this.getClass().getResourceAsStream("/sysmodel/RuntimeDict.json"); //获取当前系统所有实体资源能力
String strRuntimeDict = IOUtils.toString(runtimeDict,"UTF-8");
if(dictFeignClient.syncRuntimeDict(JSONArray.parseArray(strRuntimeDict))){
log.info("推送系统预置代码表成功");
}else{
log.error("推送系统预置代码表失败");
}
} catch (Exception e) {
log.error("推送系统预置代码表失败");
}
</#if>
}
}
\ No newline at end of file
......@@ -62,6 +62,7 @@ public class AppController {
appData.put("enablepermissionvalid",false);
else
appData.put("enablepermissionvalid",enablePermissionValid);
fillAppData(appData);
return ResponseEntity.status(HttpStatus.OK).body(appData);
}
......@@ -90,4 +91,12 @@ public class AppController {
throw new BadRequestAlertException("获取配置失败,参数缺失","IBZConfig",configType);
return ResponseEntity.ok(ibzConfigService.getConfig(configType,targetType,userId));
}
/**
* 应用参数扩展
* @param appData
*/
protected void fillAppData(JSONObject appData){
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册