完善接口与核心业务管理功能
This commit is contained in:
parent
0fae3da936
commit
ae158c0ab8
@ -1,20 +1,22 @@
|
||||
package ink.wgink.service.core.controller.api.manage;
|
||||
|
||||
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentDTO;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.service.core.pojo.vos.manage.CoreManageUserVO;
|
||||
import ink.wgink.service.core.service.manage.ICoreManageService;
|
||||
import ink.wgink.service.user.util.UserUtil;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -33,6 +35,47 @@ public class CoreManageController extends DefaultBaseController {
|
||||
@Autowired
|
||||
private ICoreManageService coreManageService;
|
||||
|
||||
@ApiOperation(value = "新增用户", notes = "新增用户接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("save-user")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult saveUser(@RequestBody CoreManageUserVO coreManageUserVO) {
|
||||
UserUtil.checkParams(coreManageUserVO);
|
||||
coreManageService.saveUser(coreManageUserVO);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除用户", notes = "删除用户接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "ids", value = "用户ID列表,用下划线分隔", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@DeleteMapping("remove-user/{ids}")
|
||||
public SuccessResult removeUser(@PathVariable("ids") String ids) {
|
||||
coreManageService.removeUser(Arrays.asList(ids.split("\\_")));
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改用户", notes = "修改用户接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("update-user/{userId}")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult updateUser(@PathVariable("userId") String userId, @RequestBody CoreManageUserVO coreManageUserVO) {
|
||||
UserUtil.checkParams(coreManageUserVO);
|
||||
coreManageService.updateUser(userId, coreManageUserVO);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户详情", notes = "用户详情接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "userId", value = "用户ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("get-user/{userId}")
|
||||
public UserDTO getUser(@PathVariable("userId") String userId) {
|
||||
return coreManageService.getUser(userId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门导航列表", notes = "通过组织部门ID获取与查询有关的所有组织部门列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "组织部门上级ID", paramType = "path")
|
||||
@ -45,7 +88,7 @@ public class CoreManageController extends DefaultBaseController {
|
||||
|
||||
@ApiOperation(value = "组织部门用户列表", notes = "组织部门用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "query"),
|
||||
@ApiImplicitParam(name = "roleId", value = "部门ID", paramType = "query"),
|
||||
@ApiImplicitParam(name = "positionId", value = "部门ID", paramType = "query"),
|
||||
@ApiImplicitParam(name = "groupId", value = "部门ID", paramType = "query"),
|
||||
@ -56,11 +99,11 @@ public class CoreManageController extends DefaultBaseController {
|
||||
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpage-user/department-id/{departmentId}")
|
||||
public SuccessResultList<List<UserDTO>> listPageUserByDepartmentId(@PathVariable("departmentId") String departmentId, ListPage page) {
|
||||
@GetMapping("listpage-user")
|
||||
public SuccessResultList<List<UserDTO>> listPageUser(ListPage page) {
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
page.setParams(requestParams);
|
||||
return coreManageService.listPageUserByDepartmentId(departmentId, page);
|
||||
return coreManageService.listPageUser(page);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,62 @@
|
||||
package ink.wgink.service.core.pojo.vos.manage;
|
||||
|
||||
import ink.wgink.annotation.CheckListAnnotation;
|
||||
import ink.wgink.service.user.pojo.vos.UserVO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: CoreManageUserVO
|
||||
* @Description: 用户VO
|
||||
* @Author: wanggeng
|
||||
* @Date: 2022/8/12 11:37
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@ApiModel
|
||||
public class CoreManageUserVO extends UserVO {
|
||||
|
||||
@ApiModelProperty(name = "departmentIds", value = "部门ID列表")
|
||||
@CheckListAnnotation(name = "部门ID列表")
|
||||
private List<String> departmentIds;
|
||||
@ApiModelProperty(name = "roleIds", value = "角色ID列表")
|
||||
private List<String> roleIds;
|
||||
@ApiModelProperty(name = "positionIds", value = "职位ID列表")
|
||||
private List<String> positionIds;
|
||||
@ApiModelProperty(name = "groupIds", value = "组ID列表")
|
||||
private List<String> groupIds;
|
||||
|
||||
public List<String> getDepartmentIds() {
|
||||
return departmentIds == null ? new ArrayList() : departmentIds;
|
||||
}
|
||||
|
||||
public void setDepartmentIds(List<String> departmentIds) {
|
||||
this.departmentIds = departmentIds;
|
||||
}
|
||||
|
||||
public List<String> getRoleIds() {
|
||||
return roleIds == null ? new ArrayList() : roleIds;
|
||||
}
|
||||
|
||||
public void setRoleIds(List<String> roleIds) {
|
||||
this.roleIds = roleIds;
|
||||
}
|
||||
|
||||
public List<String> getPositionIds() {
|
||||
return positionIds == null ? new ArrayList() : positionIds;
|
||||
}
|
||||
|
||||
public void setPositionIds(List<String> positionIds) {
|
||||
this.positionIds = positionIds;
|
||||
}
|
||||
|
||||
public List<String> getGroupIds() {
|
||||
return groupIds == null ? new ArrayList() : groupIds;
|
||||
}
|
||||
|
||||
public void setGroupIds(List<String> groupIds) {
|
||||
this.groupIds = groupIds;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentDTO;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.service.core.pojo.vos.manage.CoreManageUserVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -17,6 +18,37 @@ import java.util.Map;
|
||||
*/
|
||||
public interface ICoreManageService {
|
||||
|
||||
/**
|
||||
* 保存用户
|
||||
*
|
||||
* @param coreManageUserVO
|
||||
*/
|
||||
void saveUser(CoreManageUserVO coreManageUserVO);
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
* @param userIds
|
||||
*/
|
||||
void removeUser(List<String> userIds);
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*
|
||||
* @param userId
|
||||
* @param coreManageUserVO
|
||||
*/
|
||||
void updateUser(String userId, CoreManageUserVO coreManageUserVO);
|
||||
|
||||
|
||||
/**
|
||||
* 用户详情
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
UserDTO getUser(String userId);
|
||||
|
||||
/**
|
||||
* 组织部门导航列表
|
||||
*
|
||||
@ -33,11 +65,11 @@ public interface ICoreManageService {
|
||||
List<UserDTO> listUser(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 组织部门用户列表
|
||||
* 用户列表
|
||||
*
|
||||
* @param departmentId
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<UserDTO>> listPageUserByDepartmentId(String departmentId, ListPage page);
|
||||
SuccessResultList<List<UserDTO>> listPageUser(ListPage page);
|
||||
|
||||
}
|
||||
|
@ -5,14 +5,25 @@ import com.github.pagehelper.PageInfo;
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.interfaces.user.mongo.IMongoLoginUserService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentDTO;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.pos.DepartmentPO;
|
||||
import ink.wgink.pojo.pos.GroupPO;
|
||||
import ink.wgink.pojo.pos.PositionPO;
|
||||
import ink.wgink.pojo.pos.RolePO;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.service.core.dao.manage.ICoreManageDao;
|
||||
import ink.wgink.service.core.pojo.vos.manage.CoreManageUserVO;
|
||||
import ink.wgink.service.core.service.manage.ICoreManageService;
|
||||
import ink.wgink.service.department.service.IDepartmentService;
|
||||
import ink.wgink.service.department.service.IDepartmentUserService;
|
||||
import ink.wgink.service.group.service.IGroupUserService;
|
||||
import ink.wgink.service.position.service.IPositionUserService;
|
||||
import ink.wgink.service.role.service.IRoleUserService;
|
||||
import ink.wgink.service.user.service.IUserService;
|
||||
import ink.wgink.util.thread.CachedThreadPoolUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -31,11 +42,54 @@ import java.util.Map;
|
||||
*/
|
||||
@Service
|
||||
public class CoreManageServiceImpl extends DefaultBaseService implements ICoreManageService {
|
||||
|
||||
@Autowired
|
||||
private ICoreManageDao coreManageDao;
|
||||
@Autowired
|
||||
private IUserService userService;
|
||||
@Autowired
|
||||
private IDepartmentService departmentService;
|
||||
@Autowired
|
||||
private ICoreManageDao coreManageDao;
|
||||
private IDepartmentUserService departmentUserService;
|
||||
@Autowired
|
||||
private IRoleUserService roleUserService;
|
||||
@Autowired
|
||||
private IPositionUserService positionUserService;
|
||||
@Autowired
|
||||
private IGroupUserService groupUserService;
|
||||
@Autowired(required = false)
|
||||
private IMongoLoginUserService mongoLoginUserService;
|
||||
|
||||
@Override
|
||||
public void saveUser(CoreManageUserVO coreManageUserVO) {
|
||||
String userId = userService.saveAndReturnId(coreManageUserVO, false);
|
||||
setUserServices(userId, coreManageUserVO);
|
||||
updateMongoLoginUser(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUser(List<String> userIds) {
|
||||
userService.remove(userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUser(String userId, CoreManageUserVO coreManageUserVO) {
|
||||
userService.update(userId, coreManageUserVO);
|
||||
setUserServices(userId, coreManageUserVO);
|
||||
updateMongoLoginUser(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDTO getUser(String userId) {
|
||||
UserDTO userDTO = userService.get(userId);
|
||||
if (userDTO == null) {
|
||||
throw new SearchException("用户不存在");
|
||||
}
|
||||
setUserDepartments(userDTO);
|
||||
setUserRoles(userDTO);
|
||||
setUserPositions(userDTO);
|
||||
setUserGroups(userDTO);
|
||||
return userDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentDTO> listDepartmentNavPathByDepartmentId(String departmentId) {
|
||||
@ -55,8 +109,7 @@ public class CoreManageServiceImpl extends DefaultBaseService implements ICoreMa
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<UserDTO>> listPageUserByDepartmentId(String departmentId, ListPage page) {
|
||||
page.getParams().put("departmentId", departmentId);
|
||||
public SuccessResultList<List<UserDTO>> listPageUser(ListPage page) {
|
||||
PageHelper.startPage(page.getPage(), page.getRows());
|
||||
List<UserDTO> userDTOs = listUser(page.getParams());
|
||||
PageInfo<UserDTO> pageInfo = new PageInfo<>(userDTOs);
|
||||
@ -79,4 +132,118 @@ public class CoreManageServiceImpl extends DefaultBaseService implements ICoreMa
|
||||
DepartmentPO departmentParentPO = departmentService.getPO(departmentPO.getDepartmentParentId());
|
||||
setDepartmentNav(navList, departmentParentPO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户业务
|
||||
*
|
||||
* @param userId
|
||||
* @param coreManageUserVO
|
||||
*/
|
||||
private void setUserServices(String userId, CoreManageUserVO coreManageUserVO) {
|
||||
List<String> departmentIds = coreManageUserVO.getDepartmentIds();
|
||||
departmentUserService.saveAfterDeleteByUserId(departmentIds, userId);
|
||||
List<String> roleIds = coreManageUserVO.getRoleIds();
|
||||
roleUserService.saveAfterDeleteByUserId(roleIds, userId);
|
||||
List<String> positionIds = coreManageUserVO.getPositionIds();
|
||||
positionUserService.saveAfterDeleteByUserId(positionIds, userId);
|
||||
List<String> groupIds = coreManageUserVO.getGroupIds();
|
||||
groupUserService.saveAfterDeleteByUserId(groupIds, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户部门
|
||||
*
|
||||
* @param userDTO
|
||||
*/
|
||||
private void setUserDepartments(UserDTO userDTO) {
|
||||
List<DepartmentPO> departmentPOS = departmentUserService.listDepartmentPOByUserId(userDTO.getUserId());
|
||||
String departmentIds = "";
|
||||
String departmentNames = "";
|
||||
for (DepartmentPO departmentPO : departmentPOS) {
|
||||
if (!StringUtils.isBlank(departmentIds)) {
|
||||
departmentIds += ",";
|
||||
departmentNames += ",";
|
||||
}
|
||||
departmentIds += departmentPO.getDepartmentId();
|
||||
departmentNames += departmentPO.getDepartmentName();
|
||||
}
|
||||
userDTO.setDepartmentIds(departmentIds);
|
||||
userDTO.setDepartmentNames(departmentNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户角色
|
||||
*
|
||||
* @param userDTO
|
||||
*/
|
||||
private void setUserRoles(UserDTO userDTO) {
|
||||
List<RolePO> rolePOS = roleUserService.listRolePOByUserId(userDTO.getUserId());
|
||||
String roleIds = "";
|
||||
String roleNames = "";
|
||||
for (RolePO rolePO : rolePOS) {
|
||||
if (!StringUtils.isBlank(roleIds)) {
|
||||
roleIds += ",";
|
||||
roleNames += ",";
|
||||
}
|
||||
roleIds += rolePO.getRoleId();
|
||||
roleNames += rolePO.getRoleName();
|
||||
}
|
||||
userDTO.setRoleIds(roleIds);
|
||||
userDTO.setRoleNames(roleNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户职位
|
||||
*
|
||||
* @param userDTO
|
||||
*/
|
||||
private void setUserPositions(UserDTO userDTO) {
|
||||
List<PositionPO> positionPOS = positionUserService.listPositionPOByUserId(userDTO.getUserId());
|
||||
String positionIds = "";
|
||||
String positionNames = "";
|
||||
for (PositionPO positionPO : positionPOS) {
|
||||
if (!StringUtils.isBlank(positionIds)) {
|
||||
positionIds += ",";
|
||||
positionNames += ",";
|
||||
}
|
||||
positionIds += positionPO.getPositionId();
|
||||
positionNames += positionPO.getPositionName();
|
||||
}
|
||||
userDTO.setPositionIds(positionIds);
|
||||
userDTO.setPositionNames(positionNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户组
|
||||
*
|
||||
* @param userDTO
|
||||
*/
|
||||
private void setUserGroups(UserDTO userDTO) {
|
||||
List<GroupPO> groupPOS = groupUserService.listGroupPOByUserId(userDTO.getUserId());
|
||||
String groupIds = "";
|
||||
String groupNames = "";
|
||||
for (GroupPO groupPO : groupPOS) {
|
||||
if (!StringUtils.isBlank(groupIds)) {
|
||||
groupIds += ",";
|
||||
groupNames += ",";
|
||||
}
|
||||
groupIds += groupPO.getGroupId();
|
||||
groupNames += groupPO.getGroupName();
|
||||
}
|
||||
userDTO.setGroupIds(groupIds);
|
||||
userDTO.setGroupNames(groupNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新mongo登录用户
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
private void updateMongoLoginUser(String userId) {
|
||||
if (mongoLoginUserService != null) {
|
||||
CachedThreadPoolUtil.execute(() -> {
|
||||
mongoLoginUserService.updateByUserId(userId);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,197 @@
|
||||
/**
|
||||
* 关闭窗口
|
||||
*/
|
||||
function closeBox() {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化下拉树
|
||||
* @param $
|
||||
* @param layuiInputTree
|
||||
*/
|
||||
function initMultiSelectInputTree($, layuiInputTree) {
|
||||
/**
|
||||
* 设置选择数据
|
||||
* @param ids
|
||||
* @param names
|
||||
*/
|
||||
function setSelectedData(selectedDatas, ids, names) {
|
||||
if (!ids) {
|
||||
return;
|
||||
}
|
||||
ids = ids.split(',');
|
||||
names = names.split(',');
|
||||
$.each(ids, function (index, item) {
|
||||
selectedDatas.push({
|
||||
id: item,
|
||||
name: names[index]
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 组织部门选择
|
||||
function initDepartmentSelect() {
|
||||
layuiInputTree.initMultiSelect({
|
||||
id: 'departmentNames',
|
||||
url: 'api/department/listztree',
|
||||
checkboxType: {Y: '', N: ''},
|
||||
getSelectedDatas: function () {
|
||||
var selectedDepartments = []
|
||||
setSelectedData(selectedDepartments, $('#departmentIds').val(), $('#departmentNames').val());
|
||||
return selectedDepartments;
|
||||
},
|
||||
onConfirm: function (zTree, selectedNodes) {
|
||||
if (selectedNodes.length == 0) {
|
||||
$('#departmentIds').val('');
|
||||
return;
|
||||
}
|
||||
var departmentIds = '';
|
||||
$.each(selectedNodes, function (index, item) {
|
||||
if (departmentIds != '') {
|
||||
departmentIds += ',';
|
||||
}
|
||||
departmentIds += item.id;
|
||||
})
|
||||
$('#departmentIds').val(departmentIds);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 角色选择
|
||||
function initRoleSelect() {
|
||||
layuiInputTree.initMultiSelect({
|
||||
id: 'roleNames',
|
||||
url: 'api/role/listztree',
|
||||
checkboxType: {Y: '', N: ''},
|
||||
getSelectedDatas: function () {
|
||||
var selectedRoles = [];
|
||||
setSelectedData(selectedRoles, $('#roleIds').val(), $('#roleNames').val());
|
||||
return selectedRoles;
|
||||
},
|
||||
onConfirm: function (zTree, selectedNodes) {
|
||||
if (selectedNodes.length == 0) {
|
||||
$('#roleIds').val('');
|
||||
return;
|
||||
}
|
||||
var roleIds = '';
|
||||
$.each(selectedNodes, function (index, item) {
|
||||
if (roleIds != '') {
|
||||
roleIds += ',';
|
||||
}
|
||||
roleIds += item.id;
|
||||
})
|
||||
$('#roleIds').val(roleIds);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 职位选择
|
||||
function initPositionSelect() {
|
||||
layuiInputTree.initMultiSelect({
|
||||
id: 'positionNames',
|
||||
url: 'api/position/listztree',
|
||||
checkboxType: {Y: '', N: ''},
|
||||
getSelectedDatas: function () {
|
||||
var selectedPositions = [];
|
||||
setSelectedData(selectedPositions, $('#positionIds').val(), $('#positionNames').val());
|
||||
return selectedPositions;
|
||||
},
|
||||
onConfirm: function (zTree, selectedNodes) {
|
||||
if (selectedNodes.length == 0) {
|
||||
$('#positionIds').val('');
|
||||
return;
|
||||
}
|
||||
var positionIds = '';
|
||||
$.each(selectedNodes, function (index, item) {
|
||||
if (positionIds != '') {
|
||||
positionIds += ',';
|
||||
}
|
||||
positionIds += item.id;
|
||||
})
|
||||
$('#positionIds').val(positionIds);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 组选择
|
||||
function initGroupSelect() {
|
||||
layuiInputTree.initMultiSelect({
|
||||
id: 'groupNames',
|
||||
url: 'api/group/listztree',
|
||||
checkboxType: {Y: '', N: ''},
|
||||
getSelectedDatas: function () {
|
||||
var selectedGroups = [];
|
||||
setSelectedData(selectedGroups, $('#groupIds').val(), $('#groupNames').val());
|
||||
return selectedGroups;
|
||||
},
|
||||
onConfirm: function (zTree, selectedNodes) {
|
||||
if (selectedNodes.length == 0) {
|
||||
$('#groupIds').val('');
|
||||
return;
|
||||
}
|
||||
var groupIds = '';
|
||||
$.each(selectedNodes, function (index, item) {
|
||||
if (groupIds != '') {
|
||||
groupIds += ',';
|
||||
}
|
||||
groupIds += item.id;
|
||||
})
|
||||
$('#groupIds').val(groupIds);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
initDepartmentSelect();
|
||||
initRoleSelect();
|
||||
initPositionSelect();
|
||||
initGroupSelect();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param laydate
|
||||
*/
|
||||
function initDate(laydate) {
|
||||
laydate.render({
|
||||
elem: '#userExpiredDate',
|
||||
trigger: 'click',
|
||||
format: 'yyyy-MM-dd HH:mm:ss'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置ID列表
|
||||
* @param $
|
||||
* @param formDataField
|
||||
*/
|
||||
function setIds($, formDataField) {
|
||||
var departmentIds = $('#departmentIds').val();
|
||||
if (departmentIds) {
|
||||
departmentIds = departmentIds.split(',');
|
||||
} else {
|
||||
departmentIds = [];
|
||||
}
|
||||
var roleIds = $('#roleIds').val();
|
||||
if (roleIds) {
|
||||
roleIds = roleIds.split(',');
|
||||
} else {
|
||||
roleIds = [];
|
||||
}
|
||||
var positionIds = $('#positionIds').val();
|
||||
if (positionIds) {
|
||||
positionIds = positionIds.split(',');
|
||||
} else {
|
||||
positionIds = [];
|
||||
}
|
||||
var groupIds = $('#groupIds').val();
|
||||
if (groupIds) {
|
||||
groupIds = groupIds.split(',');
|
||||
} else {
|
||||
groupIds = [];
|
||||
}
|
||||
formDataField.departmentIds = departmentIds;
|
||||
formDataField.roleIds = roleIds;
|
||||
formDataField.positionIds = positionIds;
|
||||
formDataField.groupIds = groupIds;
|
||||
}
|
@ -52,15 +52,16 @@
|
||||
<input type="hidden" id="groupId">
|
||||
<input type="text" id="groupName" class="layui-input search-item search-item-width-100" placeholder="选择用户组">
|
||||
</div>
|
||||
<div class="layui-inline layui-form search-item">
|
||||
<select id="searchLevel" name="searchLevel">
|
||||
<option value="this">本级</option>
|
||||
<option value="global">全局</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-btn-group">
|
||||
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||
<i class="fa fa-lg fa-search"></i> 本级搜索
|
||||
<i class="fa fa-lg fa-search"></i> 搜索
|
||||
</button>
|
||||
<!--
|
||||
<button type="button" id="globalSearch" class="layui-btn layui-btn-sm layui-btn-normal">
|
||||
<i class="fa fa-lg fa-search"></i> 全局搜索
|
||||
</button>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||
@ -102,7 +103,8 @@
|
||||
var layuiInputTree = new LayuiInputTree(layui);
|
||||
var queryParams = top.restAjax.params(window.location.href);
|
||||
var departmentId = queryParams.departmentId;
|
||||
var tableUrl = 'api/core/manage/listpage-user/department-id/{departmentId}';
|
||||
var tableUserUrl = 'api/core/manage/listpage-user';
|
||||
var tableUrl = tableUserUrl + '?departmentId={departmentId}';
|
||||
|
||||
// 初始化表格
|
||||
function initTable() {
|
||||
@ -257,7 +259,7 @@
|
||||
}
|
||||
// 重载表格
|
||||
function reloadTable(currentPage) {
|
||||
table.reload('dataTable', {
|
||||
var reloadTableObj = {
|
||||
where: {
|
||||
keywords: $('#keywords').val(),
|
||||
startTime: $('#startTime').val(),
|
||||
@ -271,7 +273,14 @@
|
||||
page: {
|
||||
curr: currentPage
|
||||
},
|
||||
});
|
||||
};
|
||||
var searchLevel = $('#searchLevel').val();
|
||||
if(searchLevel === 'global') {
|
||||
reloadTableObj.url = top.restAjax.path(tableUserUrl, []);
|
||||
} else {
|
||||
reloadTableObj.url = top.restAjax.path(tableUrl, [departmentId]);
|
||||
}
|
||||
table.reload('dataTable', reloadTableObj);
|
||||
}
|
||||
// 初始化日期
|
||||
function initDate() {
|
||||
@ -305,7 +314,10 @@
|
||||
// 角色下拉树选择
|
||||
layuiInputTree.initSelect({
|
||||
id: 'roleName',
|
||||
zTreeUrl: 'api/role/listztree',
|
||||
url: 'api/role/listztree',
|
||||
getSelectedData: function() {
|
||||
return {id: $('#roleId').val(), name: $('#roleName').val()}
|
||||
},
|
||||
onConfirm: function(zTree, selectedNode) {
|
||||
if(!selectedNode) {
|
||||
$('#roleId').val('');
|
||||
@ -317,7 +329,10 @@
|
||||
// 职位下拉树选择
|
||||
layuiInputTree.initSelect({
|
||||
id: 'positionName',
|
||||
zTreeUrl: 'api/position/listztree',
|
||||
url: 'api/position/listztree',
|
||||
getSelectedData: function() {
|
||||
return {id: $('#positionId').val(), name: $('#positionName').val()}
|
||||
},
|
||||
onConfirm: function(zTree, selectedNode) {
|
||||
if(!selectedNode) {
|
||||
$('#positionId').val('');
|
||||
@ -329,7 +344,10 @@
|
||||
// 用户组下拉树选择
|
||||
layuiInputTree.initSelect({
|
||||
id: 'groupName',
|
||||
zTreeUrl: 'api/group/listztree',
|
||||
url: 'api/group/listztree',
|
||||
getSelectedData: function() {
|
||||
return {id: $('#groupId').val(), name: $('#groupName').val()}
|
||||
},
|
||||
onConfirm: function(zTree, selectedNode) {
|
||||
if(!selectedNode) {
|
||||
$('#groupId').val('');
|
||||
@ -348,7 +366,7 @@
|
||||
yes: function (index) {
|
||||
top.dialog.close(index);
|
||||
var layIndex;
|
||||
top.restAjax.delete(top.restAjax.path('api/user/remove/{ids}', [ids]), {}, null, function (code, data) {
|
||||
top.restAjax.delete(top.restAjax.path('api/core/manage/remove-user/{ids}', [ids]), {}, null, function (code, data) {
|
||||
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
|
||||
reloadTable();
|
||||
}, function (code, data) {
|
||||
@ -407,7 +425,7 @@
|
||||
area: ['100%', '100%'],
|
||||
shadeClose: true,
|
||||
anim: 2,
|
||||
content: top.restAjax.path('route/user/update?userId={id}', [checkDatas[0].userId]),
|
||||
content: top.restAjax.path('route/core/manage/update-department-user?userId={id}', [checkDatas[0].userId]),
|
||||
end: function() {
|
||||
reloadTable();
|
||||
}
|
||||
|
@ -27,22 +27,20 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">用户名 *</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="userUsername" lay-verify="userUsername"
|
||||
placeholder="请输入用户名" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">密码 *</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="password" name="userPassword" lay-verify="required"
|
||||
placeholder="请输入密码" class="layui-input">
|
||||
<input type="text" name="userUsername" lay-verify="userUsername" placeholder="请输入用户名" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">昵称 *</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="userName" lay-verify="required" placeholder="请输入昵称"
|
||||
class="layui-input">
|
||||
<input type="text" name="userName" lay-verify="required" placeholder="请输入昵称" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">状态 *</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="userState" value="0" title="正常" checked>
|
||||
<input type="radio" name="userState" value="1" title="锁定">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" pane>
|
||||
@ -59,11 +57,10 @@
|
||||
<div>普通用户:具有APP登录权限且参与APP业务的用户</div>
|
||||
<div>公共用户:来自小程序、公众号等公共平台自动创建且参与此类业务的的用户</div>
|
||||
</blockquote>
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">状态 *</label>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="userState" value="0" title="正常" checked>
|
||||
<input type="radio" name="userState" value="1" title="锁定">
|
||||
<input type="password" name="userPassword" placeholder="请输入密码" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
@ -96,29 +93,29 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">组织部门 *</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="departmentIds">
|
||||
<input type="text" id="departmentNames" class="layui-input" placeholder="勾选组织部门">
|
||||
<input type="hidden" id="departmentIds" name="departmentIds">
|
||||
<input type="text" id="departmentNames" name="departmentNames" class="layui-input" placeholder="勾选组织部门" lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">角色</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="roleIds">
|
||||
<input type="text" id="roleNames" class="layui-input" placeholder="勾选角色">
|
||||
<input type="hidden" id="roleIds" name="roleIds">
|
||||
<input type="text" id="roleNames" name="roleNames" class="layui-input" placeholder="勾选角色">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">职位</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="positionIds">
|
||||
<input type="text" id="positionNames" class="layui-input" placeholder="勾选职位">
|
||||
<input type="hidden" id="positionIds" name="positionIds">
|
||||
<input type="text" id="positionNames" name="positionNames" class="layui-input" placeholder="勾选职位">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">组</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="groupIds">
|
||||
<input type="text" id="groupNames" class="layui-input" placeholder="勾选组">
|
||||
<input type="hidden" id="groupIds" name="groupIds">
|
||||
<input type="text" id="groupNames" name="groupNames" class="layui-input" placeholder="勾选组">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -142,6 +139,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/js/common/layui-input-tree.js"></script>
|
||||
<script src="assets/js/core/manage/department-user.js"></script>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
@ -154,141 +152,16 @@
|
||||
var form = layui.form;
|
||||
var layuiInputTree = new LayuiInputTree(layui);
|
||||
|
||||
function closeBox() {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化下拉树
|
||||
*/
|
||||
function initMultiSelectInputTree() {
|
||||
// 组织部门选择
|
||||
function initDepartmentSelect() {
|
||||
var selectedDepartments = [];
|
||||
layuiInputTree.initMultiSelect({
|
||||
id: 'departmentNames',
|
||||
zTreeUrl: 'api/department/listztree',
|
||||
checkboxType: {Y: '', N: ''},
|
||||
selectedDatas: selectedDepartments,
|
||||
onConfirm: function (zTree, selectedNodes) {
|
||||
selectedDepartments = selectedNodes;
|
||||
if (selectedNodes.length == 0) {
|
||||
$('#departmentIds').val('');
|
||||
return;
|
||||
}
|
||||
var departmentIds = '';
|
||||
$.each(selectedDepartments, function (index, item) {
|
||||
if (departmentIds != '') {
|
||||
departmentIds += ',';
|
||||
}
|
||||
departmentIds += item.id;
|
||||
})
|
||||
$('#departmentIds').val(departmentIds);
|
||||
}
|
||||
})
|
||||
}
|
||||
// 角色选择
|
||||
function initRoleSelect() {
|
||||
var selectedRoles = [];
|
||||
layuiInputTree.initMultiSelect({
|
||||
id: 'roleNames',
|
||||
zTreeUrl: 'api/role/listztree',
|
||||
checkboxType: {Y: '', N: ''},
|
||||
selectedDatas: selectedRoles,
|
||||
onConfirm: function (zTree, selectedNodes) {
|
||||
selectedRoles = selectedNodes;
|
||||
if (selectedNodes.length == 0) {
|
||||
$('#roleIds').val('');
|
||||
return;
|
||||
}
|
||||
var roleIds = '';
|
||||
$.each(selectedRoles, function (index, item) {
|
||||
if (roleIds != '') {
|
||||
roleIds += ',';
|
||||
}
|
||||
roleIds += item.id;
|
||||
})
|
||||
$('#roleIds').val(roleIds);
|
||||
}
|
||||
})
|
||||
}
|
||||
// 职位选择
|
||||
function initPositionSelect() {
|
||||
var selectedPositions = [];
|
||||
layuiInputTree.initMultiSelect({
|
||||
id: 'positionNames',
|
||||
zTreeUrl: 'api/position/listztree',
|
||||
checkboxType: {Y: '', N: ''},
|
||||
selectedDatas: selectedPositions,
|
||||
onConfirm: function (zTree, selectedNodes) {
|
||||
selectedPositions = selectedNodes;
|
||||
if (selectedNodes.length == 0) {
|
||||
$('#positionIds').val('');
|
||||
return;
|
||||
}
|
||||
var positionIds = '';
|
||||
$.each(selectedPositions, function (index, item) {
|
||||
if (positionIds != '') {
|
||||
positionIds += ',';
|
||||
}
|
||||
positionIds += item.id;
|
||||
})
|
||||
$('#positionIds').val(positionIds);
|
||||
}
|
||||
})
|
||||
}
|
||||
// 组选择
|
||||
function initGroupSelect() {
|
||||
var selectedGroups = [];
|
||||
layuiInputTree.initMultiSelect({
|
||||
id: 'groupNames',
|
||||
zTreeUrl: 'api/group/listztree',
|
||||
checkboxType: {Y: '', N: ''},
|
||||
selectedDatas: selectedGroups,
|
||||
onConfirm: function (zTree, selectedNodes) {
|
||||
selectedGroups = selectedNodes;
|
||||
if (selectedNodes.length == 0) {
|
||||
$('#groupIds').val('');
|
||||
return;
|
||||
}
|
||||
var groupIds = '';
|
||||
$.each(selectedGroups, function (index, item) {
|
||||
if (groupIds != '') {
|
||||
groupIds += ',';
|
||||
}
|
||||
groupIds += item.id;
|
||||
})
|
||||
$('#groupIds').val(groupIds);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
initDepartmentSelect();
|
||||
initRoleSelect();
|
||||
initPositionSelect();
|
||||
initGroupSelect();
|
||||
}
|
||||
|
||||
initMultiSelectInputTree();
|
||||
|
||||
function initDate() {
|
||||
laydate.render({
|
||||
elem: '#userExpiredDate',
|
||||
trigger: 'click',
|
||||
format: 'yyyy-MM-dd HH:mm:ss'
|
||||
});
|
||||
}
|
||||
|
||||
initDate();
|
||||
initMultiSelectInputTree($, layuiInputTree);
|
||||
initDate(laydate);
|
||||
|
||||
// 提交表单
|
||||
form.on('submit(submitForm)', function (formData) {
|
||||
var authorizedGrantTypes = top.restAjax.checkBoxToString(formData.field, 'authorizedGrantTypes');
|
||||
formData.field.authorizedGrantTypes = authorizedGrantTypes;
|
||||
top.dialog.confirm(top.dataMessage.commit, function (index) {
|
||||
top.dialog.close(index);
|
||||
var loadLayerIndex;
|
||||
top.restAjax.post(top.restAjax.path('api/user/save', []), formData.field, null, function (code, data) {
|
||||
setIds($, formData.field);
|
||||
top.restAjax.post(top.restAjax.path('api/core/manage/save-user', []), formData.field, null, function (code, data) {
|
||||
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
|
@ -11,7 +11,7 @@
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||
<div class="layui-anim layui-anim-fadein">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
|
||||
@ -29,18 +29,19 @@
|
||||
<input type="text" name="userUsername" lay-verify="userUsername" placeholder="请输入用户名" class="layui-input" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">新密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="password" name="userPassword" placeholder="修改密码,请输入新密码,不修改为空" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">昵称 *</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="userName" lay-verify="required" placeholder="请输入昵称" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">状态 *</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="userState" value="0" title="正常">
|
||||
<input type="radio" name="userState" value="1" title="锁定">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">类型 *</label>
|
||||
<div class="layui-input-block">
|
||||
@ -55,11 +56,10 @@
|
||||
<div>普通用户:具有APP登录权限且参与APP业务的用户</div>
|
||||
<div>公共用户:来自小程序、公众号等公共平台自动创建且参与此类业务的的用户</div>
|
||||
</blockquote>
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">状态 *</label>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">新密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="userState" value="0" title="正常">
|
||||
<input type="radio" name="userState" value="1" title="锁定">
|
||||
<input type="password" name="userPassword" placeholder="修改密码,请输入新密码,不修改为空" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
@ -87,6 +87,36 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md6 layui-col-sm8 layui-col-xs12">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">组织部门 *</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="departmentIds" name="departmentIds">
|
||||
<input type="text" id="departmentNames" name="departmentNames" class="layui-input" placeholder="勾选组织部门" lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">角色</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="roleIds" name="roleIds">
|
||||
<input type="text" id="roleNames" name="roleNames" class="layui-input" placeholder="勾选角色">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">职位</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="positionIds" name="positionIds">
|
||||
<input type="text" id="positionNames" name="positionNames" class="layui-input" placeholder="勾选职位">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">组</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="groupIds" name="groupIds">
|
||||
<input type="text" id="groupNames" name="groupNames" class="layui-input" placeholder="勾选组">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md2 layui-col-sm4 layui-col-xs12">
|
||||
<div class="layui-form-item" style="text-align: center;">
|
||||
<img id="avatarImage" src="assets/images/profile-photo.jpg" title="点击修改头像">
|
||||
@ -106,36 +136,28 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/js/common/layui-input-tree.js"></script>
|
||||
<script src="assets/js/core/manage/department-user.js"></script>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||
}).extend({
|
||||
index: 'lib/index' //主入口模块
|
||||
}).use(['index', 'form', 'laydate'], function(){
|
||||
}).use(['index', 'form', 'laydate', 'ztree'], function(){
|
||||
var $ = layui.$;
|
||||
var laydate = layui.laydate;
|
||||
var form = layui.form;
|
||||
var layuiInputTree = new LayuiInputTree(layui);
|
||||
var userId = top.restAjax.params(window.location.href).userId;
|
||||
|
||||
function closeBox() {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
|
||||
function initDate() {
|
||||
laydate.render({
|
||||
elem: '#userExpiredDate',
|
||||
trigger: 'click',
|
||||
format: 'yyyy-MM-dd HH:mm:ss'
|
||||
});
|
||||
}
|
||||
initDate();
|
||||
initMultiSelectInputTree($, layuiInputTree);
|
||||
initDate(laydate);
|
||||
|
||||
// 初始化
|
||||
function initData() {
|
||||
var self = this;
|
||||
var loadLayerIndex;
|
||||
top.restAjax.get(top.restAjax.path('api/user/get/{userId}', [userId]), {}, null, function(code, data) {
|
||||
top.restAjax.get(top.restAjax.path('api/core/manage/get-user/{userId}', [userId]), {}, null, function(code, data) {
|
||||
form.val('dataForm', {
|
||||
userAvatar: data.userAvatar,
|
||||
userUsername: data.userUsername,
|
||||
@ -144,7 +166,15 @@
|
||||
userState: data.userState +'',
|
||||
userPhone: data.userPhone,
|
||||
userEmail: data.userEmail.toString(),
|
||||
userExpiredDate: data.userExpiredDate
|
||||
userExpiredDate: data.userExpiredDate,
|
||||
departmentIds: data.departmentIds,
|
||||
departmentNames: data.departmentNames,
|
||||
roleIds: data.roleIds,
|
||||
roleNames: data.roleNames,
|
||||
positionIds: data.positionIds,
|
||||
positionNames: data.positionNames,
|
||||
groupIds: data.groupIds,
|
||||
groupNames: data.groupNames
|
||||
});
|
||||
form.render(null, 'dataForm');
|
||||
if($('#userAvatar').val() != '') {
|
||||
@ -163,12 +193,11 @@
|
||||
initData();
|
||||
// 提交表单
|
||||
form.on('submit(submitForm)', function(formData) {
|
||||
var authorizedGrantTypes = top.restAjax.checkBoxToString(formData.field, 'authorizedGrantTypes');
|
||||
formData.field.authorizedGrantTypes = authorizedGrantTypes;
|
||||
top.dialog.confirm(top.dataMessage.commit, function(index) {
|
||||
top.dialog.close(index);
|
||||
var loadLayerIndex;
|
||||
top.restAjax.put(top.restAjax.path('api/user/update/{userId}', [userId]), formData.field, null, function(code, data) {
|
||||
setIds($, formData.field);
|
||||
top.restAjax.put(top.restAjax.path('api/core/manage/update-user/{userId}', [userId]), formData.field, null, function(code, data) {
|
||||
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
|
@ -5,8 +5,10 @@ import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.exceptions.UpdateException;
|
||||
import ink.wgink.interfaces.init.IInitBaseTable;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentDTO;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.pos.DepartmentPO;
|
||||
import ink.wgink.service.user.pojo.pos.UserPO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@ -120,4 +122,22 @@ public interface IDepartmentUserDao extends IInitBaseTable {
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<DepartmentUserDTO> listDepartmentUser(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 部门列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<DepartmentDTO> listDepartment(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 部门列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<DepartmentPO> listDepartmentPO(Map<String, Object> params) throws SearchException;
|
||||
}
|
||||
|
@ -34,6 +34,14 @@ public interface IDepartmentUserService extends IDepartmentUserBaseService {
|
||||
*/
|
||||
String USER_DEPARTMENT_TYPE_LEAVE = "leave";
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param departmentIds
|
||||
* @param userId
|
||||
*/
|
||||
void saveAfterDeleteByUserId(List<String> departmentIds, String userId);
|
||||
|
||||
/**
|
||||
* 新增用户ID
|
||||
*
|
||||
@ -51,7 +59,6 @@ public interface IDepartmentUserService extends IDepartmentUserBaseService {
|
||||
*/
|
||||
void save(String departmentId, List<String> userIds);
|
||||
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
@ -68,6 +75,21 @@ public interface IDepartmentUserService extends IDepartmentUserBaseService {
|
||||
*/
|
||||
void delete(String departmentId);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
void deleteByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param userIds
|
||||
*/
|
||||
void deleteByUserIds(List<String> userIds);
|
||||
|
||||
|
||||
/**
|
||||
* 更新用户
|
||||
*
|
||||
|
@ -61,6 +61,20 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe
|
||||
@Autowired(required = false)
|
||||
private IMongoLoginUserService mongoLoginUserService;
|
||||
|
||||
@Override
|
||||
public void saveAfterDeleteByUserId(List<String> departmentIds, String userId) {
|
||||
deleteByUserId(userId);
|
||||
if (departmentIds == null || departmentIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("userId", userId);
|
||||
for (String departmentId : departmentIds) {
|
||||
params.put("departmentId", departmentId);
|
||||
departmentUserDao.save(params);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(String departmentId, String departmentName, List<String> departmentUserIds) {
|
||||
List<String> existUserIds = listUserId(departmentId, departmentUserIds);
|
||||
@ -132,6 +146,26 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe
|
||||
delete(departmentId, null, userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByUserId(String userId) {
|
||||
if (StringUtils.isBlank(userId)) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userId", userId);
|
||||
departmentUserDao.delete(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByUserIds(List<String> userIds) {
|
||||
if (userIds == null || userIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userIds", userIds);
|
||||
departmentUserDao.delete(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String departmentId, List<String> saveUserIds, List<String> deleteUserIds) {
|
||||
DepartmentPO departmentPO = departmentService.getPO(departmentId);
|
||||
@ -169,11 +203,7 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe
|
||||
public List<DepartmentPO> listDepartmentPOByUserId(String userId) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userId", userId);
|
||||
List<String> departmentIds = departmentUserDao.listDepartmentId(params);
|
||||
if (departmentIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return departmentService.listPO(departmentIds);
|
||||
return departmentUserDao.listDepartmentPO(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -451,11 +481,7 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe
|
||||
public List<DepartmentDTO> listDepartmentByUserId(String userId) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userId", userId);
|
||||
List<String> departmentIds = departmentUserDao.listDepartmentId(params);
|
||||
if (departmentIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return departmentService.listByIds(departmentIds);
|
||||
return departmentUserDao.listDepartment(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -436,4 +436,97 @@
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<!-- 部门列表 -->
|
||||
<select id="listDepartment" parameterType="map" resultMap="ink.wgink.service.department.dao.IDepartmentDao.departmentDTO">
|
||||
SELECT
|
||||
t1.department_id,
|
||||
t1.department_parent_id,
|
||||
t1.department_name,
|
||||
t1.department_name_en,
|
||||
t1.department_name_other,
|
||||
t1.department_no,
|
||||
t1.department_summary,
|
||||
t1.department_code,
|
||||
t1.department_logo,
|
||||
t1.department_logo_hover,
|
||||
t1.department_type,
|
||||
t1.department_state,
|
||||
t1.department_fax,
|
||||
t1.department_tel,
|
||||
t1.department_address,
|
||||
t1.department_master,
|
||||
t1.department_duty,
|
||||
t1.department_area_code,
|
||||
t1.department_area_name,
|
||||
t1.department_longitude,
|
||||
t1.department_latitude,
|
||||
t1.department_order
|
||||
FROM
|
||||
sys_department t1
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
AND
|
||||
t1.department_id IN (
|
||||
SELECT
|
||||
st1.department_id
|
||||
FROM
|
||||
sys_department_user st1
|
||||
<where>
|
||||
<if test="userId != null and userId != ''">
|
||||
st1.user_id = #{userId}
|
||||
</if>
|
||||
</where>
|
||||
)
|
||||
</select>
|
||||
|
||||
<!-- 部门列表 -->
|
||||
<select id="listDepartmentPO" parameterType="map" resultMap="ink.wgink.service.department.dao.IDepartmentDao.departmentPO">
|
||||
SELECT
|
||||
t1.department_id,
|
||||
t1.department_parent_id,
|
||||
t1.department_name,
|
||||
t1.department_name_en,
|
||||
t1.department_name_other,
|
||||
t1.department_no,
|
||||
t1.department_summary,
|
||||
t1.department_code,
|
||||
t1.department_logo,
|
||||
t1.department_logo_hover,
|
||||
t1.department_type,
|
||||
t1.department_state,
|
||||
t1.department_fax,
|
||||
t1.department_tel,
|
||||
t1.department_address,
|
||||
t1.department_master,
|
||||
t1.department_duty,
|
||||
t1.department_area_code,
|
||||
t1.department_area_name,
|
||||
t1.department_longitude,
|
||||
t1.department_latitude,
|
||||
t1.department_order
|
||||
FROM
|
||||
sys_department t1
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
AND
|
||||
t1.department_id IN (
|
||||
SELECT
|
||||
st1.department_id
|
||||
FROM
|
||||
sys_department_user st1
|
||||
<where>
|
||||
<if test="userId != null and userId != ''">
|
||||
st1.user_id = #{userId}
|
||||
</if>
|
||||
<if test="userIds != null and userIds.size > 0">
|
||||
AND
|
||||
st1.user_id IN
|
||||
<foreach collection="userIds" index="index" open="(" separator="," close=")">
|
||||
#{userIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
)
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -5,6 +5,7 @@ import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.interfaces.init.IInitBaseTable;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.pos.GroupPO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@ -74,4 +75,13 @@ public interface IGroupUserDao extends IInitBaseTable {
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<UserDTO> listUser(Map<String, Object> requestParams) throws SearchException;
|
||||
|
||||
/**
|
||||
* 组列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<GroupPO> listGroupPO(Map<String, Object> params) throws SearchException;
|
||||
}
|
||||
|
@ -20,6 +20,14 @@ import java.util.Map;
|
||||
*/
|
||||
public interface IGroupUserService extends IGroupUserBaseService {
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param groupIds
|
||||
* @param userId
|
||||
*/
|
||||
void saveAfterDeleteByUserId(List<String> groupIds, String userId);
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
@ -59,6 +67,21 @@ public interface IGroupUserService extends IGroupUserBaseService {
|
||||
*/
|
||||
void delete(String groupId, List<String> userIds);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
void deleteByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param userIds
|
||||
*/
|
||||
void deleteByUserIds(List<String> userIds);
|
||||
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
*
|
||||
@ -74,4 +97,5 @@ public interface IGroupUserService extends IGroupUserBaseService {
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<UserDTO>> listPageUser(ListPage page);
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.pos.GroupPO;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.service.group.dao.IGroupUserDao;
|
||||
import ink.wgink.service.group.service.IGroupService;
|
||||
import ink.wgink.service.group.service.IGroupUserService;
|
||||
import ink.wgink.util.thread.CachedThreadPoolUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -44,12 +43,23 @@ public class GroupUserServiceImpl extends DefaultBaseService implements IGroupUs
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IUserBaseService userBaseService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IGroupService groupService;
|
||||
@Autowired(required = false)
|
||||
private IMongoLoginUserService mongoLoginUserService;
|
||||
|
||||
@Override
|
||||
public void saveAfterDeleteByUserId(List<String> groupIds, String userId) {
|
||||
deleteByUserId(userId);
|
||||
if (groupIds == null || groupIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("userId", userId);
|
||||
for (String groupId : groupIds) {
|
||||
params.put("groupId", groupId);
|
||||
groupUserDao.save(params);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(String groupId, List<String> saveUserIds) {
|
||||
// 判断是否已经添加
|
||||
@ -116,6 +126,26 @@ public class GroupUserServiceImpl extends DefaultBaseService implements IGroupUs
|
||||
updateMongoLoginUser(userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByUserId(String userId) {
|
||||
if (StringUtils.isBlank(userId)) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userId", userId);
|
||||
groupUserDao.delete(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByUserIds(List<String> userIds) {
|
||||
if (userIds == null || userIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userIds", userIds);
|
||||
groupUserDao.delete(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> listUser(Map<String, Object> requestParams) {
|
||||
requestParams = requestParams == null ? getHashMap(0) : requestParams;
|
||||
@ -165,11 +195,7 @@ public class GroupUserServiceImpl extends DefaultBaseService implements IGroupUs
|
||||
public List<GroupPO> listGroupPOByUserId(String userId) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userId", userId);
|
||||
List<String> groupIds = groupUserDao.listGroupId(params);
|
||||
if (groupIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return groupService.listPO(groupIds);
|
||||
return groupUserDao.listGroupPO(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -190,5 +190,38 @@
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 职位列表 -->
|
||||
<select id="listGroupPO" parameterType="map" resultMap="ink.wgink.service.group.dao.IGroupDao.groupPO">
|
||||
SELECT
|
||||
t1.group_id,
|
||||
t1.group_parent_id,
|
||||
t1.group_name,
|
||||
t1.group_summary,
|
||||
t1.group_code
|
||||
FROM
|
||||
sys_group t1
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
AND
|
||||
t1.group_id IN (
|
||||
SELECT
|
||||
st1.group_id
|
||||
FROM
|
||||
sys_group_user st1
|
||||
<where>
|
||||
<if test="userId != null and userId != ''">
|
||||
st1.user_id = #{userId}
|
||||
</if>
|
||||
<if test="userIds != null and userIds.size > 0">
|
||||
AND
|
||||
st1.user_id IN
|
||||
<foreach collection="userIds" index="index" open="(" separator="," close=")">
|
||||
#{userIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
)
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -5,6 +5,7 @@ import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.interfaces.init.IInitBaseTable;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.pos.PositionPO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@ -74,4 +75,13 @@ public interface IPositionUserDao extends IInitBaseTable {
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<UserDTO> listUser(Map<String, Object> requestParams) throws SearchException;
|
||||
|
||||
/**
|
||||
* 职位列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<PositionPO> listPositionPO(Map<String, Object> params) throws SearchException;
|
||||
}
|
||||
|
@ -20,6 +20,14 @@ import java.util.Map;
|
||||
**/
|
||||
public interface IPositionUserService extends IPositionUserBaseService {
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param positionIds
|
||||
* @param userId
|
||||
*/
|
||||
void saveAfterDeleteByUserId(List<String> positionIds, String userId);
|
||||
|
||||
/**
|
||||
* 保存职位人员
|
||||
*
|
||||
@ -59,6 +67,19 @@ public interface IPositionUserService extends IPositionUserBaseService {
|
||||
*/
|
||||
void delete(String positionId, List<String> userIds);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
void deleteByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param userIds
|
||||
*/
|
||||
void deleteByUserIds(List<String> userIds);
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
*
|
||||
@ -74,4 +95,5 @@ public interface IPositionUserService extends IPositionUserBaseService {
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<UserDTO>> listPageUser(ListPage page);
|
||||
|
||||
}
|
||||
|
@ -50,6 +50,20 @@ public class PositionUserServiceImpl extends DefaultBaseService implements IPosi
|
||||
@Autowired(required = false)
|
||||
private IMongoLoginUserService mongoLoginUserService;
|
||||
|
||||
@Override
|
||||
public void saveAfterDeleteByUserId(List<String> positionIds, String userId) {
|
||||
deleteByUserId(userId);
|
||||
if (positionIds == null || positionIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("userId", userId);
|
||||
for (String positionId : positionIds) {
|
||||
params.put("positionId", positionId);
|
||||
positionUserDao.save(params);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(String positionId, List<String> saveUserIds) {
|
||||
// 判断是否已经添加
|
||||
@ -116,6 +130,26 @@ public class PositionUserServiceImpl extends DefaultBaseService implements IPosi
|
||||
updateMongoLoginUser(userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByUserId(String userId) {
|
||||
if (StringUtils.isBlank(userId)) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userId", userId);
|
||||
positionUserDao.delete(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByUserIds(List<String> userIds) {
|
||||
if (userIds == null || userIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userIds", userIds);
|
||||
positionUserDao.delete(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> listUser(Map<String, Object> requestParams) {
|
||||
requestParams = requestParams == null ? getHashMap(0) : requestParams;
|
||||
@ -195,11 +229,7 @@ public class PositionUserServiceImpl extends DefaultBaseService implements IPosi
|
||||
public List<PositionPO> listPositionPOByUserId(String userId) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userId", userId);
|
||||
List<String> positionIds = positionUserDao.listPositionId(params);
|
||||
if (positionIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return positionService.listPO(positionIds);
|
||||
return positionUserDao.listPositionPO(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,8 +2,6 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="ink.wgink.service.position.dao.IPositionDao">
|
||||
|
||||
|
||||
|
||||
<resultMap id="positionPO" type="ink.wgink.pojo.pos.PositionPO">
|
||||
<id property="positionId" column="position_id"/>
|
||||
<result property="positionParentId" column="position_parent_id"/>
|
||||
|
@ -200,4 +200,38 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 职位列表 -->
|
||||
<select id="listPositionPO" parameterType="map" resultMap="ink.wgink.service.position.dao.IPositionDao.positionPO">
|
||||
SELECT
|
||||
t1.position_id,
|
||||
t1.position_parent_id,
|
||||
t1.position_name,
|
||||
t1.position_name_en,
|
||||
t1.position_summary,
|
||||
t1.position_code
|
||||
FROM
|
||||
sys_position t1
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
AND
|
||||
t1.position_id IN (
|
||||
SELECT
|
||||
st1.position_id
|
||||
FROM
|
||||
sys_position_user st1
|
||||
<where>
|
||||
<if test="userId != null and userId != ''">
|
||||
st1.user_id = #{userId}
|
||||
</if>
|
||||
<if test="userIds != null and userIds.size > 0">
|
||||
AND
|
||||
st1.user_id IN
|
||||
<foreach collection="userIds" index="index" open="(" separator="," close=")">
|
||||
#{userIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
)
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -6,6 +6,7 @@ import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.interfaces.init.IInitBaseTable;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.pos.RolePO;
|
||||
import ink.wgink.service.user.pojo.pos.UserPO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@ -94,4 +95,13 @@ public interface IRoleUserDao extends IInitBaseTable {
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<UserPO> listUserPO(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<RolePO> listRolePO(Map<String, Object> params) throws SearchException;
|
||||
}
|
||||
|
@ -22,6 +22,14 @@ import java.util.Map;
|
||||
**/
|
||||
public interface IRoleUserService extends IRoleUserBaseService {
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param roleIds
|
||||
* @param userId
|
||||
*/
|
||||
void saveAfterDeleteByUserId(List<String> roleIds, String userId);
|
||||
|
||||
/**
|
||||
* 保存角色与用户
|
||||
*
|
||||
@ -41,20 +49,22 @@ public interface IRoleUserService extends IRoleUserBaseService {
|
||||
/**
|
||||
* 更新用户组人员列表
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param saveUserIds 新增ID列表
|
||||
* @param deleteIds 删除ID列表
|
||||
* @param roleId 角色ID
|
||||
* @param saveUserIds 新增ID列表
|
||||
* @param deleteIds 删除ID列表
|
||||
*/
|
||||
void update(String roleId, List<String> saveUserIds, List<String> deleteIds);
|
||||
|
||||
/**
|
||||
* 删除角色用户
|
||||
*
|
||||
* @param roleId
|
||||
*/
|
||||
void delete(String roleId);
|
||||
|
||||
/**
|
||||
* 删除角色用户
|
||||
*
|
||||
* @param roleIds
|
||||
*/
|
||||
void delete(List<String> roleIds);
|
||||
@ -67,6 +77,21 @@ public interface IRoleUserService extends IRoleUserBaseService {
|
||||
*/
|
||||
void delete(String roleId, List<String> userIds);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
void deleteByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param userIds
|
||||
*/
|
||||
void deleteByUserIds(List<String> userIds);
|
||||
|
||||
|
||||
/**
|
||||
* 部门用户列表
|
||||
*
|
||||
@ -114,4 +139,5 @@ public interface IRoleUserService extends IRoleUserBaseService {
|
||||
* @return
|
||||
*/
|
||||
List<UserPO> listUserPOByRoleIds(List<String> roleIds);
|
||||
|
||||
}
|
||||
|
@ -55,6 +55,20 @@ public class RoleUserServiceImpl extends DefaultBaseService implements IRoleUser
|
||||
@Autowired(required = false)
|
||||
private IMongoLoginUserService mongoLoginUserService;
|
||||
|
||||
@Override
|
||||
public void saveAfterDeleteByUserId(List<String> roleIds, String userId) {
|
||||
deleteByUserId(userId);
|
||||
if (roleIds == null || roleIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("userId", userId);
|
||||
for (String roleId : roleIds) {
|
||||
params.put("roleId", roleId);
|
||||
roleUserDao.save(params);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(String roleId, List<String> saveUserIds) {
|
||||
// 判断是否已经添加
|
||||
@ -134,6 +148,26 @@ public class RoleUserServiceImpl extends DefaultBaseService implements IRoleUser
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByUserId(String userId) {
|
||||
if (StringUtils.isBlank(userId)) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userId", userId);
|
||||
roleUserDao.delete(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByUserIds(List<String> userIds) {
|
||||
if (userIds == null || userIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userIds", userIds);
|
||||
roleUserDao.delete(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentUserDTO> listDepartmentUser(Map<String, Object> params) {
|
||||
params = params == null ? getHashMap(2) : params;
|
||||
@ -189,11 +223,7 @@ public class RoleUserServiceImpl extends DefaultBaseService implements IRoleUser
|
||||
public List<RolePO> listRolePOByUserId(String userId) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userId", userId);
|
||||
List<String> roleIds = roleUserDao.listRoleId(params);
|
||||
if (roleIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return roleService.listPO(roleIds);
|
||||
return roleUserDao.listRolePO(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,8 +2,6 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="ink.wgink.service.role.dao.IRoleDao">
|
||||
|
||||
|
||||
|
||||
<resultMap id="rolePO" type="ink.wgink.pojo.pos.RolePO">
|
||||
<id property="roleId" column="role_id"/>
|
||||
<result property="roleParentId" column="role_parent_id"/>
|
||||
|
@ -313,7 +313,7 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 部门用户列表 -->
|
||||
<!-- 角色用户列表 -->
|
||||
<select id="listRoleUser" parameterType="map" resultMap="roleUserDTO">
|
||||
SELECT
|
||||
t1.user_id,
|
||||
@ -323,8 +323,7 @@
|
||||
t1.user_email,
|
||||
t1.user_type,
|
||||
t1.user_state,
|
||||
jt1.role_id,
|
||||
jt1.user_sort
|
||||
jt1.role_id
|
||||
FROM
|
||||
sys_user t1
|
||||
LEFT JOIN
|
||||
@ -480,4 +479,38 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 角色列表 -->
|
||||
<select id="listRolePO" parameterType="map" resultMap="ink.wgink.service.role.dao.IRoleDao.rolePO">
|
||||
SELECT
|
||||
t1.role_id,
|
||||
t1.role_parent_id,
|
||||
t1.role_name,
|
||||
t1.role_summary,
|
||||
t1.role_code,
|
||||
t1.role_data_right
|
||||
FROM
|
||||
sys_role t1
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
AND
|
||||
t1.role_id IN (
|
||||
SELECT
|
||||
st1.role_id
|
||||
FROM
|
||||
sys_role_user st1
|
||||
<where>
|
||||
<if test="userId != null and userId != ''">
|
||||
st1.user_id = #{userId}
|
||||
</if>
|
||||
<if test="userIds != null and userIds.size > 0">
|
||||
AND
|
||||
st1.user_id IN
|
||||
<foreach collection="userIds" index="index" open="(" separator="," close=")">
|
||||
#{userIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
)
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -17,6 +17,7 @@ import ink.wgink.service.user.pojo.vos.UpdateExpiredDateVO;
|
||||
import ink.wgink.service.user.pojo.vos.UpdateUsernameVO;
|
||||
import ink.wgink.service.user.pojo.vos.UserVO;
|
||||
import ink.wgink.service.user.service.IUserService;
|
||||
import ink.wgink.service.user.util.UserUtil;
|
||||
import ink.wgink.util.ReflectUtil;
|
||||
import ink.wgink.util.RegexUtil;
|
||||
import io.swagger.annotations.*;
|
||||
@ -55,7 +56,7 @@ public class UserController extends DefaultBaseController {
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("save")
|
||||
public SuccessResult save(@RequestBody UserVO userVO) {
|
||||
checkParams(userVO);
|
||||
UserUtil.checkParams(userVO);
|
||||
userService.save(userVO);
|
||||
return new SuccessResult();
|
||||
}
|
||||
@ -89,29 +90,11 @@ public class UserController extends DefaultBaseController {
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("update/{userId}")
|
||||
public SuccessResult update(@PathVariable("userId") String userId, @RequestBody UserVO userVO) {
|
||||
checkParams(userVO);
|
||||
UserUtil.checkParams(userVO);
|
||||
userService.update(userId, userVO);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数校验
|
||||
*
|
||||
* @param userVO
|
||||
* @throws ParamsException
|
||||
*/
|
||||
private void checkParams(UserVO userVO) throws ParamsException {
|
||||
if (!StringUtils.isBlank(userVO.getUserPhone()) && !RegexUtil.isPhone(userVO.getUserPhone())) {
|
||||
throw new ParamsException("手机号码格式错误");
|
||||
}
|
||||
if (!StringUtils.isBlank(userVO.getUserEmail()) && !RegexUtil.isEmail(userVO.getUserEmail())) {
|
||||
throw new ParamsException("用户邮箱格式错误");
|
||||
}
|
||||
if (!StringUtils.isBlank(userVO.getUserExpiredDate()) && !RegexUtil.isDatetime(userVO.getUserExpiredDate())) {
|
||||
throw new ParamsException("过期时间格式错误");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户重置密码", notes = "用户重置密码接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("reset-password/{userId}")
|
||||
|
@ -146,13 +146,16 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
||||
|
||||
@Override
|
||||
public void remove(List<String> ids) {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userIds", ids);
|
||||
setUpdateInfo(params);
|
||||
userDao.remove(params);
|
||||
// 删除关联用户
|
||||
deleteRelationUser(ids);
|
||||
updateMongoLoginUser(ids);
|
||||
deleteMongoLoginUser(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -162,7 +165,7 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
||||
userDao.delete(params);
|
||||
// 删除关联用户
|
||||
deleteRelationUser(ids);
|
||||
updateMongoLoginUser(ids);
|
||||
deleteMongoLoginUser(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -833,6 +836,20 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除mongo
|
||||
*
|
||||
* @param userIds
|
||||
*/
|
||||
private void deleteMongoLoginUser(List<String> userIds) {
|
||||
if (mongoLoginUserService != null) {
|
||||
CachedThreadPoolUtil.execute(() -> {
|
||||
LOG.debug("delete mongo login user");
|
||||
mongoLoginUserService.delete(userIds);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Excel导入错误对象
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ink.wgink.service.user.util;
|
||||
|
||||
import ink.wgink.exceptions.ParamsException;
|
||||
import ink.wgink.exceptions.base.SystemException;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.interfaces.manager.ISystemConfigManager;
|
||||
@ -7,7 +8,9 @@ import ink.wgink.interfaces.user.IUserExpandBaseService;
|
||||
import ink.wgink.interfaces.user.IUserExpandOptionButton;
|
||||
import ink.wgink.pojo.bos.LoginUser;
|
||||
import ink.wgink.service.user.pojo.pos.UserPO;
|
||||
import ink.wgink.service.user.pojo.vos.UserVO;
|
||||
import ink.wgink.util.ReflectUtil;
|
||||
import ink.wgink.util.RegexUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
@ -25,6 +28,24 @@ import java.util.Map;
|
||||
*/
|
||||
public class UserUtil {
|
||||
|
||||
/**
|
||||
* 参数校验
|
||||
*
|
||||
* @param userVO
|
||||
* @throws ParamsException
|
||||
*/
|
||||
public static void checkParams(UserVO userVO) throws ParamsException {
|
||||
if (!StringUtils.isBlank(userVO.getUserPhone()) && !RegexUtil.isPhone(userVO.getUserPhone())) {
|
||||
throw new ParamsException("手机号码格式错误");
|
||||
}
|
||||
if (!StringUtils.isBlank(userVO.getUserEmail()) && !RegexUtil.isEmail(userVO.getUserEmail())) {
|
||||
throw new ParamsException("用户邮箱格式错误");
|
||||
}
|
||||
if (!StringUtils.isBlank(userVO.getUserExpiredDate()) && !RegexUtil.isDatetime(userVO.getUserExpiredDate())) {
|
||||
throw new ParamsException("过期时间格式错误");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户列表页面拓转属性
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user