修复bug
This commit is contained in:
parent
1923c00b2d
commit
dece7d4f7e
|
|
@ -94,7 +94,7 @@ const handleEdit = async (data: any) => {
|
|||
const handleDelete = async (id: number) => {
|
||||
await feedback.confirm('确定要删除?')
|
||||
await oaReplyDel({ id })
|
||||
feedback.msgSuccess('删除成功')
|
||||
// feedback.msgSuccess('删除成功')
|
||||
getLists()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.mdd.admin;
|
|||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mdd.admin.service.admin.IAdminRoleService;
|
||||
import com.mdd.common.aop.NotPower;
|
||||
import com.mdd.common.aop.NotLogin;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
|
|
@ -33,6 +34,9 @@ public class LikeAdminInterceptor implements HandlerInterceptor {
|
|||
@Resource
|
||||
AdminMapper systemAuthAdminMapper;
|
||||
|
||||
@Resource
|
||||
IAdminRoleService iAdminRoleService;
|
||||
|
||||
/**
|
||||
* 前置处理器
|
||||
*
|
||||
|
|
@ -177,6 +181,8 @@ public class LikeAdminInterceptor implements HandlerInterceptor {
|
|||
// 写入线程
|
||||
LikeAdminThreadLocal.put("adminId", id);
|
||||
LikeAdminThreadLocal.put("username", adminUser.getName());
|
||||
String roleIds = StringUtils.join(iAdminRoleService.getRoleIdAttr(Integer.parseInt(String.valueOf(id))), ",");
|
||||
LikeAdminThreadLocal.put("roleIds", roleIds);
|
||||
|
||||
// 权限校验
|
||||
if (!adminUser.getId().equals(1)) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.mdd.admin.config.stp;
|
|||
import cn.dev33.satoken.stp.StpInterface;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mdd.admin.LikeAdminThreadLocal;
|
||||
import com.mdd.admin.service.admin.IAdminRoleService;
|
||||
import com.mdd.common.entity.system.SystemMenu;
|
||||
import com.mdd.common.entity.system.SystemRoleMenu;
|
||||
import com.mdd.common.mapper.system.SystemMenuMapper;
|
||||
|
|
@ -25,6 +26,9 @@ public class StpInterConfig implements StpInterface {
|
|||
@Resource
|
||||
SystemMenuMapper systemAuthMenuMapper;
|
||||
|
||||
@Resource
|
||||
IAdminRoleService iAdminRoleService;
|
||||
|
||||
/**
|
||||
* 返回一个账号所拥有的权限码集合
|
||||
*
|
||||
|
|
@ -36,14 +40,13 @@ public class StpInterConfig implements StpInterface {
|
|||
public List<String> getPermissionList(Object loginId, String loginType) {
|
||||
List<Integer> roleIds = LikeAdminThreadLocal.getRoleIds();
|
||||
List<String> perms = new LinkedList<>();
|
||||
|
||||
if (roleIds.isEmpty()) {
|
||||
return perms;
|
||||
}
|
||||
|
||||
List<SystemRoleMenu> permList = systemRoleMenuMapper.selectList(
|
||||
new QueryWrapper<SystemRoleMenu>()
|
||||
.select("id,role_id,menu_id")
|
||||
.select("role_id,menu_id")
|
||||
.in("role_id", roleIds));
|
||||
|
||||
if (permList.isEmpty()) {
|
||||
|
|
@ -60,12 +63,12 @@ public class StpInterConfig implements StpInterface {
|
|||
.select("id,perms")
|
||||
.eq("is_disable", 0)
|
||||
.in("id", menuIds)
|
||||
.in("menu_type", Arrays.asList("C", "A"))
|
||||
.orderByAsc(Arrays.asList("menu_sort", "id")));
|
||||
.in("type", Arrays.asList("C", "A"))
|
||||
.orderByAsc(Arrays.asList("sort", "id")));
|
||||
|
||||
for (SystemMenu item : systemAuthMenus) {
|
||||
if (StringUtils.isNotNull(item.getPerms()) && StringUtils.isNotEmpty(item.getPerms())) {
|
||||
perms.add(item.getPerms().trim());
|
||||
perms.add(item.getPerms().trim().replace("/", ":"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@ package com.mdd.admin.controller.adminapi.auth;
|
|||
|
||||
import com.mdd.admin.LikeAdminThreadLocal;
|
||||
import com.mdd.admin.service.IIndexService;
|
||||
import com.mdd.admin.service.admin.IAdminRoleService;
|
||||
import com.mdd.admin.service.admin.IAdminService;
|
||||
import com.mdd.admin.vo.auth.AdminMySelfVo;
|
||||
import com.mdd.common.aop.NotLogin;
|
||||
import com.mdd.common.aop.NotPower;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
|
@ -26,10 +28,17 @@ public class AdminController {
|
|||
@Resource
|
||||
IAdminService iAdminService;
|
||||
|
||||
@Resource
|
||||
IAdminRoleService iAdminRoleService;
|
||||
|
||||
@NotPower
|
||||
@GetMapping("/mySelf")
|
||||
@ApiOperation(value="获取当前管理员信息")
|
||||
public AjaxResult<AdminMySelfVo> mySelf() {
|
||||
List<Integer> roleIds = LikeAdminThreadLocal.getRoleIds();
|
||||
Integer adminId = LikeAdminThreadLocal.getAdminId();
|
||||
|
||||
List<Integer> roleIds = iAdminRoleService.getRoleIdAttr(adminId);
|
||||
|
||||
AdminMySelfVo mySelf = iAdminService.mySelf(LikeAdminThreadLocal.getAdminId(), roleIds);
|
||||
return AjaxResult.success(mySelf);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import com.mdd.admin.service.admin.IAuthService;
|
|||
import com.mdd.admin.vo.system.SystemAuthAdminDetailVo;
|
||||
import com.mdd.common.entity.admin.AdminDept;
|
||||
import com.mdd.common.mapper.admin.AdminDeptMapper;
|
||||
import com.mdd.common.mapper.system.SystemMenuMapper;
|
||||
import com.mdd.common.mapper.system.SystemRoleMenuMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -21,6 +23,13 @@ public class AuthServiceImpl implements IAuthService {
|
|||
|
||||
@Resource
|
||||
IAdminService iAdminService;
|
||||
|
||||
@Resource
|
||||
SystemMenuMapper systemMenuMapper;
|
||||
|
||||
@Resource
|
||||
SystemRoleMenuMapper SystemRoleMenuMapper;
|
||||
|
||||
@Override
|
||||
public List<String> getBtnAuthByRoleId(Integer adminId) {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
|
|
@ -29,7 +38,8 @@ public class AuthServiceImpl implements IAuthService {
|
|||
ret.add("*");
|
||||
return ret;
|
||||
} else {
|
||||
|
||||
List<Integer> menuIds = SystemRoleMenuMapper.getMenuIds(adminId);
|
||||
ret = this.systemMenuMapper.getPerms(menuIds);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ public class SystemLoginServiceImpl implements ISystemLoginService {
|
|||
throw new LoginException(ErrorEnum.FAILED.getCode(), ErrorEnum.LOGIN_DISABLE_ERROR.getMsg());
|
||||
}
|
||||
String md5Pwd = ToolUtils.makePassword(password);
|
||||
System.out.println(md5Pwd);
|
||||
if (!md5Pwd.equals(sysAdmin.getPassword())) {
|
||||
this.recordLoginLog(sysAdmin.getId(), loginsValidate.getAccount(), ErrorEnum.FAILED.getMsg());
|
||||
throw new LoginException(ErrorEnum.FAILED.getCode(), ErrorEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
|
|
@ -145,7 +144,7 @@ public class SystemLoginServiceImpl implements ISystemLoginService {
|
|||
} catch (Exception e) {
|
||||
Integer adminId = StringUtils.isNotNull(sysAdmin.getId()) ? sysAdmin.getId() : 0;
|
||||
String error = StringUtils.isEmpty(e.getMessage()) ? "未知错误" : e.getMessage();
|
||||
this.recordLoginLog(adminId, loginsValidate.getAccount(), error);
|
||||
// this.recordLoginLog(adminId, loginsValidate.getAccount(), error);
|
||||
throw new OperateException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class SystemMenuServiceImpl implements ISystemMenuService {
|
|||
|
||||
QueryWrapper<SystemMenu> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("type", Arrays.asList("M", "C"));
|
||||
queryWrapper.eq("is_disable", 0);
|
||||
// queryWrapper.eq("is_disable", 0);
|
||||
queryWrapper.orderByDesc("sort");
|
||||
queryWrapper.orderByAsc("id");
|
||||
if (!adminId.equals(1)) {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class SystemRoleMenuServiceImpl implements ISystemRoleMenuService {
|
|||
|
||||
SystemRole systemAuthRole = systemAuthRoleMapper.selectOne(new QueryWrapper<SystemRole>()
|
||||
.in("id", roleIds)
|
||||
.eq("is_disable", 0)
|
||||
// .eq("is_disable", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
if (StringUtils.isNull(systemAuthRole)) {
|
||||
|
|
|
|||
|
|
@ -3,10 +3,28 @@ package com.mdd.common.mapper.system;
|
|||
import com.mdd.common.core.basics.IBaseMapper;
|
||||
import com.mdd.common.entity.system.SystemMenu;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统菜单Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemMenuMapper extends IBaseMapper<SystemMenu> {
|
||||
|
||||
@Select({"<script>",
|
||||
" SELECT ",
|
||||
" perms ",
|
||||
" FROM la_system_menu WHERE perms != '' AND id in ",
|
||||
"<foreach item='item' index='index' collection='items' open='(' separator=',' close=')'>",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
"</script>"})
|
||||
List<String> getPerms(@Param("items") List<Integer> menuIds);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,21 @@ import com.mdd.common.core.basics.IBaseMapper;
|
|||
import com.mdd.common.entity.system.SystemMenu;
|
||||
import com.mdd.common.entity.system.SystemRoleMenu;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统菜单Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemRoleMenuMapper extends IBaseMapper<SystemRoleMenu> {
|
||||
|
||||
|
||||
@Select("SELECT DISTINCT menuR.menu_id FROM la_system_role_menu menuR INNER JOIN la_system_role role ON menuR.role_id = role.id INNER JOIN la_admin_role lar ON lar.role_id = role.id WHERE lar.admin_id = #{adminId} AND role.delete_time IS NULL")
|
||||
List<Integer> getMenuIds(@Param("adminId") Integer adminId);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ public class QiniuStorage {
|
|||
public void upload(MultipartFile multipartFile, String key) {
|
||||
Configuration cfg = new Configuration(Region.region2());
|
||||
UploadManager uploadManager = new UploadManager(cfg);
|
||||
|
||||
try {
|
||||
Response response = uploadManager.put(multipartFile.getBytes(), key, this.upToken());
|
||||
DefaultPutRet ret = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
|
||||
|
|
@ -67,8 +66,6 @@ public class QiniuStorage {
|
|||
}
|
||||
|
||||
public void delete(String filePath) {
|
||||
|
||||
|
||||
String accessKey = this.config.getOrDefault("access_key", "");
|
||||
String secretKey = this.config.getOrDefault("secret_key", "");
|
||||
String bucket = this.config.getOrDefault("bucket", "");
|
||||
|
|
|
|||
Loading…
Reference in New Issue