提交 dce5b4d0 编写于 作者: yanshaowei's avatar yanshaowei

init

上级
流水线 #224 已失败 ,包含阶段
# Changelog 模板变更日志
## [1.0.2] - 2019-08-17
### 修改内容
- 实体支持数据审计
## [1.0.1] - 2019-08-11
### 修改内容
- 解决do属性名与代码名不一致时,mybatis查询结果无法注入do
- 解决处理逻辑直接参数赋值参数类型转换问题
## [1.0.0] - 2019-07-15
### 修改内容
- update去掉dirtyflag,先get再save,xml去掉update one.
- 暂时去掉domain中的校验注解.
- domain主键生成规则由input改为uuid.
- selectRow由mapper.xml迁入mapper.java.
- 去掉rest目录中的api相关逻辑.
- 实体自定义行为返回domain.
- 将get行为中的返回值通过beanCopy拷贝到原对象中返回.
- 前后台项目合并,control -->Rest , vo-->domain.去掉moudle,只留一个srv
- 引入docker.
- 系统预定义属性走切面模式.
- 多数据源切换,@ds注解发在mapper中.
- searchfilterBase中去掉dataContext,activeContext属性.只留get方法
- 引入redis,get发缓存,create,update,delete时更新缓存.
- 支持临时模式.
\ No newline at end of file
<#ibiztemplate>
TARGET=PSDATAENTITY
</#ibiztemplate>
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#if sysrun.getPSDBDevInst()??>
<#assign dbinst = sysrun.getPSDBDevInst()>
:: 脚本使用须知:该脚本用于在进行数据库更新时,针对本次更新的脚本,对应输出的回滚脚本(注意:执行该脚本前请将diff出来的changelog拷贝到源目录对应的classes目录下)
:: 指令1: liquibase : tag 说明:用于在【databaseChangelog】表中标记更新前最后一次的更新点
:: 指令2: liquibase : futureRollbackSQL 说明:输出最后一次更新点以后的更新脚本对应的回滚脚本
echo begin
call mvn org.liquibase:liquibase-maven-plugin:3.6.3:tag -Dliquibase.tag=rollbacktag -Dliquibase.driver=org.h2.Driver -Dliquibase.url="jdbc:h2:~/h2/last_db/${dbinst.getUserName()};MODE=ORACLE;INIT=runscript from 'src/main/resources/liquibase/config/init_h2.sql';" -DdefaultSchemaName=${dbinst.getUserName()} -Dliquibase.username=${dbinst.getUserName()}
call mvn org.liquibase:liquibase-maven-plugin:3.6.3:futureRollbackSQL -Dliquibase.rollbackTag=201906161758 -Dliquibase.driver=org.h2.Driver -Dliquibase.changeLogFile=src/main/resources/liquibase/master.xml -Dliquibase.url="jdbc:h2:~/h2/last_db/${dbinst.getUserName()};MODE=ORACLE;INIT=runscript from 'src/main/resources/liquibase/config/init_h2.sql';" -DdefaultSchemaName=${dbinst.getUserName()} -Dliquibase.username=${dbinst.getUserName()} -Dliquibase.outputFile=src/main/resources/liquibase/rollback/rollback_future.sql
echo done
pause
</#if>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#if sysrun.getPSDBDevInst()??>
<#assign dbinst = sysrun.getPSDBDevInst()>
:: 脚本使用须知:该脚本用于将ibiz平台中最新的表结构与生产环境中的表结构(镜像)做差异比较,得出差异内容,将差异内容更新到生产环境中实现数据库同步。
:: 指令1: liquibase : tag 说明:用于在【databaseChangelog】表中标记更新前最后一次的更新点
:: 指令2: liquibase : futureRollbackSQL 说明:输出最后一次更新点以后的更新脚本对应的回滚脚本
echo begin
call mvn org.liquibase:liquibase-maven-plugin:3.6.3:update -Dliquibase.driver=org.h2.Driver -Dliquibase.changeLogFile=src/main/resources/liquibase/h2_table.xml -Dliquibase.url="jdbc:h2:~/h2/ibzdbmirror/${dbinst.getUserName()};MODE=ORACLE;INIT=runscript from 'src/main/resources/liquibase/config/init_h2.sql';" -DdefaultSchemaName=${dbinst.getUserName()} -Dliquibase.username=${dbinst.getUserName()} -Dliquibase.dropFirst=true
call mvn org.liquibase:liquibase-maven-plugin:3.6.3:update -Dliquibase.driver=org.h2.Driver -Dliquibase.changeLogFile=src/main/resources/liquibase/master_table.xml -Dliquibase.url="jdbc:h2:~/h2/last_db/${dbinst.getUserName()};MODE=ORACLE;INIT=runscript from 'src/main/resources/liquibase/config/init_h2.sql';" -DdefaultSchemaName=${dbinst.getUserName()} -Dliquibase.username=${dbinst.getUserName()} -Dliquibase.dropFirst=true
call mvn org.liquibase:liquibase-maven-plugin:3.6.3:diff -Dliquibase.driver=org.h2.Driver -Dliquibase.changeLogFile=src/main/resources/liquibase/empty.xml -Dliquibase.diffChangeLogFile="src/main/resources/liquibase/changelog/%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%_diff.xml" -Dliquibase.url="jdbc:h2:~/h2/last_db/${dbinst.getUserName()};MODE=ORACLE;INIT=runscript from 'src/main/resources/liquibase/config/init_h2.sql';" -Dliquibase.username=${dbinst.getUserName()} -Dliquibase.referenceUrl="jdbc:h2:~/h2/ibzdbmirror/${dbinst.getUserName()};MODE=ORACLE;INIT=runscript from 'src/main/resources/liquibase/config/init_h2.sql';" -Dliquibase.referenceUsername=${dbinst.getUserName()} -Dliquibase.referenceDefaultSchemaName=${dbinst.getUserName()} -Dliquibase.defaultSchemaName=${dbinst.getUserName()} -Dliquibase.diffExcludeObjects="Index:.*,table:IBZFILE,IBZUSER,IBZDATAAUDIT"
echo done
pause
</#if>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>${pub.getCodeName()?lower_case}-srv</artifactId>
<name>${pub.getCodeName()?lower_case}-srv</name>
<packaging>jar</packaging>
<parent>
<artifactId>${sys.codeName}</artifactId>
<groupId>${pub.getPKGCodeName()}</groupId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<#assign mspkg = pub.getPKGCodeName()>
<#assign msmain = pub.codeName+"Main">
<dependencies>
</dependencies>
<build>
<resources>
<resource>
<directory>${r'${basedir}'}/src/main/webapp</directory>
<targetPath>META-INF/resources</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
<resource>
<directory>${r'${basedir}'}/src/main/resources</directory>
<includes>
<include>**/**</include>
</includes>
</resource>
<resource>
<directory>src/main/docker</directory>
<filtering>true</filtering>
<includes>
<include>**/Dockerfile</include>
</includes>
<targetPath>../docker</targetPath>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>${sys.codeName?lower_case}</finalName>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<#if msmain??>
<mainClass>${mspkg?lower_case}.boot.${pub.getCodeName()?lower_case}Main</mainClass>
</#if>
<outputDirectory>../</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.0</version>
<configuration>
<dockerDirectory>target/docker</dockerDirectory>
<registryUrl>registry.ibiz5.com:5000</registryUrl>
<imageName>
registry.ibiz5.com:5000/sadept2/${sys.codeName?lower_case}:latest
</imageName>
<imageTags>
<imageTag>latest</imageTag>
</imageTags>
<resources>
<rescource>
<targetPath>/</targetPath>
<directory>../</directory>
<include>${sys.codeName?lower_case}.jar</include>
</rescource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
<#if sys.getAllPSApps()??>
<profiles>
<profile>
<id>prod</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>exec-yarn-run-install</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>yarn</executable>
<workingDirectory>../app_${pub.getPSApplication().getPKGCodeName()}</workingDirectory>
</configuration>
</execution>
<execution>
<id>exec-yarn-run-build</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>yarn</executable>
<arguments>
<argument>build</argument>
</arguments>
<workingDirectory>../app_${pub.getPSApplication().getPKGCodeName()}</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</#if>
</project>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
FROM openjdk:8-jre-alpine
ENV SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \
IBZ_SLEEP=0 \
JAVA_OPTS=""
CMD echo "The application will start in ${r'${IBZ_SLEEP}'}s..." && \
sleep ${r'${IBZ_SLEEP}'} && \
java ${r'${JAVA_OPTS}'} -Djava.security.egd=file:/dev/./urandom -jar /${pub.getCodeName()?lower_case}.jar
EXPOSE 8080
ADD ${pub.getCodeName()?lower_case}.jar /${pub.getCodeName()?lower_case}.jar
<#ibiztemplate>
TARGET=PSCODELIST
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${item.getPSSystemModule().codeName?lower_case}.codelist;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import org.springframework.util.StringUtils;
import org.springframework.stereotype.Component;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import ${pub.getPKGCodeName()}.ibizutil.domain.CodeList;
import ${pub.getPKGCodeName()}.ibizutil.domain.CodeItem;
<#comment>定义实体服务</#comment>
<#if item.getCodeListType() == "DYNAMIC" && item.getPSDataEntity()??>
import ${pub.getPKGCodeName()}.${item.getPSDataEntity().getPSSystemModule().codeName?lower_case}.service.${item.getPSDataEntity().codeName}Service;
</#if>
/**
* 代码表[${item.name}]
*/
@Component("${sys.codeName}_${item.codeName}CodeList")
public class ${item.codeName}CodeList extends ${pub.getPKGCodeName()}.ibizutil.domain.CodeListBase{
@PostConstruct
protected void init()
{
}
<#if item.getCodeListType() == "DYNAMIC" && item.getPSDataEntity()??>
@Autowired
private ${item.getPSDataEntity().codeName}Service ${item.getPSDataEntity().codeName?lower_case}Service;
protected ${item.getPSDataEntity().codeName}Service get${item.getPSDataEntity().codeName}Service(){
return ${item.getPSDataEntity().codeName?lower_case}Service;
}
</#if>
<#assign bTree=false>
@Override
public void initCodeList() <#if item.getCodeListType() == "DYNAMIC" && item.getPSDataEntity()??></#if> {
CodeList codeList = new CodeList();
codeList.setSrfkey("${sys.codeName}_${item.codeName}");
List<CodeItem> codeItemList = new ArrayList<CodeItem>();
<#if item.getCodeListType() == "STATIC" && item.getAllPSCodeItems()??>
<#list item.getAllPSCodeItems() as codeitem>
CodeItem item${codeitem_index?c} = new CodeItem();
<#comment>判断是否为数值代码项</#comment>
<#if item.isCodeItemValueNumber()==true>
item${codeitem_index?c}.setValue(${srfjavastring(codeitem.getValue())});
<#else>
item${codeitem_index?c}.setValue("${srfjavastring(codeitem.getValue())}");
</#if>
item${codeitem_index?c}.setId("${srfjavastring(codeitem.getValue())}");
item${codeitem_index?c}.setText("${srfjavastring(codeitem.getText())}");
item${codeitem_index?c}.setLabel("${srfjavastring(codeitem.getText())}");
<#if codeitem.getParentCodeItem()??>
<#assign bTree=true>
item${codeitem_index?c}.setParentValue("${codeitem.getParentCodeItem().getValue()}");
</#if>
<#if codeitem.isDisableSelect()>
item${codeitem_index?c}.setDisabled(true);
</#if>
codeItemList.add(item${codeitem_index?c});
codeList.getCodeItemModelMap().put("${srfjavastring(codeitem.getValue())}",item${codeitem_index?c});
</#list>
<#if bTree==true>
List<CodeItem> codeItemTreeList = new ArrayList<CodeItem>();
codeItemTreeList = getTrees(codeItemList, "");
codeList.setItems(codeItemTreeList.toArray(new CodeItem[codeItemTreeList.size()]));
<#else>
codeList.setItems(codeItemList.toArray(new CodeItem[codeItemList.size()]));
</#if>
</#if>
<#if item.getCodeListType() == "DYNAMIC" && item.getPSDataEntity()??>
<#assign filtername>${pub.getPKGCodeName()}.${item.getPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.service.dto.${item.getPSDataEntity().getCodeName()}SearchFilter</#assign>
<#assign entityname>${pub.getPKGCodeName()}.${item.getPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.domain.${item.getPSDataEntity().getCodeName()}</#assign>
${filtername} searchFilter = new ${filtername}();
<#if ((item.getFetchCondition())!"") != "">
searchFilter.setCustomCond("${item.getFetchCondition()}");
</#if>
<#if item.getMinorSortPSDEField()??>
String strSortField = "${item.getMinorSortPSDEField().getCodeName()}";
<#if item.getMinorSortDir()?? && item.getMinorSortDir() == "DESC">
searchFilter.getSelectCond().orderBy(true, false, strSortField);
<#else>
searchFilter.getSelectCond().orderBy(true, true, strSortField);
</#if>
</#if>
<#if item.getPSDEDataSet().getCodeName()??>
List<${entityname}> pageResult = this.${item.getPSDataEntity().codeName?lower_case}Service.list${item.getPSDEDataSet().getCodeName()}(searchFilter);
<#else>
List<${entityname}> pageResult = this.${item.getPSDataEntity().codeName?lower_case}Service.listDefault(searchFilter);
</#if>
for(${entityname} entity : pageResult) {
CodeItem item = new CodeItem();
<#if item.getValuePSDEField().getCodeName()??>
String strId = entity.get${item.getValuePSDEField().getCodeName()?lower_case?cap_first}();
item.setValue(strId);
item.setId(strId);
</#if>
<#if item.getTextPSDEField().getCodeName()??>
String strText = entity.get${item.getTextPSDEField().getCodeName()?lower_case?cap_first}();
item.setText(strText);
item.setLabel(strText);
</#if>
<#if item.getPValuePSDEField()??>
<#assign bTree=true>
String strParentId = entity.get${item.getPValuePSDEField().getCodeName()?lower_case?cap_first}();
item.setParentValue(strParentId);
</#if>
<#if item.getDisablePSDEField()??>
String strDisabled = String.valueOf(entity.get${item.getDisablePSDEField().getCodeName()?lower_case?cap_first}());
if("1".equalsIgnoreCase(strDisabled)){
item.setDisabled(true);
}
</#if>
codeItemList.add(item);
codeList.getCodeItemModelMap().put(strId,item);
}
<#if bTree==true>
List<CodeItem> codeItemTreeList = new ArrayList<CodeItem>();
codeItemTreeList = getTrees(codeItemList, "");
codeList.setItems(codeItemTreeList.toArray(new CodeItem[codeItemTreeList.size()]));
<#else>
codeList.setItems(codeItemList.toArray(new CodeItem[codeItemList.size()]));
</#if>
</#if>
this.setCodeList(codeList);
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSMODULE
</#ibiztemplate>
平台发布service类重写请放入此文件夹
#重写service类
注:IDEA中可以打开基类service文件,鼠标点中基类service类名,按Alt+Enter,弹出的操作菜单中选择Create Subclass,选中此目录完成快速重写
声明@Primary和@Service
```java
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import java.util.Collection;
@Primary
@Service
public class TestEntityServiceImplImpl extends TestEntityServiceImpl
{
@Override
public boolean create(TA_JS_QZCS et)
{
//此处放入create之前代码
boolean rt=super.create(et);
//此处放入create之后代码
return rt;
}
}
```
\ No newline at end of file
<#ibiztemplate>
TARGET=PSDELOGIC
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.logic;
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.domain.${de.codeName};
/**
* 实体[${de.codeName}] 处理逻辑接口
*/
public interface ${de.codeName}Logic {
<#if de.getAllPSDELogics()??>
<#list de.getAllPSDELogics() as delogic>
boolean ${srfmethodname(delogic.getCodeName())}(${de.codeName} et);
</#list>
</#if>
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSDELOGIC
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.logic.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.mapper.${de.codeName}Mapper;
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.domain.${de.codeName};
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.service.${de.codeName}Service;
import ${pub.getPKGCodeName()}.ibizutil.service.ServiceImplBase;
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.service.dto.${de.codeName}SearchFilter;
import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils;
import java.util.UUID;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.math.BigInteger;
import ${pub.getPKGCodeName()}.ibizutil.annotation.PreField;
import java.lang.reflect.Field;
import org.kie.api.runtime.KieSession;
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.logic.${de.codeName}Logic;
import java.util.HashMap;
import org.kie.api.runtime.KieContainer;
import ${pub.getPKGCodeName()}.ibizutil.errors.BadRequestAlertException;
import org.aspectj.lang.annotation.Aspect;
/**
* 实体[${de.codeName}] 处理逻辑接口实现
*/
@Service
public class ${de.codeName}LogicImpl implements ${de.codeName}Logic{
<#if de.getAllPSDEActions()??>
<#assign outputDELogic=false>
<#list de.getAllPSDEActions() as DEAction>
<#if DEAction.getPSDEActionLogics()??>
<#assign outputDELogic=true>
<#list DEAction.getPSDEActionLogics() as ActionLogic><#comment>实体行为附加逻辑</#comment>
<#if ActionLogic.isInternalLogic()==true><#comment>内部逻辑</#comment>
<#assign DELogic=ActionLogic.getPSDELogic()>
<#assign ExecutePoint=ActionLogic.getAttachMode()?lower_case?cap_first>
<#assign ExecuteDEAction=ActionLogic.getPSDEAction()>
<#comment>由于附加逻辑需要按照次序执行,而Aspectorder只能注解在类上,所以只能发内部类实现此需求</#comment>
<#assign orderIndex=ActionLogic_index?c><#comment>Beforeorder越小越先执行,Afterorder越大越先执行</#comment>
<#if ExecutePoint=='After' && orderIndex!='0'>
<#assign orderIndex="-"+orderIndex>
</#if>
@Aspect
@org.springframework.core.annotation.Order(${orderIndex})
@Service
class ${de.codeName?lower_case?cap_first}Execute${DELogic.codeName?lower_case?cap_first}${ExecutePoint}${ExecuteDEAction.codeName?lower_case?cap_first}{
@org.aspectj.lang.annotation.${ExecutePoint}(value = "execution(* ${pub.getPKGCodeName()}.*.service.${de.codeName}Service.${srfmethodname(ExecuteDEAction.codeName)}(..))")
void execute(org.aspectj.lang.JoinPoint point) throws Exception {
${de.codeName}LogicImpl.this.ExecuteDELogic(point,"${srfmethodname(DELogic.getCodeName())}");
}
}
</#if>
</#list>
</#if>
</#list>
<#if outputDELogic==true>
/**
* 执行处理逻辑
* @param point
* @param LogicName
* @throws Exception
*/
public void ExecuteDELogic(org.aspectj.lang.JoinPoint point,String LogicName) throws Exception {
Object [] args = point.getArgs();
Object obj =args[0];
if (obj instanceof ${de.codeName}){
${de.codeName} entity = (${de.codeName}) obj;
java.lang.reflect.Method method = this.getClass().getMethod(LogicName,${de.codeName}.class);
method.invoke(this,entity);
}
}
</#if>
</#if>
@Autowired
private KieContainer kieContainer;
<#if de.getAllPSDELogics()??>
<#list de.getAllPSDELogics() as delogic>
<#comment>注入处理逻辑中所用到的service对象</#comment>
<#if delogic.getPSDELogicNodes?? && delogic.getPSDELogicNodes()??>
<#list delogic.getPSDELogicNodes() as deLogicNode>
<#if deLogicNode.getDstPSDataEntity?? && deLogicNode.getDstPSDataEntity()??>
<#assign nodePSDataEntity=deLogicNode.getDstPSDataEntity()>
<#if !P.exists("Autowired",nodePSDataEntity.getCodeName(),"service")>
@Autowired
private ${pub.getPKGCodeName()}.${nodePSDataEntity.getPSSystemModule().codeName?lower_case}.service.${nodePSDataEntity.codeName}Service ${deLogicNode.getDstPSDataEntity().getCodeName()?lower_case}service;
</#if>
</#if>
</#list>
</#if>
</#list>
<#comment>注入当前实体的service对象,供自定义查询使用</#comment>
@Autowired
private ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.service.${de.codeName}Service iBzSysDefaultService;
</#if>
<#if de.getAllPSDELogics()??>
<#list de.getAllPSDELogics() as delogic>
<#assign logicName=(de.codeName+delogic.codeName)?lower_case>
public boolean ${srfmethodname(delogic.getCodeName())}(${de.codeName} et){
KieSession kieSession = null;
try{
kieSession=kieContainer.newKieSession();
<#comment>插入逻辑参数</#comment>
<#if delogic.getPSDELogicParams?? && delogic.getPSDELogicParams()??>
<#list delogic.getPSDELogicParams() as logicParam>
<#assign paramObj=(logicName+logicParam.codeName)?lower_case>
<#assign paramObjValue=(logicName+logicParam.codeName)?lower_case>
<#if logicParam.isDefault()==true><#comment>默认变量</#comment>
<#assign paramObjValue="et">
<#elseif logicParam.getParamPSDataEntity?? && logicParam.getParamPSDataEntity()??>
<#assign ParamPSDataEntity=logicParam.getParamPSDataEntity()>
${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.domain.${ParamPSDataEntity.codeName} ${(logicName+logicParam.codeName)?lower_case} =new ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.domain.${ParamPSDataEntity.codeName}();
<#else>
Map ${(logicName+logicParam.codeName)?lower_case} =new HashMap();
</#if>
kieSession.insert(${paramObjValue}); <#comment>将逻辑参数存储到fact</#comment>
kieSession.setGlobal("${paramObj}",${paramObjValue});<#comment>将逻辑参数存储到global</#comment>
</#list>
</#if>
<#comment>插入处理逻辑中所用到的service对象</#comment>
<#if delogic.getPSDELogicNodes?? && delogic.getPSDELogicNodes()??>
<#list delogic.getPSDELogicNodes() as deLogicNode>
<#if deLogicNode.getDstPSDataEntity?? && deLogicNode.getDstPSDataEntity()??>
<#if !P.exists(delogic.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>
</#if>
</#if>
</#list>
</#if>
<#comment>插入当前实体的defaultService对象,供自定义查询使用</#comment>
kieSession.setGlobal("iBzSys${de.codeName?lower_case?cap_first}DefaultService",iBzSysDefaultService);<#comment>将逻辑中引用到的service存储到global</#comment>
kieSession.startProcess("${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.logic.${de.codeName?lower_case}logic.${delogic.getCodeName()?lower_case}");<#comment>执行所要执行的流程</#comment>
}catch(Exception e){
throw new BadRequestAlertException("执行[${delogic.getName()}]处理逻辑发生异常"+e,"","");
}finally {
if(kieSession!=null)
kieSession.destroy();
}
return true;
}
</#list>
</#if>
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSDATAENTITY
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${item.getPSSystemModule().codeName?lower_case}.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import java.util.Map;
import org.apache.ibatis.annotations.Select;
import ${pub.getPKGCodeName()}.${item.getPSSystemModule().codeName?lower_case}.domain.${item.getCodeName()};
import ${pub.getPKGCodeName()}.${item.getPSSystemModule().codeName?lower_case}.service.dto.${item.getCodeName()}SearchFilter;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import java.io.Serializable;
import com.baomidou.mybatisplus.core.toolkit.Constants;
<#if item.getDSLink?? && item.getDSLink()??>
<#if item.getDSLink()!='DEFAULT'>
@com.baomidou.dynamic.datasource.annotation.DS("${item.getDSLink()?lower_case}")
</#if>
</#if>
public interface ${item.getCodeName()}Mapper extends BaseMapper<${item.getCodeName()}>{
<#if item.getAllPSDEDataSets()??>
<#list item.getAllPSDEDataSets() as dedataset>
List<${item.getCodeName()}> search${dedataset.getCodeName()}(@Param("srf") ${item.getCodeName()}SearchFilter searchfilter,@Param("ew") Wrapper<${item.getCodeName()}> wrapper) ;
Page<${item.getCodeName()}> search${dedataset.getCodeName()}(IPage page, @Param("srf") ${item.getCodeName()}SearchFilter searchfilter, @Param("ew") Wrapper<${item.getCodeName()}> wrapper) ;
</#list>
@Select("${r'${sql}'}")
List<Map<String,Object>> selectRow( @Param("sql")String sql);
</#if>
<#assign keyfieldCodeName=item.getKeyPSDEField().codeName?lower_case>
@Override
@Cacheable( value="entity",key = "'${item.getCodeName()}:'+#p0")
${item.getCodeName()} selectById(Serializable id);
@Override
@CacheEvict( value="entity",key = "'${item.getCodeName()}:'+#p0.${keyfieldCodeName}")
int insert(${item.getCodeName()} entity);
@Override
@CacheEvict( value="entity",key = "'${item.getCodeName()}:'+#p0.${keyfieldCodeName}")
int updateById(@Param(Constants.ENTITY) ${item.getCodeName()} entity);
@Override
@CacheEvict( value="entity",key = "'${item.getCodeName()}:'+#p0")
int deleteById(Serializable id);
Page<${item.getCodeName()}> selectPermission(IPage page,@Param("pw") Wrapper<${item.getCodeName()}> wrapper) ;
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSAPPVIEWCTRL_TREEVIEW
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.rest;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import lombok.Data;
import org.springframework.util.StringUtils;
import ${pub.getPKGCodeName()}.ibizutil.errors.BadRequestAlertException;
import org.springframework.validation.annotation.Validated;
import org.springframework.http.ResponseEntity;
import ${pub.getPKGCodeName()}.ibizutil.domain.ActionResult;
import ${pub.getPKGCodeName()}.ibizutil.domain.TreeNode;
import ${pub.getPKGCodeName()}.ibizutil.domain.TreeNodeFilter;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
<#comment>定义实体服务</#comment>
<#if item.getPSDETreeNodes()??>
<#list item.getPSDETreeNodes() as node>
<#if node.getTreeNodeType() == 'DE' && node.getPSDataEntity()??>
<#if !P.exists("importService",node.getPSDataEntity().getId(),"")>
import ${pub.getPKGCodeName()}.${node.getPSDataEntity().getPSSystemModule().codeName?lower_case}.service.${node.getPSDataEntity().codeName}Service;
</#if>
</#if>
</#list>
</#if>
@RestController
@RequestMapping("/${app.getPKGCodeName()?lower_case}/ctrl/${item.codeName?lower_case}treeview")
public class ${app.getPKGCodeName()}${item.codeName}TreeViewController{
/**
* 节点分隔符号
*/
public static final String TREENODE_SEPARATOR = ";";
<#if item.getPSDETreeNodes()??>
<#list item.getPSDETreeNodes() as node>
public static final String TREENODE_${node.getNodeType()?upper_case} = "${srfjavastring(node.getNodeType())}";
</#list>
</#if>
<#comment>注入各实体服务</#comment>
<#if item.getPSDETreeNodes()??>
<#list item.getPSDETreeNodes() as node>
<#if node.getTreeNodeType() == 'DE' && node.getPSDataEntity()??>
<#if !P.exists("@Resource",node.getPSDataEntity().getId(),"")>
@Autowired
private ${node.getPSDataEntity().codeName}Service ${node.getPSDataEntity().codeName?lower_case}Service;
protected ${node.getPSDataEntity().codeName}Service get${node.getPSDataEntity().codeName}Service(){
return ${node.getPSDataEntity().codeName?lower_case}Service;
}
</#if>
</#if>
</#list>
</#if>
<#if item.getRootPSDETreeNode()??>
@GetMapping(value="getnodes")
public ResponseEntity<List<TreeNode>> getNodes(@Validated String srfparentkey,String srfcat,String srfnodeid,String srfnodefilter){
List<TreeNode> list = new ArrayList<TreeNode>();
TreeNodeFilter filter = new TreeNodeFilter();
if (!StringUtils.hasLength(srfnodeid) || srfnodeid.equals("#")) {
<#if item.isRootVisible()>
fill${srfclassname(item.getRootPSDETreeNode().getNodeType()?lower_case)}Nodes(filter,list);
return ResponseEntity.ok().body(list);
<#else>
srfnodeid = TREENODE_${item.getRootPSDETreeNode().getNodeType()?upper_case};
</#if>
}
String strTreeNodeId = srfnodeid;
String strRealNodeId = "";
boolean bRootSelect = false;
String strNodeType = null;
// String strRootSelectNode = this.getWebContext().getPostValue("srfnodeselect");
String strRootSelectNode = "";// this.getWebContext().getPostValue("srfnodeselect");
if (strTreeNodeId.equals(TREENODE_${item.getRootPSDETreeNode().getNodeType()?upper_case})) {
strNodeType = TREENODE_${item.getRootPSDETreeNode().getNodeType()?upper_case};
//treeNode = this.getTreeModel().getRootTreeNodeModel();
//strRealNodeId = treeNodeFetchContext.getCatalog();
//bRootSelect = this.getTreeModel().isEnableRootSelect();
} else {
int nPos = strTreeNodeId.indexOf(TREENODE_SEPARATOR);
if (nPos == -1) {
throw new BadRequestAlertException("树节点[%1$s]标识无效","","");
}
strNodeType = strTreeNodeId.substring(0, nPos);
strRealNodeId = strTreeNodeId.substring(nPos + 1);
}
filter.setSrfParentKey(srfparentkey);
filter.setSrfCat(srfcat);
filter.setSrfNodeFilter(srfnodefilter);
filter.setRealNodeId(strRealNodeId);
filter.setSrfNodeId(srfnodeid);
filter.setNodeType(strNodeType);
/**
* 分解节点标识
*/
String[] nodeid = strRealNodeId.split(TREENODE_SEPARATOR);
for (int i = 0; i < nodeid.length; i++) {
switch(i){
case 0:
filter.setNodeId(nodeid[0]);
break;
case 1:
filter.setNodeId2(nodeid[1]);
break;
case 2:
filter.setNodeId3(nodeid[2]);
break;
case 3:
filter.setNodeId4(nodeid[3]);
break;
default:
break;
}
}
<#list item.getPSDETreeNodes() as node>
if(strNodeType.equals(TREENODE_${node.getNodeType()?upper_case})){
fill${srfclassname(node.getNodeType()?lower_case)}NodeChilds(filter,list);
return ResponseEntity.ok().body(list);
}
</#list>
return ResponseEntity.ok().body(list);
}
</#if>
<#if item.getPSDETreeNodes()??>
<#list item.getPSDETreeNodes() as node>
/**
* 填充 树视图节点[${node.getName()}]
*/
protected void fill${srfclassname(node.getNodeType()?lower_case)}Nodes(@Validated TreeNodeFilter filter,List<TreeNode> list) {
<#if node.getTreeNodeType() == 'STATIC'>
TreeNode treeNode = new TreeNode();
treeNode.setText("${srfjavastring(node.getName())}");
treeNode.setSrfmajortext("${srfjavastring(node.getName())}");
String strNodeId = "${srfjavastring(node.getNodeType())}";
<#if node.getNodeValue()?? && node.getNodeValue()?length gt 0>
treeNode.setSrfkey("${srfjavastring(node.getNodeValue())}");
strNodeId += TREENODE_SEPARATOR;
strNodeId += "${srfjavastring(node.getNodeValue())}";
</#if>
<#if node.isAppendPNodeId()>
strNodeId += TREENODE_SEPARATOR;
strNodeId += filter.getRealNodeId();
</#if>
treeNode.setId(strNodeId);
<#if node.getPSSysImage()??>
treeNode.setIconcls("${item.getPSSysImage().getCssClass()}");
treeNode.setIcon("${item.getPSSysImage().getImagePath()}");
</#if>
<#if node.isEnableCheck()>
treeNode.setEnablecheck(true);
</#if>
<#if node.isExpanded()>
treeNode.setExpanded(true);
<#else>
treeNode.setExpanded(filter.isAutoExpand());
</#if>
<#if node.hasPSDETreeNodeRSs()>
treeNode.setLeaf(false);
</#if>
list.add(treeNode);
</#if>
<#if node.getTreeNodeType() == 'DE' && node.getPSDataEntity()??>
<#assign filtername>${pub.getPKGCodeName()}.${node.getPSDataEntity().getPSSystemModule().codeName?lower_case}.service.dto.${node.getPSDataEntity().codeName}SearchFilter</#assign>
<#assign entityname>${pub.getPKGCodeName()}.${node.getPSDataEntity().getPSSystemModule().codeName?lower_case}.domain.${node.getPSDataEntity().codeName}</#assign>
${filtername} searchFilter = new ${filtername}();
<#list item.getPSDETreeNodeRSs() as noders>
<#if noders.getChildPSDETreeNode().id == node.id && noders.getParentPSDER1N()??>
<#assign pickupfield=noders.getParentPSDER1N().getPSPickupDEField()>
if(filter.getNodeType().equals(TREENODE_${noders.getParentPSDETreeNode().getNodeType()?upper_case})){
//关系 [${noders.getParentPSDER1N().getName()}]条件
searchFilter.setN_${pickupfield.getName()?lower_case}_eq(filter.getNodeId<#if noders.getParentValueLevel() gt 1>${noders.getParentValueLevel()?c}</#if>());
}
</#if>
</#list>
//searchFilter.setActiveData(filter);
<#if node.getSortPSDEField()??>
</#if>
List<${entityname}> pageResult = this.get${node.getPSDataEntity().codeName}Service().list${node.getPSDEDataSet().getCodeName()}(searchFilter);
for(${entityname} entity : pageResult) {
TreeNode treeNode = new TreeNode();
<#if node.getIdPSDEField()??>
String strId = entity.get${node.getIdPSDEField().codeName?lower_case?cap_first}();
<#else>
String strId = entity.get${node.getPSDataEntity().getKeyPSDEField().codeName?lower_case?cap_first}();
</#if>
<#if node.getTextPSDEField()??>
String strText = entity.get${node.getTextPSDEField().codeName?lower_case?cap_first}();
<#else>
String strText = entity.get${node.getPSDataEntity().getMajorPSDEField().codeName?lower_case?cap_first}();
</#if>
treeNode.setSrfkey(strId);
treeNode.setText(strText);
treeNode.setSrfmajortext(strText);
String strNodeId = "${srfjavastring(node.getNodeType())}";
strNodeId += TREENODE_SEPARATOR;
strNodeId += strId;
<#if node.isAppendPNodeId()>
strNodeId += TREENODE_SEPARATOR;
strNodeId += filter.getRealNodeId();
</#if>
treeNode.setId(strNodeId);
<#if node.getPSSysImage()??>
treeNode.setIconcls("${item.getPSSysImage().getCssClass()}");
treeNode.setIcon("${item.getPSSysImage().getImagePath()}");
</#if>
<#if node.isEnableCheck()>
treeNode.setEnablecheck(true);
</#if>
<#if node.isExpanded()>
treeNode.setExpanded(true);
<#else>
treeNode.setExpanded(filter.isAutoExpand());
</#if>
<#if node.hasPSDETreeNodeRSs()>
treeNode.setLeaf(false);
</#if>
list.add(treeNode);
}
</#if>
}
/**
* 填充 树视图节点[${node.getName()}]子节点
*/
protected void fill${srfclassname(node.getNodeType()?lower_case)}NodeChilds(@Validated TreeNodeFilter filter,List<TreeNode> list) {
<#if item.getPSDETreeNodeRSs()??>
<#list item.getPSDETreeNodeRSs() as noders>
<#if noders.getParentPSDETreeNode().id == node.id>
//填充${noders.getChildPSDETreeNode().getName()}
fill${srfclassname(noders.getChildPSDETreeNode().getNodeType()?lower_case)}Nodes(filter,list);
</#if>
</#list>
</#if>
}
</#list>
</#if>
}
<#ibiztemplate>
TARGET=PSDATAENTITY
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${item.getPSSystemModule().codeName?lower_case}.service;
import ${pub.getPKGCodeName()}.${item.getPSSystemModule().codeName?lower_case}.domain.${item.codeName};
import ${pub.getPKGCodeName()}.${item.getPSSystemModule().codeName?lower_case}.service.dto.${item.codeName}SearchFilter;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.Map;
/**
* 实体[${item.codeName}] 服务对象接口
*/
public interface ${item.codeName}Service extends IService<${item.codeName}>{
<#if item.getAllPSDEActions()??>
<#list item.getAllPSDEActions() as deaction>
<#if deaction.getCodeName() != "Save"><#comment>Save与mybatis冲突</#comment>
<#if (deaction.getActionMode() == "READ"|| deaction.getActionType()=='USERCUSTOM' || deaction.getActionType()=='DELOGIC') && (!deaction.codeName?lower_case?contains("major")) ><#comment>Get与自定义行为返回DoMain不发带major</#comment>
${item.codeName} ${srfmethodname(deaction.getCodeName())}(${item.codeName} et);
<#else>
boolean ${srfmethodname(deaction.getCodeName())}(${item.codeName} et);
</#if>
</#if>
</#list>
</#if>
<#if item.getAllPSDEDataSets()??>
<#list item.getAllPSDEDataSets() as dedataset>
List<${item.codeName}> list${dedataset.getCodeName()}(${item.codeName}SearchFilter filter) ;
Page<${item.codeName}> search${dedataset.getCodeName()}(${item.codeName}SearchFilter filter);
</#list>
</#if>
/** 实体[${item.codeName}] 自定义数据查询 **/
List<Map<String,Object>> selectRow(String sql);
<#comment>重定向视图</#comment>
<#if item.getAllPSDEMainStates?? && item.getAllPSDEMainStates()??>
<#if item.getDEMainStateDEFields?? && item.getDEMainStateDEFields()??>
String getMajState(${item.codeName} et);
</#if>
</#if>
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSDATAENTITY
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${item.getPSSystemModule().codeName?lower_case}.service.dto;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import ${pub.getPKGCodeName()}.ibizutil.domain.ParentData;
import ${pub.getPKGCodeName()}.${item.getPSSystemModule().codeName?lower_case}.domain.${item.codeName};
import org.springframework.util.StringUtils;
import lombok.Data;
import java.util.Map;
import java.sql.Timestamp;
import ${pub.getPKGCodeName()}.ibizutil.service.SearchFilterBase;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonFormat;
import ${pub.getPKGCodeName()}.ibizutil.domain.DataObj;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class ${item.getCodeName()}SearchFilter extends SearchFilterBase {
private String query;
private Page page;
private QueryWrapper<${item.getCodeName()}> selectCond;
public ${item.getCodeName()}SearchFilter(){
this.page =new Page<${item.getCodeName()}>(1,Short.MAX_VALUE);
this.selectCond=new QueryWrapper<${item.getCodeName()}>();
}
/**
* 设定自定义查询条件,在原有SQL基础上追加该SQL
*/
public void setCustomCond(String sql)
{
this.selectCond.apply(sql);
}
/**
* 获取父数据
* @param srfparentdata
*/
public void setSrfparentdata(DataObj srfparentdata) {
this.srfparentdata = srfparentdata;
String strParentkey=this.getSrfparentdata().getStringValue("srfparentkey");
<#comment>输出获取外键值方法-用于通过parentdata关系填充外键值id</#comment>
<#list item.getPSDEFields() as defield>
<#if defield.getAllPSDEFSearchModes()??>
<#list defield.getAllPSDEFSearchModes() as formitem>
<#if formitem.getPSDEField()??>
<#assign defield=formitem.getPSDEField()>
<#if defield.getDataType()=='PICKUP'>
<#assign psder1n=defield.getPSDER1N().name>
if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("${psder1n}"))
if(StringUtils.isEmpty(strParentkey)){
this.set${formitem.name?lower_case?cap_first}("NA");
}
else{
this.set${formitem.name?lower_case?cap_first}(strParentkey);
}
</#if>
</#if>
</#list>
</#if>
</#list>
}
/**
* 启用快速搜索
*/
public void setQuery(String query)
{
this.query=query;
if(!StringUtils.isEmpty(query)){
<#list item.getPSDEFields() as defield>
<#if defield.isEnableQuickSearch()==true>
this.selectCond.or().like("${defield.name?lower_case}",query);
</#if>
</#list>
}
}
/**
* 输出实体搜索项
*/
<#list item.getPSDEFields() as defield>
<#if defield.getAllPSDEFSearchModes()??>
<#list defield.getAllPSDEFSearchModes() as formitem>
<#if formitem.getPSDEField()??>
<#assign defDataType=formitem.getPSDEField().getDataType()>
<#if defDataType == "DATETIME">
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
<#elseif defDataType == "DATE">
@JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+8")
<#elseif defDataType == "TIME">
@JsonFormat(pattern="HH:mm", timezone="GMT+8")
</#if>
private ${srfjavatype(formitem.getPSDEField().stdDataType)} ${formitem.getName()?lower_case};//[${defield.getLogicName()}]
public void set${formitem.getName()?lower_case?cap_first}(${srfjavatype(formitem.getPSDEField().stdDataType)} ${formitem.getName()?lower_case}) {
this.${formitem.getName()?lower_case} = ${formitem.getName()?lower_case};
if(!StringUtils.isEmpty(this.${formitem.getName()?lower_case})){
<#if formitem.getValueOp() == "LIKE">
this.selectCond.like("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "LEFTLIKE">
this.selectCond.likeRight("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "RIGHTLIKE">
this.selectCond.likeLeft("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "EQ">
this.selectCond.eq("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "NOTEQ">
this.selectCond.ne("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "GT">
this.selectCond.gt("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "GTANDEQ">
this.selectCond.ge("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "LT">
this.selectCond.lt("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "LTANDEQ">
this.selectCond.le("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "ISNOTNULL">
<#if srfjavatype(formitem.getPSDEField().stdDataType)=='Integer'>
if(this.${formitem.getName()?lower_case}==1){
this.selectCond.isNotNull("${formitem.getPSDEField().getName()?lower_case}");
}
<#elseif srfjavatype(formitem.getPSDEField().stdDataType)=='String'>
if(this.${formitem.getName()?lower_case}.equals("1")){
this.selectCond.isNotNull("${formitem.getPSDEField().getName()?lower_case}");
}
</#if>
<#elseif formitem.getValueOp() == "ISNULL">
<#if srfjavatype(formitem.getPSDEField().stdDataType)=='Integer'>
if(this.${formitem.getName()?lower_case}==1){
this.selectCond.isNull("${formitem.getPSDEField().getName()?lower_case}");
}
<#elseif srfjavatype(formitem.getPSDEField().stdDataType)=='String'>
if(this.${formitem.getName()?lower_case}.equals("1")){
this.selectCond.isNull("${formitem.getPSDEField().getName()?lower_case}");
}
</#if>
</#if>
}
}
</#if>
</#list>
</#if>
</#list>
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSAPPVIEWCTRL_CALENDAR
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.vo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.domain.${de.codeName};
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.sql.Timestamp;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class ${de.codeName}_Calendar_${ctrl.codeName}{
//前台传入的开始时间
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
@JsonProperty(access=Access.WRITE_ONLY)
private Timestamp srfbegintime;
//前台传入的结束时间
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
@JsonProperty(access=Access.WRITE_ONLY)
private Timestamp srfendtime;
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
private Timestamp begintime;
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
private Timestamp endtime;
private String icon;
private String hrefTarget;
private String text;
private String cls;
private String type;
private String srfkey;
private String srfmajortext;
private String iconCls;
private String bkcolor;
private String id;
private String content;
private String color;
private String href;
private String qtip;
private boolean disabled;
<#list ctrl.getPSSysCalendarItems() as calendards>
<#assign calendarEntity=calendards.getPSDataEntity()>
/**
* 日历部件[${calendards.name}]设置数据源查询条件
* @param searchFilter
* @return
*/
public ${pub.getPKGCodeName()}.${calendarEntity.getPSSystemModule().codeName?lower_case}.service.dto.${calendarEntity.codeName}SearchFilter get${calendarEntity.codeName}SearchFilter(${de.codeName}_Calendar_${ctrl.codeName} searchFilter) {
${pub.getPKGCodeName()}.${calendarEntity.getPSSystemModule().codeName?lower_case}.service.dto.${calendarEntity.codeName}SearchFilter filter=new ${pub.getPKGCodeName()}.${calendarEntity.getPSSystemModule().codeName?lower_case}.service.dto.${calendarEntity.codeName}SearchFilter();
QueryWrapper<${pub.getPKGCodeName()}.${calendarEntity.getPSSystemModule().codeName?lower_case}.domain.${calendarEntity.getCodeName()}> qw =filter.getSelectCond();
qw.ge("${calendards.getBeginTimePSDEField().name?lower_case}",srfbegintime);
qw.le("${calendards.getEndTimePSDEField().name?lower_case}",srfendtime);
return filter;
}
/**
* 日历部件[${calendards.name}]将数据源结果填入list集合中
* @param
* @param records
*/
public void add${calendarEntity.codeName}ToRecords(Page<${pub.getPKGCodeName()}.${calendarEntity.getPSSystemModule().codeName?lower_case}.domain.${calendarEntity.getCodeName()}> ${calendarEntity.codeName?lower_case}SearchResult, List<${de.codeName}_Calendar_${ctrl.codeName}> records) {
for(${pub.getPKGCodeName()}.${calendarEntity.getPSSystemModule().codeName?lower_case}.domain.${calendarEntity.getCodeName()} source:${calendarEntity.codeName?lower_case}SearchResult.getRecords()) {
${de.codeName}_Calendar_${ctrl.codeName} target=new ${de.codeName}_Calendar_${ctrl.codeName}();
target.from${calendarEntity.codeName}(source);
records.add(target);
}
}
/**
* 日历部件[${calendards.name}]数据源结果vo对象转换
* @param sourceEntity
*/
public void from${calendarEntity.codeName}(${pub.getPKGCodeName()}.${calendarEntity.getPSSystemModule().codeName?lower_case}.domain.${calendarEntity.getCodeName()} sourceEntity) {
this.setEndtime(sourceEntity.get${calendards.getEndTimePSDEField().codeName?lower_case?cap_first}());
this.setIcon("");
this.setHrefTarget("");
this.setText("");
this.setCls("");
this.setBegintime(sourceEntity.get${calendards.getBeginTimePSDEField().codeName?lower_case?cap_first}());
this.setType("${calendards.getItemType()}");
this.setSrfkey(sourceEntity.get${calendarEntity.getKeyPSDEField().codeName?lower_case?cap_first}());
this.setSrfmajortext(sourceEntity.get${calendarEntity.getMajorPSDEField().codeName?lower_case?cap_first}());
this.setIconCls("");
this.setBkcolor("${calendards.getBKColor()}");
this.setId(sourceEntity.get${calendarEntity.getKeyPSDEField().codeName?lower_case?cap_first}());
this.setContent(sourceEntity.get${calendarEntity.getMajorPSDEField().codeName?lower_case?cap_first}());
this.setColor("${calendards.getColor()}");
this.setHref("");
this.setQtip("");
this.setDisabled(false);
}
</#list>
/**
* 将全部数据源结果集封装成page对象
* @param records
* @return
*/
public Page<${de.codeName}_Calendar_${ctrl.codeName}> addRecordsToPage(List<${de.codeName}_Calendar_${ctrl.codeName}> records) {
Page<${de.codeName}_Calendar_${ctrl.codeName}> targetpage=new Page<${de.codeName}_Calendar_${ctrl.codeName}>(0,0,records.size(),false);
targetpage.setAsc(null);
targetpage.setDesc(null);
targetpage.setOptimizeCountSql(false);
targetpage.setRecords(records);
return targetpage;
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSAPPVIEWCTRL_CHART
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.vo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.domain.${de.codeName};
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.sql.Timestamp;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import com.alibaba.fastjson.JSONObject;
import java.util.Map;
import java.util.HashMap;
import org.springframework.cglib.beans.BeanMap;
import ${pub.getPKGCodeName()}.ibizutil.chart.model.ChartAxisModel;
import ${pub.getPKGCodeName()}.ibizutil.chart.model.ChartSeriesModel;
import ${pub.getPKGCodeName()}.ibizutil.chart.model.ChartModelBase;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class ${de.codeName}_Chart_${ctrl.codeName} extends ChartModelBase{
/**
* 准备图表坐标轴模型
* @throws Exception
*/
protected void prepareChartAxisModels() {
<#assign index=0 >
<#list ctrl.getPSDEChartSerieses() as Seriese>
<#if Seriese.getXPSDEChartAxes()??>
<#assign axesX=Seriese.getXPSDEChartAxes()>
ChartAxisModel chartAxis${index} = new ChartAxisModel();
chartAxis${index}.setName("${axesX.getName()}");
chartAxis${index}.setCaption("${axesX.getCaption()}");
chartAxis${index}.setAxisType("${axesX.getAxesType()}");
chartAxis${index}.setAxisPos("${axesX.getAxesPos()}");
this.registerChartAxisModel(chartAxis${index});
<#assign index=index+1 >
</#if>
<#if Seriese.getYPSDEChartAxes()??>
<#assign axesY=Seriese.getYPSDEChartAxes()>
ChartAxisModel chartAxis${index} = new ChartAxisModel();
chartAxis${index}.setName("${axesY.getName()}");
chartAxis${index}.setCaption("${axesY.getCaption()}");
chartAxis${index}.setAxisType("${axesY.getAxesType()}");
chartAxis${index}.setAxisPos("${axesY.getAxesPos()}");
this.registerChartAxisModel(chartAxis${index});
<#assign index=index+1 >
</#if>
</#list>
}
/**
* 准备图表序列模型
* @throws Exception
*/
protected void prepareChartSeriesModels() {
<#assign index=0 >
<#list ctrl.getPSDEChartSerieses() as Seriese>
ChartSeriesModel chartSeries${index} = new ChartSeriesModel();
chartSeries${index}.setName("${Seriese.getName()}");
chartSeries${index}.setCaption("${Seriese.getCaption()}");
chartSeries${index}.setSeriesType("${Seriese.getSeriesType()}");
chartSeries${index}.setCatalogField("${Seriese.getCatalogField()?lower_case}");
chartSeries${index}.setValueField("${Seriese.getValueField()?lower_case}");
chartSeries${index}.setTimeGroupMode("${Seriese.getTimeGroupMode()}");
this.registerChartSeriesModel(chartSeries${index});
<#assign index=index+1 >
</#list>
}
public Page<JSONObject> addRecordsToPage(JSONObject opt) {
Page<JSONObject> targetpage=new Page<JSONObject>();
List<JSONObject> records=new ArrayList<JSONObject>();
records.add(opt);
targetpage.setAsc(null);
targetpage.setDesc(null);
targetpage.setOptimizeCountSql(false);
targetpage.setRecords(records);
return targetpage;
}
/**
* entity转成map
* @param searchResult
* @return
*/
public List<Map<String, Object>> pageToListDatas(Page<${de.codeName}> searchResult) {
if(searchResult==null)
return null;
List<Map<String, Object>> records=new ArrayList<>();
for(${de.codeName} source:searchResult.getRecords()) {
${de.codeName}_Chart_${ctrl.codeName} target=new ${de.codeName}_Chart_${ctrl.codeName}();
records.add(target.beanToMap(source));
}
return records;
}
/**
*entity转成map
* @param bean
* @param <T>
* @return
*/
public <T> Map<String,Object> beanToMap(T bean){
Map map =new HashMap<String,Object>();
if(bean!=null){
BeanMap beanMap=BeanMap.create(bean);
for(Object obj:beanMap.keySet()){
map.put(obj+"",beanMap.get(obj));
}
}
return map;
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSAPPVIEWCTRL_DATAVIEW
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.vo;
import java.sql.Timestamp;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.domain.${de.codeName};
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class ${de.codeName}_DataView_${ctrl.codeName}{
<#if ctrl.getPSDEDataViewDataItems()??>
<#list ctrl.getPSDEDataViewDataItems() as dataitem>
<#if de.getPSDEField(dataitem.name?lower_case,true)??>
<#assign defitem=de.getPSDEField(dataitem.name?lower_case,true)>
private ${srfjavatype(defitem.stdDataType)} ${dataitem.name?lower_case};
<#else>
private ${srfjavatype(dataitem.getDataType())} ${dataitem.name?lower_case};
</#if>
</#list>
public void from${de.codeName}(${de.codeName} sourceEntity) {
<#list ctrl.getPSDEDataViewDataItems() as dataitem>
<#if dataitem.getDataItemParam()??><#assign param0=dataitem.getDataItemParam()>
this.set${dataitem.name?lower_case?cap_first}(sourceEntity.get${param0.getName()?lower_case?cap_first}());
<#else >
<#if de.getPSDEField(dataitem.name?lower_case,true)?? >
this.set${dataitem.name?lower_case?cap_first}(sourceEntity.get${dataitem.name?lower_case?cap_first}());
</#if>
</#if>
</#list>
}
public static Page<${de.codeName}_DataView_${ctrl.codeName}> from${de.codeName}(Page<${de.codeName}> sourcePage) {
if(sourcePage==null)
return null;
Page<${de.codeName}_DataView_${ctrl.codeName}> targetpage=new Page<${de.codeName}_DataView_${ctrl.codeName}>(sourcePage.getCurrent(),sourcePage.getSize(),sourcePage.getTotal(),sourcePage.isSearchCount());
List<${de.codeName}_DataView_${ctrl.codeName}> records=new ArrayList<${de.codeName}_DataView_${ctrl.codeName}>();
for(${de.codeName} source:sourcePage.getRecords()) {
${de.codeName}_DataView_${ctrl.codeName} target=new ${de.codeName}_DataView_${ctrl.codeName}();
target.from${de.codeName}(source);
records.add(target);
}
targetpage.setAsc(sourcePage.ascs());
targetpage.setDesc(sourcePage.descs());
targetpage.setOptimizeCountSql(sourcePage.optimizeCountSql());
targetpage.setRecords(records);
return targetpage;
}
</#if>
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSAPPVIEWCTRL_GRID
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.vo;
import java.sql.Timestamp;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.domain.${de.codeName};
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import org.springframework.cglib.beans.BeanMap;
import com.alibaba.fastjson.JSONObject;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class ${de.codeName}_Grid_${ctrl.codeName}{
<#if ctrl.getPSDEGridDataItems()??>
<#list ctrl.getPSDEGridDataItems() as dataitem>
<#if de.getPSDEField(dataitem.name?lower_case,true)??>
<#assign defitem=de.getPSDEField(dataitem.name?lower_case,true)>
<#comment>实体属性</#comment>
<#assign defDataType=defitem.getDataType()>
<#assign dataType="${srfdatatype(defitem.getStdDataType())}"><#comment>外键值附加数据时间格式转换</#comment>
<#if defDataType == "DATETIME" || (defDataType=='PICKUPDATA' && dataType== "DATETIME" && defitem.getValueFormat()=="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
<#elseif defDataType == "DATE" || (defDataType=='PICKUPDATA' && dataType== "DATETIME" && defitem.getValueFormat()=="%1$tY-%1$tm-%1$td")>
@JsonFormat(pattern="yyyy-MM-dd", locale = "zh" , timezone="GMT+8")
<#elseif defDataType == "TIME" || (defDataType=='PICKUPDATA' && dataType== "DATETIME" && defitem.getValueFormat()=="%1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="HH:mm", locale = "zh" , timezone="GMT+8")
</#if>
private ${srfjavatype(defitem.stdDataType)} ${dataitem.name?lower_case};
<#else>
<#comment>系统保留属性 (srfmajortext)</#comment>
<#if dataitem.name?lower_case='srfkey' || dataitem.name?lower_case='srfdataaccaction'>
private ${srfjavatype(de.getKeyPSDEField().stdDataType)} ${dataitem.name?lower_case};
<#elseif dataitem.name?lower_case='srfmajortext' >
private ${srfjavatype(de.getMajorPSDEField().stdDataType)} ${dataitem.name?lower_case};
<#else>
private ${srfjavatype(dataitem.getDataType())} ${dataitem.name?lower_case};
</#if>
</#if>
</#list>
<#comment>表格修改</#comment>
public void from${de.codeName}(${de.codeName} sourceEntity) {
<#list ctrl.getPSDEGridDataItems() as dataitem>
<#if dataitem.getDataItemParam()??>
<#assign param0=dataitem.getDataItemParam()>
this.set${dataitem.name?lower_case?cap_first}(sourceEntity.get${param0.getName()?lower_case?cap_first}());
<#else>
<#if de.getPSDEField(dataitem.name?lower_case,true)?? >
<#assign defield=dataitem.getPSDEField()>
this.set${dataitem.name?lower_case?cap_first}(sourceEntity.get${defield.codeName?lower_case?cap_first}());
</#if>
</#if>
</#list>
}
public static Page<${de.codeName}_Grid_${ctrl.codeName}> from${de.codeName}(Page<${de.codeName}> sourcePage) {
if(sourcePage==null)
return null;
Page<${de.codeName}_Grid_${ctrl.codeName}> targetpage=new Page<${de.codeName}_Grid_${ctrl.codeName}>(sourcePage.getCurrent(),sourcePage.getSize(),sourcePage.getTotal(),sourcePage.isSearchCount());
List<${de.codeName}_Grid_${ctrl.codeName}> records=new ArrayList<${de.codeName}_Grid_${ctrl.codeName}>();
for(${de.codeName} source:sourcePage.getRecords()) {
${de.codeName}_Grid_${ctrl.codeName} target=new ${de.codeName}_Grid_${ctrl.codeName}();
target.from${de.codeName}(source);
records.add(target);
}
targetpage.setAsc(sourcePage.ascs());
targetpage.setDesc(sourcePage.descs());
targetpage.setOptimizeCountSql(sourcePage.optimizeCountSql());
targetpage.setRecords(records);
return targetpage;
}
/**
* 表格模型集合
* @return
*/
public static List<Map<String,String>> getGridColumnModels() {
List columnModelList =new ArrayList();
<#list ctrl.getPSDEGridColumns() as gridColumn>
<#if gridColumn.getPSDEField?? && gridColumn.getPSDEField()??>
columnModelList.add(new HashMap(){ { put("${gridColumn.getPSDEField().getName()?lower_case}","${gridColumn.getCaption()}"); }});
</#if>
</#list>
return columnModelList;
}
/**
*entity转成map
* @param bean
* @param <T>
* @return
*/
public <T> Map<String,Object> beanToMap(T bean){
Map map =new HashMap<String,Object>();
if(bean!=null){
BeanMap beanMap=BeanMap.create(bean);
for(Object obj:beanMap.keySet()){
map.put(obj+"",beanMap.get(obj));
}
}
return map;
}
/**
* entity转成map
* @param searchResult
* @return
*/
public static List<Map<String, Object>> pageToListDatas(Page<${de.codeName}> searchResult) {
if(searchResult==null)
return null;
List<Map<String, Object>> records=new ArrayList<>();
for(${de.codeName} source:searchResult.getRecords()) {
${de.codeName}_Grid_${ctrl.codeName} target=new ${de.codeName}_Grid_${ctrl.codeName}();
records.add(target.beanToMap(source));
}
return records;
}
/**
* 输出表格数据导出文件url
* @param sourcePage
* @param downloadurl
* @return
*/
public static Page<JSONObject> getResultPage(Page<${de.codeName}> sourcePage,String downloadurl) {
if(sourcePage==null)
return null;
Page<JSONObject> targetpage=new Page<JSONObject>(sourcePage.getCurrent(),sourcePage.getSize(),sourcePage.getTotal(),sourcePage.isSearchCount());
List<JSONObject> records=new ArrayList<JSONObject>();
JSONObject obj =new JSONObject();
obj.put("downloadurl",downloadurl);
records.add(obj);
targetpage.setAsc(sourcePage.ascs());
targetpage.setDesc(sourcePage.descs());
targetpage.setOptimizeCountSql(sourcePage.optimizeCountSql());
targetpage.setRecords(records);
return targetpage;
}
</#if>
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSAPPVIEWCTRL_LIST
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.vo;
import java.sql.Timestamp;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.domain.${de.codeName};
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class ${de.codeName}_List_${ctrl.codeName}{
<#if ctrl.getPSListDataItems()??>
<#list ctrl.getPSListDataItems() as dataitem>
<#if de.getPSDEField(dataitem.name?lower_case,true)??>
<#assign defitem=de.getPSDEField(dataitem.name?lower_case,true)>
private ${srfjavatype(defitem.stdDataType)} ${dataitem.name?lower_case};
<#else>
private ${srfjavatype(dataitem.getDataType())} ${dataitem.name?lower_case};
</#if>
</#list>
public void from${de.codeName}(${de.codeName} sourceEntity) {
<#list ctrl.getPSListDataItems() as dataitem>
<#if dataitem.getDataItemParam()??><#assign param0=dataitem.getDataItemParam()>
this.set${dataitem.name?lower_case?cap_first}(String.format("%s",sourceEntity.get${param0.getName()?lower_case?cap_first}()));
<#else >
<#if de.getPSDEField(dataitem.name?lower_case,true)?? >
this.set${dataitem.name?lower_case?cap_first}(String.format("%s",sourceEntity.get${dataitem.name?lower_case?cap_first}()));
</#if>
</#if>
</#list>
}
public static Page<${de.codeName}_List_${ctrl.codeName}> from${de.codeName}(Page<${de.codeName}> sourcePage) {
if(sourcePage==null)
return null;
Page<${de.codeName}_List_${ctrl.codeName}> targetpage=new Page<${de.codeName}_List_${ctrl.codeName}>(sourcePage.getCurrent(),sourcePage.getSize(),sourcePage.getTotal(),sourcePage.isSearchCount());
List<${de.codeName}_List_${ctrl.codeName}> records=new ArrayList<${de.codeName}_List_${ctrl.codeName}>();
for(${de.codeName} source:sourcePage.getRecords()) {
${de.codeName}_List_${ctrl.codeName} target=new ${de.codeName}_List_${ctrl.codeName}();
target.from${de.codeName}(source);
records.add(target);
}
targetpage.setAsc(sourcePage.ascs());
targetpage.setDesc(sourcePage.descs());
targetpage.setOptimizeCountSql(sourcePage.optimizeCountSql());
targetpage.setRecords(records);
return targetpage;
}
</#if>
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSAPPVIEWCTRL_MOBMDCTRL
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.vo;
import java.sql.Timestamp;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.domain.${de.codeName};
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class ${de.codeName}_MOBMDCTRL_${ctrl.codeName}{
<#if ctrl.getPSListDataItems()??>
<#list ctrl.getPSListDataItems() as dataitem>
<#if de.getPSDEField(dataitem.name?lower_case,true)??>
<#assign defitem=de.getPSDEField(dataitem.name?lower_case,true)>
private ${srfjavatype(defitem.stdDataType)} ${dataitem.name?lower_case};
<#else>
private ${srfjavatype(dataitem.getDataType())} ${dataitem.name?lower_case};
</#if>
</#list>
public void from${de.codeName}(${de.codeName} sourceEntity) {
<#list ctrl.getPSListDataItems() as dataitem>
<#if dataitem.getDataItemParam()??><#assign param0=dataitem.getDataItemParam()>
this.set${dataitem.name?lower_case?cap_first}(String.format("%s",sourceEntity.get${param0.getName()?lower_case?cap_first}()));
<#else >
<#if de.getPSDEField(dataitem.name?lower_case,true)?? >
this.set${dataitem.name?lower_case?cap_first}(String.format("%s",sourceEntity.get${dataitem.name?lower_case?cap_first}()));
</#if>
</#if>
</#list>
}
public static Page<${de.codeName}_MOBMDCTRL_${ctrl.codeName}> from${de.codeName}(Page<${de.codeName}> sourcePage) {
if(sourcePage==null)
return null;
Page<${de.codeName}_MOBMDCTRL_${ctrl.codeName}> targetpage=new Page<${de.codeName}_MOBMDCTRL_${ctrl.codeName}>(sourcePage.getCurrent(),sourcePage.getSize(),sourcePage.getTotal(),sourcePage.isSearchCount());
List<${de.codeName}_MOBMDCTRL_${ctrl.codeName}> records=new ArrayList<${de.codeName}_MOBMDCTRL_${ctrl.codeName}>();
for(${de.codeName} source:sourcePage.getRecords()) {
${de.codeName}_MOBMDCTRL_${ctrl.codeName} target=new ${de.codeName}_MOBMDCTRL_${ctrl.codeName}();
target.from${de.codeName}(source);
records.add(target);
}
targetpage.setAsc(sourcePage.ascs());
targetpage.setDesc(sourcePage.descs());
targetpage.setOptimizeCountSql(sourcePage.optimizeCountSql());
targetpage.setRecords(records);
return targetpage;
}
</#if>
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSAPPVIEWCTRL_SEARCHFORM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.vo;
import java.sql.Timestamp;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import lombok.Data;
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.service.dto.${de.codeName}SearchFilter;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.springframework.util.StringUtils;
import java.util.Map;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class ${de.codeName}_SearchForm_${ctrl.codeName}{
private Map<String,String> srfparentdata;
<#list ctrl.getPSDEFormItems() as formitem>
<#if formitem.getIgnoreInput() == 3>
@JsonProperty(access=Access.READ_ONLY)
</#if>
<#if !formitem.isAllowEmpty()>
@NotEmpty
</#if>
<#if formitem.getPSDEField()??>
<#if !formitem.isAllowEmpty() && srfjavatype(formitem.getPSDEField().stdDataType)=='String'>
@NotBlank
</#if>
private ${srfjavatype(formitem.getPSDEField().stdDataType)} ${formitem.name?lower_case};
<#else>
private String ${formitem.name?lower_case};
</#if>
<#if ( formitem.getCreateDV()?? && formitem.getCreateDV()?length gt 0) || ( formitem.getCreateDVT()?? && formitem.getCreateDVT()?length gt 0)>
<#if formitem.getPSDEField()??><#comment>表单项有关联属性</#comment>
<#if !P.exists("searchformitem","get",formitem.name)>
private ${srfjavatype(formitem.getPSDEField().stdDataType)} get${formitem.name?lower_case?cap_first}(){
<#if formitem.getPSDEField().getDataType()=='PICKUP'><#comment>外键值填充</#comment>
<#assign psder1n=formitem.getPSDEField().getPSDER1N().name>
if(StringUtils.isEmpty(${formitem.name?lower_case}) && this.getSrfparentdata() != null){
if(this.getSrfparentdata().containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("${psder1n}"))
this.${formitem.name?lower_case}=this.getSrfparentdata().get("srfparentkey");
}
</#if>
if(StringUtils.isEmpty(${formitem.name?lower_case})){<#comment>上下文中填充</#comment>
<#if formitem.getCreateDVT()=='PARAM'>
<#if srfjavatype(formitem.getPSDEField().stdDataType)=='String'>
this.${formitem.name?lower_case}=this.getSrfparentdata().get("${formitem.getCreateDV()}");
<#else>
//this.${formitem.name?lower_case}=this.getSrfparentdata().get("${formitem.getCreateDV()}");
</#if>
<#else>
//暂未实现 DefaultValue(value="${formitem.getCreateDV()}",type="${formitem.getCreateDVT()}")
</#if>
}
return this.${formitem.name?lower_case};
}
</#if>
<#else><#comment>表单项无关联属性</#comment>
<#if !P.exists("searchformitem","get",formitem.name)>
private String get${formitem.name?lower_case?cap_first}(){
if(this.${formitem.name?lower_case}==null){
<#if formitem.getCreateDVT()=='PARAM'>
this.${formitem.name?lower_case}=this.getSrfparentdata().get("${formitem.getCreateDV()}");
<#else>
//暂未实现 DefaultValue(value="${formitem.getCreateDV()}",type="${formitem.getCreateDVT()}")
</#if>
}
return this.${formitem.name?lower_case};
}
</#if>
</#if>
</#if>
</#list>
private Page page;
private Page getPage(){
if(this.page==null)
this.page=new Page(1,20,true);
return this.page;
}
public void from${de.codeName}SearchFilter(${de.codeName}SearchFilter sourceSearchFilter) {
<#list ctrl.getPSDEFormItems() as formitem>
this.set${formitem.name?lower_case?cap_first}(sourceSearchFilter.get${formitem.name?lower_case?cap_first}());
</#list>
this.setPage(sourceSearchFilter.getPage());
}
public ${de.codeName}SearchFilter to${de.codeName}SearchFilter() {
${de.codeName}SearchFilter targetSearchFilter=new ${de.codeName}SearchFilter();
<#list ctrl.getPSDEFormItems() as formitem>
if(targetSearchFilter.get${formitem.name?lower_case?cap_first}()==null)
targetSearchFilter.set${formitem.name?lower_case?cap_first}(this.get${formitem.name?lower_case?cap_first}());
</#list>
targetSearchFilter.setPage(this.getPage());
return targetSearchFilter;
}
<#comment>输出获取外键值方法-用于通过parentdata关系填充外键值id</#comment>
<#list ctrl.getPSDEFormItems() as formitem>
<#if formitem.getPSDEField?? && formitem.getPSDEField()??>
<#assign defield=formitem.getPSDEField()>
<#if defield.getDataType()=='PICKUP'>
<#if !P.exists("searchformitem","get",formitem.name)>
<#assign psder1n=defield.getPSDER1N().name>
//输出获取外键值方法-用于通过parentdata关系填充外键值id
public String get${formitem.name?lower_case?cap_first}()
{
if(StringUtils.isEmpty(${formitem.name?lower_case}) && this.getSrfparentdata() != null)
{
if(this.getSrfparentdata().containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("${psder1n}"))
this.${formitem.name?lower_case}=this.getSrfparentdata().get("srfparentkey");
}
return this.${formitem.name?lower_case};
}
</#if>
</#if>
</#if>
</#list>
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSDESERVICEAPI
</#ibiztemplate>
<#assign hasRS = true>
package ${pub.getPKGCodeName()}.api.${item.getPSSysServiceAPI().getCodeName()?lower_case}.dto;
import java.util.ArrayList;
import java.util.List;
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().getCodeName()?lower_case}.domain.${de.getCodeName()};
import lombok.Data;
import java.sql.Timestamp;
import org.springframework.cglib.beans.BeanCopier;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@Data
public class ${item.getCodeName()}DTO {
<#if item.getPSDEServiceAPIFields()??>
<#list item.getPSDEServiceAPIFields() as apifield>
private ${srfjavatype(apifield.getPSDEField().stdDataType)} ${apifield.getPSDEField().codeName?lower_case};
</#list>
</#if>
<#comment>true/false暂时为是否导出子数据</#comment>
<#if item.getPSDEServiceAPIRSs()?? && hasRS>
<#list item.getPSDEServiceAPIRSs() as apider>
List <${apider.getMinorPSDEServiceAPI().getCodeName()}DTO> ${apider.getMinorPSDEServiceAPI().getCodeName()?lower_case}DTOs;
</#list>
</#if>
public ${de.getCodeName()} toPO() {
${de.getCodeName()} po = new ${de.getCodeName()}();
BeanCopier copier=BeanCopier.create(${de.getCodeName()}DTO.class, ${de.getCodeName()}.class, false);
copier.copy(this, po, null);
po.set${de.getKeyPSDEField().getCodeName()?lower_case?cap_first}(null);
return po;
}
public void fromPO(${de.getCodeName()} po) {
BeanCopier copier=BeanCopier.create(${de.getCodeName()}.class, ${de.getCodeName()}DTO.class, false);
copier.copy(po, this, null);
}
public List<${de.getCodeName()}DTO> fromPOPage(Page<${de.getCodeName()}> poPage) {
if(poPage == null)
return null;
//Page<${de.getCodeName()}DTO> dtoPage=new Page<${de.getCodeName()}DTO>(poPage.getCurrent(), poPage.getSize(), poPage.getTotal(), poPage.isSearchCount());
List<${de.getCodeName()}DTO> dtos=new ArrayList<${de.getCodeName()}DTO>();
for(${de.getCodeName()} po : poPage.getRecords()) {
${de.getCodeName()}DTO dto = new ${de.getCodeName()}DTO();
dto.fromPO(po);
dtos.add(dto);
}
//dtoPage.setAsc(poPage.ascs());
//dtoPage.setDesc(poPage.descs());
//dtoPage.setOptimizeCountSql(poPage.optimizeCountSql());
//dtoPage.setRecords(dtos);
return dtos;
}
}
<#ibiztemplate>
TARGET=PSDESERVICEAPI
</#ibiztemplate>
<#assign hasRS = true>
<#assign itemCodeName = item.getCodeName()>
<#assign itemSysApiCodeNameLC = item.getPSSysServiceAPI().getCodeName()?lower_case>
<#if item.isMajor()>
<#macro buildApi deapi rootPath levels>
<#if deapi.getPSDEServiceAPIMethods()??>
<#list deapi.getPSDEServiceAPIMethods() as apiMethod>
<#assign deapiCodeName = deapi.getCodeName()>
<#assign apide = deapi.getPSDataEntity()>
<#assign apideCodeName = apide.getCodeName()>
<#assign reqMtd = apiMethod.getRequestMethod()>
<#if apiMethod.getActionType()=='DEACTION'>
<#assign deaction = apiMethod.getPSDEAction()>
<#assign deactionName = deaction.getName()>
<#assign deactionCodeName = deaction.getCodeName()>
<#assign apidePKCodeNameLC = apide.getKeyPSDEField().getCodeName()?lower_case>
@ApiOperation(value = "${deaction.getLogicName()}", tags = {"${itemCodeName}" }, notes = "${deaction.getLogicName()}")
@RequestMapping(method= RequestMethod.${reqMtd} , value="${rootPath}<#if (deactionName=='Create')><#else>/{${apidePKCodeNameLC}}</#if><#if (deactionName=='Get'||deactionName=='Create'||deactionName=='Update'||deactionName=='Remove')><#else>/${deactionCodeName?lower_case}</#if>")
public <#if deactionName=='Remove'>boolean<#else>${deapiCodeName}DTO</#if> ${deactionCodeName?lower_case}${apideCodeName}(<#list levels as level>@PathVariable String ${level},</#list><#if deactionName=='Create'><#else>@PathVariable String ${apidePKCodeNameLC}</#if><#if deactionName='Get'||deactionName='Remove'><#else><#if deactionName!='Create'>,</#if>@RequestBody ${deapiCodeName}DTO dto</#if>) {
<#comment>前期iidid没做关联,暂时先自己service做操作</#comment>
<#if deactionName=='Get'||deactionName=='Remove'>
${deapiCodeName}DTO dto = new ${deapiCodeName}DTO();
</#if>
${deapiCodeName} po = dto.toPO();
<#if deactionName!='Create'>
po.set${apidePKCodeNameLC?cap_first}(${apidePKCodeNameLC});
</#if>
<#if deactionName=='Remove'>
return ${deapiCodeName?lower_case}Service.${srfmethodname(deactionCodeName)}(po);
<#else>
${deapiCodeName?lower_case}Service.${srfmethodname(deactionCodeName)}(po);
dto.fromPO(po);
return dto;
</#if>
}
<#elseif apiMethod.getActionType()=='FETCH'>
<#assign deds = apiMethod.getPSDEDataSet()>
@ApiOperation(value = "获取${deds.getLogicName()}", tags = {"${itemCodeName}" } ,notes = "获取${deds.getLogicName()}")
@RequestMapping(method= RequestMethod.${reqMtd} , value="${rootPath}/search<#if (deds.getName()=='DEFAULT')><#else>-${deds.getCodeName()?lower_case}</#if>")
public List<${deapiCodeName}DTO> search${apideCodeName}<#if (deds.getName()=='DEFAULT')><#else>${deds.getCodeName()}</#if>(@PathVariable ${apideCodeName}SearchFilter searchFilter) {
${deapiCodeName}DTO dto = new ${deapiCodeName}DTO();
return dto.fromPOPage(${deapiCodeName?lower_case}Service.search${deds.getCodeName()}(searchFilter));
}
</#if>
</#list>
</#if>
<#if deapi.getPSDEServiceAPIRSs()?? && hasRS>
<#list deapi.getPSDEServiceAPIRSs() as apider>
<@buildApi deapi=apider.getMinorPSDEServiceAPI() rootPath= rootPath + '/{' + deapi.getPSDataEntity().getKeyPSDEField().getCodeName()?lower_case +'}/' + apider.getMinorPSDEServiceAPI().getCodeName()?lower_case levels= levels + [deapi.getPSDataEntity().getKeyPSDEField().getCodeName()?lower_case] />
</#list>
</#if>
</#macro>
package ${pub.getPKGCodeName()}.api.${itemSysApiCodeNameLC}.resource;
import java.util.List;
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().getCodeName()?lower_case}.domain.${de.getCodeName()};
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().getCodeName()?lower_case}.service.${de.getCodeName()}Service;
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().getCodeName()?lower_case}.service.dto.${de.getCodeName()}SearchFilter;
<#if item.getPSDEServiceAPIRSs()?? && hasRS>
<#list item.getPSDEServiceAPIRSs() as apider>
<#assign deapide=apider.getMinorPSDEServiceAPI().getPSDataEntity()>
import ${pub.getPKGCodeName()}.${deapide.getPSSystemModule().getCodeName()?lower_case}.domain.${deapide.getCodeName()};
import ${pub.getPKGCodeName()}.${deapide.getPSSystemModule().getCodeName()?lower_case}.service.${deapide.getCodeName()}Service;
import ${pub.getPKGCodeName()}.${deapide.getPSSystemModule().getCodeName()?lower_case}.service.dto.${deapide.getCodeName()}SearchFilter;
</#list>
</#if>
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import ${pub.getPKGCodeName()}.api.${itemSysApiCodeNameLC}.dto.*;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
<#if api.getAPIType() == "RESTFUL" >
@Api(tags = {"${itemCodeName}" })
@RestController
@RequestMapping("/rest/${itemSysApiCodeNameLC}/${item.getCodeName()?lower_case}")
</#if>
public class ${item.getCodeName()}Resource {
@Autowired
private ${de.codeName}Service ${de.codeName?lower_case}Service;
<#if item.getPSDEServiceAPIRSs()?? && hasRS>
<#list item.getPSDEServiceAPIRSs() as apider>
<#assign deapide=apider.getMinorPSDEServiceAPI().getPSDataEntity()>
@Autowired
private ${deapide.codeName}Service ${deapide.codeName?lower_case}Service;
</#list>
</#if>
<#if api.getAPIType() == "RESTFUL" >
<@buildApi deapi=item rootPath='' levels=[] />
</#if>
}
</#if>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.api.swagger;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import static com.google.common.base.Predicates.or;
import static springfox.documentation.builders.PathSelectors.regex;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfiguration {
@Bean
public Docket docket() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("DEFAULT")
.pathMapping("/")
.apiInfo(
new ApiInfoBuilder()
.title("DEFAULT")
.build()
)
.select()
.paths(or(regex("/rest/.*")))
.build()
;
}
<#if sys.getAllPSSysServiceAPIs()??>
<#list sys.getAllPSSysServiceAPIs() as api>
@Bean
public Docket ${api.getCodeName()?lower_case}Docket() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("${api.getName()}")
.pathMapping("/")
.apiInfo(
new ApiInfoBuilder()
.title("${api.getName()}")
.version("${api.getAPIVersion()}")
.build()
)
.select()
.paths(or(regex("/rest/${api.getCodeName()?lower_case}/.*")))
.build()
;
}
</#list>
</#if>
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.app.controller;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.JsonNode;
import ${pub.getPKGCodeName()}.ibizutil.domain.ActionResult;
import ${pub.getPKGCodeName()}.ibizutil.errors.BadRequestAlertException;
import org.springframework.validation.annotation.Validated;
import org.springframework.http.ResponseEntity;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import com.fasterxml.jackson.databind.node.ObjectNode;
import javax.servlet.http.HttpServletRequest;
@RestController
public class AppMenuController{
<#list pub.getPSSystem().getAllPSApps() as app>
<#assign appName=app.getPKGCodeName()?lower_case>
<#if app.getAllPSAppMenuModels?? && app.getAllPSAppMenuModels()??>
<#list app.getAllPSAppMenuModels() as item>
<#assign appReqUrl="/"+app.getPKGCodeName()?lower_case+"/ctrl/"+item.codeName?lower_case+"appmenu">
@GetMapping(value="${appReqUrl}/get")
public ResponseEntity<JsonNode> ${appName}${item.codeName?lower_case?cap_first}Get(){
JsonNode jsonNode;
try{
InputStream in = this.getClass().getResourceAsStream("/appmenu/${app.getPKGCodeName()?lower_case}_${item.codeName?lower_case}.json");
jsonNode = new ObjectMapper().readTree(in);
}
catch(Exception ex){
throw new BadRequestAlertException("操作发生错误","","");
}
return ResponseEntity.ok().body(jsonNode);
}
<#if item.getPSSysCounter?? && item.getPSSysCounter()??>
<#assign sysCounter=item.getPSSysCounter()>
/**
* 菜单计数器
* @return
*/
@GetMapping(value="${appReqUrl}/get${sysCounter.codeName?lower_case}counter")
public ResponseEntity<JSONObject> ${appName}Get${sysCounter.codeName?lower_case?cap_first}Counter(){
JSONObject jobj=new JSONObject();
return ResponseEntity.ok().body(jobj);
}
</#if>
</#list>
</#if>
/**
* 系统预置服务接口
* @return
*/
@RequestMapping(value="/${app.getPKGCodeName()?lower_case}/app/${app.getPKGCodeName()?lower_case}/getappdata")
public ResponseEntity<AppData> ${appName}GetAppData(@Validated HttpServletRequest request){
AppData appData = new AppData();
return ResponseEntity.ok().body(appData);
}
</#list>
@Data
static protected class AppData{
private String remotetag = null;
private ObjectNode localdata = null;
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.app.controller;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ${pub.getPKGCodeName()}.ibizutil.domain.ActionResult;
import ${pub.getPKGCodeName()}.ibizutil.domain.CodeList;
import ${pub.getPKGCodeName()}.ibizutil.errors.BadRequestAlertException;
import org.springframework.validation.annotation.Validated;
import org.springframework.http.ResponseEntity;
@RestController
public class CodeListController{
<#list pub.getPSSystem().getAllPSApps() as app>
<#assign appReqUrl="/"+app.getPKGCodeName()?lower_case+"/app/codelist">
<#assign appName=app.getPKGCodeName()?lower_case>
<#if app.getAllPSAppViews()??>
<#list app.getAllPSAppViews() as appview>
<#if appview.getRelatedPSCodeLists()??>
<#list appview.getRelatedPSCodeLists() as codelist>
<#if !P.exists(appName+'CODELIST',codelist.getCodeName(),"ICodeList")>
@Resource(name="${codelist.getSystemTag()}_${codelist.codeName}CodeList")
private ${pub.getPKGCodeName()}.${codelist.getPSSystemModule().codeName?lower_case}.codelist.${codelist.codeName}CodeList ${srfparamname(codelist.getSystemTag())}_${appName}_${codelist.codeName}CodeList;
</#if>
</#list>
</#if>
</#list>
</#if>
<#if app.getAllPSAppViews()??>
<#list app.getAllPSAppViews() as appview>
<#if appview.getRelatedPSCodeLists()??>
<#list appview.getRelatedPSCodeLists() as codelist>
<#if !P.exists(appName+'CODELIST',codelist.getCodeName(),"getCodeList")>
<#if codelist.getPSSysRef()??>
//子系统未实现
<#else>
@RequestMapping("${appReqUrl}/${codelist.getSystemTag()?lower_case}/${codelist.codeName?lower_case}")
public ResponseEntity<CodeList> ${appName}get${codelist.getSystemTag()}_${codelist.codeName}CodeList(){
return ResponseEntity.ok().body(${srfparamname(codelist.getSystemTag())}_${appName}_${codelist.codeName}CodeList.getCodeList());
}
</#if>
</#if>
</#list>
</#if>
</#list>
</#if>
@RequestMapping("${appReqUrl}/getall")
public ResponseEntity<List<CodeList>> ${appName}getAll(){
List<CodeList> list = new ArrayList<CodeList>();
<#if app.getAllPSAppViews()??>
<#list app.getAllPSAppViews() as appview>
<#if appview.getRelatedPSCodeLists()??>
<#list appview.getRelatedPSCodeLists() as codelist>
<#if !P.exists(appName+'CODELIST',codelist.getCodeName(),"get")>
<#if codelist.getPSSysRef()??>
//子系统未实现 ${srfparamname(codelist.getSystemTag())}_${codelist.codeName}
<#else>
list.add(${srfparamname(codelist.getSystemTag())}_${appName}_${codelist.codeName}CodeList.getCodeList());
</#if>
</#if>
</#list>
</#if>
</#list>
</#if>
return ResponseEntity.ok().body(list);
}
</#list>
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#--package ${pub.getPKGCodeName()}.app.controller;-->
<#--import lombok.Data;-->
<#--import com.fasterxml.jackson.databind.node.ObjectNode;-->
<#--import ${pub.getPKGCodeName()}.ibizutil.domain.ActionResult;-->
<#--import javax.servlet.http.HttpServletRequest;-->
<#--import org.springframework.web.bind.annotation.RequestMapping;-->
<#--import org.springframework.web.bind.annotation.RestController;-->
<#--import ${pub.getPKGCodeName()}.ibizutil.errors.BadRequestAlertException;-->
<#--import org.springframework.validation.annotation.Validated;-->
<#--import org.springframework.http.ResponseEntity;-->
<#--@RestController-->
<#--@RequestMapping("/${app.getPKGCodeName()?lower_case}/app/${app.getPKGCodeName()?lower_case}")-->
<#--public class ${app.getPKGCodeName()}Controller{-->
<#--@Data-->
<#--static protected class AppData{-->
<#--private String remotetag = null;-->
<#--private ObjectNode localdata = null;-->
<#--}-->
<#---->
<#--@RequestMapping("getappdata")-->
<#--public ResponseEntity<AppData> getAppData(@Validated HttpServletRequest request){-->
<#--AppData appData = new AppData();-->
<#--fillAppData(appData);-->
<#--return ResponseEntity.ok().body(appData);-->
<#--}-->
<#---->
<#--protected void fillAppData(@Validated AppData appData){-->
<#---->
<#--}-->
<#---->
<#--}-->
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
平台发布RestController类重写请放入此文件夹
#重写RestController类
注:IDEA中可以打开基类RestController文件,鼠标点中基类RestController类名,按Alt+Enter,弹出的操作菜单中选择Create Subclass,选中此目录完成快速重写
${app.getPKGCodeName()}Main启动类中设置排除被重写的基类
```java
import org.springframework.cache.annotation.EnableCaching;
@ComponentScans({
@ComponentScan(basePackages = {"${pub.getPKGCodeName()}"}
,excludeFilters={@Filter(type=FilterType.REGEX,pattern="${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.testmodule.controller.TestEntityController")}
),
})
@EnableCaching
public class ${app.getPKGCodeName()}Main extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplicationBuilder builder = new SpringApplicationBuilder(VueR6DevMain.class);
builder.run(args) ;
}
}
```
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.boot;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScans;
import org.springframework.context.annotation.AnnotationBeanNameGenerator;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import ${pub.getPKGCodeName()}.config.liquibase.MasterProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@SpringBootApplication(exclude = {
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientAutoConfiguration.class,
org.springframework.boot.autoconfigure.security.oauth2.OAuth2AutoConfiguration.class,
DruidDataSourceAutoConfigure.class<#if sys.hasPSWFEngineType("ACTIVITI")>,
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration.class,
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration.class</#if>
})
@ComponentScans({
@ComponentScan(basePackages = {"${pub.getPKGCodeName()}"}
),
})
@MapperScan("${pub.getPKGCodeName()}.*.mapper")
@EnableConfigurationProperties({MasterProperties.class})
//@EnableFeignClients(basePackages = {"${pub.getPKGCodeName()}" })
//@EnableEurekaClient
public class ${pub.getCodeName()?lower_case}Main extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplicationBuilder builder = new SpringApplicationBuilder(${pub.getCodeName()?lower_case}Main.class);
builder.run(args) ;
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.config;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
import org.apache.ibatis.mapping.DatabaseIdProvider;
import java.util.Properties;
import org.springframework.context.annotation.Primary;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.jdbc.DataSourceBuilder;
import ${pub.getPKGCodeName()}.config.liquibase.IProperties;
import ${pub.getPKGCodeName()}.config.liquibase.MasterProperties;
import ${pub.getPKGCodeName()}.config.liquibase.TempMasterProperties;
import org.springframework.beans.factory.annotation.Autowired;
import liquibase.integration.spring.SpringLiquibase;
import org.springframework.util.StringUtils;
import com.alibaba.druid.pool.DruidDataSource;
import org.mybatis.spring.batch.MyBatisCursorItemReader;
import org.apache.ibatis.session.SqlSessionFactory;
@Configuration
public class ${pub.getCodeName()?lower_case}Conf {
@Bean
public PerformanceInterceptor performanceInterceptor() {
PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
/*<!--SQL是否格式化 默认false-->*/
performanceInterceptor.setFormat(true);
return performanceInterceptor;
}
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
/**
* 屏蔽json序列化对象属性为空的错误
* @return
*/
@Bean
public ObjectMapper objectMapper() {
return new ObjectMapper().disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
}
/**
* 多数据源切换
* @return
*/
@Bean
public DatabaseIdProvider getDatabaseIdProvider() {
DatabaseIdProvider databaseIdProvider = new VendorDatabaseIdProvider();
Properties p = new Properties();
p.setProperty("Oracle", "oracle");
p.setProperty("MySQL", "mysql");
p.setProperty("DM", "oracle");//达梦数据库使用oracle模式
<#if sysrun.getPSDBDevInst()??>
<#assign dbinst = sysrun.getPSDBDevInst()>
p.setProperty("H2", "${dbinst.getDBType()?lower_case?replace("mysql5","mysql")}");//根据当前运行的数据库设置h2对应的databaseid
</#if>
databaseIdProvider.setProperties(p);
return databaseIdProvider;
}
/**
* 主数据源版本管理
* @param
* @return
*/
@Bean
public SpringLiquibase masterliquibase(MasterProperties masterProperties) {
return LiquibaseInit(masterProperties);
}
/**
* 临时数据源版本管理
* @param
* @return
*/
@Bean
public SpringLiquibase tempMasterliquibase(TempMasterProperties tempMasterProperties) {
return LiquibaseInit(tempMasterProperties);
}
/**
* liquibase初始化数据库
* @param properties
* @return
*/
private SpringLiquibase LiquibaseInit(IProperties properties){
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setUsername(properties.getUsername());
druidDataSource.setPassword(properties.getPassword());
druidDataSource.setUrl(properties.getUrl());
SpringLiquibase liquibase = new SpringLiquibase();
liquibase.setDataSource(druidDataSource);
liquibase.setChangeLog(getChangelog(properties.getIsSyncDBSchema(),properties.getConf()));
liquibase.setContexts("development,test,production");
liquibase.setShouldRun(true);
liquibase.setDefaultSchema(properties.getDefaultSchema());
return liquibase;
}
/**
* 获取数据库差异文件
* @param isSyncDBSchema 是否同步表结构
* @param conf //liquibase配置文件
* @return
*/
private String getChangelog(String isSyncDBSchema,String conf){
String defaultChangelog="classpath:liquibase/empty.xml";
if((!StringUtils.isEmpty(isSyncDBSchema))&&(!StringUtils.isEmpty(conf))){
if(isSyncDBSchema.toLowerCase().equals("true"))
defaultChangelog=conf;
}
return defaultChangelog;
}
/**
* mybatis游标查询 MyBatisCursorItemReader
* @param sqlSessionFactory
* @return
*/
@Bean
public MyBatisCursorItemReader myMyBatisCursorItemReader(SqlSessionFactory sqlSessionFactory) {
MyBatisCursorItemReader reader =new MyBatisCursorItemReader();
reader.setQueryId("");
reader.setSqlSessionFactory(sqlSessionFactory);
return reader;
}
<#if sys.hasPSWFEngineType("ACTIVITI")>
@Bean
public org.activiti.spring.SpringProcessEngineConfiguration processEngineConfiguration(HibernateTransactionManager transactionManager, DataSource dataSource) {
org.activiti.spring.SpringProcessEngineConfiguration processEngineConfiguration = new org.activiti.spring.SpringProcessEngineConfiguration();
processEngineConfiguration.setDataSource(dataSource);
processEngineConfiguration.setTransactionManager(transactionManager);
processEngineConfiguration.setDatabaseSchemaUpdate("true");
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource[] resources = null;
try {
resources = resolver.getResources("classpath*:/activiti/*.bpmn");
} catch (IOException e) {
e.printStackTrace();
}
processEngineConfiguration.setDeploymentResources(resources);
processEngineConfiguration.setDeploymentMode("single-resource");
return processEngineConfiguration;
}
@Bean
public org.activiti.spring.ProcessEngineFactoryBean processEngine(org.activiti.spring.SpringProcessEngineConfiguration processEngineConfiguration) {
org.activiti.spring.ProcessEngineFactoryBean processEngine = new org.activiti.spring.ProcessEngineFactoryBean();
processEngine.setProcessEngineConfiguration(processEngineConfiguration);
return processEngine;
}
@Bean
public org.activiti.engine.RepositoryService repositoryService(org.activiti.engine.ProcessEngine processEngine){
return processEngine.getRepositoryService();
}
@Bean
public org.activiti.engine.RuntimeService runtimeService(org.activiti.engine.ProcessEngine processEngine){
return processEngine.getRuntimeService();
}
@Bean
public org.activiti.engine.TaskService taskService(org.activiti.engine.ProcessEngine processEngine){
return processEngine.getTaskService();
}
@Bean
public org.activiti.engine.FormService formService(org.activiti.engine.ProcessEngine processEngine){
return processEngine.getFormService();
}
@Bean
public org.activiti.engine.HistoryService historyService(org.activiti.engine.ProcessEngine processEngine){
return processEngine.getHistoryService();
}
@Bean
public org.activiti.engine.IdentityService identityService(org.activiti.engine.ProcessEngine processEngine){
return processEngine.getIdentityService();
}
@Bean
public org.activiti.engine.ManagementService managementService(org.activiti.engine.ProcessEngine processEngine){
return processEngine.getManagementService();
}
</#if>
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.config;
import ${pub.getPKGCodeName()}.ibizutil.security.AuthenticationEntryPoint;
import ${pub.getPKGCodeName()}.ibizutil.security.AuthorizationTokenFilter;
import ${pub.getPKGCodeName()}.ibizutil.service.AuthenticationUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.core.GrantedAuthorityDefaults;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = false)
public class ${pub.getCodeName()?lower_case}SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private AuthenticationEntryPoint unauthorizedHandler;
@Autowired
private AuthenticationUserService userDetailsService;
/**
* 自定义基于JWT的安全过滤器
*/
@Autowired
AuthorizationTokenFilter authenticationTokenFilter;
@Value("${r'${ibiz.jwt.header:Authorization}"'})
private String tokenHeader;
@Value("${r'${ibiz.custompermitpath:custompermit}"'})
private String custompermitpath;
@Value("${r'${ibiz.customanonymouspath:customanonymous}"'})
private String customanonymouspath;
@Value("${r'${ibiz.auth.path:ibizutil/login}"'})
private String loginPath;
@Value("${r'${ibiz.file.uploadpath:ibizutil/upload}"'})
private String uploadpath;
private final String defaultdownloadpath="ibizutil/download/{id}";
@Value("${r'${ibiz.file.downloadpath:"+defaultdownloadpath+"}"'})
private String downloadpath;
@Value("${r'${ibiz.file.previewpath:ibizutil/preview}"'})
private String previewpath;
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.userDetailsService(userDetailsService)
.passwordEncoder(passwordEncoderBean());
}
@Bean
GrantedAuthorityDefaults grantedAuthorityDefaults() {
// Remove the ROLE_ prefix
return new GrantedAuthorityDefaults("");
}
@Bean
public PasswordEncoder passwordEncoderBean() {
return new BCryptPasswordEncoder();
}
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity
// 禁用 CSRF
.csrf().disable()
// 授权异常
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
// 不创建会话
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
// 过滤请求
.authorizeRequests()
.antMatchers(
HttpMethod.GET,
"/*.html",
"/**/*.html",
"/**/*.css",
"/**/*.js",
"/**/*.ico",
"/**/assets/**",
"/**/css/**",
"/**/fonts/**",
"/**/js/**",
"/**/img/**",
"/"
).permitAll()
.antMatchers( HttpMethod.POST,"/"+loginPath).permitAll()
.antMatchers("/websocket/**").permitAll()
// 文件操作
.antMatchers("/"+downloadpath).permitAll()
.antMatchers("/"+uploadpath).permitAll()
.antMatchers("/"+previewpath+"/**").permitAll()
.antMatchers("/"+custompermitpath+"/**").permitAll()
.antMatchers("/"+customanonymouspath+"/**").anonymous()
.antMatchers("/**/codelist/**").permitAll()
.antMatchers("/**/getappdata").permitAll()
// 系统监控
.antMatchers("/actuator/**").anonymous()
// swagger start
.antMatchers("/swagger-ui.html").anonymous()
.antMatchers("/swagger-resources/**").anonymous()
.antMatchers("/webjars/**").anonymous()
.antMatchers("/*/api-docs").anonymous()
// swagger end
// 接口限流测试
.antMatchers("/test/**").anonymous()
.antMatchers(HttpMethod.OPTIONS, "/**").anonymous()
.antMatchers("/druid/**").permitAll()
// 所有请求都需要认证
.anyRequest().authenticated()
// 防止iframe 造成跨域
.and().headers().frameOptions().disable();
httpSecurity
.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.config;
import com.github.benmanes.caffeine.cache.CaffeineSpec;
import ${pub.getPKGCodeName()}.ibizutil.cache.layering.LayeringCacheManager;
import ${pub.getPKGCodeName()}.ibizutil.cache.setting.FirstCacheSetting;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.cache.CacheProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cache.CacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.cache.RedisCacheWriter;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Profile;
import org.springframework.util.StringUtils;
import java.util.HashMap;
import java.util.Map;
/**
* 缓存配置类
* 1级缓存为caffeine
* 2级缓存为redis
*/
@Profile("prod")
@EnableCaching
@Configuration
@EnableConfigurationProperties(CacheProperties.class)
public class CacheConfig {
@Bean
public RedisCacheManager redisCacheManager(RedisConnectionFactory connectionFactory) {
return RedisCacheManager.create(connectionFactory);
}
@Bean
public RedisCacheWriter redisCacheWriter(RedisConnectionFactory connectionFactory){
RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory);
return redisCacheWriter;
}
@Autowired
private RedisCacheWriter redisCacheWriter;
@Autowired
private RedisCacheConfiguration configuration;
@Bean
@Primary
public CacheManager cacheManager() {
LayeringCacheManager layeringCacheManager = new LayeringCacheManager();
setFirstCacheConfig(layeringCacheManager);//Caffeine缓存设置
layeringCacheManager.setAllowNullValues(true); //允许存null,防止缓存击穿
layeringCacheManager.setRedisCacheWriter(redisCacheWriter);
layeringCacheManager.setRedisConfiguration(configuration);
return layeringCacheManager;
}
@Autowired
private CacheProperties cacheProperties;
private void setFirstCacheConfig(LayeringCacheManager layeringCacheManager) {
String specification = cacheProperties.getCaffeine().getSpec();
if (StringUtils.hasText(specification)) {
layeringCacheManager.setCaffeineSpec(CaffeineSpec.parse(specification));
}
Map<String, FirstCacheSetting> firstCacheSettings = new HashMap<>();
layeringCacheManager.setFirstCacheSettings(firstCacheSettings);
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.config;
import org.kie.api.KieBase;
import org.kie.api.KieServices;
import org.kie.api.builder.*;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.internal.io.ResourceFactory;
import org.kie.spring.KModuleBeanFactoryPostProcessor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import java.io.IOException;
@Configuration
public class DroolsAutoConfiguration {
private static final String RULES_PATH = "rules/**/";
@Bean
@ConditionalOnMissingBean(KieFileSystem.class)
public KieFileSystem kieFileSystem() throws IOException {
KieFileSystem kieFileSystem = getKieServices().newKieFileSystem();
for (Resource file : getRuleFiles()) {
kieFileSystem.write(ResourceFactory.newUrlResource(file.getURL()));
}
return kieFileSystem;
}
private Resource[] getRuleFiles() throws IOException {
ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
return resourcePatternResolver.getResources("classpath*:" + RULES_PATH + "**/*.*");
}
@Bean
@ConditionalOnMissingBean(KieContainer.class)
public KieContainer kieContainer() throws IOException {
final KieRepository kieRepository = getKieServices().getRepository();
kieRepository.addKieModule(new KieModule() {
public ReleaseId getReleaseId() {
return kieRepository.getDefaultReleaseId();
}
});
KieBuilder kieBuilder = getKieServices().newKieBuilder(kieFileSystem());
kieBuilder.buildAll();
return getKieServices().newKieContainer(kieRepository.getDefaultReleaseId());
}
private KieServices getKieServices() {
return KieServices.Factory.get();
}
@Bean
@ConditionalOnMissingBean(KieBase.class)
public KieBase kieBase() throws IOException {
return kieContainer().getKieBase();
}
@Bean
@ConditionalOnMissingBean(KieSession.class)
public KieSession kieSession() throws IOException {
return kieContainer().newKieSession();
}
@Bean
@ConditionalOnMissingBean(KModuleBeanFactoryPostProcessor.class)
public KModuleBeanFactoryPostProcessor kiePostProcessor() {
return new KModuleBeanFactoryPostProcessor();
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.config.liquibase;
public interface IProperties {
/**
*获取数据库用户名
*/
String getUsername();
/**
*获取数据库密码
*/
String getPassword();
/**
*获取数据库url
*/
String getUrl();
/**
*获取数据库schema
*/
String getDefaultSchema();
/**
*获取是否同步
*/
String getIsSyncDBSchema();
/**
* liquibase配置文件
*/
String getConf();
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.config.liquibase;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.master")
@Data
public class MasterProperties implements IProperties{
private String url;
private String username;
private String password;
private String isSyncDBSchema;
private String defaultSchema;
private String conf;
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.config.liquibase;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.tempmaster")
@Data
public class TempMasterProperties implements IProperties{
private String url;
private String username;
private String password;
private String isSyncDBSchema;
private String defaultSchema;
private String conf;
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.ibizutil;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class SpringContextHolder implements ApplicationContextAware
{
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
SpringContextHolder.applicationContext = applicationContext;
}
public static ApplicationContext getApplicationContext() {
assertApplicationContext();
return applicationContext;
}
@SuppressWarnings("unchecked")
public static <T> T getBean(String beanName) {
assertApplicationContext();
return (T) applicationContext.getBean(beanName);
}
public static <T> T getBean(Class<T> requiredType) {
assertApplicationContext();
return applicationContext.getBean(requiredType);
}
private static void assertApplicationContext() {
if (SpringContextHolder.applicationContext == null) {
throw new RuntimeException("applicaitonContext属性为null,请检查是否注入了SpringContextHolder!");
}
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.ibizutil.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD})
public @interface Audit
{
String fieldLogicName() default "";//字段逻辑名称
String dictName() default "";//代码表名称
String fieldType() default"";//字段类型
String format() default "";//格式化
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.ibizutil.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD})
public @interface Dict
{
String dictName() default "";//代码表转换类
String textField() default "";
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.ibizutil.annotation;
import ${pub.getPKGCodeName()}.ibizutil.enums.FillMode;
import ${pub.getPKGCodeName()}.ibizutil.enums.PredefinedType;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD})
public @interface PreField
{
FillMode fill() default FillMode.INSERT_UPDATE;//填充模式 insert or update
PredefinedType preType() default PredefinedType.DEFAULT;//预置属性类型
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.ibizutil.aspect;
import ${pub.getPKGCodeName()}.ibizutil.annotation.Audit;
import ${pub.getPKGCodeName()}.ibizutil.domain.EntityBase;
import ${pub.getPKGCodeName()}.ibizutil.domain.IBZDataAudit;
import ${pub.getPKGCodeName()}.ibizutil.helper.DataAuditHelper;
import ${pub.getPKGCodeName()}.ibizutil.helper.IPHelper;
import ${pub.getPKGCodeName()}.ibizutil.security.AuthenticationUser;
import ${pub.getPKGCodeName()}.ibizutil.service.IBZDataAuditService;
import ${pub.getPKGCodeName()}.ibizutil.service.ServiceImplBase;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Map;
/**
* 实体数据审计切面类
*/
@Aspect
@Component
public class AuditAspect
{
@Autowired
IBZDataAuditService dataAuditService;
/**
* 实体数据建立切面,在成功创建数据后将新增数据内容记录审计日志内(审计明细【AuditInfo】中只记录审计属性变化情况,审计属性在平台属性中配置)
* @param point
*/
@AfterReturning(value = "execution(* ${pub.getPKGCodeName()}.*.service.*.create(..))")
public void create(JoinPoint point){
HttpServletRequest request=null;
RequestAttributes requestAttributes=RequestContextHolder.getRequestAttributes();
if(requestAttributes!=null){
request=((ServletRequestAttributes)requestAttributes).getRequest();
}
Object [] args = point.getArgs();
if(args.length>0){
Object serviceObj=point.getTarget();
Object serviceParam =args[0];
if (serviceParam instanceof EntityBase && serviceObj instanceof ServiceImplBase){
EntityBase curEntity=(EntityBase)serviceParam;//创建数据
Map<Field, Audit> auditFields= curEntity.getAuditField();
if(auditFields.size()==0)//是否有审计属性
return;
String auditResult = DataAuditHelper.getInstance().CompareAuditObjectByInsert(curEntity,auditFields);//获取审计明细
saveAuditData("创建",curEntity.getClass().getSimpleName(),curEntity.getSrfkey(),request,auditResult,1);//记录审计日志
return;
}
}
}
/**
* 实体数据更新切面,在成功更新数据后将新增数据内容记录审计日志内(审计明细【AuditInfo】中只记录审计属性变化情况,审计属性在平台属性中配置)
* 使用环切【@Around】获取到更新前后的实体数据并进行差异比较,并将差异内容记入审计日志内
* @param point
*/
@Around("execution(* ${pub.getPKGCodeName()}.*.service.*.update(..))")
public Object update(ProceedingJoinPoint point) throws Throwable {
HttpServletRequest request=null;
RequestAttributes requestAttributes=RequestContextHolder.getRequestAttributes();
if(requestAttributes!=null){
request=((ServletRequestAttributes)requestAttributes).getRequest();
}
Object serviceObj=point.getTarget();
Object args[]=point.getArgs();
if(args.length>0){
Object arg=args[0];
if(arg instanceof EntityBase && serviceObj instanceof ServiceImplBase){
ServiceImplBase service= (ServiceImplBase) serviceObj;
EntityBase curEntity= (EntityBase) arg;
Map<Field, Audit> auditFields= curEntity.getAuditField();
if(auditFields.size()==0)//是否有审计属性
return point.proceed();
EntityBase before_entity= curEntity.getClass().newInstance();
before_entity.setSrfkey(curEntity.getSrfkey());
service.get(before_entity);//获取更新前的数据
point.proceed();//执行更新操作
EntityBase after_entity= curEntity.getClass().newInstance();
after_entity.setSrfkey(curEntity.getSrfkey());
service.get(after_entity);//获取更新后的数据
String auditResult=DataAuditHelper.getInstance().CompareAuditObjectByUpdate(before_entity,after_entity,auditFields);//比较更新前后差异内容
int isDataChanged=1;
if(StringUtils.isEmpty(auditResult))//审计内容是否发生变化
isDataChanged=0;
saveAuditData("更新",curEntity.getClass().getSimpleName(),curEntity.getSrfkey(),request,auditResult,isDataChanged);//记录审计日志
}
}
return true;
}
/**
* 实体数据更新切面,在成功更新数据后将新增数据内容记录审计日志内(审计明细【AuditInfo】中只记录审计属性变化情况,审计属性在平台属性中配置)
* 使用环切【@Around】获取要删除的完整数据,并将审计属性相关信息记录到审计日志中
* @param point
* @return
* @throws Throwable
*/
@Around("execution(* ${pub.getPKGCodeName()}.*.service.*.remove(..))")
public Object remove(ProceedingJoinPoint point) throws Throwable {
HttpServletRequest request=null;
RequestAttributes requestAttributes=RequestContextHolder.getRequestAttributes();
if(requestAttributes!=null){
request=((ServletRequestAttributes)requestAttributes).getRequest();
}
Object serviceObj=point.getTarget();
Object args[]=point.getArgs();
if(args.length>0){
Object arg=args[0];
if(arg instanceof EntityBase && serviceObj instanceof ServiceImplBase){
ServiceImplBase service= (ServiceImplBase) serviceObj;
EntityBase curEntity= (EntityBase) arg;
Map<Field, Audit> auditFields= curEntity.getAuditField();
if(auditFields.size()==0)//是否有审计属性
return point.proceed();//无审计属性,跳过审计,执行remove
EntityBase remove_entity= curEntity.getClass().newInstance();
remove_entity.setSrfkey(curEntity.getSrfkey());
service.get(remove_entity);//获取要删除的完整数据
point.proceed();//执行remove
String auditResult=DataAuditHelper.getInstance().CompareAuditObjectByRemove(remove_entity,auditFields);//获取审计明细
saveAuditData("删除",curEntity.getClass().getSimpleName(),curEntity.getSrfkey(),request,auditResult,1);//记录审计日志
}
}
return true;
}
/**
* 保存审计数据
* @param auditLogicName
* @param entityName
* @param srfkey
* @param request
* @param auditResult
* @param isDataChanged
*/
private void saveAuditData(String auditLogicName,String entityName,Object srfkey,HttpServletRequest request,String auditResult,int isDataChanged){
IBZDataAudit dataAudit =new IBZDataAudit();
dataAudit.setOppersonid(AuthenticationUser.getAuthenticationUser().getUserid());
dataAudit.setOppersonname(String.format("%s[%s]",AuthenticationUser.getAuthenticationUser().getPersonname(),AuthenticationUser.getAuthenticationUser().getOrgname()));
dataAudit.setAudittype(auditLogicName);
dataAudit.setAuditobject(entityName);
dataAudit.setAuditobjectdata(srfkey);
dataAudit.setOptime(new Timestamp(new Date().getTime()));
if(request!=null)
dataAudit.setIpaddress(IPHelper.getIpAddress(request, AuthenticationUser.getAuthenticationUser()));
dataAudit.setAuditinfo(auditResult);
dataAudit.setIsdatachanged(isDataChanged);
dataAuditService.save(dataAudit);
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.ibizutil.cache.redis;
import org.springframework.data.redis.cache.RedisCache;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.cache.RedisCacheWriter;
/**
* 自定义的redis缓存
*/
public class CustomizedRedisCache extends RedisCache {
public CustomizedRedisCache(String name, RedisCacheWriter redisCacheWriter,RedisCacheConfiguration configuration) {
super(name, redisCacheWriter, configuration);
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.ibizutil.cache.setting;
import com.github.benmanes.caffeine.cache.CaffeineSpec;
public class FirstCacheSetting {
/**
* 一级缓存配置,配置项请点击这里 {@link CaffeineSpec#configure(String, String)}
* @param cacheSpecification
*/
public FirstCacheSetting(String cacheSpecification) {
this.cacheSpecification = cacheSpecification;
}
private String cacheSpecification;
public String getCacheSpecification() {
return cacheSpecification;
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.ibizutil.client.uaa;
public class UAAClientCfg {
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册