提交 983f1c83 编写于 作者: tony001's avatar tony001

update:更新

上级 878e4400
{{name}}:{ {{name}}:{
action:{
loadAction: '{{ctrl.getPSControlAction.psAppDEMethod.codeName}}', loadAction: '{{ctrl.getPSControlAction.psAppDEMethod.codeName}}',
removeAction: '{{ctrl.removePSControlAction.psAppDEMethod.codeName}}', removeAction: '{{ctrl.removePSControlAction.psAppDEMethod.codeName}}',
updateAction: '{{ctrl.updatePSControlAction.psAppDEMethod.codeName}}', updateAction: '{{ctrl.updatePSControlAction.psAppDEMethod.codeName}}',
loadDraftAction: '{{ctrl.getDraftPSControlAction.psAppDEMethod.codeName}}', loadDraftAction: '{{ctrl.getDraftPSControlAction.psAppDEMethod.codeName}}',
createAction: '{{ctrl.createPSControlAction.psAppDEMethod.codeName}}' createAction: '{{ctrl.createPSControlAction.psAppDEMethod.codeName}}'
} }
}
\ No newline at end of file
...@@ -59,7 +59,7 @@ const { state, handleToolbarEvent } = new EditView(ViewConfig).moduleInstall(pro ...@@ -59,7 +59,7 @@ const { state, handleToolbarEvent } = new EditView(ViewConfig).moduleInstall(pro
:showBusyIndicator="true" :showBusyIndicator="true"
:context="state.context" :context="state.context"
:viewParams="state.viewParams" :viewParams="state.viewParams"
:controlAction="state.controlsAction.{{name}}" :controlAction="state.{{name}}.action"
:viewSubject="state.viewSubject" :viewSubject="state.viewSubject"
></{{codeName}}Form> ></{{codeName}}Form>
{{/eq}} {{/eq}}
......
<?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>{{projectName}}</artifactId>
<groupId>{{packageName}}</groupId>
<version>1.0.0.0</version>
</parent>
<artifactId>{{projectName}}-provider</artifactId>
<name>{{projectDesc}} Provider</name>
<packaging>pom</packaging>
<description>{{projectDesc}} Provider</description>
<modules>
{{#each system.apis}}
<module>{{projectName}}-provider-{{lowerCase codeName}}</module>
{{/each}}
</modules>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
<?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>{{projectName}}-provider</artifactId>
<groupId>{{packageName}}</groupId>
<version>1.0.0.0</version>
</parent>
<artifactId>{{projectName}}-provider-{{lowerCase api.codeName}}</artifactId>
<name>{{projectDesc}} Microservice {{lowerCase api.codeName}}</name>
<description> microservice</description>
<packaging>${project.packaging}</packaging>
<dependencies>
<dependency>
<groupId>{{packageName}}</groupId>
<artifactId>{{projectName}}-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<properties>
<project.packaging>jar</project.packaging>
<docker.image.prefix>registry.cn-shanghai.aliyuncs.com/ibizsys</docker.image.prefix>
</properties>
<profiles>
<profile>
<id>{{lowerCase api.codeName}}</id>
<build>
<resources>
<resource>
<directory>${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>{{projectName}}-provider-api</finalName>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<mainClass>{{packageName}}.api.{{system.codeName}}{{api.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>${docker.image.prefix}/${project.artifactId}:latest</imageName>
<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>../../</directory>
<include>${project.artifactId}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>prepare</id>
<configuration>
<executable>cp</executable>
<arguments>
<argument>../../${project.artifactId}.jar</argument>
<argument>${project.basedir}/src/main/docker/</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>buildpush</id>
<configuration>
<executable>docker</executable>
<arguments>
<argument>buildx</argument>
<argument>build</argument>
<argument>--platform</argument>
<argument>linux/amd64,linux/arm64</argument>
<argument>-t</argument>
<argument>${docker.image.prefix}/${project.artifactId}:latest</argument>
<argument>${project.basedir}/src/main/docker</argument>
<argument>--push</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>{{lowerCase api.codeName}}-war</id>
<properties>
<project.packaging>war</project.packaging>
</properties>
<build>
<resources>
<resource>
<directory>${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>{{projectName}}-provider-api</finalName>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<mainClass>{{packageName}}.api.{{system.codeName}}{{api.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>${docker.image.prefix}/${project.artifactId}:latest</imageName>
<dockerDirectory>${project.basedir}/src/main/dockerwar</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>../../</directory>
<include>${project.artifactId}.war</include>
</resource>
</resources>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>prepare</id>
<configuration>
<executable>cp</executable>
<arguments>
<argument>../../${project.artifactId}.war</argument>
<argument>${project.basedir}/src/main/dockerwar/</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>buildpush</id>
<configuration>
<executable>docker</executable>
<arguments>
<argument>buildx</argument>
<argument>build</argument>
<argument>--platform</argument>
<argument>linux/arm64</argument>
<argument>-t</argument>
<argument>${docker.image.prefix}/${project.artifactId}:latest</argument>
<argument>${project.basedir}/src/main/dockerwar</argument>
<argument>--push</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
FROM image.ibizlab.cn/library/openjdk:8-jre-alpine
ENV TZ="Asia/Shanghai" \
SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \
IBIZ_SLEEP=0 \
JAVA_OPTS=""
CMD echo "The application will start in ${IBIZ_SLEEP}s..." && \
sleep ${IBIZ_SLEEP} && \
java ${JAVA_OPTS} -Duser.timezone=$TZ -Djava.security.egd=file:/dev/./urandom -jar /{{projectName}}-provider-{{lowerCase api.codeName}}.jar
EXPOSE {{#if app.httpPort}}{{app.httpPort}}{{else}}8080{{/if}}
ADD {{projectName}}-provider-{{lowerCase api.codeName}}.jar /{{projectName}}-provider-{{lowerCase api.codeName}}.jar
package {{packageName}}.swagger;
import cn.ibizlab.util.security.SpringContextHolder;
import cn.ibizlab.util.web.IBZOperationParameterReader;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.plugin.core.PluginRegistry;
import org.springframework.plugin.core.PluginRegistrySupport;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.schema.EnumTypeDeterminer;
import springfox.documentation.spi.service.OperationBuilderPlugin;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.spring.web.readers.operation.OperationParameterReader;
import springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
@Configuration
@EnableSwagger2
@ConditionalOnExpression("${swagger.enable:false}")
public class SwaggerConfiguration {
@Bean
public Docket docket() {
Docket docket = new Docket(DocumentationType.SWAGGER_2)
.groupName("DEFAULT")
.pathMapping("/")
.apiInfo(
new ApiInfoBuilder()
.title("DEFAULT")
.build()
)
.select()
.apis(RequestHandlerSelectors.basePackage("{{packageName}}"))
//.paths(or(regex("/rest/.*")))
.paths(PathSelectors.any())
.build();
removeDefaultPlugin();
return docket ;
}
@Bean
public Docket {{lowerCase api.codeName}}Docket() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("{{api.name}}")
.pathMapping("/")
.apiInfo(
new ApiInfoBuilder()
.title("{{api.name}}")
.version("{{api.aPIVersion}}")
.build()
)
.select()
.apis(RequestHandlerSelectors.basePackage("{{packageName}}.{{api.codeName}}"))
.paths(PathSelectors.any())
.build();
}
private void removeDefaultPlugin() {
// 从spring容器中获取swagger插件注册表
PluginRegistry<OperationBuilderPlugin, DocumentationType> pluginRegistry = SpringContextHolder.getBean("operationBuilderPluginRegistry");
// 插件集合
List<OperationBuilderPlugin> plugins = pluginRegistry.getPlugins();
// 从spring容器中获取需要删除的插件
OperationParameterReader operationParameterReader = SpringContextHolder.getBean(OperationParameterReader.class);
if(operationParameterReader==null)
return ;
// 原plugins集合不能修改,创建新集合,通过反射替换
if (pluginRegistry.contains(operationParameterReader)) {
List<OperationBuilderPlugin> plugins_new = new ArrayList<OperationBuilderPlugin>(plugins);
plugins_new.remove(operationParameterReader);
try {
Field field = PluginRegistrySupport.class.getDeclaredField("plugins");
field.setAccessible(true);
field.set(pluginRegistry, plugins_new);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Bean
public IBZOperationParameterReader iBZOperationParameterReader(ModelAttributeParameterExpander expander,EnumTypeDeterminer enumTypeDeterminer){
IBZOperationParameterReader iBZOperationParameterReader = new IBZOperationParameterReader(expander, enumTypeDeterminer) ;
return iBZOperationParameterReader ;
}
}
package {{packageName}}.{{lowerCase api.codeName}}.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;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
import org.springframework.context.annotation.Import;
{{#if system.enableGlobalTransaction}}
@Import({com.alibaba.cloud.seata.feign.SeataFeignClientAutoConfiguration.class})
{{/if}}
@Configuration
@ConditionalOnClass({{api.codeName}}RestConfiguration.class)
@ConditionalOnWebApplication
@EnableConfigurationProperties({{api.codeName}}ServiceProperties.class)
public class {{api.codeName}}AutoConfiguration implements ApplicationContextAware {
protected ApplicationContext applicationContext;
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
@Bean("asyncExecutor")
public Executor asyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(10);
executor.setMaxPoolSize(20);
executor.setQueueCapacity(2000);
executor.setKeepAliveSeconds(600);
executor.setThreadNamePrefix("asyncExecutor-");
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
return executor;
}
// @Bean
// public ServletRegistrationBean {{api.codeName}}Servlet() {
// AnnotationConfigWebApplicationContext dispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();
// dispatcherServletConfiguration.setParent(applicationContext);
// dispatcherServletConfiguration.register({{api.codeName}}RestConfiguration.class);
// DispatcherServlet servlet = new DispatcherServlet(dispatcherServletConfiguration);
// String path = "/{{lowerCase api.codeName}}";
// String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*");
// ServletRegistrationBean registrationBean = new ServletRegistrationBean(servlet, urlMapping);
// registrationBean.setName("{{api.codeName}}");
// return registrationBean;
// }
}
package {{packageName}}.{{lowerCase api.codeName}}.config;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan("{{packageName}}.{{lowerCase api.codeName}}")
public class {{api.codeName}}RestConfiguration {
}
package {{packageName}}.{{lowerCase api.codeName}}.config;
import cn.ibizlab.util.security.AuthenticationEntryPoint;
import cn.ibizlab.util.security.AuthorizationTokenFilter;
import cn.ibizlab.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;
import org.springframework.beans.factory.annotation.Qualifier;
@Profile("{{lowerCase api.codeName}}-prod")
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class {{api.codeName}}SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private AuthenticationEntryPoint unauthorizedHandler;
@Autowired
private AuthenticationUserService userDetailsService;
/**
* 自定义基于JWT的安全过滤器
*/
@Autowired
AuthorizationTokenFilter authenticationTokenFilter;
@Value("${ibiz.auth.path:v7/login}")
private String loginPath;
@Value("${ibiz.auth.logoutpath:v7/logout}")
private String logoutPath;
@Value("${ibiz.file.uploadpath:ibizutil/upload}")
private String uploadpath;
@Value("${ibiz.file.downloadpath:ibizutil/download}")
private String downloadpath;
@Value("${ibiz.file.previewpath:ibizutil/preview}")
private String previewpath;
@Value("${ibiz.auth.excludesPattern:}")
private String[] excludesPattern;
@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/**",
"/",
"webjars/**",
"/swagger-resources/**",
"/v2/**"
).permitAll()
//放行登录请求
.antMatchers( HttpMethod.POST, "/"+loginPath).permitAll()
//放行注销请求
.antMatchers( HttpMethod.GET, "/"+logoutPath).permitAll()
// 文件操作
.antMatchers("/"+downloadpath+"/**").permitAll()
.antMatchers("/"+uploadpath).permitAll()
.antMatchers("/"+previewpath+"/**").permitAll();
for (String excludePattern : excludesPattern) {
authenticationTokenFilter.addExcludePattern(excludePattern);
httpSecurity.authorizeRequests().antMatchers(excludePattern).permitAll();
}
// 所有请求都需要认证
httpSecurity.authorizeRequests().anyRequest().authenticated()
// 防止iframe 造成跨域
.and().headers().frameOptions().disable();
httpSecurity
.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
}
}
package {{packageName}}.{{lowerCase api.codeName}}.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import lombok.Data;
@ConfigurationProperties(prefix = "service.{{lowerCase api.codeName}}")
@Data
public class {{api.codeName}}ServiceProperties {
private boolean enabled;
private boolean auth;
}
\ No newline at end of file
{{#unless apiDto.apiEntity.subSysDE}}
package {{packageName}}.{{apis}}.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.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.alibaba.fastjson.annotation.JSONField;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import cn.ibizlab.util.domain.DTOBase;
import cn.ibizlab.util.domain.DTOClient;
import lombok.*;
import lombok.experimental.Accessors;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* 服务DTO对象[{{apiDto.codeName}}]
*/
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@ApiModel("{{apiDto.logicName}}")
public class {{apiDto.codeName}} extends {{#eq apiDto.apiEntity.entity.psSubSysServiceAPI.serviceType "MIDDLEPLATFORM"}}DTOClient{{else}}DTOBase{{/eq}} implements Serializable {
private static final long serialVersionUID = 1L;
{{#each apiDto.apiDtoFields}}
/**
* {{logicName}}
*/
@JsonProperty("{{jsonName}}")
{{#timeType}}
@JsonFormat(pattern = "{{format}}", locale = "zh", timezone = "GMT+8")
{{/timeType}}
@JSONField(name = "{{jsonName}}"{{#timeType}} , format = "{{format}}"{{/timeType}})
{{#eq javaType "Long"}}
@JsonSerialize(using = ToStringSerializer.class)
{{/eq}}
@ApiModelProperty("{{logicName}}")
private {{javaType}} {{camelCase codeName}};
{{/each}}
{{#each apiDto.apiDtoFields}}
{{#unless keyDEField}}
{{#unless predefinedType}}
/**
* 设置 [{{logicName}}]
*/
public {{apiDto.codeName}} set{{pascalCase codeName}}({{javaType}} {{camelCase codeName}}) {
this.{{camelCase codeName}} = {{camelCase codeName}};
this.modify("{{lowerCase name}}", {{camelCase codeName}});
return this;
}
{{/unless}}
{{/unless}}
{{/each}}
}
{{/unless}}
\ No newline at end of file
{{#eq apiEntity.codeName ""}}
{{#unless apiEntity.subSysDE}}
package {{packageName}}.{{lowerCase apiEntity.api.codeName}}.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.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.alibaba.fastjson.annotation.JSONField;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import cn.ibizlab.util.domain.DTOBase;
import cn.ibizlab.util.domain.DTOClient;
import lombok.*;
import lombok.experimental.Accessors;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* 服务DTO对象[{{apiEntity.codeName}}DTO]
*/
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@ApiModel("{{apiEntity.logicName}}")
public class {{apiEntity.codeName}}DTO extends {{#eq apiEntity.entity.psSubSysServiceAPI.serviceType "MIDDLEPLATFORM"}}DTOClient{{else}}DTOBase{{/eq}} implements Serializable {
private static final long serialVersionUID = 1L;
{{#each apiEntity.properties}}
{{#unless deepStructure}}
/**
* {{logicName}}
*/
@JsonProperty("{{jsonName}}")
{{#timeType}}
@JsonFormat(pattern = "{{format}}", locale = "zh", timezone = "GMT+8")
{{/timeType}}
@JSONField(name = "{{jsonName}}"{{#timeType}} , format = "{{format}}"{{/timeType}})
{{#eq type.java "Long"}}
@JsonSerialize(using = ToStringSerializer.class)
{{/eq}}
@ApiModelProperty("{{logicName}}")
private {{type.java}} {{camelCase codeName}};
{{/unless}}
{{/each}}
{{#each apiEntity.entity.nesteds}}
/**
* {{entityLogicName}}
*/
@JSONField(name = "{{pluralize codeName}}")
@JsonProperty("{{pluralize codeName}}")
private List<{{packageName}}.core.{{module}}.domain.{{entityCodeName}}> {{camelCase codeName}};
{{/each}}
{{#each apiEntity.properties}}
{{#unless deepStructure}}
{{#unless keyDEField}}
{{#unless predefinedType}}
/**
* 设置 [{{logicName}}]
*/
public {{apiEntity.codeName}}DTO set{{pascalCase codeName}}({{type.java}} {{camelCase codeName}}) {
this.{{camelCase codeName}} = {{camelCase codeName}};
this.modify("{{lowerCase name}}", {{camelCase codeName}});
return this;
}
{{/unless}}
{{/unless}}
{{/unless}}
{{/each}}
{{#apiEntity.entity.nesteds}}
{{#columnName}}
/**
* 设置 [{{entityLogicName}}]
*/
public {{apiEntity.codeName}}DTO set{{pascalCase codeName}}(List<{{packageName}}.core.{{module}}.domain.{{entityCodeName}}> {{camelCase codeName}}) {
this.{{camelCase codeName}} = {{camelCase codeName}};
this.modify("{{columnName}}", ({{camelCase codeName}}!=null)?{{camelCase codeName}}:(new ArrayList()));
return this;
}
{{/columnName}}
{{/apiEntity.entity.nesteds}}
}
{{/unless}}
{{/eq}}
\ No newline at end of file
{{#unless apiDto.apiEntity.subSysDE}}
package {{packageName}}.{{apis}}.mapping;
{{#with apiDto.apiEntity.entity as | entity | }}
import org.mapstruct.*;
import {{packageName}}.core.{{entity.module}}.domain.{{entity.codeName}};
import {{packageName}}.{{apis}}.dto.{{apiDto.codeName}};
import cn.ibizlab.util.domain.MappingBase;
@Mapper(componentModel = "spring", uses = {}, implementationName = "{{api.codeName}}{{apiDto.codeName}}Mapping",
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE,
nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface {{apiDto.codeName}}Mapping extends MappingBase<{{apiDto.codeName}}, {{entity.codeName}}> {
}
{{/with}}
{{/unless}}
\ No newline at end of file
{{#eq apiEntity.codeName ""}}
{{#unless apiEntity.subSysDE}}
package {{packageName}}.{{lowerCase apiEntity.api.codeName}}.mapping;
{{#with apiEntity.entity as | entity | }}
import org.mapstruct.*;
import {{packageName}}.core.{{entity.module}}.domain.{{entity.codeName}};
import {{packageName}}.{{lowerCase apiEntity.api.codeName}}.dto.{{apiEntity.codeName}}DTO;
import cn.ibizlab.util.domain.MappingBase;
@Mapper(componentModel = "spring", uses = {}, implementationName = "{{api.codeName}}{{apiEntity.codeName}}Mapping",
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE,
nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface {{apiEntity.codeName}}Mapping extends MappingBase<{{apiEntity.codeName}}DTO, {{entity.codeName}}> {
}
{{/with}}
{{/unless}}
{{/eq}}
\ No newline at end of file
{{#unless nested}}
{{#neq apiEntity.entity.storage "NONE"}}
package {{packageName}}.{{lowerCase apiEntity.api.codeName}}.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;
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 org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.validation.annotation.Validated;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import {{packageName}}.{{lowerCase apiEntity.api.codeName}}.dto.*;
import {{packageName}}.{{lowerCase apiEntity.api.codeName}}.mapping.*;
import {{packageName}}.core.{{apiEntity.entity.module}}.domain.{{apiEntity.entity.codeName}};
import {{packageName}}.core.{{apiEntity.entity.module}}.service.I{{apiEntity.entity.codeName}}Service;
import {{packageName}}.core.{{apiEntity.entity.module}}.filter.{{apiEntity.entity.codeName}}SearchContext;
import cn.ibizlab.util.annotation.VersionCheck;
@Slf4j
@Api(tags = {"{{apiEntity.entity.logicName}}" })
@RestController("{{lowerCase apiEntity.api.codeName}}-{{lowerCase apiEntity.codeName}}")
@RequestMapping("")
public class {{apiEntity.codeName}}Resource {
@Autowired
public I{{apiEntity.entity.codeName}}Service {{camelCase apiEntity.entity.codeName}}Service;
{{#each apiEntity.dtos}}
{{#eq type "DEFAULT"}}
@Autowired
@Lazy
public {{codeName}}Mapping {{camelCase codeName}}Mapping;
{{/eq}}
{{/each}}
{{#each apiEntity.methods}}
@ApiOperation(value = "{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.{{requestMethod}}, value = "{{requestPath}}")
public ResponseEntity {{camelCase name}}({{#each pathVariables}}{{#unless @first}}, {{/unless}}@PathVariable("{{camelCase name}}") {{type.java}} {{camelCase name}}{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}@Validated @RequestBody {{body}} {{camelCase body}}{{/if}}) {
{{!行为}}
{{#eq methodType "DEACTION"}}
{{!行为参数准备}}
{{#eq input.type "DTO"}}
{{apiEntity.entity.codeName}} {{camelCase apiEntity.entity.codeName}} = {{camelCase input.pSDEMethodDTO.name}}Mapping.toDomain({{camelCase body}});
{{#each pathVariables}}
{{#if @last}}
{{camelCase apiEntity.entity.codeName}}.set{{pascalCase name}}({{camelCase name}});
{{/if}}
{{/each}}
{{camelCase apiEntity.entity.codeName}}Service.{{camelCase name}}({{camelCase apiEntity.entity.codeName}});
{{/eq}}
{{#eq input.type "KEYFIELD"}}
{{#eq return.type "DTO"}}
{{apiEntity.entity.codeName}} {{camelCase apiEntity.entity.codeName}} = {{camelCase apiEntity.entity.codeName}}Service.{{camelCase name}}({{camelCase apiEntity.entity.keyField.codeName}});
{{/eq}}
{{#neq return.type "DTO"}}
{{camelCase apiEntity.entity.codeName}}Service.{{camelCase name}}({{camelCase apiEntity.entity.keyField.codeName}});
{{/neq}}
{{/eq}}
{{!返回处理}}
{{#eq return.type "DTO"}}
return ResponseEntity.status(HttpStatus.OK).body({{camelCase return.pSDEMethodDTO.name}}Mapping.toDto({{camelCase apiEntity.entity.codeName}}));
{{/eq}}
{{#eq return.type "SIMPLE"}}
return ResponseEntity.status(HttpStatus.OK).body(0);
{{/eq}}
{{#eq return.type "KEYFIELD"}}
{{/eq}}
{{#eq return.type "VOID"}}
return ResponseEntity.status(HttpStatus.OK).body(true);
{{/eq}}
{{/eq}}
{{!数据集}}
{{#eq methodType "FETCH"}}
{{#each pathVariables}}
{{#if @last}}
{{camelCase body}}.set{{pascalCase name}}EQ({{camelCase name}});
{{/if}}
{{/each}}
Page<{{apiEntity.entity.codeName}}> domains = {{camelCase apiEntity.entity.codeName}}Service.search{{pSDEDataSet.codeName}}({{camelCase body}}) ;
List<{{return.pSDEMethodDTO.name}}> list = {{camelCase return.pSDEMethodDTO.name}}Mapping.toDto(domains.getContent());
return ResponseEntity.status(HttpStatus.OK)
.header("x-page", String.valueOf({{camelCase body}}.getPageable().getPageNumber()))
.header("x-per-page", String.valueOf({{camelCase body}}.getPageable().getPageSize()))
.header("x-total", String.valueOf(domains.getTotalElements()))
.body(list);
{{/eq}}
{{!SELECT法}}
{{#eq methodType "SELECT"}}
return ResponseEntity.status(HttpStatus.OK).body(null);
{{/eq}}
}
{{/each}}
}
{{/neq}}
{{/unless}}
\ No newline at end of file
package {{packageName}}.{{lowerCase api.codeName}};
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.context.annotation.Import;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import cn.ibizlab.util.web.SearchContextHandlerMethodArgumentResolver;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
@Slf4j
@EnableDiscoveryClient
@Configuration
@EnableTransactionManagement
@ComponentScan(basePackages = {"{{packageName}}"}
// ,excludeFilters={
// @ComponentScan.Filter(type= org.springframework.context.annotation.FilterType.REGEX,pattern="{{packageName}}.${item.codeName?lower_case}.rest.xxx"),
// }
)
@EnableMongoRepositories(basePackages = {"{{packageName}}"})
@MapperScan("{{packageName}}.*.mapper")
@SpringBootApplication(exclude = {
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
{{#unless system.enableMongo}}
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration.class,
{{/unless}}
{{#if system.enableDS}}
com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure.class
{{/if}}
})
@Import({
org.springframework.cloud.openfeign.FeignClientsConfiguration.class
})
@EnableFeignClients(basePackages = {"{{packageName}}" })
@EnableAsync
@EnableScheduling
public class {{system.codeName}}{{api.codeName}}Application extends WebMvcConfigurerAdapter{
@Autowired
SearchContextHandlerMethodArgumentResolver resolver;
public static void main(String[] args) {
SpringApplication.run({{system.codeName}}{{api.codeName}}Application.class, args);
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
super.addArgumentResolvers(argumentResolvers);
argumentResolvers.add(resolver);
}
}
package {{packageName}}.{{lowerCase api.codeName}};
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/**
* 提供外部容器启动服务能力
*/
@Slf4j
public class {{system.codeName}}{{api.codeName}}Initializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
log.info("--正在使用外部容器启动服务--");
return builder.sources({{system.codeName}}{{api.codeName}}Application.class);
}
}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册