mirror of
https://gitee.com/likeadmin/likeadmin_java.git
synced 2026-05-08 08:07:46 +08:00
feat 调整role,admin 保持和其他语言一样的DB结构和逻辑
feat 调整错误和正确信息返回的格式问题
This commit is contained in:
@@ -6,10 +6,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mdd.common.aop.NotPower;
|
||||
import com.mdd.common.aop.NotLogin;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||
import com.mdd.common.entity.admin.Admin;
|
||||
import com.mdd.common.enums.ErrorEnum;
|
||||
import com.mdd.common.exception.LoginException;
|
||||
import com.mdd.common.mapper.system.SystemAuthAdminMapper;
|
||||
import com.mdd.common.mapper.admin.AdminMapper;
|
||||
import com.mdd.common.util.StringUtils;
|
||||
import com.mdd.common.util.YmlUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -31,7 +31,7 @@ import java.util.List;
|
||||
public class LikeAdminInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Resource
|
||||
SystemAuthAdminMapper systemAuthAdminMapper;
|
||||
AdminMapper systemAuthAdminMapper;
|
||||
|
||||
/**
|
||||
* 前置处理器
|
||||
@@ -153,8 +153,8 @@ public class LikeAdminInterceptor implements HandlerInterceptor {
|
||||
}
|
||||
|
||||
// 用户校验
|
||||
SystemAuthAdmin adminUser = systemAuthAdminMapper.selectOne(
|
||||
new QueryWrapper<SystemAuthAdmin>()
|
||||
Admin adminUser = systemAuthAdminMapper.selectOne(
|
||||
new QueryWrapper<Admin>()
|
||||
.select("id,username,role_ids,dept_ids,post_ids,is_disable")
|
||||
.eq("id", Integer.parseInt(id.toString()))
|
||||
.eq("is_delete", 0)
|
||||
@@ -168,7 +168,7 @@ public class LikeAdminInterceptor implements HandlerInterceptor {
|
||||
}
|
||||
|
||||
// 禁用校验
|
||||
if (adminUser.getIsDisable().equals(1)) {
|
||||
if (adminUser.getDisable().equals(1)) {
|
||||
Integer errCode = ErrorEnum.LOGIN_DISABLE_ERROR.getCode();
|
||||
String errMsg = ErrorEnum.LOGIN_DISABLE_ERROR.getMsg();
|
||||
throw new LoginException(errCode, errMsg);
|
||||
@@ -176,10 +176,7 @@ public class LikeAdminInterceptor implements HandlerInterceptor {
|
||||
|
||||
// 写入线程
|
||||
LikeAdminThreadLocal.put("adminId", id);
|
||||
LikeAdminThreadLocal.put("username", adminUser.getUsername());
|
||||
LikeAdminThreadLocal.put("roleIds", adminUser.getRoleIds());
|
||||
LikeAdminThreadLocal.put("deptIds", adminUser.getDeptIds());
|
||||
LikeAdminThreadLocal.put("postIds", adminUser.getPostIds());
|
||||
LikeAdminThreadLocal.put("username", adminUser.getName());
|
||||
|
||||
// 权限校验
|
||||
if (!adminUser.getId().equals(1)) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mdd.admin.controller.adminapi;
|
||||
|
||||
import com.mdd.admin.service.ISystemLoginService;
|
||||
import com.mdd.admin.service.system.ISystemLoginService;
|
||||
import com.mdd.admin.validate.system.SystemAdminLoginsValidate;
|
||||
import com.mdd.admin.vo.system.SystemCaptchaVo;
|
||||
import com.mdd.admin.vo.system.SystemLoginVo;
|
||||
@@ -32,9 +32,9 @@ public class LoginController {
|
||||
}
|
||||
|
||||
@NotLogin
|
||||
@PostMapping("/login")
|
||||
@PostMapping("/account")
|
||||
@ApiOperation(value="登录系统")
|
||||
public AjaxResult<SystemLoginVo> login(@Validated() @RequestBody SystemAdminLoginsValidate loginsValidate) {
|
||||
public AjaxResult<SystemLoginVo> account(@Validated() @RequestBody SystemAdminLoginsValidate loginsValidate) {
|
||||
SystemLoginVo vo = iSystemLoginService.login(loginsValidate);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.mdd.admin.controller.system;
|
||||
import com.mdd.admin.LikeAdminThreadLocal;
|
||||
import com.mdd.admin.aop.Log;
|
||||
import com.mdd.common.aop.NotPower;
|
||||
import com.mdd.admin.service.ISystemAuthAdminService;
|
||||
import com.mdd.admin.service.admin.IAdminService;
|
||||
import com.mdd.admin.validate.commons.IdValidate;
|
||||
import com.mdd.admin.validate.commons.PageValidate;
|
||||
import com.mdd.admin.validate.system.SystemAdminCreateValidate;
|
||||
@@ -29,7 +29,7 @@ import javax.annotation.Resource;
|
||||
public class SystemAuthAdminController {
|
||||
|
||||
@Resource
|
||||
ISystemAuthAdminService iSystemAuthAdminService;
|
||||
IAdminService iSystemAuthAdminService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value="管理员列表")
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.mdd.admin.controller.system;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.mdd.common.aop.NotPower;
|
||||
import com.mdd.admin.service.ISystemAuthDeptService;
|
||||
import com.mdd.admin.service.system.ISystemAuthDeptService;
|
||||
import com.mdd.admin.validate.commons.IdValidate;
|
||||
import com.mdd.admin.validate.system.SystemDeptCreateValidate;
|
||||
import com.mdd.admin.validate.system.SystemDeptSearchValidate;
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.alibaba.fastjson2.JSONArray;
|
||||
import com.mdd.admin.LikeAdminThreadLocal;
|
||||
import com.mdd.admin.aop.Log;
|
||||
import com.mdd.common.aop.NotPower;
|
||||
import com.mdd.admin.service.ISystemAuthMenuService;
|
||||
import com.mdd.admin.service.system.ISystemAuthMenuService;
|
||||
import com.mdd.admin.validate.commons.IdValidate;
|
||||
import com.mdd.admin.validate.system.SystemMenuCreateValidate;
|
||||
import com.mdd.admin.validate.system.SystemMenuUpdateValidate;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mdd.admin.controller.system;
|
||||
|
||||
import com.mdd.common.aop.NotPower;
|
||||
import com.mdd.admin.service.ISystemAuthPostService;
|
||||
import com.mdd.admin.service.system.ISystemAuthPostService;
|
||||
import com.mdd.admin.validate.commons.IdValidate;
|
||||
import com.mdd.admin.validate.commons.PageValidate;
|
||||
import com.mdd.admin.validate.system.SystemPostCreateValidate;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.mdd.admin.controller.system;
|
||||
|
||||
import com.mdd.admin.aop.Log;
|
||||
import com.mdd.common.aop.NotPower;
|
||||
import com.mdd.admin.service.ISystemAuthRoleService;
|
||||
import com.mdd.admin.service.system.ISystemRoleService;
|
||||
import com.mdd.admin.validate.commons.IdValidate;
|
||||
import com.mdd.admin.validate.commons.PageValidate;
|
||||
import com.mdd.admin.validate.system.SystemRoleCreateValidate;
|
||||
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
public class SystemAuthRoleController {
|
||||
|
||||
@Resource
|
||||
ISystemAuthRoleService iSystemAuthRoleService;
|
||||
ISystemRoleService iSystemAuthRoleService;
|
||||
|
||||
@NotPower
|
||||
@GetMapping("/all")
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.mdd.admin.controller.system;
|
||||
|
||||
|
||||
import com.mdd.admin.aop.Log;
|
||||
import com.mdd.admin.service.ISystemCacheService;
|
||||
import com.mdd.admin.service.system.ISystemCacheService;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mdd.admin.controller.system;
|
||||
|
||||
import com.mdd.admin.service.ISystemLogsServer;
|
||||
import com.mdd.admin.service.system.ISystemLogsServer;
|
||||
import com.mdd.admin.validate.commons.PageValidate;
|
||||
import com.mdd.admin.validate.system.SystemSearchLoginsValidate;
|
||||
import com.mdd.admin.validate.system.SystemSearchOperateValidate;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.mdd.admin.service.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色关联接口类
|
||||
*/
|
||||
public interface IAdminRoleService {
|
||||
|
||||
/**
|
||||
* 关联角色id
|
||||
*
|
||||
* @author damonyuan
|
||||
*/
|
||||
List<Integer> getRoleIdAttr(Integer adminId);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.admin.service;
|
||||
package com.mdd.admin.service.admin;
|
||||
|
||||
import com.mdd.admin.validate.commons.PageValidate;
|
||||
import com.mdd.admin.validate.system.SystemAdminCreateValidate;
|
||||
@@ -13,7 +13,7 @@ import com.mdd.common.core.PageResult;
|
||||
/**
|
||||
* 系统管理员服务接口类
|
||||
*/
|
||||
public interface ISystemAuthAdminService {
|
||||
public interface IAdminService {
|
||||
|
||||
/**
|
||||
* 管理员列表
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mdd.admin.service.impl.admin;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mdd.admin.service.admin.IAdminRoleService;
|
||||
import com.mdd.common.entity.admin.AdminRole;
|
||||
import com.mdd.common.mapper.admin.AdminRoleMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 系统角色服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class AdminRoleServiceImpl implements IAdminRoleService {
|
||||
|
||||
@Resource
|
||||
AdminRoleMapper adminRoleMapper;
|
||||
@Override
|
||||
public List<Integer> getRoleIdAttr(Integer adminId) {
|
||||
List<Integer> ret = new ArrayList<Integer>();
|
||||
List<AdminRole> rolesList = adminRoleMapper.selectList(new QueryWrapper<AdminRole>().eq("admin_id", adminId).select("role_id"));
|
||||
System.out.println(rolesList);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.admin.service.impl;
|
||||
package com.mdd.admin.service.impl.admin;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -6,8 +6,8 @@ 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.service.ISystemAuthAdminService;
|
||||
import com.mdd.admin.service.ISystemAuthPermService;
|
||||
import com.mdd.admin.service.admin.IAdminService;
|
||||
import com.mdd.admin.service.system.ISystemAuthPermService;
|
||||
import com.mdd.admin.validate.commons.PageValidate;
|
||||
import com.mdd.admin.validate.system.SystemAdminCreateValidate;
|
||||
import com.mdd.admin.validate.system.SystemAdminSearchValidate;
|
||||
@@ -15,15 +15,15 @@ import com.mdd.admin.validate.system.SystemAdminUpInfoValidate;
|
||||
import com.mdd.admin.validate.system.SystemAdminUpdateValidate;
|
||||
import com.mdd.admin.vo.system.*;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||
import com.mdd.common.entity.admin.Admin;
|
||||
import com.mdd.common.entity.system.SystemAuthDept;
|
||||
import com.mdd.common.entity.system.SystemAuthMenu;
|
||||
import com.mdd.common.entity.system.SystemAuthRole;
|
||||
import com.mdd.common.entity.system.SystemRole;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.mapper.system.SystemAuthAdminMapper;
|
||||
import com.mdd.common.mapper.admin.AdminMapper;
|
||||
import com.mdd.common.mapper.system.SystemAuthDeptMapper;
|
||||
import com.mdd.common.mapper.system.SystemAuthMenuMapper;
|
||||
import com.mdd.common.mapper.system.SystemAuthRoleMapper;
|
||||
import com.mdd.common.mapper.system.SystemRoleMapper;
|
||||
import com.mdd.common.util.*;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -35,10 +35,10 @@ import java.util.*;
|
||||
* 系统管理员服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
public class AdminServiceImpl implements IAdminService {
|
||||
|
||||
@Resource
|
||||
SystemAuthAdminMapper systemAuthAdminMapper;
|
||||
AdminMapper systemAuthAdminMapper;
|
||||
|
||||
@Resource
|
||||
SystemAuthMenuMapper systemAuthMenuMapper;
|
||||
@@ -47,7 +47,7 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
SystemAuthDeptMapper systemAuthDeptMapper;
|
||||
|
||||
@Resource
|
||||
SystemAuthRoleMapper systemAuthRoleMapper;
|
||||
SystemRoleMapper systemAuthRoleMapper;
|
||||
|
||||
@Resource
|
||||
ISystemAuthPermService iSystemAuthPermService;
|
||||
@@ -65,7 +65,7 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
Integer page = pageValidate.getPageNo();
|
||||
Integer limit = pageValidate.getPageSize();
|
||||
|
||||
MPJQueryWrapper<SystemAuthAdmin> mpjQueryWrapper = new MPJQueryWrapper<>();
|
||||
MPJQueryWrapper<Admin> mpjQueryWrapper = new MPJQueryWrapper<>();
|
||||
mpjQueryWrapper.select("t.id,t.username,t.nickname,t.avatar," +
|
||||
"t.role_ids as role,t.dept_ids as dept,t.is_multipoint," +
|
||||
"t.is_disable,t.last_login_ip,t.last_login_time,t.create_time,t.update_time")
|
||||
@@ -94,10 +94,10 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
List<String> role = new LinkedList<>();
|
||||
List<Integer> roleIds = ListUtils.stringToListAsInt(vo.getRole(), ",");
|
||||
if (!roleIds.isEmpty()) {
|
||||
List<SystemAuthRole> roleList = systemAuthRoleMapper.selectList(new QueryWrapper<SystemAuthRole>()
|
||||
List<SystemRole> roleList = systemAuthRoleMapper.selectList(new QueryWrapper<SystemRole>()
|
||||
.select("id,name")
|
||||
.in("id", roleIds));
|
||||
for (SystemAuthRole d : roleList) {
|
||||
for (SystemRole d : roleList) {
|
||||
role.add(d.getName());
|
||||
}
|
||||
}
|
||||
@@ -140,8 +140,8 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
@Override
|
||||
public SystemAuthAdminSelvesVo self(Integer adminId) {
|
||||
// 管理员信息
|
||||
SystemAuthAdmin sysAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.select(SystemAuthAdmin.class, info->
|
||||
Admin sysAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<Admin>()
|
||||
.select(Admin.class, info->
|
||||
!info.getColumn().equals("salt") &&
|
||||
!info.getColumn().equals("password") &&
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
@@ -155,12 +155,12 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
systemAuthAdminInformVo.setAvatar(UrlUtils.toAbsoluteUrl(sysAdmin.getAvatar()));
|
||||
systemAuthAdminInformVo.setUpdateTime(TimeUtils.timestampToDate(sysAdmin.getUpdateTime()));
|
||||
systemAuthAdminInformVo.setCreateTime(TimeUtils.timestampToDate(sysAdmin.getCreateTime()));
|
||||
systemAuthAdminInformVo.setLastLoginTime(TimeUtils.timestampToDate(sysAdmin.getLastLoginTime()));
|
||||
systemAuthAdminInformVo.setLastLoginTime(TimeUtils.timestampToDate(sysAdmin.getLoginTime()));
|
||||
|
||||
// 角色权限
|
||||
List<String> auths = new LinkedList<>();
|
||||
if (adminId > 1) {
|
||||
List<Integer> roleIds = ListUtils.stringToListAsInt(sysAdmin.getRoleIds(), ",");
|
||||
List<Integer> roleIds = new ArrayList<Integer>();
|
||||
List<Integer> menuIds = iSystemAuthPermService.selectMenuIdsByRoleId(roleIds);
|
||||
if (menuIds.size() > 0) {
|
||||
List<SystemAuthMenu> systemAuthMenus = systemAuthMenuMapper.selectList(new QueryWrapper<SystemAuthMenu>()
|
||||
@@ -201,8 +201,8 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
*/
|
||||
@Override
|
||||
public SystemAuthAdminDetailVo detail(Integer id) {
|
||||
SystemAuthAdmin sysAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.select(SystemAuthAdmin.class, info->
|
||||
Admin sysAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<Admin>()
|
||||
.select(Admin.class, info->
|
||||
!info.getColumn().equals("salt") &&
|
||||
!info.getColumn().equals("password") &&
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
@@ -215,13 +215,10 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
|
||||
SystemAuthAdminDetailVo vo = new SystemAuthAdminDetailVo();
|
||||
BeanUtils.copyProperties(sysAdmin, vo);
|
||||
vo.setRoleIds(ListUtils.stringToListAsInt(sysAdmin.getRoleIds(), ","));
|
||||
vo.setDeptIds(ListUtils.stringToListAsInt(sysAdmin.getDeptIds(), ","));
|
||||
vo.setPostIds(ListUtils.stringToListAsInt(sysAdmin.getPostIds(), ","));
|
||||
vo.setAvatar(UrlUtils.toAbsoluteUrl(sysAdmin.getAvatar()));
|
||||
vo.setCreateTime(TimeUtils.timestampToDate(sysAdmin.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtils.timestampToDate(sysAdmin.getUpdateTime()));
|
||||
vo.setLastLoginTime(TimeUtils.timestampToDate(sysAdmin.getLastLoginTime()));
|
||||
vo.setLastLoginTime(TimeUtils.timestampToDate(sysAdmin.getLoginTime()));
|
||||
return vo;
|
||||
}
|
||||
|
||||
@@ -234,13 +231,13 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
@Override
|
||||
public void add(SystemAdminCreateValidate createValidate) {
|
||||
String[] field = {"id", "username", "nickname"};
|
||||
Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper<Admin>()
|
||||
.select(field)
|
||||
.eq("is_delete", 0)
|
||||
.eq("username", createValidate.getUsername())
|
||||
.last("limit 1")), "账号已存在换一个吧!");
|
||||
|
||||
Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper<Admin>()
|
||||
.select(field)
|
||||
.eq("is_delete", 0)
|
||||
.eq("nickname", createValidate.getNickname())
|
||||
@@ -253,18 +250,13 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
String defaultAvatar = "/api/static/backend_avatar.png";
|
||||
String avatar = StringUtils.isNotEmpty(createValidate.getAvatar()) ? UrlUtils.toRelativeUrl(createAvatar) : defaultAvatar;
|
||||
|
||||
SystemAuthAdmin model = new SystemAuthAdmin();
|
||||
model.setRoleIds(ListUtils.listToStringByInt(createValidate.getRoleIds(), ","));
|
||||
model.setDeptIds(ListUtils.listToStringByInt(createValidate.getDeptIds(), ","));
|
||||
model.setPostIds(ListUtils.listToStringByInt(createValidate.getPostIds(), ","));
|
||||
model.setUsername(createValidate.getUsername());
|
||||
model.setNickname(createValidate.getNickname());
|
||||
Admin model = new Admin();
|
||||
model.setAccount(createValidate.getUsername());
|
||||
model.setName(createValidate.getNickname());
|
||||
model.setAvatar(avatar);
|
||||
model.setPassword(pwd);
|
||||
model.setSalt(salt);
|
||||
model.setSort(createValidate.getSort());
|
||||
model.setIsMultipoint(createValidate.getIsMultipoint());
|
||||
model.setIsDisable(createValidate.getIsDisable());
|
||||
model.setMultipointLogin(createValidate.getIsMultipoint());
|
||||
model.setDisable(createValidate.getIsDisable());
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthAdminMapper.insert(model);
|
||||
@@ -284,47 +276,41 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
}
|
||||
|
||||
String[] field = {"id", "username", "nickname"};
|
||||
Assert.notNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
Assert.notNull(systemAuthAdminMapper.selectOne(new QueryWrapper<Admin>()
|
||||
.select(field)
|
||||
.eq("id", updateValidate.getId())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1")), "账号不存在了!");
|
||||
|
||||
Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper<Admin>()
|
||||
.select(field)
|
||||
.eq("is_delete", 0)
|
||||
.eq("username", updateValidate.getUsername())
|
||||
.ne("id", updateValidate.getId())
|
||||
.last("limit 1")), "账号已存在换一个吧!");
|
||||
|
||||
Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper<Admin>()
|
||||
.select(field)
|
||||
.eq("is_delete", 0)
|
||||
.eq("nickname", updateValidate.getNickname())
|
||||
.ne("id", updateValidate.getId())
|
||||
.last("limit 1")), "昵称已存在换一个吧!");
|
||||
|
||||
SystemAuthAdmin model = new SystemAuthAdmin();
|
||||
Admin model = new Admin();
|
||||
model.setId(updateValidate.getId());
|
||||
model.setRoleIds(ListUtils.listToStringByInt(updateValidate.getRoleIds(), ","));
|
||||
model.setDeptIds(ListUtils.listToStringByInt(updateValidate.getDeptIds(), ","));
|
||||
model.setPostIds(ListUtils.listToStringByInt(updateValidate.getPostIds(), ","));
|
||||
model.setNickname(updateValidate.getNickname());
|
||||
model.setName(updateValidate.getNickname());
|
||||
model.setAvatar(UrlUtils.toRelativeUrl(updateValidate.getAvatar()));
|
||||
model.setSort(updateValidate.getSort());
|
||||
model.setIsMultipoint(updateValidate.getIsMultipoint());
|
||||
model.setIsDisable(updateValidate.getIsDisable());
|
||||
model.setMultipointLogin(updateValidate.getIsMultipoint());
|
||||
model.setDisable(updateValidate.getIsDisable());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
|
||||
if (!updateValidate.getId().equals(1)) {
|
||||
model.setUsername(updateValidate.getUsername());
|
||||
model.setAccount(updateValidate.getUsername());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotNull(updateValidate.getPassword()) && StringUtils.isNotEmpty(updateValidate.getPassword())) {
|
||||
String salt = ToolUtils.randomString(5);
|
||||
String pwd = ToolUtils.makeMd5( updateValidate.getPassword().trim() + salt);
|
||||
String pwd = ToolUtils.makeMd5( updateValidate.getPassword().trim());
|
||||
model.setPassword(pwd);
|
||||
model.setSalt(salt);
|
||||
}
|
||||
|
||||
systemAuthAdminMapper.updateById(model);
|
||||
@@ -341,7 +327,7 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
*/
|
||||
@Override
|
||||
public void upInfo(SystemAdminUpInfoValidate upInfoValidate, Integer adminId) {
|
||||
SystemAuthAdmin model = systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
Admin model = systemAuthAdminMapper.selectOne(new QueryWrapper<Admin>()
|
||||
.select("id,username,nickname,password,salt")
|
||||
.eq("id", adminId)
|
||||
.eq("is_delete", 0)
|
||||
@@ -354,19 +340,17 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
String avatar = StringUtils.isNotEmpty(upInfoValidate.getAvatar()) ? UrlUtils.toRelativeUrl(createAvatar) : defaultAvatar;
|
||||
|
||||
model.setAvatar(avatar);
|
||||
model.setNickname(upInfoValidate.getNickname());
|
||||
model.setName(upInfoValidate.getNickname());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
|
||||
if (StringUtils.isNotNull(upInfoValidate.getPassword()) && StringUtils.isNotEmpty(upInfoValidate.getPassword())) {
|
||||
String currPassword = ToolUtils.makeMd5(upInfoValidate.getCurrPassword() + model.getSalt());
|
||||
String currPassword = ToolUtils.makeMd5(upInfoValidate.getCurrPassword());
|
||||
Assert.isFalse(!currPassword.equals(model.getPassword()), "当前密码不正确!");
|
||||
if (upInfoValidate.getPassword().length() > 64) {
|
||||
throw new OperateException("密码不能超出64个字符");
|
||||
}
|
||||
String salt = ToolUtils.randomString(5);
|
||||
String pwd = ToolUtils.makeMd5( upInfoValidate.getPassword().trim() + salt);
|
||||
String pwd = ToolUtils.makeMd5( upInfoValidate.getPassword().trim());
|
||||
model.setPassword(pwd);
|
||||
model.setSalt(salt);
|
||||
}
|
||||
|
||||
systemAuthAdminMapper.updateById(model);
|
||||
@@ -385,7 +369,7 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
@Override
|
||||
public void del(Integer id, Integer adminId) {
|
||||
String[] field = {"id", "username", "nickname"};
|
||||
Assert.notNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
Assert.notNull(systemAuthAdminMapper.selectOne(new QueryWrapper<Admin>()
|
||||
.select(field)
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
@@ -394,9 +378,8 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
Assert.isFalse(id.equals(1), "系统管理员不允许删除!");
|
||||
Assert.isFalse(id.equals(adminId) , "不能删除自己!");
|
||||
|
||||
SystemAuthAdmin model = new SystemAuthAdmin();
|
||||
Admin model = new Admin();
|
||||
model.setId(id);
|
||||
model.setIsDelete(1);
|
||||
model.setDeleteTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthAdminMapper.updateById(model);
|
||||
|
||||
@@ -412,7 +395,7 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
*/
|
||||
@Override
|
||||
public void disable(Integer id, Integer adminId) {
|
||||
SystemAuthAdmin systemAuthAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
Admin systemAuthAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<Admin>()
|
||||
.select("id,username,nickname,is_disable")
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
@@ -421,8 +404,8 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
|
||||
Assert.notNull(systemAuthAdmin, "账号已不存在!");
|
||||
Assert.isFalse(id.equals(adminId) , "不能禁用自己!");
|
||||
|
||||
Integer disable = systemAuthAdmin.getIsDisable() == 1 ? 0 : 1;
|
||||
systemAuthAdmin.setIsDisable(disable);
|
||||
Integer disable = systemAuthAdmin.getDisable() == 1 ? 0 : 1;
|
||||
systemAuthAdmin.setDisable(disable);
|
||||
systemAuthAdmin.setUpdateTime(TimeUtils.timestamp());
|
||||
systemAuthAdminMapper.updateById(systemAuthAdmin);
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.mdd.admin.service.impl;
|
||||
package com.mdd.admin.service.impl.system;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.mdd.admin.service.ISystemAuthDeptService;
|
||||
import com.mdd.admin.service.system.ISystemAuthDeptService;
|
||||
import com.mdd.admin.validate.system.SystemDeptCreateValidate;
|
||||
import com.mdd.admin.validate.system.SystemDeptSearchValidate;
|
||||
import com.mdd.admin.validate.system.SystemDeptUpdateValidate;
|
||||
import com.mdd.admin.vo.system.SystemAuthDeptVo;
|
||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||
import com.mdd.common.entity.admin.Admin;
|
||||
import com.mdd.common.entity.system.SystemAuthDept;
|
||||
import com.mdd.common.mapper.system.SystemAuthAdminMapper;
|
||||
import com.mdd.common.mapper.admin.AdminMapper;
|
||||
import com.mdd.common.mapper.system.SystemAuthDeptMapper;
|
||||
import com.mdd.common.util.ListUtils;
|
||||
import com.mdd.common.util.TimeUtils;
|
||||
@@ -30,7 +30,7 @@ class SystemAuthDeptServiceImpl implements ISystemAuthDeptService {
|
||||
SystemAuthDeptMapper systemAuthDeptMapper;
|
||||
|
||||
@Resource
|
||||
SystemAuthAdminMapper systemAuthAdminMapper;
|
||||
AdminMapper systemAuthAdminMapper;
|
||||
|
||||
/**
|
||||
* 岗位所有
|
||||
@@ -212,7 +212,7 @@ class SystemAuthDeptServiceImpl implements ISystemAuthDeptService {
|
||||
|
||||
Assert.isNull(pModel, "请先删除子级部门");
|
||||
|
||||
SystemAuthAdmin systemAuthAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
Admin systemAuthAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<Admin>()
|
||||
.select("id,nickname")
|
||||
.apply("find_in_set({0}, dept_ids)", id)
|
||||
.eq("is_delete", 0)
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.mdd.admin.service.impl;
|
||||
package com.mdd.admin.service.impl.system;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.mdd.admin.LikeAdminThreadLocal;
|
||||
import com.mdd.admin.service.ISystemAuthMenuService;
|
||||
import com.mdd.admin.service.ISystemAuthPermService;
|
||||
import com.mdd.admin.service.system.ISystemAuthMenuService;
|
||||
import com.mdd.admin.service.system.ISystemAuthPermService;
|
||||
import com.mdd.admin.validate.system.SystemMenuCreateValidate;
|
||||
import com.mdd.admin.validate.system.SystemMenuUpdateValidate;
|
||||
import com.mdd.admin.vo.system.SystemAuthMenuVo;
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.mdd.admin.service.impl;
|
||||
package com.mdd.admin.service.impl.system;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mdd.admin.service.ISystemAuthPermService;
|
||||
import com.mdd.admin.service.system.ISystemAuthPermService;
|
||||
import com.mdd.common.entity.system.SystemAuthPerm;
|
||||
import com.mdd.common.entity.system.SystemAuthRole;
|
||||
import com.mdd.common.entity.system.SystemRole;
|
||||
import com.mdd.common.mapper.system.SystemAuthPermMapper;
|
||||
import com.mdd.common.mapper.system.SystemAuthRoleMapper;
|
||||
import com.mdd.common.mapper.system.SystemRoleMapper;
|
||||
import com.mdd.common.util.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -24,7 +24,7 @@ public class SystemAuthPermServiceImpl implements ISystemAuthPermService {
|
||||
SystemAuthPermMapper systemAuthPermMapper;
|
||||
|
||||
@Resource
|
||||
SystemAuthRoleMapper systemAuthRoleMapper;
|
||||
SystemRoleMapper systemAuthRoleMapper;
|
||||
|
||||
/**
|
||||
* 根据角色ID获取菜单ID
|
||||
@@ -40,7 +40,7 @@ public class SystemAuthPermServiceImpl implements ISystemAuthPermService {
|
||||
return menus;
|
||||
}
|
||||
|
||||
SystemAuthRole systemAuthRole = systemAuthRoleMapper.selectOne(new QueryWrapper<SystemAuthRole>()
|
||||
SystemRole systemAuthRole = systemAuthRoleMapper.selectOne(new QueryWrapper<SystemRole>()
|
||||
.in("id", roleIds)
|
||||
.eq("is_disable", 0)
|
||||
.last("limit 1"));
|
||||
@@ -1,19 +1,19 @@
|
||||
package com.mdd.admin.service.impl;
|
||||
package com.mdd.admin.service.impl.system;
|
||||
|
||||
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.mdd.admin.service.ISystemAuthPostService;
|
||||
import com.mdd.admin.service.system.ISystemAuthPostService;
|
||||
import com.mdd.admin.validate.commons.PageValidate;
|
||||
import com.mdd.admin.validate.system.SystemPostCreateValidate;
|
||||
import com.mdd.admin.validate.system.SystemPostSearchValidate;
|
||||
import com.mdd.admin.validate.system.SystemPostUpdateValidate;
|
||||
import com.mdd.admin.vo.system.SystemAuthPostVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||
import com.mdd.common.entity.admin.Admin;
|
||||
import com.mdd.common.entity.system.SystemAuthPost;
|
||||
import com.mdd.common.mapper.system.SystemAuthAdminMapper;
|
||||
import com.mdd.common.mapper.admin.AdminMapper;
|
||||
import com.mdd.common.mapper.system.SystemAuthPostMapper;
|
||||
import com.mdd.common.util.TimeUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -34,7 +34,7 @@ public class SystemAuthPostServiceImpl implements ISystemAuthPostService {
|
||||
SystemAuthPostMapper systemAuthPostMapper;
|
||||
|
||||
@Resource
|
||||
SystemAuthAdminMapper systemAuthAdminMapper;
|
||||
AdminMapper systemAuthAdminMapper;
|
||||
|
||||
/**
|
||||
* 岗位所有
|
||||
@@ -212,7 +212,7 @@ public class SystemAuthPostServiceImpl implements ISystemAuthPostService {
|
||||
|
||||
Assert.notNull(model, "岗位不存在");
|
||||
|
||||
SystemAuthAdmin systemAuthAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
Admin systemAuthAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<Admin>()
|
||||
.select("id,nickname")
|
||||
.apply("find_in_set({0}, post_ids)", id)
|
||||
.eq("is_delete", 0)
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mdd.admin.service.impl;
|
||||
package com.mdd.admin.service.impl.system;
|
||||
|
||||
import com.mdd.admin.service.ISystemCacheService;
|
||||
import com.mdd.admin.service.system.ISystemCacheService;
|
||||
import com.mdd.common.cache.ConfigCache;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package com.mdd.admin.service.impl;
|
||||
package com.mdd.admin.service.impl.system;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mdd.admin.cache.CaptchaCache;
|
||||
import com.mdd.admin.service.ISystemLoginService;
|
||||
import com.mdd.admin.service.system.ISystemLoginService;
|
||||
import com.mdd.admin.validate.system.SystemAdminLoginsValidate;
|
||||
import com.mdd.admin.vo.system.SystemCaptchaVo;
|
||||
import com.mdd.admin.vo.system.SystemLoginVo;
|
||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||
import com.mdd.common.entity.admin.Admin;
|
||||
import com.mdd.common.entity.system.SystemLogLogin;
|
||||
import com.mdd.common.enums.ErrorEnum;
|
||||
import com.mdd.common.exception.LoginException;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.mapper.system.SystemAuthAdminMapper;
|
||||
import com.mdd.common.mapper.admin.AdminMapper;
|
||||
import com.mdd.common.mapper.system.SystemLogLoginMapper;
|
||||
import com.mdd.common.util.*;
|
||||
import com.google.code.kaptcha.Producer;
|
||||
@@ -20,7 +20,6 @@ import nl.bitwalker.useragentutils.UserAgent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.FastByteArrayOutputStream;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -43,7 +42,7 @@ public class SystemLoginServiceImpl implements ISystemLoginService {
|
||||
SystemLogLoginMapper systemLogLoginMapper;
|
||||
|
||||
@Resource
|
||||
SystemAuthAdminMapper systemAuthAdminMapper;
|
||||
AdminMapper adminMapper;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SystemLoginServiceImpl.class);
|
||||
|
||||
@@ -91,44 +90,30 @@ public class SystemLoginServiceImpl implements ISystemLoginService {
|
||||
*/
|
||||
@Override
|
||||
public SystemLoginVo login(SystemAdminLoginsValidate loginsValidate) {
|
||||
String username = loginsValidate.getUsername();
|
||||
String username = loginsValidate.getAccount();
|
||||
String password = loginsValidate.getPassword();
|
||||
|
||||
String captchaStatus = YmlUtils.get("like.captcha.status");
|
||||
if (StringUtils.isNotNull(captchaStatus) && captchaStatus.equals("true")) {
|
||||
Assert.notNull(loginsValidate.getCode(), "code参数缺失");
|
||||
Assert.notNull(loginsValidate.getUuid(), "uuid参数缺失");
|
||||
|
||||
String code = CaptchaCache.get(loginsValidate.getUuid());
|
||||
if (!loginsValidate.getCode().equals(code)) {
|
||||
throw new LoginException(ErrorEnum.CAPTCHA_ERROR.getCode(), ErrorEnum.CAPTCHA_ERROR.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
SystemAuthAdmin sysAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
.eq("username", username)
|
||||
Admin sysAdmin = adminMapper.selectOne(new QueryWrapper<Admin>()
|
||||
.eq("account", username)
|
||||
.last("limit 1"));
|
||||
|
||||
if (StringUtils.isNull(sysAdmin) || sysAdmin.getIsDelete().equals(1)) {
|
||||
this.recordLoginLog(0, loginsValidate.getUsername(), ErrorEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
throw new LoginException(ErrorEnum.LOGIN_ACCOUNT_ERROR.getCode(), ErrorEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
if (StringUtils.isNull(sysAdmin)) {
|
||||
throw new OperateException("账号不存在");
|
||||
}
|
||||
|
||||
if (sysAdmin.getIsDisable().equals(1)) {
|
||||
this.recordLoginLog(sysAdmin.getId(), loginsValidate.getUsername(), ErrorEnum.LOGIN_DISABLE_ERROR.getMsg());
|
||||
throw new LoginException(ErrorEnum.LOGIN_DISABLE_ERROR.getCode(), ErrorEnum.LOGIN_DISABLE_ERROR.getMsg());
|
||||
if (sysAdmin.getDisable().equals(1)) {
|
||||
this.recordLoginLog(sysAdmin.getId(), loginsValidate.getAccount(), ErrorEnum.FAILED.getMsg());
|
||||
throw new LoginException(ErrorEnum.FAILED.getCode(), ErrorEnum.LOGIN_DISABLE_ERROR.getMsg());
|
||||
}
|
||||
|
||||
String newPWd = password + sysAdmin.getSalt();
|
||||
String md5Pwd = ToolUtils.makeMd5(newPWd);
|
||||
String md5Pwd = ToolUtils.makePassword(password);
|
||||
if (!md5Pwd.equals(sysAdmin.getPassword())) {
|
||||
this.recordLoginLog(sysAdmin.getId(), loginsValidate.getUsername(), ErrorEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
throw new LoginException(ErrorEnum.LOGIN_ACCOUNT_ERROR.getCode(), ErrorEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
this.recordLoginLog(sysAdmin.getId(), loginsValidate.getAccount(), ErrorEnum.FAILED.getMsg());
|
||||
throw new LoginException(ErrorEnum.FAILED.getCode(), ErrorEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
}
|
||||
|
||||
try {
|
||||
// 禁止多处登录
|
||||
if (sysAdmin.getIsMultipoint().equals(0)) {
|
||||
if (sysAdmin.getMultipointLogin().equals(0)) {
|
||||
StpUtil.logout(sysAdmin.getId());
|
||||
}
|
||||
|
||||
@@ -136,22 +121,26 @@ public class SystemLoginServiceImpl implements ISystemLoginService {
|
||||
StpUtil.login(sysAdmin.getId());
|
||||
|
||||
// 更新登录信息
|
||||
sysAdmin.setLastLoginIp(IpUtils.getIpAddress());
|
||||
sysAdmin.setLastLoginTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthAdminMapper.updateById(sysAdmin);
|
||||
sysAdmin.setLoginIp(IpUtils.getIpAddress());
|
||||
sysAdmin.setLoginTime(System.currentTimeMillis() / 1000);
|
||||
adminMapper.updateById(sysAdmin);
|
||||
|
||||
// 记录登录日志
|
||||
this.recordLoginLog(sysAdmin.getId(), loginsValidate.getUsername(), "");
|
||||
this.recordLoginLog(sysAdmin.getId(), loginsValidate.getAccount(), "");
|
||||
|
||||
// 响应登录信息
|
||||
String defaultAvatar = "/api/static/backend_avatar.png";
|
||||
String avatar = StringUtils.isNotEmpty(sysAdmin.getAvatar()) ? UrlUtils.toRelativeUrl(sysAdmin.getAvatar()) : defaultAvatar;
|
||||
SystemLoginVo vo = new SystemLoginVo();
|
||||
vo.setId(sysAdmin.getId());
|
||||
vo.setName(sysAdmin.getName());
|
||||
vo.setAvatar(UrlUtils.toAbsoluteUrl(avatar));
|
||||
vo.setToken(StpUtil.getTokenValue());
|
||||
return vo;
|
||||
} catch (Exception e) {
|
||||
Integer adminId = StringUtils.isNotNull(sysAdmin.getId()) ? sysAdmin.getId() : 0;
|
||||
String error = StringUtils.isEmpty(e.getMessage()) ? "未知错误" : e.getMessage();
|
||||
this.recordLoginLog(adminId, loginsValidate.getUsername(), error);
|
||||
this.recordLoginLog(adminId, loginsValidate.getAccount(), error);
|
||||
throw new OperateException(e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.mdd.admin.service.impl;
|
||||
package com.mdd.admin.service.impl.system;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.query.MPJQueryWrapper;
|
||||
import com.mdd.admin.service.ISystemLogsServer;
|
||||
import com.mdd.admin.service.system.ISystemLogsServer;
|
||||
import com.mdd.admin.validate.commons.PageValidate;
|
||||
import com.mdd.admin.validate.system.SystemSearchLoginsValidate;
|
||||
import com.mdd.admin.validate.system.SystemSearchOperateValidate;
|
||||
@@ -1,20 +1,20 @@
|
||||
package com.mdd.admin.service.impl;
|
||||
package com.mdd.admin.service.impl.system;
|
||||
|
||||
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.mdd.admin.service.ISystemAuthPermService;
|
||||
import com.mdd.admin.service.ISystemAuthRoleService;
|
||||
import com.mdd.admin.service.system.ISystemAuthPermService;
|
||||
import com.mdd.admin.service.system.ISystemRoleService;
|
||||
import com.mdd.admin.validate.commons.PageValidate;
|
||||
import com.mdd.admin.validate.system.SystemRoleCreateValidate;
|
||||
import com.mdd.admin.validate.system.SystemRoleUpdateValidate;
|
||||
import com.mdd.admin.vo.system.SystemAuthRoleVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||
import com.mdd.common.entity.system.SystemAuthRole;
|
||||
import com.mdd.common.mapper.system.SystemAuthAdminMapper;
|
||||
import com.mdd.common.mapper.system.SystemAuthRoleMapper;
|
||||
import com.mdd.common.entity.admin.Admin;
|
||||
import com.mdd.common.entity.system.SystemRole;
|
||||
import com.mdd.common.mapper.admin.AdminMapper;
|
||||
import com.mdd.common.mapper.system.SystemRoleMapper;
|
||||
import com.mdd.common.util.TimeUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -28,13 +28,13 @@ import java.util.*;
|
||||
* 系统角色服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class SystemAuthRoleServiceImpl implements ISystemAuthRoleService {
|
||||
public class SystemRoleServiceImpl implements ISystemRoleService {
|
||||
|
||||
@Resource
|
||||
SystemAuthAdminMapper systemAuthAdminMapper;
|
||||
AdminMapper systemAuthAdminMapper;
|
||||
|
||||
@Resource
|
||||
SystemAuthRoleMapper systemAuthRoleMapper;
|
||||
SystemRoleMapper systemRoleMapper;
|
||||
|
||||
@Resource
|
||||
ISystemAuthPermService iSystemAuthPermService;
|
||||
@@ -47,19 +47,18 @@ public class SystemAuthRoleServiceImpl implements ISystemAuthRoleService {
|
||||
*/
|
||||
@Override
|
||||
public List<SystemAuthRoleVo> all() {
|
||||
QueryWrapper<SystemAuthRole> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("id,name,sort,is_disable,create_time,update_time");
|
||||
QueryWrapper<SystemRole> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("id,name,sort,create_time,update_time");
|
||||
queryWrapper.orderByDesc(Arrays.asList("sort", "id"));
|
||||
List<SystemAuthRole> systemAuthRoles = systemAuthRoleMapper.selectList(queryWrapper);
|
||||
List<SystemRole> systemAuthRoles = systemRoleMapper.selectList(queryWrapper);
|
||||
|
||||
List<SystemAuthRoleVo> list = new ArrayList<>();
|
||||
for (SystemAuthRole systemAuthRole : systemAuthRoles) {
|
||||
for (SystemRole systemAuthRole : systemAuthRoles) {
|
||||
SystemAuthRoleVo vo = new SystemAuthRoleVo();
|
||||
|
||||
vo.setId(systemAuthRole.getId());
|
||||
vo.setName(systemAuthRole.getName());
|
||||
vo.setSort(systemAuthRole.getSort());
|
||||
vo.setIsDisable(systemAuthRole.getIsDisable());
|
||||
vo.setCreateTime(TimeUtils.timestampToDate(systemAuthRole.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtils.timestampToDate(systemAuthRole.getUpdateTime()));
|
||||
vo.setMember(0);
|
||||
@@ -83,21 +82,17 @@ public class SystemAuthRoleServiceImpl implements ISystemAuthRoleService {
|
||||
Integer page = pageValidate.getPageNo();
|
||||
Integer limit = pageValidate.getPageSize();
|
||||
|
||||
QueryWrapper<SystemAuthRole> queryWrapper = new QueryWrapper<>();
|
||||
QueryWrapper<SystemRole> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc(Arrays.asList("sort", "id"));
|
||||
|
||||
IPage<SystemAuthRole> iPage = systemAuthRoleMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||
IPage<SystemRole> iPage = systemRoleMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||
|
||||
List<SystemAuthRoleVo> list = new ArrayList<>();
|
||||
for (SystemAuthRole systemAuthRole : iPage.getRecords()) {
|
||||
for (SystemRole systemAuthRole : iPage.getRecords()) {
|
||||
SystemAuthRoleVo vo = new SystemAuthRoleVo();
|
||||
BeanUtils.copyProperties(systemAuthRole, vo);
|
||||
|
||||
List<Integer> ids = systemAuthAdminMapper.selectChildrenById(systemAuthRole.getId());
|
||||
Integer member = ids.size();
|
||||
|
||||
vo.setMenus(new ArrayList<>());
|
||||
vo.setMember(member);
|
||||
vo.setCreateTime(TimeUtils.timestampToDate(systemAuthRole.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtils.timestampToDate(systemAuthRole.getUpdateTime()));
|
||||
list.add(vo);
|
||||
@@ -115,7 +110,7 @@ public class SystemAuthRoleServiceImpl implements ISystemAuthRoleService {
|
||||
*/
|
||||
@Override
|
||||
public SystemAuthRoleVo detail(Integer id) {
|
||||
SystemAuthRole systemAuthRole = systemAuthRoleMapper.selectOne(new QueryWrapper<SystemAuthRole>()
|
||||
SystemRole systemAuthRole = systemRoleMapper.selectOne(new QueryWrapper<SystemRole>()
|
||||
.eq("id", id)
|
||||
.last("limit 1"));
|
||||
|
||||
@@ -143,19 +138,18 @@ public class SystemAuthRoleServiceImpl implements ISystemAuthRoleService {
|
||||
@Override
|
||||
@Transactional
|
||||
public void add(SystemRoleCreateValidate createValidate) {
|
||||
Assert.isNull(systemAuthRoleMapper.selectOne(new QueryWrapper<SystemAuthRole>()
|
||||
Assert.isNull(systemRoleMapper.selectOne(new QueryWrapper<SystemRole>()
|
||||
.select("id,name")
|
||||
.eq("name", createValidate.getName().trim())
|
||||
.eq("name", createValidate.getName().trim()).isNull("delete_time")
|
||||
.last("limit 1")), "角色名称已存在!");
|
||||
|
||||
SystemAuthRole model = new SystemAuthRole();
|
||||
SystemRole model = new SystemRole();
|
||||
model.setName(createValidate.getName().trim());
|
||||
model.setRemark(createValidate.getRemark());
|
||||
model.setDesc(createValidate.getDesc());
|
||||
model.setSort(createValidate.getSort());
|
||||
model.setIsDisable(createValidate.getIsDisable());
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthRoleMapper.insert(model);
|
||||
systemRoleMapper.insert(model);
|
||||
iSystemAuthPermService.batchSaveByMenuIds(model.getId(), createValidate.getMenuIds());
|
||||
}
|
||||
|
||||
@@ -168,25 +162,24 @@ public class SystemAuthRoleServiceImpl implements ISystemAuthRoleService {
|
||||
@Override
|
||||
@Transactional
|
||||
public void edit(SystemRoleUpdateValidate updateValidate) {
|
||||
Assert.notNull(systemAuthRoleMapper.selectOne(new QueryWrapper<SystemAuthRole>()
|
||||
Assert.notNull(systemRoleMapper.selectOne(new QueryWrapper<SystemRole>()
|
||||
.select("id,name")
|
||||
.eq("id", updateValidate.getId())
|
||||
.eq("id", updateValidate.getId()).isNull("delete_time")
|
||||
.last("limit 1")), "角色已不存在!");
|
||||
|
||||
Assert.isNull(systemAuthRoleMapper.selectOne(new QueryWrapper<SystemAuthRole>()
|
||||
Assert.isNull(systemRoleMapper.selectOne(new QueryWrapper<SystemRole>()
|
||||
.select("id,name")
|
||||
.ne("id", updateValidate.getId())
|
||||
.eq("name", updateValidate.getName().trim())
|
||||
.eq("name", updateValidate.getName().trim()).isNull("delete_time")
|
||||
.last("limit 1")), "角色名称已存在!");
|
||||
|
||||
SystemAuthRole model = new SystemAuthRole();
|
||||
SystemRole model = new SystemRole();
|
||||
model.setId(updateValidate.getId());
|
||||
model.setName(updateValidate.getName().trim());
|
||||
model.setRemark(updateValidate.getRemark());
|
||||
model.setDesc(updateValidate.getDesc());
|
||||
model.setSort(updateValidate.getSort());
|
||||
model.setIsDisable(updateValidate.getIsDisable());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemAuthRoleMapper.updateById(model);
|
||||
systemRoleMapper.updateById(model);
|
||||
|
||||
iSystemAuthPermService.batchDeleteByRoleId(updateValidate.getId());
|
||||
iSystemAuthPermService.batchSaveByMenuIds(updateValidate.getId(), updateValidate.getMenuIds());
|
||||
@@ -202,19 +195,19 @@ public class SystemAuthRoleServiceImpl implements ISystemAuthRoleService {
|
||||
@Transactional
|
||||
public void del(Integer id) {
|
||||
Assert.notNull(
|
||||
systemAuthRoleMapper.selectOne(new QueryWrapper<SystemAuthRole>()
|
||||
systemRoleMapper.selectOne(new QueryWrapper<SystemRole>()
|
||||
.select("id", "name")
|
||||
.eq("id", id)
|
||||
.last("limit 1")),
|
||||
"角色已不存在!");
|
||||
|
||||
Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||
Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper<Admin>()
|
||||
.select("id", "role_ids", "nickname")
|
||||
.apply("find_in_set({0}, role_ids)", id)
|
||||
.eq("is_delete", 0)),
|
||||
"角色已被管理员使用,请先移除");
|
||||
|
||||
systemAuthRoleMapper.deleteById(id);
|
||||
systemRoleMapper.deleteById(id);
|
||||
iSystemAuthPermService.batchDeleteByRoleId(id);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.admin.service;
|
||||
package com.mdd.admin.service.system;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.mdd.admin.validate.system.SystemDeptCreateValidate;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.admin.service;
|
||||
package com.mdd.admin.service.system;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.mdd.admin.validate.system.SystemMenuCreateValidate;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.admin.service;
|
||||
package com.mdd.admin.service.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.admin.service;
|
||||
package com.mdd.admin.service.system;
|
||||
|
||||
import com.mdd.admin.validate.commons.PageValidate;
|
||||
import com.mdd.admin.validate.system.SystemPostCreateValidate;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.admin.service;
|
||||
package com.mdd.admin.service.system;
|
||||
|
||||
/**
|
||||
* 系统缓存接口类
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.admin.service;
|
||||
package com.mdd.admin.service.system;
|
||||
|
||||
import com.mdd.admin.validate.system.SystemAdminLoginsValidate;
|
||||
import com.mdd.admin.vo.system.SystemCaptchaVo;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.admin.service;
|
||||
package com.mdd.admin.service.system;
|
||||
|
||||
import com.mdd.admin.validate.commons.PageValidate;
|
||||
import com.mdd.admin.validate.system.SystemSearchLoginsValidate;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.admin.service;
|
||||
package com.mdd.admin.service.system;
|
||||
|
||||
import com.mdd.admin.validate.commons.PageValidate;
|
||||
import com.mdd.admin.validate.system.SystemRoleCreateValidate;
|
||||
@@ -8,12 +8,11 @@ import com.mdd.common.core.PageResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统角色服务接口类
|
||||
*/
|
||||
public interface ISystemAuthRoleService {
|
||||
public interface ISystemRoleService {
|
||||
|
||||
/**
|
||||
* 角色所有
|
||||
@@ -3,9 +3,11 @@ package com.mdd.admin.validate.system;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@@ -17,17 +19,15 @@ public class SystemAdminLoginsValidate implements Serializable {
|
||||
@NotEmpty(message = "账号不能为空")
|
||||
@Length(min = 2, max = 20, message = "账号或密码错误")
|
||||
@ApiModelProperty(value = "登录账号", required = true)
|
||||
private String username;
|
||||
private String account;
|
||||
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
@Length(min = 6, max = 64, message = "账号或密码错误")
|
||||
@ApiModelProperty(value = "登录密码", required = true)
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(value = "验证码")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "标识码")
|
||||
private String uuid;
|
||||
@NotNull(message = "请选择设备类型")
|
||||
@ApiModelProperty(value = "设备类型", required = true)
|
||||
private Integer terminal;
|
||||
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ public class SystemRoleCreateValidate implements Serializable {
|
||||
@ApiModelProperty(value = "角色名称", required = true)
|
||||
private String name;
|
||||
|
||||
@Length(max = 200, message = "备注信息不能超过200个字符")
|
||||
@ApiModelProperty(value = "备注", required = true)
|
||||
private String remark;
|
||||
@Length(max = 200, message = "描述信息不能超过200个字符")
|
||||
@ApiModelProperty(value = "描述", required = true)
|
||||
private String desc;
|
||||
|
||||
@DecimalMin(value = "0", message = "排序号值不能少于0")
|
||||
@ApiModelProperty(value = "排序", required = true)
|
||||
|
||||
@@ -27,9 +27,9 @@ public class SystemRoleUpdateValidate implements Serializable {
|
||||
@ApiModelProperty(value = "角色名称", required = true)
|
||||
private String name;
|
||||
|
||||
@Length(max = 200, message = "备注信息不能超过200个字符")
|
||||
@ApiModelProperty(value = "备注", required = true)
|
||||
private String remark;
|
||||
@Length(max = 200, message = "描述信息不能超过200个字符")
|
||||
@ApiModelProperty(value = "描述", required = true)
|
||||
private String desc;
|
||||
|
||||
@DecimalMin(value = "0", message = "排序号值不能少于0")
|
||||
@ApiModelProperty(value = "排序")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mdd.admin.vo.system;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -18,4 +19,12 @@ public class SystemLoginVo implements Serializable {
|
||||
@ApiModelProperty(value = "登录令牌")
|
||||
private String token;
|
||||
|
||||
@ApiModelProperty(value = "名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "用户头像")
|
||||
private String avatar;
|
||||
@ApiModelProperty(value = "用户头像")
|
||||
@JsonProperty("role_name")
|
||||
private String roleName;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# 项目配置
|
||||
like:
|
||||
upload-directory: /www/uploads/likeadmin-java/ # 上传目录
|
||||
unique-identification: WHsAs2rtaav7hor8LdGy #密码盐
|
||||
|
||||
# 框架配置
|
||||
spring:
|
||||
|
||||
@@ -17,6 +17,9 @@ public class AjaxResult<T> {
|
||||
/** 响应数据 **/
|
||||
private T data;
|
||||
|
||||
/** 是否显示错误信息 **/
|
||||
private Integer show;
|
||||
|
||||
/** 无参构造 **/
|
||||
protected AjaxResult() {}
|
||||
|
||||
@@ -28,10 +31,11 @@ public class AjaxResult<T> {
|
||||
* @param msg 提示信息
|
||||
* @param data 响应数据
|
||||
*/
|
||||
public AjaxResult(Integer code, String msg, T data) {
|
||||
public AjaxResult(Integer code, String msg, T data, Integer show) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
this.show = show;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,7 +45,7 @@ public class AjaxResult<T> {
|
||||
* @return AjaxResult
|
||||
*/
|
||||
public static AjaxResult<Object> success() {
|
||||
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), ErrorEnum.SUCCESS.getMsg(), new ArrayList<>());
|
||||
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), ErrorEnum.SUCCESS.getMsg(), new ArrayList<>(), ErrorEnum.HIDE_MSG.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +56,7 @@ public class AjaxResult<T> {
|
||||
* @return AjaxResult
|
||||
*/
|
||||
public static AjaxResult<Object> success(Integer code) {
|
||||
return new AjaxResult<>(code, ErrorEnum.SUCCESS.getMsg(), new ArrayList<>());
|
||||
return new AjaxResult<>(code, ErrorEnum.SUCCESS.getMsg(), new ArrayList<>(), ErrorEnum.HIDE_MSG.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +67,18 @@ public class AjaxResult<T> {
|
||||
* @return AjaxResult
|
||||
*/
|
||||
public static AjaxResult<Object> success(String msg) {
|
||||
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), msg, new ArrayList<>());
|
||||
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), msg, new ArrayList<>(), ErrorEnum.SHOW_MSG.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功返回结果
|
||||
*
|
||||
* @author fzr
|
||||
* @param msg 提示信息
|
||||
* @return AjaxResult
|
||||
*/
|
||||
public static AjaxResult<Object> success(String msg, Integer show) {
|
||||
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), msg, new ArrayList<>(), show);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +89,7 @@ public class AjaxResult<T> {
|
||||
* @return AjaxResult
|
||||
*/
|
||||
public static <T> AjaxResult<T> success(T data) {
|
||||
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), ErrorEnum.SUCCESS.getMsg(), data);
|
||||
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), ErrorEnum.SUCCESS.getMsg(), data, ErrorEnum.HIDE_MSG.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +101,19 @@ public class AjaxResult<T> {
|
||||
* @return AjaxResult
|
||||
*/
|
||||
public static AjaxResult<Object> success(Integer code, String msg) {
|
||||
return new AjaxResult<>(code, msg, new ArrayList<>());
|
||||
return new AjaxResult<>(code, msg, new ArrayList<>(), ErrorEnum.SHOW_MSG.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功返回结果
|
||||
*
|
||||
* @author fzr
|
||||
* @param code 状态码
|
||||
* @param msg 提示信息
|
||||
* @return AjaxResult
|
||||
*/
|
||||
public static AjaxResult<Object> success(Integer code, String msg, Integer show) {
|
||||
return new AjaxResult<>(code, msg, new ArrayList<>(), show);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +125,7 @@ public class AjaxResult<T> {
|
||||
* @return AjaxResult
|
||||
*/
|
||||
public static <T> AjaxResult <T> success(String msg, T data) {
|
||||
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), msg, data);
|
||||
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), msg, data, ErrorEnum.SHOW_MSG.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +138,7 @@ public class AjaxResult<T> {
|
||||
* @return AjaxResult
|
||||
*/
|
||||
public static <T> AjaxResult<T> success(Integer code, String msg, T data) {
|
||||
return new AjaxResult<>(code, msg, data);
|
||||
return new AjaxResult<>(code, msg, data, ErrorEnum.SHOW_MSG.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +149,7 @@ public class AjaxResult<T> {
|
||||
* @return AjaxResult
|
||||
*/
|
||||
public static AjaxResult<Object> failed(Integer code) {
|
||||
return new AjaxResult<>(code, ErrorEnum.FAILED.getMsg(), new ArrayList<>());
|
||||
return new AjaxResult<>(code, ErrorEnum.FAILED.getMsg(), new ArrayList<>(), ErrorEnum.SHOW_MSG.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,7 +160,7 @@ public class AjaxResult<T> {
|
||||
* @return AjaxResult
|
||||
*/
|
||||
public static AjaxResult<Object> failed(String msg) {
|
||||
return new AjaxResult<>(ErrorEnum.FAILED.getCode(), msg, new ArrayList<>());
|
||||
return new AjaxResult<>(ErrorEnum.FAILED.getCode(), msg, new ArrayList<>(), ErrorEnum.SHOW_MSG.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +171,7 @@ public class AjaxResult<T> {
|
||||
* @return AjaxResult
|
||||
*/
|
||||
public static <T> AjaxResult<T> failed(T data) {
|
||||
return new AjaxResult<T>(ErrorEnum.FAILED.getCode(), ErrorEnum.FAILED.getMsg(), data);
|
||||
return new AjaxResult<T>(ErrorEnum.FAILED.getCode(), ErrorEnum.FAILED.getMsg(), data, ErrorEnum.SHOW_MSG.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +183,7 @@ public class AjaxResult<T> {
|
||||
* @return AjaxResult
|
||||
*/
|
||||
public static AjaxResult<Object> failed(Integer code, String msg) {
|
||||
return new AjaxResult<>(code, msg, new ArrayList<>());
|
||||
return new AjaxResult<>(code, msg, new ArrayList<>(), ErrorEnum.SHOW_MSG.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,7 +196,19 @@ public class AjaxResult<T> {
|
||||
* @return AjaxResult
|
||||
*/
|
||||
public static <T> AjaxResult<T> failed(Integer code, String msg, T data) {
|
||||
return new AjaxResult<>(code, msg, data);
|
||||
return new AjaxResult<>(code, msg, data, ErrorEnum.SHOW_MSG.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应失败结果
|
||||
*
|
||||
* @author fzr
|
||||
* @param code 状态码
|
||||
* @param msg 提示信息
|
||||
* @param data 响应数据
|
||||
* @return AjaxResult
|
||||
*/
|
||||
public static <T> AjaxResult<T> failed(Integer code, String msg, T data, Integer show) {
|
||||
return new AjaxResult<>(code, msg, data, show);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mdd.common.entity.system;
|
||||
package com.mdd.common.entity.admin;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@@ -10,7 +10,7 @@ import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("系统管理员实体")
|
||||
public class SystemAuthAdmin implements Serializable {
|
||||
public class Admin implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -18,47 +18,32 @@ public class SystemAuthAdmin implements Serializable {
|
||||
@ApiModelProperty("ID")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("是否超级管理员 0-否 1-是")
|
||||
private Integer root;
|
||||
|
||||
@ApiModelProperty("用户账号")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty("用户昵称")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty("用户密码")
|
||||
private String password;
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("用户头像")
|
||||
private String avatar;
|
||||
|
||||
@ApiModelProperty("加密盐巴")
|
||||
private String salt;
|
||||
@ApiModelProperty("用户昵称")
|
||||
private String account;
|
||||
|
||||
@ApiModelProperty("角色主键")
|
||||
private String roleIds;
|
||||
|
||||
@ApiModelProperty("部门主键")
|
||||
private String deptIds;
|
||||
|
||||
@ApiModelProperty("岗位主键")
|
||||
private String postIds;
|
||||
|
||||
@ApiModelProperty("排序编号")
|
||||
private Integer sort;
|
||||
@ApiModelProperty("用户密码")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty("多端登录: [0=否, 1=是]")
|
||||
private Integer isMultipoint;
|
||||
private Integer multipointLogin;
|
||||
|
||||
@ApiModelProperty("是否禁用: [0=否, 1=是]")
|
||||
private Integer isDisable;
|
||||
|
||||
@ApiModelProperty("是否删除: [0=否, 1=是]")
|
||||
private Integer isDelete;
|
||||
private Integer disable;
|
||||
|
||||
@ApiModelProperty("最后登录IP")
|
||||
private String lastLoginIp;
|
||||
private String loginIp;
|
||||
|
||||
@ApiModelProperty("最后登录时间")
|
||||
private Long lastLoginTime;
|
||||
private Long loginTime;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Long createTime;
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mdd.common.entity.admin;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("角色关联表实体")
|
||||
public class AdminRole implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("管理员id")
|
||||
private Integer adminId;
|
||||
|
||||
@ApiModelProperty("角色id")
|
||||
private Integer roleId;
|
||||
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("系统角色实体")
|
||||
public class SystemAuthRole implements Serializable {
|
||||
public class SystemRole implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -21,19 +21,18 @@ public class SystemAuthRole implements Serializable {
|
||||
@ApiModelProperty("角色名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("备注信息")
|
||||
private String remark;
|
||||
@ApiModelProperty("描述")
|
||||
private String desc;
|
||||
|
||||
@ApiModelProperty("角色排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty("是否禁用: [0=否, 1=是]")
|
||||
private Integer isDisable;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Long createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Long updateTime;
|
||||
private Long updateTime;
|
||||
|
||||
@ApiModelProperty("删除时间")
|
||||
private Long deleteTime;
|
||||
}
|
||||
@@ -2,8 +2,10 @@ package com.mdd.common.enums;
|
||||
|
||||
public enum ErrorEnum {
|
||||
|
||||
SUCCESS(200, "成功"),
|
||||
FAILED(300, "失败"),
|
||||
SHOW_MSG(1, "显示信息"),
|
||||
HIDE_MSG(0, "隐藏信息"),
|
||||
SUCCESS(1, "成功"),
|
||||
FAILED(0, "失败"),
|
||||
PARAMS_VALID_ERROR(310, "参数校验错误"),
|
||||
PARAMS_TYPE_ERROR(311, "参数类型错误"),
|
||||
REQUEST_METHOD_ERROR(312, "请求方法错误"),
|
||||
|
||||
@@ -12,10 +12,11 @@ public class BaseException extends RuntimeException {
|
||||
|
||||
private Integer code;
|
||||
private String msg;
|
||||
private Integer show;
|
||||
|
||||
public BaseException(Integer code, String msg) {
|
||||
public BaseException(Integer code, String msg, Integer show) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.show = show;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ public class GlobalException {
|
||||
public AjaxResult<Object> handleException(BaseException e) {
|
||||
int code = e.getCode();
|
||||
String msg = e.getMsg();
|
||||
int show = e.getShow();
|
||||
return AjaxResult.failed(code, msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
package com.mdd.common.exception;
|
||||
|
||||
import com.mdd.common.enums.ErrorEnum;
|
||||
|
||||
/**
|
||||
* 登录异常类
|
||||
*/
|
||||
public class LoginException extends BaseException {
|
||||
|
||||
public LoginException(Integer code, String msg) {
|
||||
super(code, msg);
|
||||
super(code, msg, ErrorEnum.SHOW_MSG.getCode());
|
||||
}
|
||||
|
||||
public LoginException(Integer code, String msg, Integer show) {
|
||||
super(code, msg, show);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ import com.mdd.common.enums.ErrorEnum;
|
||||
public class OperateException extends BaseException {
|
||||
|
||||
public OperateException(String msg) {
|
||||
super(ErrorEnum.FAILED.getCode(), msg);
|
||||
super(ErrorEnum.FAILED.getCode(), msg, ErrorEnum.SHOW_MSG.getCode());
|
||||
}
|
||||
|
||||
public OperateException(String msg, Integer errCode) {
|
||||
super(errCode, msg);
|
||||
super(errCode, msg, ErrorEnum.SHOW_MSG.getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ import com.mdd.common.enums.ErrorEnum;
|
||||
public class PaymentException extends BaseException {
|
||||
|
||||
public PaymentException(String msg) {
|
||||
super(ErrorEnum.PAYMENT_ERROR.getCode(), msg);
|
||||
super(ErrorEnum.FAILED.getCode(), msg, ErrorEnum.SHOW_MSG.getCode());
|
||||
}
|
||||
|
||||
public PaymentException(String msg, Integer errCode) {
|
||||
super(errCode, msg);
|
||||
super(errCode, msg, ErrorEnum.SHOW_MSG.getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mdd.common.mapper.admin;
|
||||
|
||||
import com.mdd.common.core.basics.IBaseMapper;
|
||||
import com.mdd.common.entity.admin.Admin;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统管理员Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AdminMapper extends IBaseMapper<Admin> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mdd.common.mapper.admin;
|
||||
|
||||
import com.mdd.common.core.basics.IBaseMapper;
|
||||
import com.mdd.common.entity.admin.Admin;
|
||||
import com.mdd.common.entity.admin.AdminRole;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 角色关联表Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AdminRoleMapper extends IBaseMapper<AdminRole> {
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.mdd.common.mapper.system;
|
||||
|
||||
import com.mdd.common.core.basics.IBaseMapper;
|
||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统管理员Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemAuthAdminMapper extends IBaseMapper<SystemAuthAdmin> {
|
||||
|
||||
/**
|
||||
* 获取角色管理员
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 文件夹ID
|
||||
* @return List<Integer>
|
||||
*/
|
||||
@Select("SELECT id FROM ${prefix}system_auth_admin WHERE is_delete=0 AND FIND_IN_SET(#{id}, role_ids)")
|
||||
List<Integer> selectChildrenById(Integer id);
|
||||
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.mdd.common.mapper.system;
|
||||
|
||||
import com.mdd.common.core.basics.IBaseMapper;
|
||||
import com.mdd.common.entity.system.SystemAuthRole;
|
||||
import com.mdd.common.entity.system.SystemRole;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 系统角色Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemAuthRoleMapper extends IBaseMapper<SystemAuthRole> {
|
||||
public interface SystemRoleMapper extends IBaseMapper<SystemRole> {
|
||||
}
|
||||
@@ -47,6 +47,19 @@ public class ToolUtils {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 制作MD5
|
||||
*
|
||||
* @author fzr
|
||||
* @param data 需加密的数据
|
||||
* @return String
|
||||
*/
|
||||
public static String makePassword(String password){
|
||||
String newPWd = password + YmlUtils.get("like.unique-identification");
|
||||
String md5Pwd = ToolUtils.makeMd5(ToolUtils.makeMd5(newPWd));
|
||||
return md5Pwd;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成唯一Token
|
||||
*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user