Commit 494ee193 authored by duanzhihong's avatar duanzhihong

修改角色

parent 38d86c17
...@@ -8,6 +8,7 @@ import com.hungraim.ltc.constant.Gender; ...@@ -8,6 +8,7 @@ import com.hungraim.ltc.constant.Gender;
import com.hungraim.ltc.pojo.entity.system.SystemUser; import com.hungraim.ltc.pojo.entity.system.SystemUser;
import com.hungraim.ltc.pojo.entity.system.SystemUserRole; import com.hungraim.ltc.pojo.entity.system.SystemUserRole;
import com.hungraim.ltc.pojo.vo.system.ReqUserInfo; import com.hungraim.ltc.pojo.vo.system.ReqUserInfo;
import com.hungraim.ltc.system.dao.SystemUserRoleMapper;
import com.hungraim.ltc.system.service.ISystemUserRoleService; import com.hungraim.ltc.system.service.ISystemUserRoleService;
import com.hungraim.ltc.system.service.ISystemUserService; import com.hungraim.ltc.system.service.ISystemUserService;
import com.hungraim.ltc.system.service.impl.SystemUserRoleServiceImpl; import com.hungraim.ltc.system.service.impl.SystemUserRoleServiceImpl;
...@@ -20,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -20,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -37,6 +39,8 @@ public class UserController { ...@@ -37,6 +39,8 @@ public class UserController {
private final ISystemUserService userInfoService; private final ISystemUserService userInfoService;
private final ISystemUserRoleService userRoleService; private final ISystemUserRoleService userRoleService;
@Resource
private SystemUserRoleMapper systemUserRoleMapper;
@Autowired @Autowired
public UserController(SystemUserServiceImpl userInfoService, SystemUserRoleServiceImpl userRoleService) { public UserController(SystemUserServiceImpl userInfoService, SystemUserRoleServiceImpl userRoleService) {
this.userInfoService = userInfoService; this.userInfoService = userInfoService;
...@@ -253,7 +257,8 @@ public class UserController { ...@@ -253,7 +257,8 @@ public class UserController {
List<Long> deleteRoleResources = roleResources.stream() List<Long> deleteRoleResources = roleResources.stream()
.map(SystemUserRole::getRoleId).filter(id -> !reqUserInfo.getRoleIds().contains(id)) .map(SystemUserRole::getRoleId).filter(id -> !reqUserInfo.getRoleIds().contains(id))
.collect(Collectors.toList()); .collect(Collectors.toList());
userRoleService.removeByIds(deleteRoleResources); systemUserRoleMapper.removeByIds(deleteRoleResources,reqUserInfo.getId());
// userRoleService.removeByIds(deleteRoleResources);
return Result.success("更新成功"); return Result.success("更新成功");
} }
/** /**
......
...@@ -3,7 +3,12 @@ package com.hungraim.ltc.system.dao; ...@@ -3,7 +3,12 @@ package com.hungraim.ltc.system.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hungraim.ltc.pojo.entity.system.SystemUserRole; import com.hungraim.ltc.pojo.entity.system.SystemUserRole;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper @Mapper
public interface SystemUserRoleMapper extends BaseMapper<SystemUserRole> { public interface SystemUserRoleMapper extends BaseMapper<SystemUserRole> {
Integer removeByIds(@Param("roleIds") List<Long> roleIds, @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.SystemUserRoleMapper">
<delete id="removeByIds" parameterType="list">
delete from LTC_USER_ROLE where ROLE_ID in
<foreach collection="roleIds" item="roleId" open="("
separator="," close=")">
#{roleId}
</foreach>
and USER_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