接入sa-token
This commit is contained in:
parent
956bf841b3
commit
a5d63d6c96
|
|
@ -35,6 +35,12 @@
|
|||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-dao-redis-jackson</artifactId>
|
||||
<version>1.32.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- 插件管理 -->
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
package com.mdd.admin;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.mdd.admin.config.AdminConfig;
|
||||
import com.mdd.admin.service.ISystemAuthAdminService;
|
||||
import com.mdd.admin.service.ISystemAuthPermService;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.enums.HttpEnum;
|
||||
import com.mdd.common.utils.RedisUtil;
|
||||
import com.mdd.common.utils.StringUtil;
|
||||
import com.mdd.common.utils.ToolsUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
|
@ -29,20 +31,13 @@ public class LikeAdminInterceptor implements HandlerInterceptor {
|
|||
@Resource
|
||||
ISystemAuthAdminService iSystemAuthAdminService;
|
||||
|
||||
@Resource
|
||||
ISystemAuthPermService iSystemAuthPermService;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
// 404拦截
|
||||
response.setContentType("application/json;charset=utf-8");
|
||||
if (response.getStatus() == 404) {
|
||||
AjaxResult<Object> result = AjaxResult.failed(HttpEnum.REQUEST_404_ERROR.getCode(), HttpEnum.REQUEST_404_ERROR.getMsg());
|
||||
response.getWriter().print(JSON.toJSONString(result));
|
||||
return false;
|
||||
}
|
||||
public boolean preHandle(@NotNull HttpServletRequest request,
|
||||
@NotNull HttpServletResponse response,
|
||||
@NotNull Object handler) throws Exception {
|
||||
|
||||
// 判断请求接口
|
||||
// 请求的类型
|
||||
response.setContentType("application/json;charset=utf-8");
|
||||
if (!(handler instanceof HandlerMethod)) {
|
||||
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||
}
|
||||
|
|
@ -59,7 +54,7 @@ public class LikeAdminInterceptor implements HandlerInterceptor {
|
|||
}
|
||||
|
||||
// Token是否为空
|
||||
String token = request.getHeader("token");
|
||||
String token = StpUtil.getTokenValue();
|
||||
if (StringUtils.isBlank(token)) {
|
||||
AjaxResult<Object> result = AjaxResult.failed(HttpEnum.TOKEN_EMPTY.getCode(), HttpEnum.TOKEN_EMPTY.getMsg());
|
||||
response.getWriter().print(JSON.toJSONString(result));
|
||||
|
|
@ -67,73 +62,59 @@ public class LikeAdminInterceptor implements HandlerInterceptor {
|
|||
}
|
||||
|
||||
// Token是否过期
|
||||
token = AdminConfig.backstageTokenKey + token;
|
||||
if (!RedisUtil.exists(token)) {
|
||||
Object id = StpUtil.getLoginId();
|
||||
if (StringUtil.isNull(id)) {
|
||||
AjaxResult<Object> result = AjaxResult.failed(HttpEnum.TOKEN_INVALID.getCode(), HttpEnum.TOKEN_INVALID.getMsg());
|
||||
response.getWriter().print(JSON.toJSONString(result));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 用户信息缓存
|
||||
String uid = RedisUtil.get(token).toString();
|
||||
if (!RedisUtil.hExists(AdminConfig.backstageManageKey, uid)) {
|
||||
iSystemAuthAdminService.cacheAdminUserByUid(Integer.parseInt(uid));
|
||||
// Users是否存在
|
||||
if (!RedisUtil.hExists(AdminConfig.backstageManageKey, id)) {
|
||||
iSystemAuthAdminService.cacheAdminUserByUid(Integer.parseInt(id.toString()));
|
||||
}
|
||||
|
||||
// 获取用户的信息
|
||||
String UserStr = RedisUtil.hGet(AdminConfig.backstageManageKey, String.valueOf(id)).toString();
|
||||
Map<String, String> userMap = ToolsUtil.jsonToMap(UserStr);
|
||||
|
||||
// 校验用户被删除
|
||||
Map<String, String> map = ToolsUtil.jsonToMap(RedisUtil.hGet(AdminConfig.backstageManageKey, uid).toString());
|
||||
if (map == null || map.get("isDelete").equals("1")) {
|
||||
RedisUtil.del(token);
|
||||
RedisUtil.hDel(AdminConfig.backstageManageKey, uid);
|
||||
if (userMap.get("isDelete").equals("1")) {
|
||||
AjaxResult<Object> result = AjaxResult.failed(HttpEnum.TOKEN_INVALID.getCode(), HttpEnum.TOKEN_INVALID.getMsg());
|
||||
response.getWriter().print(JSON.toJSONString(result));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 校验用户被禁用
|
||||
if (map.get("isDisable").equals("1")) {
|
||||
if (userMap.get("isDisable").equals("1")) {
|
||||
AjaxResult<Object> result = AjaxResult.failed(HttpEnum.LOGIN_DISABLE_ERROR.getCode(), HttpEnum.LOGIN_DISABLE_ERROR.getMsg());
|
||||
response.getWriter().print(JSON.toJSONString(result));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 令牌剩余30分钟自动续签
|
||||
if (RedisUtil.ttl(token) < 1800) {
|
||||
RedisUtil.expire(token, 7200L);
|
||||
}
|
||||
// 用户写本地线里
|
||||
LikeAdminThreadLocal.put("adminId", id);
|
||||
LikeAdminThreadLocal.put("roleId", userMap.get("roleId"));
|
||||
LikeAdminThreadLocal.put("username", userMap.get("username"));
|
||||
LikeAdminThreadLocal.put("nickname", userMap.get("nickname"));
|
||||
|
||||
// 写入本地线程
|
||||
LikeAdminThreadLocal.put("adminId", uid);
|
||||
LikeAdminThreadLocal.put("roleId", map.get("role"));
|
||||
LikeAdminThreadLocal.put("username", map.get("username"));
|
||||
LikeAdminThreadLocal.put("nickname", map.get("nickname"));
|
||||
|
||||
// 免权限验证接口
|
||||
// 免校验权限接口
|
||||
List<String> notAuthUri = Arrays.asList(AdminConfig.notAuthUri);
|
||||
if (notAuthUri.contains(auths) || Integer.parseInt(uid) == 1) {
|
||||
if (notAuthUri.contains(auths) || Integer.parseInt(id.toString()) == 1) {
|
||||
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||
}
|
||||
|
||||
// 校验角色权限是否存在
|
||||
String roleId = map.get("role");
|
||||
if (!RedisUtil.hExists(AdminConfig.backstageRolesKey, roleId)) {
|
||||
iSystemAuthPermService.cacheRoleMenusByRoleId(Integer.parseInt(roleId));
|
||||
}
|
||||
|
||||
// 验证是否有权限操作
|
||||
String menus = RedisUtil.hGet(AdminConfig.backstageRolesKey, roleId).toString();
|
||||
if (menus.equals("") || !Arrays.asList(menus.split(",")).contains(auths)) {
|
||||
AjaxResult<Object> result = AjaxResult.failed(HttpEnum.NO_PERMISSION.getCode(), HttpEnum.NO_PERMISSION.getMsg());
|
||||
response.getWriter().print(JSON.toJSONString(result));
|
||||
return false;
|
||||
}
|
||||
// 校验用户的权限
|
||||
StpUtil.checkPermission(auths);
|
||||
|
||||
// 验证通过继续操作
|
||||
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||
public void afterCompletion(@NotNull HttpServletRequest request,
|
||||
@NotNull HttpServletResponse response,
|
||||
@NotNull Object handler, Exception ex) throws Exception {
|
||||
LikeAdminThreadLocal.remove();
|
||||
HandlerInterceptor.super.afterCompletion(request, response, handler, ex);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,12 +11,6 @@ public class AdminConfig {
|
|||
// 角色缓存键
|
||||
public static final String backstageRolesKey = "backstage:roles";
|
||||
|
||||
// 令牌缓存键
|
||||
public static final String backstageTokenKey = "backstage:token:";
|
||||
|
||||
// 令牌的集合
|
||||
public static final String backstageTokenSet = "backstage:token:set:";
|
||||
|
||||
// 免登录验证
|
||||
public static String[] notLoginUri = new String[]{
|
||||
"system:login", // 登录接口
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
package com.mdd.admin.config;
|
||||
|
||||
import cn.dev33.satoken.stp.StpInterface;
|
||||
import com.mdd.admin.LikeAdminThreadLocal;
|
||||
import com.mdd.admin.service.ISystemAuthPermService;
|
||||
import com.mdd.common.utils.RedisUtil;
|
||||
import com.mdd.common.utils.StringUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Sa-Token自定义权限验证接口
|
||||
*/
|
||||
@Component
|
||||
public class StpInterConfig implements StpInterface {
|
||||
|
||||
@Resource
|
||||
ISystemAuthPermService iSystemAuthPermService;
|
||||
|
||||
/**
|
||||
* 返回一个账号所拥有的权限码集合
|
||||
*
|
||||
* @param loginId 登录ID
|
||||
* @param loginType 登录类型
|
||||
* @return List<String>
|
||||
*/
|
||||
@Override
|
||||
public List<String> getPermissionList(Object loginId, String loginType) {
|
||||
Integer roleId = LikeAdminThreadLocal.getRoleId();
|
||||
Object menusObj = RedisUtil.hGet(AdminConfig.backstageRolesKey, String.valueOf(roleId));
|
||||
if (StringUtil.isNull(menusObj)) {
|
||||
iSystemAuthPermService.cacheRoleMenusByRoleId(roleId);
|
||||
menusObj = RedisUtil.hGet(AdminConfig.backstageRolesKey, String.valueOf(roleId));
|
||||
}
|
||||
|
||||
List<String> list = new ArrayList<>();
|
||||
String[] menus = menusObj.toString().split(",");
|
||||
for (String auth : menus) {
|
||||
list.add(auth.toLowerCase());
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回一个账号所拥有的角色标识集合
|
||||
*
|
||||
* @param loginId 登录ID
|
||||
* @param loginType 登录类型
|
||||
* @return List<String>
|
||||
*/
|
||||
@Override
|
||||
public List<String> getRoleList(Object loginId, String loginType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.mdd.admin.config;
|
|||
import com.mdd.admin.LikeAdminInterceptor;
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import com.mdd.common.utils.YmlUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
|
|
@ -37,14 +38,15 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|||
*/
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(likeAdminInterceptor).addPathPatterns("/**");
|
||||
registry.addInterceptor(likeAdminInterceptor)
|
||||
.addPathPatterns("/**");
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源目录映射
|
||||
*/
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
public void addResourceHandlers(@NotNull ResourceHandlerRegistry registry) {
|
||||
String directory = YmlUtil.get("like.upload-directory");
|
||||
if (directory == null || directory.equals("")) {
|
||||
directory = GlobalConfig.uploadDirectory;
|
||||
|
|
|
|||
|
|
@ -122,7 +122,8 @@ public class SystemAuthAdminController {
|
|||
@Log(title = "管理员删除")
|
||||
@PostMapping("/del")
|
||||
public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
|
||||
iSystemAuthAdminService.del(idValidate.getId());
|
||||
Integer adminId = LikeAdminThreadLocal.getAdminId();
|
||||
iSystemAuthAdminService.del(idValidate.getId(), adminId);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
|
@ -135,7 +136,8 @@ public class SystemAuthAdminController {
|
|||
@Log(title = "管理员状态")
|
||||
@PostMapping("/disable")
|
||||
public AjaxResult<Object> disable(@Validated @RequestBody IdValidate idValidate) {
|
||||
iSystemAuthAdminService.disable(idValidate.getId());
|
||||
Integer adminId = LikeAdminThreadLocal.getAdminId();
|
||||
iSystemAuthAdminService.disable(idValidate.getId(), adminId);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.mdd.admin.controller.system;
|
|||
|
||||
import com.mdd.admin.service.ISystemLoginService;
|
||||
import com.mdd.admin.validate.system.SystemAdminLoginsValidate;
|
||||
import com.mdd.admin.vo.system.SystemLoginVo;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
|
@ -28,12 +29,12 @@ public class SystemLoginController {
|
|||
*
|
||||
* @author fzr
|
||||
* @param loginsValidate 登录参数
|
||||
* @return AjaxResult<Map<String, Object>>
|
||||
* @return AjaxResult<SystemLoginVo>
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public AjaxResult<Map<String, Object>> login(@Validated() @RequestBody SystemAdminLoginsValidate loginsValidate) {
|
||||
Map<String, Object> map = iSystemLoginService.login(loginsValidate);
|
||||
return AjaxResult.success(map);
|
||||
public AjaxResult<SystemLoginVo> login(@Validated() @RequestBody SystemAdminLoginsValidate loginsValidate) {
|
||||
SystemLoginVo vo = iSystemLoginService.login(loginsValidate);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -16,15 +16,6 @@ import com.mdd.common.entity.system.SystemAuthAdmin;
|
|||
*/
|
||||
public interface ISystemAuthAdminService {
|
||||
|
||||
/**
|
||||
* 根据账号查找管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @param username 主键ID
|
||||
* @return SysAdmin
|
||||
*/
|
||||
SystemAuthAdmin findByUsername(String username);
|
||||
|
||||
/**
|
||||
* 管理员列表
|
||||
*
|
||||
|
|
@ -73,6 +64,7 @@ public interface ISystemAuthAdminService {
|
|||
*
|
||||
* @author fzr
|
||||
* @param upInfoValidate 参数
|
||||
* @param adminId 管理员ID
|
||||
*/
|
||||
void upInfo(SystemAdminUpInfoValidate upInfoValidate, Integer adminId);
|
||||
|
||||
|
|
@ -81,8 +73,9 @@ public interface ISystemAuthAdminService {
|
|||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
* @param adminId 管理员ID
|
||||
*/
|
||||
void del(Integer id);
|
||||
void del(Integer id, Integer adminId);
|
||||
|
||||
/**
|
||||
* 管理员状态切换
|
||||
|
|
@ -90,7 +83,7 @@ public interface ISystemAuthAdminService {
|
|||
* @author fzr
|
||||
* @param id 主键参数
|
||||
*/
|
||||
void disable(Integer id);
|
||||
void disable(Integer id, Integer adminId);
|
||||
|
||||
/**
|
||||
* 缓存管理员
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.mdd.admin.service;
|
||||
|
||||
import com.mdd.admin.validate.system.SystemAdminLoginsValidate;
|
||||
import com.mdd.admin.vo.system.SystemLoginVo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -14,9 +15,9 @@ public interface ISystemLoginService {
|
|||
*
|
||||
* @author fzr
|
||||
* @param loginsValidate 登录参数
|
||||
* @return token
|
||||
* @return SystemLoginVo
|
||||
*/
|
||||
Map<String, Object> login(SystemAdminLoginsValidate loginsValidate);
|
||||
SystemLoginVo login(SystemAdminLoginsValidate loginsValidate);
|
||||
|
||||
/**
|
||||
* 退出
|
||||
|
|
|
|||
|
|
@ -76,31 +76,28 @@ public class SettingNoticeServiceImpl implements ISettingNoticeService {
|
|||
@Override
|
||||
public SettingNoticeDetailVo detail(Integer id) {
|
||||
NoticeSetting noticeSetting = noticeSettingMapper.selectOne(new QueryWrapper<NoticeSetting>()
|
||||
.select(NoticeSetting.class, info ->
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time") &&
|
||||
!info.getColumn().equals("create_time") &&
|
||||
!info.getColumn().equals("update_time")
|
||||
)
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Map<String, Object> systemMap = ToolsUtil.jsonToMapAsObj(noticeSetting.getSystemNotice());
|
||||
Map<String, Object> oaMap = ToolsUtil.jsonToMapAsObj(noticeSetting.getOaNotice());
|
||||
Map<String, Object> mnpMap = ToolsUtil.jsonToMapAsObj(noticeSetting.getMnpNotice());
|
||||
Map<String, Object> smsMap = ToolsUtil.jsonToMapAsObj(noticeSetting.getSmsNotice());
|
||||
|
||||
SettingNoticeDetailVo vo = new SettingNoticeDetailVo();
|
||||
BeanUtils.copyProperties(noticeSetting, vo);
|
||||
|
||||
Map<String, Object> systemMap = ToolsUtil.jsonToMapAsObj(noticeSetting.getSystemNotice());
|
||||
Map<String, Object> smsMap = ToolsUtil.jsonToMapAsObj(noticeSetting.getSmsNotice());
|
||||
Map<String, Object> oaMap = ToolsUtil.jsonToMapAsObj(noticeSetting.getOaNotice());
|
||||
Map<String, Object> mnpMap = ToolsUtil.jsonToMapAsObj(noticeSetting.getMnpNotice());
|
||||
|
||||
systemMap.put("tips", JSONArray.toJSONString(systemMap.get("tips")));
|
||||
smsMap.put("tips", JSONArray.toJSONString(smsMap.get("tips")));
|
||||
oaMap.put("tips", JSONArray.toJSONString(oaMap.get("tips")));
|
||||
oaMap.put("tpl", JSONArray.toJSONString(oaMap.get("tpl")));
|
||||
mnpMap.put("tips", JSONArray.toJSONString(mnpMap.get("tips")));
|
||||
mnpMap.put("tpl", JSONArray.toJSONString(mnpMap.get("tpl")));
|
||||
|
||||
vo.setType(noticeSetting.getType()==1?"业务通知":"验证码");
|
||||
vo.setSystemNotice(systemMap);
|
||||
vo.setSmsNotice(smsMap);
|
||||
vo.setOaNotice(oaMap);
|
||||
vo.setMnpNotice(mnpMap);
|
||||
|
||||
vo.setSmsNotice(smsMap);
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package com.mdd.admin.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.query.MPJQueryWrapper;
|
||||
import com.mdd.admin.LikeAdminThreadLocal;
|
||||
import com.mdd.admin.config.AdminConfig;
|
||||
import com.mdd.admin.service.ISystemAuthAdminService;
|
||||
import com.mdd.admin.service.ISystemAuthPermService;
|
||||
|
|
@ -21,7 +21,6 @@ import com.mdd.common.config.GlobalConfig;
|
|||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||
import com.mdd.common.entity.system.SystemAuthMenu;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.mapper.system.SystemAuthAdminMapper;
|
||||
import com.mdd.common.mapper.system.SystemAuthMenuMapper;
|
||||
import com.mdd.common.utils.*;
|
||||
|
|
@ -49,20 +48,6 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
|||
@Resource
|
||||
ISystemAuthPermService iSystemAuthPermService;
|
||||
|
||||
/**
|
||||
* 根据账号查找管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @param username 主键ID
|
||||
* @return SystemAuthAdmin
|
||||
*/
|
||||
@Override
|
||||
public SystemAuthAdmin findByUsername(String username) {
|
||||
return systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.eq("username", username)
|
||||
.last("limit 1"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员列表
|
||||
*
|
||||
|
|
@ -231,11 +216,12 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
|||
Assert.notNull(roleVo, "角色不存在!");
|
||||
Assert.isTrue(roleVo.getIsDisable() <= 0, "当前角色已被禁用!");
|
||||
|
||||
String salt = ToolsUtil.randomString(5);
|
||||
String pwd = ToolsUtil.makeMd5(createValidate.getPassword().trim() + salt);
|
||||
String avatar = StringUtil.isNotEmpty(createValidate.getAvatar()) ?
|
||||
UrlUtil.toRelativeUrl(createValidate.getAvatar()) :
|
||||
"/api/static/backend_avatar.png";
|
||||
String salt = ToolsUtil.randomString(5);
|
||||
String pwd = ToolsUtil.makeMd5(createValidate.getPassword().trim() + salt);
|
||||
|
||||
String createAvatar = createValidate.getAvatar();
|
||||
String defaultAvatar = "/api/static/backend_avatar.png";
|
||||
String avatar = StringUtil.isNotEmpty(createValidate.getAvatar()) ? UrlUtil.toRelativeUrl(createAvatar) : defaultAvatar;
|
||||
|
||||
SystemAuthAdmin model = new SystemAuthAdmin();
|
||||
model.setDeptId(createValidate.getDeptId());
|
||||
|
|
@ -274,14 +260,14 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
|||
.eq("is_delete", 0)
|
||||
.eq("username", updateValidate.getUsername())
|
||||
.ne("id", updateValidate.getId())
|
||||
.last("limit 1")), "账号已存在换一个吧!");
|
||||
.last("limit 1")), "账号已存在换一个吧!");
|
||||
|
||||
Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.select(field)
|
||||
.eq("is_delete", 0)
|
||||
.eq("nickname", updateValidate.getNickname())
|
||||
.ne("id", updateValidate.getId())
|
||||
.last("limit 1")), "昵称已存在换一个吧!");
|
||||
.last("limit 1")), "昵称已存在换一个吧!");
|
||||
|
||||
if (updateValidate.getRole() > 0 && updateValidate.getId() != 1) {
|
||||
Assert.notNull(iSystemAuthRoleService.detail(updateValidate.getRole()), "角色不存在!");
|
||||
|
|
@ -299,14 +285,11 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
|||
model.setIsDisable(updateValidate.getIsDisable());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
|
||||
if (updateValidate.getId() != 1) {
|
||||
if (!updateValidate.getId().equals(1)) {
|
||||
model.setUsername(updateValidate.getUsername());
|
||||
}
|
||||
|
||||
if (StringUtil.isNotEmpty(updateValidate.getPassword())) {
|
||||
if (updateValidate.getPassword().length() < 6 || updateValidate.getPassword().length() > 20) {
|
||||
throw new OperateException("密码必须在6~20位");
|
||||
}
|
||||
if (StringUtil.isNotNull(updateValidate.getPassword())) {
|
||||
String salt = ToolsUtil.randomString(5);
|
||||
String pwd = ToolsUtil.makeMd5( updateValidate.getPassword().trim() + salt);
|
||||
model.setPassword(pwd);
|
||||
|
|
@ -316,17 +299,8 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
|||
systemAuthAdminMapper.updateById(model);
|
||||
this.cacheAdminUserByUid(updateValidate.getId());
|
||||
|
||||
Integer id = LikeAdminThreadLocal.getAdminId();
|
||||
if (updateValidate.getPassword() != null && updateValidate.getId().equals(id)) {
|
||||
String token = Objects.requireNonNull(RequestUtil.handler()).getHeader("token");
|
||||
RedisUtil.del(AdminConfig.backstageTokenKey + token);
|
||||
|
||||
Set<Object> ts = RedisUtil.sGet(AdminConfig.backstageTokenSet + id);
|
||||
for (Object t: ts) {
|
||||
RedisUtil.del(AdminConfig.backstageTokenKey+t.toString());
|
||||
}
|
||||
RedisUtil.del(AdminConfig.backstageTokenSet + id);
|
||||
RedisUtil.sSet(AdminConfig.backstageTokenSet + id, token);
|
||||
if (StringUtil.isNotNull(updateValidate.getPassword())) {
|
||||
StpUtil.kickout(updateValidate.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -346,24 +320,17 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
|||
|
||||
Assert.notNull(model, "账号不存在了!");
|
||||
|
||||
String avatar = StringUtil.isNotEmpty(upInfoValidate.getAvatar()) ?
|
||||
UrlUtil.toRelativeUrl(upInfoValidate.getAvatar()) :
|
||||
"/api/static/backend_avatar.jpg";
|
||||
String createAvatar = upInfoValidate.getAvatar();
|
||||
String defaultAvatar = "/api/static/backend_avatar.png";
|
||||
String avatar = StringUtil.isNotEmpty(upInfoValidate.getAvatar()) ? UrlUtil.toRelativeUrl(createAvatar) : defaultAvatar;
|
||||
|
||||
model.setAvatar(avatar);
|
||||
model.setNickname(upInfoValidate.getNickname());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
|
||||
if (upInfoValidate.getPassword() != null && !upInfoValidate.getPassword().equals("")) {
|
||||
if (StringUtil.isNotNull(upInfoValidate.getPassword())) {
|
||||
String currPassword = ToolsUtil.makeMd5(upInfoValidate.getCurrPassword() + model.getSalt());
|
||||
if (!currPassword.equals(model.getPassword())) {
|
||||
throw new OperateException("当前密码不正确!");
|
||||
}
|
||||
|
||||
if (upInfoValidate.getPassword().length() > 20 || upInfoValidate.getPassword().length() < 6) {
|
||||
throw new OperateException("密码必须在6~20位!");
|
||||
}
|
||||
|
||||
Assert.isFalse(!currPassword.equals(model.getPassword()), "当前密码不正确!");
|
||||
String salt = ToolsUtil.randomString(5);
|
||||
String pwd = ToolsUtil.makeMd5( upInfoValidate.getPassword().trim() + salt);
|
||||
model.setPassword(pwd);
|
||||
|
|
@ -373,18 +340,8 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
|||
systemAuthAdminMapper.updateById(model);
|
||||
this.cacheAdminUserByUid(adminId);
|
||||
|
||||
if (upInfoValidate.getPassword() != null) {
|
||||
|
||||
String token = Objects.requireNonNull(RequestUtil.handler()).getHeader("token");
|
||||
RedisUtil.del(AdminConfig.backstageTokenKey + token);
|
||||
|
||||
int uid = model.getId();
|
||||
Set<Object> ts = RedisUtil.sGet(AdminConfig.backstageTokenSet + uid);
|
||||
for (Object t: ts) {
|
||||
RedisUtil.del(AdminConfig.backstageTokenKey+t.toString());
|
||||
}
|
||||
RedisUtil.del(AdminConfig.backstageTokenSet + uid);
|
||||
RedisUtil.sSet(AdminConfig.backstageTokenSet + model.getId(), token);
|
||||
if (StringUtil.isNotNull(upInfoValidate.getPassword())) {
|
||||
StpUtil.kickout(adminId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -393,9 +350,10 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
|||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @param adminId 管理员ID
|
||||
*/
|
||||
@Override
|
||||
public void del(Integer id) {
|
||||
public void del(Integer id, Integer adminId) {
|
||||
String[] field = {"id", "username", "nickname"};
|
||||
Assert.notNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.select(field)
|
||||
|
|
@ -403,10 +361,8 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
|||
.eq("is_delete", 0)
|
||||
.last("limit 1")), "账号已不存在!");
|
||||
|
||||
Assert.isFalse(id == 1, "系统管理员不允许删除!");
|
||||
|
||||
int adminId = Integer.parseInt(LikeAdminThreadLocal.getAdminId().toString());
|
||||
Assert.isFalse(id == adminId, "不能删除自己!");
|
||||
Assert.isFalse(id.equals(1), "系统管理员不允许删除!");
|
||||
Assert.isFalse(id.equals(adminId) , "不能删除自己!");
|
||||
|
||||
SystemAuthAdmin model = new SystemAuthAdmin();
|
||||
model.setId(id);
|
||||
|
|
@ -421,25 +377,24 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
|||
*
|
||||
* @author fzr
|
||||
* @param id 主键参数
|
||||
* @param adminId 管理员ID
|
||||
*/
|
||||
@Override
|
||||
public void disable(Integer id) {
|
||||
String[] field = {"id", "username", "nickname", "is_disable"};
|
||||
public void disable(Integer id, Integer adminId) {
|
||||
SystemAuthAdmin systemAuthAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.select(field)
|
||||
.select("id,username,nickname,is_disable")
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(systemAuthAdmin, "账号已不存在!");
|
||||
|
||||
int adminId = Integer.parseInt(LikeAdminThreadLocal.getAdminId().toString());
|
||||
Assert.isFalse(id == adminId, "不能禁用自己!");
|
||||
Assert.isFalse(id.equals(adminId) , "不能禁用自己!");
|
||||
|
||||
Integer disable = systemAuthAdmin.getIsDisable() == 1 ? 0 : 1;
|
||||
systemAuthAdmin.setIsDisable(disable);
|
||||
systemAuthAdmin.setUpdateTime(TimeUtil.timestamp());
|
||||
systemAuthAdminMapper.updateById(systemAuthAdmin);
|
||||
this.cacheAdminUserByUid(id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -447,24 +402,23 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
|||
*/
|
||||
@Override
|
||||
public void cacheAdminUserByUid(Integer id) {
|
||||
SystemAuthAdmin sysAdmin = systemAuthAdminMapper.selectById(id);
|
||||
SystemAuthAdmin sysAdmin = systemAuthAdminMapper.selectOne(
|
||||
new QueryWrapper<SystemAuthAdmin>()
|
||||
.select("id,role,username,nickname,is_disable,is_delete")
|
||||
.eq("id", id)
|
||||
.last("limit 1"));
|
||||
|
||||
Map<String, Object> user = new LinkedHashMap<>();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
|
||||
user.put("id", sysAdmin.getId());
|
||||
user.put("role", sysAdmin.getRole());
|
||||
user.put("roleId", sysAdmin.getRole());
|
||||
user.put("username", sysAdmin.getUsername());
|
||||
user.put("nickname", sysAdmin.getNickname());
|
||||
user.put("avatar", sysAdmin.getAvatar());
|
||||
user.put("isMultipoint", sysAdmin.getIsDisable());
|
||||
user.put("isDisable", sysAdmin.getIsDisable());
|
||||
user.put("isDelete", sysAdmin.getIsDelete());
|
||||
user.put("lastLoginIp", sysAdmin.getLastLoginIp());
|
||||
user.put("lastLoginTime", TimeUtil.timestampToDate(sysAdmin.getLastLoginTime()));
|
||||
user.put("createTime", TimeUtil.timestampToDate(sysAdmin.getCreateTime()));
|
||||
user.put("updateTime", TimeUtil.timestampToDate(sysAdmin.getUpdateTime()));
|
||||
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put(String.valueOf(sysAdmin.getId()), JSON.toJSONString(user));
|
||||
|
||||
RedisUtil.hmSet(AdminConfig.backstageManageKey, map);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,17 +45,17 @@ class SystemAuthDeptServiceImpl implements ISystemAuthDeptService {
|
|||
.eq("is_delete", 0)
|
||||
.orderByDesc((Arrays.asList("sort", "id"))));
|
||||
|
||||
List<SystemAuthDeptVo> adminVoArrayList = new ArrayList<>();
|
||||
List<SystemAuthDeptVo> list = new ArrayList<>();
|
||||
for (SystemAuthDept systemAuthDept : systemAuthDeptList) {
|
||||
SystemAuthDeptVo vo = new SystemAuthDeptVo();
|
||||
BeanUtils.copyProperties(systemAuthDept, vo);
|
||||
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemAuthDept.getUpdateTime()));
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemAuthDept.getCreateTime()));
|
||||
adminVoArrayList.add(vo);
|
||||
list.add(vo);
|
||||
}
|
||||
|
||||
return adminVoArrayList;
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -81,17 +81,17 @@ class SystemAuthDeptServiceImpl implements ISystemAuthDeptService {
|
|||
|
||||
List<SystemAuthDept> systemAuthDeptList = systemAuthDeptMapper.selectList(queryWrapper);
|
||||
|
||||
List<SystemAuthDeptVo> lists = new LinkedList<>();
|
||||
List<SystemAuthDeptVo> list = new LinkedList<>();
|
||||
for (SystemAuthDept systemAuthDept : systemAuthDeptList) {
|
||||
SystemAuthDeptVo vo = new SystemAuthDeptVo();
|
||||
BeanUtils.copyProperties(systemAuthDept, vo);
|
||||
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemAuthDept.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemAuthDept.getUpdateTime()));
|
||||
lists.add(vo);
|
||||
list.add(vo);
|
||||
}
|
||||
|
||||
JSONArray jsonArray = JSONArray.parseArray(JSONArray.toJSONString(lists));
|
||||
JSONArray jsonArray = JSONArray.parseArray(JSONArray.toJSONString(list));
|
||||
return ArrayUtil.listToTree(jsonArray, "id", "pid", "children");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ public class SystemAuthMenuServiceImpl implements ISystemAuthMenuService {
|
|||
queryWrapper.eq("is_disable", 0);
|
||||
queryWrapper.orderByDesc("menu_sort");
|
||||
queryWrapper.orderByAsc("id");
|
||||
if (adminId != 1) {
|
||||
if ( menuIds.size() <= 0) {
|
||||
if (!adminId.equals(1)) {
|
||||
if (menuIds.size() <= 0) {
|
||||
menuIds.add(0);
|
||||
}
|
||||
queryWrapper.in("id", menuIds);
|
||||
|
|
@ -192,19 +192,20 @@ public class SystemAuthMenuServiceImpl implements ISystemAuthMenuService {
|
|||
public void del(Integer id) {
|
||||
SystemAuthMenu model = systemAuthMenuMapper.selectOne(
|
||||
new QueryWrapper<SystemAuthMenu>()
|
||||
.select("id,pid,menu_name")
|
||||
.eq("id", id)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "菜单已不存在!");
|
||||
|
||||
Assert.isNull(systemAuthMenuMapper.selectOne(
|
||||
new QueryWrapper<SystemAuthMenu>()
|
||||
.eq("pid", id)
|
||||
.last("limit 1")),
|
||||
"请先删除子菜单再操作!");
|
||||
"请先删除子菜单再操作!");
|
||||
|
||||
systemAuthMenuMapper.deleteById(id);
|
||||
iSystemAuthPermService.batchDeleteByMenuId(id);
|
||||
|
||||
RedisUtil.del(AdminConfig.backstageRolesKey);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ public class SystemAuthRoleServiceImpl implements ISystemAuthRoleService {
|
|||
|
||||
iSystemAuthPermService.batchDeleteByRoleId(updateValidate.getId());
|
||||
iSystemAuthPermService.batchSaveByMenuIds(updateValidate.getId(), updateValidate.getMenuIds());
|
||||
iSystemAuthPermService.cacheRoleMenusByRoleId(updateValidate.getId());
|
||||
RedisUtil.del(AdminConfig.backstageRolesKey);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -221,7 +221,7 @@ public class SystemAuthRoleServiceImpl implements ISystemAuthRoleService {
|
|||
|
||||
systemAuthRoleMapper.deleteById(id);
|
||||
iSystemAuthPermService.batchDeleteByRoleId(id);
|
||||
RedisUtil.hDel(AdminConfig.backstageRolesKey, String.valueOf(id));
|
||||
RedisUtil.del(AdminConfig.backstageRolesKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
package com.mdd.admin.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mdd.admin.config.AdminConfig;
|
||||
import com.mdd.admin.service.ISystemAuthAdminService;
|
||||
import com.mdd.admin.service.ISystemLoginService;
|
||||
import com.mdd.admin.validate.system.SystemAdminLoginsValidate;
|
||||
import com.mdd.admin.vo.system.SystemLoginVo;
|
||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||
import com.mdd.common.entity.system.SystemLogLogin;
|
||||
import com.mdd.common.enums.HttpEnum;
|
||||
|
|
@ -44,20 +47,23 @@ public class SystemLoginServiceImpl implements ISystemLoginService {
|
|||
*
|
||||
* @author fzr
|
||||
* @param loginsValidate 登录参数
|
||||
* @return token
|
||||
* @return SystemLoginVo
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> login(SystemAdminLoginsValidate loginsValidate) {
|
||||
public SystemLoginVo login(SystemAdminLoginsValidate loginsValidate) {
|
||||
String username = loginsValidate.getUsername();
|
||||
String password = loginsValidate.getPassword();
|
||||
|
||||
SystemAuthAdmin sysAdmin = iSystemAuthAdminService.findByUsername(username);
|
||||
if (sysAdmin == null || sysAdmin.getIsDelete() == 1) {
|
||||
SystemAuthAdmin sysAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.eq("username", username)
|
||||
.last("limit 1"));
|
||||
|
||||
if (StringUtil.isNull(sysAdmin) || sysAdmin.getIsDelete().equals(1)) {
|
||||
this.recordLoginLog(0, loginsValidate.getUsername(), HttpEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
throw new LoginException(HttpEnum.LOGIN_ACCOUNT_ERROR.getCode(), HttpEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
}
|
||||
|
||||
if (sysAdmin.getIsDisable() == 1) {
|
||||
if (sysAdmin.getIsDisable().equals(1)) {
|
||||
this.recordLoginLog(sysAdmin.getId(), loginsValidate.getUsername(), HttpEnum.LOGIN_DISABLE_ERROR.getMsg());
|
||||
throw new LoginException(HttpEnum.LOGIN_DISABLE_ERROR.getCode(), HttpEnum.LOGIN_DISABLE_ERROR.getMsg());
|
||||
}
|
||||
|
|
@ -70,24 +76,13 @@ public class SystemLoginServiceImpl implements ISystemLoginService {
|
|||
}
|
||||
|
||||
try {
|
||||
// 非多处登录
|
||||
String token = ToolsUtil.makeToken();
|
||||
if (sysAdmin.getIsMultipoint() == 0) {
|
||||
Set<Object> ts = RedisUtil.sGet(AdminConfig.backstageTokenSet + sysAdmin.getId());
|
||||
for (Object t: ts) {
|
||||
RedisUtil.del(AdminConfig.backstageTokenKey+t.toString());
|
||||
}
|
||||
RedisUtil.del(AdminConfig.backstageTokenSet + sysAdmin.getId());
|
||||
RedisUtil.sSet(AdminConfig.backstageTokenSet + sysAdmin.getId(), token);
|
||||
// 禁止多处登录
|
||||
if (sysAdmin.getIsMultipoint().equals(0)) {
|
||||
StpUtil.logout(sysAdmin.getId());
|
||||
}
|
||||
|
||||
// 缓存登录信息
|
||||
RedisUtil.set(AdminConfig.backstageTokenKey+token, sysAdmin.getId(), 7200);
|
||||
iSystemAuthAdminService.cacheAdminUserByUid(sysAdmin.getId());
|
||||
|
||||
// 返回登录信息
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("token", token);
|
||||
// 实现账号登录
|
||||
StpUtil.login(sysAdmin.getId());
|
||||
|
||||
// 更新登录信息
|
||||
sysAdmin.setLastLoginIp(IpUtil.getIpAddress());
|
||||
|
|
@ -97,7 +92,11 @@ public class SystemLoginServiceImpl implements ISystemLoginService {
|
|||
// 记录登录日志
|
||||
this.recordLoginLog(sysAdmin.getId(), loginsValidate.getUsername(), "");
|
||||
|
||||
return response;
|
||||
// 响应登录信息
|
||||
SystemLoginVo vo = new SystemLoginVo();
|
||||
vo.setId(sysAdmin.getId());
|
||||
vo.setToken(StpUtil.getTokenValue());
|
||||
return vo;
|
||||
} catch (Exception e) {
|
||||
Integer adminId = StringUtil.isNotNull(sysAdmin.getId()) ? sysAdmin.getId() : 0;
|
||||
String error = StringUtil.isEmpty(e.getMessage()) ? "未知错误" : e.getMessage();
|
||||
|
|
@ -114,7 +113,7 @@ public class SystemLoginServiceImpl implements ISystemLoginService {
|
|||
*/
|
||||
@Override
|
||||
public void logout(String token) {
|
||||
RedisUtil.del(AdminConfig.backstageTokenKey + token);
|
||||
//RedisUtil.del(AdminConfig.backstageTokenKey + token);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@ public class SystemAdminUpInfoValidate implements Serializable {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0")
|
||||
private Integer id;
|
||||
|
||||
@NotEmpty(message = "昵称不能为空")
|
||||
@Length(min = 2, max = 30, message = "昵称必须在2~30个字符内")
|
||||
private String nickname;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ public class SystemAdminUpdateValidate implements Serializable {
|
|||
@Length(min = 2, max = 30, message = "昵称必须在2~30个字符内")
|
||||
private String nickname;
|
||||
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
@Length(min = 6, max = 32, message = "密码必须在6~32个字符内")
|
||||
private String password;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.mdd.admin.validate.system;
|
||||
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import com.mdd.common.validator.annotation.IntegerContains;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
|
|
@ -24,14 +25,14 @@ public class SystemRoleUpdateValidate implements Serializable {
|
|||
@Length(min = 1, max = 30, message = "角色名称必须在1~30个字符内")
|
||||
private String name;
|
||||
|
||||
@Max(value = 200, message = "备注信息不能超过200个字符")
|
||||
private String remark = "";
|
||||
@Length(max = 200, message = "备注信息不能超过200个字符")
|
||||
private String remark;
|
||||
|
||||
@NotNull(message = "排序号不能为空")
|
||||
@DecimalMin(value = "0", message = "排序号值不能少于0")
|
||||
private Integer sort;
|
||||
private Integer sort = 0;
|
||||
|
||||
@NotNull(message = "请选择状态")
|
||||
@IntegerContains(values = {0, 1})
|
||||
private Integer isDisable;
|
||||
|
||||
private String menuIds = "";
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ public class SettingNoticeDetailVo implements Serializable {
|
|||
private String type;
|
||||
private String remarks;
|
||||
private Object systemNotice;
|
||||
private Object smsNotice;
|
||||
private Object oaNotice;
|
||||
private Object mnpNotice;
|
||||
private Object smsNotice;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.mdd.admin.vo.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统登录Vo
|
||||
*/
|
||||
@Data
|
||||
public class SystemLoginVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private String token;
|
||||
|
||||
}
|
||||
|
|
@ -50,11 +50,22 @@ spring:
|
|||
|
||||
# Mybatis-plus配置
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath*:/mapper/**Mapper.xml # 映射文件路径
|
||||
mapper-locations: classpath*:/mapper/**Mapper.xml
|
||||
typeAliasesPackage: com.mdd.**.mapper
|
||||
global-config:
|
||||
banner: false
|
||||
db-config:
|
||||
table-prefix: la_ # 设置表前缀
|
||||
table-prefix: la_
|
||||
configuration-properties:
|
||||
prefix: la_ # 自定义表前缀标签${prefix}
|
||||
prefix: la_
|
||||
|
||||
# Sa-token配置
|
||||
sa-token:
|
||||
token-name: like-admin # token的名称
|
||||
timeout: 2592000 # token有效期单位s(默认30天,-1代表永不过期)
|
||||
activity-timeout: -1 # token临时有效期(指定时间无操作掉线)
|
||||
is-concurrent: true # 是否允许同一账号并发登录
|
||||
is-share: false # 多人同登账号共用token
|
||||
token-style: random-64 # token生成的风格
|
||||
is-print: false # 打印版本字符画
|
||||
is-log: false # 是否输出操作日志
|
||||
|
|
@ -156,6 +156,7 @@ public class AjaxResult<T> {
|
|||
* @return AjaxResult
|
||||
*/
|
||||
public static AjaxResult<Object> failed(Integer code, String msg) {
|
||||
System.out.println(msg);
|
||||
return new AjaxResult<>(code, msg, new ArrayList<>());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
<bitwalker.version>1.2.4</bitwalker.version>
|
||||
<oshi-core.version>6.1.2</oshi-core.version>
|
||||
<sa-token.version>1.31.0</sa-token.version>
|
||||
<sa-token.version>1.32.0</sa-token.version>
|
||||
|
||||
<qiniu.version>7.9.5</qiniu.version>
|
||||
<qcloud-version>5.6.54</qcloud-version>
|
||||
|
|
|
|||
Loading…
Reference in New Issue