提交 32da2eba 编写于 作者: ibizdev's avatar ibizdev

ibizdev提交

上级 a95b013b
......@@ -11,7 +11,9 @@ import org.springframework.boot.SpringApplication;
@EnableDiscoveryClient
@Configuration
@EnableTransactionManagement
@SpringBootApplication
@SpringBootApplication(exclude = {
com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure.class
})
public class DevBootApplication{
public static void main(String[] args) {
......
......@@ -86,6 +86,18 @@
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<!--Liquibase数据库版本更新工具-->
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
<!--Mybatis-plus动态数据源-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
</dependency>
</dependencies>
</project>
package cn.ibizlab.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 cn.ibizlab.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
......@@ -62,6 +62,9 @@
<!--Java Web Token-->
<jsonwebtoken-jjwt.version>0.9.1</jsonwebtoken-jjwt.version>
<!--Liquibase数据库版本更新工具-->
<liquibase.version>3.6.3</liquibase.version>
</properties>
<dependencyManagement>
......@@ -216,6 +219,12 @@
<version>${jsonwebtoken-jjwt.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${alibaba-druid.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
......@@ -263,6 +272,12 @@
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- 阿里Druid数据源 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<!-- Error -->
<!-- Security -->
......
......@@ -177,7 +177,7 @@ public class IBZDictItemResource {
@ApiOperation(value = "GetByIBZDict", tags = {"IBZDictItemByIBZDict" }, notes = "GetByIBZDict")
@RequestMapping(method = RequestMethod.GET, value = "/dictapi/ibzdicts/{ibzdict_id}/ibzdictitems/{ibzdictitem_id}")
@RequestMapping(method = RequestMethod.GET, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/{ibzdictitem_id}")
public ResponseEntity<IBZDictItemDTO> getByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @PathVariable("ibzdictitem_id") String ibzdictitem_id) {
IBZDictItem domain = ibzdictitemService.get(ibzdictitem_id);
IBZDictItemDTO dto = ibzdictitemMapping.toDto(domain);
......@@ -185,7 +185,7 @@ public class IBZDictItemResource {
}
@ApiOperation(value = "GetDraftByIBZDict", tags = {"IBZDictItemByIBZDict" }, notes = "GetDraftByIBZDict")
@RequestMapping(method = RequestMethod.GET, value = "/dictapi/ibzdicts/{ibzdict_id}/ibzdictitems/getdraft")
@RequestMapping(method = RequestMethod.GET, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/getdraft")
public ResponseEntity<IBZDictItemDTO> getDraftByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id) {
IBZDictItem domain = new IBZDictItem();
domain.setDictid(ibzdict_id);
......@@ -193,7 +193,7 @@ public class IBZDictItemResource {
}
@ApiOperation(value = "SaveByIBZDict", tags = {"IBZDictItemByIBZDict" }, notes = "SaveByIBZDict")
@RequestMapping(method = RequestMethod.POST, value = "/dictapi/ibzdicts/{ibzdict_id}/ibzdictitems/save")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/save")
public ResponseEntity<Boolean> saveByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @RequestBody IBZDictItemDTO ibzdictitemdto) {
IBZDictItem domain = ibzdictitemMapping.toDomain(ibzdictitemdto);
domain.setDictid(ibzdict_id);
......@@ -201,34 +201,34 @@ public class IBZDictItemResource {
}
@ApiOperation(value = "SaveBatchByIBZDict", tags = {"SaveBatchByIBZDict" }, notes = "SaveBatchByIBZDict")
@RequestMapping(method = RequestMethod.POST, value = "/dictapi/ibzdicts/{ibzdict_id}/ibzdictitems/savebatch")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/savebatch")
public ResponseEntity<Boolean> saveBatchByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @RequestBody List<IBZDictItemDTO> ibzdictitemdtos) {
ibzdictitemService.saveBatch(ibzdictitemMapping.toDomain(ibzdictitemdtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@ApiOperation(value = "CheckKeyByIBZDict", tags = {"IBZDictItemByIBZDict" }, notes = "CheckKeyByIBZDict")
@RequestMapping(method = RequestMethod.POST, value = "/dictapi/ibzdicts/{ibzdict_id}/ibzdictitems/checkkey")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/checkkey")
public ResponseEntity<Boolean> checkKeyByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @RequestBody IBZDictItemDTO ibzdictitemdto) {
return ResponseEntity.status(HttpStatus.OK).body(ibzdictitemService.checkKey(ibzdictitemMapping.toDomain(ibzdictitemdto)));
}
@ApiOperation(value = "RemoveByIBZDict", tags = {"IBZDictItemByIBZDict" }, notes = "RemoveByIBZDict")
@RequestMapping(method = RequestMethod.DELETE, value = "/dictapi/ibzdicts/{ibzdict_id}/ibzdictitems/{ibzdictitem_id}")
@RequestMapping(method = RequestMethod.DELETE, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/{ibzdictitem_id}")
@Transactional
public ResponseEntity<Boolean> removeByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @PathVariable("ibzdictitem_id") String ibzdictitem_id) {
return ResponseEntity.status(HttpStatus.OK).body(ibzdictitemService.remove(ibzdictitem_id));
}
@ApiOperation(value = "RemoveBatchByIBZDict", tags = {"RemoveBatchByIBZDict" }, notes = "RemoveBatchByIBZDict")
@RequestMapping(method = RequestMethod.POST, value = "/dictapi/ibzdicts/{ibzdict_id}/ibzdictitems/removebatch")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/removebatch")
public ResponseEntity<Boolean> removeBatchByIBZDict(@RequestBody List<String> ids) {
ibzdictitemService.removeBatch(ids);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@ApiOperation(value = "CreateByIBZDict", tags = {"IBZDictItemByIBZDict" }, notes = "CreateByIBZDict")
@RequestMapping(method = RequestMethod.POST, value = "/dictapi/ibzdicts/{ibzdict_id}/ibzdictitems")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdicts/{ibzdict_id}/ibzdictitems")
@Transactional
public ResponseEntity<IBZDictItemDTO> createByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @RequestBody IBZDictItemDTO ibzdictitemdto) {
IBZDictItem domain = ibzdictitemMapping.toDomain(ibzdictitemdto);
......@@ -239,14 +239,14 @@ public class IBZDictItemResource {
}
@ApiOperation(value = "createBatchByIBZDict", tags = {"createBatchByIBZDict" }, notes = "createBatchByIBZDict")
@RequestMapping(method = RequestMethod.POST, value = "/dictapi/ibzdicts/{ibzdict_id}/ibzdictitems/createbatch")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/createbatch")
public ResponseEntity<Boolean> createBatchByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @RequestBody List<IBZDictItemDTO> ibzdictitemdtos) {
ibzdictitemService.createBatch(ibzdictitemMapping.toDomain(ibzdictitemdtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@ApiOperation(value = "UpdateByIBZDict", tags = {"IBZDictItemByIBZDict" }, notes = "UpdateByIBZDict")
@RequestMapping(method = RequestMethod.PUT, value = "/dictapi/ibzdicts/{ibzdict_id}/ibzdictitems/{ibzdictitem_id}")
@RequestMapping(method = RequestMethod.PUT, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/{ibzdictitem_id}")
@Transactional
public ResponseEntity<IBZDictItemDTO> updateByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @PathVariable("ibzdictitem_id") String ibzdictitem_id, @RequestBody IBZDictItemDTO ibzdictitemdto) {
IBZDictItem domain = ibzdictitemMapping.toDomain(ibzdictitemdto);
......@@ -258,14 +258,14 @@ public class IBZDictItemResource {
}
@ApiOperation(value = "UpdateBatchByIBZDict", tags = {"UpdateBatchByIBZDict" }, notes = "UpdateBatchByIBZDict")
@RequestMapping(method = RequestMethod.POST, value = "/dictapi/ibzdicts/{ibzdict_id}/ibzdictitems/updatebatch")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/updatebatch")
public ResponseEntity<Boolean> updateBatchByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @RequestBody List<IBZDictItemDTO> ibzdictitemdtos) {
ibzdictitemService.updateBatch(ibzdictitemMapping.toDomain(ibzdictitemdtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@ApiOperation(value = "fetchDEFAULTByIBZDict", tags = {"IBZDictItemByIBZDict" } ,notes = "fetchDEFAULTByIBZDict")
@RequestMapping(method= RequestMethod.GET , value="/dictapi/ibzdicts/{ibzdict_id}/ibzdictitems/fetchdefault")
@RequestMapping(method= RequestMethod.GET , value="/ibzdicts/{ibzdict_id}/ibzdictitems/fetchdefault")
public ResponseEntity<List<IBZDictItemDTO>> fetchIBZDictItemDefaultByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id,IBZDictItemSearchContext context) {
Page<IBZDictItem> domains = ibzdictitemService.searchDefault(context) ;
List<IBZDictItemDTO> list = ibzdictitemMapping.toDto(domains.getContent());
......@@ -277,7 +277,7 @@ public class IBZDictItemResource {
}
@ApiOperation(value = "searchDEFAULTByIBZDict", tags = {"IBZDictItemByIBZDict" } ,notes = "searchDEFAULTByIBZDict")
@RequestMapping(method= RequestMethod.GET , value="/dictapi/ibzdicts/{ibzdict_id}/ibzdictitems/searchdefault")
@RequestMapping(method= RequestMethod.GET , value="/ibzdicts/{ibzdict_id}/ibzdictitems/searchdefault")
public ResponseEntity<Page<IBZDictItemDTO>> searchIBZDictItemDefaultByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id,IBZDictItemSearchContext context) {
Page<IBZDictItem> domains = ibzdictitemService.searchDefault(context) ;
return ResponseEntity.status(HttpStatus.OK)
......
package cn.ibizlab.util.domain;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.master")
@Data
public class LiquibaseProp{
private String url;
private String username;
private String password;
private String isSyncDBSchema;
private String defaultSchema;
private String conf;
}
\ No newline at end of file
......@@ -5,10 +5,8 @@ spring:
discovery:
server-addr: 172.16.102.211:8848
datasource:
password: 'E6@8@7ce'
username: a_A_5ae9eb39a
url: jdbc:mysql://172.16.180.232:3306/a_A_5ae9eb39a?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true
driver-class-name: com.mysql.jdbc.Driver
dynamic:
druid: #以下是全局默认值,可以全局更改
filters: stat,wall,log4j2
#配置初始化大小/最小/最大
initial-size: 1
......@@ -27,6 +25,16 @@ spring:
#打开PSCache,并指定每个连接上PSCache的大小。oracle设为true,mysql设为false。分库分表较多推荐设置为false
pool-prepared-statements: false
max-pool-prepared-statement-per-connection-size: 20
primary: master #设置默认的数据源或者数据源组,默认值即为master
datasource:
master:
username: a_A_5ae9eb39a
password: 'E6@8@7ce'
url: jdbc:mysql://172.16.180.232:3306/a_A_5ae9eb39a?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true
driver-class-name: com.mysql.jdbc.Driver
isSyncDBSchema: false
defaultSchema: a_A_5ae9eb39a
conf: classpath:liquibase/master.xml
#Mybatis-plus配置
mybatis-plus:
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册