提交 7fe90329 编写于 作者: ibizdev's avatar ibizdev

INIT

上级
javaee
\ No newline at end of file
# **iBiz4j Spring R7 Template**
### 技术栈
我们的目标为您生成一个完整和现代Web应用或者微服务架构, 具体如下:
#### 完整的[Spring应用](https://spring.io/):
* 基于[Spring Boot](https://projects.spring.io/spring-boot/)提供应用配置简化
* [Maven](https://maven.apache.org/)构建,测试,运行应用
* [Spring Security](https://docs.spring.io/spring-security/site/index.html)组件
* [JSON Web令牌(JWT)](https://jwt.io/)身份验证安全机制
* [Spring MVC REST](https://spring.io/guides/gs/rest-service/) + [Jackson](https://github.com/FasterXML/jackson)
* [Swagger](https://swagger.io/)来自动生成REST Controller API文档
* [Zalando Problem Spring Web](https://github.com/zalando/problem-spring-web)处理异常
* ~~基于Spring websocket组件, 可选的Websocket支持~~
* [Mybatis-plus](https://mp.baomidou.com/) / [Spring Data JPA](https://projects.spring.io/spring-data-jpa/)和Bean校验
* 基于[Liquibase](http://www.liquibase.org/)数据库更新
* [Elasticsearch](https://github.com/elastic/elasticsearch)支持,如果你需要基于你的数据库提供高级搜索能力
* [MongoDB](https://www.mongodb.org/)支持, 如果你想使用面向文档的NOSQL数据库替代JPA
* [~~Cassandra~~](https://cassandra.apache.org/)~~支持, 如果你想使用面向列的NOSQL数据库替代JPA~~
* [RocketMQ](http://rocketmq.apache.org/)支持, 如果你需要一个消息发布订阅系统
* 构建标准可执行的JAR文件
#### 微服务[Microservices](https://microservices.io):
* 基于[Netflix Zuul](https://github.com/Netflix/zuul)的HTTP流量路由
* 基于[Nacos](https://nacos.io/zh-cn/index.html)[Eureka](https://github.com/Netflix/eureka)的服务发现
* 基于[Feign](https://github.com/OpenFeign/feign)的服务消费客户端
#### 生产环境组件:
* 使用[Druid](https://github.com/alibaba/druid)[ELK Stack](https://www.elastic.co/products)监控
* 使用[Caffeine](https://github.com/ben-manes/caffeine) + [Redis](https://redis.io/)提供两级缓存
* 静态资源优化 (gzip filter, HTTP cache headers)
* 使用[Logback](http://logback.qos.ch/)管理日志,可在运行时配置日志输出
* 使用[dynamic datasource](https://gitee.com/baomidou/dynamic-datasource-spring-boot-starter)多库切换和读写分离,极致的性能提升
* 使用[xxl-job](https://github.com/xuxueli/xxl-job)任务调度引擎
* 完整的[Docker](https://www.docker.com/)[Docker Compose](https://github.com/docker/compose)支持
* ~~支持云服务提供商: …~~
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>
<parent>
<artifactId>${pub.getCodeName()?lower_case}-app</artifactId>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<version>${pub.getVersionString()?default("V0.0.1_alpha")}</version>
</parent>
<artifactId>${pub.getCodeName()?lower_case}-app-${app.getPKGCodeName()?lower_case}</artifactId>
<name>${pub.getCodeName()?lower_case?cap_first} Gateway ${app.getPKGCodeName()}</name>
<description>${pub.getCodeName()?lower_case?cap_first} ${app.getPKGCodeName()}</description>
<dependencies>
<dependency>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<artifactId>${pub.getCodeName()?lower_case}-util</artifactId>
<version>${r'${project.version}'}</version>
</dependency>
<#if app.getAppMode()?? && app.getAppMode() == "WFAPP">
<dependency>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<artifactId>${pub.getCodeName()?lower_case}-workflow</artifactId>
<version>${r'${project.version}'}</version>
</dependency>
</#if>
</dependencies>
<properties>
<docker.image.prefix>registry.cn-shanghai.aliyuncs.com/ibizsys</docker.image.prefix>
</properties>
<profiles>
<profile>
<id>${app.getPKGCodeName()?lower_case}</id>
<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>
</resources>
<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_${app.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_${app.getPKGCodeName()}</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>${pub.getCodeName()?lower_case}-app-${app.getPKGCodeName()?lower_case}</finalName>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<mainClass>${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.${app.getPKGCodeName()}Application</mainClass>
<outputDirectory>../../</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<serverId>ibiz-dev</serverId>
<imageName>${r'${docker.image.prefix}/${project.artifactId}'}:latest</imageName>
<dockerDirectory>${r'${project.basedir}'}/src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>../../</directory>
<include>${r'${project.artifactId}'}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
<#assign httpPort = "8080">
<#if sysrun?? >
<#if sysrun.getPSDevSlnMSDepApp()??>
<#if sysrun.getPSDevSlnMSDepApp().getHttpPort()??>
<#assign httpPort = sysrun.getPSDevSlnMSDepApp().getHttpPort()?c>
</#if>
</#if>
</#if>
version: "3.2"
services:
${pub.getCodeName()?lower_case}-app-${app.getPKGCodeName()?lower_case}:
image: registry.cn-shanghai.aliyuncs.com/ibizsys/${pub.getCodeName()?lower_case}-app-${app.getPKGCodeName()?lower_case}:latest
ports:
- "${httpPort}:${httpPort}"
networks:
- agent_network
deploy:
mode: replicated
replicas: 1
networks:
agent_network:
driver: overlay
attachable: true
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
<#assign httpPort = "8080">
<#if sysrun?? >
<#if sysrun.getPSDevSlnMSDepApp()??>
<#if sysrun.getPSDevSlnMSDepApp().getHttpPort()??>
<#assign httpPort = sysrun.getPSDevSlnMSDepApp().getHttpPort()?c>
</#if>
</#if>
</#if>
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}-app-${app.getPKGCodeName()?lower_case}.jar
EXPOSE ${httpPort}
ADD ${pub.getCodeName()?lower_case}-app-${app.getPKGCodeName()?lower_case}.jar /${pub.getCodeName()?lower_case}-app-${app.getPKGCodeName()?lower_case}.jar
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case};
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignClientsConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
@Slf4j
@Import({
FeignClientsConfiguration.class
})
@EnableDiscoveryClient
@Configuration
@EnableFeignClients
@EnableZuulProxy
@ComponentScan(basePackages = {"${pub.getPKGCodeName()}"})
@MapperScan("${pub.getPKGCodeName()}.*.mapper")
@SpringBootApplication(exclude = {
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
})
public class ${app.getPKGCodeName()}Application{
public static void main(String[] args) {
SpringApplication.run(${app.getPKGCodeName()}Application.class,args);
}
}
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.config;
import ${pub.getPKGCodeName()}.util.security.AuthenticationEntryPoint;
import ${pub.getPKGCodeName()}.util.security.AuthorizationTokenFilter;
import ${pub.getPKGCodeName()}.util.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;
import org.springframework.context.annotation.Profile;
@Profile("${app.getPKGCodeName()?lower_case}-prod")
@Configuration
@EnableWebSecurity
public class ${app.getPKGCodeName()}SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private AuthenticationEntryPoint unauthorizedHandler;
@Autowired
private AuthenticationUserService userDetailsService;
/**
* 自定义基于JWT的安全过滤器
*/
@Autowired
AuthorizationTokenFilter authenticationTokenFilter;
@Value("${r'${ibiz.auth.path:v7/login}"'})
private String loginPath;
@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()
// 所有请求都需要认证
.anyRequest().authenticated()
// 防止iframe 造成跨域
.and().headers().frameOptions().disable();
httpSecurity
.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
}
}
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
<#assign httpPort = "8080">
<#if sysrun?? >
<#if sysrun.getPSDevSlnMSDepApp()??>
<#if sysrun.getPSDevSlnMSDepApp().getHttpPort()??>
<#assign httpPort = sysrun.getPSDevSlnMSDepApp().getHttpPort()?c>
</#if>
</#if>
</#if>
server:
port: ${httpPort}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
<#assign httpPort = "8080">
<#if sysrun?? >
<#if sysrun.getPSDevSlnMSDepApp()??>
<#if sysrun.getPSDevSlnMSDepApp().getHttpPort()??>
<#assign httpPort = sysrun.getPSDevSlnMSDepApp().getHttpPort()?c>
</#if>
</#if>
</#if>
server:
port: ${httpPort}
<#if item.getAllPSAppDataEntities?? && app.getAllPSAppDataEntities()??>
#zuul网关路由设置
zuul:
routes:
<#list item.getAllPSAppDataEntities() as appDataEntity>
<#assign serviceId="">
<#assign serviceUrl=srfpluralize(appDataEntity.codeName?lower_case)>
<#assign appEntity=appDataEntity.name?lower_case>
<#assign psDataEntity=appDataEntity.getPSDataEntity()>
<#assign systemName=sys.getCodeName()?lower_case>
<#if psDataEntity.getStorageMode()==4>
<#comment>serviceApi模式</#comment>
<#assign serviceId=(psDataEntity.getPSSubSysServiceAPI().getServiceCodeName())!''>
<#assign serviceUrl=srfpluralize(appDataEntity.name?lower_case)>
<#else>
<#assign sysApi=appDataEntity.getPSDEServiceAPI().getPSSysServiceAPI().codeName?lower_case>
<#assign deApi=appDataEntity.getPSDEServiceAPI().codeName?lower_case>
<#assign serviceId=systemName+"-"+sysApi>
</#if>
${appEntity}:
path: /${serviceUrl}/**
serviceId: ${serviceId}
stripPrefix: false
</#list>
<#comment>通过设置该参数,避免Zuul转发请求时丢失Authorization请求头信息</#comment>
sensitive-headers:
- Cookie,Set-Cookie,Authorization
</#if>
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
spring:
profiles:
include: sys , ${app.getPKGCodeName()?lower_case}-prod
application:
name: ${sys.getCodeName()?lower_case}-${app.getPKGCodeName()?lower_case}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>
<parent>
<artifactId>${pub.getCodeName()?lower_case}</artifactId>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<version>${pub.getVersionString()?default("V0.0.1_alpha")}</version>
</parent>
<artifactId>${pub.getCodeName()?lower_case}-app</artifactId>
<name>${pub.getCodeName()?lower_case?cap_first} Application</name>
<description>${pub.getCodeName()?lower_case?cap_first} Application</description>
<packaging>pom</packaging>
<#-- modules -->
<#if sys.getAllPSApps()??>
<modules>
<#list sys.getAllPSApps() as app>
<module>${pub.getCodeName()?lower_case}-app-${app.getPKGCodeName()?lower_case}</module>
</#list>
</modules>
</#if>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<#--<dependency>-->
<#--<groupId>org.springframework.cloud</groupId>-->
<#--<artifactId>spring-cloud-starter-security</artifactId>-->
<#--<version>2.1.1.RELEASE</version>-->
<#--</dependency>-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<#--<dependency>-->
<#--<groupId>org.springframework.security</groupId>-->
<#--<artifactId>spring-security-cas</artifactId>-->
<#--</dependency>-->
<#--<dependency>-->
<#--<groupId>${pub.getPKGCodeName()?lower_case}</groupId>-->
<#--<artifactId>${pub.getCodeName()?lower_case}-util</artifactId>-->
<#--<version>${r'${project.version}'}</version>-->
<#--</dependency>-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
</dependencies>
</project>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>
<parent>
<artifactId>${pub.getCodeName()?lower_case}</artifactId>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<version>${pub.getVersionString()?default("V0.0.1_alpha")}</version>
</parent>
<artifactId>${pub.getCodeName()?lower_case}-boot</artifactId>
<name>${pub.getCodeName()?lower_case?cap_first} Dev Monolithic Boot</name>
<description>${pub.getCodeName()?lower_case?cap_first} Boot</description>
<dependencies>
<dependency>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<artifactId>${pub.getCodeName()?lower_case}-core</artifactId>
<version>${r'${project.version}'}</version>
</dependency>
<#comment>引入后台服务接口</#comment>
<#if sys.getAllPSSysServiceAPIs()??>
<#list sys.getAllPSSysServiceAPIs() as sysapi>
<dependency>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<artifactId>${pub.getCodeName()?lower_case}-provider-${sysapi.getCodeName()?lower_case}</artifactId>
<version>${r'${project.version}'}</version>
</dependency>
</#list>
</#if>
<#comment>引入前端应用</#comment>
<#if sys.getAllPSApps()??>
<#list sys.getAllPSApps() as sysApp>
<dependency>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<artifactId>${pub.getCodeName()?lower_case}-app-${sysApp.getPKGCodeName()?lower_case}</artifactId>
<version>${r'${project.version}'}</version>
</dependency>
</#list>
</#if>
</dependencies>
<!--由于boot是通过dependency来关联所有子项目,页面和配置等信息都存在与子项目中,
所以您在对boot进行打包前,需要先将子项目install到maven仓库,以确保boot可以正常引用所有完整的子项目-->
<profiles>
<profile>
<id>boot</id>
<build>
<resources>
<resource>
<directory>${r'${basedir}'}/src/main/resources</directory>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>${pub.codeName?lower_case}</finalName>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<mainClass>${pub.getPKGCodeName()}.DevBootApplication</mainClass>
<outputDirectory>../</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()};
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.boot.SpringApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
@Slf4j
@EnableDiscoveryClient
@Configuration
@EnableTransactionManagement
@SpringBootApplication
@EnableFeignClients(basePackages = {"${pub.getPKGCodeName()}" })
public class DevBootApplication{
public static void main(String[] args) {
SpringApplication.run(DevBootApplication.class,args);
}
}
<#ibiztemplate>
TARGET=PSSYSSERVICEAPI
</#ibiztemplate>
package ${pub.getPKGCodeName()}.config;
import ${pub.getPKGCodeName()}.util.security.AuthenticationEntryPoint;
import ${pub.getPKGCodeName()}.util.security.AuthorizationTokenFilter;
import ${pub.getPKGCodeName()}.util.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 = true)
public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private AuthenticationEntryPoint unauthorizedHandler;
@Autowired
private AuthenticationUserService userDetailsService;
/**
* 自定义基于JWT的安全过滤器
*/
@Autowired
AuthorizationTokenFilter authenticationTokenFilter;
@Value("${r'${ibiz.auth.path:v7/login}"'})
private String loginPath;
@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()
.anyRequest().authenticated()
// 防止iframe 造成跨域
.and().headers().frameOptions().disable();
httpSecurity
.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#assign httpPort = "8080">
<#if sysrun?? >
<#if sysrun.getPSDevSlnMSDepAPI()??>
<#if sysrun.getPSDevSlnMSDepAPI().getHttpPort()??>
<#assign httpPort = sysrun.getPSDevSlnMSDepAPI().getHttpPort()?c>
</#if>
</#if>
</#if>
server:
port: ${httpPort}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#comment>引入前端应用</#comment>
<#assign refAppYaml="">
<#if sys.getAllPSApps()??>
<#list sys.getAllPSApps() as sysApp>
<#assign refAppYaml=refAppYaml+sysApp.getPKGCodeName()?lower_case+"-dev">
<#assign refAppYaml=refAppYaml+",">
</#list>
</#if>
<#comment>引入后台服务接口</#comment>
<#assign refProviderYaml="">
<#if sys.getAllPSSysServiceAPIs()??>
<#list sys.getAllPSSysServiceAPIs() as sysapi>
<#assign refProviderYaml=refProviderYaml+sysapi.getCodeName()?lower_case+"-dev">
<#assign refProviderYaml=refProviderYaml+",">
</#list>
</#if>
spring:
profiles:
include: sys , <#if refAppYaml!=''>${refAppYaml}</#if> <#if refProviderYaml!=''> ${refProviderYaml} </#if> dev
application:
name: ${item.getCodeName()?lower_case}
main:
allow-bean-definition-overriding: true
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>
<parent>
<artifactId>${pub.getCodeName()?lower_case}</artifactId>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<version>${pub.getVersionString()?default("V0.0.1_alpha")}</version>
</parent>
<artifactId>${pub.getCodeName()?lower_case}-core</artifactId>
<name>${pub.getCodeName()?lower_case?cap_first} Core</name>
<description>${pub.getCodeName()?lower_case?cap_first} Core</description>
<dependencies>
<dependency>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<artifactId>${pub.getCodeName()?lower_case}-util</artifactId>
<version>${r'${project.version}'}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<!-- JBPM -->
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-flow-builder</artifactId>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-bpmn2</artifactId>
</dependency>
<!-- Drools -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-spring</artifactId>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<!-- MySQL数据库 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- Druid阿里连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
</dependency>
<!--MapStruct高性能属性映射工具-->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
</dependency>
<!--MongoDB-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<!--Liquibase数据库版本更新工具-->
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
</dependencies>
</project>
<#ibiztemplate>
TARGET=PSSUBSYSSERVICEAPIDE
</#ibiztemplate>
<#assign refDE=sys.getPSDataEntity(item.name)>
<#if refDE??>
package ${pub.getPKGCodeName()}.core.${refDE.getPSSystemModule().getCodeName()?lower_case}.client;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;
import ${pub.getPKGCodeName()}.core.${refDE.getPSSystemModule().getCodeName()?lower_case}.domain.${refDE.getCodeName()};
import ${pub.getPKGCodeName()}.core.${refDE.getPSSystemModule().getCodeName()?lower_case}.filter.${refDE.getCodeName()}SearchContext;
import org.springframework.stereotype.Component;
<#if item.getPSSubSysServiceAPI().getServicePath()??>
<#if item.getPSSubSysServiceAPI().getServicePath() != '' >
<#assign fullpath= item.getPSSubSysServiceAPI().getServicePath() + "/" + srfpluralize(item.getCodeName()?lower_case) >
<#else>
<#assign fullpath="/" + item.getPSSubSysServiceAPI().getCodeName()?lower_case + "/" + srfpluralize(item.getCodeName()?lower_case) >
</#if>
<#else>
<#assign fullpath="/" + item.getPSSubSysServiceAPI().getCodeName()?lower_case + "/" + srfpluralize(item.getCodeName()?lower_case) >
</#if>
/**
* 实体[${item.codeName}] 服务对象接口
*/
@Component
public class ${item.codeName}Fallback implements ${item.codeName}FeignClient{
<#if item.getPSSubSysServiceAPIDEMethods()??>
<#list item.getPSSubSysServiceAPIDEMethods() as apiMethod>
<#assign req_param_type=(apiMethod.getRequestParamType()!'')>
<#assign req_param=(apiMethod.getRequestField()!'')>
<#assign retval_type=(apiMethod.getRetvalType())!''>
<#assign return_type='void'>
<#if return_type?? && return_type!='' && retval_type !='VOID' && retval_type='ENTITY' ><#comment>由于无法获取到返回值类型,暂时通过请求参数类型确定返回值类型</#comment>
<#assign return_type=item.codeName>
</#if>
<#if apiMethod.getActionType()=='DEACTION'><#comment>实体行为</#comment>
<#-- ${return_type} ${srfmethodname(apiMethod.getCodeName())}(<#if req_param_type?? && req_param_type=='ENTITY'><#if apiMethod.getPSDEName()??>${apiMethod.getPSDEName()} entity</#if></#if>); -->
<#if apiMethod.getCodeName()?lower_case == 'get'>
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}")-->
public ${item.codeName} get(${srfjavatype(item.getKeyDEField().stdDataType)} ${item.getKeyDEField().getCodeName()?lower_case}){
return null;
}
<#elseif apiMethod.getCodeName()?lower_case == 'remove'>
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}")-->
public Boolean remove(${srfjavatype(item.getKeyDEField().stdDataType)} ${item.getKeyDEField().getCodeName()?lower_case}){
return false;
}
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")-->
public Boolean removeBatch(Collection<${srfjavatype(item.getKeyDEField().stdDataType)}> idList){
return false;
}
<#elseif apiMethod.getCodeName()?lower_case == 'create'>
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}")-->
public ${item.codeName} create(${item.codeName} ${item.codeName?lower_case}){
return null;
}
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")-->
public Boolean createBatch(List<${item.codeName}> ${srfpluralize(item.getCodeName()?lower_case)}){
return false;
}
<#elseif apiMethod.getCodeName()?lower_case == 'save'>
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}")-->
public Boolean save(${item.codeName} ${item.codeName?lower_case}){
return false;
}
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")-->
public Boolean saveBatch(List<${item.codeName}> ${srfpluralize(item.getCodeName()?lower_case)}){
return false;
}
<#elseif apiMethod.getCodeName()?lower_case == 'update'>
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}")-->
public ${item.codeName} update(${srfjavatype(item.getKeyDEField().stdDataType)} ${item.getKeyDEField().getCodeName()?lower_case}, ${item.codeName} ${item.codeName?lower_case}){
return null;
}
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")-->
public Boolean updateBatch(List<${item.codeName}> ${srfpluralize(item.getCodeName()?lower_case)}){
return false;
}
<#elseif apiMethod.getCodeName()?lower_case == 'getdraft'>
public ${item.codeName} getDraft(){
return null;
}
<#elseif apiMethod.getCodeName()?lower_case == 'checkkey'>
public Boolean checkKey(${item.codeName} ${item.codeName?lower_case}){
return false;
}
<#elseif apiMethod.getCodeName()?lower_case == 'createbatch'>
<#elseif apiMethod.getCodeName()?lower_case == 'updatebatch'>
<#elseif apiMethod.getCodeName()?lower_case == 'removebatch'>
<#elseif apiMethod.getCodeName()?lower_case == 'savebatch'>
<#else>
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}/${apiMethod.getCodeName()?lower_case}")-->
public ${item.codeName} ${apiMethod.getCodeName()?uncap_first}( ${srfjavatype(item.getKeyDEField().stdDataType)} ${item.getKeyDEField().getCodeName()?lower_case}, ${item.codeName} ${item.codeName?lower_case}){
return null;
}
</#if>
<#elseif apiMethod.getActionType()=='SELECT'><#comment>简单查询</#comment>
<#-- List<${item.codeName}> ${srfmethodname(apiMethod.getCodeName())}(<#if req_param_type?? && req_param_type=='ENTITY'><#if apiMethod.getPSDEName()??>${apiMethod.getPSDEName()} entity</#if></#if>); -->
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")-->
public Page<${item.codeName}> ${apiMethod.getCodeName()?uncap_first}(){
return null;
}
<#elseif apiMethod.getActionType()=='FETCH'><#comment>数据集合</#comment>
<#--@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")-->
public Page<${item.codeName}> ${apiMethod.getCodeName()?uncap_first?replace("fetch","search")}(${refDE.getCodeName()}SearchContext context){
return null;
}
<#elseif apiMethod.getActionType()=='USER'><#comment>用户自定义</#comment>
public void ${apiMethod.getCodeName()?uncap_first}(){
return null;
}
</#if>
</#list>
</#if>
}
</#if>
<#ibiztemplate>
TARGET=PSSUBSYSSERVICEAPIDE
</#ibiztemplate>
<#assign refDE=sys.getPSDataEntity(item.name)>
<#if refDE??>
package ${pub.getPKGCodeName()}.core.${refDE.getPSSystemModule().getCodeName()?lower_case}.client;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;
import ${pub.getPKGCodeName()}.core.${refDE.getPSSystemModule().getCodeName()?lower_case}.domain.${refDE.getCodeName()};
import ${pub.getPKGCodeName()}.core.${refDE.getPSSystemModule().getCodeName()?lower_case}.filter.${refDE.getCodeName()}SearchContext;
import org.springframework.cloud.openfeign.FeignClient;
<#if item.getPSSubSysServiceAPI().getServicePath()??>
<#if item.getPSSubSysServiceAPI().getServicePath() != '' >
<#assign fullpath= item.getPSSubSysServiceAPI().getServicePath() + "/" + srfpluralize(item.getCodeName()?lower_case) >
<#else>
<#assign fullpath="/" + item.getPSSubSysServiceAPI().getCodeName()?lower_case + "/" + srfpluralize(item.getCodeName()?lower_case) >
</#if>
<#else>
<#assign fullpath="/" + item.getPSSubSysServiceAPI().getCodeName()?lower_case + "/" + srfpluralize(item.getCodeName()?lower_case) >
</#if>
/**
* 实体[${item.codeName}] 服务对象接口
*/
@FeignClient(value = "${(item.getPSSubSysServiceAPI().getServiceCodeName())!''}", fallback = ${item.codeName}Fallback.class)
public interface ${item.codeName}FeignClient {
<#if item.getPSSubSysServiceAPIDEMethods()??>
<#list item.getPSSubSysServiceAPIDEMethods() as apiMethod>
<#assign req_param_type=(apiMethod.getRequestParamType()!'')>
<#assign req_param=(apiMethod.getRequestField()!'')>
<#assign retval_type=(apiMethod.getRetvalType())!''>
<#assign return_type='void'>
<#if return_type?? && return_type!='' && retval_type !='VOID' && retval_type='ENTITY' ><#comment>由于无法获取到返回值类型,暂时通过请求参数类型确定返回值类型</#comment>
<#assign return_type=item.codeName>
</#if>
<#if apiMethod.getActionType()=='DEACTION'><#comment>实体行为</#comment>
<#-- ${return_type} ${srfmethodname(apiMethod.getCodeName())}(<#if req_param_type?? && req_param_type=='ENTITY'><#if apiMethod.getPSDEName()??>${apiMethod.getPSDEName()} entity</#if></#if>); -->
<#if apiMethod.getCodeName()?lower_case == 'get'>
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}")
${item.codeName} get(@PathVariable("${item.getKeyDEField().getCodeName()?lower_case}") ${srfjavatype(item.getKeyDEField().stdDataType)} ${item.getKeyDEField().getCodeName()?lower_case});
<#elseif apiMethod.getCodeName()?lower_case == 'remove'>
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}")
Boolean remove(@PathVariable("${item.getKeyDEField().getCodeName()?lower_case}") ${srfjavatype(item.getKeyDEField().stdDataType)} ${item.getKeyDEField().getCodeName()?lower_case});
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")
Boolean removeBatch(@RequestBody Collection<${srfjavatype(item.getKeyDEField().stdDataType)}> idList);
<#elseif apiMethod.getCodeName()?lower_case == 'create'>
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}")
${item.codeName} create(@RequestBody ${item.codeName} ${item.codeName?lower_case});
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")
Boolean createBatch(@RequestBody List<${item.codeName}> ${srfpluralize(item.getCodeName()?lower_case)});
<#elseif apiMethod.getCodeName()?lower_case == 'save'>
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/save")
Boolean save(@RequestBody ${item.codeName} ${item.codeName?lower_case});
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")
Boolean saveBatch(@RequestBody List<${item.codeName}> ${srfpluralize(item.getCodeName()?lower_case)});
<#elseif apiMethod.getCodeName()?lower_case == 'getdraft'>
@RequestMapping(method = RequestMethod.GET, value = "${fullpath}/getdraft")
${item.codeName} getDraft();
<#elseif apiMethod.getCodeName()?lower_case == 'checkkey'>
@RequestMapping(method = RequestMethod.POST, value = "${fullpath}/checkkey")
Boolean checkKey(@RequestBody ${item.codeName} ${item.codeName?lower_case});
<#elseif apiMethod.getCodeName()?lower_case == 'update'>
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}")
${item.codeName} update(@PathVariable("${item.getKeyDEField().getCodeName()?lower_case}") ${srfjavatype(item.getKeyDEField().stdDataType)} ${item.getKeyDEField().getCodeName()?lower_case},@RequestBody ${item.codeName} ${item.codeName?lower_case});
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")
Boolean updateBatch(@RequestBody List<${item.codeName}> ${srfpluralize(item.getCodeName()?lower_case)});
<#elseif apiMethod.getCodeName()?lower_case == 'createbatch'>
<#elseif apiMethod.getCodeName()?lower_case == 'updatebatch'>
<#elseif apiMethod.getCodeName()?lower_case == 'removebatch'>
<#elseif apiMethod.getCodeName()?lower_case == 'savebatch'>
<#else>
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}/${apiMethod.getCodeName()?lower_case}")
${item.codeName} ${apiMethod.getCodeName()?uncap_first}(@PathVariable("${item.getKeyDEField().getCodeName()?lower_case}") ${srfjavatype(item.getKeyDEField().stdDataType)} ${item.getKeyDEField().getCodeName()?lower_case},@RequestBody ${item.codeName} ${item.codeName?lower_case});
</#if>
<#elseif apiMethod.getActionType()=='SELECT'><#comment>简单查询</#comment>
<#-- List<${item.codeName}> ${srfmethodname(apiMethod.getCodeName())}(<#if req_param_type?? && req_param_type=='ENTITY'><#if apiMethod.getPSDEName()??>${apiMethod.getPSDEName()} entity</#if></#if>); -->
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")
Page<${item.codeName}> ${apiMethod.getCodeName()?uncap_first}();
<#elseif apiMethod.getActionType()=='FETCH'><#comment>数据集合</#comment>
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case?replace("fetch","search")}")
Page<${item.codeName}> ${apiMethod.getCodeName()?uncap_first?replace("fetch","search")}(${refDE.getCodeName()}SearchContext context);
<#elseif apiMethod.getActionType()=='USER'><#comment>用户自定义</#comment>
void ${apiMethod.getCodeName()?uncap_first}();
</#if>
</#list>
</#if>
}
</#if>
<#ibiztemplate>
TARGET=PSDATAENTITY
</#ibiztemplate>
package ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.domain;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.math.BigInteger;
import java.util.HashMap;
import java.math.BigDecimal;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import ${pub.getPKGCodeName()}.util.domain.EntityBase;
import ${pub.getPKGCodeName()}.util.annotation.DEField;
import ${pub.getPKGCodeName()}.util.enums.DEPredefinedFieldType;
import ${pub.getPKGCodeName()}.util.enums.DEFieldDefaultValueType;
import java.io.Serializable;
import lombok.Data;
import org.springframework.data.annotation.Transient;
<#comment>SQL存储-Mybatis</#comment>
<#if de.getStorageMode()==1>
import com.baomidou.mybatisplus.annotation.*;
import ${pub.getPKGCodeName()}.util.domain.EntityMP;
/**
* 实体[${item.getLogicName()}]
*/
@Data
@TableName(value = "${item.getTableName()}",resultMap = "${item.codeName}ResultMap")
public class ${item.getCodeName()} extends EntityMP implements Serializable {
private static final long serialVersionUID = 1L;
<#if de.getPSDEFields()??>
<#comment>输出实体属性</#comment>
<#list de.getPSDEFields() as defield>
<#assign defDataType = (defield.getDataType())!"">
<#if defDataType!='ONE2MANYDATA'>
<#assign columnname = defield.getName()?lower_case>
<#assign prvateCodeName = srfcaseformat(defield.getCodeName(),'l_u2lC') >
<#assign publicCodeName = prvateCodeName?cap_first >
<#assign jsonfield = defield.getCodeName()?lower_case >
<#assign tablefieldano = "value = \""+columnname+"\"" >
<#assign defieldano = "" >
<#if defield.getDefaultValue()?? && defield.getDefaultValue()!=''>
<#assign defieldano = "defaultValue = \""+defield.getDefaultValue()+"\"">
</#if>
<#if defield.getDefaultValueType()?? && defield.getDefaultValueType()!=''>
<#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , ">
</#if>
<#assign defieldano = defieldano+"defaultValueType = DEFieldDefaultValueType."+defield.getDefaultValueType()?upper_case>
</#if>
<#if defield.isKeyDEField()==true>
<#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , ">
</#if>
<#assign defieldano = defieldano+"isKeyField=true">
<#elseif defield.getPredefinedType()?? && defield.getPredefinedType()!=''>
<#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , ">
</#if>
<#assign defieldano = defieldano+"preType = DEPredefinedFieldType."+defield.getPredefinedType()?upper_case>
<#if defield.getPredefinedType()?lower_case =='createdate'||defield.getPredefinedType()?lower_case =='createman'>
<#assign tablefieldano = tablefieldano+" , fill = FieldFill.INSERT">
<#elseif defield.getPredefinedType()?lower_case =='logicvalid'>
<#if de.getLogicValidPSDEField()?? && de.isLogicValid()==true>
<#assign defieldano = defieldano+", logicval = \""+((item.getValidLogicValue())!'1')+"\" , logicdelval=\""+((item.getInvalidLogicValue())!'0')+"\"">
</#if>
</#if>
</#if>
/**
* ${defield.getLogicName()}
*/
<#comment>属性默认值</#comment>
<#if defieldano?? && defieldano!='' && defield.isPhisicalDEField()==true>
@DEField(${defieldano})
</#if>
<#comment>主键</#comment>
<#if defield.isKeyDEField()==true>
@TableId(value= "${columnname}",type=IdType.UUID)
<#elseif defield.isPhisicalDEField()==false>
@TableField(exist = false)
<#elseif defield.getPredefinedType?? && defield.getPredefinedType()?? && defield.getPredefinedType()?lower_case =='logicvalid'>
<#comment>逻辑有效默认值-用于mybatis-plus删除时update逻辑有效值</#comment>
<#if de.getLogicValidPSDEField()?? && de.isLogicValid()==true>
<#if (((item.getValidLogicValue())!'')!='') && (((item.getInvalidLogicValue())!'')!='')>
@TableLogic(value= "${item.getValidLogicValue()}",delval="${item.getInvalidLogicValue()}")
<#else>
@TableLogic
</#if>
</#if>
@TableField(${tablefieldano})
<#else>
@TableField(${tablefieldano})
</#if>
<#if defDataType == "DATETIME" || (defDataType=='PICKUPDATA' && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
@JSONField(name = "${jsonfield}" , format="yyyy-MM-dd HH:mm:ss")
<#elseif defDataType == "DATE" || (defDataType=='PICKUPDATA' && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td")>
@JsonFormat(pattern="yyyy-MM-dd", locale = "zh" , timezone="GMT+8")
@JSONField(name = "${jsonfield}" , format="yyyy-MM-dd")
<#elseif defDataType == "TIME" || (defDataType=='PICKUPDATA' && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="HH:mm", locale = "zh" , timezone="GMT+8")
@JSONField(name = "${jsonfield}" , format="HH:mm")
<#else>
@JSONField(name = "${jsonfield}")
</#if>
@JsonProperty("${jsonfield}")
private ${srfjavatype(defield.getStdDataType())} ${prvateCodeName};
</#if>
</#list>
<#comment>创建1N关系实体-输出主实体</#comment>
<#if item.getMinorPSDERs?? && item.getMinorPSDERs()??>
<#list item.getMinorPSDERs() as MinorPSDER>
<#if MinorPSDER?? && MinorPSDER.getDERType()=='DER1N'>
<#if MinorPSDER.getMajorPSDataEntity?? && MinorPSDER.getMajorPSDataEntity()?? && MinorPSDER.getCodeName?? && MinorPSDER.getCodeName()??>
<#assign MajorEntity = MinorPSDER.getMajorPSDataEntity()>
<#if MajorEntity.getCodeName?? && MinorPSDER.getCodeName()?? >
/**
* ${MinorPSDER.getLogicName()}
*/
@JsonIgnore
@JSONField(serialize = false)
@TableField(exist = false)
private ${pub.getPKGCodeName()}.core.${MajorEntity.getPSSystemModule().getCodeName()?lower_case}.domain.${MajorEntity.getCodeName()} ${srfcaseformat(MinorPSDER.getCodeName(),'l_u2lC')};
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>输出关系数据(子实体)</#comment>
<#if de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as der>
<#if der.getDERType() =='DER1N' >
<#assign listcode=(der.getMinorCodeName()!der.getMinorPSDataEntity().getCodeName())>
<#if listcode?? && listcode==''><#assign listcode=der.getMinorPSDataEntity().getCodeName()></#if>
<#assign columnname=srfcaseformat(listcode,'l_u2lC')>
<#assign subDTOs = srfpluralize(listcode)?lower_case >
<#assign nested=der.isNestedRS()>
<#if nested == false && der.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list der.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
/**
* ${der.getMinorPSDataEntity().getLogicName()}
*/
<#if der.getMinorPSDataEntity().getStorageMode()==0>
@JSONField(name = "${subDTOs}")
@JsonProperty("${subDTOs}")
<#if der.getPSOne2ManyDataDEField()?? && der.getPSOne2ManyDataDEField().isPhisicalDEField()==true>
<#assign columnname=der.getPSOne2ManyDataDEField().getName()?lower_case>
@TableField(value = "${columnname}" , typeHandler = ${pub.getPKGCodeName()}.core.${der.getMinorPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.domain.handlers.${der.getMinorPSDataEntity().getCodeName()}TypeHandler.class)
<#else >
@TableField(exist = false)
</#if>
<#else>
@JsonIgnore
@JSONField(serialize = false)
@TableField(exist = false)
</#if>
private List<${pub.getPKGCodeName()}.core.${der.getMinorPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.domain.${der.getMinorPSDataEntity().getCodeName()}> ${srfcaseformat(listcode,'l_u2lC')};
<#if der.getMinorPSDataEntity().getStorageMode()==0 && der.getPSOne2ManyDataDEField()?? && der.getPSOne2ManyDataDEField().isPhisicalDEField()==true>
/**
* 设置 [${der.getMinorPSDataEntity().getLogicName()}]
*/
public void set${srfcaseformat(listcode,'l_u2lC')?cap_first}(List<${pub.getPKGCodeName()}.core.${der.getMinorPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.domain.${der.getMinorPSDataEntity().getCodeName()}> ${srfcaseformat(listcode,'l_u2lC')}){
this.${srfcaseformat(listcode,'l_u2lC')} = ${srfcaseformat(listcode,'l_u2lC')} ;
this.modify("${columnname}",(${srfcaseformat(listcode,'l_u2lC')}!=null)?${srfcaseformat(listcode,'l_u2lC')}:(new ArrayList()));
}
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>输出set方法用于设置null</#comment>
<#list de.getPSDEFields() as defield>
<#assign defDataType = (defield.getDataType())!"">
<#assign columnname = defield.getName()?lower_case>
<#assign prvateCodeName = srfcaseformat(defield.getCodeName(),'l_u2lC') >
<#assign publicCodeName = prvateCodeName?cap_first >
<#assign jsonfield = defield.getCodeName()?lower_case >
<#if defield.isPhisicalDEField()==true && defield.isKeyDEField()==false && defDataType!='ONE2MANYDATA'>
<#if defield.getPredefinedType()?? && defield.getPredefinedType()!=''>
<#else >
/**
* 设置 [${defield.getLogicName()}]
*/
public void set${publicCodeName}(${srfjavatype(defield.getStdDataType())} ${prvateCodeName}){
this.${prvateCodeName} = ${prvateCodeName} ;
this.modify("${columnname}",${prvateCodeName});
}
</#if>
</#if>
</#list>
</#if>
}
<#comment>NoSQL存储-MongoDB</#comment>
<#elseif de.getStorageMode()==2>
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.data.mongodb.core.mapping.FieldType;
import ${pub.getPKGCodeName()}.util.domain.EntityMongo;
/**
* 大数据 [${item.getLogicName()}] 对象
*/
@Data
@Document(collection = "${item.getCodeName()?lower_case}")
public class ${item.getCodeName()} extends EntityMongo implements Serializable {
<#if de.getPSDEFields()??>
<#comment>输出实体属性</#comment>
<#list de.getPSDEFields() as defield>
<#assign defDataType = (defield.getDataType())!"">
<#if defDataType!='ONE2MANYDATA'>
<#assign columnname = defield.getName()?lower_case>
<#assign prvateCodeName = srfcaseformat(defield.getCodeName(),'l_u2lC') >
<#assign publicCodeName = prvateCodeName?cap_first >
<#assign jsonfield = defield.getCodeName()?lower_case >
<#assign defieldano = "" >
<#if defield.getDefaultValue()?? && defield.getDefaultValue()!=''>
<#assign defieldano = "defaultValue = \""+defield.getDefaultValue()+"\"">
</#if>
<#if defield.getDefaultValueType()?? && defield.getDefaultValueType()!=''>
<#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , ">
</#if>
<#assign defieldano = defieldano+"defaultValueType = DEFieldDefaultValueType."+defield.getDefaultValueType()?upper_case>
</#if>
<#if defield.isKeyDEField()==true>
<#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , ">
</#if>
<#assign defieldano = defieldano+"isKeyField=true">
<#elseif defield.getPredefinedType()?? && defield.getPredefinedType()!=''>
<#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , ">
</#if>
<#assign defieldano = defieldano+"preType = DEPredefinedFieldType."+defield.getPredefinedType()?upper_case>
<#if defield.getPredefinedType()?lower_case =='logicvalid'>
<#if de.getLogicValidPSDEField()?? && de.isLogicValid()==true>
<#assign defieldano = defieldano+", logicval = \""+((item.getValidLogicValue())!'1')+"\" , logicdelval=\""+((item.getInvalidLogicValue())!'0')+"\"">
</#if>
</#if>
</#if>
/**
* ${defield.getLogicName()}
*/
<#if defield.isKeyDEField()==true>
@Id()
</#if>
<#comment>属性默认值</#comment>
<#if defieldano?? && defieldano!='' && defield.isPhisicalDEField()==true>
@DEField(${defieldano})
</#if>
<#assign defDataType = (defield.getDataType())!"">
<#if defDataType == "DATETIME" || (defDataType=='PICKUPDATA' && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
@JSONField(name = "${jsonfield}" , format="yyyy-MM-dd HH:mm:ss")
<#elseif defDataType == "DATE" || (defDataType=='PICKUPDATA' && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td")>
@JsonFormat(pattern="yyyy-MM-dd", locale = "zh" , timezone="GMT+8")
@JSONField(name = "${jsonfield}" , format="yyyy-MM-dd")
<#elseif defDataType == "TIME" || (defDataType=='PICKUPDATA' && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="HH:mm", locale = "zh" , timezone="GMT+8")
@JSONField(name = "${jsonfield}" , format="HH:mm")
<#else>
@JSONField(name = "${jsonfield}")
</#if>
@JsonProperty("${jsonfield}")
<#if defield.isKeyDEField()==false>
@Field(name = "${columnname}")
</#if>
private ${srfjavatype(defield.getStdDataType())} ${prvateCodeName};
</#if>
</#list>
<#comment>创建1N关系实体-输出主实体</#comment>
<#if item.getMinorPSDERs?? && item.getMinorPSDERs()??>
<#list item.getMinorPSDERs() as MinorPSDER>
<#if MinorPSDER?? && MinorPSDER.getDERType()=='DER1N'>
<#if MinorPSDER.getMajorPSDataEntity?? && MinorPSDER.getMajorPSDataEntity()?? && MinorPSDER.getCodeName?? && MinorPSDER.getCodeName()??>
<#assign MajorEntity = MinorPSDER.getMajorPSDataEntity()>
<#if MajorEntity.getCodeName?? && MinorPSDER.getCodeName()?? >
/**
* ${MinorPSDER.getLogicName()}
*/
@JsonIgnore
@JSONField(serialize = false)
@Transient
private ${pub.getPKGCodeName()}.core.${MajorEntity.getPSSystemModule().getCodeName()?lower_case}.domain.${MajorEntity.getCodeName()} ${srfcaseformat(MinorPSDER.getCodeName(),'l_u2lC')};
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>输出关系数据(子实体)</#comment>
<#if de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as der>
<#if der.getDERType() =='DER1N' >
<#assign listcode=(der.getMinorCodeName()!der.getMinorPSDataEntity().getCodeName())>
<#if listcode?? && listcode==''><#assign listcode=der.getMinorPSDataEntity().getCodeName()></#if>
<#assign subDTOs = srfpluralize(listcode)?lower_case >
<#assign nested=der.isNestedRS()>
<#if nested == false && der.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list der.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
/**
* ${der.getMinorPSDataEntity().getLogicName()}
*/
<#if der.getMinorPSDataEntity().getStorageMode()==0>
@JSONField(name = "${subDTOs}")
@JsonProperty("${subDTOs}")
<#if der.getPSOne2ManyDataDEField()??>
@Field(name = "${der.getPSOne2ManyDataDEField().getName()?lower_case}"
<#else >
@Field(name = "${srfcaseformat(listcode,'l_u2lC')}")
</#if>
<#else >
@JsonIgnore
@JSONField(serialize = false)
@Transient
</#if>
private List<${pub.getPKGCodeName()}.core.${der.getMinorPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.domain.${der.getMinorPSDataEntity().getCodeName()}> ${srfcaseformat(listcode,'l_u2lC')};
</#if>
</#if>
</#list>
</#if>
</#if>
}
<#comment>Api存储</#comment>
<#elseif de.getStorageMode()==4 || de.getStorageMode()==0>
import ${pub.getPKGCodeName()}.util.domain.EntityClient;
/**
* ServiceApi [${item.getLogicName()}] 对象
*/
@Data
public class ${item.getCodeName()} extends EntityClient implements Serializable {
<#if de.getPSDEFields()??>
<#comment>输出实体属性</#comment>
<#list de.getPSDEFields() as defield>
<#assign defDataType = (defield.getDataType())!"">
<#if defDataType!='ONE2MANYDATA'>
<#assign columnname = defield.getName()?lower_case>
<#assign prvateCodeName = srfcaseformat(defield.getCodeName(),'l_u2lC') >
<#assign publicCodeName = prvateCodeName?cap_first >
<#assign jsonfield = defield.getCodeName()?lower_case >
<#if de.getStorageMode()==0><#assign jsonfield = defield.getCodeName()?uncap_first ></#if>
<#assign defieldano = "" >
<#if defield.getDefaultValue()?? && defield.getDefaultValue()!=''>
<#assign defieldano = "defaultValue = \""+defield.getDefaultValue()+"\"">
</#if>
<#if defield.getDefaultValueType()?? && defield.getDefaultValueType()!=''>
<#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , ">
</#if>
<#assign defieldano = defieldano+"defaultValueType = DEFieldDefaultValueType."+defield.getDefaultValueType()?upper_case>
</#if>
<#if defield.isKeyDEField()==true>
<#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , ">
</#if>
<#assign defieldano = defieldano+"isKeyField=true">
<#elseif defield.getPredefinedType()?? && defield.getPredefinedType()!=''>
<#if defieldano?? && defieldano!=''>
<#assign defieldano = defieldano+" , ">
</#if>
<#assign defieldano = defieldano+"preType = DEPredefinedFieldType."+defield.getPredefinedType()?upper_case>
<#if defield.getPredefinedType()?lower_case =='logicvalid'>
<#if de.getLogicValidPSDEField()?? && de.isLogicValid()==true>
<#assign defieldano = defieldano+", logicval = \""+((item.getValidLogicValue())!'1')+"\" , logicdelval=\""+((item.getInvalidLogicValue())!'0')+"\"">
</#if>
</#if>
</#if>
/**
* ${defield.getLogicName()}
*/
<#comment>属性默认值</#comment>
<#if defieldano?? && defieldano!='' && defield.isPhisicalDEField()==true>
@DEField(${defieldano})
</#if>
<#assign defDataType = (defield.getDataType())!"">
<#if defDataType == "DATETIME" || (defDataType=='PICKUPDATA' && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
@JSONField(name = "${jsonfield}" , format="yyyy-MM-dd HH:mm:ss")
<#elseif defDataType == "DATE" || (defDataType=='PICKUPDATA' && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tY-%1$tm-%1$td")>
@JsonFormat(pattern="yyyy-MM-dd", locale = "zh" , timezone="GMT+8")
@JSONField(name = "${jsonfield}" , format="yyyy-MM-dd")
<#elseif defDataType == "TIME" || (defDataType=='PICKUPDATA' && srfdatatype(defield.getStdDataType())== "DATETIME" && defield.getValueFormat()=="%1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="HH:mm", locale = "zh" , timezone="GMT+8")
@JSONField(name = "${jsonfield}" , format="HH:mm")
<#else>
@JSONField(name = "${jsonfield}")
</#if>
@JsonProperty("${jsonfield}")
private ${srfjavatype(defield.getStdDataType())} ${prvateCodeName};
</#if>
</#list>
<#comment>创建1N关系实体-输出主实体</#comment>
<#if item.getMinorPSDERs?? && item.getMinorPSDERs()??>
<#list item.getMinorPSDERs() as MinorPSDER>
<#if MinorPSDER?? && MinorPSDER.getDERType()=='DER1N'>
<#if MinorPSDER.getMajorPSDataEntity?? && MinorPSDER.getMajorPSDataEntity()?? && MinorPSDER.getCodeName?? && MinorPSDER.getCodeName()??>
<#assign MajorEntity = MinorPSDER.getMajorPSDataEntity()>
<#if MajorEntity.getCodeName?? && MinorPSDER.getCodeName()?? >
/**
* ${MinorPSDER.getLogicName()}
*/
@JSONField(name = "${srfcaseformat(MinorPSDER.getCodeName(),'l_u2lC')?lower_case}")
@JsonProperty("${srfcaseformat(MinorPSDER.getCodeName(),'l_u2lC')?lower_case}")
private ${pub.getPKGCodeName()}.core.${MajorEntity.getPSSystemModule().getCodeName()?lower_case}.domain.${MajorEntity.getCodeName()} ${srfcaseformat(MinorPSDER.getCodeName(),'l_u2lC')};
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>输出关系数据(子实体)</#comment>
<#if de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as der>
<#if der.getDERType() =='DER1N' >
<#assign listcode=(der.getMinorCodeName()!der.getMinorPSDataEntity().getCodeName())>
<#if listcode?? && listcode==''><#assign listcode=der.getMinorPSDataEntity().getCodeName()></#if>
<#assign subDTOs = srfpluralize(listcode)?lower_case >
<#assign nested=der.isNestedRS()>
<#if nested == false && der.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list der.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
/**
* ${der.getMinorPSDataEntity().getLogicName()}
*/
@JSONField(name = "${subDTOs}")
@JsonProperty("${subDTOs}")
private List<${pub.getPKGCodeName()}.core.${der.getMinorPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.domain.${der.getMinorPSDataEntity().getCodeName()}> ${srfcaseformat(listcode,'l_u2lC')};
</#if>
</#if>
</#list>
</#if>
<#comment>输出set方法用于设置null</#comment>
<#list de.getPSDEFields() as defield>
<#assign defDataType = (defield.getDataType())!"">
<#assign columnname = defield.getName()?lower_case>
<#assign prvateCodeName = srfcaseformat(defield.getCodeName(),'l_u2lC') >
<#assign publicCodeName = prvateCodeName?cap_first >
<#assign jsonfield = defield.getCodeName()?lower_case >
<#if defield.isPhisicalDEField()==true && defield.isKeyDEField()==false && defDataType!='ONE2MANYDATA'>
<#if defield.getPredefinedType()?? && defield.getPredefinedType()!=''>
<#else >
/**
* 设置 [${defield.getLogicName()}]
*/
public void set${publicCodeName}(${srfjavatype(defield.getStdDataType())} ${prvateCodeName}){
this.${prvateCodeName} = ${prvateCodeName} ;
this.modify("${columnname}",${prvateCodeName});
}
</#if>
</#if>
</#list>
</#if>
}
</#if>
<#ibiztemplate>
TARGET=PSDATAENTITY
</#ibiztemplate>
<#assign needconv = false>
<#if de.getStorageMode()==0>
<#comment>判断无存储实体中的外键是否有物理化bson主表字段,有则需要输出类型转换器</#comment>
<#if item.getMinorPSDERs?? && item.getMinorPSDERs()??>
<#list item.getMinorPSDERs() as MinorPSDER>
<#if MinorPSDER?? && MinorPSDER.getDERType()=='DER1N'>
<#if MinorPSDER.getMajorPSDataEntity?? && MinorPSDER.getMajorPSDataEntity()?? && MinorPSDER.getCodeName?? && MinorPSDER.getCodeName()??>
<#assign MajorEntity = MinorPSDER.getMajorPSDataEntity()>
<#if MajorEntity.getCodeName?? && MinorPSDER.getCodeName()?? && MajorEntity.getStorageMode()==1>
<#if MinorPSDER.getPSOne2ManyDataDEField()?? && MinorPSDER.getPSOne2ManyDataDEField().isPhisicalDEField()==true>
<#assign needconv=true>
</#if>
</#if>
</#if>
</#if>
</#list>
</#if>
</#if>
<#if needconv==true>
package ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.domain.handlers;
import ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.domain.${item.getCodeName()};
import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@MappedTypes({List.class})
@MappedJdbcTypes(JdbcType.VARCHAR)
public class ${item.getCodeName()}TypeHandler extends AbstractJsonTypeHandler<List>
{
private static ObjectMapper objectMapper = new ObjectMapper();
private JavaType type;
public ${item.getCodeName()}TypeHandler(Class<List> type) {
this.type = objectMapper.getTypeFactory().constructParametricType(ArrayList.class, ${item.getCodeName()}.class);
}
@Override
protected List parse(String json) {
try {
return objectMapper.readValue(json, type);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@Override
protected String toJson(List obj) {
try {
return objectMapper.writeValueAsString(obj);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
public static void setObjectMapper(ObjectMapper objectMapper) {
${item.getCodeName()}TypeHandler.objectMapper = objectMapper;
}
}
</#if>
<#ibiztemplate>
TARGET=PSDATAENTITY
</#ibiztemplate>
package ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.filter;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
<#comment>SQL存储-Mybatis</#comment>
<#if de.getStorageMode()==1>
import ${pub.getPKGCodeName()}.util.filter.QueryWrapperContext;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().codeName?lower_case}.domain.${item.getCodeName()};
/**
* 关系型数据实体[${item.codeName}] 查询条件对象
*/
@Slf4j
@Data
public class ${item.codeName}SearchContext extends QueryWrapperContext<${item.codeName}> {
<#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")
@JSONField(format="yyyy-MM-dd HH:mm:ss")
<#elseif defDataType == "DATE">
@JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+8")
@JSONField(format="yyyy-MM-dd")
<#elseif defDataType == "TIME">
@JsonFormat(pattern="HH:mm", timezone="GMT+8")
@JSONField(format="HH:mm")
</#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(!ObjectUtils.isEmpty(this.${formitem.getName()?lower_case})){
<#if formitem.getValueOp() == "LIKE">
this.getSelectCond().like("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "LEFTLIKE">
this.getSelectCond().likeRight("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "RIGHTLIKE">
this.getSelectCond().likeLeft("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "EQ">
this.getSelectCond().eq("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "NOTEQ">
this.getSelectCond().ne("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "GT">
this.getSelectCond().gt("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "GTANDEQ">
this.getSelectCond().ge("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "LT">
this.getSelectCond().lt("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "LTANDEQ">
this.getSelectCond().le("${formitem.getPSDEField().getName()?lower_case}", ${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "ISNOTNULL">
if(this.${formitem.getName()?lower_case}.toString().equals("1")){
this.getSelectCond().isNotNull("${formitem.getPSDEField().getName()?lower_case}");
}
<#elseif formitem.getValueOp() == "ISNULL">
if(this.${formitem.getName()?lower_case}.toString().equals("1")){
this.getSelectCond().isNull("${formitem.getPSDEField().getName()?lower_case}");
}
<#elseif formitem.getValueOp() == "IN">
<#if formitem.getPSCodeListId()??>
<#assign codeListName=getCodeListName(formitem.getPSCodeListId())>
String defaultSeparator=(CodeListBase.getCodeList("${codeListName}")==null)?";":CodeListBase.getCodeList("${codeListName}").getCodeList().getValueseparator();
<#else >
String defaultSeparator=";";
</#if>
this.getSelectCond().in("${formitem.getPSDEField().getName()?lower_case}",this.${formitem.getName()?lower_case}.split(defaultSeparator));
<#elseif formitem.getValueOp() == "NOTIN">
<#if formitem.getPSCodeListId()??>
<#assign codeListName=getCodeListName(formitem.getPSCodeListId())>
String defaultSeparator=(CodeListBase.getCodeList("${codeListName}")==null)?";":CodeListBase.getCodeList("${codeListName}").getCodeList().getValueseparator();
<#else >
String defaultSeparator=";";
</#if>
String defaultSeparator=";";
this.getSelectCond().notIn("${formitem.getPSDEField().getName()?lower_case}",this.${formitem.getName()?lower_case}.split(defaultSeparator));
</#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.getSelectCond().or().like("${defield.name?lower_case}",query);
</#if>
</#list>
}
}
}
<#comment>NoSQL存储-MongoDB</#comment>
<#elseif de.getStorageMode()==2>
import ${pub.getPKGCodeName()}.util.filter.QueryBuildContext;
import ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().codeName?lower_case}.domain.${item.getCodeName()};
import java.util.regex.Pattern;
import com.mongodb.BasicDBObject;
/**
* NoSQL数据实体[${item.codeName}] 查询条件对象
*/
@Slf4j
@Data
public class ${item.codeName}SearchContext extends QueryBuildContext {
<#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")
@JSONField(format="yyyy-MM-dd HH:mm:ss")
<#elseif defDataType == "DATE">
@JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+8")
@JSONField(format="yyyy-MM-dd")
<#elseif defDataType == "TIME">
@JsonFormat(pattern="HH:mm", timezone="GMT+8")
@JSONField(format="HH:mm")
</#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(!ObjectUtils.isEmpty(this.${formitem.getName()?lower_case})){
<#if formitem.getValueOp() == "LIKE">
Pattern pattern = Pattern.compile("^.*" + ${formitem.getName()?lower_case} + ".*$", Pattern.CASE_INSENSITIVE);
this.getSelectCond().and("${formitem.getPSDEField().getName()?lower_case}").regex(pattern);
<#elseif formitem.getValueOp() == "LEFTLIKE">
Pattern pattern = Pattern.compile( ${formitem.getName()?lower_case} + ".*$", Pattern.CASE_INSENSITIVE);
this.getSelectCond().and("${formitem.getPSDEField().getName()?lower_case}").regex(pattern);
<#elseif formitem.getValueOp() == "RIGHTLIKE">
Pattern pattern = Pattern.compile("^.*" + ${formitem.getName()?lower_case} + "$", Pattern.CASE_INSENSITIVE);
this.getSelectCond().and("${formitem.getPSDEField().getName()?lower_case}").regex(pattern);
<#elseif formitem.getValueOp() == "EQ">
this.getSelectCond().and("${formitem.getPSDEField().getName()?lower_case}").is(${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "NOTEQ">
this.getSelectCond().and("${formitem.getPSDEField().getName()?lower_case}").notEquals(${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "GT">
this.getSelectCond().and("${formitem.getPSDEField().getName()?lower_case}").greaterThan(${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "GTANDEQ">
this.getSelectCond().and("${formitem.getPSDEField().getName()?lower_case}").greaterThanEquals(${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "LT">
this.getSelectCond().and("${formitem.getPSDEField().getName()?lower_case}").lessThan(${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "LTANDEQ">
this.getSelectCond().and("${formitem.getPSDEField().getName()?lower_case}").lessThanEquals(${formitem.getName()?lower_case});
<#elseif formitem.getValueOp() == "ISNOTNULL">
if(this.${formitem.getName()?lower_case}.toString().equals("1")){
this.getSelectCond().and("${formitem.getPSDEField().getName()?lower_case}").exists(true).and("${formitem.getPSDEField().getName()?lower_case}").notEquals("").and("${formitem.getPSDEField().getName()?lower_case}").notEquals(null);
}
<#elseif formitem.getValueOp() == "ISNULL">
if(this.${formitem.getName()?lower_case}.toString().equals("1")){
this.getSelectCond().and("${formitem.getPSDEField().getName()?lower_case}").exists(null);
}
<#elseif formitem.getValueOp() == "IN">
<#if formitem.getPSCodeListId()??>
<#assign codeListName=getCodeListName(formitem.getPSCodeListId())>
String defaultSeparator=(CodeListBase.getCodeList("${codeListName}")==null)?";":CodeListBase.getCodeList("${codeListName}").getCodeList().getValueseparator();
<#else >
String defaultSeparator=";";
</#if>
this.getSelectCond().and("${formitem.getPSDEField().getName()?lower_case}").in(this.${formitem.getName()?lower_case}.split(defaultSeparator)));
<#elseif formitem.getValueOp() == "NOTIN">
<#if formitem.getPSCodeListId()??>
<#assign codeListName=getCodeListName(formitem.getPSCodeListId())>
String defaultSeparator=(CodeListBase.getCodeList("${codeListName}")==null)?";":CodeListBase.getCodeList("${codeListName}").getCodeList().getValueseparator();
<#else >
String defaultSeparator=";";
</#if>
String defaultSeparator=";";
this.getSelectCond().and("${formitem.getPSDEField().getName()?lower_case}").notIn(this.${formitem.getName()?lower_case}.split(defaultSeparator)));
</#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>
Pattern pattern = Pattern.compile("^.*" + query + ".*$", Pattern.CASE_INSENSITIVE);
this.getSelectCond().or(new BasicDBObject("${defield.name?lower_case}",pattern));
</#if>
</#list>
}
}
}
<#comment>ServiceApi</#comment>
<#elseif de.getStorageMode()==4>
import ${pub.getPKGCodeName()}.util.filter.SearchContextBase;
/**
* ServiceApi数据实体[${item.codeName}] 查询条件对象
*/
@Slf4j
@Data
public class ${item.codeName}SearchContext extends SearchContextBase {
<#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")
@JSONField(format="yyyy-MM-dd HH:mm:ss")
<#elseif defDataType == "DATE">
@JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+8")
@JSONField(format="yyyy-MM-dd")
<#elseif defDataType == "TIME">
@JsonFormat(pattern="HH:mm", timezone="GMT+8")
@JSONField(format="HH:mm")
</#if>
private ${srfjavatype(formitem.getPSDEField().stdDataType)} ${formitem.getName()?lower_case};//[${defield.getLogicName()}]
</#if>
</#list>
</#if>
</#list>
}
<#elseif de.getStorageMode()==0>
import ${pub.getPKGCodeName()}.util.filter.SearchContextBase;
/**
* ServiceApi数据实体[${item.codeName}] 查询条件对象
*/
@Slf4j
@Data
public class ${item.codeName}SearchContext extends SearchContextBase {
<#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")
@JSONField(format="yyyy-MM-dd HH:mm:ss")
<#elseif defDataType == "DATE">
@JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+8")
@JSONField(format="yyyy-MM-dd")
<#elseif defDataType == "TIME">
@JsonFormat(pattern="HH:mm", timezone="GMT+8")
@JSONField(format="HH:mm")
</#if>
private ${srfjavatype(formitem.getPSDEField().stdDataType)} ${formitem.getName()?lower_case};//[${defield.getLogicName()}]
</#if>
</#list>
</#if>
</#list>
}
</#if>
<#ibiztemplate>
TARGET=PSDATAENTITY
</#ibiztemplate>
<#if de.getStorageMode()==1>
package ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().codeName?lower_case}.mapper;
import java.util.List;
import org.apache.ibatis.annotations.*;
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()}.core.${item.getPSSystemModule().codeName?lower_case}.domain.${item.getCodeName()};
import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.filter.${de.codeName}SearchContext;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import java.io.Serializable;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.alibaba.fastjson.JSONObject;
public interface ${item.getCodeName()}Mapper extends BaseMapper<${item.getCodeName()}>{
<#if item.getAllPSDEDataSets()??>
<#list item.getAllPSDEDataSets() as dedataset>
Page<${item.getCodeName()}> search${dedataset.getCodeName()}(IPage page, @Param("srf") ${de.codeName}SearchContext context, @Param("ew") Wrapper<${item.getCodeName()}> wrapper) ;
</#list>
</#if>
<#assign keyfieldCodeName=item.getKeyPSDEField().codeName?lower_case>
@Override
<#if item.isEnableEntityCache()==true>
@Cacheable( value="${item.codeName?lower_case}",key = "'row:'+#p0")
</#if>
${item.getCodeName()} selectById(Serializable id);
@Override
<#if item.isEnableEntityCache()==true>
@CacheEvict( value="${item.codeName?lower_case}",key = "'row:'+#p0.${keyfieldCodeName}")
</#if>
int insert(${item.getCodeName()} entity);
@Override
<#if item.isEnableEntityCache()==true>
@CacheEvict( value="${item.codeName?lower_case}",key = "'row:'+#p0.${keyfieldCodeName}")
</#if>
int updateById(@Param(Constants.ENTITY) ${item.getCodeName()} entity);
@Override
<#if item.isEnableEntityCache()==true>
@CacheEvict( value="${item.codeName?lower_case}",key = "'row:'+#p0")
</#if>
int deleteById(Serializable id);
/**
* 自定义查询SQL
* @param sql
* @return
*/
@Select("${r'${sql}'}")
List<JSONObject> selectBySQL(@Param("sql") String sql);
/**
* 自定义更新SQL
* @param sql
* @return
*/
@Update("${r'${sql}'}")
boolean updateBySQL(@Param("sql") String sql);
/**
* 自定义插入SQL
* @param sql
* @return
*/
@Insert("${r'${sql}'}")
boolean insertBySQL(@Param("sql") String sql);
/**
* 自定义删除SQL
* @param sql
* @return
*/
@Delete("${r'${sql}'}")
boolean deleteBySQL(@Param("sql") String sql);
<#comment>1N关系中,在子实体中创建父实体的实例对象</#comment>
<#if de.getMinorPSDERs?? && de.getMinorPSDERs()??>
<#list de.getMinorPSDERs() as MinorPSDER>
<#if MinorPSDER?? && MinorPSDER.getDERType()=='DER1N'>
<#if MinorPSDER.getMajorPSDataEntity?? && MinorPSDER.getMajorPSDataEntity()??>
<#assign MajorEntity = MinorPSDER.getMajorPSDataEntity()>
<#if MajorEntity.name?? && MinorPSDER.getCodeName()?? >
<#if MinorPSDER.getPSPickupDEField?? && MinorPSDER.getPSPickupDEField()??>
<#assign MajorkeyField = MajorEntity.getKeyPSDEField()>
<#assign MajorField = MinorPSDER.getPSPickupDEField()>
<#if de.getDefaultPSDEDataSet()??>
<#assign deDefaultDataSet=de.getDefaultPSDEDataSet()>
<#if deDefaultDataSet.getPSDEDataQueries()??>
List<${item.getCodeName()}> selectBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(@Param("${MajorkeyField.codeName?lower_case}") Serializable ${MajorkeyField.codeName?lower_case}) ;
</#if>
</#if>
</#if>
</#if>
</#if>
</#if>
</#list>
</#if>
}
</#if>
\ No newline at end of file
<#ibiztemplate>
TARGET=PSDATAENTITY
</#ibiztemplate>
<#comment>数据存储为NoSQL</#comment>
<#if de.getStorageMode()==2>
package ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().codeName?lower_case}.repository;
import org.springframework.data.mongodb.repository.MongoRepository;
import ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.domain.${item.getCodeName()};
import org.springframework.stereotype.Repository;
@Repository
public interface ${de.codeName}Repository extends MongoRepository<${de.codeName}, String>{
}
</#if>
<#ibiztemplate>
TARGET=PSDATAENTITY
</#ibiztemplate>
<#if de.getStorageMode()==1 || de.getStorageMode()==2 ||de.getStorageMode()==4||de.getStorageMode()==0>
package ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.service;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.math.BigInteger;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import com.alibaba.fastjson.JSONObject;
import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.domain.${de.getCodeName()};
import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.filter.${de.getCodeName()}SearchContext;
<#comment>SQL存储-Mybatis</#comment>
<#if de.getStorageMode()==1>
import com.baomidou.mybatisplus.extension.service.IService;
/**
* 实体[${item.codeName}] 服务对象接口
*/
public interface I${item.codeName}Service extends IService<${item.codeName}>{
<@addIDESerivceBody />
List<JSONObject> select(String sql);
boolean execute(String sql);
}
<#comment>NoSQL存储-MongoDB</#comment>
<#elseif de.getStorageMode()==2>
/**
* 实体[${item.codeName}] 服务对象接口
*/
public interface I${item.codeName}Service{
<@addIDESerivceBody />
}
<#elseif de.getStorageMode()==4>
/**
* 实体[${item.codeName}] 服务对象接口
*/
public interface I${item.codeName}Service{
<@addIDESerivceBody />
}
<#elseif de.getStorageMode()==0>
/**
* 实体[${item.codeName}] 服务对象接口
*/
public interface I${item.codeName}Service{
<@addIDESerivceBody />
}
</#if>
<#macro addIDESerivceBody >
<#comment>实体接口主体内容</#comment>
<#assign keyfield=item.getKeyPSDEField()>
<#if item.getAllPSDEActions()??>
<#list item.getAllPSDEActions() as deaction>
<#if deaction.isEnableBackend()>
<#if (deaction.getActionType()=='USERCUSTOM') >
${item.codeName} ${srfmethodname(deaction.getCodeName())}(${item.codeName} et) ;
<#elseif deaction.getActionType()=='DELOGIC'>
${item.codeName} ${srfmethodname(deaction.getCodeName())}(${item.codeName} et) ;
<#elseif deaction.codeName?lower_case == 'get'>
${item.codeName} get(${srfjavatype(keyfield.stdDataType)} key) ;
<#elseif deaction.codeName?lower_case == "create">
boolean create(${item.codeName} et) ;
void createBatch(List<${item.codeName}> list) ;
<#elseif deaction.codeName?lower_case == "update">
boolean update(${item.codeName} et) ;
void updateBatch(List<${item.codeName}> list) ;
<#elseif deaction.codeName?lower_case == "remove">
boolean remove(${srfjavatype(keyfield.stdDataType)} key) ;
void removeBatch(Collection<${srfjavatype(keyfield.stdDataType)}> idList) ;
<#elseif deaction.codeName?lower_case == "save">
boolean save(${item.codeName} et) ;
void saveBatch(List<${item.codeName}> list) ;
<#elseif deaction.codeName?lower_case == "getdraft">
${item.codeName} getDraft(${item.codeName} et) ;
<#elseif deaction.codeName?lower_case == "checkkey">
boolean checkKey(${item.codeName} et) ;
<#elseif deaction.codeName?lower_case == "createbatch">
<#elseif deaction.codeName?lower_case == "savebatch">
<#elseif deaction.codeName?lower_case == "updatebatch">
<#elseif deaction.codeName?lower_case == "removebatch">
<#else>
${item.codeName} ${srfmethodname(deaction.getCodeName())}(${item.codeName} et) ;
</#if>
</#if>
</#list>
</#if>
<#if item.getAllPSDEDataSets()??>
<#list item.getAllPSDEDataSets() as dedataset>
Page<${item.codeName}> search${dedataset.getCodeName()}(${item.codeName}SearchContext context) ;
</#list>
</#if>
<#comment>1N关系中,在子实体中创建父实体的实例对象</#comment>
<#if de.getMinorPSDERs?? && de.getMinorPSDERs()??>
<#list de.getMinorPSDERs() as MinorPSDER>
<#if MinorPSDER?? && MinorPSDER.getDERType()=='DER1N'>
<#if MinorPSDER.getMajorPSDataEntity?? && MinorPSDER.getMajorPSDataEntity()??>
<#assign MajorEntity = MinorPSDER.getMajorPSDataEntity()>
<#if MajorEntity.name?? && MinorPSDER.getCodeName()?? >
<#if MinorPSDER.getPSPickupDEField?? && MinorPSDER.getPSPickupDEField()??>
<#assign MajorkeyField = MajorEntity.getKeyPSDEField()>
<#assign MajorField = MinorPSDER.getPSPickupDEField()>
<#if de.getDefaultPSDEDataSet()??>
<#assign deDefaultDataSet=de.getDefaultPSDEDataSet()>
<#if deDefaultDataSet.getPSDEDataQueries()??>
List<${item.getCodeName()}> selectBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfjavatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case}) ;
void removeBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfjavatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case}) ;
<#assign nested=MinorPSDER.isNestedRS()>
<#if nested == false && MinorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list MinorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
void saveBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfjavatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case},List<${item.getCodeName()}> list) ;
</#if>
</#if>
</#if>
</#if>
</#if>
</#if>
</#if>
</#list>
</#if>
</#macro>
</#if>
\ No newline at end of file
<#ibiztemplate>
TARGET=PSDATAENTITY
</#ibiztemplate>
<#if de.getStorageMode()==1 || de.getStorageMode()==2 ||de.getStorageMode()==4||de.getStorageMode()==0>
package ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.service.impl;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.ObjectUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Lazy;
import ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.domain.${de.getCodeName()};
import ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.filter.${de.getCodeName()}SearchContext;
import ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.service.I${de.getCodeName()}Service;
import ${pub.getPKGCodeName()}.util.helper.CachedBeanCopier;
<#if item.getAllPSDELogics()??>
<#list item.getAllPSDELogics() as logic>
//import ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.service.logic.I${de.getCodeName()}${logic.getCodeName()}Logic;
</#list>
</#if>
<#comment>SQL存储-Mybatis</#comment>
<#if de.getStorageMode()==1>
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.mapper.${item.getCodeName()}Mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.alibaba.fastjson.JSONObject;
/**
* 实体[${item.getLogicName()}] 服务对象接口实现
*/
@Slf4j
@Service
public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeName()}Mapper, ${de.getCodeName()}> implements I${de.getCodeName()}Service {
<#assign keyfield=de.getKeyPSDEField()>
<#comment>引入关联依赖</#comment>
<#if de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as der>
<#if der.getDERType() =='DER1N' && (der.getMinorPSDataEntity().getStorageMode()==1||der.getMinorPSDataEntity().getStorageMode()==2||der.getMinorPSDataEntity().getStorageMode()==4)>
<#if !P.exists('DEMinorPSDataEntity',der.getMinorPSDataEntity().getCodeName())>
@Autowired
@Lazy
private ${pub.getPKGCodeName()}.core.${der.getMinorPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.service.I${der.getMinorPSDataEntity().getCodeName()}Service ${srfcaseformat(der.getMinorPSDataEntity().getCodeName(),'l_u2lC')}Service;
</#if>
</#if>
</#list>
</#if>
private int batchSize = 500;
<#comment>输出实体行为</#comment>
<#if item.getAllPSDEActions()??>
<#list item.getAllPSDEActions() as deaction>
<#if deaction.isEnableBackend()>
<#if deaction.getRender()??>
${deaction.getRender().code}
<#else>
<#if (deaction.getActionType()=='USERCUSTOM')>
@Override
@Transactional
public ${item.getCodeName()} ${srfmethodname(deaction.getCodeName())}(${item.getCodeName()} et) {
<#comment>附加数据逻辑-操作前</#comment>
<@addBoforeLogic deaction/>
//自定义代码
<#comment>附加数据逻辑-操作后</#comment>
<@addAfterLogic deaction/>
return et;
}
<#elseif deaction.getActionType()=='DELOGIC'>
@Override
@Transactional
public ${item.getCodeName()} ${srfmethodname(deaction.getCodeName())}(${item.getCodeName()} et) {
//${deaction.getPSDELogic().getCodeName()?lower_case}Logic.execute(et);
return et ;
}
<#elseif deaction.getCodeName()?lower_case == 'get'>
@Override
@Transactional
public ${item.getCodeName()} get(${srfjavatype(keyfield.stdDataType)} key) {
${item.getCodeName()} et = getById(key);
if(et==null){
et=new ${item.getCodeName()}();
et.set${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(key);
}
else{
<#comment>1N关系中,在父实体中创建子实体的List集合</#comment>
<#if de.getMajorPSDERs?? && de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as MajorPSDER>
<#if MajorPSDER??>
<#if MajorPSDER.getMinorPSDataEntity?? && MajorPSDER.getMinorPSDataEntity()?? && MajorPSDER.getDERType()=='DER1N' && (MajorPSDER.getMinorPSDataEntity().getStorageMode()==1||MajorPSDER.getMinorPSDataEntity().getStorageMode()==2||MajorPSDER.getMinorPSDataEntity().getStorageMode()==4)>
<#assign MinorEntity = MajorPSDER.getMinorPSDataEntity()>
<#assign MajorDerField = MajorPSDER.getPSPickupDEField()>
<#assign listcode=(MajorPSDER.getMinorCodeName()!MajorPSDER.getMinorPSDataEntity().getCodeName())>
<#if listcode?? && listcode==''><#assign listcode=MajorPSDER.getMinorPSDataEntity().getCodeName()></#if>
<#assign nested=MajorPSDER.isNestedRS()>
<#if nested == false && MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
et.set${srfcaseformat(listcode,'l_u2lC')?cap_first}(${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.selectBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(key));
</#if>
</#if>
</#if>
</#list>
</#if>
}
return et;
}
<#elseif deaction.getCodeName()?lower_case == "createbatch">
<#elseif deaction.getCodeName()?lower_case == "updatebatch">
<#elseif deaction.getCodeName()?lower_case == "removebatch">
<#elseif deaction.getCodeName()?lower_case == "savebatch">
<#elseif deaction.getCodeName()?lower_case == "create">
@Override
@Transactional
public boolean create(${item.getCodeName()} et) {
<#comment>附加数据逻辑-操作前</#comment>
<@addBoforeLogic deaction/>
if(!this.retBool(this.baseMapper.insert(et)))
return false;
<#comment>1N关系中,在父实体中创建子实体的List集合</#comment>
<#if de.getMajorPSDERs?? && de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as MajorPSDER>
<#if MajorPSDER??>
<#if MajorPSDER.getMinorPSDataEntity?? && MajorPSDER.getMinorPSDataEntity()?? && MajorPSDER.getDERType()=='DER1N' && (MajorPSDER.getMinorPSDataEntity().getStorageMode()==1||MajorPSDER.getMinorPSDataEntity().getStorageMode()==2||MajorPSDER.getMinorPSDataEntity().getStorageMode()==4)>
<#assign MinorEntity = MajorPSDER.getMinorPSDataEntity()>
<#assign MajorDerField = MajorPSDER.getPSPickupDEField()>
<#assign listcode=(MajorPSDER.getMinorCodeName()!MajorPSDER.getMinorPSDataEntity().getCodeName())>
<#if listcode?? && listcode==''><#assign listcode=MajorPSDER.getMinorPSDataEntity().getCodeName()></#if>
<#assign nested=MajorPSDER.isNestedRS()>
<#if nested == false && MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(),et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>成功后get填充一次完整信息</#comment>
CachedBeanCopier.copy(get(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()),et);
<#comment>附加数据逻辑-操作后</#comment>
<@addAfterLogic deaction/>
return true;
}
@Override
public void createBatch(List<${item.getCodeName()}> list) {
saveBatch(list,batchSize);
}
<#elseif deaction.getCodeName()?lower_case == "update">
@Override
@Transactional
public boolean update(${item.getCodeName()} et) {
<#comment>附加数据逻辑-操作前</#comment>
<@addBoforeLogic deaction/>
<#if de.getKeyPSDEField()??>
if(!update(et,(Wrapper) et.getUpdateWrapper(true).eq("${keyfield.name?lower_case}",et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}())))
return false;
<#comment>1N关系中,在父实体中创建子实体的List集合</#comment>
<#if de.getMajorPSDERs?? && de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as MajorPSDER>
<#if MajorPSDER??>
<#if MajorPSDER.getMinorPSDataEntity?? && MajorPSDER.getMinorPSDataEntity()?? && MajorPSDER.getDERType()=='DER1N' && (MajorPSDER.getMinorPSDataEntity().getStorageMode()==1||MajorPSDER.getMinorPSDataEntity().getStorageMode()==2||MajorPSDER.getMinorPSDataEntity().getStorageMode()==4)>
<#assign MinorEntity = MajorPSDER.getMinorPSDataEntity()>
<#assign MajorDerField = MajorPSDER.getPSPickupDEField()>
<#assign listcode=(MajorPSDER.getMinorCodeName()!MajorPSDER.getMinorPSDataEntity().getCodeName())>
<#if listcode?? && listcode==''><#assign listcode=MajorPSDER.getMinorPSDataEntity().getCodeName()></#if>
<#assign nested=MajorPSDER.isNestedRS()>
<#if nested == false && MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(),et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>成功后get填充一次完整信息</#comment>
CachedBeanCopier.copy(get(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()),et);
<#comment>附加数据逻辑-操作后</#comment>
<@addAfterLogic deaction/>
return true;
<#else>
throw new RuntimeException("请检查[${de.getLogicName()}]实体是否存在主键属性");
</#if>
}
@Override
public void updateBatch(List<${item.getCodeName()}> list) {
updateBatchById(list,batchSize);
}
<#elseif deaction.getCodeName()?lower_case == "save">
@Override
@Transactional
public boolean save(${item.getCodeName()} et) {
<#comment>附加数据逻辑-操作前</#comment>
<@addBoforeLogic deaction/>
if(!saveOrUpdate(et))
return false;
<#comment>附加数据逻辑-操作后</#comment>
<@addAfterLogic deaction/>
return true;
}
@Override
@Transactional(
rollbackFor = {Exception.class}
)
public boolean saveOrUpdate(${item.getCodeName()} et) {
if (null == et) {
return false;
} else {
return checkKey(et) ? this.update(et) : this.create(et);
}
}
@Override
public void saveBatch(List<${item.getCodeName()}> list) {
saveOrUpdateBatch(list,batchSize);
}
<#elseif deaction.getCodeName()?lower_case == "remove">
@Override
@Transactional
public boolean remove(${srfjavatype(keyfield.stdDataType)} key) {
<#comment>附加数据逻辑-操作前</#comment>
<@addBoforeLogic deaction/>
<#if de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as der>
<#if der.getDERType() =='DER1N' && der.isNestedRS() && der.getMinorPSDataEntity()?? && (der.getMinorPSDataEntity().getStorageMode()==1||der.getMinorPSDataEntity().getStorageMode()==2||der.getMinorPSDataEntity().getStorageMode()==4) >
<#assign MajorDerField = der.getPSPickupDEField()>
<#assign minorKeyField = der.getMinorPSDataEntity().getKeyPSDEField()>
${srfcaseformat(der.getMinorPSDataEntity().getCodeName(),'l_u2lC')}Service.removeBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(key) ;
</#if>
</#list>
</#if>
if(!removeById(key)) return false;
<#comment>附加数据逻辑-操作后</#comment>
<@addAfterLogic deaction/>
return true ;
}
@Override
public void removeBatch(Collection<${srfjavatype(keyfield.stdDataType)}> idList) {
removeByIds(idList);
}
<#elseif deaction.getCodeName()?lower_case == "getdraft">
@Override
public ${item.getCodeName()} getDraft(${item.getCodeName()} et) {
return et;
}
<#elseif deaction.getCodeName()?lower_case == "checkkey">
@Override
public boolean checkKey(${item.getCodeName()} et) {
return (!ObjectUtils.isEmpty(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()))&&(!Objects.isNull(this.getById(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}())));
}
<#else>
@Override
@Transactional
public ${item.getCodeName()} ${srfmethodname(deaction.getCodeName())}(${item.getCodeName()} et) {
//自定义代码
return et;
}
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>1N关系中,在子实体中创建父实体的实例对象</#comment>
<#if de.getMinorPSDERs?? && de.getMinorPSDERs()??>
<#list de.getMinorPSDERs() as MinorPSDER>
<#if MinorPSDER?? && MinorPSDER.getDERType()=='DER1N'>
<#if MinorPSDER.getMajorPSDataEntity?? && MinorPSDER.getMajorPSDataEntity()??>
<#assign MajorEntity = MinorPSDER.getMajorPSDataEntity()>
<#if MajorEntity.name?? && MinorPSDER.getCodeName()?? >
<#if MinorPSDER.getPSPickupDEField?? && MinorPSDER.getPSPickupDEField()??>
<#assign MajorkeyField = MajorEntity.getKeyPSDEField()>
<#assign MajorField = MinorPSDER.getPSPickupDEField()>
<#if de.getDefaultPSDEDataSet()??>
<#assign deDefaultDataSet=de.getDefaultPSDEDataSet()>
<#if deDefaultDataSet.getPSDEDataQueries()??>
@Override
public List<${item.getCodeName()}> selectBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfjavatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case}) {
return baseMapper.selectBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${MajorkeyField.codeName?lower_case});
}
@Override
public void removeBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfjavatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case}) {
this.remove(new QueryWrapper<${item.getCodeName()}>().eq("${MajorField.getName()?lower_case}",${MajorkeyField.codeName?lower_case}));
}
<#assign nested=MinorPSDER.isNestedRS()>
<#if nested == false && MinorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list MinorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
@Override
public void saveBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfjavatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case},List<${item.getCodeName()}> list) {
if(list==null)
return;
Set<${srfjavatype(keyfield.stdDataType)}> delIds=new HashSet<${srfjavatype(keyfield.stdDataType)}>();
List<${item.getCodeName()}> _update=new ArrayList<${item.getCodeName()}>();
List<${item.getCodeName()}> _create=new ArrayList<${item.getCodeName()}>();
for(${item.getCodeName()} before:selectBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${MajorkeyField.codeName?lower_case})){
delIds.add(before.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}());
}
for(${item.getCodeName()} sub:list) {
sub.set${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${MajorkeyField.codeName?lower_case});
if(ObjectUtils.isEmpty(sub.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}()))
sub.set${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}((${srfjavatype(keyfield.stdDataType)})sub.getDefaultKey(true));
if(delIds.contains(sub.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}())) {
delIds.remove(sub.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}());
_update.add(sub);
}
else
_create.add(sub);
}
if(_update.size()>0)
this.updateBatch(_update);
if(_create.size()>0)
this.createBatch(_create);
if(delIds.size()>0)
this.removeBatch(delIds);
}
</#if>
</#if>
</#if>
</#if>
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>输出数据查询</#comment>
<#if item.getAllPSDEDataSets()??>
<#list item.getAllPSDEDataSets() as dedataset>
/**
* 查询集合 ${dedataset.getLogicName()}
*/
@Override
public Page<${item.getCodeName()}> search${dedataset.getCodeName()}(${item.getCodeName()}SearchContext context) {
<#if item.isEnableSQLStorage() && item.getAllPSDEDBTables()??>
<#--<#list item.getAllPSDEDBTables() as detable>-->
com.baomidou.mybatisplus.extension.plugins.pagination.Page<${de.getCodeName()}> pages=baseMapper.search${dedataset.getCodeName()}(context.getPages(),context,context.getSelectCond());
return new PageImpl<${item.getCodeName()}>(pages.getRecords(), context.getPageable(), pages.getTotal());
<#--</#list>-->
<#else>
return null ;
</#if>
}
</#list>
</#if>
<#comment>输出自定义sql查询</#comment>
@Override
public List<JSONObject> select(String sql){
return this.baseMapper.selectBySQL(sql);
}
@Override
@Transactional
public boolean execute(String sql){
if (sql == null || sql.isEmpty()) {
return false;
}
if (sql.toLowerCase().trim().startsWith("insert")) {
return this.baseMapper.insertBySQL(sql);
}
if (sql.toLowerCase().trim().startsWith("update")) {
return this.baseMapper.updateBySQL(sql);
}
if (sql.toLowerCase().trim().startsWith("delete")) {
return this.baseMapper.deleteBySQL(sql);
}
log.warn("暂未支持的SQL语法");
return true;
}
}
<#comment>NOSQL存储</#comment>
<#elseif de.getStorageMode()==2>
import ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().codeName?lower_case}.repository.${de.codeName}Repository;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.BasicQuery;
import org.springframework.data.mongodb.core.query.Query;
import javax.annotation.Resource;
/**
* 实体[${item.getLogicName()}] 服务对象接口实现
*/
@Slf4j
@Service
public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Service {
@Autowired
private ${item.getCodeName()}Repository repository;
<#assign keyfield=de.getKeyPSDEField()>
<#comment>引入关联依赖</#comment>
<#if de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as der>
<#if der.getDERType() =='DER1N' && (der.getMinorPSDataEntity().getStorageMode()==1||der.getMinorPSDataEntity().getStorageMode()==2||der.getMinorPSDataEntity().getStorageMode()==4)>
<#if !P.exists('DEMinorPSDataEntity',der.getMinorPSDataEntity().getCodeName())>
@Autowired
@Lazy
private ${pub.getPKGCodeName()}.core.${der.getMinorPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.service.I${der.getMinorPSDataEntity().getCodeName()}Service ${srfcaseformat(der.getMinorPSDataEntity().getCodeName(),'l_u2lC')}Service;
</#if>
</#if>
</#list>
</#if>
<#comment>输出实体行为</#comment>
<#if item.getAllPSDEActions()??>
<#list item.getAllPSDEActions() as deaction>
<#if deaction.isEnableBackend()>
<#if deaction.getRender()??>
${deaction.getRender().code}
<#else>
<#if (deaction.getActionType()=='USERCUSTOM')>
@Override
@Transactional
public ${item.getCodeName()} ${srfmethodname(deaction.getCodeName())}(${item.getCodeName()} et) {
<#comment>附加数据逻辑-操作前</#comment>
<@addBoforeLogic deaction/>
//自定义代码
<#comment>附加数据逻辑-操作后</#comment>
<@addAfterLogic deaction/>
return et;
}
<#elseif deaction.getActionType()=='DELOGIC'>
@Override
@Transactional
public ${item.getCodeName()} ${srfmethodname(deaction.getCodeName())}(${item.getCodeName()} et) {
//${deaction.getPSDELogic().getCodeName()?lower_case}Logic.execute(et);
return et ;
}
<#elseif deaction.getCodeName()?lower_case == 'get'>
@Override
@Transactional
public ${item.getCodeName()} get(${srfjavatype(keyfield.stdDataType)} key) {
Optional<${item.getCodeName()}> result = repository.findById(key);
if(!result.isPresent()){
${item.getCodeName()} et=new ${item.getCodeName()}();
et.set${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(key);
return et;
}
else{
${item.getCodeName()} et=result.get();
<#comment>1N关系中,在父实体中创建子实体的List集合</#comment>
<#if de.getMajorPSDERs?? && de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as MajorPSDER>
<#if MajorPSDER??>
<#if MajorPSDER.getMinorPSDataEntity?? && MajorPSDER.getMinorPSDataEntity()?? && MajorPSDER.getDERType()=='DER1N' && (MajorPSDER.getMinorPSDataEntity().getStorageMode()==1||MajorPSDER.getMinorPSDataEntity().getStorageMode()==2||MajorPSDER.getMinorPSDataEntity().getStorageMode()==4)>
<#assign MinorEntity = MajorPSDER.getMinorPSDataEntity()>
<#assign MajorDerField = MajorPSDER.getPSPickupDEField()>
<#assign listcode=(MajorPSDER.getMinorCodeName()!MajorPSDER.getMinorPSDataEntity().getCodeName())>
<#if listcode?? && listcode==''><#assign listcode=MajorPSDER.getMinorPSDataEntity().getCodeName()></#if>
<#assign nested=MajorPSDER.isNestedRS()>
<#if nested == false && MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
et.set${srfcaseformat(listcode,'l_u2lC')?cap_first}(${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.selectBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(key));
</#if>
</#if>
</#if>
</#list>
</#if>
return result.get();
}
}
<#elseif deaction.getCodeName()?lower_case == "createbatch">
<#elseif deaction.getCodeName()?lower_case == "updatebatch">
<#elseif deaction.getCodeName()?lower_case == "removebatch">
<#elseif deaction.getCodeName()?lower_case == "savebatch">
<#elseif deaction.getCodeName()?lower_case == "create">
@Override
@Transactional
public boolean create(${item.getCodeName()} et) {
<#comment>附加数据逻辑-操作前</#comment>
<@addBoforeLogic deaction/>
repository.insert(et);
<#comment>1N关系中,在父实体中创建子实体的List集合</#comment>
<#if de.getMajorPSDERs?? && de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as MajorPSDER>
<#if MajorPSDER??>
<#if MajorPSDER.getMinorPSDataEntity?? && MajorPSDER.getMinorPSDataEntity()?? && MajorPSDER.getDERType()=='DER1N' && (MajorPSDER.getMinorPSDataEntity().getStorageMode()==1||MajorPSDER.getMinorPSDataEntity().getStorageMode()==2||MajorPSDER.getMinorPSDataEntity().getStorageMode()==4)>
<#assign MinorEntity = MajorPSDER.getMinorPSDataEntity()>
<#assign MajorDerField = MajorPSDER.getPSPickupDEField()>
<#assign listcode=(MajorPSDER.getMinorCodeName()!MajorPSDER.getMinorPSDataEntity().getCodeName())>
<#if listcode?? && listcode==''><#assign listcode=MajorPSDER.getMinorPSDataEntity().getCodeName()></#if>
<#assign nested=MajorPSDER.isNestedRS()>
<#if nested == false && MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(),et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>成功后get填充一次完整信息</#comment>
CachedBeanCopier.copy(get(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()),et);
<#comment>附加数据逻辑-操作后</#comment>
<@addAfterLogic deaction/>
return true ;
}
@Override
public void createBatch(List<${item.getCodeName()}> list) {
repository.insert(list);
}
<#elseif deaction.getCodeName()?lower_case == "update">
@Override
@Transactional
public boolean update(${item.getCodeName()} et) {
<#comment>附加数据逻辑-操作前</#comment>
<@addBoforeLogic deaction/>
<#if de.getKeyPSDEField()??>
repository.save(et);
<#comment>1N关系中,在父实体中创建子实体的List集合</#comment>
<#if de.getMajorPSDERs?? && de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as MajorPSDER>
<#if MajorPSDER??>
<#if MajorPSDER.getMinorPSDataEntity?? && MajorPSDER.getMinorPSDataEntity()?? && MajorPSDER.getDERType()=='DER1N' && (MajorPSDER.getMinorPSDataEntity().getStorageMode()==1||MajorPSDER.getMinorPSDataEntity().getStorageMode()==2||MajorPSDER.getMinorPSDataEntity().getStorageMode()==4)>
<#assign MinorEntity = MajorPSDER.getMinorPSDataEntity()>
<#assign MajorDerField = MajorPSDER.getPSPickupDEField()>
<#assign listcode=(MajorPSDER.getMinorCodeName()!MajorPSDER.getMinorPSDataEntity().getCodeName())>
<#if listcode?? && listcode==''><#assign listcode=MajorPSDER.getMinorPSDataEntity().getCodeName()></#if>
<#assign nested=MajorPSDER.isNestedRS()>
<#if nested == false && MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(),et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>成功后get填充一次完整信息</#comment>
CachedBeanCopier.copy(get(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()),et);
<#comment>附加数据逻辑-操作后</#comment>
<@addAfterLogic deaction/>
return true ;
<#else>
throw new RuntimeException("请检查[${de.getLogicName()}]实体是否存在主键属性");
</#if>
}
@Override
public void updateBatch(List<${item.getCodeName()}> list) {
repository.saveAll(list);
}
<#elseif deaction.getCodeName()?lower_case == "save">
@Override
@Transactional
public boolean save(${item.getCodeName()} et) {
<#comment>附加数据逻辑-操作前</#comment>
<@addBoforeLogic deaction/>
<#if de.getKeyPSDEField()??>
repository.save(et);
<#comment>1N关系中,在父实体中创建子实体的List集合</#comment>
<#if de.getMajorPSDERs?? && de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as MajorPSDER>
<#if MajorPSDER??>
<#if MajorPSDER.getMinorPSDataEntity?? && MajorPSDER.getMinorPSDataEntity()?? && MajorPSDER.getDERType()=='DER1N' && (MajorPSDER.getMinorPSDataEntity().getStorageMode()==1||MajorPSDER.getMinorPSDataEntity().getStorageMode()==2||MajorPSDER.getMinorPSDataEntity().getStorageMode()==4)>
<#assign MinorEntity = MajorPSDER.getMinorPSDataEntity()>
<#assign MajorDerField = MajorPSDER.getPSPickupDEField()>
<#assign listcode=(MajorPSDER.getMinorCodeName()!MajorPSDER.getMinorPSDataEntity().getCodeName())>
<#if listcode?? && listcode==''><#assign listcode=MajorPSDER.getMinorPSDataEntity().getCodeName()></#if>
<#assign nested=MajorPSDER.isNestedRS()>
<#if nested == false && MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(),et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>成功后get填充一次完整信息</#comment>
CachedBeanCopier.copy(get(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()),et);
<#comment>附加数据逻辑-操作后</#comment>
<@addAfterLogic deaction/>
return true ;
<#else>
throw new RuntimeException("请检查[${de.getLogicName()}]实体是否存在主键属性");
</#if>
}
@Override
public void saveBatch(List<${item.getCodeName()}> list) {
repository.saveAll(list);
}
<#elseif deaction.getCodeName()?lower_case == "remove">
@Override
@Transactional
public boolean remove(${srfjavatype(keyfield.stdDataType)} key) {
<#comment>附加数据逻辑-操作前</#comment>
<@addBoforeLogic deaction/>
<#if de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as der>
<#if der.getDERType() =='DER1N' && der.isNestedRS() && der.getMinorPSDataEntity()?? && (der.getMinorPSDataEntity().getStorageMode()==1||der.getMinorPSDataEntity().getStorageMode()==2||der.getMinorPSDataEntity().getStorageMode()==4) >
<#assign MajorDerField = der.getPSPickupDEField()>
<#assign minorKeyField = der.getMinorPSDataEntity().getKeyPSDEField()>
${srfcaseformat(der.getMinorPSDataEntity().getCodeName(),'l_u2lC')}Service.removeBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(key) ;
</#if>
</#list>
</#if>
repository.deleteById(key);
<#comment>附加数据逻辑-操作后</#comment>
<@addAfterLogic deaction/>
return true ;
}
@Override
public void removeBatch(Collection<${srfjavatype(keyfield.stdDataType)}> idList) {
repository.deleteAll(repository.findAllById(idList));
}
<#elseif deaction.getCodeName()?lower_case == "getdraft">
@Override
public ${item.getCodeName()} getDraft(${item.getCodeName()} et) {
return et;
}
<#elseif deaction.getCodeName()?lower_case == "checkkey">
@Override
public boolean checkKey(${item.getCodeName()} et) {
return repository.findById(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()).isPresent();
}
<#else>
@Override
@Transactional
public ${item.getCodeName()} ${srfmethodname(deaction.getCodeName())}(${item.getCodeName()} et) {
//自定义代码
return et;
}
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>1N关系中,在子实体中创建父实体的实例对象</#comment>
<#if de.getMinorPSDERs?? && de.getMinorPSDERs()??>
<#list de.getMinorPSDERs() as MinorPSDER>
<#if MinorPSDER?? && MinorPSDER.getDERType()=='DER1N'>
<#if MinorPSDER.getMajorPSDataEntity?? && MinorPSDER.getMajorPSDataEntity()??>
<#assign MajorEntity = MinorPSDER.getMajorPSDataEntity()>
<#if MajorEntity.name?? && MinorPSDER.getCodeName()?? >
<#if MinorPSDER.getPSPickupDEField?? && MinorPSDER.getPSPickupDEField()??>
<#assign MajorkeyField = MajorEntity.getKeyPSDEField()>
<#assign MajorField = MinorPSDER.getPSPickupDEField()>
<#if de.getDefaultPSDEDataSet()??>
<#assign deDefaultDataSet=de.getDefaultPSDEDataSet()>
<#if deDefaultDataSet.getPSDEDataQueries()??>
@Override
public List<${item.getCodeName()}> selectBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfjavatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case}) {
${item.getCodeName()}SearchContext context=new ${item.getCodeName()}SearchContext();
context.setN_${MajorField.name?lower_case}_eq(${MajorkeyField.codeName?lower_case});
Query query = new BasicQuery(context.getSelectCond().get().toString());
return mongoTemplate.find(query,${item.getCodeName()}.class);
}
@Override
public void removeBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfjavatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case}) {
Set<${srfjavatype(keyfield.stdDataType)}> delIds=new HashSet<${srfjavatype(keyfield.stdDataType)}>();
for(${item.getCodeName()} before:selectBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${MajorkeyField.codeName?lower_case})){
delIds.add(before.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}());
}
if(delIds.size()>0)
this.removeBatch(delIds);
}
<#assign nested=MinorPSDER.isNestedRS()>
<#if nested == false && MinorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list MinorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
@Override
public void saveBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfjavatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case},List<${item.getCodeName()}> list) {
if(list==null)
return;
Set<${srfjavatype(keyfield.stdDataType)}> delIds=new HashSet<${srfjavatype(keyfield.stdDataType)}>();
List<${item.getCodeName()}> _update=new ArrayList<${item.getCodeName()}>();
List<${item.getCodeName()}> _create=new ArrayList<${item.getCodeName()}>();
for(${item.getCodeName()} before:selectBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${MajorkeyField.codeName?lower_case})){
delIds.add(before.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}());
}
for(${item.getCodeName()} sub:list) {
sub.set${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${MajorkeyField.codeName?lower_case});
if(ObjectUtils.isEmpty(sub.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}()))
sub.set${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}((${srfjavatype(keyfield.stdDataType)})sub.getDefaultKey(true));
if(delIds.contains(sub.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}())) {
delIds.remove(sub.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}());
_update.add(sub);
}
else
_create.add(sub);
}
if(_update.size()>0)
this.updateBatch(_update);
if(_create.size()>0)
this.createBatch(_create);
if(delIds.size()>0)
this.removeBatch(delIds);
}
</#if>
</#if>
</#if>
</#if>
</#if>
</#if>
</#if>
</#list>
</#if>
@Resource
private MongoTemplate mongoTemplate;
<#comment>输出数据查询</#comment>
<#if item.getAllPSDEDataSets()??>
<#list item.getAllPSDEDataSets() as dedataset>
/**
* 查询集合 ${dedataset.getLogicName()}
*/
@Override
public Page<${item.getCodeName()}> search${dedataset.getCodeName()}(${item.getCodeName()}SearchContext context) {
Query query = new BasicQuery(context.getSelectCond().get().toString());
long total = mongoTemplate.count(query, ${item.getCodeName()}.class);
List<${item.getCodeName()}> list=mongoTemplate.find(query.with(context.getPageable()),${item.getCodeName()}.class);
return new PageImpl<${item.getCodeName()}>(list,context.getPageable(),total);
}
</#list>
</#if>
}
<#comment>Api存储</#comment>
<#elseif de.getStorageMode()==4>
import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.client.${item.codeName}FeignClient;
/**
* 实体[${item.getLogicName()}] 服务对象接口实现
*/
@Slf4j
@Service
public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Service {
<#comment>引入feignClient</#comment>
@Autowired
${item.codeName}FeignClient ${item.codeName?uncap_first}FeignClient;
<#assign keyfield=de.getKeyPSDEField()>
<#comment>引入关联依赖</#comment>
<#if de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as der>
<#if der.getDERType() =='DER1N' && (der.getMinorPSDataEntity().getStorageMode()==1||der.getMinorPSDataEntity().getStorageMode()==2)>
<#if !P.exists('DEMinorPSDataEntity',der.getMinorPSDataEntity().getCodeName())>
@Autowired
@Lazy
private ${pub.getPKGCodeName()}.core.${der.getMinorPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.service.I${der.getMinorPSDataEntity().getCodeName()}Service ${srfcaseformat(der.getMinorPSDataEntity().getCodeName(),'l_u2lC')}Service;
</#if>
</#if>
</#list>
</#if>
<#comment>输出实体行为</#comment>
<#if item.getAllPSDEActions()??>
<#list item.getAllPSDEActions() as deaction>
<#if deaction.isEnableBackend()>
<#if deaction.getRender()??>
${deaction.getRender().code}
<#else>
<#if (deaction.getActionType()=='USERCUSTOM')>
<#elseif deaction.getActionType()=='DELOGIC'>
<#elseif deaction.getCodeName()?lower_case == 'get'>
@Override
public ${item.getCodeName()} get(${srfjavatype(keyfield.stdDataType)} ${keyfield.getCodeName()?lower_case}) {
<#if item.isEnableAPIStorage()>
<#if deaction.getPSSubSysServiceAPIDEMethod()?? >
${item.getCodeName()} et=${item.codeName?uncap_first}FeignClient.${deaction.getPSSubSysServiceAPIDEMethod().getCodeName()?uncap_first}(${keyfield.getCodeName()?lower_case});
if(et==null){
et=new ${item.getCodeName()}();
et.set${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(${keyfield.getCodeName()?lower_case});
}
else{
<#comment>1N关系中,在父实体中创建子实体的List集合</#comment>
<#if de.getMajorPSDERs?? && de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as MajorPSDER>
<#if MajorPSDER??>
<#if MajorPSDER.getMinorPSDataEntity?? && MajorPSDER.getMinorPSDataEntity()?? && MajorPSDER.getDERType()=='DER1N' && (MajorPSDER.getMinorPSDataEntity().getStorageMode()==1||MajorPSDER.getMinorPSDataEntity().getStorageMode()==2)>
<#assign MinorEntity = MajorPSDER.getMinorPSDataEntity()>
<#assign MajorDerField = MajorPSDER.getPSPickupDEField()>
<#assign listcode=(MajorPSDER.getMinorCodeName()!MajorPSDER.getMinorPSDataEntity().getCodeName())>
<#if listcode?? && listcode==''><#assign listcode=MajorPSDER.getMinorPSDataEntity().getCodeName()></#if>
<#assign nested=MajorPSDER.isNestedRS()>
<#if nested == false && MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
et.set${srfcaseformat(listcode,'l_u2lC')?cap_first}(${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.selectBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(key));
</#if>
</#if>
</#if>
</#list>
</#if>
}
return et;
<#else>
return null;
</#if>
</#if>
}
<#elseif deaction.getCodeName()?lower_case == "createbatch">
<#elseif deaction.getCodeName()?lower_case == "updatebatch">
<#elseif deaction.getCodeName()?lower_case == "removebatch">
<#elseif deaction.getCodeName()?lower_case == "savebatch">
<#elseif deaction.getCodeName()?lower_case == "create">
@Override
public boolean create(${item.getCodeName()} et) {
<#if item.isEnableAPIStorage()>
<#if deaction.getPSSubSysServiceAPIDEMethod()?? >
${item.getCodeName()} rt = ${item.codeName?uncap_first}FeignClient.create(et);
if(rt==null)
return false;
<#comment>1N关系中,在父实体中创建子实体的List集合</#comment>
<#if de.getMajorPSDERs?? && de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as MajorPSDER>
<#if MajorPSDER??>
<#if MajorPSDER.getMinorPSDataEntity?? && MajorPSDER.getMinorPSDataEntity()?? && MajorPSDER.getDERType()=='DER1N' && (MajorPSDER.getMinorPSDataEntity().getStorageMode()==1||MajorPSDER.getMinorPSDataEntity().getStorageMode()==2)>
<#assign MinorEntity = MajorPSDER.getMinorPSDataEntity()>
<#assign MajorDerField = MajorPSDER.getPSPickupDEField()>
<#assign listcode=(MajorPSDER.getMinorCodeName()!MajorPSDER.getMinorPSDataEntity().getCodeName())>
<#if listcode?? && listcode==''><#assign listcode=MajorPSDER.getMinorPSDataEntity().getCodeName()></#if>
<#assign nested=MajorPSDER.isNestedRS()>
<#if nested == false && MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(rt.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(),et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
rt.set${srfcaseformat(listcode,'l_u2lC')?cap_first}(et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
</#if>
</#if>
</#if>
</#list>
</#if>
CachedBeanCopier.copy(rt,et);
return true;
<#else>
return false;
</#if>
<#else>
return false;
</#if>
}
public void createBatch(List<${item.codeName}> list){
<#if item.isEnableAPIStorage()>
<#if deaction.getPSSubSysServiceAPIDEMethod()?? >
${item.codeName?uncap_first}FeignClient.createBatch(list) ;
</#if>
</#if>
}
<#elseif deaction.getCodeName()?lower_case == "update">
@Override
public boolean update(${item.getCodeName()} et) {
<#if item.isEnableAPIStorage()>
<#if deaction.getPSSubSysServiceAPIDEMethod()?? >
${item.getCodeName()} rt = ${item.codeName?uncap_first}FeignClient.update(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(),et);
if(rt==null)
return false;
<#comment>1N关系中,在父实体中创建子实体的List集合</#comment>
<#if de.getMajorPSDERs?? && de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as MajorPSDER>
<#if MajorPSDER??>
<#if MajorPSDER.getMinorPSDataEntity?? && MajorPSDER.getMinorPSDataEntity()?? && MajorPSDER.getDERType()=='DER1N' && (MajorPSDER.getMinorPSDataEntity().getStorageMode()==1||MajorPSDER.getMinorPSDataEntity().getStorageMode()==2)>
<#assign MinorEntity = MajorPSDER.getMinorPSDataEntity()>
<#assign MajorDerField = MajorPSDER.getPSPickupDEField()>
<#assign listcode=(MajorPSDER.getMinorCodeName()!MajorPSDER.getMinorPSDataEntity().getCodeName())>
<#if listcode?? && listcode==''><#assign listcode=MajorPSDER.getMinorPSDataEntity().getCodeName()></#if>
<#assign nested=MajorPSDER.isNestedRS()>
<#if nested == false && MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(),et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}()));
rt.set${srfcaseformat(listcode,'l_u2lC')?cap_first}(et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
</#if>
</#if>
</#if>
</#list>
</#if>
CachedBeanCopier.copy(rt,et);
return true;
<#else>
return false;
</#if>
<#else>
return false;
</#if>
}
public void updateBatch(List<${item.codeName}> list){
<#if item.isEnableAPIStorage()>
<#if deaction.getPSSubSysServiceAPIDEMethod()?? >
${item.codeName?uncap_first}FeignClient.updateBatch(list) ;
</#if>
</#if>
}
<#elseif deaction.getCodeName()?lower_case == "save">
@Override
@Transactional
public boolean save(${item.getCodeName()} et) {
<#if item.isEnableAPIStorage()>
<#if deaction.getPSSubSysServiceAPIDEMethod()?? >
if(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()==null) et.set${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}((${srfjavatype(keyfield.stdDataType)})et.getDefaultKey(true));
if(!${item.codeName?uncap_first}FeignClient.save(et))
return false;
<#comment>1N关系中,在父实体中创建子实体的List集合</#comment>
<#if de.getMajorPSDERs?? && de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as MajorPSDER>
<#if MajorPSDER??>
<#if MajorPSDER.getMinorPSDataEntity?? && MajorPSDER.getMinorPSDataEntity()?? && MajorPSDER.getDERType()=='DER1N' && (MajorPSDER.getMinorPSDataEntity().getStorageMode()==1||MajorPSDER.getMinorPSDataEntity().getStorageMode()==2)>
<#assign MinorEntity = MajorPSDER.getMinorPSDataEntity()>
<#assign MajorDerField = MajorPSDER.getPSPickupDEField()>
<#assign listcode=(MajorPSDER.getMinorCodeName()!MajorPSDER.getMinorPSDataEntity().getCodeName())>
<#if listcode?? && listcode==''><#assign listcode=MajorPSDER.getMinorPSDataEntity().getCodeName()></#if>
<#assign nested=MajorPSDER.isNestedRS()>
<#if nested == false && MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
${srfcaseformat(MinorEntity.getCodeName(),'l_u2lC')}Service.saveBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(),et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
rt.set${srfcaseformat(listcode,'l_u2lC')?cap_first}(et.get${srfcaseformat(listcode,'l_u2lC')?cap_first}());
</#if>
</#if>
</#if>
</#list>
</#if>
return true;
<#else>
return false;
</#if>
<#else>
return false;
</#if>
}
@Override
public void saveBatch(List<${item.getCodeName()}> list) {
<#if item.isEnableAPIStorage()>
<#if deaction.getPSSubSysServiceAPIDEMethod()?? >
${item.codeName?uncap_first}FeignClient.saveBatch(list) ;
</#if>
</#if>
}
<#elseif deaction.getCodeName()?lower_case == "remove">
@Override
public boolean remove(${srfjavatype(keyfield.stdDataType)} ${keyfield.getCodeName()?lower_case}) {
<#if de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as der>
<#if der.getDERType() =='DER1N' && der.isNestedRS() && der.getMinorPSDataEntity()?? && (der.getMinorPSDataEntity().getStorageMode()==1||der.getMinorPSDataEntity().getStorageMode()==2) >
<#assign MajorDerField = der.getPSPickupDEField()>
<#assign minorKeyField = der.getMinorPSDataEntity().getKeyPSDEField()>
${srfcaseformat(der.getMinorPSDataEntity().getCodeName(),'l_u2lC')}Service.removeBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}(key) ;
</#if>
</#list>
</#if>
<#if item.isEnableAPIStorage()>
<#if deaction.getPSSubSysServiceAPIDEMethod()?? >
return ${item.codeName?uncap_first}FeignClient.remove(${keyfield.getCodeName()?lower_case}) ;
<#else>
return false;
</#if>
<#else>
return false;
</#if>
}
public void removeBatch(Collection<${srfjavatype(keyfield.stdDataType)}> idList){
<#if item.isEnableAPIStorage()>
<#if deaction.getPSSubSysServiceAPIDEMethod()?? >
${item.codeName?uncap_first}FeignClient.removeBatch(idList);
</#if>
</#if>
}
<#elseif deaction.getCodeName()?lower_case == "getdraft">
@Override
public ${item.getCodeName()} getDraft(${item.getCodeName()} et) {
<#if item.isEnableAPIStorage()>
<#if deaction.getPSSubSysServiceAPIDEMethod()?? >
return ${item.codeName?uncap_first}FeignClient.getDraft();
<#else>
return null;
</#if>
<#else>
return null;
</#if>
}
<#elseif deaction.getCodeName()?lower_case == "checkkey">
@Override
public boolean checkKey(${item.getCodeName()} et) {
<#if item.isEnableAPIStorage()>
<#if deaction.getPSSubSysServiceAPIDEMethod()?? >
return ${item.codeName?uncap_first}FeignClient.checkKey(et);
<#else>
return false;
</#if>
<#else>
return false;
</#if>
}
<#else>
@Override
public ${item.getCodeName()} ${srfmethodname(deaction.getCodeName())}(${item.getCodeName()} et) {
<#if item.isEnableAPIStorage()>
<#if deaction.getPSSubSysServiceAPIDEMethod()?? >
return ${item.codeName?uncap_first}FeignClient.${deaction.getPSSubSysServiceAPIDEMethod().getCodeName()?uncap_first}(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}(),et);
<#else>
return null;
</#if>
<#else>
return null;
</#if>
}
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>1N关系中,在子实体中创建父实体的实例对象</#comment>
<#if de.getMinorPSDERs?? && de.getMinorPSDERs()??>
<#list de.getMinorPSDERs() as MinorPSDER>
<#if MinorPSDER?? && MinorPSDER.getDERType()=='DER1N'>
<#if MinorPSDER.getMajorPSDataEntity?? && MinorPSDER.getMajorPSDataEntity()??>
<#assign MajorEntity = MinorPSDER.getMajorPSDataEntity()>
<#if MajorEntity.name?? && MinorPSDER.getCodeName()?? >
<#if MinorPSDER.getPSPickupDEField?? && MinorPSDER.getPSPickupDEField()??>
<#assign MajorkeyField = MajorEntity.getKeyPSDEField()>
<#assign MajorField = MinorPSDER.getPSPickupDEField()>
<#if de.getDefaultPSDEDataSet()??>
<#assign deDefaultDataSet=de.getDefaultPSDEDataSet()>
<#if deDefaultDataSet.getPSDEDataQueries()??>
@Override
public List<${item.getCodeName()}> selectBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfjavatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case}) {
${item.getCodeName()}SearchContext context=new ${item.getCodeName()}SearchContext();
context.setSize(Integer.MAX_VALUE);
context.setN_${MajorField.name?lower_case}_eq(${MajorkeyField.codeName?lower_case});
return ${item.codeName?uncap_first}FeignClient.search${deDefaultDataSet.getCodeName()}(context).getContent();
}
@Override
public void removeBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfjavatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case}) {
Set<${srfjavatype(keyfield.stdDataType)}> delIds=new HashSet<${srfjavatype(keyfield.stdDataType)}>();
for(${item.getCodeName()} before:selectBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${MajorkeyField.codeName?lower_case})){
delIds.add(before.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}());
}
if(delIds.size()>0)
this.removeBatch(delIds);
}
<#assign nested=MinorPSDER.isNestedRS()>
<#if nested == false && MinorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list MinorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
@Override
public void saveBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfjavatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case},List<${item.getCodeName()}> list) {
if(list==null)
return;
Set<${srfjavatype(keyfield.stdDataType)}> delIds=new HashSet<${srfjavatype(keyfield.stdDataType)}>();
List<${item.getCodeName()}> _update=new ArrayList<${item.getCodeName()}>();
List<${item.getCodeName()}> _create=new ArrayList<${item.getCodeName()}>();
for(${item.getCodeName()} before:selectBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${MajorkeyField.codeName?lower_case})){
delIds.add(before.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}());
}
for(${item.getCodeName()} sub:list) {
sub.set${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${MajorkeyField.codeName?lower_case});
if(ObjectUtils.isEmpty(sub.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}()))
sub.set${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}((${srfjavatype(keyfield.stdDataType)})sub.getDefaultKey(true));
if(delIds.contains(sub.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}())) {
delIds.remove(sub.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}());
_update.add(sub);
}
else
_create.add(sub);
}
if(_update.size()>0)
this.updateBatch(_update);
if(_create.size()>0)
this.createBatch(_create);
if(delIds.size()>0)
this.removeBatch(delIds);
}
</#if>
</#if>
</#if>
</#if>
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>输出数据查询</#comment>
<#if item.getAllPSDEDataSets()??>
<#list item.getAllPSDEDataSets() as dedataset>
/**
* 查询集合 ${dedataset.getLogicName()}
*/
@Override
public Page<${item.getCodeName()}> search${dedataset.getCodeName()}(${item.getCodeName()}SearchContext context) {
<#--<#if item.isEnableNoSQLStorage() && item.getAllPSDEDBTables()??>-->
<#--<#list item.getAllPSDEDBTables() as detable>-->
Page<${de.getCodeName()}> ${de.getCodeName()?uncap_first}s=${item.codeName?uncap_first}FeignClient.search${dedataset.getCodeName()}(context);
return ${de.getCodeName()?uncap_first}s;
<#--</#list>-->
<#--<#else>-->
<#--return null ;-->
<#--</#if>-->
}
</#list>
</#if>
}
<#comment>无存储</#comment>
<#elseif de.getStorageMode()==0>
/**
* 实体[${item.getLogicName()}] 无存储服务对象接口实现
*/
@Slf4j
@Service
public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Service {
<#assign keyfield=de.getKeyPSDEField()>
<#comment>引入关联依赖</#comment>
<#if de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as der>
<#if der.getDERType() =='DER1N' >
<#if !P.exists('DEMinorPSDataEntity',der.getMinorPSDataEntity().getCodeName())>
@Autowired
@Lazy
private ${pub.getPKGCodeName()}.core.${der.getMinorPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.service.I${der.getMinorPSDataEntity().getCodeName()}Service ${srfcaseformat(der.getMinorPSDataEntity().getCodeName(),'l_u2lC')}Service;
</#if>
</#if>
</#list>
</#if>
<#comment>输出实体行为</#comment>
<#if item.getAllPSDEActions()??>
<#list item.getAllPSDEActions() as deaction>
<#if deaction.isEnableBackend()>
<#if deaction.getRender()??>
${deaction.getRender().code}
<#else>
<#if (deaction.getActionType()=='USERCUSTOM')>
<#elseif deaction.getActionType()=='DELOGIC'>
<#elseif deaction.getCodeName()?lower_case == 'get'>
@Override
public ${item.getCodeName()} get(${srfjavatype(keyfield.stdDataType)} ${keyfield.getCodeName()?lower_case}) {
return null;
}
<#elseif deaction.getCodeName()?lower_case == "createbatch">
<#elseif deaction.getCodeName()?lower_case == "updatebatch">
<#elseif deaction.getCodeName()?lower_case == "removebatch">
<#elseif deaction.getCodeName()?lower_case == "savebatch">
<#elseif deaction.getCodeName()?lower_case == "create">
@Override
public boolean create(${item.getCodeName()} et) {
return true;
}
public void createBatch(List<${item.codeName}> list){
}
<#elseif deaction.getCodeName()?lower_case == "update">
@Override
public boolean update(${item.getCodeName()} et) {
return true;
}
public void updateBatch(List<${item.codeName}> list){
}
<#elseif deaction.getCodeName()?lower_case == "save">
@Override
@Transactional
public boolean save(${item.getCodeName()} et) {
return true;
}
@Override
public void saveBatch(List<${item.getCodeName()}> list) {
}
<#elseif deaction.getCodeName()?lower_case == "remove">
@Override
public boolean remove(${srfjavatype(keyfield.stdDataType)} ${keyfield.getCodeName()?lower_case}) {
return true;
}
public void removeBatch(Collection<${srfjavatype(keyfield.stdDataType)}> idList){
}
<#elseif deaction.getCodeName()?lower_case == "getdraft">
@Override
public ${item.getCodeName()} getDraft(${item.getCodeName()} et) {
return null;
}
<#elseif deaction.getCodeName()?lower_case == "checkkey">
@Override
public boolean checkKey(${item.getCodeName()} et) {
return false;
}
<#else>
@Override
public ${item.getCodeName()} ${srfmethodname(deaction.getCodeName())}(${item.getCodeName()} et) {
return null;
}
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>1N关系中,在子实体中创建父实体的实例对象</#comment>
<#if de.getMinorPSDERs?? && de.getMinorPSDERs()??>
<#list de.getMinorPSDERs() as MinorPSDER>
<#if MinorPSDER?? && MinorPSDER.getDERType()=='DER1N'>
<#if MinorPSDER.getMajorPSDataEntity?? && MinorPSDER.getMajorPSDataEntity()??>
<#assign MajorEntity = MinorPSDER.getMajorPSDataEntity()>
<#if MajorEntity.name?? && MinorPSDER.getCodeName()?? >
<#if MinorPSDER.getPSPickupDEField?? && MinorPSDER.getPSPickupDEField()??>
<#assign MajorkeyField = MajorEntity.getKeyPSDEField()>
<#assign MajorField = MinorPSDER.getPSPickupDEField()>
<#if de.getDefaultPSDEDataSet()??>
<#assign deDefaultDataSet=de.getDefaultPSDEDataSet()>
<#if deDefaultDataSet.getPSDEDataQueries()??>
@Override
public List<${item.getCodeName()}> selectBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfjavatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case}) {
return null;
}
@Override
public void removeBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfjavatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case}) {
Set<${srfjavatype(keyfield.stdDataType)}> delIds=new HashSet<${srfjavatype(keyfield.stdDataType)}>();
for(${item.getCodeName()} before:selectBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${MajorkeyField.codeName?lower_case})){
delIds.add(before.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}());
}
if(delIds.size()>0)
this.removeBatch(delIds);
}
<#assign nested=MinorPSDER.isNestedRS()>
<#if nested == false && MinorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list MinorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
@Override
public void saveBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${srfjavatype(MajorField.stdDataType)} ${MajorkeyField.codeName?lower_case},List<${item.getCodeName()}> list) {
if(list==null)
return;
Set<${srfjavatype(keyfield.stdDataType)}> delIds=new HashSet<${srfjavatype(keyfield.stdDataType)}>();
List<${item.getCodeName()}> _update=new ArrayList<${item.getCodeName()}>();
List<${item.getCodeName()}> _create=new ArrayList<${item.getCodeName()}>();
for(${item.getCodeName()} before:selectBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${MajorkeyField.codeName?lower_case})){
delIds.add(before.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}());
}
for(${item.getCodeName()} sub:list) {
sub.set${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}(${MajorkeyField.codeName?lower_case});
if(ObjectUtils.isEmpty(sub.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}()))
sub.set${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}((${srfjavatype(keyfield.stdDataType)})sub.getDefaultKey(true));
if(delIds.contains(sub.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}())) {
delIds.remove(sub.get${srfcaseformat(keyfield.getCodeName(),'l_u2lC')?cap_first}());
_update.add(sub);
}
else
_create.add(sub);
}
if(_update.size()>0)
this.updateBatch(_update);
if(_create.size()>0)
this.createBatch(_create);
if(delIds.size()>0)
this.removeBatch(delIds);
}
</#if>
</#if>
</#if>
</#if>
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>输出数据查询</#comment>
<#if item.getAllPSDEDataSets()??>
<#list item.getAllPSDEDataSets() as dedataset>
/**
* 查询集合 ${dedataset.getLogicName()}
*/
@Override
public Page<${item.getCodeName()}> search${dedataset.getCodeName()}(${item.getCodeName()}SearchContext context) {
<#--<#if item.isEnableNoSQLStorage() && item.getAllPSDEDBTables()??>-->
<#--<#list item.getAllPSDEDBTables() as detable>-->
return null;
<#--</#list>-->
<#--<#else>-->
<#--return null ;-->
<#--</#if>-->
}
</#list>
</#if>
}
</#if>
<#comment>附加逻辑-操作前</#comment>
<#macro addBoforeLogic deaction>
<#if deaction.getPSDEActionLogics()??>
<#list deaction.getPSDEActionLogics() as actionlogic>
<#if actionlogic.getAttachMode()=='BEFORE'>
<#if actionlogic.isInternalLogic()>
//${actionlogic.getPSDELogic().getCodeName()?lower_case}Logic.execute(et);
<#else>
//行为处理
</#if>
</#if>
</#list>
</#if>
</#macro>
<#comment>附加逻辑-操作后</#comment>
<#macro addAfterLogic deaction>
<#if deaction.getPSDEActionLogics()??>
<#list deaction.getPSDEActionLogics() as actionlogic>
<#if actionlogic.getAttachMode()=='AFTER'>
<#if actionlogic.isInternalLogic()>
//${actionlogic.getPSDELogic().getCodeName()?lower_case}Logic.execute(et);
<#else>
//行为处理
</#if>
</#if>
</#list>
</#if>
</#macro>
</#if>
\ No newline at end of file
<#ibiztemplate>
TARGET=PSDELOGIC
</#ibiztemplate>
package ${pub.getPKGCodeName()}.core.${item.getPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.service.logic;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.domain.${de.getCodeName()};
/**
* 关系型数据实体[${item.codeName}] 对象
*/
public interface I${de.codeName}${item.codeName}Logic {
void execute(${de.codeName} ${de.codeName?lower_case} ) ;
}
<#ibiztemplate>
TARGET=PSDELOGIC
</#ibiztemplate>
package ${pub.getPKGCodeName()}.core.${item.getPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.service.logic.impl;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.KieContainer;
import ${pub.getPKGCodeName()}.core.${item.getPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.service.logic.I${de.codeName}${item.codeName}Logic;
import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.domain.${de.getCodeName()};
/**
* 关系型数据实体[${item.codeName}] 对象
*/
@Slf4j
@Service
public class ${de.codeName}${item.codeName}LogicImpl implements I${de.codeName}${item.codeName}Logic{
@Autowired
private KieContainer kieContainer;
<#comment>注入处理逻辑中所用到的service对象</#comment>
<#if item.getPSDELogicNodes?? && item.getPSDELogicNodes()??>
<#list item.getPSDELogicNodes() as deLogicNode>
<#if deLogicNode.getDstPSDataEntity?? && deLogicNode.getDstPSDataEntity()??>
<#assign nodePSDataEntity=deLogicNode.getDstPSDataEntity()>
<#if !P.exists("Autowired",nodePSDataEntity.getCodeName(),"service")>
@Autowired
private ${pub.getPKGCodeName()}.core.${nodePSDataEntity.getPSSystemModule().codeName?lower_case}.service.I${nodePSDataEntity.codeName}Service ${deLogicNode.getDstPSDataEntity().getCodeName()?lower_case}service;
public ${pub.getPKGCodeName()}.core.${nodePSDataEntity.getPSSystemModule().codeName?lower_case}.service.I${nodePSDataEntity.codeName}Service get${deLogicNode.getDstPSDataEntity().getCodeName()?lower_case?cap_first}Service() {
return this.${deLogicNode.getDstPSDataEntity().getCodeName()?lower_case}service;
}
</#if>
</#if>
</#list>
</#if>
<#comment>注入当前实体的service对象,供自定义查询使用</#comment>
@Autowired
private ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().codeName?lower_case}.service.I${de.codeName}Service iBzSysDefaultService;
public ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().codeName?lower_case}.service.I${de.codeName}Service getIBzSysDefaultService() {
return this.iBzSysDefaultService;
}
public void execute(${de.codeName} et){
KieSession kieSession = null;
try{
kieSession=kieContainer.newKieSession();
<#comment>插入逻辑参数</#comment>
<#if item.getPSDELogicParams?? && item.getPSDELogicParams()??>
<#assign logicName=(de.codeName+item.codeName)?lower_case>
<#list item.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()}.core.${ParamPSDataEntity.getPSSystemModule().codeName?lower_case}.domain.${ParamPSDataEntity.codeName} ${(logicName+logicParam.codeName)?lower_case} =new ${pub.getPKGCodeName()}.core.${ParamPSDataEntity.getPSSystemModule().codeName?lower_case}.domain.${ParamPSDataEntity.codeName}();
<#else>
Map ${(logicName+logicParam.codeName)?lower_case} =new HashMap();
</#if>
kieSession.insert(${paramObjValue}); <#comment>将逻辑参数存储到fact</#comment>
kieSession.setGlobal("${paramObj}",${paramObjValue});<#comment>将逻辑参数存储到global</#comment>
</#list>
</#if>
<#comment>插入处理逻辑中所用到的service对象</#comment>
<#if item.getPSDELogicNodes?? && item.getPSDELogicNodes()??>
<#list item.getPSDELogicNodes() as deLogicNode>
<#if deLogicNode.getDstPSDataEntity?? && deLogicNode.getDstPSDataEntity()??>
<#if !P.exists(item.codeName,"kieSessionGlobalService",deLogicNode.getDstPSDataEntity().getCodeName()?lower_case)>
kieSession.setGlobal("${deLogicNode.getDstPSDataEntity().getCodeName()?lower_case}service",${deLogicNode.getDstPSDataEntity().getCodeName()?lower_case}service);<#comment>将逻辑中引用到的service存储到global</#comment>
</#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()}.core.${de.getPSSystemModule().codeName?lower_case}.service.logic.${de.codeName?lower_case}${item.getCodeName()?lower_case}");<#comment>执行所要执行的流程</#comment>
}catch(Exception e){
throw new RuntimeException("执行[${item.getName()}]处理逻辑发生异常"+e);
<#--throw new BadRequestAlertException(""+e,"","");-->
}finally {
if(kieSession!=null)
kieSession.destroy();
}
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.core.util.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 org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.IOException;
import java.util.List;
@Configuration
public class DroolsAutoConfiguration {
private Log logger= LogFactory.getLog(DroolsAutoConfiguration.class);
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();
if(kieBuilder.getResults().hasMessages(new Message.Level[] { Message.Level.ERROR })){
List<Message> errors = kieBuilder.getResults().getMessages(new Message.Level[] { Message.Level.ERROR });
StringBuilder stringBuilder = new StringBuilder("Errors:");
for (Message msg : errors)
{
stringBuilder.append(new StringBuilder().append("\n ").append(prettyBuildMessage(msg)).toString());
}
logger.error(String.format("初始化处理逻辑发生异常,异常原因为[%s]",stringBuilder.toString()));
//忽略处理逻辑
getKieServices().newKieBuilder(getKieServices().newKieFileSystem()).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();
}
/**
* 输出异常信息
* @param msg
* @return
*/
public static String prettyBuildMessage(Message msg)
{
return new StringBuilder().append("Message: {id=").append(msg.getId()).append(", level=").append(msg.getLevel()).append(", path=").append(msg.getPath()).append(", line=").append(msg.getLine())
.append(", column=").append(msg.getColumn()).append(", text=\"").append(msg.getText()).append("\"}").toString();
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.core.util.config;
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()}.util.domain.LiquibaseProp;
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.apache.ibatis.session.SqlSessionFactory;
@Configuration
public class LiquibaseConfiguration {
/**
* 主数据源版本管理
* @param
* @return
*/
@Bean
public SpringLiquibase masterliquibase(LiquibaseProp masterProperties) {
return LiquibaseInit(masterProperties);
}
/**
* liquibase初始化数据库
* @param properties
* @return
*/
private SpringLiquibase LiquibaseInit(LiquibaseProp 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;
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.core.util.config;
import ${pub.getPKGCodeName()}.util.helper.JSR310DateConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.mongodb.core.convert.*;
import java.util.ArrayList;
import java.util.List;
@Configuration
public class MongoDBConfig {
@Bean
public MongoCustomConversions customConversions() {
List<Converter<?, ?>> converterList = new ArrayList<>();
converterList.add(JSR310DateConverters.DateToZonedDateTimeConverter.INSTANCE);
converterList.add(JSR310DateConverters.ZonedDateTimeToDateConverter.INSTANCE);
converterList.add(JSR310DateConverters.DurationToLongConverter.INSTANCE);
converterList.add(JSR310DateConverters.TimestampToDateConverter.INSTANCE);
converterList.add(JSR310DateConverters.DateToTimestampConverter.INSTANCE);
return new MongoCustomConversions(converterList);
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.core.util.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Configuration;
/**
* mybatis自动配置
*/
@Configuration
@ConditionalOnClass(MybatisConfiguration.class)
@ConditionalOnWebApplication
public class MybatisAutoConfiguration {
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.core.util.config;
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
import ${pub.getPKGCodeName()}.util.helper.UniqueNameGenerator;
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
<#--import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;-->
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.apache.ibatis.mapping.DatabaseIdProvider;
import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.mybatis.spring.annotation.MapperScan;
import java.util.Properties;
/**
* mybatis全局配置类
*/
@Configuration
@MapperScan(value="${pub.getPKGCodeName()}.core.*.mapper",nameGenerator = UniqueNameGenerator.class)
public class MybatisConfiguration {
/**
* mybatis适配多数据库
* @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模式
p.setProperty("H2", "mysql");//根据当前运行的数据库设置h2对应的databaseid
databaseIdProvider.setProperties(p);
return databaseIdProvider;
}
/**
* mybatis-plus分页
* @return
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
<#--/**-->
<#--* mybatis-plus逻辑有效-->
<#--* @return-->
<#--*/-->
<#--@Bean-->
<#--public ISqlInjector sqlInjector() {-->
<#--return new LogicSqlInjector();-->
<#--}-->
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#if sys.getAllPSApps()??>
<#assign ct=0>
[
<#list sys.getAllPSApps() as app>
<#if app.getAllPSAppDataEntities?? && app.getAllPSAppDataEntities()??>
<#list app.getAllPSAppDataEntities() as appde><#comment>由于平台暂未开放获取实体操作标识的方法,所以暂时写死</#comment>
<#assign de=appde.getPSDE()>
<#if !P.exists(de.getCodeName(),"")>
<#if (ct>0)>
,</#if><#assign ct=ct+1>
{
"dename":"${de.codeName}",
"delogicname":"${de.logicName}",
"sysmoudle":{"id":"${de.getPSSystemModule().codeName?upper_case}","name":"${de.getPSSystemModule().name}"},
"dedataset":[{"id":"Default","name":"默认数据集"}],
"dedatarange":[{"id":"ALL","name":"全部数据"},{"id":"CURORG","name":"当前单位"},{"id":"PORG","name":"上级单位"},{"id":"SORG","name":"下级单位"},{"id":"CURORGDEPT","name":"当前部门"},{"id":"PORGDEPT","name":"上级部门"},{"id":"SORGDEPT","name":"下级部门"}],
"deprivs":[{"id":"READ","name":"READ"},{"id":"CREATE","name":"CREATE"},{"id":"UPDATE","name":"UPDATE"},{"id":"DELETE","name":"DELETE"}]
}
</#if>
</#list>
</#if>
</#list>
]
</#if>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
<changeSet author="Think (generated)" id="1561433044682-1">
<createTable remarks="文件" tableName="IBZFILE">
<column name="FILEID" type="VARCHAR2(100 BYTE)">
<constraints primaryKey="true" primaryKeyName="SYS_C00168533"/>
</column>
<column name="FILENAME" type="VARCHAR2(200 BYTE)"/>
<column name="FILEPATH" type="VARCHAR2(500 BYTE)"/>
<column name="FOLDER" type="VARCHAR2(20 BYTE)"/>
<column name="CREATEMAN" type="VARCHAR2(60 BYTE)"/>
<column name="CREATEDATE" type="date"/>
<column name="UPDATEMAN" type="VARCHAR2(60 BYTE)"/>
<column name="UPDATEDATE" type="date"/>
<column name="FILEEXT" type="VARCHAR2(10 BYTE)"/>
<column name="FILESIZE" type="INTEGER"/>
<column name="DIGESTCODE" type="VARCHAR2(64 BYTE)"/>
<column name="OWNERTYPE" type="VARCHAR2(100 BYTE)"/>
<column name="OWNERID" type="VARCHAR2(100 BYTE)"/>
<column name="MEMO" type="VARCHAR2(500 BYTE)"/>
<column name="RESERVER" type="VARCHAR2(100 BYTE)"/>
</createTable>
</changeSet>
<changeSet author="Think (generated)" id="1561433044682-2">
<createTable remarks="用户" tableName="IBZUSER">
<column name="USERID" type="VARCHAR2(100 BYTE)">
<constraints primaryKey="true" primaryKeyName="SYS_C00168531"/>
</column>
<column name="PERSONNAME" type="VARCHAR2(200 BYTE)"/>
<column name="USERNAME" type="VARCHAR2(200 BYTE)"/>
<column name="USERCODE" type="VARCHAR2(100 BYTE)"/>
<column name="LOGINNAME" type="VARCHAR2(100 BYTE)"/>
<column name="PASSWORD" type="VARCHAR2(100 BYTE)"/>
<column name="DOMAINS" type="VARCHAR2(100 BYTE)"/>
<column name="MDEPTID" type="VARCHAR2(100 BYTE)"/>
<column name="MDEPTCODE" type="VARCHAR2(100 BYTE)"/>
<column name="MDEPTNAME" type="VARCHAR2(200 BYTE)"/>
<column name="BCODE" type="VARCHAR2(100 BYTE)"/>
<column name="POSTID" type="VARCHAR2(100 BYTE)"/>
<column name="POSTCODE" type="VARCHAR2(100 BYTE)"/>
<column name="POSTNAME" type="VARCHAR2(200 BYTE)"/>
<column name="ORGID" type="VARCHAR2(100 BYTE)"/>
<column name="ORGCODE" type="VARCHAR2(100 BYTE)"/>
<column name="ORGNAME" type="VARCHAR2(200 BYTE)"/>
<column name="NICKNAME" type="VARCHAR2(36 BYTE)"/>
<column name="EMAIL" type="VARCHAR2(100 BYTE)"/>
<column name="AVATAR" type="VARCHAR2(100 BYTE)"/>
<column name="PHONE" type="VARCHAR2(100 BYTE)"/>
<column name="RESERVER" type="VARCHAR2(100 BYTE)"/>
<column name="USERICON" type="VARCHAR2(100 BYTE)"/>
<column name="SEX" type="VARCHAR2(10 BYTE)"/>
<column name="BIRTHDAY" type="date"/>
<column name="CERTCODE" type="VARCHAR2(36 BYTE)"/>
<column name="ADDR" type="VARCHAR2(200 BYTE)"/>
<column name="THEME" type="VARCHAR2(100 BYTE)"/>
<column name="FONTSIZE" type="VARCHAR2(10 BYTE)"/>
<column name="LANG" type="VARCHAR2(100 BYTE)"/>
<column name="MEMO" type="VARCHAR2(500 BYTE)"/>
</createTable>
</changeSet>
<changeSet author="Think (generated)" id="1561433044682-3">
<insert tableName="IBZUSER">
<column name="USERID" value="0100"/>
<column name="PERSONNAME" value="管理员"/>
<column name="USERNAME" value="系统管理员"/>
<column name="USERCODE" value="0100"/>
<column name="LOGINNAME" value="ibzadmin"/>
<column name="PASSWORD" value="123456"/>
<column name="DOMAINS" value="100000"/>
<column name="MDEPTID"/>
<column name="MDEPTCODE"/>
<column name="MDEPTNAME"/>
<column name="BCODE"/>
<column name="POSTID"/>
<column name="POSTCODE"/>
<column name="POSTNAME"/>
<column name="ORGID"/>
<column name="ORGCODE"/>
<column name="ORGNAME"/>
<column name="NICKNAME"/>
<column name="EMAIL"/>
<column name="AVATAR"/>
<column name="PHONE"/>
<column name="RESERVER"/>
<column name="USERICON"/>
<column name="SEX"/>
<column name="BIRTHDAY"/>
<column name="CERTCODE"/>
<column name="ADDR"/>
<column name="THEME"/>
<column name="FONTSIZE"/>
<column name="LANG"/>
<column name="MEMO"/>
</insert>
</changeSet>
</databaseChangeLog>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#if sysrun.getPSDBDevInst()??>
<#assign dbinst = sysrun.getPSDBDevInst()>
create schema if not exists ${dbinst.getUserName()};
set schema ${dbinst.getUserName()};
<#--CREATE ALIAS IF NOT EXISTS TO_NUMBER AS $$-->
<#--Long toNumber(String value) {-->
<#--return value == null ? null : Long.valueOf(value);-->
<#--}-->
<#--$$;-->
</#if>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<!--liquibase启动时需要指定chanlogxml,若无changelog,则使用此xml来初始化liquibase,使liquibase能正常启动 -->
</databaseChangeLog>
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<include file="changelog/20190625112530_init_ibizsys.xml" relativeToChangelogFile="true"/>
<include file="changelog/20190817112530_init_ibizsys_audit.xml" relativeToChangelogFile="true"/>
<include file="h2_table.xml" relativeToChangelogFile="true"/>
<include file="view.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#if sysrun.getPSDBDevInst()??>
<#assign dbinst = sysrun.getPSDBDevInst()>
<#assign curdate=.now?string["yyyyMMddHHmmss"]>
</#if>
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
<#assign sequenceNumber=0>
<#list sys.getAllPSDataEntities() as de>
<#if de.getTableName?? &&de.getTableName()?? && de.isSubSysDE()==false>
<!--输出实体[${de.getName()}]数据结构 -->
<#assign sequenceNumber=sequenceNumber+1>
<#assign deVersion=de.getVersion()?c>
<#assign deName=de.getName()?lower_case>
<#comment>输出表结构</#comment>
<#if !P.exists("table_",de.getTableName(),"")>
<changeSet author="${dbinst.getUserName()}" id="tab-${deName}-${deVersion}-${sequenceNumber}">
<createTable tableName="${de.getTableName()}">
<#list de.getAllPSDEFields() as defield>
<#if defield.isPhisicalDEField()==true><#comment>物理属性</#comment>
<#assign dataType="${srfdatatype(defield.getStdDataType())}">
<#comment>varchar需要设置字段长度,若不设置,则liquibase比较时会自动填充,最终恢复到生产库会报错</#comment>
<#if srfjavatype(defield.stdDataType)=='String'>
<#if defield.getLength()?? && defield.getLength()?c!='-1'>
<#assign dataType="${srfdatatype(defield.getStdDataType())}(${defield.getLength()?c})" >
<#else>
<#assign dataType="${srfdatatype(defield.getStdDataType())}(200)">
</#if>
<#elseif dataType?lower_case=='decimal'>
<#assign dataType="${srfdatatype(defield.getStdDataType())}(38,2)"><#comment>设置数值类型精度</#comment>
</#if>
<#comment>由于liquibase不支持修改mysql的remarks,修改remarks会导致启动报错,所以mysql数据库暂时不发remarks</#comment>
<column name="${defield.getName()}" remarks="<#if (dbinst.getDBType()!='MYSQL5')>${defield.getLogicName()}</#if>" type="${dataType}">
<#if defield.isKeyDEField()==true>
<#comment>oracle中约束名长度不能大于30</#comment>
<#assign constraintName="PK_"+de.getName()+"_"+defield.getName()>
<#if constraintName?length gt 30>
<#assign constraintName=constraintName?substring(0,30)>
</#if>
<constraints primaryKey="true" primaryKeyName="${constraintName}"/>
</#if>
</column>
</#if>
</#list>
</createTable>
</changeSet>
</#if>
</#if>
</#list>
<#comment>输出外键</#comment>
<#list sys.getAllPSDataEntities() as de>
<#assign deVersion=de.getVersion()?c>
<#assign deName=de.getName()?lower_case>
<#if de.getTableName?? &&de.getTableName()?? && de.isSubSysDE()==false>
<#if de.getMinorPSDERs?? && de.getMinorPSDERs()?? >
<!--输出实体[${de.getName()}]外键关系 -->
<#list de.getMinorPSDERs() as fk>
<#if fk.getDERType()=='DER1N'>
<#if fk.getMajorPSDataEntity().getTableName()??>
<#assign sequenceNumber=sequenceNumber+1>
<#comment>oracle中约束名长度不能大于30</#comment>
<#assign fkConstraintName=fk.getName()>
<#if fkConstraintName?length gt 30>
<#assign fkConstraintName=fkConstraintName?substring(0,30)>
</#if>
<#if !P.exists("fk_",fkConstraintName,"")>
<changeSet author="${dbinst.getUserName()}" id="fk-${deName}-${deVersion}-${sequenceNumber}">
<addForeignKeyConstraint baseColumnNames="${fk.getPSPickupDEField().getName()}" baseTableName="${de.getTableName()}" constraintName="${fkConstraintName}" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="${fk.getMajorPSDataEntity().getKeyPSDEField().getName()}" referencedTableName="${fk.getMajorPSDataEntity().getTableName()}" validate="true"/>
</changeSet>
</#if>
</#if>
</#if>
</#list>
</#if>
</#if>
</#list>
</databaseChangeLog>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<includeAll path="liquibase/changelog/"/>
<include file="view.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<includeAll path="liquibase/changelog/"/>
</databaseChangeLog>
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
此文件只用于让模板能发出[rollback]文件夹,无实际用途
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#if sysrun.getPSDBDevInst()??>
<#assign dbinst = sysrun.getPSDBDevInst()>
<#assign curdate=.now?string["yyyyMMddHHmmss"]>
</#if>
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
<#assign sequenceNumber=0>
<#comment>输出视图信息</#comment>
<#list sys.getAllPSDataEntities() as de>
<#if de.getStorageMode()==1>
<#if de.getViewName?? && ((de.getViewName()!'')!='') && de.isSubSysDE()==false && de.isNoViewMode()!=true>
<#assign sequenceNumber=sequenceNumber+1>
<#assign deVersion=de.getVersion()?c>
<#assign deName=de.getName()?lower_case>
<#if !P.exists("view_",de.getViewName(),"")>
<!--输出实体[${de.getName()}]视图结构信息 runOnChange="true" 当视图发生变更时,通过liquibase强刷prod的视图,实现视图的同步-->
<changeSet author="${dbinst.getUserName()}" id="view-${deName}-${deVersion}-${sequenceNumber}" runOnChange="true">
<createView fullDefinition="false" replaceIfExists="true" viewName="${de.getViewName()}">
<#if de.getAllPSDEDataQueries?? && de.getAllPSDEDataQueries()??>
<#assign resultDataQuery = de.getAllPSDEDataQueries()>
<#list resultDataQuery as singleQuery>
<#if singleQuery.getCodeName()?lower_case=='default'>
<#if singleQuery.getAllPSDEDataQueryCodes()??>
<#assign queryCodeList = singleQuery.getAllPSDEDataQueryCodes()>
<#assign sql="">
<#comment>遍历数据查询,有oracle则输出,无则输出mysql</#comment>
<#list singleQuery.getAllPSDEDataQueryCodes() as dedqcode>
<#assign sql=srfjavasqlcode('${dedqcode.getQueryCode()}')>
<#assign dbtype=dedqcode.getDBType()?lower_case?replace("mysql5","mysql")>
<#if dbtype?lower_case=='oracle'>
<#break>
</#if>
</#list>
<![CDATA[ ${sql}]]>
<#break>
</#if>
</#if>
</#list>
</#if>
</createView>
</changeSet>
</#if>
</#if>
</#if>
</#list>
</databaseChangeLog>
<#ibiztemplate>
TARGET=PSDATAENTITY
</#ibiztemplate>
<#if de.getStorageMode()==1>
<#if de.getAllPSDEDataSets()??>
<#assign resultSet=de.getAllPSDEDataSets()>
</#if>
<#if de.getAllPSDEDataQueries()??>
<#assign dataQueries=de.getAllPSDEDataQueries()>
</#if>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${pub.getPKGCodeName()}.core.${de.getPSSystemModule().codeName?lower_case}.mapper.${de.codeName}Mapper">
<!--该方法用于重写mybatis中selectById方法,以实现查询逻辑属性-->
<#comment>无视图模式-查询view的数据查询</#comment>
<#if de.isNoViewMode()==true>
<#list dataQueries as singleQuery>
<#if singleQuery.getCodeName()?lower_case=='view'>
<#if singleQuery.getAllPSDEDataQueryCodes()??>
<#assign queryCodeList = singleQuery.getAllPSDEDataQueryCodes()>
<#list singleQuery.getAllPSDEDataQueryCodes() as dedqcode>
<#assign dbtype=dedqcode.getDBType()?lower_case?replace("mysql5","mysql")>
<select id="selectById" resultMap="${de.codeName}ResultMap" databaseId="${dbtype}">
<![CDATA[select t1.* from (${contextParamConvert(srfjavasqlcode(dedqcode.getQueryCode()))}) t1 where ${de.getKeyPSDEField().name?lower_case}=<#noparse>#{id}</#noparse>]]>
</select>
</#list>
</#if>
<#break>
</#if>
</#list>
<#else>
<#comment>直接查询视图</#comment>
<#list dataQueries as singleQuery>
<#list singleQuery.getAllPSDEDataQueryCodes() as dedqcode>
<#assign dbtype=dedqcode.getDBType()?lower_case?replace("mysql5","mysql")>
<select id="selectById" resultMap="${de.codeName}ResultMap" databaseId="${dbtype}">
<![CDATA[select * from ${de.getViewName()?lower_case} t1 where ${de.getKeyPSDEField().name?lower_case}=<#noparse>#{id}</#noparse>]]>
</select>
</#list>
<#break>
</#list>
</#if>
<!--通过mybatis将查询结果注入到entity中,通过配置autoMapping="true"由mybatis自动处理映射关系 -->
<resultMap id="${de.codeName}ResultMap" type="${pub.getPKGCodeName()}.core.${de.getPSSystemModule().codeName?lower_case}.domain.${de.codeName}" autoMapping="true">
<id property="${srfcaseformat(de.getKeyPSDEField().codeName,'l_u2lC')}" column="${de.getKeyPSDEField().getName()?lower_case}" /><!--主键字段映射-->
<#comment>外键值字段映射:由于需要将一个数据库列注入到2个domian属性中(主关系实体对象),由于已经手动将列映射给主关系对象,所以autoMapping将不会自动注入外键id,需要再次声明映射关系</#comment>
<#comment>属性名称与代码名称不一致时,强制进行映射</#comment>
<#list item.getPSDEFields() as defield>
<#if defield.isKeyDEField()!=true && ((defield.getDataType())!"")!='ONE2MANYDATA'>
<#if defield.codeName?lower_case != defield.name?lower_case || defield.getDataType()=='PICKUP'>
<result property="${srfcaseformat(defield.codeName,'l_u2lC')}" column="${defield.getName()?lower_case}" />
</#if>
</#if>
</#list>
<#comment>1:N关系中,在父实体中创建子实体的List集合</#comment>
<#if de.getMajorPSDERs?? && de.getMajorPSDERs()??>
<#list de.getMajorPSDERs() as MajorPSDER>
<#if MajorPSDER??>
<#if MajorPSDER.getMinorPSDataEntity?? && MajorPSDER.getMinorPSDataEntity()?? && MajorPSDER.getDERType()=='DER1N' >
<#assign MinorEntity = MajorPSDER.getMinorPSDataEntity()>
<#assign MajorDerField = MajorPSDER.getPSPickupDEField()>
<#assign listcode=(MajorPSDER.getMinorCodeName()!MajorPSDER.getMinorPSDataEntity().getCodeName())>
<#if listcode?? && listcode==''><#assign listcode=MajorPSDER.getMinorPSDataEntity().getCodeName()></#if>
<#assign nested=MajorPSDER.isNestedRS()>
<#if nested == false && MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs()??>
<#list MajorPSDER.getMinorPSDataEntity().getAllPSDEServiceAPIs() as api>
<#if api.isNested()>
<#assign nested=true>
</#if>
</#list>
</#if>
<#if nested>
<#if MinorEntity.getStorageMode()==0 && MajorPSDER.getPSOne2ManyDataDEField()?? && MajorPSDER.getPSOne2ManyDataDEField().isPhisicalDEField()==true>
<#assign columnname=MajorPSDER.getPSOne2ManyDataDEField().getName()?lower_case>
<result property="${srfcaseformat(listcode,'l_u2lC')}" column="${columnname}" typeHandler="${pub.getPKGCodeName()}.core.${MinorEntity.getPSSystemModule().codeName?lower_case}.domain.handlers.${MinorEntity.codeName}TypeHandler" />
</#if>
<#--<collection property="${srfcaseformat(listcode,'l_u2lC')}" ofType="${pub.getPKGCodeName()}.core.${MinorEntity.getPSSystemModule().codeName?lower_case}.domain.${MinorEntity.codeName}" column="${de.getKeyPSDEField().getName()?lower_case}" select="${pub.getPKGCodeName()}.core.${MinorEntity.getPSSystemModule().codeName?lower_case}.mapper.${MinorEntity.codeName}Mapper.selectBy${srfcaseformat(MajorDerField.codeName,'l_u2lC')?cap_first}" fetchType="lazy"></collection>-->
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>1:N关系中,在子实体中创建父实体的实例对象</#comment>
<#if de.getMinorPSDERs?? && de.getMinorPSDERs()??>
<#list de.getMinorPSDERs() as MinorPSDER>
<#if MinorPSDER?? && MinorPSDER.getDERType()=='DER1N'>
<#if MinorPSDER.getMajorPSDataEntity?? && MinorPSDER.getMajorPSDataEntity()??>
<#assign MajorEntity = MinorPSDER.getMajorPSDataEntity()>
<#if MajorEntity.name?? && MinorPSDER.getCodeName()?? && MajorEntity.getStorageMode()==1>
<#if MinorPSDER.getPSPickupDEField?? && MinorPSDER.getPSPickupDEField()??>
<#assign MajorkeyField = MajorEntity.getKeyPSDEField()>
<#assign MajorField = MinorPSDER.getPSPickupDEField()>
<!--通过mybatis自动注入关系属性[主实体],fetchType="lazy"为懒加载配置 -->
<association property="${srfcaseformat(MinorPSDER.getCodeName(),'l_u2lC')}" javaType="${pub.getPKGCodeName()}.core.${MajorEntity.getPSSystemModule().codeName?lower_case}.domain.${MajorEntity.codeName}" column="${MajorField.getName()?lower_case}" select="${pub.getPKGCodeName()}.core.${MajorEntity.getPSSystemModule().codeName?lower_case}.mapper.${MajorEntity.codeName}Mapper.selectById" fetchType="lazy"></association>
</#if>
</#if>
</#if>
</#if>
</#list>
</#if>
</resultMap>
<#comment>1:N关系中,在子实体中创建父实体的实例对象</#comment>
<#if de.getMinorPSDERs?? && de.getMinorPSDERs()??>
<#list de.getMinorPSDERs() as MinorPSDER>
<#if MinorPSDER?? && MinorPSDER.getDERType()=='DER1N'>
<#if MinorPSDER.getMajorPSDataEntity?? && MinorPSDER.getMajorPSDataEntity()??>
<#assign MajorEntity = MinorPSDER.getMajorPSDataEntity()>
<#if MajorEntity.name?? && MinorPSDER.getCodeName()?? >
<#if MinorPSDER.getPSPickupDEField?? && MinorPSDER.getPSPickupDEField()??>
<#assign MajorkeyField = MajorEntity.getKeyPSDEField()>
<#assign MajorField = MinorPSDER.getPSPickupDEField()>
<!--关系实体暴露select方法供主实体通过外键查询关系实体数据[实体关系名称:${MinorPSDER.getName()}] -->
<#if de.getDefaultPSDEDataSet()??>
<#assign deDefaultDataSet=de.getDefaultPSDEDataSet()>
<#if deDefaultDataSet.getPSDEDataQueries()??>
<select id="selectBy${srfcaseformat(MajorField.codeName,'l_u2lC')?cap_first}" resultMap="${de.codeName}ResultMap">
select t1.* from (
<#if deDefaultDataSet.getPSDEDataQueries()??>
<#list deDefaultDataSet.getPSDEDataQueries() as defaultDQ>
<#if defaultDQ_index gt 0>
union all
</#if>
<include refid="${defaultDQ.getCodeName()}" />
</#list>
</#if>
) t1
where ${MajorField.getName()?lower_case}=<#noparse>#{</#noparse>${MajorkeyField.codeName?lower_case}<#noparse>}</#noparse>
</select>
</#if>
</#if>
</#if>
</#if>
</#if>
</#if>
</#list>
</#if>
<#comment>暂未实现多数据源,暂时先发布单数据库</#comment>
<#if resultSet??>
<#list resultSet as singleSet>
<#if singleSet.getPSDEDataQueries()??>
<!--数据集合[${singleSet.getCodeName()}]-->
<select id="search${singleSet.getCodeName()}" parameterType="${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.filter.${de.codeName}SearchContext" resultMap="${de.codeName}ResultMap">
select t1.* from (
<#list singleSet.getPSDEDataQueries() as dataQuery>
<#if dataQuery_index gt 0>
union all
</#if>
<include refid="${dataQuery.getCodeName()}" />
</#list>
)t1
<where><if test="ew!=null and ew.sqlSegment!=null and !ew.emptyOfWhere"><#noparse>${ew.sqlSegment}</#noparse></if></where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere"><#noparse>${ew.sqlSegment}</#noparse></if>
</select>
</#if>
</#list>
</#if>
<#comment>数据查询</#comment>
<#if de.getAllPSDEDataQueries()??>
<#list de.getAllPSDEDataQueries() as singleQuery>
<#if singleQuery.getAllPSDEDataQueryCodes()??>
<#list singleQuery.getAllPSDEDataQueryCodes() as dedqcode>
<#assign dbtype=dedqcode.getDBType()?lower_case?replace("mysql5","mysql")>
<!--数据查询[${singleQuery.getCodeName()}]-->
<sql id="${singleQuery.getCodeName()}" databaseId="${dbtype}">
<![CDATA[ ${contextParamConvert(srfjavasqlcode(dedqcode.getQueryCode()))}
<#if dedqcode.getPSDEDataQueryCodeConds()??>
<#list dedqcode.getPSDEDataQueryCodeConds() as dedqfieldcond>
<#if (dedqfieldcond_index==0)> WHERE </#if> <#if (dedqfieldcond_index>0)> AND </#if>${contextParamConvert(srfjavasqlcode(dedqfieldcond.getCustomCond()))}
</#list>
</#if>]]>
</sql>
</#list>
</#if>
</#list>
</#if>
</mapper>
</#if>
<#comment>上下文参数转换</#comment>
<#function contextParamConvert contextParam>
<#assign resultParam="">
<#assign resultParam=contextParam?replace('$\{srfdatacontext(\'','#\{srf.datacontext.')?replace("','\\{[\\S]*","\\}","r")><#comment>数据上下文</#comment>
<#assign resultParam=resultParam?replace('$\{srfsessioncontext(\'','#\{srf.sessioncontext.')?replace("','\\{[\\S]*","\\}","r")><#comment>用户上下文</#comment>
<#assign resultParam=resultParam?replace('$\{srfwebcontext(\'','#\{srf.webcontext.')?replace("','\\{[\\S]*","\\}","r")><#comment>网页请求上下文</#comment>
<#return resultParam>
</#function>
<#ibiztemplate>
TARGET=PSDELOGIC
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.logic.${de.codeName?lower_case}logic.${item.getCodeName()?lower_case};
<#assign logicName=(de.codeName+item.codeName)?lower_case>
<#assign delogic=item>
<#assign defaultLogicParam="">
<#comment>插入逻辑参数</#comment>
<#if delogic.getPSDELogicParams?? && delogic.getPSDELogicParams()??>
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
<#list delogic.getPSDELogicParams() as logicParam>
<#if logicParam.isDefault()==true>
<#assign defaultLogicParam=logicParam><#comment>获取处理逻辑中默认逻辑参数</#comment>
</#if>
<#if logicParam.getParamPSDataEntity?? && logicParam.getParamPSDataEntity()??>
<#assign ParamPSDataEntity=logicParam.getParamPSDataEntity()>
global ${pub.getPKGCodeName()}.core.${ParamPSDataEntity.getPSSystemModule().codeName?lower_case}.domain.${ParamPSDataEntity.codeName} ${logicName+logicParam.codeName?lower_case};
<#else>
global java.util.Map ${logicName+logicParam.codeName?lower_case};
</#if>
</#list>
</#if>
<#comment>插入处理逻辑中所用到的service对象</#comment>
<#if delogic.getPSDELogicNodes?? && delogic.getPSDELogicNodes()??>
<#list delogic.getPSDELogicNodes() as deLogicNode>
<#if deLogicNode.getDstPSDataEntity?? && deLogicNode.getDstPSDataEntity()??>
<#if !P.exists("kieSession",deLogicNode.getDstPSDataEntity().getCodeName()?lower_case,"service")>
<#assign DstPSDataEntity=deLogicNode.getDstPSDataEntity()>
global ${pub.getPKGCodeName()}.core.${DstPSDataEntity.getPSSystemModule().codeName?lower_case}.service.I${DstPSDataEntity.codeName}Service ${deLogicNode.getDstPSDataEntity().getCodeName()?lower_case}service;
</#if>
</#if>
</#list>
<#comment>插入当前实体的defaultService对象,供自定义查询使用</#comment>
global ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().codeName?lower_case}.service.I${de.codeName}Service iBzSys${de.codeName?lower_case?cap_first}DefaultService;
</#if>
no-loop
<#if delogic.getPSDELogicNodes?? && delogic.getPSDELogicNodes()??>
<#list delogic.getPSDELogicNodes() as deLogicNode>
//逻辑处理节点[${deLogicNode.getName()?lower_case}]
rule "${deLogicNode.getCodeName()?lower_case}"
ruleflow-group "${logicName+deLogicNode.getCodeName()?lower_case}"
when
then
<#if deLogicNode.codeName !='Begin'><#comment>开始节点不输出内容</#comment>
<#if deLogicNode.getLogicNodeType()=='PREPAREPARAM' && deLogicNode.getPSDELogicNodeParams()??><#comment>准备参数</#comment>
<#list deLogicNode.getPSDELogicNodeParams() as nodeParam>
<#assign targetLogicParam=nodeParam.getDstPSDELogicParam()>
<#assign targetLogicFieldName=nodeParam.getDstFieldName()>
<#assign targetDEField=((targetLogicParam.getParamPSDataEntity().getPSDEField(targetLogicFieldName))!'')>
<#if nodeParam.getSrcValueType()=='SRCVALUE'><#comment>直接值</#comment>
<#if srfjavatype(targetDEField.stdDataType)=='Integer'>
${logicName+targetLogicParam.getCodeName()?lower_case}.set${targetDEField.codeName?cap_first}(${nodeParam.getSrcValue()});
<#elseif srfjavatype(targetDEField.stdDataType)=='String'>
${logicName+targetLogicParam.getCodeName()?lower_case}.set${targetDEField.codeName?cap_first}("${nodeParam.getSrcValue()}");
<#else>
//暂不支持该数据类型的直接值
</#if>
<#elseif nodeParam.getSrcValueType()=='SRCDLPARAM' ><#comment>源逻辑参数</#comment>
<#assign srcPSDELogicParam=nodeParam.getSrcPSDELogicParam()>
<#assign srcFieldName=nodeParam.getSrcFieldName()>
<#assign srcDEField=((srcPSDELogicParam.getParamPSDataEntity().getPSDEField(srcFieldName))!'') >
<#if srcDEField!='' && targetDEField!=''>
${logicName+targetLogicParam.getCodeName()?lower_case}.set${targetDEField.codeName?cap_first}(${logicName+srcPSDELogicParam.getCodeName()?lower_case}.get${srcDEField.codeName?cap_first}());<#comment>源逻辑参数选择了实体</#comment>
<#else>
//暂不支持逻辑参数无实体模式 属性[${srcFieldName?upper_case}]
</#if>
<#else>
//暂未支持其余准备参数设置
</#if>
</#list>
<#elseif deLogicNode.getLogicNodeType()=='DEACTION'><#comment>调用实体行为</#comment>
<#assign operateEntity=deLogicNode.getDstPSDataEntity()><#comment>操作实体</#comment>
<#assign operateAction=deLogicNode.getDstPSDEAction()><#comment>操作行为</#comment>
<#assign operateParam=deLogicNode.getDstPSDELogicParam()><#comment>操作参数</#comment>
<#assign logicParamEntity=logicName+operateParam.codeName?lower_case>
<#if deLogicNode.getDstPSDEAction()=='Get'>
<#if operateEntity.getKeyPSDEField()??>
<#assign operateEntityKeyField=operateEntity.getKeyPSDEField()?lower_case?cap_first>
${pub.getPKGCodeName()}.util.helper.CachedBeanCopier.copy(${operateEntity.codeName?lower_case}service.get(${logicParamEntity}.get${operateEntityKeyField}()),${logicParamEntity});
<#else>
//操作实体没有主键属性,未能正常发布出get行为
</#if>
<#else>
${operateEntity.codeName?lower_case}service.${operateAction.codeName?uncap_first}(${logicParamEntity});
</#if>
<#elseif deLogicNode.getLogicNodeType()=='RAWSQLCALL'><#comment>直接SQL</#comment>
<#if deLogicNode.getPSDELogicNodeParams()??><#comment>是否包含参数列表</#comment>
String strSql=${getCallSQL(deLogicNode)};
<#else>
String strSql="${srfjavasqlcode('${deLogicNode.getParam("PARAM4","")}')}";
</#if>
java.util.List<JSONObject> entities=iBzSys${de.codeName?lower_case?cap_first}DefaultService.select(strSql);//SQL调用
<#if deLogicNode.getDstPSDELogicParam?? && deLogicNode.getDstPSDELogicParam()?? ><#comment>配置返回参数</#comment>
if(entities.size()>0){
<#assign targetLogicParam=deLogicNode.getDstPSDELogicParam()>
JSONObject entity=entities.get(0);
<#assign targetLogicParamCodeName=logicName+targetLogicParam.getCodeName()?lower_case>
<#if targetLogicParam.getParamPSDataEntity?? && targetLogicParam.getParamPSDataEntity()??>
<#assign targetEntity=targetLogicParam.getParamPSDataEntity()>
<#if (deLogicNode.getParam("PARAM7",1)==0)><#comment>重置原数据</#comment>
${pub.getPKGCodeName()}.core.${targetEntity.getPSSystemModule().codeName?lower_case}.domain.${targetEntity.codeName} targetEntity =new ${pub.getPKGCodeName()}.core.${targetEntity.getPSSystemModule().codeName?lower_case}.domain.${targetEntity.codeName}();
for (Map.Entry entry : entity.entrySet()) {
targetEntity.setFieldValue(String.valueOf(entry.getKey()),entry.getValue());
}
org.springframework.cglib.beans.BeanCopier copier= org.springframework.cglib.beans.BeanCopier.create(targetEntity.getClass(),${targetLogicParamCodeName}.getClass(), false);
copier.copy(targetEntity,${targetLogicParamCodeName},null);
<#else><#comment>不重置原数据</#comment>
for (Map.Entry entry : entity.entrySet()) {
${targetLogicParamCodeName}.setFieldValue(String.valueOf(entry.getKey()),entry.getValue());
}
</#if>
<#else>
${targetLogicParamCodeName}.putAll(entity);
</#if>
}
</#if>
<#elseif deLogicNode.getLogicNodeType()=='RAWSQLANDLOOPCALL'><#comment>直接SQL并循环调用</#comment>
//暂不支持
<#--<#if deLogicNode.getPSDELogicNodeParams()??><#comment>是否包含参数列表</#comment>-->
<#--String strSql=${getCallSQL(deLogicNode)};-->
<#--<#else>-->
<#--String strSql="${srfjavasqlcode('${deLogicNode.getParam("PARAM4","")}')}";-->
<#--</#if>-->
<#--java.util.List<Map<String,Object>> entities=iBzSys${de.codeName?lower_case?cap_first}DefaultService.selectRow(strSql);//SQL调用-->
<#--if(entities.size()>0){-->
<#--<#if deLogicNode.getDstPSDataEntity?? && deLogicNode.getDstPSDataEntity()?? &&deLogicNode.getDstPSDEAction?? && deLogicNode.getDstPSDEAction()??>-->
<#--<#assign targetEntity=deLogicNode.getDstPSDataEntity()>-->
<#--<#assign targetAction=deLogicNode.getDstPSDEAction()>-->
<#--for(Map<String,Object> entity:entities){-->
<#--${pub.getPKGCodeName()}.${targetEntity.getPSSystemModule().codeName?lower_case}.domain.${targetEntity.codeName} targetEntity =new ${pub.getPKGCodeName()}.${targetEntity.getPSSystemModule().codeName?lower_case}.domain.${targetEntity.codeName}();-->
<#--for (Map.Entry<String,Object> entry : entity.entrySet()) {-->
<#--targetEntity.set(entry.getKey(),entry.getValue());-->
<#--}-->
<#--${targetEntity.codeName?lower_case}service.${targetAction.codeName?lower_case}(targetEntity);-->
<#--}-->
<#--</#if>-->
<#--}-->
</#if>
<#if delogic.getPSDELogicParams?? && delogic.getPSDELogicParams()??>
<#list delogic.getPSDELogicParams() as logicParam>
update(${logicName+logicParam.codeName?lower_case});//更新fact中变量值
</#list>
</#if>
</#if>
end
</#list>
</#if>
<#comment>获取String.format拼接的sql</#comment>
<#function getCallSQL deLogicNode>
<#assign sql=srfjavasqlcode('${deLogicNode.getParam("PARAM4","")}')>
<#comment>sql中的?替换为%s ,如:select * from table where id=? ; select * from table where id = '%s' </#comment>
<#assign sql=sql?replace('%','%%')?replace('?','%s')>
<#assign strSQL="String.format(\""+sql+"\",">
<#list deLogicNode.getPSDELogicNodeParams() as nodeParam>
<#assign sqlParam="">
<#if nodeParam.getSrcValueType()=='SRCDLPARAM'><#comment>源逻辑参数</#comment>
<#assign srcPSDELogicParam=nodeParam.getSrcPSDELogicParam()>
<#assign srcFieldName=nodeParam.getSrcFieldName()>
<#if srcPSDELogicParam.getParamPSDataEntity?? && srcPSDELogicParam.getParamPSDataEntity()??><#comment>源逻辑参数选择了实体</#comment>
<#assign sqlParam=logicName+srcPSDELogicParam.getCodeName()?lower_case+".get"+srcFieldName?lower_case?cap_first+"()">
</#if>
<#elseif nodeParam.getSrcValueType()=='SRCVALUE'><#comment>直接值</#comment>
<#assign sqlParam=nodeParam.getSrcValue()>
<#else>
<#assign sqlParam="null"><#comment>暂未支持其余准备参数设置</#comment>
</#if>
<#if nodeParam.getSrcValueType()=='SRCVALUE'>
<#assign strSQL=strSQL+"\""+sqlParam+"\"">
<#else>
<#assign strSQL=strSQL+sqlParam>
</#if>
<#if nodeParam_has_next>
<#assign strSQL=strSQL+",">
</#if>
</#list>
<#assign strSQL=strSQL+")">
<#return strSQL>
</#function>
\ No newline at end of file
<#ibiztemplate>
TARGET=PSDELOGIC
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:g="http://www.jboss.org/drools/flow/gpd" xmlns:tns="http://www.jboss.org/drools" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.mvel.org/2.0" id="Definition" name="" targetNamespace="http://www.jboss.org/drools" typeLanguage="http://www.java.com/javaTypes">
<process id="${pub.getPKGCodeName()}.core.${de.getPSSystemModule().codeName?lower_case}.service.logic.${de.codeName?lower_case}${item.getCodeName()?lower_case}" isClosed="false" isExecutable="true" name="ScoreRule" processType="Private" tns:packageName="${pub.getPKGCodeName()}.core.${de.getPSSystemModule().codeName?lower_case}.service.logic.${de.codeName?lower_case}${item.getCodeName()?lower_case}">
<extensionElements>
<tns:import name="java.util.Map" />
<tns:import name="org.springframework.util.StringUtils"/>
<tns:import name="${pub.getPKGCodeName()}.util.helper.CompareHelper"/>
<#assign logicName=(de.codeName+item.codeName)?lower_case>
<#comment>插入逻辑参数</#comment>
<#if item.getPSDELogicParams?? && item.getPSDELogicParams()??>
<#list item.getPSDELogicParams() as logicParam>
<#if logicParam.getParamPSDataEntity?? && logicParam.getParamPSDataEntity()??>
<#assign ParamPSDataEntity=logicParam.getParamPSDataEntity()>
<tns:global identifier="${logicName+logicParam.codeName?lower_case}" type="${pub.getPKGCodeName()}.core.${ParamPSDataEntity.getPSSystemModule().codeName?lower_case}.domain.${ParamPSDataEntity.codeName}" />
<#else>
</#if>
</#list>
</#if>
</extensionElements>
<#comment>绘制处理节点</#comment>
<#if item.getPSDELogicNodes?? && item.getPSDELogicNodes()??>
<#list item.getPSDELogicNodes() as logicNode>
<#if logicNode.getLogicNodeType()=='BEGIN'>
<startEvent id="${logicNode.getId()}" isInterrupting="true"/>
<#else>
<businessRuleTask activiti:exclusive="true" g:ruleFlowGroup="${logicName+logicNode.getCodeName()?lower_case}" id="${logicNode.getId()}" implementation="http://www.jboss.org/drools/rule" name="${logicNode.getName()}"/>
</#if>
<#if !(logicNode.getPSDELogicLinks()??)><#comment>是否为流程最后一个处理节点,若为最后一个处理节点则生成End节点</#comment>
<endEvent id="${logicNode.getId()}_End" name="End"/>
<sequenceFlow id="${logicNode.getId()}_End_Line" sourceRef="${logicNode.getId()}" targetRef="${logicNode.getId()}_End"/><#comment>生成流程最后一个处理节点与End节点之间的连线</#comment>
</#if>
</#list>
</#if>
<#comment>绘制节点连线</#comment>
<#if item.getPSDELogicLinks?? && item.getPSDELogicLinks()??>
<#list item.getPSDELogicLinks() as LogicLink>
<#assign sourceNodeid=LogicLink.getSrcPSDELogicNode().getId()>
<#if LogicLink.getPSDELogicLinkGroupCond?? && LogicLink.getPSDELogicLinkGroupCond()??><#comment>判断连接线含有条件,若有条件,则将源节点指向网关</#comment>
<#assign sourceNodeid="gateway-"+LogicLink.getSrcPSDELogicNode().getId()>
</#if>
<sequenceFlow id="${LogicLink.getId()}" sourceRef="${sourceNodeid}" targetRef="${LogicLink.getDstPSDELogicNode().getId()}">
<#if LogicLink.getPSDELogicLinkGroupCond?? && LogicLink.getPSDELogicLinkGroupCond()??><#comment>连接线含有条件</#comment>
<conditionExpression language="http://www.jboss.org/drools/rule" ><![CDATA[
<#comment>准备逻辑参数</#comment>
<#if item.getPSDELogicParams?? && item.getPSDELogicParams()??>
<#list item.getPSDELogicParams() as logicParam>
<#if logicParam.getParamPSDataEntity?? && logicParam.getParamPSDataEntity()??>
<#assign ParamPSDataEntity=logicParam.getParamPSDataEntity()>
$${logicName+logicParam.codeName?lower_case}:${ParamPSDataEntity.codeName}();
<#else>
$${logicName+logicParam.codeName?lower_case}:Map();
</#if>
</#list>
<#assign strExpCond=getConditionExpression(item)>
eval(${strExpCond});<#comment>在fact中寻找与global中对应参数</#comment>
</#if>
<#assign LogicLinkCond=LogicLink.getPSDELogicLinkGroupCond()>
<#assign strGroupCond=getGroupCond(LogicLinkCond)>
<#assign strGroupCond=strGroupCond?replace("ISNOTNULL","!=NULL")?replace("ISNULL","==NULL")?replace("AND","&&")?replace("OR","||")?replace("GT&&EQ",">=")?replace("LT&&EQ","<=")?replace("NOTEQ","!=")?replace("EQ","==")?replace("GT",">")?replace("LT","<") >
eval${strGroupCond}
]]>
</conditionExpression>
</#if>
</sequenceFlow>
</#list>
</#if>
<#comment>生成交互网关节点</#comment>
<#if item.getPSDELogicLinks?? && item.getPSDELogicLinks()??>
<#list item.getPSDELogicLinks() as LogicLink>
<#if LogicLink.getPSDELogicLinkGroupCond?? && LogicLink.getPSDELogicLinkGroupCond()??><#comment>连接线含有条件</#comment>
<#assign gatewayid="gateway-"+LogicLink.getSrcPSDELogicNode().getId()>
<#if !P.exists("gateway",gatewayid)>
<#comment>绘制网关</#comment>
<exclusiveGateway id="${gatewayid}" name="Gateway" gatewayDirection="Diverging" default="${gatewayid}_End_Line"></exclusiveGateway>
<#comment>绘制网关与源节点的连线</#comment>
<sequenceFlow id="${LogicLink.getId()}-gatewayline" sourceRef="${LogicLink.getSrcPSDELogicNode().getId()}" targetRef="${gatewayid}"></sequenceFlow>
</#if>
<#comment>绘制网关默认结束节点</#comment>
<#if !P.exists("gateway-end",gatewayid)>
<sequenceFlow id="${gatewayid}_End_Line" sourceRef="${gatewayid}" targetRef="${gatewayid}_End"/><#comment>生成流程最后一个处理节点与End节点之间的连线</#comment>
<endEvent id="${gatewayid}_End" name="End"/>
</#if>
</#if>
</#list>
</#if>
</process>
</definitions>
<#comment>获取组合条件表达式</#comment>
<#function getGroupCond LogicLinkCond>
<#assign strRuleCond="(">
<#if LogicLinkCond.getPSDELogicLinkConds?? && LogicLinkCond.getPSDELogicLinkConds()??><#comment>判断是否有组条件</#comment>
<#assign conn=LogicLinkCond.getGroupOP()>
<#list LogicLinkCond.getPSDELogicLinkConds() as childLogicLinkCond><#comment>组条件,递归</#comment>
<#if childLogicLinkCond.getPSDELogicLinkConds?? && childLogicLinkCond.getPSDELogicLinkConds()??>
<#assign strRuleCond=strRuleCond+getGroupCond(childLogicLinkCond)>//getGroupCond
<#else>
<#assign strRuleCond=strRuleCond+getFieldCond(childLogicLinkCond)>//getFieldCond
</#if>
<#if childLogicLinkCond_has_next>
<#assign strRuleCond=strRuleCond+conn>//拼接连接符
</#if>
</#list>
</#if>
<#assign strRuleCond=strRuleCond+")">
<#return strRuleCond/>
</#function>
<#comment>获取单项条件表达式</#comment>
<#function getFieldCond LogicLinkCond>
<#assign fieldCond="(" >
<#assign condBody="">
<#assign targetParam=LogicLinkCond.getDstLogicParam()><#comment>目标参数</#comment>
<#assign targetFieldName=LogicLinkCond.getDstFieldName()><#comment>目标属性名称</#comment>
<#assign targetDEField=((targetParam.getParamPSDataEntity().getPSDEField(targetFieldName))!'')><#comment>目标属性</#comment>
<#assign targetDBValueOP=LogicLinkCond.getPSDBValueOPId()><#comment>表达式</#comment>
<#assign targetValue=LogicLinkCond.getValue()><#comment>值项</#comment>
<#if targetDEField!=''>
<#if targetDBValueOP=="ISNULL">
<#assign condBody="StringUtils.isEmpty($"+logicName+targetParam.getCodeName()?lower_case+".get"+targetDEField.codeName?cap_first+"()"+")">
<#elseif targetDBValueOP=="ISNOTNULL">
<#assign condBody="!StringUtils.isEmpty($"+logicName+targetParam.getCodeName()?lower_case+".get"+targetDEField.codeName?cap_first+"()"+")">
<#else>
<#assign condBody="CompareHelper.compare($"+logicName+targetParam.getCodeName()?lower_case+".get"+targetDEField.codeName?cap_first+"(),"+"\""+targetValue+"\","+"\""+targetDBValueOP+"\")">
</#if>
</#if>
<#assign fieldCond=fieldCond+condBody >
<#assign fieldCond=fieldCond+")" >
<#return fieldCond/>
</#function>
<#comment>获取conditionExpression</#comment>
<#function getConditionExpression LogicParams>
<#assign expressionCond="" >
<#list LogicParams.getPSDELogicParams() as logicParam>
<#assign condBody="">
<#if logicParam.getParamPSDataEntity?? && logicParam.getParamPSDataEntity()??>
<#assign condBody='$'+logicName+logicParam.codeName?lower_case+'=='+logicName+logicParam.codeName?lower_case>
<#if logicParam_has_next>
<#assign condBody=condBody+" && ">
</#if>
<#else>
//暂未实现
</#if>
<#assign expressionCond=expressionCond+condBody >
</#list>
<#return expressionCond/>
</#function>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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}-dependencies</artifactId>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<version>${pub.getVersionString()?default("V0.0.1_alpha")}</version>
<name>${pub.getCodeName()?lower_case?cap_first} Dependencies</name>
<packaging>pom</packaging>
<description>${pub.getCodeName()?lower_case?cap_first} Dependencies</description>
<!-- Spring Boot -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
</parent>
<#-- properties, usually record jars version constants -->
<properties>
<!-- Spring Cloud Alibaba(2.1.x.RELEASE) & Spring Cloud(Spring Cloud Greenwich) & Spring Boot(2.1.x.RELEASE) compatibility -->
<spring-cloud-alibaba.version>2.1.1.RELEASE</spring-cloud-alibaba.version>
<spring-cloud-openfeign.version>2.2.1.RELEASE</spring-cloud-openfeign.version>
<!-- Alibaba Druid -->
<alibaba-druid.version>1.1.16</alibaba-druid.version>
<!-- Mybatis Plus -->
<mybatis-plus.version>3.3.1</mybatis-plus.version>
<mybatis-plus-dynamic-datasource.version>3.0.0</mybatis-plus-dynamic-datasource.version>
<!-- Liquibase -->
<liquibase.version>3.6.3</liquibase.version>
<!-- Swagger2 -->
<springfox-swagger.version>2.9.2</springfox-swagger.version>
<!-- JBPM+Drools -->
<drools-version>7.23.0.Final</drools-version>
<!-- Error -->
<zalando-problem-spring-web.version>0.23.0</zalando-problem-spring-web.version>
<!-- Security -->
<spring-cloud-security.version>2.1.1.RELEASE</spring-cloud-security.version>
<!-- Activity -->
<activiti.version>7.1.0.M2</activiti.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<!--logstash-logback-encoder-->
<logstash.version>5.2</logstash.version>
<!--Zuul网关-->
<spring-cloud-starter-netflix-zuul.version>2.2.1.RELEASE</spring-cloud-starter-netflix-zuul.version>
<!--MapStruct高性能属性映射工具-->
<mapstruct.version>1.3.0.Final</mapstruct.version>
<!--Java Web Token-->
<jsonwebtoken-jjwt.version>0.9.1</jsonwebtoken-jjwt.version>
<!--Liquibase数据库版本更新工具-->
<liquibase.version>3.6.3</liquibase.version>
</properties>
<#-- dependencies,just for statement, manage the version of jars -->
<dependencyManagement>
<dependencies>
<!-- Alibaba Cloud -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${r'${spring-cloud-alibaba.version}'}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- Spring Cloud -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign-dependencies</artifactId>
<version>${r'${spring-cloud-openfeign.version}'}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- Alibaba Druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${r'${alibaba-druid.version}'}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${r'${alibaba-druid.version}'}</version>
</dependency>
<!-- Mybatis Plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${r'${mybatis-plus.version}'}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>${r'${mybatis-plus-dynamic-datasource.version}'}</version>
</dependency>
<!-- Liquibase -->
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>${r'${liquibase.version}'}</version>
</dependency>
<!-- Swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${r'${springfox-swagger.version}'}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${r'${springfox-swagger.version}'}</version>
</dependency>
<!-- JBPM -->
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-flow-builder</artifactId>
<version>${r'${drools-version}'}</version>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-bpmn2</artifactId>
<version>${r'${drools-version}'}</version>
</dependency>
<!-- Drools -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${r'${drools-version}'}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${r'${drools-version}'}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-spring</artifactId>
<version>${r'${drools-version}'}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>${r'${drools-version}'}</version>
</dependency>
<!-- Activiti -->
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter</artifactId>
<version>${r'${activiti.version}'}</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-json-converter</artifactId>
<version>${r'${activiti.version}'}</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-image-generator</artifactId>
<version>${r'${activiti.version}'}</version>
</dependency>
<!-- Error -->
<#--<dependency>-->
<#--<groupId>org.zalando</groupId>-->
<#--<artifactId>problem-spring-web</artifactId>-->
<#--<version>${r'${zalando-problem-spring-web.version}'}</version>-->
<#--</dependency>-->
<!-- Security -->
<#--<dependency>-->
<#--<groupId>org.springframework.cloud</groupId>-->
<#--<artifactId>spring-cloud-starter-security</artifactId>-->
<#--<version>${r'${spring-cloud-security.version}'}</version>-->
<#--</dependency>-->
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>${r'${logstash.version}'}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
<version>${r'${spring-cloud-starter-netflix-zuul.version}'}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<version>${r'${mapstruct.version}'}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${r'${mapstruct.version}'}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
<version>${r'${spring-cloud-security.version}'}</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>${r'${jsonwebtoken-jjwt.version}'}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${r'${alibaba-druid.version}'}</version>
</dependency>
<dependency>
<groupId>org.zalando</groupId>
<artifactId>problem-spring-web</artifactId>
<version>${r'${zalando-problem-spring-web.version}'}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Spring Boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Spring Cloud -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- Httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<!-- MySQL驱动包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- 阿里Druid数据源 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<!-- Error -->
<#--<dependency>-->
<#--<groupId>org.zalando</groupId>-->
<#--<artifactId>problem-spring-web</artifactId>-->
<#--</dependency>-->
<!-- Security -->
<#--<dependency>-->
<#--<groupId>org.springframework.cloud</groupId>-->
<#--<artifactId>spring-cloud-starter-security</artifactId>-->
<#--</dependency>-->
</dependencies>
</project>
<#ibiztemplate>
TARGET=PSSYSSERVICEAPI
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>
<parent>
<artifactId>${pub.getCodeName()?lower_case}-provider</artifactId>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<version>${pub.getVersionString()?default("V0.0.1_alpha")}</version>
</parent>
<artifactId>${pub.getCodeName()?lower_case}-provider-${api.getCodeName()?lower_case}</artifactId>
<name>${pub.getCodeName()?lower_case?cap_first} Microservice ${api.getCodeName()}</name>
<description>${pub.getMemo()?default(pub.getName())} ${api.getName()}</description>
<dependencies>
<dependency>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<artifactId>${pub.getCodeName()?lower_case}-core</artifactId>
<version>${r'${project.version}'}</version>
</dependency>
<!-- Swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
</dependencies>
<properties>
<docker.image.prefix>registry.cn-shanghai.aliyuncs.com/ibizsys</docker.image.prefix>
</properties>
<profiles>
<profile>
<id>${item.codeName?lower_case}</id>
<build>
<resources>
<resource>
<directory>${r'${basedir}'}/src/main/resources</directory>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>${pub.getCodeName()?lower_case}-provider-${item.codeName?lower_case}</finalName>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<mainClass>${pub.getPKGCodeName()}.${item.codeName?lower_case}.${sys.codeName}${item.codeName}Application</mainClass>
<outputDirectory>../../</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<serverId>ibiz-dev</serverId>
<imageName>${r'${docker.image.prefix}/${project.artifactId}'}:latest</imageName>
<dockerDirectory>${r'${project.basedir}'}/src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>../../</directory>
<include>${r'${project.artifactId}'}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
<#ibiztemplate>
TARGET=PSSYSSERVICEAPI
</#ibiztemplate>
<#assign httpPort = "8081">
<#if sysrun?? >
<#if sysrun.getPSDevSlnMSDepAPI()??>
<#if sysrun.getPSDevSlnMSDepAPI().getHttpPort()??>
<#assign httpPort = sysrun.getPSDevSlnMSDepAPI().getHttpPort()?c>
</#if>
</#if>
</#if>
version: "3.2"
services:
${pub.getCodeName()?lower_case}-provider-${api.getCodeName()?lower_case}:
image: registry.cn-shanghai.aliyuncs.com/ibizsys/${pub.getCodeName()?lower_case}-provider-${api.getCodeName()?lower_case}:latest
ports:
- "${httpPort}:${httpPort}"
networks:
- agent_network
deploy:
mode: replicated
replicas: 1
networks:
agent_network:
driver: overlay
attachable: true
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSSERVICEAPI
</#ibiztemplate>
<#assign httpPort = "8081">
<#if sysrun?? >
<#if sysrun.getPSDevSlnMSDepAPI()??>
<#if sysrun.getPSDevSlnMSDepAPI().getHttpPort()??>
<#assign httpPort = sysrun.getPSDevSlnMSDepAPI().getHttpPort()?c>
</#if>
</#if>
</#if>
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}-provider-${api.getCodeName()?lower_case}.jar
EXPOSE ${httpPort}
ADD ${pub.getCodeName()?lower_case}-provider-${api.getCodeName()?lower_case}.jar /${pub.getCodeName()?lower_case}-provider-${api.getCodeName()?lower_case}.jar
<#ibiztemplate>
TARGET=PSSYSSERVICEAPI
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${item.codeName?lower_case};
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.mybatis.spring.annotation.MapperScan;
@Slf4j
@EnableDiscoveryClient
@Configuration
@EnableTransactionManagement
@ComponentScan(basePackages = {"${pub.getPKGCodeName()}"})
@EnableMongoRepositories(basePackages = {"${pub.getPKGCodeName()}"})
@MapperScan("${pub.getPKGCodeName()}.*.mapper")
@SpringBootApplication(exclude = {
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
})
public class ${sys.codeName}${item.codeName}Application{
public static void main(String[] args) {
SpringApplication.run(${sys.codeName}${item.codeName}Application.class, args);
}
}
<#ibiztemplate>
TARGET=PSSYSSERVICEAPI
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${item.getCodeName()?lower_case}.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
@Configuration
@ConditionalOnClass(${item.codeName}RestConfiguration.class)
@ConditionalOnWebApplication
@EnableConfigurationProperties(${item.codeName}ServiceProperties.class)
public class ${item.codeName}AutoConfiguration implements ApplicationContextAware{
protected ApplicationContext applicationContext;
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
// @Bean
// public ServletRegistrationBean ${item.codeName?lower_case}Servlet() {
// AnnotationConfigWebApplicationContext dispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();
// dispatcherServletConfiguration.setParent(applicationContext);
// dispatcherServletConfiguration.register(${item.codeName}RestConfiguration.class);
// DispatcherServlet servlet = new DispatcherServlet(dispatcherServletConfiguration);
// String path = "/${item.codeName?lower_case}";
// String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*");
// ServletRegistrationBean registrationBean = new ServletRegistrationBean(servlet, urlMapping);
// registrationBean.setName("${item.codeName}");
// return registrationBean;
// }
}
<#ibiztemplate>
TARGET=PSSYSSERVICEAPI
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${item.getCodeName()?lower_case}.config;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan("${pub.getPKGCodeName()}.${item.getCodeName()?lower_case}")
public class ${item.codeName}RestConfiguration {
}
<#ibiztemplate>
TARGET=PSSYSSERVICEAPI
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${item.getCodeName()?lower_case}.config;
import ${pub.getPKGCodeName()}.util.security.AuthenticationEntryPoint;
import ${pub.getPKGCodeName()}.util.security.AuthorizationTokenFilter;
import ${pub.getPKGCodeName()}.util.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;
import org.springframework.context.annotation.Profile;
@Profile("${item.getCodeName()?lower_case}-prod")
@Configuration
@EnableWebSecurity
public class ${item.codeName}SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private AuthenticationEntryPoint unauthorizedHandler;
@Autowired
private AuthenticationUserService userDetailsService;
/**
* 自定义基于JWT的安全过滤器
*/
@Autowired
AuthorizationTokenFilter authenticationTokenFilter;
@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()
// 服务中暂时只为重构用户身份,不进行身份认证
.anyRequest().permitAll()
// 防止iframe 造成跨域
.and().headers().frameOptions().disable();
httpSecurity
.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
}
}
<#ibiztemplate>
TARGET=PSSYSSERVICEAPI
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${item.getCodeName()?lower_case}.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import lombok.Data;
@ConfigurationProperties(prefix = "service.${item.codeName?lower_case}")
@Data
public class ${item.codeName}ServiceProperties {
private boolean enabled;
private boolean auth;
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSDESERVICEAPI
</#ibiztemplate>
<#comment>不发布子系统实体</#comment>
<#if de.isSubSysDE()==false>
<#assign pubPkgCodeName = pub.getPKGCodeName()>
<#assign itemSysApiCodeNameLC = item.getPSSysServiceAPI().getCodeName()?lower_case>
package ${pubPkgCodeName}.${itemSysApiCodeNameLC}.dto;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.math.BigInteger;
import java.util.Map;
import java.util.HashMap;
import java.io.Serializable;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.alibaba.fastjson.annotation.JSONField;
import ${pub.getPKGCodeName()}.util.domain.DTOBase;
import lombok.Data;
/**
* 服务DTO对象[${item.getCodeName()}DTO]
*/
@Data
public class ${item.getCodeName()}DTO extends DTOBase implements Serializable {
private static final long serialVersionUID = 1L;
<#if item.getPSDEServiceAPIFields()??>
<#comment>接口属性集合</#comment>
<#list item.getPSDEServiceAPIFields() as apifield>
<#assign defDataType = (apifield.getPSDEField().getDataType())!"">
<#assign columnname = apifield.getName()?lower_case>
<#assign prvateCodeName = srfcaseformat(apifield.getCodeName(),'l_u2lC') >
<#assign publicCodeName = prvateCodeName?cap_first >
<#assign jsonfield = apifield.getCodeName()?lower_case >
<#if defDataType!='ONE2MANYDATA'>
/**
* 属性 [${apifield.getName()}]
*
*/
<#if defDataType == "DATETIME" || (defDataType=='PICKUPDATA' && srfdatatype(apifield.getStdDataType())== "DATETIME" && apifield.getPSDEField().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")
@JSONField(name = "${jsonfield}" , format="yyyy-MM-dd HH:mm:ss")
<#elseif defDataType == "DATE" || (defDataType=='PICKUPDATA' && srfdatatype(apifield.getStdDataType())== "DATETIME" && apifield.getPSDEField().getValueFormat()=="%1$tY-%1$tm-%1$td")>
@JsonFormat(pattern="yyyy-MM-dd", locale = "zh" , timezone="GMT+8")
@JSONField(name = "${jsonfield}" , format="yyyy-MM-dd")
<#elseif defDataType == "TIME" || (defDataType=='PICKUPDATA' && srfdatatype(apifield.getStdDataType())== "DATETIME" && apifield.getPSDEField().getValueFormat()=="%1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="HH:mm", locale = "zh" , timezone="GMT+8")
@JSONField(name = "${jsonfield}" , format="HH:mm")
<#else>
@JSONField(name = "${jsonfield}")
</#if>
@JsonProperty("${jsonfield}")
private ${srfjavatype(apifield.getStdDataType())} ${prvateCodeName};
</#if>
</#list>
</#if>
<#comment>输出set方法用于设置null</#comment>
<#list item.getPSDEServiceAPIFields() as apifield>
<#assign defield = apifield.getPSDEField() >
<#assign defDataType = (defield.getDataType())!"">
<#assign columnname = apifield.getName()?lower_case>
<#assign prvateCodeName = srfcaseformat(apifield.getCodeName(),'l_u2lC') >
<#assign publicCodeName = prvateCodeName?cap_first >
<#if defield.isPhisicalDEField()==true && defield.isKeyDEField()==false && defDataType!='ONE2MANYDATA'>
<#if defield.getPredefinedType()?? && defield.getPredefinedType()!=''>
<#else >
/**
* 设置 [${apifield.getName()}]
*/
public void set${publicCodeName}(${srfjavatype(apifield.getStdDataType())} ${prvateCodeName}){
this.${prvateCodeName} = ${prvateCodeName} ;
this.modify("${columnname}",${prvateCodeName});
}
</#if>
</#if>
</#list>
<#comment>输出关系数据(子实体)</#comment>
<#if item.getPSDEServiceAPIRSs()?? >
<#list item.getPSDEServiceAPIRSs() as apider>
<#assign der = apider.getPSDER1N() >
<#if apider.getMinorPSDEServiceAPI().isNested()>
<#assign subDTOs = srfpluralize(apider.getMinorPSDEServiceAPI().getCodeName())?lower_case >
<#assign subcode = srfcaseformat((der.getMinorCodeName()!der.getMinorPSDataEntity().getCodeName()),'l_u2lC') >
<#if subcode?? && subcode==''><#assign subcode=srfcaseformat(der.getMinorPSDataEntity().getCodeName(),'l_u2lC')></#if>
/**
* [${apider.getMinorPSDEServiceAPI().getName()}]
*/
@JsonProperty("${subDTOs}")
@JSONField(name = "${subDTOs}")
private List<${apider.getMinorPSDEServiceAPI().getCodeName()}DTO> ${subcode} ;
</#if>
</#list>
</#if>
}
</#if>
\ No newline at end of file
<#ibiztemplate>
TARGET=PSDESERVICEAPI
</#ibiztemplate>
<#comment>不发布子系统实体</#comment>
<#if de.isSubSysDE()==false && de.getAllPSDEServiceAPIs()??>
<#assign pubPkgCodeName = pub.getPKGCodeName()>
<#assign itemSysApiCodeNameLC = item.getPSSysServiceAPI().getCodeName()?lower_case>
package ${pubPkgCodeName}.${itemSysApiCodeNameLC}.mapping;
import org.mapstruct.*;
import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.domain.${de.codeName};
import ${pubPkgCodeName}.${itemSysApiCodeNameLC}.dto.${item.getCodeName()}DTO;
import ${pub.getPKGCodeName()}.util.domain.MappingBase;
import org.mapstruct.factory.Mappers;
@Mapper(componentModel = "spring", uses = {},
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE,
nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface ${item.getCodeName()}Mapping extends MappingBase<${item.codeName}DTO, ${de.codeName}> {
<#--<#comment>输出关系数据(子实体)</#comment>-->
<#--<#if item.getPSDEServiceAPIRSs()?? >-->
<#--<#assign nested=false>-->
<#--<#assign first=true>-->
<#--<#list item.getPSDEServiceAPIRSs() as apider>-->
<#--<#assign der = apider.getPSDER1N() >-->
<#--<#if apider.getMinorPSDEServiceAPI().isNested() && der.getMinorPSDataEntity().getStorageMode()==1>-->
<#--<#assign nested=true>-->
<#--<#if first==true>-->
<#--@Mappings({-->
<#--</#if>-->
<#--<#assign subcode = srfcaseformat((der.getMinorCodeName()!der.getMinorPSDataEntity().getCodeName()),'l_u2lC') >-->
<#--<#if first==false>,</#if>@Mapping(target = "${subcode}", ignore = true )-->
<#--<#assign first=false>-->
<#--</#if>-->
<#--</#list>-->
<#--<#if nested==true>-->
<#--})-->
<#--@Override-->
<#--${item.codeName}DTO toDto(${de.codeName} entity);-->
<#--</#if>-->
<#--</#if>-->
}
</#if>
<#ibiztemplate>
TARGET=PSDESERVICEAPI
</#ibiztemplate>
<#comment>不发布子系统实体</#comment>
<#if de.isSubSysDE()==false>
<#-- SYSAPIRESTFUL,主从接口(非嵌套) -->
<#if api.getAPIType() == "RESTFUL" && !item.isNested()>
<#assign pubPkgCodeName = pub.getPKGCodeName()>
<#assign itemCodeName = item.getCodeName()>
<#assign itemCodeNameLC = itemCodeName?lower_case>
<#assign deCodeName = de.getCodeName()>
<#assign deCodeNameLC = deCodeName?lower_case>
<#assign dePKCodeNameLC = srfcaseformat(de.getKeyPSDEField().getCodeName(),'l_u2lC')>
<#assign dePKCodeName = (dePKCodeNameLC)?cap_first>
<#assign deModelCodeNameLC = de.getPSSystemModule().getCodeName()?lower_case>
<#assign itemSysApiCodeName = item.getPSSysServiceAPI().getCodeName()>
<#assign itemSysApiCodeNameLC = item.getPSSysServiceAPI().getCodeName()?lower_case>
<#assign keyCNLC = "_id">
package ${pubPkgCodeName}.${itemSysApiCodeNameLC}.rest;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.math.BigInteger;
import java.util.HashMap;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.ServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
<#if de.getStorageMode()==4><#else>import org.springframework.transaction.annotation.Transactional;</#if>
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.http.HttpStatus;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import ${pubPkgCodeName}.${itemSysApiCodeNameLC}.dto.*;
import ${pubPkgCodeName}.${itemSysApiCodeNameLC}.mapping.*;
import ${pubPkgCodeName}.core.${deModelCodeNameLC}.domain.${deCodeName};
import ${pubPkgCodeName}.core.${deModelCodeNameLC}.service.I${deCodeName}Service;
import ${pubPkgCodeName}.core.${deModelCodeNameLC}.filter.${deCodeName}SearchContext;
<#if item.getPSDEServiceAPIRSs()??>
<#list item.getPSDEServiceAPIRSs() as apider>
<#assign deapide=apider.getMinorPSDEServiceAPI().getPSDataEntity()>
<#assign deapideCN=deapide.getCodeName()>
<#assign deapideModuleCNLC=deapide.getPSSystemModule().getCodeName()?lower_case>
<#if apider.getMinorPSDEServiceAPI().isNested() && (deapide.getStorageMode()==1||deapide.getStorageMode()==2||deapide.getStorageMode()==4) >
import ${pubPkgCodeName}.core.${deapideModuleCNLC}.filter.${deapideCN}SearchContext;
import ${pubPkgCodeName}.core.${deapideModuleCNLC}.domain.${deapideCN};
import ${pubPkgCodeName}.core.${deapideModuleCNLC}.service.I${deapideCN}Service;
</#if>
</#list>
</#if>
@Slf4j
@Api(tags = {"${itemCodeName}" })
<#comment>两个服务接口引用同一个实体时,会产生两个Resource,通过dev模式代理启动两个服务时,会产生bean同名冲突,所以需要进行区分</#comment>
@RestController("${itemSysApiCodeName}-${itemCodeName?lower_case}")
@RequestMapping("")
public class ${itemCodeName}Resource {
@Autowired
private I${deCodeName}Service ${deCodeNameLC}Service;
@Autowired
@Lazy
private ${itemCodeName}Mapping ${itemCodeNameLC}Mapping;
<#-- 嵌套服务对象 -->
<#if item.getPSDEServiceAPIRSs()??>
<#list item.getPSDEServiceAPIRSs() as apider>
<#assign deapide=apider.getMinorPSDEServiceAPI().getPSDataEntity()>
<#assign deapideCN=deapide.getCodeName()>
<#assign deapideModuleCNLC=deapide.getPSSystemModule().getCodeName()?lower_case>
<#if apider.getMinorPSDEServiceAPI().isNested() && (deapide.getStorageMode()==1||deapide.getStorageMode()==2||deapide.getStorageMode()==4)>
@Autowired
private I${deapideCN}Service ${deapideCN?lower_case}Service;
</#if>
</#list>
</#if>
<#-- 主接口 start -->
<#if item.isMajor()>
<#--<#assign parentPath = "/" + item.getPSSysServiceAPI().getCodeName()?lower_case >-->
<#--<#assign selfPath="/" + srfpluralize(itemCodeNameLC) >-->
<#assign parentPath = "" >
<#assign selfPath= "/" +srfpluralize(itemCodeNameLC) >
<#assign parentParams = "">
<#assign parentSearchParams = "" >
<#assign parentParams2 = "">
<#assign parentParams3 = "">
<#assign idParams = "">
<#assign idParams2 = "">
<#assign idParams3 = "">
<#assign etParams = "">
<#assign etParamsList = "">
<#assign etParams2 = "">
<#assign etParams3 = "">
<#assign id_etParams = "">
<#assign id_etParams4 = "">
<#assign id_etParams4_batch = "">
<#assign etParams = etParams + "@RequestBody " + itemCodeName + "DTO " + itemCodeNameLC + "dto">
<#assign etParamsList = etParamsList + "@RequestBody List<" + itemCodeName + "DTO> " + itemCodeNameLC + "dtos">
<#assign etParams2 = etParams2 + itemCodeName + "DTO " + itemCodeNameLC + "dto">
<#assign etParams3 = etParams3 + itemCodeNameLC + "dto">
<#assign idParams = idParams + "@PathVariable(\"" + itemCodeNameLC + keyCNLC + "\") " + srfjavatype(de.getKeyPSDEField().getStdDataType()) + " " + itemCodeNameLC + keyCNLC >
<#assign idParams2 = idParams2 + " " + srfjavatype(de.getKeyPSDEField().getStdDataType()) + " " + itemCodeNameLC + keyCNLC >
<#assign idParams3 = idParams3 + " " + itemCodeNameLC + keyCNLC >
<#assign id_etParams = id_etParams + "@PathVariable(\"" + itemCodeNameLC + keyCNLC + "\") " + srfjavatype(de.getKeyPSDEField().getStdDataType())+" " + itemCodeNameLC + keyCNLC + ", @RequestBody " + itemCodeName + "DTO " + itemCodeNameLC + "dto" >
<#assign id_etParams4 = id_etParams4 + "@RequestBody " + itemCodeName + "DTO " + itemCodeNameLC + "dto" >
<#assign id_etParams4_batch = id_etParams4_batch + "@RequestBody List<" + itemCodeName + "DTO> " + itemCodeNameLC + "dtos" >
<#assign fullPath = parentPath + selfPath>
<#if item.getPSDEServiceAPIMethods()??>
<#list item.getPSDEServiceAPIMethods() as apiMethod>
<#assign reqMtd = apiMethod.getRequestMethod()>
<#assign statusCode = "">
<#if reqMtd == "POST" >
<#assign statusCode = "HttpStatus.CREATED" >
<#else>
<#assign statusCode = "HttpStatus.OK" >
</#if>
<#if apiMethod.getActionType()=='DEACTION'>
<#assign deaction = apiMethod.getPSDEAction()>
<#assign deactionName = deaction.getName()>
<#assign deactionCodeName = deaction.getCodeName()>
<#if deaction.codeName?lower_case == 'create'>
@PreAuthorize("hasPermission('','CREATE',this.getEntity())")
@ApiOperation(value = "${deaction.getLogicName()}", tags = {"${itemCodeName}" }, notes = "${deaction.getLogicName()}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}")
<#if de.getStorageMode()==4><#else> @Transactional</#if>
public ResponseEntity<${itemCodeName}DTO> create(${etParams}) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
${deCodeNameLC}Service.create(domain);
${itemCodeName}DTO dto = ${itemCodeNameLC}Mapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@PreAuthorize("hasPermission('','CREATE',this.getEntity())")
@ApiOperation(value = "createBatch", tags = {"createBatch" }, notes = "createBatch")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/createbatch")
public ResponseEntity<Boolean> createBatch(${etParamsList}) {
${deCodeNameLC}Service.createBatch(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
<#elseif deaction.codeName?lower_case == 'update'>
@PreAuthorize("hasPermission(#${itemCodeNameLC + keyCNLC},'UPDATE',this.getEntity())")
@ApiOperation(value = "${deaction.getLogicName()}", tags = {"${itemCodeName}" }, notes = "${deaction.getLogicName()}")
@RequestMapping(method = RequestMethod.PUT, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
<#if de.getStorageMode()==4><#else> @Transactional</#if>
public ResponseEntity<${itemCodeName}DTO> update(${id_etParams}) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
domain.set${dePKCodeName}(${itemCodeNameLC + keyCNLC});
${deCodeNameLC}Service.update(domain);
${itemCodeName}DTO dto = ${itemCodeNameLC}Mapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@PreAuthorize("hasPermission(#${itemCodeNameLC + keyCNLC},'UPDATE',this.getEntity())")
@ApiOperation(value = "UpdateBatch", tags = {"UpdateBatch" }, notes = "UpdateBatch")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/updatebatch")
public ResponseEntity<Boolean> updateBatch(${etParamsList}) {
${deCodeNameLC}Service.updateBatch(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
<#elseif deaction.codeName?lower_case == 'save'>
@ApiOperation(value = "${deaction.getLogicName()}", tags = {"${itemCodeName}" }, notes = "${deaction.getLogicName()}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}")
public ResponseEntity<Boolean> save(${etParams}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.save(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto)));
}
@ApiOperation(value = "SaveBatch", tags = {"SaveBatch" }, notes = "SaveBatch")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/savebatch")
public ResponseEntity<Boolean> saveBatch(${etParamsList}) {
${deCodeNameLC}Service.saveBatch(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
<#elseif deaction.codeName?lower_case == 'remove'>
@PreAuthorize("hasPermission('DELETE',{#${itemCodeNameLC + keyCNLC},this.getEntity()})")
@ApiOperation(value = "${deaction.getLogicName()}", tags = {"${itemCodeName}" }, notes = "${deaction.getLogicName()}")
@RequestMapping(method = RequestMethod.DELETE, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
<#if de.getStorageMode()==4><#else> @Transactional</#if>
public ResponseEntity<Boolean> remove(${idParams}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.remove(${itemCodeNameLC + keyCNLC}));
}
@ApiOperation(value = "RemoveBatch", tags = {"RemoveBatch" }, notes = "RemoveBatch")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/removebatch")
public ResponseEntity<Boolean> removeBatch(@RequestBody List<${srfjavatype(de.getKeyPSDEField().getStdDataType())}> ids) {
${deCodeNameLC}Service.removeBatch(ids);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
<#elseif deaction.codeName?lower_case == 'get'>
@PreAuthorize("hasPermission(#${itemCodeNameLC + keyCNLC},'READ',this.getEntity())")
@ApiOperation(value = "${deaction.getLogicName()}", tags = {"${itemCodeName}" }, notes = "${deaction.getLogicName()}")
@RequestMapping(method = RequestMethod.GET, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
public ResponseEntity<${itemCodeName}DTO> get(${idParams}) {
${deCodeName} domain = ${deCodeNameLC}Service.get(${itemCodeNameLC + keyCNLC});
${itemCodeName}DTO dto = ${itemCodeNameLC}Mapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
<#elseif deaction.codeName?lower_case == 'checkkey'>
@ApiOperation(value = "${deaction.getLogicName()}", tags = {"${itemCodeName}" }, notes = "${deaction.getLogicName()}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}")
public ResponseEntity<Boolean> checkKey(${etParams}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.checkKey(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto)));
}
<#elseif deaction.codeName?lower_case == 'getdraft'><#comment>前端支持临时模式,后台不做处理</#comment>
@ApiOperation(value = "${deaction.getLogicName()}", tags = {"${itemCodeName}" }, notes = "${deaction.getLogicName()}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}")
public ResponseEntity<${itemCodeName}DTO> ${deactionCodeName?uncap_first}() {
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC}Mapping.toDto(${deCodeNameLC}Service.getDraft(new ${deCodeName}())));
}
<#elseif deaction.codeName?lower_case == 'createbatch'>
<#elseif deaction.codeName?lower_case == 'updatebatch'>
<#elseif deaction.codeName?lower_case == 'removebatch'>
<#elseif deaction.codeName?lower_case == 'savebatch'>
<#elseif deaction.getUserTag()?? && deaction.getActionType()?? && deaction.getUserTag() == 'REGIST' && deaction.getActionType() == 'USERCREATE'>
<#else>
@ApiOperation(value = "${deaction.getLogicName()}", tags = {"${itemCodeName}" }, notes = "${deaction.getLogicName()}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/${deactionCodeName?lower_case}")
<#if de.getStorageMode()==4><#else> @Transactional</#if>
public ResponseEntity<${itemCodeName}DTO> ${deactionCodeName?uncap_first}(${id_etParams}) {
${deCodeName} ${deCodeNameLC} = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
${deCodeNameLC} = ${deCodeNameLC}Service.${srfmethodname(deactionCodeName)}(${deCodeNameLC});
${itemCodeNameLC}dto = ${itemCodeNameLC}Mapping.toDto(${deCodeNameLC});
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC}dto);
}
</#if>
<#elseif apiMethod.getActionType()=='FETCH'>
<#assign deds = apiMethod.getPSDEDataSet()>
@PreAuthorize("hasPermission('READ',{#context,'${deds.getCodeName()}',this.getEntity()})")
@ApiOperation(value = "fetch${deds.getLogicName()}", tags = {"${itemCodeName}" } ,notes = "fetch${deds.getLogicName()}")
@RequestMapping(method= RequestMethod.${reqMtd} , value="${fullPath}/fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>")
public ResponseEntity<List<${itemCodeName}DTO>> fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()}<#else>${deds.getCodeName()}</#if>(${deCodeName}SearchContext context) {
<#--${parentSearchParams}-->
Page<${deCodeName}> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ;
List<${itemCodeName}DTO> list = ${itemCodeNameLC}Mapping.toDto(domains.getContent());
return ResponseEntity.status(${statusCode})
.header("x-page", String.valueOf(context.getPageable().getPageNumber()))
.header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
.header("x-total", String.valueOf(domains.getTotalElements()))
.body(list);
}
@PreAuthorize("hasPermission('READ',{#context,'${deds.getCodeName()}',this.getEntity()})")
@ApiOperation(value = "search${deds.getLogicName()}", tags = {"${itemCodeName}" } ,notes = "search${deds.getLogicName()}")
@RequestMapping(method= RequestMethod.${reqMtd} , value="${fullPath}/search<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>")
public ResponseEntity<Page<${itemCodeName}DTO>> search<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()}<#else>${deds.getCodeName()}</#if>(${deCodeName}SearchContext context) {
<#--${parentSearchParams}-->
Page<${deCodeName}> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ;
return ResponseEntity.status(${statusCode})
.body(new PageImpl(${itemCodeNameLC}Mapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
}
</#if>
</#list>
</#if>
</#if>
<#-- 主接口 end -->
<#-- 关系接口 start -->
<#if item.getPSDEServiceAPIRSPathCount() gt 0>
<#list 0..1000 as x>
<#if x gte item.getPSDEServiceAPIRSPathCount()>
<#break>
<#else>
<#assign parentPath = "">
<#assign selfPath="/" + srfpluralize(itemCodeNameLC) >
<#assign parentParams = "">
<#assign byParams = "By">
<#assign parentSearchParams = "" >
<#assign parentSetParams = "" >
<#assign parentParams2 = "">
<#assign parentParams3 = "">
<#assign idParams = "">
<#assign idParams2 = "">
<#assign idParams3 = "">
<#assign etParams = "">
<#assign etParamsList = "">
<#assign etParams2 = "">
<#assign etParams3 = "">
<#assign id_etParams = "">
<#assign id_etParams4 = "">
<#assign id_etParams4_batch = "">
<#assign apiRsPathLast = item.getPSDEServiceAPIRSPathLast(x)>
<#list item.getPSDEServiceAPIRSPath(x) as rs>
<#assign rsMainDEServiceAPI = rs.getMajorPSDEServiceAPI()>
<#assign rsMainDe = rsMainDEServiceAPI.getPSDataEntity()>
<#assign rsMainDeCN = rsMainDe.codeName >
<#assign rsMainDeCNLC = rsMainDeCN?lower_case >
<#assign rsMainDePKCN = rsMainDe.getKeyPSDEField().codeName >
<#assign rsMainDePKCNLC = rsMainDePKCN?lower_case >
<#assign rsMainDePKDataType = rsMainDe.getKeyPSDEField().getStdDataType() >
<#assign parentPath += "/" + srfpluralize(rsMainDEServiceAPI.codeName)?lower_case + "/{" + rsMainDeCNLC + keyCNLC + "}" >
<#if rs_index != 0 && parentParams!= "">
<#assign parentParams += ", ">
</#if>
<#assign parentParams += "@PathVariable(\"" + rsMainDeCNLC + keyCNLC + "\") " + srfjavatype(rsMainDePKDataType) + " " + rsMainDeCNLC + keyCNLC >
<#assign byParams += rsMainDeCN >
<#if rs.getPSDER1N()?? && apiRsPathLast.getCodeName() == rs.getCodeName()>
<#assign parentSearchParams += "context.setN_" + rs.getPSDER1N().getPSPickupDEField().getName()?lower_case + "_eq("+ rsMainDeCNLC + keyCNLC +");" >
<#assign parentSetParams += "domain.set" + srfcaseformat(rs.getPSDER1N().getPSPickupDEField().getCodeName(),'l_u2lC')?cap_first + "("+ rsMainDeCNLC + keyCNLC +");" >
</#if>
<#assign parentParams2 += "" + srfjavatype(rsMainDePKDataType)+" " + rsMainDeCNLC + keyCNLC >
<#assign parentParams3 += "" + rsMainDeCNLC + keyCNLC >
</#list>
<#if parentParams != "" >
<#assign idParams = parentParams + ", ">
<#assign idParams2 = parentParams2 + ", ">
<#assign idParams3 = parentParams3 + ", ">
<#assign etParams = parentParams + ", ">
<#assign etParamsList = parentParams + ", ">
<#assign etParams2 = parentParams2 + ", ">
<#assign etParams3 = parentParams3 + ", ">
<#assign id_etParams = parentParams + ", ">
<#assign id_etParams4 = parentParams + ", ">
<#assign id_etParams4_batch = parentParams + ", ">
</#if>
<#assign etParams = etParams + "@RequestBody " + itemCodeName + "DTO " + itemCodeNameLC + "dto">
<#assign etParamsList = etParamsList + "@RequestBody List<" + itemCodeName + "DTO> " + itemCodeNameLC + "dtos">
<#assign etParams2 = etParams2 + itemCodeName + "DTO " + itemCodeNameLC + "dto">
<#assign etParams3 = etParams3 + itemCodeNameLC + "dto">
<#assign idParams = idParams + "@PathVariable(\"" + itemCodeNameLC + keyCNLC + "\") " + srfjavatype(de.getKeyPSDEField().getStdDataType()) + " " + itemCodeNameLC + keyCNLC >
<#assign idParams2 = idParams2 + " " + srfjavatype(de.getKeyPSDEField().getStdDataType()) + " " + itemCodeNameLC + keyCNLC >
<#assign idParams3 = idParams3 + " " + itemCodeNameLC + keyCNLC >
<#assign id_etParams = id_etParams + "@PathVariable(\"" + itemCodeNameLC + keyCNLC + "\") " + srfjavatype(de.getKeyPSDEField().getStdDataType())+" " + itemCodeNameLC + keyCNLC + ", @RequestBody " + itemCodeName + "DTO " + itemCodeNameLC + "dto" >
<#assign id_etParams4 = id_etParams4 + "@RequestBody " + itemCodeName + "DTO " + itemCodeNameLC + "dto" >
<#assign id_etParams4_batch = id_etParams4_batch + "@RequestBody List<" + itemCodeName + "DTO> " + itemCodeNameLC + "dtos" >
<#assign fullPath = parentPath + selfPath>
<#if item.getPSDEServiceAPIMethods()??>
<#list item.getPSDEServiceAPIMethods() as apiMethod>
<#assign reqMtd = apiMethod.getRequestMethod()>
<#assign statusCode = "">
<#if reqMtd == "POST" >
<#assign statusCode = "HttpStatus.CREATED" >
<#else>
<#assign statusCode = "HttpStatus.OK" >
</#if>
<#if apiMethod.getActionType()=='DEACTION'>
<#assign deaction = apiMethod.getPSDEAction()>
<#assign deactionName = deaction.getName()>
<#assign deactionCodeName = deaction.getCodeName()>
<#if deaction.codeName?lower_case == 'create'>
@ApiOperation(value = "${deaction.getLogicName()}${byParams}", tags = {"${itemCodeName}${byParams}" }, notes = "${deaction.getLogicName()}${byParams}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}")
<#if de.getStorageMode()==4><#else> @Transactional</#if>
public ResponseEntity<${itemCodeName}DTO> ${deactionCodeName?uncap_first}${byParams}(${etParams}) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
${parentSetParams}
${deCodeNameLC}Service.create(domain);
${itemCodeName}DTO dto = ${itemCodeNameLC}Mapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@ApiOperation(value = "createBatch${byParams}", tags = {"createBatch${byParams}" }, notes = "createBatch${byParams}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/createbatch")
public ResponseEntity<Boolean> createBatch${byParams}(${etParamsList}) {
List<${deCodeName}> domainlist=${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos);
for(${deCodeName} domain:domainlist){
${parentSetParams}
}
${deCodeNameLC}Service.createBatch(domainlist);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
<#elseif deaction.codeName?lower_case == 'update'>
@ApiOperation(value = "${deaction.getLogicName()}${byParams}", tags = {"${itemCodeName}${byParams}" }, notes = "${deaction.getLogicName()}${byParams}")
@RequestMapping(method = RequestMethod.PUT, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
<#if de.getStorageMode()==4><#else> @Transactional</#if>
public ResponseEntity<${itemCodeName}DTO> ${deactionCodeName?uncap_first}${byParams}(${id_etParams}) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
${parentSetParams}
domain.set${dePKCodeName}(${itemCodeNameLC + keyCNLC});
${deCodeNameLC}Service.update(domain);
${itemCodeName}DTO dto = ${itemCodeNameLC}Mapping.toDto(domain);
<#--
<#if item.getPSDEServiceAPIRSs()??>
<#list item.getPSDEServiceAPIRSs() as apider>
<#assign deMinApi = apider.getMinorPSDEServiceAPI()>
<#assign deMinApiCN = deMinApi.getCodeName()>
<#assign deMinApiCNLC = deMinApi.getCodeName()?lower_case>
<#assign deapide=deMinApi.getPSDataEntity()>
<#if deMinApi.isNested()>
<#assign subDTOs = srfpluralize(deMinApiCN)?lower_case >
List<${deMinApiCN}DTO> ${deMinApiCNLC}dtos = ${itemCodeNameLC}dto.get${subDTOs?cap_first}();
Page<${deapide.getCodeName()}> ${deMinApiCNLC}DOs = ${deapide.getCodeName()?lower_case}Service.selectBy${apider.getPSDER1N().getCodeName()}(${itemCodeNameLC + keyCNLC});
List<${srfjavatype(deapide.getKeyPSDEField().getStdDataType())}> ${deMinApiCNLC}Ids = new ArrayList<${srfjavatype(deapide.getKeyPSDEField().getStdDataType())}>();
if (${deMinApiCNLC}DOs != null && !${deMinApiCNLC}DOs.isEmpty()) {
for (${deapide.getCodeName()} minorDO : ${deMinApiCNLC}DOs) {
${deMinApiCNLC}Ids.add(minorDO.get${deapide.getKeyPSDEField().getCodeName()?cap_first}());
}
}
List<${deMinApiCN}DTO> ${deMinApiCNLC}dtos2 = new ArrayList<${deapide.getCodeName()}DTO>();
if (${deapide.getCodeName()?lower_case}dtos != null && ${deapide.getCodeName()?lower_case}dtos.size() > 0) {
for (${deMinApiCN}DTO ${deapide.getCodeName()?lower_case}dto : ${deapide.getCodeName()?lower_case}dtos) {
${deapide.getCodeName()} ${deapide.getCodeName()?lower_case}Do = ${deapide.getCodeName()?lower_case}dto.toDO();
${deapide.getCodeName()?lower_case}Do.set${dePKCodeName?cap_first}(dto.get${dePKCodeName?cap_first}());
if ( StringUtils.isEmpty( ${deapide.getCodeName()?lower_case}Do.get${deapide.getKeyPSDEField().getCodeName()?cap_first}()) || (${deMinApiCNLC}Ids != null && !${deMinApiCNLC}Ids.isEmpty() && ${deMinApiCNLC}Ids.contains(${deapide.getCodeName()?lower_case}Do.get${deapide.getKeyPSDEField().getCodeName()?cap_first}()))) {
${deapide.getCodeName()?lower_case}Service.save(${deapide.getCodeName()?lower_case}Do);
${deapide.getCodeName()?lower_case}dto.fromDO(${deapide.getCodeName()?lower_case}Do);
${deapide.getCodeName()?lower_case}dtos2.add(${deapide.getCodeName()?lower_case}dto);
} else {
${deapide.getCodeName()?lower_case}Service.remove(${deapide.getCodeName()?lower_case}Do.get${deapide.getKeyPSDEField().getCodeName()?cap_first}());
}
}
} else {
${deapide.getCodeName()?lower_case}dtos2 = ${deapide.getCodeName()?lower_case}dtos;
}
dto.set${subDTOs?cap_first}(${deapide.getCodeName()?lower_case}dtos2);
</#if>
</#list>
</#if>
-->
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@ApiOperation(value = "UpdateBatch${byParams}", tags = {"UpdateBatch${byParams}" }, notes = "UpdateBatch${byParams}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/updatebatch")
public ResponseEntity<Boolean> updateBatch${byParams}(${etParamsList}) {
List<${deCodeName}> domainlist=${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos);
for(${deCodeName} domain:domainlist){
${parentSetParams}
}
${deCodeNameLC}Service.updateBatch(domainlist);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
<#elseif deaction.codeName?lower_case == 'remove'>
@ApiOperation(value = "${deaction.getLogicName()}${byParams}", tags = {"${itemCodeName}${byParams}" }, notes = "${deaction.getLogicName()}${byParams}")
@RequestMapping(method = RequestMethod.DELETE, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
<#if de.getStorageMode()==4><#else> @Transactional</#if>
public ResponseEntity<Boolean> ${deactionCodeName?uncap_first}${byParams}(${idParams}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.remove(${itemCodeNameLC + keyCNLC}));
}
@ApiOperation(value = "RemoveBatch${byParams}", tags = {"RemoveBatch${byParams}" }, notes = "RemoveBatch${byParams}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/removebatch")
public ResponseEntity<Boolean> removeBatch${byParams}(@RequestBody List<${srfjavatype(de.getKeyPSDEField().getStdDataType())}> ids) {
${deCodeNameLC}Service.removeBatch(ids);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
<#elseif deaction.codeName?lower_case == 'save'>
@ApiOperation(value = "${deaction.getLogicName()}${byParams}", tags = {"${itemCodeName}${byParams}" }, notes = "${deaction.getLogicName()}${byParams}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}")
public ResponseEntity<Boolean> ${deactionCodeName?uncap_first}${byParams}(${etParams}) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
${parentSetParams}
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.save(domain));
}
@ApiOperation(value = "SaveBatch${byParams}", tags = {"SaveBatch${byParams}" }, notes = "SaveBatch${byParams}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/savebatch")
public ResponseEntity<Boolean> saveBatch${byParams}(${etParamsList}) {
List<${deCodeName}> domainlist=${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dtos);
for(${deCodeName} domain:domainlist){
${parentSetParams}
}
${deCodeNameLC}Service.saveBatch(domainlist);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
<#elseif deaction.codeName?lower_case == 'get'>
@ApiOperation(value = "${deaction.getLogicName()}${byParams}", tags = {"${itemCodeName}${byParams}" }, notes = "${deaction.getLogicName()}${byParams}")
@RequestMapping(method = RequestMethod.GET, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
public ResponseEntity<${itemCodeName}DTO> ${deactionCodeName?uncap_first}${byParams}(${idParams}) {
${deCodeName} domain = ${deCodeNameLC}Service.get(${itemCodeNameLC + keyCNLC});
${itemCodeName}DTO dto = ${itemCodeNameLC}Mapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
<#elseif deaction.codeName?lower_case == 'checkkey'>
@ApiOperation(value = "${deaction.getLogicName()}${byParams}", tags = {"${itemCodeName}${byParams}" }, notes = "${deaction.getLogicName()}${byParams}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}")
public ResponseEntity<Boolean> ${deactionCodeName?uncap_first}${byParams}(${etParams}) {
return ResponseEntity.status(HttpStatus.OK).body(${deCodeNameLC}Service.checkKey(${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto)));
}
<#elseif deaction.codeName?lower_case == 'getdraft'>
@ApiOperation(value = "${deaction.getLogicName()}${byParams}", tags = {"${itemCodeName}${byParams}" }, notes = "${deaction.getLogicName()}${byParams}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}")
public ResponseEntity<${itemCodeName}DTO> ${deactionCodeName?uncap_first}${byParams}(${parentParams}) {
${deCodeName} domain = new ${deCodeName}();
${parentSetParams}
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC}Mapping.toDto(${deCodeNameLC}Service.getDraft(domain)));
}
<#elseif deaction.codeName?lower_case == 'createbatch'>
<#elseif deaction.codeName?lower_case == 'updatebatch'>
<#elseif deaction.codeName?lower_case == 'removebatch'>
<#elseif deaction.codeName?lower_case == 'savebatch'>
<#elseif deaction.getUserTag()?? && deaction.getActionType()?? && deaction.getUserTag() == 'REGIST' && deaction.getActionType() == 'USERCREATE'>
<#else>
@ApiOperation(value = "${deaction.getLogicName()}${byParams}", tags = {"${itemCodeName}${byParams}" }, notes = "${deaction.getLogicName()}${byParams}")
@RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/{${itemCodeNameLC + dePKCodeNameLC}}/${deactionCodeName?lower_case}")
<#if de.getStorageMode()==4><#else> @Transactional</#if>
public ResponseEntity<${itemCodeName}DTO> ${deactionCodeName?uncap_first}${byParams}(${id_etParams}) {
${deCodeName} domain = ${itemCodeNameLC}Mapping.toDomain(${itemCodeNameLC}dto);
${parentSetParams}
domain = ${deCodeNameLC}Service.${srfmethodname(deactionCodeName)}(domain) ;
${itemCodeNameLC}dto = ${itemCodeNameLC}Mapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeNameLC}dto);
}
</#if>
<#elseif apiMethod.getActionType()=='FETCH'>
<#assign deds = apiMethod.getPSDEDataSet()>
@ApiOperation(value = "fetch${deds.getLogicName()}${byParams}", tags = {"${itemCodeName}${byParams}" } ,notes = "fetch${deds.getLogicName()}${byParams}")
@RequestMapping(method= RequestMethod.${reqMtd} , value="${fullPath}/fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>")
public ResponseEntity<List<${itemCodeName}DTO>> fetch${itemCodeName}<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()}<#else>${deds.getCodeName()}</#if>${byParams}(<#if parentParams!="">${parentParams},</#if>${deCodeName}SearchContext context) {
${parentSearchParams}
Page<${deCodeName}> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ;
List<${itemCodeName}DTO> list = ${itemCodeNameLC}Mapping.toDto(domains.getContent());
return ResponseEntity.status(${statusCode})
.header("x-page", String.valueOf(context.getPageable().getPageNumber()))
.header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
.header("x-total", String.valueOf(domains.getTotalElements()))
.body(list);
}
@ApiOperation(value = "search${deds.getLogicName()}${byParams}", tags = {"${itemCodeName}${byParams}" } ,notes = "search${deds.getLogicName()}${byParams}")
@RequestMapping(method= RequestMethod.${reqMtd} , value="${fullPath}/search<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>")
public ResponseEntity<Page<${itemCodeName}DTO>> search${itemCodeName}<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()}<#else>${deds.getCodeName()}</#if>${byParams}(<#if parentParams!="">${parentParams},</#if>${deCodeName}SearchContext context) {
${parentSearchParams}
Page<${deCodeName}> domains = ${deCodeNameLC}Service.search${deds.getCodeName()}(context) ;
return ResponseEntity.status(${statusCode})
.body(new PageImpl(${itemCodeNameLC}Mapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
}
</#if>
</#list>
</#if>
</#if>
</#list>
</#if>
<#-- 关系接口 end -->
/**
* 用户权限校验
* @return
*/
public ${deCodeName} getEntity(){
return new ${deCodeName}();
}
}
</#if>
</#if>
\ No newline at end of file
<#ibiztemplate>
TARGET=PSDESERVICEAPI
</#ibiztemplate>
<#--package ${pub.getPKGCodeName()!''}.service.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=PSSYSSERVICEAPI
</#ibiztemplate>
<#assign httpPort = "8081">
<#if sysrun?? >
<#if sysrun.getPSDevSlnMSDepAPI()??>
<#if sysrun.getPSDevSlnMSDepAPI().getHttpPort()??>
<#assign httpPort = sysrun.getPSDevSlnMSDepAPI().getHttpPort()?c>
</#if>
</#if>
</#if>
server:
port: ${httpPort}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSSERVICEAPI
</#ibiztemplate>
<#assign httpPort = "8081">
<#if sysrun?? >
<#if sysrun.getPSDevSlnMSDepAPI()??>
<#if sysrun.getPSDevSlnMSDepAPI().getHttpPort()??>
<#assign httpPort = sysrun.getPSDevSlnMSDepAPI().getHttpPort()?c>
</#if>
</#if>
</#if>
server:
port: ${httpPort}
<#ibiztemplate>
TARGET=PSSYSSERVICEAPI
</#ibiztemplate>
spring:
profiles:
include: sys , ${item.codeName?lower_case}-prod
application:
name: ${sys.getCodeName()?lower_case}-${item.getCodeName()?lower_case}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>
<parent>
<artifactId>${pub.getCodeName()?lower_case}</artifactId>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<version>${pub.getVersionString()?default("V0.0.1_alpha")}</version>
</parent>
<artifactId>${pub.getCodeName()?lower_case}-provider</artifactId>
<name>${pub.getCodeName()?lower_case?cap_first} Provider</name>
<packaging>pom</packaging>
<description>${pub.getCodeName()?lower_case?cap_first} Provider</description>
<#-- modules -->
<#if sys.getAllPSSysServiceAPIs()??>
<modules>
<#list sys.getAllPSSysServiceAPIs() as sysapi>
<module>${pub.getCodeName()?lower_case}-provider-${sysapi.getCodeName()?lower_case}</module>
</#list>
</modules>
</#if>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>
<parent>
<artifactId>${pub.getCodeName()?lower_case}</artifactId>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<version>${pub.getVersionString()?default("V0.0.1_alpha")}</version>
</parent>
<artifactId>${pub.getCodeName()?lower_case}-util</artifactId>
<name>${pub.getCodeName()?lower_case?cap_first} Util</name>
<description>${pub.getCodeName()?lower_case?cap_first} Util</description>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
</dependency>
<dependency>
<groupId>org.zalando</groupId>
<artifactId>problem-spring-web</artifactId>
</dependency>
</dependencies>
</project>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.annotation;
import ${pub.getPKGCodeName()}.util.enums.DEFieldDefaultValueType;
import ${pub.getPKGCodeName()}.util.enums.DEPredefinedFieldType;
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 DEField
{
/**
* 是否为数据主键
* @return
*/
boolean isKeyField() default false;
/**
* 默认值
* @return
*/
String defaultValue() default "";
/**
* 默认值类型
* @return
*/
DEFieldDefaultValueType defaultValueType() default DEFieldDefaultValueType.NONE;
/**
* 预置属性类型
* @return
*/
DEPredefinedFieldType preType() default DEPredefinedFieldType.NONE;
/**
* 逻辑删除有效值
* @return
*/
String logicval() default "";
/**
* 逻辑删除无效值
* @return
*/
String logicdelval() default "";
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.aspect;
import ${pub.getPKGCodeName()}.util.annotation.DEField;
import ${pub.getPKGCodeName()}.util.enums.DEFieldDefaultValueType;
import ${pub.getPKGCodeName()}.util.enums.DEPredefinedFieldType;
import ${pub.getPKGCodeName()}.util.helper.DEFieldCacheMap;
import ${pub.getPKGCodeName()}.util.security.AuthenticationUser;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.cglib.beans.BeanMap;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.util.AlternativeJdkIdGenerator;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 实体属性默认值切面,只有新建(Create)时才会填充默认值
*/
@Aspect
@Order(0)
@Component
public class DEFieldDefaultValueAspect
{
/**
* 新建数据切入点
* @param point
* @throws Exception
*/
@Before(value = "execution(* ${pub.getPKGCodeName()}.core.*.service.*.create(..))")
public void BeforeCreate(JoinPoint point) throws Exception {
fillDEFieldDefaultValue(point);
}
/**
* 更新数据切入点
* @param point
* @throws Exception
*/
@Before(value = "execution(* ${pub.getPKGCodeName()}.core.*.service.*.update(..))")
public void BeforeUpdate(JoinPoint point) throws Exception {
fillDEFieldDefaultValue(point);
}
/**
* 保存数据切入点
* @param point
* @throws Exception
*/
@Before(value = "execution(* ${pub.getPKGCodeName()}.core.*.service.*.save(..))")
public void BeforeSave(JoinPoint point) throws Exception {
checkAction(point);
}
/**
* 判断当前是否为新建操作,若为新建,则填充属性默认值
* @param joinPoint
* @throws Exception
*/
private void checkAction(JoinPoint joinPoint) throws Exception {
Object[] args = joinPoint.getArgs();
if (args.length > 0) {
Object obj = args[0];
String className=obj.getClass().getName();
//获取当前do对象中的属性
DEFieldCacheMap.getFieldMap(className);
//从属性列表中过滤出主键属性
Field keyPSDEField = this.getKeyPSDEField(className);
if(ObjectUtils.isEmpty(keyPSDEField))
return ;
String filename = keyPSDEField.getName();
PropertyDescriptor field = new PropertyDescriptor(filename, obj.getClass());
Method fieldGetMethod = field.getReadMethod();
//获取主键值
Object fieldValue = fieldGetMethod.invoke(obj);
//实体数据主键为空,则为新建操作,填充属性默认值
if(ObjectUtils.isEmpty(fieldValue)){
fillDEFieldDefaultValue(joinPoint);
}
}
}
/**
* 获取主键属性
* @param className 实体类名
* @return 主键属性
*/
private Field getKeyPSDEField(String className){
Field keyField =null;
List<Field> fields = DEFieldCacheMap.getFields(className);
for(Field field:fields){
DEField deField=field.getAnnotation(DEField.class);
if(!ObjectUtils.isEmpty(deField) && deField.isKeyField()) {
return field;
}
}
return keyField;
}
/**
* 填充属性默认值
* @param joinPoint
* @return
* @throws Exception
*/
public Object fillDEFieldDefaultValue(JoinPoint joinPoint) throws Exception {
Object[] args = joinPoint.getArgs();
if (args.length > 0) {
Object obj = args[0];
String className=obj.getClass().getName();
//获取当前po对象中的属性
DEFieldCacheMap.getFieldMap(className);
//从属性列表中过滤出预置属性
Map<Field, DEField> deFields = this.SearchDEField(className);
//填充预置属性
fillDEField(obj, deFields,joinPoint);
return true;
}
return true;
}
/**
*获取含有@DEField注解的实体属性
* @param className do对象类名
* @return
*/
private Map <Field, DEField> SearchDEField(String className){
List<Field> fields = DEFieldCacheMap.getFields(className);
Map <Field, DEField> deFieldMap =new HashMap<>();
for(Field field:fields){
DEField deField=field.getAnnotation(DEField.class);
if(!ObjectUtils.isEmpty(deField)) {
deFieldMap.put(field,deField);
}
}
return deFieldMap;
}
/**
* 填充系统预置属性
* @param et 当前实体对象
*/
private void fillDEField(Object et, Map<Field, DEField> deFields, JoinPoint joinPoint) throws Exception {
if(deFields.size()==0)
return ;
for (Map.Entry<Field, DEField> entry : deFields.entrySet()) {
Field deField=entry.getKey();
String fileName=deField.getName();
//获取注解
DEField fieldAnnotation=entry.getValue();
//获取默认值类型
DEFieldDefaultValueType deFieldType=fieldAnnotation.defaultValueType();
//获取属性默认值
String deFieldDefaultValue = fieldAnnotation.defaultValue();
//获取预置属性类型
DEPredefinedFieldType predefinedFieldType = fieldAnnotation.preType();
//填充系统默认值
if( deFieldType!= DEFieldDefaultValueType.NONE || (!StringUtils.isEmpty(deFieldDefaultValue)) ){
fillFieldDefaultValue(fileName, deFieldType, deFieldDefaultValue, et , fieldAnnotation) ;
}
//填充系统预置属性
if(predefinedFieldType != DEPredefinedFieldType.NONE){
fillPreFieldValue( fileName, predefinedFieldType , et ,joinPoint ,fieldAnnotation);
}
}
}
/**
* 填充属性默认值
* @param fileName 实体属性名
* @param deFieldType 默认值类型
* @param deFieldDefaultValue 默认值
* @param et 当前实体对象
* @throws Exception
*/
private void fillFieldDefaultValue(String fileName , DEFieldDefaultValueType deFieldType,String deFieldDefaultValue,Object et ,DEField fieldAnnotation) throws Exception {
AuthenticationUser curUser=AuthenticationUser.getAuthenticationUser();
BeanMap beanMap = BeanMap.create(et);
Object fieldValue = beanMap.get(fileName);
//获取当前所需填充属性的getset方法及字段值
PropertyDescriptor field = new PropertyDescriptor(fileName, et.getClass());
if(org.springframework.util.StringUtils.isEmpty(fieldValue)){
//填充直接值及其余默认值类型
if( (deFieldType== DEFieldDefaultValueType.NONE && !StringUtils.isEmpty(deFieldDefaultValue)) || (deFieldType != DEFieldDefaultValueType.NONE) ){
switch(deFieldType){
case SESSION:
String sessionField=fieldAnnotation.defaultValue();
if(!StringUtils.isEmpty(sessionField)){
Object sessionFieldValue = curUser.getSessionParams().get(sessionField);
if(!ObjectUtils.isEmpty(sessionFieldValue)){
beanMap.put(fileName,sessionFieldValue);
}
}
break;
case APPLICATION:
//暂未实现
break;
case UNIQUEID:
String uuid=(new AlternativeJdkIdGenerator()).generateId().toString();
Object objUuId=fieldValueConvert(uuid,field);
beanMap.put(fileName,objUuId);
break;
case CONTEXT:
//暂未实现
break;
case PARAM:
String paramField=fieldAnnotation.defaultValue();
if(!StringUtils.isEmpty(paramField)){
Object paramFieldValue=beanMap.get(paramField);
if(!ObjectUtils.isEmpty(paramFieldValue)){
beanMap.put(fileName,paramFieldValue);
}
}
break;
case OPERATOR:
beanMap.put(fileName,curUser.getUserid());
break;
case OPERATORNAME:
beanMap.put(fileName,curUser.getPersonname());
break;
case CURTIME:
beanMap.put(fileName,new Timestamp(new Date().getTime()));
break;
case APPDATA:
//暂未实现
break;
case NONE:
Object deFieldDefaultValueObj=fieldValueConvert(deFieldDefaultValue,field);
beanMap.put(fileName,deFieldDefaultValueObj);
break;
}
}
}
}
/**
* 填充系统预置属性
* @param fileName 实体属性名
* @param preFieldType 预置类型
* @param et 当前实体对象
* @param joinPoint 切点
* @param fieldAnnotation 属性注解
* @throws Exception
*/
private void fillPreFieldValue(String fileName , DEPredefinedFieldType preFieldType ,Object et , JoinPoint joinPoint ,DEField fieldAnnotation) throws Exception {
AuthenticationUser curUser=AuthenticationUser.getAuthenticationUser();
BeanMap beanMap = BeanMap.create(et);
//当前操作行为
String actionName=joinPoint.getSignature().getName();
Object fieldValue = beanMap.get(fileName);
//获取当前所需填充属性的getset方法及字段值
PropertyDescriptor field = new PropertyDescriptor(fileName, et.getClass());
//为预置属性进行赋值
if( (actionName.equalsIgnoreCase("create") && org.springframework.util.StringUtils.isEmpty(fieldValue) )||
preFieldType== DEPredefinedFieldType.UPDATEDATE|| preFieldType== DEPredefinedFieldType.UPDATEMAN||
preFieldType== DEPredefinedFieldType.UPDATEMANNAME){
switch(preFieldType){//根据注解给预置属性填充值
case CREATEMAN:
beanMap.put(fileName,curUser.getUserid());
break;
case CREATEMANNAME:
beanMap.put(fileName,curUser.getPersonname());
break;
case UPDATEMAN:
beanMap.put(fileName,curUser.getUserid());
break;
case UPDATEMANNAME:
beanMap.put(fileName,curUser.getPersonname());
break;
case CREATEDATE:
beanMap.put(fileName,new Timestamp(new Date().getTime()));
break;
case UPDATEDATE:
beanMap.put(fileName,new Timestamp(new Date().getTime()));
break;
case ORGID:
beanMap.put(fileName,curUser.getOrgid());
break;
case ORGNAME:
beanMap.put(fileName,curUser.getOrgname());
break;
case ORGSECTORID:
beanMap.put(fileName,curUser.getMdeptid());
break;
case ORGSECTORNAME:
beanMap.put(fileName,curUser.getMdeptname());
break;
case LOGICVALID:
String logicValue=fieldAnnotation.logicval();
Object objLogicValue=fieldValueConvert(logicValue,field);
if(!StringUtils.isEmpty(objLogicValue)){
beanMap.put(fileName,objLogicValue);
}
break;
}
}
}
/**
* 值类型转换
* @param fieldValue
* @param field
*/
private Object fieldValueConvert(String fieldValue,PropertyDescriptor field){
Object resultValue=fieldValue;
String targetType=field.getPropertyType().getSimpleName();
if(targetType.equals("Boolean")){
resultValue=Boolean.valueOf(fieldValue);
}
else if(targetType.equals("Character")){
resultValue=fieldValue.toCharArray();
}
else if(targetType.equals("Byte")){
resultValue=Byte.valueOf(fieldValue);
}
else if(targetType.equals("Short")){
resultValue=Short.valueOf(fieldValue);
}
else if(targetType.equals("Integer")){
resultValue= Integer.valueOf(fieldValue);
}
else if(targetType.equals("Long")){
resultValue=Long.valueOf(fieldValue);
}
else if(targetType.equals("Float")){
resultValue= Float.valueOf(fieldValue);
}
else if(targetType.equals("Double")){
resultValue= Double.valueOf(fieldValue);
}
return resultValue;
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.client;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
@Component
public class IBZOUFallback implements IBZOUFeignClient {
@Override
public JSONObject getOrgInfo(String loginName) {
return null;
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.client;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@FeignClient(value = "ibzou",fallback = IBZOUFallback.class)
public interface IBZOUFeignClient
{
/**
* ou中获取当前上下级组织、部门信息
* @param loginName 登录名
* @return
*/
@GetMapping(value = "/ibzou/org/{loginname}")
JSONObject getOrgInfo(@PathVariable("loginname") String loginName);
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.client;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class IBZUAAFallback implements IBZUAAFeignClient {
@Override
public JSONObject getUserPermissionData(String loginName, String systemId) {
return null;
}
@Override
public Map<String, Object> pushSystemPermissionData(Map<String, Object> systemPermissionData, String systemId) {
return null;
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.client;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@FeignClient(value = "ibzuaa",fallback = IBZUAAFallback.class)
public interface IBZUAAFeignClient
{
/**
* uaa中获取当前用户权限
* @param loginName
* @param systemId
* @return
*/
@GetMapping(value = "/uaa/permission/{loginname}")
JSONObject getUserPermissionData(@PathVariable("loginname") String loginName, @RequestParam("systemid") String systemId);
/**
* 推送系统权限数据到uaa
* @param systemPermissionData
* @param systemId
* @return
*/
@PostMapping("/uaa/permission/save")
Map<String,Object> pushSystemPermissionData(@RequestBody Map<String, Object> systemPermissionData, @RequestParam("systemid") String systemId);
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.domain;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.alibaba.fastjson.annotation.JSONField;
import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import lombok.Data;
@Data
public class DTOBase implements Serializable {
@JsonIgnore
@JSONField(serialize = false)
private Set<String> focusNull;
public void modify(String field,Object val) {
if(val==null)
this.getFocusNull(true).add(field.toLowerCase());
else
this.getFocusNull(true).remove(field.toLowerCase());
}
public Set<String> getFocusNull() {
if(focusNull==null)
focusNull=new HashSet<>();
if(focusNull.size()>0 && extensionparams.containsKey("dirtyflagenable"))
{
Set<String> nocheck=new HashSet<>();
for(String key:focusNull)
{
if(!extensionparams.containsKey(key+"dirtyflag"))
nocheck.add(key);
}
for(String key:nocheck)
focusNull.remove(key);
}
return focusNull;
}
private Set<String> getFocusNull(boolean newflag) {
if(focusNull==null)
focusNull=new HashSet<>();
return focusNull;
}
@JsonIgnore
private Map<String,Object> extensionparams=new HashMap<String,Object>();
public Map<String, Object> getExtensionparams() {
return extensionparams;
}
public void setExtensionparams(Map<String, Object> extensionparams) {
this.extensionparams = extensionparams;
}
@JsonAnyGetter
public Map<String , Object> any() {
return extensionparams;
}
@JsonAnySetter
public void set(String name, Object value) {
extensionparams.put(name.toLowerCase(), value);
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.domain;
import ${pub.getPKGCodeName()}.util.helper.DEFieldCacheMap;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.cglib.beans.BeanMap;
import org.springframework.data.annotation.Transient;
import org.springframework.util.AlternativeJdkIdGenerator;
import java.io.Serializable;
import java.util.*;
public class EntityBase implements Serializable {
@JsonIgnore
@JSONField(serialize = false)
@TableField(exist = false)
@Transient
private Set<String> focusNull;
public Set<String> getFocusNull() {
if(focusNull==null)
focusNull=new HashSet<>();
return focusNull;
}
public void setFocusNull(Set<String> focusNull) {
this.focusNull = focusNull;
}
public void modify(String field,Object val) {
}
public Serializable getDefaultKey(boolean gen) {
String Id=(new AlternativeJdkIdGenerator()).generateId().toString();
return gen?Id.replace("-", ""):Id;
}
@JsonIgnore
@JSONField(serialize = false)
@TableField(exist = false)
@Transient
private BeanMap map;
private BeanMap getMap()
{
if(map==null)
map=BeanMap.create(this);
return map;
}
@JsonIgnore
@TableField(exist = false)
@Transient
private Map<String,Object> extensionparams=new HashMap<String,Object>();
public Map<String, Object> getExtensionparams() {
return extensionparams;
}
public void setExtensionparams(Map<String, Object> extensionparams) {
this.extensionparams = extensionparams;
}
public Object get(String field) {
field=field.toLowerCase();
Hashtable<String,String> keys=DEFieldCacheMap.getFieldKeys(this.getClass().getName());
if(keys.containsKey(field))
return getMap().get(keys.get(field));
else
return this.extensionparams.get(field);
}
@JsonAnyGetter
public Map<String , Object> any() {
return extensionparams;
}
@JsonAnySetter
public void set(String field, Object value) {
field=field.toLowerCase();
Hashtable<String,String> keys=DEFieldCacheMap.getFieldKeys(this.getClass().getName());
if(keys.containsKey(field))
getMap().put(keys.get(field),value);
else
this.extensionparams.put(field,value);
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.domain;
public class EntityClient extends EntityBase {
@Override
public void modify(String field,Object val) {
if(val==null){
this.getFocusNull().add(field.toLowerCase());
getExtensionparams().put("dirtyflagenable",true);
getExtensionparams().put(field.toLowerCase()+"dirtyflag",true);
}
else{
this.getFocusNull().remove(field.toLowerCase());
getExtensionparams().remove(field.toLowerCase()+"dirtyflag");
}
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.domain;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
public class EntityMP extends EntityBase {
public UpdateWrapper getUpdateWrapper(boolean clean) {
UpdateWrapper wrapper=new UpdateWrapper();
for(String nullField:getFocusNull()) {
wrapper.set(nullField,null);
}
if(clean)
getFocusNull().clear();
return wrapper;
}
@Override
public void modify(String field,Object val) {
if(val==null)
this.getFocusNull().add(field.toLowerCase());
else
this.getFocusNull().remove(field.toLowerCase());
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.domain;
public class EntityMongo extends EntityBase {
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@AllArgsConstructor
public class FileItem
{
private String id;
private String name;
private long size;
private String ext;
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.domain;
import java.sql.Timestamp;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import javax.validation.constraints.Size;
import java.io.Serializable;
/**
* 实体[IBZUSER] 数据对象
*/
@TableName(value = "IBZUSER")
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public class IBZUSER implements Serializable{
@Size(min = 0, max = 100, message = "[用户标识]长度必须在[100]以内!")
@TableId(value= "userid",type=IdType.INPUT)//指定主键生成策略
private String userid;
@Size(min = 0, max = 200, message = "[用户全局名]长度必须在[200]以内!")
private String username;
@Size(min = 0, max = 100, message = "[用户姓名]长度必须在[100]以内!")
private String personname;
@Size(min = 0, max = 100, message = "[用户代码]长度必须在[100]以内!")
private String usercode;
@Size(min = 0, max = 100, message = "[登录别名]长度必须在[100]以内!")
private String loginname;
@Size(min = 0, max = 100, message = "[登录密码]长度必须在[100]以内!")
private String password;
@Size(min = 0, max = 100, message = "[区属]长度必须在[100]以内!")
private String domains;
@Size(min = 0, max = 100, message = "[主部门id]长度必须在[100]以内!")
private String mdeptid;
@Size(min = 0, max = 100, message = "[主部门代码]长度必须在[100]以内!")
private String mdeptcode;
@Size(min = 0, max = 200, message = "[主部门名称]长度必须在[200]以内!")
private String mdeptname;
@Size(min = 0, max = 100, message = "[业务编码]长度必须在[100]以内!")
private String bcode;
@Size(min = 0, max = 100, message = "[岗位id]长度必须在[100]以内!")
private String postid;
@Size(min = 0, max = 100, message = "[岗位代码]长度必须在[100]以内!")
private String postcode;
@Size(min = 0, max = 200, message = "[岗位名称]长度必须在[200]以内!")
private String postname;
@Size(min = 0, max = 100, message = "[单位id]长度必须在[100]以内!")
private String orgid;
@Size(min = 0, max = 100, message = "[单位代码]长度必须在[100]以内!")
private String orgcode;
@Size(min = 0, max = 200, message = "[单位名称]长度必须在[200]以内!")
private String orgname;
@Size(min = 0, max = 36, message = "[昵称]长度必须在[36]以内!")
private String nickname;
@Size(min = 0, max = 100, message = "[邮箱]长度必须在[100]以内!")
private String email;
@Size(min = 0, max = 100, message = "[通信账号]长度必须在[100]以内!")
private String avatar;
@Size(min = 0, max = 100, message = "[联系电话]长度必须在[100]以内!")
private String phone;
@Size(min = 0, max = 100, message = "[保留字段]长度必须在[100]以内!")
private String reserver;
@Size(min = 0, max = 100, message = "[头像]长度必须在[100]以内!")
private String usericon;
@Size(min = 0, max = 10, message = "[性别]长度必须在[10]以内!")
private String sex;
private Timestamp birthday;
@Size(min = 0, max = 36, message = "[证件号码]长度必须在[36]以内!")
private String certcode;
@Size(min = 0, max = 200, message = "[地址]长度必须在[200]以内!")
private String addr;
@Size(min = 0, max = 100, message = "[主题]长度必须在[100]以内!")
private String theme;
@Size(min = 0, max = 100, message = "[语言]长度必须在[100]以内!")
private String lang;
@Size(min = 0, max = 10, message = "[字号]长度必须在[10]以内!")
private String fontsize;
@Size(min = 0, max = 500, message = "[备注]长度必须在[500]以内!")
private String memo;
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.domain;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties(prefix = "spring.datasource")
@Data
public class LiquibaseProp{
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()}.util.domain;
import java.util.List;
/**
* 实体转换器基类
* @param <D> domainDTO
* @param <E> domain
*/
public interface MappingBase<D, E> {
/**
* dtodomain
* @param dto
* @return
*/
E toDomain(D dto);
/**
* domaindto
* @param entity
* @return
*/
D toDto(E entity);
/**
* dto集合转domain集合
* @param dtoList
* @return
*/
List <E> toDomain(List<D> dtoList);
/**
* domain集合转dto集合
* @param entityList
* @return
*/
List <D> toDto(List<E> entityList);
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.enums;
/**
* 实体属性默认值类型
*/
public enum DEFieldDefaultValueType {
/**
* 用户全局对象
*/
SESSION,
/**
* 系统全局对象
*/
APPLICATION,
/**
* 唯一编码
*/
UNIQUEID,
/**
* 网页请求
*/
CONTEXT,
/**
* 数据对象属性
*/
PARAM,
/**
* 当前时间
*/
CURTIME,
/**
* 当前操作用户(编号)
*/
OPERATOR,
/**
* 当前操作用户(名称)
*/
OPERATORNAME,
/**
* 当前应用数据
*/
APPDATA,
/**
* 默认值
*/
NONE
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.enums;
/**
* 实体属性预定义类型
*/
public enum DEPredefinedFieldType {
/**
* 创建人标识
*/
CREATEMAN,
/**
* 创建人名称
*/
CREATEMANNAME,
/**
* 更新人标识
*/
UPDATEMAN,
/**
* 更新人名称
*/
UPDATEMANNAME,
/**
* 创建时间
*/
CREATEDATE,
/**
* 更新时间
*/
UPDATEDATE,
/**
* 组织机构标识
*/
ORGID,
/**
* 组织机构名称
*/
ORGNAME,
/**
* 部门标识
*/
ORGSECTORID,
/**
* 部门名称
*/
ORGSECTORNAME,
/**
* 逻辑有效
*/
LOGICVALID,
/**
* 不处理
*/
NONE
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.errors;
import org.zalando.problem.AbstractThrowableProblem;
import org.zalando.problem.Status;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
public class BadRequestAlertException extends AbstractThrowableProblem {
private final String entityName;
private final String errorKey;
public BadRequestAlertException(String defaultMessage, String entityName, String errorKey) {
this(ErrorConstants.DEFAULT_TYPE, defaultMessage, entityName, errorKey);
}
public BadRequestAlertException(URI type, String defaultMessage, String entityName, String errorKey) {
super(type, defaultMessage, Status.BAD_REQUEST, null, null, null, getAlertParameters(entityName, errorKey));
this.entityName = entityName;
this.errorKey = errorKey;
}
public String getEntityName() {
return entityName;
}
public String getErrorKey() {
return errorKey;
}
private static Map<String, Object> getAlertParameters(String entityName, String errorKey) {
Map<String, Object> parameters = new HashMap<>();
parameters.put("message", "error." + errorKey);
parameters.put("params", entityName);
return parameters;
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.errors;
import org.zalando.problem.AbstractThrowableProblem;
import java.util.HashMap;
import java.util.Map;
import static org.zalando.problem.Status.BAD_REQUEST;
public class CustomParameterizedException extends AbstractThrowableProblem {
private static final long serialVersionUID = 1L;
private static final String PARAM = "param";
public CustomParameterizedException(String message, String... params) {
this(message, toParamMap(params));
}
public CustomParameterizedException(String message, Map<String, Object> paramMap) {
super(ErrorConstants.PARAMETERIZED_TYPE, "处理发生异常", BAD_REQUEST, null, null, null, toProblemParameters(message, paramMap));
}
public static Map<String, Object> toParamMap(String... params) {
Map<String, Object> paramMap = new HashMap<>();
if (params != null && params.length > 0) {
for (int i = 0; i < params.length; i++) {
paramMap.put(PARAM + i, params[i]);
}
}
return paramMap;
}
public static Map<String, Object> toProblemParameters(String message, Map<String, Object> paramMap) {
Map<String, Object> parameters = new HashMap<>();
parameters.put("message", message);
parameters.put("params", paramMap);
return parameters;
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.errors;
import java.net.URI;
public final class ErrorConstants {
public static final String ERR_CONCURRENCY_FAILURE = "处理请求发生错误";
public static final String ERR_VALIDATION = "数据校验发生错误";
public static final String PROBLEM_BASE_URL = "";
public static final URI DEFAULT_TYPE = URI.create(PROBLEM_BASE_URL + "/problem-with-message");
public static final URI CONSTRAINT_VIOLATION_TYPE = URI.create(PROBLEM_BASE_URL + "/constraint-violation");
public static final URI PARAMETERIZED_TYPE = URI.create(PROBLEM_BASE_URL + "/parameterized");
private ErrorConstants() {
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.errors;
import org.springframework.dao.ConcurrencyFailureException;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.context.request.NativeWebRequest;
import org.zalando.problem.DefaultProblem;
import org.zalando.problem.Problem;
import org.zalando.problem.ProblemBuilder;
import org.zalando.problem.Status;
import org.zalando.problem.spring.web.advice.ProblemHandling;
import org.zalando.problem.spring.web.advice.validation.ConstraintViolationProblem;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.stream.Collectors;
@ControllerAdvice
public class ExceptionTranslator implements ProblemHandling {
@Override
public ResponseEntity<Problem> process(@Nullable ResponseEntity<Problem> entity, NativeWebRequest request) {
if (entity == null || entity.getBody() == null) {
return entity;
}
Problem problem = entity.getBody();
if (!(problem instanceof ConstraintViolationProblem || problem instanceof DefaultProblem)) {
return entity;
}
ProblemBuilder builder = Problem.builder()
.withType(Problem.DEFAULT_TYPE.equals(problem.getType()) ? ErrorConstants.DEFAULT_TYPE : problem.getType())
.withStatus(problem.getStatus())
.withTitle(problem.getTitle())
.with("path", request.getNativeRequest(HttpServletRequest.class).getRequestURI());
if (problem instanceof ConstraintViolationProblem) {
builder
.with("violations", ((ConstraintViolationProblem) problem).getViolations())
.with("message", ErrorConstants.ERR_VALIDATION);
return new ResponseEntity<>(builder.build(), entity.getHeaders(), entity.getStatusCode());
} else {
builder
.withCause(((DefaultProblem) problem).getCause())
.withDetail(problem.getDetail())
.withInstance(problem.getInstance());
problem.getParameters().forEach(builder::with);
if (!problem.getParameters().containsKey("message") && problem.getStatus() != null) {
builder.with("message", "error.http." + problem.getStatus().getStatusCode());
}
return new ResponseEntity<>(builder.build(), entity.getHeaders(), entity.getStatusCode());
}
}
@Override
public ResponseEntity<Problem> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, @Nonnull NativeWebRequest request) {
BindingResult result = ex.getBindingResult();
List<FieldErrorVM> fieldErrors = result.getFieldErrors().stream()
.map(f -> new FieldErrorVM(f.getObjectName(), f.getField(), f.getDefaultMessage()))
.collect(Collectors.toList());
Problem problem = Problem.builder()
.withType(ErrorConstants.CONSTRAINT_VIOLATION_TYPE)
.withTitle(ErrorConstants.ERR_VALIDATION)
.withStatus(defaultConstraintViolationStatus())
.with("message", ErrorConstants.ERR_VALIDATION )
.with("fieldErrors", fieldErrors)
.build();
return create(ex, problem, request);
}
@ExceptionHandler(BadRequestAlertException.class)
public ResponseEntity<Problem> handleBadRequestAlertException(BadRequestAlertException ex, NativeWebRequest request) {
return create(ex, request, createFailureAlert(ex.getEntityName(), ex.getErrorKey(), ex.getMessage()));
}
@ExceptionHandler(ConcurrencyFailureException.class)
public ResponseEntity<Problem> handleConcurrencyFailure(ConcurrencyFailureException ex, NativeWebRequest request) {
Problem problem = Problem.builder()
.withStatus(Status.CONFLICT)
.with("message", ErrorConstants.ERR_CONCURRENCY_FAILURE)
.build();
return create(ex, problem, request);
}
public static HttpHeaders createFailureAlert(String entityName, String errorKey, String defaultMessage) {
HttpHeaders headers = new HttpHeaders();
headers.add("X-ibz-error", "error." + errorKey);
headers.add("X-ibz-params", entityName);
return headers;
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.errors;
import java.io.Serializable;
public class FieldErrorVM implements Serializable {
private static final long serialVersionUID = 1L;
private final String objectName;
private final String field;
private final String message;
public FieldErrorVM(String dto, String field, String message) {
this.objectName = dto;
this.field = field;
this.message = message;
}
public String getObjectName() {
return objectName;
}
public String getField() {
return field;
}
public String getMessage() {
return message;
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.errors;
import org.zalando.problem.AbstractThrowableProblem;
import org.zalando.problem.Status;
public class InternalServerErrorException extends AbstractThrowableProblem {
public InternalServerErrorException(String message) {
super(ErrorConstants.DEFAULT_TYPE, message, Status.INTERNAL_SERVER_ERROR);
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.filter;
public interface ISearchContext {
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.filter;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.mongodb.QueryBuilder;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Data
public class QueryBuildContext extends SearchContextBase implements ISearchContext{
@JsonIgnore
@JSONField(serialize = false)
private QueryBuilder selectCond=new QueryBuilder();
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.filter;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Sort;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@Slf4j
@Data
public class QueryWrapperContext<T> extends SearchContextBase implements ISearchContext{
@JsonIgnore
@JSONField(serialize = false)
private QueryWrapper<T> selectCond=new QueryWrapper<T>();
/**
* 解析查询上下文中的参数,构建mybatis-plus分页对象
* @return
*/
@JsonIgnore
@JSONField(serialize = false)
public Page getPages(){
Page page;
List<String> asc_fieldList = new ArrayList<>();
List<String> desc_fieldList = new ArrayList<>();
int currentPage=getPageable().getPageNumber();
int pageSize=getPageable().getPageSize();
//构造mybatis-plus分页
if(StringUtils.isEmpty(currentPage) || StringUtils.isEmpty(pageSize))
page=new Page(1,Short.MAX_VALUE);
else
page=new Page(currentPage+1,pageSize);
//构造mybatis-plus排序
Sort sort = getPageable().getSort();
Iterator<Sort.Order> it_sort = sort.iterator();
if(ObjectUtils.isEmpty(it_sort))
return page;
while (it_sort.hasNext()) {
Sort.Order sort_order = it_sort.next();
if(sort_order.getDirection()== Sort.Direction.ASC){
asc_fieldList.add(sort_order.getProperty());
}
else if(sort_order.getDirection()== Sort.Direction.DESC){
desc_fieldList.add(sort_order.getProperty());
}
}
if(asc_fieldList.size()>0){
page.setAscs(asc_fieldList);
}
if(desc_fieldList.size()>0){
page.setDescs(desc_fieldList);
}
return page;
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.filter;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.util.StringUtils;
import org.springframework.util.ObjectUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Data
public class SearchContextBase implements ISearchContext{
/**
* 自定义查询条件
*/
@JsonProperty("customcond")
public String customCond;
/**
* 自定义查询参数
*/
@JsonProperty("customparams")
public String customParams;
/**
* 快速搜索
*/
@JsonProperty("query")
public String query;
/**
* 数据查询
*/
public List dataQueryList;
/**
* 当前页数
*/
public int page=0;
/**
* 每页显示条数
*/
public int size=20;
/**
* 排序
*/
public String sort;
/**
* 排序对象
*/
public Sort pageSort;
/**
* 获取分页参数
* @return
*/
public Pageable getPageable() {
if(ObjectUtils.isEmpty(pageSort))
return PageRequest.of(page,size);
else
return PageRequest.of(page,size,pageSort);
}
/**
* 设置排序值
* @param strSort
*/
public void setSort(String strSort) {
this.sort=strSort;
if(!StringUtils.isEmpty(strSort)){
String sortArr[]=strSort.split(",");
String sortField=sortArr[0];
String sortDirection=sortArr[1];
if(sortDirection.equalsIgnoreCase("asc")){
this.pageSort=Sort.by(Sort.Direction.ASC,sortField);
}
else if(sortDirection.equalsIgnoreCase("desc")){
this.pageSort=Sort.by(Sort.Direction.DESC,sortField);
}
}
}
/**
* 上下文参数
*/
Map<String,Object> params = new HashMap<String,Object>() ;
/**
* 获取数据上下文
* @return
*/
public Map<String,Object> getDatacontext() {
return params;
}
/**
* 获取网页请求上下文
* @return
*/
public Map<String,Object> getWebcontext() {
return params;
}
/**
* 用户上下文参数
*/
Map<String,Object> sessionparams = new HashMap<String,Object>() ;
/**
* 获取用户上下文
* @return
*/
public Map<String,Object> getSessioncontext() {
return sessionparams;
}
@JsonAnyGetter
public Map<String , Object> any() {
return params;
}
@JsonAnySetter
public void set(String name, Object value) {
params.put(name, value);
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.helper;
import org.springframework.cglib.beans.BeanCopier;
import java.util.HashMap;
import java.util.Map;
public class CachedBeanCopier {
//创建过的BeanCopier实例放到缓存中,下次可以直接获取,提升性能
static final Map<String, BeanCopier> BEAN_COPIERS = new HashMap<String, BeanCopier>();
public static void copy(Object srcObj, Object destObj) {
copy(srcObj,destObj,false);
}
public static void copy(Object srcObj, Object destObj,boolean useConverter) {
if(srcObj==null||destObj==null)
return;
getCopier(srcObj,destObj,useConverter).copy(srcObj, destObj, null);
}
public synchronized static BeanCopier getCopier(Object srcObj, Object destObj,boolean useConverter) {
String key = srcObj.getClass().getName()+destObj.getClass().getName()+useConverter;
BeanCopier copier;
if (!BEAN_COPIERS.containsKey(key)) {
copier = BeanCopier.create(srcObj.getClass(), destObj.getClass(), useConverter);
BEAN_COPIERS.put(key, copier);
} else {
copier = BEAN_COPIERS.get(key);
}
return copier;
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.helper;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
/**
* 实体对象属性缓存类
*/
public class DEFieldCacheMap {
private static Hashtable<String, Hashtable<String,Field>> cacheMap = new Hashtable<>();
private static Hashtable<String, List<Field>> cacheList = new Hashtable<>();
private static Hashtable<String, Hashtable<String,String>> cacheKey = new Hashtable<>();
private static Object objLock1=new Object();
private static Object objLock2=new Object();
private static Object objLock3=new Object();
/**
* 将实体对象中的属性存入缓存中
* @param className
* @return
*/
public static Hashtable<String,Field> getFieldMap(String className) {
if(className.indexOf("_$")>0)
className=className.substring(0, className.lastIndexOf("_$"));
if(cacheMap.containsKey(className))
return cacheMap.get(className);
synchronized (objLock1) {
if(cacheMap.containsKey(className))
return cacheMap.get(className);
Class clazz = null;
try {
clazz = Class.forName(className);
}
catch (Exception ex) {
cacheMap.put(className, new Hashtable<String,Field>());
return cacheMap.get(className);
}
Hashtable<String,Field> result = cacheMap.get(className);
if (result == null) {
result=new Hashtable<String,Field>();
Field[] fields=clazz.getDeclaredFields();
for(Field field:fields){
result.put(field.getName(),field);
}
cacheMap.put(className, result);
}
return result;
}
}
/**
* 从缓存中查询实体对象属性列表
* @param className
* @return
*/
public static List<Field> getFields(String className) {
if(className.indexOf("_$")>0)
className=className.substring(0, className.lastIndexOf("_$"));
if(cacheList.containsKey(className))
return cacheList.get(className);
synchronized (objLock2) {
if (cacheList.containsKey(className))
return cacheList.get(className);
Hashtable<String,Field> fieldmap=DEFieldCacheMap.getFieldMap(className);
Iterator it = fieldmap.keySet().iterator();
List<Field> list=new ArrayList<Field>();
while(it.hasNext()) {
Object key = it.next();
if(fieldmap.get(key.toString())!=null)
list.add(fieldmap.get(key.toString()));
}
cacheList.put(className,list);
return list;
}
}
/**
* 从缓存中查询实体对象属性列表
* @param className
* @return
*/
public static Hashtable<String,String> getFieldKeys(String className) {
if(className.indexOf("_$")>0)
className=className.substring(0, className.lastIndexOf("_$"));
if(cacheKey.containsKey(className))
return cacheKey.get(className);
synchronized (objLock3) {
if (cacheKey.containsKey(className))
return cacheKey.get(className);
Hashtable<String,Field> fieldmap=DEFieldCacheMap.getFieldMap(className);
Iterator it = fieldmap.keySet().iterator();
Hashtable<String,String> list=new Hashtable<String,String>();
while(it.hasNext()) {
Object key = it.next();
list.put(key.toString().toLowerCase(),key.toString());
}
cacheKey.put(className,list);
return list;
}
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.helper;
import org.springframework.core.convert.converter.Converter;
import java.sql.Timestamp;
import java.time.*;
import java.util.Date;
/**
* <p>JSR310DateConverters class.</p>
*/
public final class JSR310DateConverters {
private JSR310DateConverters() {
}
public static class TimestampToDateConverter implements Converter<Timestamp, Date> {
public static final TimestampToDateConverter INSTANCE = new TimestampToDateConverter();
private TimestampToDateConverter() {
}
@Override
public Date convert(Timestamp source) {
return source == null ? null : new Date(source.getTime());
}
}
public static class DateToTimestampConverter implements Converter<Date, Timestamp> {
public static final DateToTimestampConverter INSTANCE = new DateToTimestampConverter();
private DateToTimestampConverter() {
}
@Override
public Timestamp convert(Date source) {
return source == null ? null : new Timestamp(source.getTime());
}
}
public static class LocalDateToDateConverter implements Converter<LocalDate, Date> {
public static final LocalDateToDateConverter INSTANCE = new LocalDateToDateConverter();
private LocalDateToDateConverter() {
}
@Override
public Date convert(LocalDate source) {
return source == null ? null : Date.from(source.atStartOfDay(ZoneId.systemDefault()).toInstant());
}
}
public static class DateToLocalDateConverter implements Converter<Date, LocalDate> {
public static final DateToLocalDateConverter INSTANCE = new DateToLocalDateConverter();
private DateToLocalDateConverter() {
}
@Override
public LocalDate convert(Date source) {
return source == null ? null : ZonedDateTime.ofInstant(source.toInstant(), ZoneId.systemDefault())
.toLocalDate();
}
}
public static class ZonedDateTimeToDateConverter implements Converter<ZonedDateTime, Date> {
public static final ZonedDateTimeToDateConverter INSTANCE = new ZonedDateTimeToDateConverter();
private ZonedDateTimeToDateConverter() {
}
@Override
public Date convert(ZonedDateTime source) {
return source == null ? null : Date.from(source.toInstant());
}
}
public static class DateToZonedDateTimeConverter implements Converter<Date, ZonedDateTime> {
public static final DateToZonedDateTimeConverter INSTANCE = new DateToZonedDateTimeConverter();
private DateToZonedDateTimeConverter() {
}
@Override
public ZonedDateTime convert(Date source) {
return source == null ? null : ZonedDateTime.ofInstant(source.toInstant(), ZoneId.systemDefault());
}
}
public static class LocalDateTimeToDateConverter implements Converter<LocalDateTime, Date> {
public static final LocalDateTimeToDateConverter INSTANCE = new LocalDateTimeToDateConverter();
private LocalDateTimeToDateConverter() {
}
@Override
public Date convert(LocalDateTime source) {
return source == null ? null : Date.from(source.atZone(ZoneId.systemDefault()).toInstant());
}
}
public static class DateToLocalDateTimeConverter implements Converter<Date, LocalDateTime> {
public static final DateToLocalDateTimeConverter INSTANCE = new DateToLocalDateTimeConverter();
private DateToLocalDateTimeConverter() {
}
@Override
public LocalDateTime convert(Date source) {
return source == null ? null : LocalDateTime.ofInstant(source.toInstant(), ZoneId.systemDefault());
}
}
public static class DurationToLongConverter implements Converter<Duration, Long> {
public static final DurationToLongConverter INSTANCE = new DurationToLongConverter();
private DurationToLongConverter() {
}
@Override
public Long convert(Duration source) {
return source == null ? null : source.toNanos();
}
}
public static class LongToDurationConverter implements Converter<Long, Duration> {
public static final LongToDurationConverter INSTANCE = new LongToDurationConverter();
private LongToDurationConverter() {
}
@Override
public Duration convert(Long source) {
return source == null ? null : Duration.ofNanos(source);
}
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.helper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.AnnotationBeanNameGenerator;
@Slf4j
public class UniqueNameGenerator extends AnnotationBeanNameGenerator {
@Override
public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
//全限定类名
String beanName = definition.getBeanClassName();
return beanName;
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#assign sid = sys.getId()/>
<#if sysrun.getPSDevSlnMSDepApp() ??>
<#assign sysr = sysrun.getPSDevSlnMSDepApp()!''/>
<#assign sid = sysr.getId()!sys.getId()/>
</#if>
package ${pub.getPKGCodeName()}.util.job;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import ${pub.getPKGCodeName()}.util.client.IBZUAAFeignClient;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.io.IOException;
/**
* 权限:向uaa同步当前系统菜单、权限资源任务类
*/
@Component //开启此类需要保证Main中开启了feign EnableFeignClients
public class PermissionSyncJob implements ApplicationRunner {
private Log log = LogFactory.getLog(PermissionSyncJob.class);
@Autowired
private IBZUAAFeignClient client;
@Value("${r'${ibiz.enablePermissionValid:false}'}")
boolean enablePermissionValid; //是否开启权限校验
@Value("${r'$'}{ibiz.systemid:${sid}}")
private String systemId;
@Override
public void run(ApplicationArguments args) throws Exception {
if(enablePermissionValid){
try {
InputStream permission= this.getClass().getResourceAsStream("/deprivs/DEPrivs.json"); //获取当前系统所有实体资源能力
String permissionResult = IOUtils.toString(permission,"UTF-8");
JSONArray jsonNodePermission = JSONArray.parseArray(permissionResult);
Map<String,Object> map=new HashMap<String,Object>();
map.put("menu",new JSONArray());
map.put("permission",jsonNodePermission);
client.pushSystemPermissionData(map,systemId);
}
catch (Exception ex) {
log.error(String.format("向UAA同步数据发生错误,请检查UAA服务是否正常! [%s]",ex));
}
}
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import ${pub.getPKGCodeName()}.util.domain.IBZUSER;
public interface IBZUSERMapper extends BaseMapper<IBZUSER>{
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.rest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "")
public class AppController {
@RequestMapping(method = RequestMethod.GET, value = "/appdata")
public ResponseEntity<JSONObject> getAppData() {
JSONObject appData = new JSONObject() ;
return ResponseEntity.status(HttpStatus.OK).body(appData);
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.rest;
import ${pub.getPKGCodeName()}.util.security.AuthenticationInfo;
import ${pub.getPKGCodeName()}.util.security.AuthenticationUser;
import ${pub.getPKGCodeName()}.util.security.AuthorizationLogin;
import ${pub.getPKGCodeName()}.util.security.AuthTokenUtil;
import ${pub.getPKGCodeName()}.util.service.AuthenticationUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/")
public class AuthenticationController
{
@Value(${r'"${ibiz.jwt.header:Authorization}"'})
private String tokenHeader;
@Autowired
private AuthTokenUtil jwtTokenUtil;
@Autowired
private AuthenticationUserService userDetailsService;
@PostMapping(value = ${r'"${ibiz.auth.path:v7/login}"'})
public ResponseEntity<AuthenticationInfo> login(@Validated @RequestBody AuthorizationLogin authorizationLogin){
userDetailsService.resetByUsername(authorizationLogin.getUsername());
final AuthenticationUser authuserdetail = userDetailsService.loadUserByLogin(authorizationLogin.getDomain(),authorizationLogin.getLoginname(),authorizationLogin.getPassword());
// 生成令牌
final String token = jwtTokenUtil.generateToken(authuserdetail);
// 返回 token
return ResponseEntity.ok().body(new AuthenticationInfo(token,authuserdetail));
}
@GetMapping(value = ${r'"${ibiz.auth.account:ibizutil/account}"'})
public ResponseEntity<AuthenticationUser> getUserInfo(){
UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
AuthenticationUser authuserdetail=new AuthenticationUser();
if(userDetails==null){
throw new RuntimeException("未能获取用户信息");
}
else if(userDetails instanceof AuthenticationUser ) {
authuserdetail= (AuthenticationUser)userDetails;
}
else {
authuserdetail= userDetailsService.loadUserByUsername(userDetails.getUsername());
}
return ResponseEntity.ok().body(authuserdetail);
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.rest;
import ${pub.getPKGCodeName()}.util.domain.FileItem;
import ${pub.getPKGCodeName()}.util.service.FileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
@Slf4j
public class FileController
{
@Autowired
private FileService fileService;
@PostMapping(value = "${r'${ibiz.uploadpath.path:ibizutil/upload}'}")
public ResponseEntity<FileItem> upload(@RequestParam("file") MultipartFile multipartFile){
return ResponseEntity.ok().body(fileService.saveFile(multipartFile));
}
private final String defaultdownloadpath="ibizutil/download/{id}";
protected String getDefaultdownloadpath(){
return defaultdownloadpath;
}
@GetMapping(value = "${r'${ibiz.file.downloadpath:"+defaultdownloadpath+"}'}")
@ResponseStatus(HttpStatus.OK)
public void download(@PathVariable String id, HttpServletResponse response){
File file= fileService.getFile(id);
response.setHeader("Content-Disposition", "attachment;filename="+getFileName(file.getName()));
this.sendRespose(response, file);
}
protected void sendRespose(HttpServletResponse response, File file){
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(new FileInputStream(file));
bos = new BufferedOutputStream(response.getOutputStream());
byte[] buff = new byte[2048];
int bytesRead;
while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
}
}
catch (Exception e) {
//throw e;
}
finally {
if (bis != null) {
try {
bis.close();
}
catch (IOException e) {
}
}
if (bos != null) {
try {
bos.close();
}
catch (IOException e) {
}
}
}
}
protected String getFileName(String fileName){
try {
return new String(fileName.getBytes("utf-8"),"iso8859-1");//防止中文乱码
}
catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return fileName;
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.security;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import ${pub.getPKGCodeName()}.util.domain.EntityBase;
import ${pub.getPKGCodeName()}.util.filter.QueryWrapperContext;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.PermissionEvaluator;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* spring security 权限管理类
* 重写权限控制方法
*/
@Component
public class AuthPermissionEvaluator implements PermissionEvaluator {
@Value("${r'${ibiz.enablePermissionValid:false}'}")
boolean enablePermissionValid; //是否开启权限校验
/**
* 表格权限检查 :用于检查当前用户是否拥有表格数据的读取、删除权限
*
* @param authentication
* @param obj_action 表格行为,如:[READ,DELETE]
* @param grid_param 表格参数,如:当前表格所处实体(EntityName)、表格删除的数据主键(srfkeys)
* @return true/false true则允许当前行为,false拒绝行为
*/
@Override
public boolean hasPermission(Authentication authentication, Object obj_action, Object grid_param) {
if(AuthenticationUser.getAuthenticationUser().getSuperuser()==1 || !enablePermissionValid)
return true; //系统没开启权限、超级管理员 两种情况不进行权限检查
try{
String action = "";
if (obj_action instanceof String)
action = (String) obj_action;
if (StringUtils.isEmpty(action))
return false;
JSONObject permissionList= AuthenticationUser.getAuthenticationUser().getPermisionList();//获取权限列表
if(permissionList==null)
return false;
List param_list = (ArrayList) grid_param;
if(obj_action.equals("DELETE")){ //表格删除权限校验
Object srfkey =param_list.get(0);
EntityBase cur_entity = (EntityBase) param_list.get(1);
String entityName = cur_entity.getClass().getSimpleName();
ServiceImpl service= SpringContextHolder.getBean(String.format("%s%s",getBeanName(entityName),"ServiceImpl"));//获取当前实体service
JSONObject formDataAbility=permissionList.getJSONObject("dataAbility-form");//由于表格删除是不跟着dataSet走,所以此处走form获取权限
Map<String,String> permissionField=getPermissionField(cur_entity);//获取系统预置属性列表
String selectCond=generatePermissionSQLForm(formDataAbility,entityName,action,srfkey,permissionField);//拼接权限条件
if(StringUtils.isEmpty(selectCond))
return false;
QueryWrapper permissionCond=getPermissionCond(selectCond,permissionField);
return testDataAccess(service,permissionCond);//执行权限检查
}
else{ //表格查询权限校验
Object searchContext=param_list.get(0);
String dataSet=String.valueOf(param_list.get(1));
EntityBase cur_entity = (EntityBase) param_list.get(2);
String entityName = cur_entity.getClass().getSimpleName();
if(StringUtils.isEmpty(entityName)|| StringUtils.isEmpty(dataSet)|| StringUtils.isEmpty(action))
return false;
JSONObject gridDataAbility=permissionList.getJSONObject("dataAbility-grid");//获取表格的权限数据
Map<String,String> permissionField=getPermissionField(cur_entity);//获取系统预置属性列表
String selectCond=generatePermissionSQLGrid(gridDataAbility,entityName,action,dataSet,permissionField,null);//拼接权限条件
if(StringUtils.isEmpty(selectCond))
return false;
filterDataAccess(searchContext,selectCond);//过滤出权限内的数据
}
return true;
}catch (Exception e){
throw new RuntimeException("系统在进行权限检查时出现异常,原因为:"+e);
}
}
/**
* 表单权限检查 :用于检查当前用户是否拥有表单的新建、编辑、删除权限
*
* @param authentication
* @param srfkey 当前操作数据的主键
* @param action 当前操作行为:如:[READUPDATEDELETE]
* @param cur_entity 当前操作的实体对象
* @return true/false true则允许当前行为,false拒绝行为
*/
@Override
public boolean hasPermission(Authentication authentication, Serializable srfkey, String action, Object cur_entity) {
if(AuthenticationUser.getAuthenticationUser().getSuperuser()==1 || !enablePermissionValid)
return true; //系统没开启权限、超级管理员 两种情况不进行权限检查
boolean isPermission;
EntityBase entity = null;
if (cur_entity instanceof EntityBase)
entity = (EntityBase) cur_entity;
if (StringUtils.isEmpty(entity))
return false;
try {
String entityName = entity.getClass().getSimpleName(); //实体名
if(action.equals("CREATE")){ //表单新建权限校验
JSONObject permissionList= AuthenticationUser.getAuthenticationUser().getPermisionList();//获取权限列表
JSONObject formDataAbility=permissionList.getJSONObject("dataAbility-form");//获取表单的权限数据
return isFormCreatePermission(formDataAbility,entityName,action);//拼接权限条件
}
else{
//表单编辑、查询权限校验
ServiceImpl service= SpringContextHolder.getBean(String.format("%s%s",getBeanName(entityName),"ServiceImpl"));//获取当前实体service
JSONObject permissionList= AuthenticationUser.getAuthenticationUser().getPermisionList();//获取权限列表
JSONObject formDataAbility=permissionList.getJSONObject("dataAbility-form");//获取表单的权限数据
if(isAllData(formDataAbility,entityName,action)){//若为全部数据则直接返回,不再进行校验
return true;
}
Map<String,String> permissionField=getPermissionField(entity);//获取系统预置属性
String selectCond=generatePermissionSQLForm(formDataAbility,entityName,action,srfkey,permissionField);//根据uaa中分配的权限拼接where条件
if(StringUtils.isEmpty(selectCond))
return false;
QueryWrapper permissionCond=getPermissionCond(selectCond,permissionField);
isPermission=testDataAccess(service,permissionCond);//执行权限检查
}
}catch (Exception e){
throw new RuntimeException("系统在进行权限检查时出现异常,原因为:"+e);
}
return isPermission;
}
/**
* 判断是否包含全部数据
* @param formDataAbility
* @param entityName
* @param action
* @return
*/
private boolean isAllData(JSONObject formDataAbility, String entityName, String action) {
if(formDataAbility==null)
return false;
if(!formDataAbility.containsKey(entityName))
return false;
JSONObject entityObj=formDataAbility.getJSONObject(entityName);//获取实体
if(!entityObj.containsKey(action))
return false;
JSONArray entityOperation=entityObj.getJSONArray(action);//行为:readinsert...
if(entityOperation.size()==0)
return false;
if(entityOperation.contains("ALL")){ //全部数据
return true;
}
return false;
}
/**
* 拼接表格查询条件
* @param gridDataAbility
* @param entityName
* @param action
* @param dataSet
* @param permissionField
* @param srfkey
* @return
*/
private String generatePermissionSQLGrid(JSONObject gridDataAbility, String entityName, String action, String dataSet, Map<String,String> permissionField,Object srfkey){
if(gridDataAbility==null)
return null;
if(!gridDataAbility.containsKey(entityName))
return null;
JSONObject entityObj=gridDataAbility.getJSONObject(entityName);//获取实体
if(!entityObj.containsKey(dataSet))
return null;
JSONObject dedatasetObject=entityObj.getJSONObject(dataSet);//获取实体数据集
if(!dedatasetObject.containsKey(action))
return null;
JSONArray entityOperation=dedatasetObject.getJSONArray(action);//行为:readinsert...
if(entityOperation.size()==0)
return null;
if(StringUtils.isEmpty(srfkey))
return getPermissionCond(entityOperation,permissionField); //拼接权限条件-查询
else
return String.format(" (%s) AND (%sid='%s')",getPermissionCond(entityOperation,permissionField),srfkey); //拼接权限条件-删除
}
/**
* 表格拼接权限条件,过滤出权限数据
* @param targetDomainObject
* @param permissionCond
* @throws Exception
*/
private void filterDataAccess(Object targetDomainObject, String permissionCond) throws Exception{
if(targetDomainObject instanceof QueryWrapperContext){
QueryWrapperContext queryWrapperContext = (QueryWrapperContext) targetDomainObject;
QueryWrapper queryWrapper = queryWrapperContext.getSelectCond();
queryWrapper.apply(permissionCond);
}
}
/**
* 拼接表单数据查询条件
* @param formDataAbility
* @param entityName
* @param action
* @param srfkey
* @param permissionField
* @return
*/
private String generatePermissionSQLForm(JSONObject formDataAbility, String entityName, String action, Object srfkey, Map<String,String> permissionField){
if(formDataAbility==null)
return null;
if(!formDataAbility.containsKey(entityName))
return null;
JSONObject entityObj=formDataAbility.getJSONObject(entityName);//获取实体
if(!entityObj.containsKey(action))
return null;
JSONArray entityOperation=entityObj.getJSONArray(action);//行为:readinsert...
if(entityOperation.size()==0)
return null;
String resultCond=getPermissionCond(entityOperation,permissionField);
if(StringUtils.isEmpty(srfkey))
return String.format(" (%s)",resultCond,entityName.toLowerCase()); //拼接权限条件-新建
else
return String.format(" (%s) AND (%sid='%s')",resultCond,entityName.toLowerCase(),srfkey); //拼接权限条件-编辑
}
/**
* 判断当前用户是否拥有建立表单数据权限
* @param formDataAbility
* @param entityName
* @param targetType
* @return
*/
private boolean isFormCreatePermission(JSONObject formDataAbility, String entityName, String targetType){
if(formDataAbility==null)
return false;
if(!formDataAbility.containsKey(entityName))
return false;
JSONObject entityObj=formDataAbility.getJSONObject(entityName);//获取实体
if(!entityObj.containsKey(targetType))
return false;
return true;
}
/**
* 表单权限检查
* @param service
* @param permissionCond
* @return
*/
private boolean testDataAccess(ServiceImpl service, QueryWrapper permissionCond){
boolean isPermission=false;
List list=service.list(permissionCond);
if(list.size()>0)
isPermission=true;
return isPermission;
}
/**
* 拼接权限条件(表单/表格)共用
* @param entityOperation
* @param permissionField
* @return
*/
private String getPermissionCond(JSONArray entityOperation, Map<String,String> permissionField){
String orgField=permissionField.get("orgfield");
String orgDeptField=permissionField.get("orgsecfield");
StringBuffer permissionSQL=new StringBuffer();
AuthenticationUser authenticationUser = AuthenticationUser.getAuthenticationUser();
JSONObject userInfo = authenticationUser.getOrgInfo();
JSONObject orgObject = userInfo.getJSONObject("org");
JSONArray orgParent = orgObject.getJSONArray("porg");
JSONArray orgChild = orgObject.getJSONArray("sorg");
JSONObject orgDeptObject = userInfo.getJSONObject("orgdept");
JSONArray orgDeptParent = orgDeptObject.getJSONArray("porgdept");
JSONArray orgDeptChild = orgDeptObject.getJSONArray("sorgdept");
for(int i=0;i<entityOperation.size();i++){
if(i>0 && (!StringUtils.isEmpty(permissionSQL.toString())))
permissionSQL.append("OR");
String permissionCond=entityOperation.getString(i);//权限配置条件
if(permissionCond.equals("CURORG")){ //本单位
permissionSQL.append(String.format("(%s='%s')",orgField,AuthenticationUser.getAuthenticationUser().getOrgid()));
}
if(permissionCond.equals("SORG")){//下级单位
permissionSQL.append(String.format(" %s in(%s) ", orgField, formatStringArr(orgChild)));
}
if(permissionCond.equals("PORG")){//上级单位
permissionSQL.append(String.format(" %s in(%s) ", orgField, formatStringArr(orgParent)));
}
if(permissionCond.equals("CREATEMAN")){//建立人
permissionSQL.append(String.format("(createman='%s')",AuthenticationUser.getAuthenticationUser().getUserid()));
}
if(permissionCond.equals("CURORGDEPT")){//本部门
permissionSQL.append(String.format("(orgsecid='%s')",AuthenticationUser.getAuthenticationUser().getMdeptid()));
}
if(permissionCond.equals("SORGDEPT")){//下级部门
permissionSQL.append(String.format(" %s in (%s) ", orgDeptField, formatStringArr(orgDeptChild)));
}
if(permissionCond.equals("PORGDEPT")){//上级部门
permissionSQL.append(String.format(" %s in (%s) ", orgDeptField, formatStringArr(orgDeptParent)));
}
if(permissionCond.equals("ALL")){//全部数据
permissionSQL.append("(1=1)");
}
}
if(StringUtils.isEmpty(permissionSQL.toString()))
return "";
String resultCond=permissionSQL.toString();
if(resultCond.endsWith("OR")){
resultCond=resultCond.substring(0,resultCond.lastIndexOf("OR"));
}
return resultCond;
}
/**
* 拼接权限查询条件(表单/表格)共用
* @param whereCond
* @param permissionField
* @return
*/
private QueryWrapper getPermissionCond(String whereCond, Map<String,String> permissionField){
QueryWrapper allPermissionCond=new QueryWrapper();
if(StringUtils.isEmpty(whereCond))
return allPermissionCond;
allPermissionCond.apply(whereCond);
return allPermissionCond;
}
/**
* 获取实体权限字段 orgid/orgsecid
* @param entityBase
* @return
*/
private Map<String,String> getPermissionField(EntityBase entityBase){
Map<String,String> permissionFiled=new HashMap<>();
String orgField="orgid"; //组织权限默认值
String orgsecField="orgsecid"; //部门权限默认值
// Map<Field, PreField> preFields= entityBase.SearchPreField(); //从缓存中获取当前类预置属性
// //寻找实体权限属性
// for (Map.Entry<Field,PreField> entry : preFields.entrySet()){
// Field prefield=entry.getKey();//获取注解字段
// PreField fieldAnnotation=entry.getValue();//获取注解值
// PredefinedType prefieldType=fieldAnnotation.preType();
// if(prefieldType==PredefinedType.ORGID)//用户配置系统预置属性-组织机构标识
// orgField=prefield.getName();
// if(prefieldType==PredefinedType.ORGSECTORID)//用户配置系统预置属性-部门标识
// orgsecField=prefield.getName();
// }
permissionFiled.put("orgfield",orgField);
permissionFiled.put("orgsecfield",orgsecField);
return permissionFiled;
}
/**
* 获取bean名称
* @param className
* @return
*/
private String getBeanName(String className) {
if (Character.isLowerCase(className.charAt(0))) {
return className;
} else {
return (new StringBuilder()).append(Character.toLowerCase(className.charAt(0))).append(className.substring(1)).toString();
}
}
/**
* 转换[a,b]格式字符串到 'a','b'格式
*
* @return
*/
private String formatStringArr(JSONArray array) {
String[] arr = array.toArray(new String[array.size()]);
return "'" + String.join("','", arr) + "'";
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.security;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Clock;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.impl.DefaultClock;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
@Component
public class AuthTokenUtil implements Serializable {
private static final long serialVersionUID = -3301605591108950415L;
private Clock clock = DefaultClock.INSTANCE;
@Value(${r'"${ibiz.jwt.secret:ibzsecret}"'})
private String secret;
@Value(${r'"${ibiz.jwt.expiration:7200000}"'})
private Long expiration;
@Value(${r'"${ibiz.jwt.header:Authorization}"'})
private String tokenHeader;
public String getUsernameFromToken(String token) {
return getClaimFromToken(token, Claims::getSubject);
}
public Date getIssuedAtDateFromToken(String token) {
return getClaimFromToken(token, Claims::getIssuedAt);
}
public Date getExpirationDateFromToken(String token) {
return getClaimFromToken(token, Claims::getExpiration);
}
public <T> T getClaimFromToken(String token, Function<Claims, T> claimsResolver) {
final Claims claims = getAllClaimsFromToken(token);
return claimsResolver.apply(claims);
}
private Claims getAllClaimsFromToken(String token) {
return Jwts.parser()
.setSigningKey(secret)
.parseClaimsJws(token)
.getBody();
}
private Boolean isTokenExpired(String token) {
final Date expiration = getExpirationDateFromToken(token);
return expiration.before(clock.now());
}
private Boolean isCreatedBeforeLastPasswordReset(Date created, Date lastPasswordReset) {
return (lastPasswordReset != null && created.before(lastPasswordReset));
}
private Boolean ignoreTokenExpiration(String token) {
// here you specify tokens, for that the expiration is ignored
return false;
}
public String generateToken(UserDetails userDetails) {
Map<String, Object> claims = new HashMap<>();
return doGenerateToken(claims, userDetails.getUsername());
}
private String doGenerateToken(Map<String, Object> claims, String subject) {
final Date createdDate = clock.now();
final Date expirationDate = calculateExpirationDate(createdDate);
return Jwts.builder()
.setClaims(claims)
.setSubject(subject)
.setIssuedAt(createdDate)
.setExpiration(expirationDate)
.signWith(SignatureAlgorithm.HS512, secret)
.compact();
}
public Boolean canTokenBeRefreshed(String token, Date lastPasswordReset) {
final Date created = getIssuedAtDateFromToken(token);
return !isCreatedBeforeLastPasswordReset(created, lastPasswordReset)
&& (!isTokenExpired(token) || ignoreTokenExpiration(token));
}
public String refreshToken(String token) {
final Date createdDate = clock.now();
final Date expirationDate = calculateExpirationDate(createdDate);
final Claims claims = getAllClaimsFromToken(token);
claims.setIssuedAt(createdDate);
claims.setExpiration(expirationDate);
return Jwts.builder()
.setClaims(claims)
.signWith(SignatureAlgorithm.HS512, secret)
.compact();
}
public Boolean validateToken(String token, UserDetails userDetails) {
AuthenticationUser user = (AuthenticationUser) userDetails;
final Date created = getIssuedAtDateFromToken(token);
return (!isTokenExpired(token) );
}
private Date calculateExpirationDate(Date createdDate) {
return new Date(createdDate.getTime() + expiration);
}
/**
* Get the login of the current user.
*
* @return the login of the current user
*/
public static Optional<String> getCurrentUserLogin() {
SecurityContext securityContext = SecurityContextHolder.getContext();
return Optional.ofNullable(securityContext.getAuthentication())
.map(authentication -> {
if (authentication.getPrincipal() instanceof UserDetails) {
UserDetails springSecurityUser = (UserDetails) authentication.getPrincipal();
return springSecurityUser.getUsername();
} else if (authentication.getPrincipal() instanceof String) {
return (String) authentication.getPrincipal();
}
return null;
});
}
/**
* Check if a user is authenticated.
*
* @return true if the user is authenticated, false otherwise
*/
public static boolean isAuthenticated() {
SecurityContext securityContext = SecurityContextHolder.getContext();
return Optional.ofNullable(securityContext.getAuthentication())
.map(authentication -> authentication.getAuthorities().stream()
.noneMatch(grantedAuthority -> grantedAuthority.getAuthority().equals("ANONYMOUS")))
.orElse(false);
}
/**
* If the current user has a specific authority (security role).
* <p>
* The name of this method comes from the isUserInRole() method in the Servlet API
*
* @param authority the authority to check
* @return true if the current user has the authority, false otherwise
*/
public static boolean isCurrentUserInRole(String authority) {
SecurityContext securityContext = SecurityContextHolder.getContext();
return Optional.ofNullable(securityContext.getAuthentication())
.map(authentication -> authentication.getAuthorities().stream()
.anyMatch(grantedAuthority -> grantedAuthority.getAuthority().equals(authority)))
.orElse(false);
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.security;
import org.springframework.security.core.AuthenticationException;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;
@Component
public class AuthenticationEntryPoint implements org.springframework.security.web.AuthenticationEntryPoint, Serializable {
private static final long serialVersionUID = -8970718410437077606L;
@Override
public void commence(HttpServletRequest request,
HttpServletResponse response,
AuthenticationException authException) throws IOException {
/**
* 当用户尝试访问安全的REST资源而不提供任何凭据时,将调用此方法发送401 响应
*/
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException==null?"Unauthorized":authException.getMessage());
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.security;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.io.Serializable;
@Getter
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class AuthenticationInfo implements Serializable {
private final String token;
private final AuthenticationUser user;
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.security;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.util.ObjectUtils;
import java.util.Map;
import java.util.HashMap;
import java.sql.Timestamp;
import java.util.Collection;
import com.alibaba.fastjson.JSONObject;
@Data
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class AuthenticationUser implements UserDetails
{
public AuthenticationUser()
{
}
private String userid;
private String username;
private String personname;
private String usercode;
private String loginname;
private String password;
private String domain;
private String mdeptid;
private String mdeptcode;
private String mdeptname;
private String bcode;
private String postid;
private String postcode;
private String postname;
private String orgid;
private String orgcode;
private String orgname;
private String nickname;
private String email;
private String avatar;
private String phone;
private String reserver;
private String usericon;
private String sex;
private Timestamp birthday;
private String certcode;
private String addr;
private String theme;
private String fontsize;
private String lang;
private String memo;
private Map <String,String> sessionParams;
@JsonIgnore
private Collection<GrantedAuthority> authorities;
@JsonIgnore
private int superuser;
@JsonIgnore
private JSONObject permisionList;
private String orglevel;//单位级别
private String deptlevel;//部门级别
@JsonIgnore
private Map<String,String> userSessionParam;//用户自定义session
@JsonIgnore
private JSONObject orgInfo;//上下级组织信息
@JsonIgnore
@Override
public boolean isAccountNonExpired() {
return true;
}
@JsonIgnore
@Override
public boolean isAccountNonLocked() {
return true;
}
@JsonIgnore
@Override
public boolean isCredentialsNonExpired() {
return true;
}
@JsonIgnore
@Override
public String getPassword() {
return password;
}
@Override
public boolean isEnabled() {
return true;
}
public static AuthenticationUser getAuthenticationUser()
{
if(SecurityContextHolder.getContext()==null||SecurityContextHolder.getContext().getAuthentication()==null||SecurityContextHolder.getContext().getAuthentication().getPrincipal()==null){
return new AuthenticationUser();
}
Object userDetails = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
AuthenticationUser authuserdetail;
if(userDetails instanceof AuthenticationUser ) {
authuserdetail= (AuthenticationUser)userDetails;
}
else {
authuserdetail=new AuthenticationUser();
}
return authuserdetail;
}
public Map <String,String> getSessionParams()
{
if(this.sessionParams==null)
{
sessionParams = getUserSessionParam();
sessionParams.put("srfpersonid", this.getUserid());
sessionParams.put("srfpersonname", this.getPersonname());
sessionParams.put("srforgsectorid", this.getMdeptid());
sessionParams.put("srforgsectorcode", this.getMdeptcode());
sessionParams.put("srforgsectorname", this.getMdeptname());
sessionParams.put("srforgid", this.getOrgid());
sessionParams.put("srforgcode", this.getOrgcode());
sessionParams.put("srforgname", this.getOrgname());
sessionParams.put("srfuserid", this.getUserid());
sessionParams.put("srfusername", this.getPersonname());
sessionParams.put("srfusermode", "");
sessionParams.put("srforgsectorbc", this.getBcode());
sessionParams.put("srfloginname", this.getLoginname());
sessionParams.put("srflocale", this.getLang());
sessionParams.put("srftimezone", "");
sessionParams.put("srfusercode", this.getUsercode());
}
return this.sessionParams;
}
private Map<String, String> getUserSessionParam() {
if(userSessionParam!=null)
return userSessionParam;
else
return new HashMap<>();
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.security;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.StringUtils;
import javax.validation.constraints.NotBlank;
@Getter
@Setter
@JsonIgnoreProperties(ignoreUnknown = true)
public class AuthorizationLogin
{
private String domain;
@NotBlank(message="用户名不能为空")
private String loginname;
@NotBlank(message="密码不能为空")
private String password;
public String getUsername()
{
if(!StringUtils.isEmpty(domain))
return loginname+"|"+domain;
return loginname;
}
@Override
public String toString()
{
return "AuthorizationLogin{" +
"domain='" + domain + '\'' +
", loginname='" + loginname + '\'' +
", password='××××××'}";
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.security;
import io.jsonwebtoken.ExpiredJwtException;
import lombok.extern.slf4j.Slf4j;
import ${pub.getPKGCodeName()}.util.service.AuthenticationUserService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Slf4j
@Component
public class AuthorizationTokenFilter extends OncePerRequestFilter {
private final UserDetailsService userDetailsService;
private final AuthTokenUtil authTokenUtil;
private final String tokenHeader;
public AuthorizationTokenFilter(AuthenticationUserService userDetailsService, AuthTokenUtil authTokenUtil, @Value(${r'"${ibiz.jwt.header:Authorization}"'}) String tokenHeader) {
this.userDetailsService = userDetailsService;
this.authTokenUtil = authTokenUtil;
this.tokenHeader = tokenHeader;
}
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException {
final String requestHeader = request.getHeader(this.tokenHeader);
String username = null;
String authToken = null;
if (requestHeader != null && requestHeader.startsWith("Bearer ")) {
authToken = requestHeader.substring(7);
try {
username = authTokenUtil.getUsernameFromToken(authToken);
} catch (ExpiredJwtException e) {
log.error(e.getMessage());
}
}
if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
// It is not compelling necessary to load the use details from the database. You could also store the information
// in the token and read it from it. It's up to you ;)
UserDetails userDetails = this.userDetailsService.loadUserByUsername(username);
// For simple validation it is completely sufficient to just check the token integrity. You don't have to call
// the database compellingly. Again it's up to you ;)
if (authTokenUtil.validateToken(authToken, userDetails)) {
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
log.info("authorizated user '{}', setting security context", username);
SecurityContextHolder.getContext().setAuthentication(authentication);
}
}
chain.doFilter(request, response);
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.security;
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()}.util.service;
import ${pub.getPKGCodeName()}.util.errors.BadRequestAlertException;
import ${pub.getPKGCodeName()}.util.security.AuthenticationUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.stereotype.Service;
public interface AuthenticationUserService extends UserDetailsService {
@Override
@Cacheable( value="ibzdict_users",key = "'getByUsername:'+#p0")
AuthenticationUser loadUserByUsername(String username);
@Cacheable( value="ibzdict_users",key = "'getByUsername:'+#p0")
AuthenticationUser loadUserByLogin(String username,String password);
@Cacheable( value="ibzdict_users",key = "'getByUsername:'+#p1")
AuthenticationUser loadUserByLogin(String domain,String username,String password);
@CacheEvict( value="ibzdict_users",key = "'getByUsername:'+#p0")
void resetByUsername(String username);
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.service;
import ${pub.getPKGCodeName()}.util.domain.FileItem;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
public interface FileService
{
FileItem saveFile(MultipartFile multipartFile);
File getFile(String fileid);
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.service;
import ${pub.getPKGCodeName()}.util.domain.IBZUSER;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* 实体[IBZUSER] 服务对象接口实现
*/
public interface IBZUSERService extends IService<IBZUSER> {
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import ${pub.getPKGCodeName()}.util.security.AuthenticationUser;
import ${pub.getPKGCodeName()}.util.errors.BadRequestAlertException;
import ${pub.getPKGCodeName()}.util.helper.CachedBeanCopier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import ${pub.getPKGCodeName()}.util.mapper.IBZUSERMapper;
import ${pub.getPKGCodeName()}.util.domain.IBZUSER;
import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils;
/**
* 实体[IBZUSER] 服务对象接口实现
*/
@Service("IBZUSERService")
public class IBZUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> implements IBZUSERService,AuthenticationUserService{
@Value(${r'"${ibiz.auth.pwencrymode:0}"'})
private int pwencrymode;
@Override
public AuthenticationUser loadUserByUsername(String username) {
if(StringUtils.isEmpty(username))
throw new UsernameNotFoundException("用户名为空");
QueryWrapper<IBZUSER> conds=new QueryWrapper<IBZUSER>();
String[] data=username.split("[|]");
String loginname="";
String domains="";
if(data.length>0)
loginname=data[0].trim();
if(data.length>1)
domains=data[1].trim();
if(!StringUtils.isEmpty(loginname))
conds.eq("loginname",loginname);
if(!StringUtils.isEmpty(domains))
conds.eq("domains",domains);
IBZUSER user = this.getOne(conds);
if (user == null) {
throw new UsernameNotFoundException("用户" + username + "未找到");
}
else {
user.setUsername(username);
return createUserDetails(user);
}
}
@Override
public AuthenticationUser loadUserByLogin(String username, String password){
AuthenticationUser authuserdetail = loadUserByUsername(username);
if(pwencrymode==1)
password = DigestUtils.md5DigestAsHex(password.getBytes());
else if(pwencrymode==2)
password = DigestUtils.md5DigestAsHex(String.format("%1$s||%2$s", username, password).getBytes());
if(!authuserdetail.getPassword().equals( password )){
throw new BadRequestAlertException("用户名密码错误","IBZUSER",username);
}
return authuserdetail;
}
@Override
public AuthenticationUser loadUserByLogin(String domain, String username, String password) {
if(!StringUtils.isEmpty(domain))
username = username+"|"+domain;
return loadUserByLogin(username,password);
}
public void resetByUsername(String username) {
}
public AuthenticationUser createUserDetails(IBZUSER user) {
AuthenticationUser userdatail = new AuthenticationUser();
CachedBeanCopier.copy(user,userdatail);
return userdatail;
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.service;
import ${pub.getPKGCodeName()}.util.domain.FileItem;
import com.cmbchina.util.errors.InternalServerErrorException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.UUID;
@Primary
@Slf4j
@Service
public class SimpleFileService implements FileService {
@Value("${r'${ibiz.filePath:/app/file/}'}")
private String fileRoot;
@Override
public FileItem saveFile(MultipartFile multipartFile) {
FileItem item=null;
// 获取文件名
String fileName = multipartFile.getOriginalFilename();
// 获取文件后缀
String extname="."+getExtensionName(fileName);
// uuid作为文件名,防止生成的临时文件重复
String fileid= UUID.randomUUID().toString();
String fileFullPath = this.fileRoot+"ibztuit"+File.separator+fileid+File.separator+fileName;
File file = new File(fileFullPath);
File parent = new File(file.getParent());
if(!parent.exists())
parent.mkdirs();
try {
FileCopyUtils.copy(multipartFile.getInputStream() , Files.newOutputStream(file.toPath()));
item=new FileItem(fileid,fileName, (int)multipartFile.getSize() ,extname);
} catch (IOException e) {
throw new InternalServerErrorException("文件上传失败");
}
return item;
}
@Override
public File getFile(String fileid) {
String dirpath = this.fileRoot+"ibztuit"+File.separator+fileid;
File parent = new File(dirpath);
if (parent.exists() && parent.isDirectory() && parent.listFiles().length > 0) {
return parent.listFiles()[0];
}
throw new InternalServerErrorException("文件未找到");
}
/**
* 获取文件扩展名
* @param filename
* @return
*/
public static String getExtensionName(String filename) {
if ((filename != null) && (filename.length() > 0)) {
int dot = filename.lastIndexOf('.');
if ((dot >-1) && (dot < (filename.length() - 1))) {
return filename.substring(dot + 1);
}
}
return filename;
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#assign sid = sys.getId()/>
<#if sysrun.getPSDevSlnMSDepApp() ??>
<#assign sysr = sysrun.getPSDevSlnMSDepApp()!''/>
<#assign sid = sysr.getId()!sys.getId()/>
</#if>
package ${pub.getPKGCodeName()}.util.service;
import ${pub.getPKGCodeName()}.util.security.AuthenticationUser;
import ${pub.getPKGCodeName()}.util.client.IBZUAAFeignClient;
import ${pub.getPKGCodeName()}.util.client.IBZOUFeignClient;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
/**
* 实体[IBZUSER] 服务对象接口实现
*/
@Primary
@Service("SimpleUserService")
public class SimpleUserService implements AuthenticationUserService{
@Value("${r'${ibiz.enablePermissionValid:false}'}")
boolean enablePermissionValid; //是否开启权限校验
@Value("${r'$'}{ibiz.systemid:${sid}}")
private String systemid;
@Autowired
private IBZUAAFeignClient uaaFeignClient;
@Autowired
private IBZOUFeignClient ouFeignClient;
@Override
public AuthenticationUser loadUserByUsername(String username) {
AuthenticationUser user = new AuthenticationUser();
String[] data=username.split("[|]");
String loginname=username;
String domains="";
String password="";
if(data.length==3) {
loginname=data[0].trim();
domains=data[1].trim();
password=data[2].trim();
}
else if(data.length==2) {
loginname=data[0].trim();
password=data[1].trim();
}
user.setUserid(DigestUtils.md5DigestAsHex(username.getBytes()));
user.setUsercode(loginname);
user.setUsername(username);
user.setLoginname(loginname);
user.setPersonname(loginname);
user.setDomain(domains);
user.setPassword(password);
user.setOrgid(domains);
user.setOrgcode(domains);
user.setOrgname(domains);
setUserPermission(user);
setUserOrgInfo(user);
return user;
}
@Override
public AuthenticationUser loadUserByLogin(String username, String password) {
password = DigestUtils.md5DigestAsHex(String.format("%1$s||%2$s", username, password).getBytes());
AuthenticationUser authuserdetail = loadUserByUsername(username+"|"+password);
return authuserdetail;
}
@Override
public AuthenticationUser loadUserByLogin(String domain, String username, String password) {
if(!StringUtils.isEmpty(domain))
username = username+"|"+domain;
return loadUserByLogin(username,password);
}
@Override
public void resetByUsername(String username) {
}
/**
* 设置用户权限
*/
private void setUserPermission(AuthenticationUser user) {
if(enablePermissionValid){
JSONObject permission= uaaFeignClient.getUserPermissionData(user.getLoginname(),systemid);
user.setPermisionList(permission);
}
}
/**
* 设置用户组织相关信息
* @param user
*/
private void setUserOrgInfo(AuthenticationUser user) {
if(enablePermissionValid) {
JSONObject orgInfo=ouFeignClient.getOrgInfo(user.getLoginname());
if(orgInfo==null)
throw new RuntimeException("获取用户信息失败,请检查用户中心[IBZOU]中是否存在当前用户!");
user.setOrgInfo(orgInfo);
}
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#comment>通用配置文件</#comment>
<#assign nacosUrl = "172.16.102.211:8848" >
<#if sysrun?? >
<#if sysrun.getPSDevSlnMSDepApp()??>
<#assign sysr = sysrun.getPSDevSlnMSDepApp()/>
<#if sysr.getPSDCMSPlatformNode()??>
<#if sysr.getPSDCMSPlatformNode().getPSDCMSPlatform().getUserParam("nacos","172.16.102.211:8848")??>
<#assign nacosUrl = sysr.getPSDCMSPlatformNode().getPSDCMSPlatform().getUserParam("nacos","172.16.102.211:8848")>
</#if>
</#if>
</#if>
</#if>
#nacos配置中心、数据源
spring:
cloud:
nacos:
discovery:
server-addr: ${nacosUrl}
<#if sysrun.getPSDBDevInst()??>
<#assign dbinst = sysrun.getPSDBDevInst()>
datasource:
username: ${dbinst.getUserName()}
password: '${dbinst.getPassword()}'
url: ${dbinst.getConnUrl()}
driver-class-name: <#if (dbinst.getDBType()=='MYSQL5')>com.mysql.jdbc.Driver<#elseif (dbinst.getDBType()=='DB2')>com.ibm.db2.jcc.DB2Driver<#elseif (dbinst.getDBType()=='ORACLE')>oracle.jdbc.driver.OracleDriver<#elseif (dbinst.getDBType()=='SQLSERVER')>com.microsoft.sqlserver.jdbc.SQLServerDriver<#elseif (dbinst.getDBType()=='POSTGRESQL')>org.postgresql.Driver<#elseif (dbinst.getDBType()=='PPAS')>com.edb.Driver</#if>
filters: stat,wall,log4j2
#配置初始化大小/最小/最大
initial-size: 1
min-idle: 1
max-active: 20
#获取连接等待超时时间
max-wait: 60000
#间隔多久进行一次检测,检测需要关闭的空闲连接
time-between-eviction-runs-millis: 60000
#一个连接在池中最小生存的时间
min-evictable-idle-time-millis: 300000
validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
#打开PSCache,并指定每个连接上PSCache的大小。oracle设为true,mysql设为false。分库分表较多推荐设置为false
pool-prepared-statements: false
max-pool-prepared-statement-per-connection-size: 20
isSyncDBSchema: false
defaultSchema: ${dbinst.getUserName()}
conf: classpath:liquibase/master.xml
</#if>
#Mybatis-plus配置
mybatis-plus:
global-config:
refresh-mapper: true
db-config:
# 全局逻辑已删除默认值
logic-delete-value: 0
# 全局逻辑未删除默认值
logic-not-delete-value: 1
mapper-locations: classpath*:/mapper/*/*/*.xml
configuration:
jdbc-type-for-null: 'null'
map-underscore-to-camel-case: false
#阿里sentinel熔断器
feign:
sentinel:
enabled: true
#Log配置
logging:
level:
${pub.getPKGCodeName()}: debug
org.springframework.boot.autoconfigure: ERROR
#zuul网关超时设置
ribbon:
ReadTimeout: 60000
ConnectTimeout: 60000
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
*target
.settings
*node_modules
*bin
*.project
*.classpath
*.factorypath
.history
.vscode
.idea
**.iml
*.jar
*.log
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
# 系统概览
<#if 1==2>
## 系统后台体系
<#if sys.getAllPSSysSFPubs()??>
<#if srfemptylist(sys.getAllPSSysSFPubs())>
<#else>
<#list sys.getAllPSSysSFPubs() as pub>
* ${pub.getPSSFStyle().getName()}
</#list>
</#if>
</#if>
## 系统模块
<#-- 系统模块 -->
<#if sys.getAllPSSystemModules()??>
<#if srfemptylist(sys.getAllPSSystemModules())>
暂无系统模块
<#else>
<#list sys.getAllPSSystemModules() as module>
<#if !module.isSubSysModule()>
### ${module.getName()}
| 实体编号 | 实体名称 | 实体类型 | 备注 |
| -------- |------------| ----- | -------- |
<#if sys.getAllPSDataEntities()??>
<#list sys.getAllPSDataEntities() as entity>
<#if (!entity.getPSSystemModule().isSubSysModule() && (module.getId() == entity.getPSSystemModule().getId()) )>
|${entity.getName()}|${entity.getLogicName()}|${srfcodelist2("DEType",entity.getDEType())}|&nbsp;${entity.getMemo()}|
</#if>
</#list>
</#if>
</#if>
</#list>
</#if>
</#if>
<#-- 实体信息
## 实体信息
<#if sys.getAllPSDataEntities()??>
<#list sys.getAllPSDataEntities() as entity>
### ${entity.getLogicName()}
| 属性名称 | 中文名称 | 类型 | 备注 |
| -------- |------------| ----- | -------- |
<#if entity.getAllPSDEFields()??>
<#list entity.getAllPSDEFields() as field>
|${field.getName()}|${field.getLogicName()}|${field.getDataType()}|&nbsp;${field.getMemo()}|
</#list>
</#if>
</#list>
</#if>
-->
## 业务流程
<#if srfemptylist(sys.getAllPSWorkflows())>
暂无业务流程
<#else>
<#list sys.getAllPSWorkflows() as workflow>
### ${workflow.getName()}
</#list>
</#if>
## 外部系统接口
<#if srfemptylist(sys.getAllPSSubSysServiceAPIs())>
暂无外部系统接口
<#else>
<#list sys.getAllPSSubSysServiceAPIs() as subapi>
* ${subapi.getName()}
</#list>
</#if>
## 服务
<#if srfemptylist(sys.getAllPSSysServiceAPIs())>
暂无服务
<#else>
<#list sys.getAllPSSysServiceAPIs() as api>
* ${api.getName()}
</#list>
</#if>
## 系统应用
<#if sys.getAllPSApps()??>
<#if srfemptylist(sys.getAllPSApps())>
暂无系统应用
<#else>
| 应用名称 | 应用类型 | 技术架构 | 技术模板 | 备注 |
| -------- | ------------ | -----------| -----------| -----------|
<#if sys.getAllPSApps()??>
<#list sys.getAllPSApps() as app>
| ${app.getName()} | ${app.getPSPF().getPSAppType().getName()} | ${app.getPSPF().getName()}| ${app.getPSPFStyle().getName()} | &nbsp;${app.getMemo()} |
</#list>
</#if>
</#if>
</#if>
<#-- 数据库相关信息 -->
## 支持数据库
<#if sys.getAllPSSystemDBConfigs()??>
<#if srfemptylist(sys.getAllPSSystemDBConfigs())>
暂无数据库支持
<#else>
<#list sys.getAllPSSystemDBConfigs() as dbcfg>
### ${dbcfg.getName()}
<#-- 表结构 -->
<#list sys.getAllPSDataEntities() as entity>
<#if !entity.getPSSystemModule().isSubSysModule()>
<#if entity.getPSDEDBConfig(dbcfg.getDBType())??>
<#assign dedbconfig=entity.getPSDEDBConfig(dbcfg.getDBType())>
#### **${entity.getLogicName()}** (${dedbconfig.getTableName()})
| 字段 | 中文名称 | 类型 | 长度 | 备注 |
| -------- |------------| :-----: | :----: | :--------- |
<#list dedbconfig.getAllPSDEFDTColumns() as decolumn>
| ${decolumn.getColumnName()} | ${decolumn.getPSDEField().getLogicName()} | ${decolumn.getDBDataType()} | <#if decolumn.getLength() gt 0>${decolumn.getLength()}</#if> | <#if decolumn.getPSDEField().isKeyDEField()>主键</#if>&nbsp;${decolumn.getMemo()} |
</#list>
<#if sys.getPSSysDMItems(dbcfg.getName()) ??>
<#list sys.getPSSysDMItems(dbcfg.getName()) as dmitem>
<#if (dmitem.getPSDEId() == entity.getId()) && (dmitem.getPSSystemDBCfgId()==dbcfg.id) && (dmitem.getDBObjType() == 'TABLE')>
<#if dmitem.getCreateSql()?? && dmitem.getCreateSql()?length gt 0>
```sql
${dmitem.getCreateSql()}
```
</#if>
</#if>
<#--
<#if ((dmitem.getPSDEId() == entity.getId()) && dmitem.getPSSystemDBCfgId()==dbcfg.id) && (dmitem.getDBObjType() == 'VIEW')>
<#if dmitem.getCreateSql()?? && dmitem.getCreateSql()?length gt 0>
视图
```sql
${dmitem.getCreateSql()}
```
</#if>
</#if>
-->
</#list>
</#if>
</#if>
</#if>
</#list>
<#-- 表结构 -->
</#list>
</#if>
<#else>
暂无数据库支持
</#if>
<#-- 数据字典 -->
## 数据字典
<#if sys.getAllPSCodeLists()??>
<#list sys.getAllPSCodeLists() as codelist>
<#if codelist.getPSCodeListTemplId()?default("")?trim?length gt 0>
<#else>
<#if codelist.getPSSystemModule()??>
<#if (!codelist.getPSSystemModule().isSubSysModule() && !codelist.isSubSysCodeList() && (codelist.getCodeListType() == 'STATIC') )>
## ${codelist.getName()}
| 数据项 | 数据值 | 备注 |
| -------- |------------| --------- |
<#if codelist.getAllPSCodeItems()??>
<#list codelist.getAllPSCodeItems() as codeitem>
|${codeitem.getName()}|${codeitem.getValue()}|&nbsp;${codeitem.getMemo()}|
</#list>
</#if>
</#if>
</#if>
</#if>
</#list>
</#if>
</#if>
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#if pub.getPSDeployCenter()?? && sysrun.getRunMode()??>
<#if pub.getPSDeployCenter().getDeployCenterType()?? && (pub.getPSDeployCenter().getDeployCenterType()=="JENKINS") >
<#if sysrun.getRunMode() == "STARTMSAPI">
<#assign depapi = sysrun.getPSDevSlnMSDepAPI()>
<#assign configId = depapi.getId()>
<#assign config = "api"+depapi.getName()>
<#assign depnode = sysrun.getPSDevSlnMSDepAPI().getPSDCMSPlatformNode()>
<#elseif sysrun.getRunMode() == "STARTMSAPP">
<#assign depapp = sysrun.getPSDevSlnMSDepApp()>
<#assign configId = depapp.getId()>
<#assign config = "app"+depapp.getName()>
<#assign depnode = sysrun.getPSDevSlnMSDepApp().getPSDCMSPlatformNode()>
</#if>
<#if sys.getPSSVNInstRepo().getGitBranch()?? && sys.getPSSVNInstRepo().getGitBranch()!="">
<#assign branch=sys.getPSSVNInstRepo().getGitBranch()>
<#else>
<#assign branch='master'>
</#if>
<?xml version='1.1' encoding='UTF-8'?>
<project>
<actions/>
<description>${sys.codeName}</description>
<keepDependencies>false</keepDependencies>
<properties>
<hudson.model.ParametersDefinitionProperty>
<parameterDefinitions>
<hudson.model.StringParameterDefinition>
<name>para1</name>
<description></description>
<defaultValue>para1</defaultValue>
<trim>false</trim>
</hudson.model.StringParameterDefinition>
<hudson.model.StringParameterDefinition>
<name>para2</name>
<description></description>
<defaultValue>para2</defaultValue>
<trim>false</trim>
</hudson.model.StringParameterDefinition>
</parameterDefinitions>
</hudson.model.ParametersDefinitionProperty>
</properties>
<scm class="hudson.scm.NullSCM"/>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers/>
<concurrentBuild>false</concurrentBuild>
<builders>
<hudson.tasks.Shell>
<command>
BUILD_ID=DONTKILLME
source /etc/profile
rm -rf ${sys.codeName?lower_case}
git clone -b ${branch} $para2 ${sys.codeName?lower_case}/
export NODE_OPTIONS=--max-old-space-size=4096
cd ${sys.codeName?lower_case}/
<#if sysrun.getRunMode() == "STARTMSAPP">
mvn clean package -P${pub.getPSApplication().getPKGCodeName()?lower_case}
cd ${pub.getCodeName()?lower_case}-app/${pub.getCodeName()?lower_case}-app-${pub.getPSApplication().getPKGCodeName()?lower_case}
mvn -P${pub.getPSApplication().getPKGCodeName()?lower_case} docker:build
mvn -P${pub.getPSApplication().getPKGCodeName()?lower_case} docker:push
docker -H tcp://172.16.102.110:2375 stack deploy --compose-file=src/main/docker/${pub.getCodeName()?lower_case}-app-${pub.getPSApplication().getPKGCodeName()?lower_case}.yaml dev --with-registry-auth
echo &apos;echo &quot;$para1&quot;&apos; &gt; apppasswd.sh
chmod -R 777 *
setsid env SSH_ASKPASS=&apos;./apppasswd.sh&apos; DISPLAY=&apos;none:0&apos; ssh ${depnode.getSSHUserName()}@${depnode.getSSHIPAddr()} &quot;mkdir -p ${depnode.getWorkshopPath()}/${configId}&quot;
setsid env SSH_ASKPASS=&apos;./apppasswd.sh&apos; DISPLAY=&apos;none:0&apos; scp -r ${pub.getCodeName()?lower_case}-app-${pub.getPSApplication().getPKGCodeName()?lower_case}.jar ${depnode.getSSHUserName()}@${depnode.getSSHIPAddr()}:${depnode.getWorkshopPath()}/${configId}
setsid env SSH_ASKPASS=&apos;./apppasswd.sh&apos; DISPLAY=&apos;none:0&apos; ssh ${depnode.getSSHUserName()}@${depnode.getSSHIPAddr()} &quot;ps -ef | grep &apos;${depnode.getWorkshopPath()}/${configId}&apos;| tr -s &apos; &apos;|cut -d&apos; &apos; -f2,8,9 | grep -v grep | grep &apos;jar&apos; | cut -d&apos; &apos; -f1|xargs --no-run-if-empty kill -9&quot;
setsid env SSH_ASKPASS=&apos;./apppasswd.sh&apos; DISPLAY=&apos;none:0&apos; ssh ${depnode.getSSHUserName()}@${depnode.getSSHIPAddr()} &quot;source /etc/profile;source ~/.bash_profile; nohup java -jar -Xms512m -Xmx1024m -XX:PermSize=128M -XX:MaxPermSize=128m ${depnode.getWorkshopPath()}/${configId}/${pub.getCodeName()?lower_case}-app-${pub.getPSApplication().getPKGCodeName()?lower_case}.jar &gt;&gt;${depnode.getWorkshopPath()}/${configId}/${sys.codeName?lower_case}_${config?lower_case}-`date --date=&apos;0 days ago&apos; +%Y-%m-%d`.log 2&gt;&amp;1 &amp;&quot;
</#if>
<#if sysrun.getRunMode() == "STARTMSAPI">
mvn clean package -P${pub.getPSSysServiceAPI().getCodeName()?lower_case}
cd ${pub.getCodeName()?lower_case}-provider/${pub.getCodeName()?lower_case}-provider-${pub.getPSSysServiceAPI().getCodeName()?lower_case}
mvn -P${pub.getPSSysServiceAPI().getCodeName()?lower_case} docker:build
mvn -P${pub.getPSSysServiceAPI().getCodeName()?lower_case} docker:push
docker -H tcp://172.16.102.110:2375 stack deploy --compose-file=src/main/docker/${pub.getCodeName()?lower_case}-provider-${pub.getPSSysServiceAPI().getCodeName()?lower_case}.yaml dev --with-registry-auth
echo &apos;echo &quot;$para1&quot;&apos; &gt; apppasswd.sh
chmod -R 777 *
setsid env SSH_ASKPASS=&apos;./apppasswd.sh&apos; DISPLAY=&apos;none:0&apos; ssh ${depnode.getSSHUserName()}@${depnode.getSSHIPAddr()} &quot;mkdir -p ${depnode.getWorkshopPath()}/${configId}&quot;
setsid env SSH_ASKPASS=&apos;./apppasswd.sh&apos; DISPLAY=&apos;none:0&apos; scp -r ${pub.getCodeName()?lower_case}-provider-${pub.getPSSysServiceAPI().getCodeName()?lower_case}.jar ${depnode.getSSHUserName()}@${depnode.getSSHIPAddr()}:${depnode.getWorkshopPath()}/${configId}
setsid env SSH_ASKPASS=&apos;./apppasswd.sh&apos; DISPLAY=&apos;none:0&apos; ssh ${depnode.getSSHUserName()}@${depnode.getSSHIPAddr()} &quot;ps -ef | grep &apos;${depnode.getWorkshopPath()}/${configId}&apos;| tr -s &apos; &apos;|cut -d&apos; &apos; -f2,8,9 | grep -v grep | grep &apos;jar&apos; | cut -d&apos; &apos; -f1|xargs --no-run-if-empty kill -9&quot;
setsid env SSH_ASKPASS=&apos;./apppasswd.sh&apos; DISPLAY=&apos;none:0&apos; ssh ${depnode.getSSHUserName()}@${depnode.getSSHIPAddr()} &quot;source /etc/profile;source ~/.bash_profile; nohup java -jar -Xms512m -Xmx1024m -XX:PermSize=128M -XX:MaxPermSize=128m ${depnode.getWorkshopPath()}/${configId}/${pub.getCodeName()?lower_case}-provider-${pub.getPSSysServiceAPI().getCodeName()?lower_case}.jar &gt;&gt;${depnode.getWorkshopPath()}/${configId}/${sys.codeName?lower_case}_${config?lower_case}-`date --date=&apos;0 days ago&apos; +%Y-%m-%d`.log 2&gt;&amp;1 &amp;&quot;
</#if>
</command>
</hudson.tasks.Shell>
</builders>
<publishers>
<hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup@0.34">
<patterns class="empty-list"/>
<deleteDirs>false</deleteDirs>
<skipWhenFailed>false</skipWhenFailed>
<cleanWhenSuccess>true</cleanWhenSuccess>
<cleanWhenUnstable>true</cleanWhenUnstable>
<cleanWhenFailure>true</cleanWhenFailure>
<cleanWhenNotBuilt>true</cleanWhenNotBuilt>
<cleanWhenAborted>true</cleanWhenAborted>
<notFailBuild>false</notFailBuild>
<cleanupMatrixParent>false</cleanupMatrixParent>
<externalDelete></externalDelete>
</hudson.plugins.ws__cleanup.WsCleanup>
</publishers>
<buildWrappers/>
</project>
</#if>
</#if>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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}</artifactId>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<version>${pub.getVersionString()?default("V0.0.1_alpha")}</version>
<name>${pub.getCodeName()?lower_case?cap_first}</name>
<description>${pub.getMemo()?default(pub.getName())}</description>
<packaging>pom</packaging>
<parent>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<artifactId>${pub.getCodeName()?lower_case}-dependencies</artifactId>
<version>${pub.getVersionString()?default("V0.0.1_alpha")}</version>
<relativePath>${pub.getCodeName()?lower_case}-dependencies/pom.xml</relativePath>
</parent>
<#-- modules -->
<modules>
<!-- dependencies -->
<module>${pub.getCodeName()?lower_case}-dependencies</module>
<!-- utils -->
<module>${pub.getCodeName()?lower_case}-util</module>
<!-- cores -->
<module>${pub.getCodeName()?lower_case}-core</module>
<!-- services -->
<module>${pub.getCodeName()?lower_case}-provider</module>
<!-- apps -->
<module>${pub.getCodeName()?lower_case}-app</module>
<!-- boot -->
<module>${pub.getCodeName()?lower_case}-boot</module>
</modules>
<repositories>
<repository>
<id>aliyunmaven</id>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</project>
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册