Commit 6f5078ad by fengshuonan

修改一些常量到数据库

parent d9b62e17
......@@ -16,7 +16,7 @@ USE guns;
Target Server Version : 50724
File Encoding : 65001
Date: 25/06/2019 13:20:39
Date: 25/06/2019 18:51:22
*/
SET NAMES utf8mb4;
......@@ -100,6 +100,9 @@ INSERT INTO `sys_config` VALUES (1143386953933254657, '阿里云短信的secret'
INSERT INTO `sys_config` VALUES (1143387023449649154, '阿里云短信的签名', 'GUNS_SMS_SIGN_NAME', 'N', NULL, 'xxxsign', '阿里云短信的签名', '2019-06-25 13:14:44', 1, NULL, NULL);
INSERT INTO `sys_config` VALUES (1143387131109044225, '阿里云短信登录的模板号', 'GUNS_SMS_LOGIN_TEMPLATE_CODE', 'N', NULL, 'SMS_XXXXXX', '阿里云短信登录的模板号', '2019-06-25 13:15:10', 1, NULL, NULL);
INSERT INTO `sys_config` VALUES (1143387225019510785, '验证码短信失效时间', 'GUNS_SMS_INVALIDATE_MINUTES', 'N', NULL, '2', '验证码短信失效时间', '2019-06-25 13:15:32', 1, NULL, NULL);
INSERT INTO `sys_config` VALUES (1143468689664876546, '管理系统名称', 'GUNS_SYSTEM_NAME', 'N', NULL, 'Guns快速开发平台', '管理系统名称', '2019-06-25 18:39:15', 1, NULL, NULL);
INSERT INTO `sys_config` VALUES (1143468867767607297, '默认系统密码', 'GUNS_DEFAULT_PASSWORD', 'N', NULL, '111111', '默认系统密码', '2019-06-25 18:39:57', 1, NULL, NULL);
INSERT INTO `sys_config` VALUES (1143469008025133058, 'OAuth2登录用户的账号标识', 'GUNS_OAUTH2_PREFIX', 'N', NULL, 'oauth2', 'OAuth2登录用户的账号标识', '2019-06-25 18:40:31', 1, NULL, NULL);
COMMIT;
-- ----------------------------
......
......@@ -3,6 +3,7 @@ package cn.stylefeng.guns.base.consts;
import cn.stylefeng.guns.base.enums.CommonStatus;
import cn.stylefeng.guns.base.sms.AliyunSmsProperties;
import cn.stylefeng.roses.core.util.ToolUtil;
import lombok.extern.slf4j.Slf4j;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
......@@ -15,6 +16,7 @@ import static cn.stylefeng.guns.base.consts.ConfigConstant.SYSTEM_CONSTANT_PREFI
* @author fengshuonan
* @Date 2019-06-20 13:37
*/
@Slf4j
public class ConstantsContext {
/**
......@@ -83,4 +85,43 @@ public class ConstantsContext {
aliyunSmsProperties.setInvalidateMinutes(Integer.valueOf(gunsSmsInvalidateMinutes));
return aliyunSmsProperties;
}
/**
* 获取管理系统名称
*/
public static String getSystemName() {
String systemName = (String) CONSTNTS_HOLDER.get("GUNS_SYSTEM_NAME");
if (ToolUtil.isEmpty(systemName)) {
log.error("系统常量存在空值!常量名称:GUNS_SYSTEM_NAME,采用默认名称:Guns快速开发平台");
return "Guns快速开发平台";
} else {
return systemName;
}
}
/**
* 获取管理系统名称
*/
public static String getDefaultPassword() {
String defaultPassword = (String) CONSTNTS_HOLDER.get("GUNS_DEFAULT_PASSWORD");
if (ToolUtil.isEmpty(defaultPassword)) {
log.error("系统常量存在空值!常量名称:GUNS_DEFAULT_PASSWORD,采用默认密码:111111");
return "111111";
} else {
return defaultPassword;
}
}
/**
* 获取管理系统名称
*/
public static String getOAuth2UserPrefix() {
String oauth2Prefix = (String) CONSTNTS_HOLDER.get("GUNS_OAUTH2_PREFIX");
if (ToolUtil.isEmpty(oauth2Prefix)) {
log.error("系统常量存在空值!常量名称:GUNS_OAUTH2_PREFIX,采用默认值:oauth2");
return "oauth2";
} else {
return oauth2Prefix;
}
}
}
......@@ -15,6 +15,7 @@
*/
package cn.stylefeng.guns.sys.core.beetl;
import cn.stylefeng.guns.base.consts.ConstantsContext;
import cn.stylefeng.guns.sys.core.util.KaptchaUtil;
import cn.stylefeng.roses.core.util.ToolUtil;
import org.beetl.ext.spring.BeetlGroupUtilConfiguration;
......@@ -22,9 +23,6 @@ import org.beetl.ext.spring.BeetlGroupUtilConfiguration;
import java.util.HashMap;
import java.util.Map;
import static cn.stylefeng.guns.sys.core.constant.Const.DEFAULT_SYSTEM_NAME;
import static cn.stylefeng.guns.sys.core.constant.Const.DEFAULT_WELCOME_TIP;
/**
* beetl拓展配置,绑定一些工具类,方便在模板中直接调用
*
......@@ -38,8 +36,8 @@ public class BeetlConfiguration extends BeetlGroupUtilConfiguration {
//全局共享变量
Map<String, Object> shared = new HashMap<>();
shared.put("systemName", DEFAULT_SYSTEM_NAME);
shared.put("welcomeTip", DEFAULT_WELCOME_TIP);
shared.put("systemName", ConstantsContext.getSystemName());
shared.put("welcomeTip", "欢迎使用" + ConstantsContext.getSystemName());
groupTemplate.setSharedVars(shared);
//全局共享方法
......
......@@ -28,21 +28,6 @@ import java.util.List;
public interface Const {
/**
* 默认管理系统的名称
*/
String DEFAULT_SYSTEM_NAME = "Guns快速开发平台";
/**
* 默认欢迎界面的提示
*/
String DEFAULT_WELCOME_TIP = "欢迎使用Guns快速开发平台!";
/**
* 重置密码
*/
String DEFAULT_PWD = "111111";
/**
* 管理员角色的名字
*/
String ADMIN_NAME = "administrator";
......@@ -72,9 +57,4 @@ public interface Const {
"/tran/**",
"/favicon.ico");
/**
* OAuth2登录用户的账号标识
*/
String OAUTH2_ACCOUNT_PREFIX = "oauth2";
}
......@@ -15,6 +15,7 @@
*/
package cn.stylefeng.guns.sys.core.shiro;
import cn.stylefeng.guns.base.consts.ConstantsContext;
import cn.stylefeng.guns.base.shiro.ShiroUser;
import cn.stylefeng.guns.sys.core.constant.Const;
import cn.stylefeng.guns.sys.core.constant.factory.ConstantFactory;
......@@ -322,7 +323,7 @@ public class ShiroKit {
*/
public static boolean oauth2Flag() {
String account = ShiroKit.getUserNotNull().getAccount();
if (account.startsWith(Const.OAUTH2_ACCOUNT_PREFIX)) {
if (account.startsWith(ConstantsContext.getOAuth2UserPrefix())) {
return true;
} else {
return false;
......
......@@ -15,6 +15,7 @@
*/
package cn.stylefeng.guns.sys.modular.system.controller;
import cn.stylefeng.guns.base.consts.ConstantsContext;
import cn.stylefeng.guns.base.log.BussinessLog;
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.shiro.annotion.Permission;
......@@ -277,7 +278,7 @@ public class UserMgrController extends BaseController {
this.userService.assertAuth(userId);
User user = this.userService.getById(userId);
user.setSalt(ShiroKit.getRandomSalt(5));
user.setPassword(ShiroKit.md5(Const.DEFAULT_PWD, user.getSalt()));
user.setPassword(ShiroKit.md5(ConstantsContext.getDefaultPassword(), user.getSalt()));
this.userService.updateById(user);
return SUCCESS_TIP;
}
......
package cn.stylefeng.guns.sys.modular.third.factory;
import cn.stylefeng.guns.sys.modular.third.entity.OauthUserInfo;
import cn.stylefeng.guns.sys.core.constant.Const;
import cn.stylefeng.guns.base.consts.ConstantsContext;
import cn.stylefeng.guns.sys.core.constant.state.ManagerStatus;
import cn.stylefeng.guns.sys.core.shiro.ShiroKit;
import cn.stylefeng.guns.sys.modular.system.entity.User;
import cn.stylefeng.guns.sys.modular.third.entity.OauthUserInfo;
import cn.stylefeng.roses.core.util.ToolUtil;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
......@@ -57,7 +57,7 @@ public class OAuthUserInfoFactory {
systemUser.setSalt(salt);
//利用openId设置账号
systemUser.setAccount(Const.OAUTH2_ACCOUNT_PREFIX + "_" + authUser.getSource().name() + "_" + authUser.getUsername());
systemUser.setAccount(ConstantsContext.getOAuth2UserPrefix() + "_" + authUser.getSource().name() + "_" + authUser.getUsername());
systemUser.setName(authUser.getNickname());
systemUser.setBirthday(new Date());
systemUser.setSex(AuthUserGender.MALE.equals(authUser.getGender()) ? "M" : "F");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment