|
|
@ -5,6 +5,8 @@ import java.util.List; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
|
|
import com.hxhq.business.domain.SystemLog; |
|
|
|
|
|
import com.hxhq.business.service.ISystemLogService; |
|
|
import com.hxhq.system.domain.SysUserRole; |
|
|
import com.hxhq.system.domain.SysUserRole; |
|
|
import com.hxhq.system.form.RoleUserSaveForm; |
|
|
import com.hxhq.system.form.RoleUserSaveForm; |
|
|
import com.hxhq.system.service.ISysDeptService; |
|
|
import com.hxhq.system.service.ISysDeptService; |
|
|
@ -51,6 +53,9 @@ public class SysRoleController extends BaseController |
|
|
@Autowired |
|
|
@Autowired |
|
|
private ISysDeptService deptService; |
|
|
private ISysDeptService deptService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ISystemLogService systemLogService; |
|
|
|
|
|
|
|
|
@RequiresPermissions("system:role:list") |
|
|
@RequiresPermissions("system:role:list") |
|
|
@GetMapping("/list") |
|
|
@GetMapping("/list") |
|
|
public TableDataInfo list(SysRole role) |
|
|
public TableDataInfo list(SysRole role) |
|
|
@ -239,14 +244,34 @@ public class SysRoleController extends BaseController |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public AjaxResult setAll(@RequestBody RoleUserSaveForm form) |
|
|
public AjaxResult setAll(@RequestBody RoleUserSaveForm form) |
|
|
{ |
|
|
{ |
|
|
|
|
|
SysRole sysRole = roleService.selectRoleById(form.getRoleId()); |
|
|
List<Long> existsUserIds = userService.selectAllocatedListSimple(form.getRoleId()); |
|
|
List<Long> existsUserIds = userService.selectAllocatedListSimple(form.getRoleId()); |
|
|
List<Long> deleteIds = existsUserIds.stream().filter(o->!form.getUserIdList().contains(o)).collect(Collectors.toList()); |
|
|
List<Long> deleteIds = existsUserIds.stream().filter(o->!form.getUserIdList().contains(o)).collect(Collectors.toList()); |
|
|
List<Long> addList = form.getUserIdList().stream().filter(o->!existsUserIds.contains(o)).collect(Collectors.toList()); |
|
|
List<Long> addList = form.getUserIdList().stream().filter(o->!existsUserIds.contains(o)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
List<String> deleteUserNames = new ArrayList<>(); |
|
|
|
|
|
List<String> addUserNames = new ArrayList<>(); |
|
|
if(deleteIds.size()>0){ |
|
|
if(deleteIds.size()>0){ |
|
|
roleService.deleteAuthUsers(form.getRoleId(), deleteIds.toArray(new Long[0])); |
|
|
roleService.deleteAuthUsers(form.getRoleId(), deleteIds.toArray(new Long[0])); |
|
|
|
|
|
deleteUserNames = userService.selectNamesByIdList(deleteIds); |
|
|
} |
|
|
} |
|
|
if(addList.size()>0){ |
|
|
if(addList.size()>0){ |
|
|
roleService.insertAuthUsers(form.getRoleId(), addList.toArray(new Long[0])); |
|
|
roleService.insertAuthUsers(form.getRoleId(), addList.toArray(new Long[0])); |
|
|
|
|
|
addUserNames = userService.selectNamesByIdList(addList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(addUserNames.size()>0 || deleteUserNames.size()>0){ |
|
|
|
|
|
SystemLog log = new SystemLog(); |
|
|
|
|
|
log.setName(sysRole.getRoleName()); |
|
|
|
|
|
log.setJcmc("分配用户"); |
|
|
|
|
|
log.setJcmcEn("Add User"); |
|
|
|
|
|
log.setQmrId(SecurityUtils.getUserId()); |
|
|
|
|
|
log.setQmrMc(SecurityUtils.getNickName()); |
|
|
|
|
|
log.setQmrMcEn(SecurityUtils.getUsername()); |
|
|
|
|
|
|
|
|
|
|
|
log.setJcnr((addUserNames.size()>0?("新增用户:"+String.join(",",addUserNames)):"")+(deleteUserNames.size()>0?(";删除用户:"+String.join(",",deleteUserNames)):"")); |
|
|
|
|
|
log.setJcnrEn((addUserNames.size()>0?("Add User:"+String.join(",",addUserNames)):"")+(deleteUserNames.size()>0?(";Remove User:"+String.join(",",deleteUserNames)):"")); |
|
|
|
|
|
systemLogService.save(log); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return AjaxResult.success("操作成功"); |
|
|
return AjaxResult.success("操作成功"); |
|
|
|