是否开启flyway

Raod 4 years ago
parent 5c95d34006
commit 6f1d0287fa

@ -3,6 +3,7 @@ package com.anjiplus.template.gaea.business.config;
import com.zaxxer.hikari.HikariDataSource; import com.zaxxer.hikari.HikariDataSource;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.flyway.FlywayProperties; import org.springframework.boot.autoconfigure.flyway.FlywayProperties;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -18,6 +19,7 @@ import java.sql.Statement;
@Slf4j @Slf4j
@Component @Component
@AllArgsConstructor @AllArgsConstructor
@ConditionalOnProperty(value = {"spring.flyway.enabled"})
public class DatabaseInitializer { public class DatabaseInitializer {
private final FlywayProperties flywayProperties; private final FlywayProperties flywayProperties;

@ -12,7 +12,7 @@ import java.util.Date;
* @author ·De <lide1202@hotmail.com> * @author ·De <lide1202@hotmail.com>
* @date 2019-02-17 08:50:10.009 * @date 2019-02-17 08:50:10.009
**/ **/
@TableName(value="access_authority") @TableName(keepGlobalPrefix=true, value="access_authority")
@Data @Data
public class AccessAuthority extends GaeaBaseEntity { public class AccessAuthority extends GaeaBaseEntity {
/** 父菜单代码 */ /** 父菜单代码 */

@ -11,7 +11,7 @@ import java.util.Date;
* @author ·De <lide1202@hotmail.com> * @author ·De <lide1202@hotmail.com>
* @date 2019-02-17 08:50:14.136 * @date 2019-02-17 08:50:14.136
**/ **/
@TableName(value="access_role") @TableName(keepGlobalPrefix=true, value="access_role")
@Data @Data
public class AccessRole extends GaeaBaseEntity { public class AccessRole extends GaeaBaseEntity {

@ -14,7 +14,7 @@ import java.util.Date;
* @author ·De <lide1202@hotmail.com> * @author ·De <lide1202@hotmail.com>
* @date 2019-02-17 08:50:14.136 * @date 2019-02-17 08:50:14.136
**/ **/
@TableName(value="access_role_authority") @TableName(keepGlobalPrefix=true, value="access_role_authority")
@Data @Data
public class AccessRoleAuthority extends GaeaBaseEntity { public class AccessRoleAuthority extends GaeaBaseEntity {

@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* @desc AccessRole * @desc AccessRole
@ -52,7 +53,14 @@ public class AccessRoleServiceImpl implements AccessRoleService {
List<TreeNode> treeData = accessAuthorityService.getAuthorityTree(operator, true); List<TreeNode> treeData = accessAuthorityService.getAuthorityTree(operator, true);
// 该角色已选中的菜单及按钮 // 该角色已选中的菜单及按钮
List<String> checkedKeys = accessRoleMapper.checkedAuthoritys(roleCode); // List<String> checkedKeys = accessRoleMapper.checkedAuthoritys(roleCode);
LambdaQueryWrapper<AccessRoleAuthority> accessRoleAuthorityWrapper = Wrappers.lambdaQuery();
accessRoleAuthorityWrapper.select(AccessRoleAuthority::getTarget, AccessRoleAuthority::getAction);
accessRoleAuthorityWrapper.eq(AccessRoleAuthority::getRoleCode, roleCode);
List<AccessRoleAuthority> accessRoleAuthorities = accessRoleAuthorityMapper.selectList(accessRoleAuthorityWrapper);
List<String> checkedKeys = accessRoleAuthorities.stream()
.map(accessRoleAuthority -> accessRoleAuthority.getTarget().concat("_").concat(accessRoleAuthority.getAction())).distinct().collect(Collectors.toList());
result.put("treeData", treeData); result.put("treeData", treeData);
result.put("checkedKeys", checkedKeys); result.put("checkedKeys", checkedKeys);

@ -11,7 +11,7 @@ import java.util.Date;
* @author ·De <lide1202@hotmail.com> * @author ·De <lide1202@hotmail.com>
* @date 2019-02-17 08:50:11.902 * @date 2019-02-17 08:50:11.902
**/ **/
@TableName(value="access_user") @TableName(keepGlobalPrefix=true, value="access_user")
@Data @Data
public class AccessUser extends GaeaBaseEntity { public class AccessUser extends GaeaBaseEntity {

@ -13,7 +13,7 @@ import java.util.Date;
* @author ·De <lide1202@hotmail.com> * @author ·De <lide1202@hotmail.com>
* @date 2019-02-17 08:50:11.902 * @date 2019-02-17 08:50:11.902
**/ **/
@TableName(value="access_user_role") @TableName(keepGlobalPrefix=true, value="access_user_role")
@Data @Data
public class AccessUserRole extends GaeaBaseEntity { public class AccessUserRole extends GaeaBaseEntity {

@ -13,8 +13,10 @@ import com.anji.plus.gaea.utils.GaeaUtils;
import com.anji.plus.gaea.utils.JwtBean; import com.anji.plus.gaea.utils.JwtBean;
import com.anjiplus.template.gaea.business.code.ResponseCode; import com.anjiplus.template.gaea.business.code.ResponseCode;
import com.anjiplus.template.gaea.business.constant.BusinessConstant; import com.anjiplus.template.gaea.business.constant.BusinessConstant;
import com.anjiplus.template.gaea.business.modules.accessrole.dao.AccessRoleAuthorityMapper;
import com.anjiplus.template.gaea.business.modules.accessrole.dao.AccessRoleMapper; import com.anjiplus.template.gaea.business.modules.accessrole.dao.AccessRoleMapper;
import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessRole; import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessRole;
import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessRoleAuthority;
import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.AccessUserDto; import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.AccessUserDto;
import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.GaeaUserDto; import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.GaeaUserDto;
import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.UpdatePasswordDto; import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.UpdatePasswordDto;
@ -31,10 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -54,6 +53,9 @@ public class AccessUserServiceImpl implements AccessUserService {
@Autowired @Autowired
private AccessUserRoleMapper accessUserRoleMapper; private AccessUserRoleMapper accessUserRoleMapper;
@Autowired
private AccessRoleAuthorityMapper accessRoleAuthorityMapper;
@Value("${customer.user.default.password:'123456'}") @Value("${customer.user.default.password:'123456'}")
private String defaultPassword; private String defaultPassword;
@ -168,7 +170,24 @@ public class AccessUserServiceImpl implements AccessUserService {
// 4.读取用户最新人权限主信息 // 4.读取用户最新人权限主信息
String userKey = String.format(BusinessConstant.GAEA_SECURITY_LOGIN_USER, loginName); String userKey = String.format(BusinessConstant.GAEA_SECURITY_LOGIN_USER, loginName);
List<String> authorities = accessUserMapper.queryAuthoritiesByLoginName(loginName); //为了兼容底层其他数据库不再写自定义sql
// List<String> authorities = accessUserMapper.queryAuthoritiesByLoginName(loginName);
//当前用户的roleCode集合
LambdaQueryWrapper<AccessUserRole> accessUserWrapper = Wrappers.lambdaQuery();
accessUserWrapper.select(AccessUserRole::getRoleCode);
accessUserWrapper.eq(AccessUserRole::getLoginName, loginName);
List<AccessUserRole> accessUserRoles = accessUserRoleMapper.selectList(accessUserWrapper);
Set<String> roleCodeSet = accessUserRoles.stream().map(AccessUserRole::getRoleCode).collect(Collectors.toSet());
LambdaQueryWrapper<AccessRoleAuthority> accessRoleAuthorityWrapper = Wrappers.lambdaQuery();
accessRoleAuthorityWrapper.select(AccessRoleAuthority::getTarget, AccessRoleAuthority::getAction);
accessRoleAuthorityWrapper.in(AccessRoleAuthority::getRoleCode, roleCodeSet);
List<AccessRoleAuthority> accessRoleAuthorities = accessRoleAuthorityMapper.selectList(accessRoleAuthorityWrapper);
List<String> authorities = accessRoleAuthorities.stream()
.map(accessRoleAuthority -> accessRoleAuthority.getTarget().concat(":").concat(accessRoleAuthority.getAction())).distinct().collect(Collectors.toList());
gaeaUser.setLoginName(loginName); gaeaUser.setLoginName(loginName);
gaeaUser.setRealName(accessUser.getRealName()); gaeaUser.setRealName(accessUser.getRealName());
gaeaUser.setToken(token); gaeaUser.setToken(token);

@ -13,7 +13,7 @@ import lombok.Data;
* @author Raod * @author Raod
* @date 2021-04-12 14:52:21.761 * @date 2021-04-12 14:52:21.761
**/ **/
@TableName(value="gaea_report_dashboard") @TableName(keepGlobalPrefix=true, value="gaea_report_dashboard")
@Data @Data
public class ReportDashboard extends GaeaBaseEntity { public class ReportDashboard extends GaeaBaseEntity {
@ApiModelProperty(value = "报表编码") @ApiModelProperty(value = "报表编码")

@ -11,7 +11,7 @@ import lombok.Data;
* @author Raod * @author Raod
* @date 2021-04-12 15:12:43.724 * @date 2021-04-12 15:12:43.724
**/ **/
@TableName(value="gaea_report_dashboard_widget") @TableName(keepGlobalPrefix=true, value="gaea_report_dashboard_widget")
@Data @Data
public class ReportDashboardWidget extends GaeaBaseEntity { public class ReportDashboardWidget extends GaeaBaseEntity {
@ApiModelProperty(value = "报表编码") @ApiModelProperty(value = "报表编码")

@ -13,7 +13,7 @@ import lombok.Data;
* @author Raod * @author Raod
* @date 2021-03-18 12:11:31.150755900 * @date 2021-03-18 12:11:31.150755900
**/ **/
@TableName(value="gaea_report_data_set") @TableName(keepGlobalPrefix=true, value="gaea_report_data_set")
@Data @Data
public class DataSet extends GaeaBaseEntity { public class DataSet extends GaeaBaseEntity {
@ApiModelProperty(value = "数据集编码") @ApiModelProperty(value = "数据集编码")

@ -11,7 +11,7 @@ import lombok.Data;
* @author Raod * @author Raod
* @date 2021-03-18 12:12:33.108033200 * @date 2021-03-18 12:12:33.108033200
**/ **/
@TableName(value="gaea_report_data_set_param") @TableName(keepGlobalPrefix=true, value="gaea_report_data_set_param")
@Data @Data
public class DataSetParam extends GaeaBaseEntity { public class DataSetParam extends GaeaBaseEntity {
@ApiModelProperty(value = "数据集编码") @ApiModelProperty(value = "数据集编码")

@ -11,7 +11,7 @@ import lombok.Data;
* @author Raod * @author Raod
* @date 2021-03-18 12:13:15.591309400 * @date 2021-03-18 12:13:15.591309400
**/ **/
@TableName(value="gaea_report_data_set_transform") @TableName(keepGlobalPrefix=true, value="gaea_report_data_set_transform")
@Data @Data
public class DataSetTransform extends GaeaBaseEntity { public class DataSetTransform extends GaeaBaseEntity {
@ApiModelProperty(value = "数据集编码") @ApiModelProperty(value = "数据集编码")

@ -13,7 +13,7 @@ import lombok.Data;
* @author Raod * @author Raod
* @date 2021-03-18 12:09:57.728203200 * @date 2021-03-18 12:09:57.728203200
**/ **/
@TableName(value="gaea_report_data_source") @TableName(keepGlobalPrefix=true, value="gaea_report_data_source")
@Data @Data
public class DataSource extends GaeaBaseEntity { public class DataSource extends GaeaBaseEntity {
@ApiModelProperty(value = "数据源编码") @ApiModelProperty(value = "数据源编码")

@ -13,7 +13,7 @@ import java.io.Serializable;
* @author lr * @author lr
* @since 2021-02-23 10:01:02 * @since 2021-02-23 10:01:02
*/ */
@TableName("gaea_dict") @TableName(keepGlobalPrefix=true, value = "gaea_dict")
public class GaeaDict extends GaeaBaseEntity implements Serializable { public class GaeaDict extends GaeaBaseEntity implements Serializable {
/** /**
* *

@ -15,7 +15,7 @@ import java.io.Serializable;
* @author lirui * @author lirui
* @since 2021-03-09 15:52:41 * @since 2021-03-09 15:52:41
*/ */
@TableName("gaea_dict_item") @TableName(keepGlobalPrefix=true,value = "gaea_dict_item")
@UnionUniqueCode(group = BusinessConstant.DICT_ITEM_EXIST_GROUP, code = ResponseCode.DICT_ITEM_REPEAT) @UnionUniqueCode(group = BusinessConstant.DICT_ITEM_EXIST_GROUP, code = ResponseCode.DICT_ITEM_REPEAT)
public class GaeaDictItem extends GaeaBaseEntity implements Serializable { public class GaeaDictItem extends GaeaBaseEntity implements Serializable {

@ -13,7 +13,7 @@ import java.io.Serializable;
* @author peiyanni * @author peiyanni
* @since 2021-02-18 14:48:20 * @since 2021-02-18 14:48:20
*/ */
@TableName("gaea_file") @TableName(keepGlobalPrefix=true, value = "gaea_file")
@Data @Data
public class GaeaFile extends GaeaBaseEntity implements Serializable { public class GaeaFile extends GaeaBaseEntity implements Serializable {

@ -13,7 +13,7 @@ import lombok.Data;
* @author chenkening * @author chenkening
* @date 2021/3/26 10:20 * @date 2021/3/26 10:20
*/ */
@TableName(value="gaea_report") @TableName(keepGlobalPrefix=true, value="gaea_report")
@Data @Data
public class Report extends GaeaBaseEntity { public class Report extends GaeaBaseEntity {

@ -12,7 +12,7 @@ import java.util.Date;
* @author Raod * @author Raod
* @date 2021-08-18 13:37:26.663 * @date 2021-08-18 13:37:26.663
**/ **/
@TableName(value="gaea_report_share") @TableName(keepGlobalPrefix=true, value="gaea_report_share")
@Data @Data
public class ReportShare extends GaeaBaseEntity { public class ReportShare extends GaeaBaseEntity {
/** 分享编码系统生成默认UUID */ /** 分享编码系统生成默认UUID */

@ -37,6 +37,7 @@ spring:
breakAfterAcquireFailure: true # 数据库服务宕机自动重连机制 breakAfterAcquireFailure: true # 数据库服务宕机自动重连机制
timeBetweenConnectErrorMillis: 300000 # 连接出错后重试时间间隔 timeBetweenConnectErrorMillis: 300000 # 连接出错后重试时间间隔
flyway: flyway:
enabled: true #是否开启flyway默认true.
baseline-on-migrate: true baseline-on-migrate: true
#数据库连接配置 #数据库连接配置
url: ${spring.datasource.url} url: ${spring.datasource.url}

Loading…
Cancel
Save