diff --git a/server/common/src/main/java/com/xaaef/molly/common/consts/ConfigNameConst.java b/server/common/src/main/java/com/xaaef/molly/common/consts/ConfigDataConst.java similarity index 52% rename from server/common/src/main/java/com/xaaef/molly/common/consts/ConfigNameConst.java rename to server/common/src/main/java/com/xaaef/molly/common/consts/ConfigDataConst.java index c91fa7a..d55e975 100644 --- a/server/common/src/main/java/com/xaaef/molly/common/consts/ConfigNameConst.java +++ b/server/common/src/main/java/com/xaaef/molly/common/consts/ConfigDataConst.java @@ -6,6 +6,7 @@ import org.apache.commons.collections4.keyvalue.DefaultKeyValue; /** *

* 全局配置文件 key + * DefConfigValueConst *

* * @author Wang Chen Chen @@ -13,7 +14,7 @@ import org.apache.commons.collections4.keyvalue.DefaultKeyValue; * @date 2021/7/16 15:15 */ -public class ConfigNameConst { +public class ConfigDataConst { /** * 系统配置 @@ -24,27 +25,44 @@ public class ConfigNameConst { /** * 用户默认密码 */ - public static final KeyValue USER_DEFAULT_PASSWORD = new DefaultKeyValue<>("default_user_password", "1234546"); + public static final KeyValue DEFAULT_USER_PASSWORD = new DefaultKeyValue<>("default_user_password", "1234546"); /** * 项目默认密码 */ - public static final KeyValue PROJECT_DEFAULT_PASSWORD = new DefaultKeyValue<>("default_project_password", "1234546"); + public static final KeyValue DEFAULT_PROJECT_PASSWORD = new DefaultKeyValue<>("default_project_password", "1234546"); + + + /** + * 每个租户的 默认项目ID + */ + public static final KeyValue DEFAULT_PROJECT_ID = new DefaultKeyValue<>("default_project_id", 10001L); /** * 租户默认logo */ - public static final KeyValue TENANT_DEFAULT_LOGO = new DefaultKeyValue<>("default_tenant_logo", "https://images.xaaef.com/molly_master_logo.png"); + public static final KeyValue DEFAULT_TENANT_LOGO = new DefaultKeyValue<>("default_tenant_logo", "https://images.xaaef.com/molly_master_logo.png"); /** - * 租户默认角色名称 + * 租户默认 角色名称 */ - public static final KeyValue TENANT_DEFAULT_ROLE_NAME = new DefaultKeyValue<>("default_role_name", "操作员"); + public static final KeyValue DEFAULT_ROLE_NAME = new DefaultKeyValue<>("default_role_name", "操作员"); + /** + * 每个租户的 默认角色 ID + */ + public static final KeyValue DEFAULT_ROLE_ID = new DefaultKeyValue<>("default_role_id", 10001L); + + + /** + * 每个租户的 默认部门ID + */ + public static final KeyValue DEFAULT_DEPT_ID = new DefaultKeyValue<>("default_dept_id", 10001L); + /** * 获取法定节假日的接口 */ diff --git a/server/common/src/main/java/com/xaaef/molly/common/consts/DefConfigValueConst.java b/server/common/src/main/java/com/xaaef/molly/common/consts/DefConfigValueConst.java deleted file mode 100644 index 419d21a..0000000 --- a/server/common/src/main/java/com/xaaef/molly/common/consts/DefConfigValueConst.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.xaaef.molly.common.consts; - -/** - *

- * 全局配置文件 key - *

- * - * @author Wang Chen Chen - * @version 1.0.1 - * @date 2021/7/16 15:15 - */ - -public class DefConfigValueConst { - - /** - * 每个租户的 默认项目ID - */ - public static final Long DEFAULT_PROJECT_ID = 10001L; - - - /** - * 每个租户的 默认部门ID - */ - public static final Long DEFAULT_DEPT_ID = 10001L; - - /** - * 每个租户的 默认角色 ID - */ - public static final Long DEFAULT_ROLE_ID = 10001L; - - -} diff --git a/server/common/src/main/java/com/xaaef/molly/common/consts/RedisKeyConst.java b/server/common/src/main/java/com/xaaef/molly/common/consts/RedisKeyConst.java index 1b45259..fc1201f 100644 --- a/server/common/src/main/java/com/xaaef/molly/common/consts/RedisKeyConst.java +++ b/server/common/src/main/java/com/xaaef/molly/common/consts/RedisKeyConst.java @@ -24,7 +24,7 @@ public class RedisKeyConst { */ public final static Set IGNORE_EQUALS_KEYS = Set.of( TenantUtils.X_TENANT_ID, - ConfigNameConst.REDIS_CACHE_KEY + ConfigDataConst.REDIS_CACHE_KEY ); diff --git a/server/molly-cms/src/main/java/com/xaaef/molly/corems/api/impl/ApiCmsProjectServiceImpl.java b/server/molly-cms/src/main/java/com/xaaef/molly/corems/api/impl/ApiCmsProjectServiceImpl.java index 7a5df8a..18cc1b7 100644 --- a/server/molly-cms/src/main/java/com/xaaef/molly/corems/api/impl/ApiCmsProjectServiceImpl.java +++ b/server/molly-cms/src/main/java/com/xaaef/molly/corems/api/impl/ApiCmsProjectServiceImpl.java @@ -1,7 +1,6 @@ package com.xaaef.molly.corems.api.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.xaaef.molly.common.consts.DefConfigValueConst; import com.xaaef.molly.common.enums.StatusEnum; import com.xaaef.molly.corems.entity.CmsProject; import com.xaaef.molly.corems.entity.TenantAndProject; @@ -22,7 +21,7 @@ import java.util.*; import java.util.stream.Collectors; import static com.xaaef.molly.auth.jwt.JwtSecurityUtils.encryptPassword; -import static com.xaaef.molly.common.consts.ConfigNameConst.PROJECT_DEFAULT_PASSWORD; +import static com.xaaef.molly.common.consts.ConfigDataConst.*; import static com.xaaef.molly.tenant.util.DelegateUtils.delegate; /** @@ -79,12 +78,12 @@ public class ApiCmsProjectServiceImpl implements ApiCmsProjectService { @Transactional(rollbackFor = Exception.class) @Override public void initProject(SysTenantDTO po) { - var password = Optional.ofNullable(configService.getValueByKey(PROJECT_DEFAULT_PASSWORD.getKey())) - .orElse(PROJECT_DEFAULT_PASSWORD.getValue()); + var password = Optional.ofNullable(configService.getValueByKey(DEFAULT_PROJECT_PASSWORD.getKey())) + .orElse(DEFAULT_PROJECT_PASSWORD.getValue()); // 委托,新的租户id。执行初始化数据 delegate(po.getTenantId(), () -> { var project = new CmsProject() - .setProjectId(DefConfigValueConst.DEFAULT_PROJECT_ID) + .setProjectId(DEFAULT_PROJECT_ID.getValue()) .setProjectName("默认项目") .setLinkman(po.getLinkman()) .setContactNumber(po.getContactNumber()) @@ -93,7 +92,7 @@ public class ApiCmsProjectServiceImpl implements ApiCmsProjectService { .setSort(1L) .setPassword(encryptPassword(password)) .setStatus(StatusEnum.NORMAL.getCode()) - .setDeptId(DefConfigValueConst.DEFAULT_DEPT_ID); + .setDeptId(DEFAULT_DEPT_ID.getValue()); projectMapper.insert(project); var result = new CmsProjectDTO(); BeanUtils.copyProperties(project, result); diff --git a/server/molly-cms/src/main/java/com/xaaef/molly/corems/service/impl/CmsProjectServiceImpl.java b/server/molly-cms/src/main/java/com/xaaef/molly/corems/service/impl/CmsProjectServiceImpl.java index 085698c..2ccd514 100644 --- a/server/molly-cms/src/main/java/com/xaaef/molly/corems/service/impl/CmsProjectServiceImpl.java +++ b/server/molly-cms/src/main/java/com/xaaef/molly/corems/service/impl/CmsProjectServiceImpl.java @@ -26,7 +26,7 @@ import java.util.Set; import java.util.stream.Collectors; import static com.xaaef.molly.auth.jwt.JwtSecurityUtils.*; -import static com.xaaef.molly.common.consts.ConfigNameConst.PROJECT_DEFAULT_PASSWORD; +import static com.xaaef.molly.common.consts.ConfigDataConst.DEFAULT_PROJECT_PASSWORD; import static com.xaaef.molly.common.consts.MbpConst.PROJECT_ID; @@ -94,8 +94,8 @@ public class CmsProjectServiceImpl extends BaseServiceImpl { var pmsDept = new PmsDept() - .setDeptId(DefConfigValueConst.DEFAULT_DEPT_ID) + .setDeptId(DEFAULT_DEPT_ID.getValue()) .setParentId(0L) .setDeptName(po.getName()) .setLeader(po.getAdminNickname()) @@ -133,7 +132,7 @@ public class ApiPmsUserServiceImpl implements ApiPmsUserService { var newRoleName = String.format("%s %s", po.getName(), roleName); var pmsRole = new PmsRole() - .setRoleId(DefConfigValueConst.DEFAULT_ROLE_ID) + .setRoleId(DEFAULT_ROLE_ID.getValue()) .setRoleName(newRoleName) .setSort(1L) .setDescription(newRoleName); diff --git a/server/molly-pms/src/main/java/com/xaaef/molly/perms/service/impl/PmsUserServiceImpl.java b/server/molly-pms/src/main/java/com/xaaef/molly/perms/service/impl/PmsUserServiceImpl.java index e9466cd..b788b53 100644 --- a/server/molly-pms/src/main/java/com/xaaef/molly/perms/service/impl/PmsUserServiceImpl.java +++ b/server/molly-pms/src/main/java/com/xaaef/molly/perms/service/impl/PmsUserServiceImpl.java @@ -44,7 +44,7 @@ import java.util.function.Function; import java.util.stream.Collectors; import static com.xaaef.molly.auth.jwt.JwtSecurityUtils.*; -import static com.xaaef.molly.common.consts.ConfigNameConst.USER_DEFAULT_PASSWORD; +import static com.xaaef.molly.common.consts.ConfigDataConst.DEFAULT_USER_PASSWORD; import static com.xaaef.molly.common.enums.AdminFlag.NO; import static com.xaaef.molly.common.enums.MenuTypeEnum.BUTTON; import static com.xaaef.molly.common.enums.MenuTypeEnum.MENU; @@ -137,8 +137,8 @@ public class PmsUserServiceImpl extends BaseServiceImpl } // 如果用户密码为空 if (StringUtils.isBlank(entity.getPassword())) { - var userDefaultPassword = Optional.ofNullable(configService.getValueByKey(USER_DEFAULT_PASSWORD.getKey())) - .orElse(USER_DEFAULT_PASSWORD.getValue()); + var userDefaultPassword = Optional.ofNullable(configService.getValueByKey(DEFAULT_USER_PASSWORD.getKey())) + .orElse(DEFAULT_USER_PASSWORD.getValue()); entity.setPassword(userDefaultPassword); } diff --git a/server/molly-service/src/test/java/com/xaaef/molly/MollyApplicationTests.java b/server/molly-service/src/test/java/com/xaaef/molly/MollyApplicationTests.java index 2eb95dc..2bb6614 100644 --- a/server/molly-service/src/test/java/com/xaaef/molly/MollyApplicationTests.java +++ b/server/molly-service/src/test/java/com/xaaef/molly/MollyApplicationTests.java @@ -3,7 +3,7 @@ package com.xaaef.molly; import cn.hutool.core.util.RandomUtil; import com.xaaef.molly.auth.enums.GrantType; import com.xaaef.molly.auth.jwt.JwtLoginUser; -import com.xaaef.molly.common.consts.ConfigNameConst; +import com.xaaef.molly.common.consts.ConfigDataConst; import com.xaaef.molly.common.enums.AdminFlag; import com.xaaef.molly.common.enums.GenderType; import com.xaaef.molly.common.enums.StatusEnum; @@ -107,7 +107,7 @@ public class MollyApplicationTests { @Test public void test2() throws Exception { TenantUtils.setTenantId("master"); - var valueByKey = configService.getValueByKey(ConfigNameConst.USER_DEFAULT_PASSWORD.getKey()); + var valueByKey = configService.getValueByKey(ConfigDataConst.DEFAULT_USER_PASSWORD.getKey()); System.out.println(valueByKey); } diff --git a/server/molly-service/src/test/java/com/xaaef/molly/NoSpringTests.java b/server/molly-service/src/test/java/com/xaaef/molly/NoSpringTests.java index 702ab16..c451194 100644 --- a/server/molly-service/src/test/java/com/xaaef/molly/NoSpringTests.java +++ b/server/molly-service/src/test/java/com/xaaef/molly/NoSpringTests.java @@ -12,7 +12,7 @@ import com.github.yitter.contract.IdGeneratorOptions; import com.github.yitter.idgen.YitIdHelper; import com.mysql.cj.jdbc.MysqlDataSource; import com.xaaef.molly.auth.jwt.JwtSecurityUtils; -import com.xaaef.molly.common.consts.ConfigNameConst; +import com.xaaef.molly.common.consts.ConfigDataConst; import com.xaaef.molly.common.consts.JwtConst; import com.xaaef.molly.common.util.JsonUtils; import com.xaaef.molly.common.util.TenantUtils; @@ -222,11 +222,11 @@ public class NoSpringTests { LOGIN_TOKEN_KEY, FORCED_OFFLINE_KEY, TenantUtils.X_TENANT_ID, - ConfigNameConst.REDIS_CACHE_KEY, - ConfigNameConst.USER_DEFAULT_PASSWORD.getKey(), - ConfigNameConst.TENANT_DEFAULT_LOGO.getKey(), - ConfigNameConst.TENANT_DEFAULT_ROLE_NAME.getKey(), - ConfigNameConst.GET_HOLIDAY_URL.getKey() + ConfigDataConst.REDIS_CACHE_KEY, + ConfigDataConst.DEFAULT_USER_PASSWORD.getKey(), + ConfigDataConst.DEFAULT_TENANT_LOGO.getKey(), + ConfigDataConst.DEFAULT_ROLE_NAME.getKey(), + ConfigDataConst.GET_HOLIDAY_URL.getKey() ); var str = "waeq" + IdUtil.nanoId(); boolean b1 = ignoreContainsKeys.stream().noneMatch(s -> StrUtil.contains(str, s)); diff --git a/server/molly-sys/src/main/java/com/xaaef/molly/system/service/impl/SysConfigServiceImpl.java b/server/molly-sys/src/main/java/com/xaaef/molly/system/service/impl/SysConfigServiceImpl.java index b5c113f..a9e74c9 100644 --- a/server/molly-sys/src/main/java/com/xaaef/molly/system/service/impl/SysConfigServiceImpl.java +++ b/server/molly-sys/src/main/java/com/xaaef/molly/system/service/impl/SysConfigServiceImpl.java @@ -4,7 +4,7 @@ import cn.hutool.core.date.DatePattern; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.xaaef.molly.auth.jwt.JwtSecurityUtils; -import com.xaaef.molly.common.consts.ConfigNameConst; +import com.xaaef.molly.common.consts.ConfigDataConst; import com.xaaef.molly.common.util.JsonUtils; import com.xaaef.molly.system.entity.SysConfig; import com.xaaef.molly.system.mapper.SysConfigMapper; @@ -57,14 +57,14 @@ public class SysConfigServiceImpl extends BaseServiceImpl() @@ -126,7 +126,7 @@ public class SysConfigServiceImpl extends BaseServiceImpl(Set.of(DefConfigValueConst.DEFAULT_PROJECT_ID))); + smallTenant.setProjectIds(new HashSet<>(Set.of(DEFAULT_PROJECT_ID.getValue()))); // 将 新创建的 租户信息 保存到 redis 中 tenantManager.addTenantId(smallTenant);