新增案件
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 当前在线会话
|
||||
*
|
||||
@@ -10,8 +12,6 @@ public class SysUserOnline
|
||||
/** 会话编号 */
|
||||
private String tokenId;
|
||||
|
||||
/** 部门名称 */
|
||||
private String deptName;
|
||||
|
||||
/** 用户名称 */
|
||||
private String userName;
|
||||
@@ -41,15 +41,7 @@ public class SysUserOnline
|
||||
this.tokenId = tokenId;
|
||||
}
|
||||
|
||||
public String getDeptName()
|
||||
{
|
||||
return deptName;
|
||||
}
|
||||
|
||||
public void setDeptName(String deptName)
|
||||
{
|
||||
this.deptName = deptName;
|
||||
}
|
||||
|
||||
public String getUserName()
|
||||
{
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门管理 数据层
|
||||
@@ -124,4 +125,12 @@ public interface SysDeptMapper
|
||||
* @return
|
||||
*/
|
||||
int batchSave(@Param("list")List<SysDept> sysDepts);
|
||||
|
||||
/**
|
||||
* 根据用户id查询部门信息
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
|
||||
List<SysDept> selectDeptByUserId(Long userId);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public interface SysUserDeptMapper
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public List<SysUserDept> selectUserById(Long userId);
|
||||
public List<SysUserDept> selectUserDeptById(Long userId);
|
||||
|
||||
/**
|
||||
* 新增
|
||||
@@ -41,7 +41,7 @@ public interface SysUserDeptMapper
|
||||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserById(@Param("userId)") Long userId);
|
||||
public int deleteUserById(Long userId);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
@@ -50,5 +50,4 @@ public interface SysUserDeptMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserByIds(@Param("ids") Long[] userIds);
|
||||
|
||||
}
|
||||
|
||||
@@ -87,10 +87,6 @@ public class SysUserOnlineServiceImpl implements ISysUserOnlineService
|
||||
sysUserOnline.setBrowser(user.getBrowser());
|
||||
sysUserOnline.setOs(user.getOs());
|
||||
sysUserOnline.setLoginTime(user.getLoginTime());
|
||||
if (StringUtils.isNotNull(user.getUser().getDept()))
|
||||
{
|
||||
sysUserOnline.setDeptName(user.getUser().getDept().getDeptName());
|
||||
}
|
||||
return sysUserOnline;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.entity.SysUserDept;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
@@ -26,7 +27,6 @@ import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.validation.Validator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -53,6 +53,8 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||
|
||||
@Autowired
|
||||
private SysUserRoleMapper userRoleMapper;
|
||||
@Autowired
|
||||
private SysUserDeptMapper userDeptMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserPostMapper userPostMapper;
|
||||
@@ -238,28 +240,21 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||
@Override
|
||||
@Transactional
|
||||
public AjaxResult insertUser(SysUser user) {
|
||||
Long deptId = user.getDeptId();
|
||||
Long[] postIds = user.getPostIds();
|
||||
if (deptId != null) {
|
||||
SysDept dept = sysDeptMapper.selectDeptById(deptId);
|
||||
Integer deptType = dept.getDeptType();
|
||||
if (deptType!=null && deptType.intValue() == 1) {
|
||||
SysPost sysPost = postMapper.selectPostByPostCode("jbr");
|
||||
Long postId = sysPost.getPostId();
|
||||
if (postIds.length > 0) {
|
||||
boolean isContain = Arrays.asList(postIds).contains(postId);
|
||||
if (isContain) {
|
||||
List<SysUser> sysUsers = userMapper.selectUserByDeptId(deptId);
|
||||
if (sysUsers != null && sysUsers.size() > 0) {
|
||||
return AjaxResult.error("部门类型为仲裁机构的部门的岗位为经办人的用户只能有一个!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 新增用户信息
|
||||
int rows = userMapper.insertUser(user);
|
||||
// 新增用户部门关联
|
||||
if(CollectionUtil.isNotEmpty(user.getDeptIds())) {
|
||||
// 先删除用户与部门关联
|
||||
userDeptMapper.deleteUserById(user.getUserId());
|
||||
List<SysUserDept> userDepts = new ArrayList<>();
|
||||
for (Long userDeptId : user.getDeptIds()) {
|
||||
SysUserDept userDept = new SysUserDept();
|
||||
userDept.setUserId(user.getUserId());
|
||||
userDept.setDeptId(userDeptId);
|
||||
userDepts.add(userDept);
|
||||
}
|
||||
userDeptMapper.batchSave(userDepts);
|
||||
}
|
||||
// 新增用户岗位关联
|
||||
insertUserPost(user);
|
||||
// 新增用户与角色管理
|
||||
@@ -287,29 +282,20 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||
@Override
|
||||
@Transactional
|
||||
public AjaxResult updateUser(SysUser user) {
|
||||
Long deptId = user.getDeptId();
|
||||
Long[] postIds = user.getPostIds();
|
||||
if (deptId != null) {
|
||||
SysDept dept = sysDeptMapper.selectDeptById(deptId);
|
||||
Integer deptType = dept.getDeptType();
|
||||
if (deptType != null && deptType.intValue() == 1) {
|
||||
SysPost sysPost = postMapper.selectPostByPostCode("jbr");
|
||||
if(sysPost!=null) {
|
||||
Long postId = sysPost.getPostId();
|
||||
if (postId!=null&&postIds.length > 0) {
|
||||
boolean isContain = Arrays.asList(postIds).contains(postId);
|
||||
if (isContain) {
|
||||
List<SysUser> sysUsers = userMapper.selectUserByDeptId(deptId);
|
||||
if (sysUsers != null && sysUsers.size() > 0) {
|
||||
return AjaxResult.error("部门类型为仲裁机构的部门的岗位为经办人的用户只能有一个!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Long userId = user.getUserId();
|
||||
// 新增用户部门关联
|
||||
if(CollectionUtil.isNotEmpty(user.getDeptIds())) {
|
||||
// 先删除用户与部门关联
|
||||
userDeptMapper.deleteUserById(user.getUserId());
|
||||
List<SysUserDept> userDepts = new ArrayList<>();
|
||||
for (Long userDeptId : user.getDeptIds()) {
|
||||
SysUserDept userDept = new SysUserDept();
|
||||
userDept.setUserId(user.getUserId());
|
||||
userDept.setDeptId(userDeptId);
|
||||
userDepts.add(userDept);
|
||||
}
|
||||
userDeptMapper.batchSave(userDepts);
|
||||
}
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
// 新增用户与角色管理
|
||||
@@ -474,6 +460,8 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||
userRoleMapper.deleteUserRole(userIds);
|
||||
// 删除用户与岗位关联
|
||||
userPostMapper.deleteUserPost(userIds);
|
||||
// 删除用户部门关联
|
||||
userDeptMapper.deleteUserByIds(userIds);
|
||||
return userMapper.deleteUserByIds(userIds);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user