提交 13eacd10 编写于 作者: ibiz4j's avatar ibiz4j

提交

上级 9b80a1ca
......@@ -21,6 +21,8 @@ public class ApiEntityModel extends BaseModel {
private List<ApiDtoModel> dtos = new ArrayList<>();
private ApiDtoModel defaultDto;
private String apiName;
public String getApiName()
......@@ -38,7 +40,10 @@ public class ApiEntityModel extends BaseModel {
this.setId(String.format("%1$s-%2$s", api.getCodeName(), apiDataEntity.getCodeName()));
if (apiDataEntity.getPSDataEntity() != null && apiDataEntity.getPSDataEntity().getAllPSDEMethodDTOs() != null) {
for (IPSDEMethodDTO iPSDEMethodDTO : apiDataEntity.getPSDataEntity().getAllPSDEMethodDTOs()) {
dtos.add(new ApiDtoModel(this, iPSDEMethodDTO));
ApiDtoModel dto=new ApiDtoModel(this, iPSDEMethodDTO);
dtos.add(dto);
if(dto.codeName.equalsIgnoreCase(this.codeName+"dto"))
defaultDto=dto;
}
}
......
......@@ -187,7 +187,7 @@
../
</output>
<inputSpec>
${basedir}/src/main/resources/model/com/sa/jcsc
${basedir}/src/main/resources/model/{{replace packageName "." "/"}}
</inputSpec>
<templateDirs>
${basedir}/src/main/resources/templ/ibiz-boot
......
......@@ -10,7 +10,7 @@
</parent>
<artifactId>{{projectName}}-boot</artifactId>
<name>{{projectDesc}} Dev Monolithic Boot</name>
<name>{{projectDesc}} Boot</name>
<description>{{projectDesc}} Boot</description>
<dependencies>
......@@ -20,43 +20,59 @@
<version>${project.version}</version>
</dependency>
</dependencies>
<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}}</finalName>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<mainClass>{{packageName}}.BootApplication</mainClass>
<outputDirectory>../</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>cn.ibizlab</groupId>
<artifactId>ibizlab-generator-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<output>
../
</output>
<inputSpec>
${basedir}/src/main/resources/model/{{replace packageName "." "/"}}
</inputSpec>
<templateDirs>
${basedir}/src/main/resources/templ/ibizlab
</templateDirs>
<embedTemplate>
ibizlab
</embedTemplate>
<packageName>
${project.groupId}
</packageName>
<name>
${parent.artifactId}
</name>
</configuration>
<!--由于boot是通过dependency来关联所有子项目,页面和配置等信息都存在与子项目中,
所以您在对boot进行打包前,需要先将子项目install到maven仓库,以确保boot可以正常引用所有完整的子项目-->
<profiles>
<profile>
<id>boot</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}}</finalName>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<mainClass>{{packageName}}.DevBootApplication</mainClass>
<outputDirectory>../</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</plugin>
</plugins>
</build>
</project>
......@@ -26,9 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
{{#unless system.enableMongo}}
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration.class,
{{/unless}}
{{#unless system.enableDS}}
com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure.class
{{/unless}}
})
@ComponentScan(basePackages = {"{{packageName}}","cn.ibizlab.util"}
// ,excludeFilters = {
......@@ -40,13 +38,13 @@ import org.springframework.beans.factory.annotation.Autowired;
})
@EnableAsync
@EnableScheduling
public class DevBootApplication extends WebMvcConfigurerAdapter {
public class BootApplication extends WebMvcConfigurerAdapter {
@Autowired
SearchContextHandlerMethodArgumentResolver resolver;
public static void main(String[] args) {
SpringApplication.run(DevBootApplication.class, args);
SpringApplication.run(BootApplication.class, args);
}
@Override
......
......@@ -12,7 +12,7 @@ import java.util.concurrent.ThreadPoolExecutor;
{{#if system.enableGlobalTransaction}}
@Import({com.alibaba.cloud.seata.feign.SeataFeignClientAutoConfiguration.class})
{{/if}}
public class DevBootAutoConfiguration {
public class BootAutoConfiguration {
@Bean("asyncExecutor")
public Executor asyncExecutor() {
......
......@@ -9,7 +9,7 @@ import org.springframework.stereotype.Component;
@Component
@Slf4j
public class DevBootHeaderFilter extends ZuulFilter {
public class BootHeaderFilter extends ZuulFilter {
@Override
public String filterType() {
......
......@@ -24,7 +24,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter {
public class BootSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private AuthenticationEntryPoint unauthorizedHandler;
......
spring:
profiles:
include: sys , nacos ,{{#each system.apps}} {{lowerCase codeName}}-dev ,{{/each}}{{#each system.apis}} {{lowerCase codeName}}-dev ,{{/each}} dev
include: sys, nacos, boot, dev
application:
name: {{lowerCase system.codeName}}
name: {{lowerCase system.name}}
main:
allow-bean-definition-overriding: true
\ No newline at end of file
......@@ -20,6 +20,7 @@ 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.util.ObjectUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PostAuthorize;
......@@ -56,6 +57,17 @@ public class {{apiEntity.codeName}}Resource {
{{#each apiEntity.methods}}
{{#neq name "Select"}}
@ApiOperation(value = "{{apiName}}", tags = {"{{tags}}" }, notes = "{{notes}}")
{{#eq methodType "DEACTION"}}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-{{name}}-all')")
{{#eq name "Update"}}
{{#if apiEntity.entity.lastModifyField}}
@VersionCheck(entity = "{{lowerCase apiEntity.entity.codeName}}" , versionfield = "{{camelCase apiEntity.entity.lastModifyField.codeName}}")
{{/if}}
{{/eq}}
{{/eq}}
{{#eq methodType "FETCH"}}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-{{replace name "Fetch" "search"}}-all')")
{{/eq}}
@RequestMapping(method = RequestMethod.{{requestMethod}}, value = "{{requestPath}}")
public ResponseEntity<{{outParam}}> {{camelCase name}}{{#each pathVariables}}{{#if @first}}By{{else}}And{{/if}}{{pascalCase name}}{{/each}}
({{#each pathVariables}}{{#unless @first}}, {{/unless}}@PathVariable("{{camelCase name}}") {{type.java}} {{camelCase name}}{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}{{#neq requestMethod 'GET'}}@Validated @RequestBody {{/neq}}{{body}}{{/if}}) {
......@@ -78,6 +90,12 @@ public class {{apiEntity.codeName}}Resource {
{{/if}}
{{/if}}
{{#if booleanReturn}}
{{#eq name "Remove"}}
if(ObjectUtils.isEmpty(list)) {
list=new ArrayList<>();
list.add({{#each pathVariables}}{{#if @last}}{{camelCase name}}{{/if}}{{/each}});
}
{{/eq}}
{{camelCase apiEntity.entity.codeName}}Service.{{camelCase name}}({{inParamName2}});
{{outParam2}} rt = {{inParamName2}};
{{else}}
......@@ -109,5 +127,36 @@ public class {{apiEntity.codeName}}Resource {
{{/neq}}
{{/each}}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-Create-all')")
@ApiOperation(value = "批量新建{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "批量新建{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.POST, value = "/{{pluralize apiEntity.codeName}}/batch")
public ResponseEntity<Boolean> createBatch(@RequestBody List<{{apiEntity.codeName}}DTO> dtos) {
{{camelCase apiEntity.entity.codeName}}Service.createBatch({{camelCase apiEntity.defaultDto.codeName}}Mapping.toDomain(dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-Update-all')")
@ApiOperation(value = "批量更新{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "批量更新{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.PUT, value = "/{{pluralize apiEntity.codeName}}/batch")
public ResponseEntity<Boolean> updateBatch(@RequestBody List<{{apiEntity.codeName}}DTO> dtos) {
{{camelCase apiEntity.entity.codeName}}Service.updateBatch({{camelCase apiEntity.defaultDto.codeName}}Mapping.toDomain(dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-Save-all')")
@ApiOperation(value = "批量保存{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "批量保存{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.POST, value = "/{{pluralize apiEntity.codeName}}/savebatch")
public ResponseEntity<Boolean> saveBatch(@RequestBody List<{{apiEntity.codeName}}DTO> dtos) {
{{camelCase apiEntity.entity.codeName}}Service.saveBatch({{camelCase apiEntity.defaultDto.codeName}}Mapping.toDomain(dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-Remove-all')")
@ApiOperation(value = "批量删除{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "批量删除{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.DELETE, value = {"/{{pluralize apiEntity.codeName}}","/{{pluralize apiEntity.codeName}}/batch"})
public ResponseEntity<Boolean> removeBatch(@RequestBody List<{{apiEntity.entity.keyField.type.java}}> ids) {
{{camelCase apiEntity.entity.codeName}}Service.removeBatch(ids);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
}
{{/neq}}
\ 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}}","cn.ibizlab.util"}
// ,excludeFilters={
// @ComponentScan.Filter(type= org.springframework.context.annotation.FilterType.REGEX,pattern="{{packageName}}.{{lowerCase api.codeName}}.rest.xxx"),
// }
)
@EnableMongoRepositories(basePackages = {"{{packageName}}"})
@MapperScan({"{{packageName}}.*.mapper","cn.ibizlab.util.mapper" })
@SpringBootApplication(exclude = {
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
{{#unless system.enableMongo}}
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration.class,
{{/unless}}
{{#unless system.enableDS}}
com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure.class
{{/unless}}
})
@Import({
org.springframework.cloud.openfeign.FeignClientsConfiguration.class
})
@EnableFeignClients(basePackages = {"{{packageName}}","cn.ibizlab.util" })
@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
......@@ -42,7 +42,6 @@ spring:
driver-class-name: com.mysql.jdbc.Driver
isSyncDBSchema: false
defaultSchema: a_LAB01_da1af574b
{{#if system.enableDS}}
dynamic:
druid: #以下是全局默认值,可以全局更改
filters: stat,log4j2
......@@ -80,27 +79,6 @@ spring:
conf: classpath:liquibase/master.xml
isSyncDBSchema: ${spring.datasource.isSyncDBSchema}
defaultSchema: ${spring.datasource.defaultSchema}
{{else}}
conf: classpath:liquibase/master.xml
filters: stat,wall,log4j2
#配置初始化大小/最小/最大
initial-size: 1
min-idle: 1
max-active: 20
#获取连接等待超时时间
max-wait: 60000
#间隔多久进行一次检测,检测需要关闭的空闲连接
time-between-eviction-runs-millis: 60000
#一个连接在池中最小生存的时间
min-evictable-idle-time-millis: 300000
validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
#打开PSCache,并指定每个连接上PSCache的大小。oracle设为true,mysql设为false。分库分表较多推荐设置为false
pool-prepared-statements: false
max-pool-prepared-statement-per-connection-size: 20
{{/if}}
#Mybatis-plus配置
mybatis-plus:
......
{{#eq system.codeName "1"}}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
{
"systemid":"${sys.codeName}",
"systemname":"${sys.getLogicName()}",
"entities":[
<#if sys.getAllPSDataEntities()??>
<#list sys.getAllPSDataEntities() as de>
{
"entity_name":"${de.name}",
"logic_name":"${de.logicName}",
"code_name":"${de.codeName}",
"table_name":"${de.getTableName()}",
"system_id":"${sys.codeName}",
"system_name":"${sys.logicName}",
"module_id":"${de.getPSSystemModule().codeName}",
"module_name":"${de.getPSSystemModule().name}",
<#--"ds_id":null,-->
<#--"ds_name":"",-->
"fields":[
<#if de.getPSDEFields()??>
<#list de.getPSDEFields() as defield>
{
"fieldname":"${defield.name}" ,
"codename":"${defield.codeName}",
"field_logic_name":"${defield.logicName}",
"entity_name":"${de.name}",
<#if defield.getRelatedPSDEField?? && defield.getRelatedPSDEField()??>
"ref_de":"${defield.getRelatedPSDEField().getPSDataEntity().name}",
"ref_field_name":"${defield.getRelatedPSDEField().name}",
</#if>
<#if (((defield.dataType())!'')=='PICKUP' || ((defield.dataType())!'')=='PICKUPDATA' || ((defield.dataType())!'')=='PICKUPTEXT' ) && defield.getPSDER1N()?? >
"relation_name":"${defield.getPSDER1N().getName()}",
"relation_codename":"${defield.getPSDER1N().getCodeName()}",
</#if>
"field_type":"${defield.getDataType()}",
<#if defield.getPSCodeList()??>
"dict":"${defield.getPSCodeList().codeName}",
</#if>
"nullable":<#if defield.isAllowEmpty()>1<#else>0</#if>,
"physical_field":<#if defield.isPhisicalDEField()>1<#else>0</#if>,
"data_type":"${srfdatatype(defield.getStdDataType())}",
<#if defield.getLength()?c!='-1'>
"data_length":${defield.getLength()?c},
</#if>
<#if defield.getPrecision()?c!='0'>
"data_preci":${defield.getPrecision()?c},
</#if>
<#if defield.getDefaultPSDEFDTColumn?? && defield.getDefaultPSDEFDTColumn()?? && defield.getDefaultPSDEFDTColumn().isFormula()==true>
"expression":"${defield.getDefaultPSDEFDTColumn().getFormulaFormat()}",
</#if>
<#if defield.getPredefinedType()?? && defield.getPredefinedType()!=''>
"predefined":"${defield.getPredefinedType()}",
</#if>
"key_field":<#if defield.isKeyDEField()==true>1<#else>0</#if>,
<#if defield.getUnionKeyValue()?? && defield.getUnionKeyValue()!=''>
"union_key":"${defield.getUnionKeyValue()}",
</#if>
<#if defield.getOrderValue?? && defield.getOrderValue()??>
"show_order":${defield.getOrderValue()?c},
</#if>
"major_field":<#if defield.isMajorDEField()==true>1<#else>0</#if>
}<#if defield_has_next>,</#if>
</#list>
</#if>
],
"subEntitys":[
<#if de.getMinorPSDERs()??>
<#list de.getMajorPSDERs() as majorPSDER>
{"name":"${majorPSDER.name}",
"relation_type":"${majorPSDER.getDERType()}",
"code_name":"${majorPSDER.getCodeName()}",
"entity_name":"${majorPSDER.getMinorPSDataEntity().name}",
"ref_entity_name":"${majorPSDER.getMajorPSDataEntity().name}"
<#--"nested_name":"",-->
<#--"lookup":""-->
}<#if majorPSDER_has_next>,</#if>
</#list>
</#if>
],
"parentEntitys":[
<#if de.getMinorPSDERs()??>
<#list de.getMinorPSDERs() as minorPSDER>
{"name":"${minorPSDER.name}",
"relation_type":"${minorPSDER.getDERType()}",
"code_name":"${minorPSDER.getCodeName()}",
"entity_name":"${minorPSDER.getMinorPSDataEntity().name}",
"ref_entity_name":"${minorPSDER.getMajorPSDataEntity().name}"
<#--"nested_name":"",-->
<#--"lookup":""-->
}<#if minorPSDER_has_next>,</#if>
</#list>
</#if>
]
}
<#if de_has_next>,</#if>
</#list>
</#if>
]
}
{{/eq}}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册