20200616-zlp-1
用户多部门管理
This commit is contained in:
@ -274,6 +274,19 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item v-if="isSchool" label="多幼儿园">
|
||||||
|
<el-select v-model="form.deptIds" multiple placeholder="请选择">
|
||||||
|
<el-option
|
||||||
|
v-for="item in kindergartenOptions"
|
||||||
|
:key="item.deptId"
|
||||||
|
:label="item.deptName"
|
||||||
|
:value="item.deptId"
|
||||||
|
:disabled="item.status == 1"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item label="备注">
|
<el-form-item label="备注">
|
||||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input>
|
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input>
|
||||||
@ -374,6 +387,10 @@ export default {
|
|||||||
postOptions: [],
|
postOptions: [],
|
||||||
// 角色选项
|
// 角色选项
|
||||||
roleOptions: [],
|
roleOptions: [],
|
||||||
|
//多幼儿园选项
|
||||||
|
kindergartenOptions: [],
|
||||||
|
//是否幼儿园
|
||||||
|
isSchool:undefined,
|
||||||
// 表单参数
|
// 表单参数
|
||||||
form: {},
|
form: {},
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
@ -539,6 +556,13 @@ export default {
|
|||||||
getUser().then(response => {
|
getUser().then(response => {
|
||||||
this.postOptions = response.posts;
|
this.postOptions = response.posts;
|
||||||
this.roleOptions = response.roles;
|
this.roleOptions = response.roles;
|
||||||
|
//console.log("school="+response.isSchool);
|
||||||
|
if (response.isSchool=="0") {
|
||||||
|
this.isSchool=true;
|
||||||
|
this.kindergartenOptions = response.kindergartens;
|
||||||
|
}else{
|
||||||
|
this.isSchool=false;
|
||||||
|
}
|
||||||
this.open = true;
|
this.open = true;
|
||||||
this.title = "添加用户";
|
this.title = "添加用户";
|
||||||
this.form.password = this.initPassword;
|
this.form.password = this.initPassword;
|
||||||
@ -555,6 +579,14 @@ export default {
|
|||||||
this.roleOptions = response.roles;
|
this.roleOptions = response.roles;
|
||||||
this.form.postIds = response.postIds;
|
this.form.postIds = response.postIds;
|
||||||
this.form.roleIds = response.roleIds;
|
this.form.roleIds = response.roleIds;
|
||||||
|
this.form.deptIds=response.kindergartenIds;
|
||||||
|
//console.log("school="+response.isSchool);
|
||||||
|
if (response.isSchool=="0") {
|
||||||
|
this.isSchool=true;
|
||||||
|
this.kindergartenOptions = response.kindergartens;
|
||||||
|
}else{
|
||||||
|
this.isSchool=false;
|
||||||
|
}
|
||||||
this.open = true;
|
this.open = true;
|
||||||
this.title = "修改用户";
|
this.title = "修改用户";
|
||||||
this.form.password = "";
|
this.form.password = "";
|
||||||
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.ruoyi.project.common.SchoolCommon;
|
import com.ruoyi.project.common.SchoolCommon;
|
||||||
import com.ruoyi.project.system.domain.ByTeacherJbxx;
|
import com.ruoyi.project.system.domain.ByTeacherJbxx;
|
||||||
|
import com.ruoyi.project.system.domain.SysDept;
|
||||||
import com.ruoyi.project.system.service.*;
|
import com.ruoyi.project.system.service.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@ -58,6 +59,9 @@ public class SysUserController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SchoolCommon schoolCommon;
|
private SchoolCommon schoolCommon;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysDeptService deptService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户列表
|
* 获取用户列表
|
||||||
@ -104,14 +108,21 @@ public class SysUserController extends BaseController {
|
|||||||
@GetMapping(value = {"/", "/{userId}"})
|
@GetMapping(value = {"/", "/{userId}"})
|
||||||
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) {
|
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) {
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
|
||||||
|
SysDept dept = new SysDept();
|
||||||
|
dept.setParentId((long) 200);
|
||||||
|
|
||||||
//在添加用户时判断是否为幼儿园平台
|
//在添加用户时判断是否为幼儿园平台
|
||||||
if (schoolCommon.isSchool() == true) {
|
if (schoolCommon.isSchool() == true) {
|
||||||
//只显示幼儿园相关的岗位和角色
|
//只显示幼儿园相关的岗位和角色
|
||||||
ajax.put("roles", roleService.selectYeyRoleAll());
|
ajax.put("roles", roleService.selectYeyRoleAll());
|
||||||
ajax.put("posts", postService.selectYeyPostAll());
|
ajax.put("posts", postService.selectYeyPostAll());
|
||||||
|
ajax.put("isSchool", "1");
|
||||||
} else {
|
} else {
|
||||||
ajax.put("roles", roleService.selectRoleAll());
|
ajax.put("roles", roleService.selectRoleAll());
|
||||||
ajax.put("posts", postService.selectPostAll());
|
ajax.put("posts", postService.selectPostAll());
|
||||||
|
ajax.put("isSchool", "0");
|
||||||
|
ajax.put("kindergartens", deptService.selectDeptList(dept));
|
||||||
}
|
}
|
||||||
|
|
||||||
//在修改用户时判断是否为幼儿园平台
|
//在修改用户时判断是否为幼儿园平台
|
||||||
@ -120,12 +131,14 @@ public class SysUserController extends BaseController {
|
|||||||
ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
|
ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
|
||||||
ajax.put("postIds", postService.selectYeyPostListByUserId(userId));
|
ajax.put("postIds", postService.selectYeyPostListByUserId(userId));
|
||||||
ajax.put("roleIds", roleService.selectYeyRoleListByUserId(userId));
|
ajax.put("roleIds", roleService.selectYeyRoleListByUserId(userId));
|
||||||
|
ajax.put("isSchool", "1");
|
||||||
} else {
|
} else {
|
||||||
|
ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
|
||||||
|
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
||||||
|
ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
|
||||||
|
ajax.put("isSchool", "0");
|
||||||
|
ajax.put("kindergartenIds", deptService.selectDeptListByUserId(userId));
|
||||||
}
|
}
|
||||||
ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
|
|
||||||
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
|
||||||
ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
|
|
||||||
}
|
}
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
@ -137,20 +150,20 @@ public class SysUserController extends BaseController {
|
|||||||
@GetMapping("/listbyroleid")
|
@GetMapping("/listbyroleid")
|
||||||
public AjaxResult getUserList() {
|
public AjaxResult getUserList() {
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
Long deptId=SecurityUtils.getLoginUser().getUser().getDept().getDeptId();
|
Long deptId = SecurityUtils.getLoginUser().getUser().getDept().getDeptId();
|
||||||
SysUser user=new SysUser();
|
SysUser user = new SysUser();
|
||||||
//主班教师
|
//主班教师
|
||||||
user.setUserId((long)102);
|
user.setUserId((long) 102);
|
||||||
user.setDeptId(deptId);
|
user.setDeptId(deptId);
|
||||||
ajax.put("zbjs", userService.selectUserListByRoleId(user));
|
ajax.put("zbjs", userService.selectUserListByRoleId(user));
|
||||||
//配班教师
|
//配班教师
|
||||||
user=new SysUser();
|
user = new SysUser();
|
||||||
user.setUserId((long)104);
|
user.setUserId((long) 104);
|
||||||
user.setDeptId(deptId);
|
user.setDeptId(deptId);
|
||||||
ajax.put("pbjs", userService.selectUserListByRoleId(user));
|
ajax.put("pbjs", userService.selectUserListByRoleId(user));
|
||||||
//助理教师
|
//助理教师
|
||||||
user=new SysUser();
|
user = new SysUser();
|
||||||
user.setUserId((long)105);
|
user.setUserId((long) 105);
|
||||||
user.setDeptId(deptId);
|
user.setDeptId(deptId);
|
||||||
ajax.put("zljs", userService.selectUserListByRoleId(user));
|
ajax.put("zljs", userService.selectUserListByRoleId(user));
|
||||||
|
|
||||||
|
@ -91,6 +91,9 @@ public class SysUser extends BaseEntity
|
|||||||
/** 岗位组 */
|
/** 岗位组 */
|
||||||
private Long[] postIds;
|
private Long[] postIds;
|
||||||
|
|
||||||
|
/** 部门组 */
|
||||||
|
private Long[] deptIds;
|
||||||
|
|
||||||
/**教师对象*/
|
/**教师对象*/
|
||||||
private ByTeacherJbxx byTeacherJbxx;
|
private ByTeacherJbxx byTeacherJbxx;
|
||||||
|
|
||||||
@ -300,6 +303,15 @@ public class SysUser extends BaseEntity
|
|||||||
{
|
{
|
||||||
this.postIds = postIds;
|
this.postIds = postIds;
|
||||||
}
|
}
|
||||||
|
public Long[] getDeptIds()
|
||||||
|
{
|
||||||
|
return deptIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeptIds(Long[] deptIds)
|
||||||
|
{
|
||||||
|
this.deptIds = deptIds;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
package com.ruoyi.project.system.domain;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
|
||||||
|
import com.ruoyi.framework.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多幼儿园账户对象 sys_user_dept
|
||||||
|
*
|
||||||
|
* @author tsbz
|
||||||
|
* @date 2020-06-15
|
||||||
|
*/
|
||||||
|
public class SysUserDept extends BaseEntity {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
@Excel(name = "用户id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门id
|
||||||
|
*/
|
||||||
|
@Excel(name = "部门id")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
public void setUserId(Long userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeptId(Long deptId) {
|
||||||
|
this.deptId = deptId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getDeptId() {
|
||||||
|
return deptId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("userId", getUserId())
|
||||||
|
.append("deptId", getDeptId())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -27,6 +27,14 @@ public interface SysDeptMapper
|
|||||||
*/
|
*/
|
||||||
public List<Integer> selectDeptListByRoleId(Long roleId);
|
public List<Integer> selectDeptListByRoleId(Long roleId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID获取部门选择框列表
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 选中岗位ID列表
|
||||||
|
*/
|
||||||
|
public List<Integer> selectDeptListByUserId(Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据部门ID查询信息
|
* 根据部门ID查询信息
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,77 @@
|
|||||||
|
package com.ruoyi.project.system.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ruoyi.project.system.domain.SysUserDept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多幼儿园账户Mapper接口
|
||||||
|
*
|
||||||
|
* @author tsbz
|
||||||
|
* @date 2020-06-15
|
||||||
|
*/
|
||||||
|
public interface SysUserDeptMapper {
|
||||||
|
/**
|
||||||
|
* 通过用户ID删除用户和岗位关联
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteUserDeptByUserId(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询多幼儿园账户
|
||||||
|
*
|
||||||
|
* @param userId 多幼儿园账户ID
|
||||||
|
* @return 多幼儿园账户
|
||||||
|
*/
|
||||||
|
public SysUserDept selectSysUserDeptById(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询多幼儿园账户列表
|
||||||
|
*
|
||||||
|
* @param sysUserDept 多幼儿园账户
|
||||||
|
* @return 多幼儿园账户集合
|
||||||
|
*/
|
||||||
|
public List<SysUserDept> selectSysUserDeptList(SysUserDept sysUserDept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增多幼儿园账户
|
||||||
|
*
|
||||||
|
* @param sysUserDept 多幼儿园账户
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertSysUserDept(SysUserDept sysUserDept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改多幼儿园账户
|
||||||
|
*
|
||||||
|
* @param sysUserDept 多幼儿园账户
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateSysUserDept(SysUserDept sysUserDept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除多幼儿园账户
|
||||||
|
*
|
||||||
|
* @param userId 多幼儿园账户ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSysUserDeptById(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除多幼儿园账户
|
||||||
|
*
|
||||||
|
* @param userIds 需要删除的数据ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSysUserDeptByIds(Long[] userIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增用户部门信息
|
||||||
|
*
|
||||||
|
* @param userDeptList 用户角色列表
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int batchUserDept(List<SysUserDept> userDeptList);
|
||||||
|
}
|
@ -19,6 +19,14 @@ public interface ISysDeptService
|
|||||||
*/
|
*/
|
||||||
public List<SysDept> selectDeptList(SysDept dept);
|
public List<SysDept> selectDeptList(SysDept dept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID获取岗位选择框列表
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 选中岗位ID列表
|
||||||
|
*/
|
||||||
|
public List<Integer> selectDeptListByUserId(Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建前端所需要树结构
|
* 构建前端所需要树结构
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
package com.ruoyi.project.system.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ruoyi.project.system.domain.SysUserDept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多幼儿园账户Service接口
|
||||||
|
*
|
||||||
|
* @author tsbz
|
||||||
|
* @date 2020-06-15
|
||||||
|
*/
|
||||||
|
public interface ISysUserDeptService {
|
||||||
|
/**
|
||||||
|
* 查询多幼儿园账户
|
||||||
|
*
|
||||||
|
* @param userId 多幼儿园账户ID
|
||||||
|
* @return 多幼儿园账户
|
||||||
|
*/
|
||||||
|
public SysUserDept selectSysUserDeptById(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询多幼儿园账户列表
|
||||||
|
*
|
||||||
|
* @param sysUserDept 多幼儿园账户
|
||||||
|
* @return 多幼儿园账户集合
|
||||||
|
*/
|
||||||
|
public List<SysUserDept> selectSysUserDeptList(SysUserDept sysUserDept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增多幼儿园账户
|
||||||
|
*
|
||||||
|
* @param sysUserDept 多幼儿园账户
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertSysUserDept(SysUserDept sysUserDept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改多幼儿园账户
|
||||||
|
*
|
||||||
|
* @param sysUserDept 多幼儿园账户
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateSysUserDept(SysUserDept sysUserDept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除多幼儿园账户
|
||||||
|
*
|
||||||
|
* @param userIds 需要删除的多幼儿园账户ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSysUserDeptByIds(Long[] userIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除多幼儿园账户信息
|
||||||
|
*
|
||||||
|
* @param userId 多幼儿园账户ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSysUserDeptById(Long userId);
|
||||||
|
}
|
@ -39,6 +39,17 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||||||
return deptMapper.selectDeptList(dept);
|
return deptMapper.selectDeptList(dept);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID获取岗位选择框列表
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 选中岗位ID列表
|
||||||
|
*/
|
||||||
|
public List<Integer> selectDeptListByUserId(Long userId)
|
||||||
|
{
|
||||||
|
return deptMapper.selectDeptListByUserId(userId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建前端所需要树结构
|
* 构建前端所需要树结构
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,87 @@
|
|||||||
|
package com.ruoyi.project.system.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.ruoyi.project.system.mapper.SysUserDeptMapper;
|
||||||
|
import com.ruoyi.project.system.domain.SysUserDept;
|
||||||
|
import com.ruoyi.project.system.service.ISysUserDeptService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多幼儿园账户Service业务层处理
|
||||||
|
*
|
||||||
|
* @author tsbz
|
||||||
|
* @date 2020-06-15
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysUserDeptServiceImpl implements ISysUserDeptService {
|
||||||
|
@Autowired
|
||||||
|
private SysUserDeptMapper sysUserDeptMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询多幼儿园账户
|
||||||
|
*
|
||||||
|
* @param userId 多幼儿园账户ID
|
||||||
|
* @return 多幼儿园账户
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SysUserDept selectSysUserDeptById(Long userId) {
|
||||||
|
return sysUserDeptMapper.selectSysUserDeptById(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询多幼儿园账户列表
|
||||||
|
*
|
||||||
|
* @param sysUserDept 多幼儿园账户
|
||||||
|
* @return 多幼儿园账户
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysUserDept> selectSysUserDeptList(SysUserDept sysUserDept) {
|
||||||
|
return sysUserDeptMapper.selectSysUserDeptList(sysUserDept);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增多幼儿园账户
|
||||||
|
*
|
||||||
|
* @param sysUserDept 多幼儿园账户
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertSysUserDept(SysUserDept sysUserDept) {
|
||||||
|
return sysUserDeptMapper.insertSysUserDept(sysUserDept);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改多幼儿园账户
|
||||||
|
*
|
||||||
|
* @param sysUserDept 多幼儿园账户
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateSysUserDept(SysUserDept sysUserDept) {
|
||||||
|
return sysUserDeptMapper.updateSysUserDept(sysUserDept);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除多幼儿园账户
|
||||||
|
*
|
||||||
|
* @param userIds 需要删除的多幼儿园账户ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteSysUserDeptByIds(Long[] userIds) {
|
||||||
|
return sysUserDeptMapper.deleteSysUserDeptByIds(userIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除多幼儿园账户信息
|
||||||
|
*
|
||||||
|
* @param userId 多幼儿园账户ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteSysUserDeptById(Long userId) {
|
||||||
|
return sysUserDeptMapper.deleteSysUserDeptById(userId);
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,8 @@ package com.ruoyi.project.system.service.impl;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ruoyi.project.system.domain.*;
|
||||||
|
import com.ruoyi.project.system.mapper.*;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -13,16 +15,6 @@ import com.ruoyi.common.exception.CustomException;
|
|||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
|
import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
|
||||||
import com.ruoyi.project.system.domain.SysPost;
|
|
||||||
import com.ruoyi.project.system.domain.SysRole;
|
|
||||||
import com.ruoyi.project.system.domain.SysUser;
|
|
||||||
import com.ruoyi.project.system.domain.SysUserPost;
|
|
||||||
import com.ruoyi.project.system.domain.SysUserRole;
|
|
||||||
import com.ruoyi.project.system.mapper.SysPostMapper;
|
|
||||||
import com.ruoyi.project.system.mapper.SysRoleMapper;
|
|
||||||
import com.ruoyi.project.system.mapper.SysUserMapper;
|
|
||||||
import com.ruoyi.project.system.mapper.SysUserPostMapper;
|
|
||||||
import com.ruoyi.project.system.mapper.SysUserRoleMapper;
|
|
||||||
import com.ruoyi.project.system.service.ISysConfigService;
|
import com.ruoyi.project.system.service.ISysConfigService;
|
||||||
import com.ruoyi.project.system.service.ISysUserService;
|
import com.ruoyi.project.system.service.ISysUserService;
|
||||||
|
|
||||||
@ -50,6 +42,9 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SysUserPostMapper userPostMapper;
|
private SysUserPostMapper userPostMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysUserDeptMapper userDeptMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysConfigService configService;
|
private ISysConfigService configService;
|
||||||
|
|
||||||
@ -209,6 +204,8 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||||||
insertUserPost(user);
|
insertUserPost(user);
|
||||||
// 新增用户与角色管理
|
// 新增用户与角色管理
|
||||||
insertUserRole(user);
|
insertUserRole(user);
|
||||||
|
//新增用户与部门管理
|
||||||
|
insertUserDept(user);
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,6 +227,10 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||||||
userPostMapper.deleteUserPostByUserId(userId);
|
userPostMapper.deleteUserPostByUserId(userId);
|
||||||
// 新增用户与岗位管理
|
// 新增用户与岗位管理
|
||||||
insertUserPost(user);
|
insertUserPost(user);
|
||||||
|
// 删除用户与部门关联
|
||||||
|
userDeptMapper.deleteUserDeptByUserId(userId);
|
||||||
|
// 新增用户与角色管理
|
||||||
|
insertUserDept(user);
|
||||||
return userMapper.updateUser(user);
|
return userMapper.updateUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,6 +334,28 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户部门信息
|
||||||
|
*
|
||||||
|
* @param user 用户对象
|
||||||
|
*/
|
||||||
|
public void insertUserDept(SysUser user) {
|
||||||
|
Long[] depts = user.getDeptIds();
|
||||||
|
if (StringUtils.isNotNull(depts)) {
|
||||||
|
// 新增用户与部门管理
|
||||||
|
List<SysUserDept> list = new ArrayList<SysUserDept>();
|
||||||
|
for (Long deptId : depts) {
|
||||||
|
SysUserDept ud = new SysUserDept();
|
||||||
|
ud.setUserId(user.getUserId());
|
||||||
|
ud.setDeptId(deptId);
|
||||||
|
list.add(ud);
|
||||||
|
}
|
||||||
|
if (list.size() > 0) {
|
||||||
|
userDeptMapper.batchUserDept(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户ID删除用户
|
* 通过用户ID删除用户
|
||||||
*
|
*
|
||||||
|
@ -28,6 +28,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
from sys_dept d
|
from sys_dept d
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectDeptListByUserId" parameterType="Long" resultType="Integer">
|
||||||
|
select p.dept_id
|
||||||
|
from sys_dept p
|
||||||
|
left join sys_user_dept up on up.dept_id = p.dept_id
|
||||||
|
left join sys_user u on u.user_id = up.user_id
|
||||||
|
where u.user_id = #{userId} and p.parent_id = 200
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
|
<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
|
||||||
<include refid="selectDeptVo"/>
|
<include refid="selectDeptVo"/>
|
||||||
where d.del_flag = '0'
|
where d.del_flag = '0'
|
||||||
|
@ -29,6 +29,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="ordersum != null "> and ordersum = #{ordersum}</if>
|
<if test="ordersum != null "> and ordersum = #{ordersum}</if>
|
||||||
<if test="keyword != null and keyword != ''"> and keyword = #{keyword}</if>
|
<if test="keyword != null and keyword != ''"> and keyword = #{keyword}</if>
|
||||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||||
|
|
||||||
|
order by ordersum
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectSysDictMoedataById" parameterType="Long" resultMap="SysDictMoedataResult">
|
<select id="selectSysDictMoedataById" parameterType="Long" resultMap="SysDictMoedataResult">
|
||||||
|
@ -0,0 +1,71 @@
|
|||||||
|
<?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.ruoyi.project.system.mapper.SysUserDeptMapper">
|
||||||
|
|
||||||
|
<resultMap type="SysUserDept" id="SysUserDeptResult">
|
||||||
|
<result property="userId" column="user_id"/>
|
||||||
|
<result property="deptId" column="dept_id"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<delete id="deleteUserDeptByUserId" parameterType="Long">
|
||||||
|
delete from sys_user_dept where user_id=#{userId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<sql id="selectSysUserDeptVo">
|
||||||
|
select user_id, dept_id from sys_user_dept
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectSysUserDeptList" parameterType="SysUserDept" resultMap="SysUserDeptResult">
|
||||||
|
<include refid="selectSysUserDeptVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="userId != null ">and user_id = #{userId}</if>
|
||||||
|
<if test="deptId != null ">and dept_id = #{deptId}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectSysUserDeptById" parameterType="Long" resultMap="SysUserDeptResult">
|
||||||
|
<include refid="selectSysUserDeptVo"/>
|
||||||
|
where user_id = #{userId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertSysUserDept" parameterType="SysUserDept">
|
||||||
|
insert into sys_user_dept
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="userId != null ">user_id,</if>
|
||||||
|
<if test="deptId != null ">dept_id,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="userId != null ">#{userId},</if>
|
||||||
|
<if test="deptId != null ">#{deptId},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateSysUserDept" parameterType="SysUserDept">
|
||||||
|
update sys_user_dept
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="deptId != null ">dept_id = #{deptId},</if>
|
||||||
|
</trim>
|
||||||
|
where user_id = #{userId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteSysUserDeptById" parameterType="Long">
|
||||||
|
delete from sys_user_dept where user_id = #{userId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteSysUserDeptByIds" parameterType="String">
|
||||||
|
delete from sys_user_dept where user_id in
|
||||||
|
<foreach item="userId" collection="array" open="(" separator="," close=")">
|
||||||
|
#{userId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<insert id="batchUserDept">
|
||||||
|
insert into sys_user_dept(user_id, dept_id) values
|
||||||
|
<foreach item="item" index="index" collection="list" separator=",">
|
||||||
|
(#{item.userId},#{item.deptId})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
</mapper>
|
Reference in New Issue
Block a user