系统名称修改为可配置后台接口

This commit is contained in:
zhanghan11 2024-04-09 17:53:24 +08:00
parent 7f0aea75c8
commit 7e8fc56cd7
8 changed files with 120 additions and 68 deletions

View File

@ -39,6 +39,15 @@ public class CaptchaController
@Autowired
private ISysConfigService configService;
/**
* 获取系统名称
*/
@GetMapping("/systemName")
public AjaxResult getCode() {
return AjaxResult.success(configService.selectSystemName());
}
/**
* 生成验证码
*/

View File

@ -64,7 +64,7 @@ public class CacheConstants
/**
* 规则配置 redis key
*/
public static final String RULE_CONFIG = "rule_config_";
public static final String RULE_CONFIG = "rule_config:";
/**
* ipc缓存过期时间

View File

@ -109,7 +109,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 过滤请求
.authorizeRequests()
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/register", "/captchaImage").anonymous()
.antMatchers("/login", "/register", "/captchaImage","/systemName").anonymous()
// 数据接收接口允许匿名访问
.antMatchers("/ipc/dataReceive/plcData","/ipc/dataReceive/sensorData").permitAll()
// 静态资源可匿名访问

View File

@ -106,7 +106,7 @@ public class IpcAlarmRulesConfigServiceImpl implements IIpcAlarmRulesConfigServi
List<IpcAlarmRulesConfig> list = ipcAlarmRulesConfigMapper.selectIpcAlarmRulesConfigList(new IpcAlarmRulesConfig());
for (IpcMonitorField field : partList) {
List<IpcAlarmRulesConfig> redisList = list.stream().filter(ipcAlarmRulesConfig -> ipcAlarmRulesConfig.getPartKey().equals(field.getFieldValue())).collect(Collectors.toList());
redisCache.setCacheObject(CacheConstants.RULE_CONFIG + field.getFieldValue() + CacheConstants.REDIS_KEY_SEPARATOR, redisList,CacheConstants.IPC_EXPIRATION_TIME, TimeUnit.HOURS);
redisCache.setCacheObject(CacheConstants.RULE_CONFIG + field.getFieldValue(), redisList,CacheConstants.IPC_EXPIRATION_TIME, TimeUnit.HOURS);
}
}
@ -118,11 +118,11 @@ public class IpcAlarmRulesConfigServiceImpl implements IIpcAlarmRulesConfigServi
*/
@Override
public List<IpcAlarmRulesConfig> selectIpcAlarmRulesConfigList(String part) {
List<IpcAlarmRulesConfig> list = redisCache.getCacheObject(CacheConstants.RULE_CONFIG + part + CacheConstants.REDIS_KEY_SEPARATOR);
List<IpcAlarmRulesConfig> list = redisCache.getCacheObject(CacheConstants.RULE_CONFIG + part);
if (list == null || list.isEmpty()) {
this.updateRedisCache();
}
list = redisCache.getCacheObject(CacheConstants.RULE_CONFIG + part + CacheConstants.REDIS_KEY_SEPARATOR);
list = redisCache.getCacheObject(CacheConstants.RULE_CONFIG + part);
return list;
}
}

View File

@ -33,6 +33,13 @@ public interface ISysConfigService
*/
public boolean selectCaptchaEnabled();
/**
* 获取系统名称
*
* @return
*/
public String selectSystemName();
/**
* 查询参数配置列表
*

View File

@ -88,12 +88,23 @@ public class SysConfigServiceImpl implements ISysConfigService
@Override
public boolean selectCaptchaEnabled()
{
String captchaEnabled = selectConfigByKey("sys.account.captchaEnabled");
if (StringUtils.isEmpty(captchaEnabled))
{
return true;
return false;
// String captchaEnabled = selectConfigByKey("sys.account.captchaEnabled");
// if (StringUtils.isEmpty(captchaEnabled))
// {
// return true;
// }
// return Convert.toBool(captchaEnabled);
}
return Convert.toBool(captchaEnabled);
/**
* 获取系统名称
*
* @return
*/
@Override
public String selectSystemName(){
return selectConfigByKey("sys.name");
}
/**

View File

@ -1,4 +1,4 @@
import request from '@/utils/request'
import request from "@/utils/request";
// 登录方法
export function login(username, password, code, uuid) {
@ -6,54 +6,66 @@ export function login(username, password, code, uuid) {
username,
password,
code,
uuid
}
uuid,
};
return request({
url: '/login',
url: "/login",
headers: {
isToken: false
isToken: false,
},
method: 'post',
data: data
})
method: "post",
data: data,
});
}
// 注册方法
export function register(data) {
return request({
url: '/register',
url: "/register",
headers: {
isToken: false
isToken: false,
},
method: 'post',
data: data
})
method: "post",
data: data,
});
}
// 获取用户详细信息
export function getInfo() {
return request({
url: '/getInfo',
method: 'get'
})
url: "/getInfo",
method: "get",
});
}
// 退出方法
export function logout() {
return request({
url: '/logout',
method: 'post'
})
url: "/logout",
method: "post",
});
}
// 获取验证码
export function getCodeImg() {
return request({
url: '/captchaImage',
url: "/captchaImage",
headers: {
isToken: false
isToken: false,
},
method: 'get',
timeout: 20000
})
method: "get",
timeout: 20000,
});
}
// 获取系统名称
export function getSystemName() {
return request({
url: "/systemName",
headers: {
isToken: false,
},
method: "get",
timeout: 20000,
});
}

View File

@ -1,10 +1,16 @@
<template>
<div class="login">
<div class="login-content">
<div class="login-content-title" style="margin-bottom: 1rem;">
<div
class="login-content-title"
style="margin-bottom: 1rem;"
>
<img :src="getTitleBg()">
</div>
<div class="login-content-sub-title" style="display: none;">
<div
class="login-content-sub-title"
style="display: none;"
>
<img src="../assets/images/login/project-sub-title.png">
</div>
<div class="login-content-enter">
@ -101,7 +107,7 @@
</template>
<script>
import { getCodeImg } from "@/api/login";
import { getCodeImg, getSystemName } from "@/api/login";
import Cookies from "js-cookie";
import { encrypt, decrypt } from "@/utils/jsencrypt";
@ -132,7 +138,7 @@ export default {
//
register: false,
redirect: undefined,
theme: 'default'
theme: "default",
};
},
watch: {
@ -145,16 +151,23 @@ export default {
},
created() {
this.getCode();
this.getSystemInfo();
this.getCookie();
},
methods: {
getSystemInfo() {
getSystemName().then((res) => {
console.log(res);
});
},
getTitleBg() {
const theme = localStorage.getItem("data-theme") || 'default'
window.document.documentElement.setAttribute('data-theme', theme)
window.document.documentElement.setAttribute('class', 'light')
if (theme === 'default') return '/theme/default/loginTitle.png'
if (theme === 'redTheme') return '/theme/redTheme/loginTitle.png'
return '/theme/default/loginTitle.png'
const theme = localStorage.getItem("data-theme") || "default";
window.document.documentElement.setAttribute("data-theme", theme);
window.document.documentElement.setAttribute("class", "light");
if (theme === "default") return "/theme/default/loginTitle.png";
if (theme === "redTheme") return "/theme/redTheme/loginTitle.png";
return "/theme/default/loginTitle.png";
},
getCode() {
getCodeImg().then((res) => {
@ -214,7 +227,7 @@ export default {
</script>
<style rel="stylesheet/scss" lang="scss">
@import '@/theme/index.scss';
@import "@/theme/index.scss";
.login {
height: 100vh;
width: 100vw;