Commit 669fcc2c authored by “xuhd”'s avatar “xuhd”

1、解决修复用户管理修改用户信息会新增一条数据

2、解决修复角色权限无法保存问题
parent a1dc9f09
package com.hungraim.ltc.system.controller;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hungraim.ltc.pojo.entity.system.SystemRole;
import com.hungraim.ltc.pojo.entity.system.SystemRoleResource;
import com.hungraim.ltc.pojo.vo.system.ReqRoleInfo;
import com.hungraim.ltc.system.dao.SystemRoleResourceMapper;
import com.hungraim.ltc.system.service.ISystemRoleResourceService;
import com.hungraim.ltc.system.service.ISystemRoleService;
import com.hungraim.ltc.util.Result;
......@@ -14,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -29,6 +32,8 @@ public class RoleController {
@Autowired
private ISystemRoleResourceService roleResourceService;
@Resource
private SystemRoleResourceMapper systemRoleResourceMapper;
@Autowired
private ISystemRoleService roleService;
......@@ -177,7 +182,10 @@ public class RoleController {
List<Long> deleteRoleResources = roleResources.stream()
.map(SystemRoleResource::getResourceId).filter(resourceId -> !reqRoleInfo.getResource().contains(resourceId))
.collect(Collectors.toList());
roleResourceService.removeByIds(deleteRoleResources);
if(!deleteRoleResources.isEmpty()){
systemRoleResourceMapper.removeByIds(deleteRoleResources,reqRoleInfo.getId());
}
return Result.success("更新成功");
}
......
......@@ -229,7 +229,7 @@ public class UserController {
}
if (flag) {
systemUser.setUpdatedTime(new Date());
userInfoService.save(systemUser);
userInfoService.updateById(systemUser);
}
//查询该角色下所有的资源数据
List<SystemUserRole> roleResources = userRoleService.list(new LambdaQueryWrapper<SystemUserRole>().eq(SystemUserRole::getUserId, reqUserInfo.getId()));
......
......@@ -3,6 +3,7 @@ package com.hungraim.ltc.system.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hungraim.ltc.pojo.entity.system.SystemRoleResource;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
......@@ -22,4 +23,6 @@ public interface SystemRoleResourceMapper extends BaseMapper<SystemRoleResource>
*/
@Select("SELECT ROLE_ID FROM LTC_ROLE_RESOURCE WHERE RESOURCE_ID = #{resourceId} ")
List<Long> listRoleIds(long resourceId);
Integer removeByIds(@Param("resourceIds") List<Long> resourceIds, @Param("id") Long id);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hungraim.ltc.system.dao.SystemRoleResourceMapper">
<delete id="removeByIds" parameterType="list">
delete from LTC_ROLE_RESOURCE where RESOURCE_ID in
<foreach collection="resourceIds" item="resourceId" open="("
separator="," close=")">
#{resourceId}
</foreach>
and ROLE_ID=#{id}
</delete>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment