提交 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>
<#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>
<#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=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=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);
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册