完善基础代码(职位管理)

This commit is contained in:
WenG 2021-02-16 18:21:24 +08:00
parent 887c8e3875
commit dfc1fd0025
53 changed files with 1621 additions and 591 deletions

View File

@ -1,5 +1,15 @@
package ink.wgink.interfaces.department;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.bos.DepartmentBO;
import ink.wgink.pojo.dtos.ZTreeDTO;
import ink.wgink.pojo.dtos.department.DepartmentDTO;
import ink.wgink.pojo.dtos.department.DepartmentSimpleDTO;
import ink.wgink.pojo.result.SuccessResultList;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
@ -11,4 +21,138 @@ package ink.wgink.interfaces.department;
* @Version: 1.0
**/
public interface IDepartmentBaseService {
/**
* 部门列表
*
* @param params
* @return
*/
List<DepartmentDTO> list(Map<String, Object> params);
/**
* 通过ID获取组织部门详情
*
* @param departmentId
* @return
*/
DepartmentDTO get(String departmentId);
/**
* easyui组织部门
*
* @param page
* @return
*/
SuccessResultList<List<DepartmentDTO>> listPage(ListPage page);
/**
* easyui组织部门列表
*
* @param departmentParentId
* @param page
* @return
*/
SuccessResultList<List<DepartmentDTO>> listPageByParentId(String departmentParentId, ListPage page);
/**
* 组织部门列表递归获取全部内容
*
* @param params
* @return
*/
List<DepartmentDTO> listAll(Map<String, Object> params);
/**
* zTree组织部门
*
* @param params
* @return
*/
List<ZTreeDTO> listZTree(Map<String, Object> params);
/**
* zTree组织部门
*
* @param departmentParentId
* @param params
* @return
*/
List<ZTreeDTO> listZTree(String departmentParentId, Map<String, Object> params);
/**
* 部门ID列表
*
* @param params
* @return
*/
List<String> listId(Map<String, Object> params);
/**
* 获取基础部门ID列表
*
* @param departmentBOs
* @return
*/
List<String> listId(List<DepartmentBO> departmentBOs);
/**
* 获取上级部门
*
* @param departmentBO1
* @param departmentBO2
* @return
*/
DepartmentBO getHigherLevel(DepartmentBO departmentBO1, DepartmentBO departmentBO2);
/**
* 获得同一级部门数量按部门名称
*
* @param params
* @return
*/
Integer count(Map<String, Object> params);
/**
* 通过ID获取组织部门详情简单格式
*
* @param departmentId
* @return
*/
DepartmentSimpleDTO getSimple(String departmentId);
/**
* 部门列表
*
* @param params
* @return
*/
List<DepartmentSimpleDTO> listSimple(Map<String, Object> params);
/**
* 通过上级ID获取组织部门全部列表简单格式
*
* @param departmentParentId
* @return
*/
List<DepartmentSimpleDTO> listSimpleByParentId(String departmentParentId);
/**
* 通过上级ID和添加获取组织部门全部增量列表简单格式
*
* @param departmentParentId
* @param addDate
* @return
*/
List<DepartmentSimpleDTO> listSimpleByParentIdAndAddDate(String departmentParentId, String addDate);
/**
* 通过上级ID和更新获取组织部门全部新增和修改的列表简单格式
*
* @param departmentParentId
* @param updateDate
* @return
*/
List<DepartmentSimpleDTO> listSimpleByParentIdAndUpdateDate(String departmentParentId, String updateDate);
}

View File

@ -1,5 +1,13 @@
package ink.wgink.interfaces.group;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.ZTreeDTO;
import ink.wgink.pojo.dtos.group.GroupDTO;
import ink.wgink.pojo.result.SuccessResultList;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
@ -11,4 +19,68 @@ package ink.wgink.interfaces.group;
* @Version: 1.0
**/
public interface IGroupBaseService {
/**
* 全部组JSON列表
*
* @param groupParentId
* @return
*/
List<GroupDTO> listAllByParentId(String groupParentId);
/**
* 组列表递归获取全部内容
*
* @param params
* @return
*/
List<GroupDTO> listAll(Map<String, Object> params);
/**
* 组详情
*
* @param params
* @return
*/
GroupDTO get(Map<String, Object> params);
/**
* 组详情
*
* @param groupId
* @return
*/
GroupDTO get(String groupId);
/**
* 组zTree列表
*
* @param params
* @return
*/
List<ZTreeDTO> listZTree(Map<String, Object> params);
/**
* 组EasyUI列表
*
* @param page
* @return
*/
SuccessResultList<List<GroupDTO>> listPage(ListPage page);
/**
* 组列表
*
* @param params
* @return
*/
List<GroupDTO> list(Map<String, Object> params);
/**
* 用户组列表
*
* @param groupIds 用户ID列表
* @return
*/
List<GroupDTO> list(List<String> groupIds);
}

View File

@ -1,14 +1,14 @@
package ink.wgink.interfaces.user;
package ink.wgink.interfaces.group;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: IPositionUser
* @Description: 职位用户
* @ClassName: IGroupCheckService
* @Description: 用户组检查
* @Author: WangGeng
* @Date: 2021/1/24 12:59
* @Date: 2021/2/16 18:06
* @Version: 1.0
**/
public interface IPositionUserService {
public interface IGroupCheckService {
}

View File

@ -1,5 +1,13 @@
package ink.wgink.interfaces.position;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.ZTreeDTO;
import ink.wgink.pojo.dtos.position.PositionDTO;
import ink.wgink.pojo.result.SuccessResultList;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
@ -11,4 +19,69 @@ package ink.wgink.interfaces.position;
* @Version: 1.0
**/
public interface IPositionBaseService {
/**
* 全部职位JSON列表
*
* @param groupParentId
* @return
*/
List<PositionDTO> listAllByParentId(String groupParentId);
/**
* 职位列表递归获取全部内容
*
* @param params
* @return
*/
List<PositionDTO> listAll(Map<String, Object> params);
/**
* 职位详情
*
* @param params
* @return
*/
PositionDTO get(Map<String, Object> params);
/**
* 职位详情
*
* @param positionId
* @return
*/
PositionDTO get(String positionId);
/**
* 职位zTree列表
*
* @param params
* @return
*/
List<ZTreeDTO> listZTree(Map<String, Object> params);
/**
* 职位EasyUI列表
*
* @param page
* @return
*/
SuccessResultList<List<PositionDTO>> listPage(ListPage page);
/**
* 职位列表
*
* @param params
* @return
*/
List<PositionDTO> list(Map<String, Object> params);
/**
* 用户职位列表
*
* @param groupIds 用户ID列表
* @return
*/
List<PositionDTO> list(List<String> groupIds);
}

View File

@ -0,0 +1,14 @@
package ink.wgink.interfaces.position;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: IPositionCheckService
* @Description: 职位检查
* @Author: WangGeng
* @Date: 2021/2/16 18:07
* @Version: 1.0
**/
public interface IPositionCheckService {
}

View File

@ -0,0 +1,46 @@
package ink.wgink.interfaces.position;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.position.PositionUserDTO;
import ink.wgink.pojo.result.SuccessResultList;
import java.util.List;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: IPositionUser
* @Description: 职位用户
* @Author: WangGeng
* @Date: 2021/1/24 12:59
* @Version: 1.0
**/
public interface IPositionUserBaseService {
/**
* 用户ID列表
*
* @param positionId 用户组ID
* @return
*/
List<String> listUserId(String positionId);
/**
* 用户ID列表
*
* @param positionIds 用户组ID列表
* @return
*/
List<String> listUserId(List<String> positionIds);
/**
* 分页用户组用户
*
* @param positionId
* @param page
* @return
*/
SuccessResultList<List<PositionUserDTO>> listPage(String positionId, ListPage page);
}

View File

@ -1,5 +1,6 @@
package ink.wgink.pojo;
import java.util.HashMap;
import java.util.Map;
/**
@ -39,7 +40,7 @@ public class ListPage {
}
public Map<String, Object> getParams() {
return params;
return params == null ? new HashMap<>(16) : params;
}
public void setParams(Map<String, Object> params) {

View File

@ -1,5 +1,6 @@
package ink.wgink.pojo.dtos.position;
import ink.wgink.pojo.dtos.user.UserDTO;
import io.swagger.annotations.ApiModel;
import java.io.Serializable;
@ -26,6 +27,21 @@ public class PositionUserDTO implements Serializable {
private Integer userState;
private String userAvatar;
public PositionUserDTO() {
}
public PositionUserDTO(UserDTO userDTO) {
this.userId = userDTO.getUserId();
this.userUsername = userDTO.getUserUsername();
this.userName = userDTO.getUserName();
this.userPhone = userDTO.getUserPhone();
this.userEmail = userDTO.getUserEmail();
this.userType = userDTO.getUserType();
this.userState = userDTO.getUserState();
this.userAvatar = userDTO.getUserAvatar();
}
public String getUserId() {
return userId == null ? "" : userId.trim();
}

View File

@ -43,7 +43,7 @@ public class DepartmentUserController extends DefaultBaseController {
@PutMapping("update/{departmentId}")
public synchronized SuccessResult update(@PathVariable("departmentId") String departmentId,
@RequestBody IdsVO idsVO) {
departmentUserService.updateByDepartmentIdAndUserIds(departmentId, idsVO.getIds());
departmentUserService.update(departmentId, idsVO.getIds());
return new SuccessResult();
}
@ -56,7 +56,7 @@ public class DepartmentUserController extends DefaultBaseController {
@DeleteMapping("remove/{departmentId}/{ids}")
public synchronized SuccessResult remove(@PathVariable("departmentId") String departmentId,
@PathVariable("ids") String ids) {
departmentUserService.deleteByDepartmentIdAndUserIds(departmentId, null, Arrays.asList(ids.split("_")));
departmentUserService.delete(departmentId, null, Arrays.asList(ids.split("_")));
return new SuccessResult();
}
@ -80,8 +80,8 @@ public class DepartmentUserController extends DefaultBaseController {
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listuseridbydepartmentid/{departmentId}")
public List<String> listUserIdByDepartmentId(@PathVariable("departmentId") String departmentId) {
@GetMapping("listuserid/{departmentId}")
public List<String> listUserId(@PathVariable("departmentId") String departmentId) {
return departmentUserService.listUserId(departmentId);
}

View File

@ -35,5 +35,5 @@ public interface IDepartmentAdjustmentService {
* @param departmentName 部门名称
* @param userDepartmentType 部门用户类型joinleave
*/
void addUserDepartmentAdjustment(List<String> departmentUserIds, String departmentId, String departmentName, String userDepartmentType);
void save(List<String> departmentUserIds, String departmentId, String departmentName, String userDepartmentType);
}

View File

@ -106,137 +106,4 @@ public interface IDepartmentService extends IDepartmentBaseService, IDepartmentC
* @return
*/
void resetCode();
/**
* 部门列表
*
* @param params
* @return
*/
List<DepartmentDTO> list(Map<String, Object> params);
/**
* 通过ID获取组织部门详情
*
* @param departmentId
* @return
*/
DepartmentDTO get(String departmentId);
/**
* easyui组织部门
*
* @param page
* @return
*/
SuccessResultList<List<DepartmentDTO>> listPage(ListPage page);
/**
* easyui组织部门列表
*
* @param departmentParentId
* @param page
* @return
*/
SuccessResultList<List<DepartmentDTO>> listPageByParentId(String departmentParentId, ListPage page);
/**
* 组织部门列表递归获取全部内容
*
* @param params
* @return
*/
List<DepartmentDTO> listAll(Map<String, Object> params);
/**
* zTree组织部门
*
* @param params
* @return
*/
List<ZTreeDTO> listZTree(Map<String, Object> params);
/**
* zTree组织部门
*
* @param departmentParentId
* @param params
* @return
*/
List<ZTreeDTO> listZTree(String departmentParentId, Map<String, Object> params);
/**
* 部门ID列表
*
* @param params
* @return
*/
List<String> listId(Map<String, Object> params);
/**
* 获取基础部门ID列表
*
* @param departmentBOs
* @return
*/
List<String> listId(List<DepartmentBO> departmentBOs);
/**
* 获取上级部门
*
* @param departmentBO1
* @param departmentBO2
* @return
*/
DepartmentBO getHigherLevel(DepartmentBO departmentBO1, DepartmentBO departmentBO2);
/**
* 获得同一级部门数量按部门名称
*
* @param params
* @return
*/
Integer count(Map<String, Object> params);
/**
* 通过ID获取组织部门详情简单格式
*
* @param departmentId
* @return
*/
DepartmentSimpleDTO getSimple(String departmentId);
/**
* 部门列表
*
* @param params
* @return
*/
List<DepartmentSimpleDTO> listSimple(Map<String, Object> params);
/**
* 通过上级ID获取组织部门全部列表简单格式
*
* @param departmentParentId
* @return
*/
List<DepartmentSimpleDTO> listSimpleByParentId(String departmentParentId);
/**
* 通过上级ID和添加获取组织部门全部增量列表简单格式
*
* @param departmentParentId
* @param addDate
* @return
*/
List<DepartmentSimpleDTO> listSimpleByParentIdAndAddDate(String departmentParentId, String addDate);
/**
* 通过上级ID和更新获取组织部门全部新增和修改的列表简单格式
*
* @param departmentParentId
* @param updateDate
* @return
*/
List<DepartmentSimpleDTO> listSimpleByParentIdAndUpdateDate(String departmentParentId, String updateDate);
}

View File

@ -32,7 +32,7 @@ public interface IDepartmentUserService extends IDepartmentUserBaseService {
* @param departmentName 部门名称
* @param departmentUserIds 新增的用户ID列表
*/
void saveUserIdByDepartmentId(String departmentId, String departmentName, List<String> departmentUserIds);
void save(String departmentId, String departmentName, List<String> departmentUserIds);
/**
* 删除用户
@ -41,14 +41,14 @@ public interface IDepartmentUserService extends IDepartmentUserBaseService {
* @param departmentName 部门名称
* @param userIds 用户ID列表
*/
void deleteByDepartmentIdAndUserIds(String departmentId, String departmentName, List<String> userIds);
void delete(String departmentId, String departmentName, List<String> userIds);
/**
* 删除用户
*
* @param departmentId 部门ID
*/
void deleteUserByDepartmentId(String departmentId);
void delete(String departmentId);
/**
* 更新用户
@ -56,5 +56,5 @@ public interface IDepartmentUserService extends IDepartmentUserBaseService {
* @param departmentId 部门ID
* @param userIds 用户ID
*/
void updateByDepartmentIdAndUserIds(String departmentId, List<String> userIds);
void update(String departmentId, List<String> userIds);
}

View File

@ -48,7 +48,7 @@ public class DepartmentAdjustmentServiceImpl extends DefaultBaseService implemen
}
@Override
public void addUserDepartmentAdjustment(List<String> userIds, String departmentId, String departmentName, String userDepartmentType) {
public void save(List<String> userIds, String departmentId, String departmentName, String userDepartmentType) {
if (userIds.isEmpty()) {
return;
}

View File

@ -99,7 +99,7 @@ public class DepartmentServiceImpl extends DefaultBaseService implements IDepart
public void remove(List<String> ids) {
// 清空组织所在人员组织信息
for (String departmentId : ids) {
departmentUserService.deleteUserByDepartmentId(departmentId);
departmentUserService.delete(departmentId);
}
Map<String, Object> params = getHashMap(2);
params.put("departmentIds", ids);
@ -150,7 +150,7 @@ public class DepartmentServiceImpl extends DefaultBaseService implements IDepart
String newDepartmentId = saveReturnId(splitDepartmentInfoVO);
departmentAdjustmentService.save(departmentId, departmentDTO.getDepartmentName(), newDepartmentId, splitDepartmentInfoVO.getDepartmentName(), DepartmentAdjustmentTypeEnum.SPLIT);
if (!StringUtils.isBlank(userIds)) {
departmentUserService.updateByDepartmentIdAndUserIds(newDepartmentId, Arrays.asList(userIds.split("_")));
departmentUserService.update(newDepartmentId, Arrays.asList(userIds.split("_")));
}
}
}
@ -188,7 +188,10 @@ public class DepartmentServiceImpl extends DefaultBaseService implements IDepart
@Override
public List<DepartmentDTO> list(Map<String, Object> params) {
return departmentDao.list(params);
List<DepartmentDTO> srcDepartmentDTOs = departmentDao.list(params);
List<DepartmentDTO> destDepartmentDTOs = new ArrayList<>(Arrays.asList(new DepartmentDTO[srcDepartmentDTOs.size()]));
Collections.copy(destDepartmentDTOs, srcDepartmentDTOs);
return destDepartmentDTOs;
}
@Override
@ -437,7 +440,7 @@ public class DepartmentServiceImpl extends DefaultBaseService implements IDepart
departmentUserIds.addAll(oldDepartmentUserIds);
}
LOG.debug("将合并组织的人员添加到新组织");
departmentUserService.saveUserIdByDepartmentId(departmentId, departmentName, departmentUserIds);
departmentUserService.save(departmentId, departmentName, departmentUserIds);
}
/**
@ -451,7 +454,7 @@ public class DepartmentServiceImpl extends DefaultBaseService implements IDepart
// 获取用户ID
List<String> userIds = departmentUserService.listUserId(departmentId);
// 删除组织用户
departmentUserService.deleteByDepartmentIdAndUserIds(departmentId, departmentName, userIds);
departmentUserService.delete(departmentId, departmentName, userIds);
// 删除组织
Map<String, Object> params = getHashMap(2);
params.put("departmentIds", Arrays.asList(departmentId));

View File

@ -45,18 +45,18 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe
private IUserBaseService userBaseService;
@Override
public void saveUserIdByDepartmentId(String departmentId, String departmentName, List<String> departmentUserIds) {
public void save(String departmentId, String departmentName, List<String> departmentUserIds) {
Map<String, Object> params = getHashMap(2);
for (String departmentUserId : departmentUserIds) {
params.put("userId", departmentUserId);
params.put("departmentId", departmentId);
departmentUserDao.save(params);
}
departmentAdjustmentService.addUserDepartmentAdjustment(departmentUserIds, departmentId, departmentName, USER_DEPARTMENT_TYPE_JOIN);
departmentAdjustmentService.save(departmentUserIds, departmentId, departmentName, USER_DEPARTMENT_TYPE_JOIN);
}
@Override
public void deleteByDepartmentIdAndUserIds(String departmentId, String departmentName, List<String> userIds) {
public void delete(String departmentId, String departmentName, List<String> userIds) {
String adjustmentDepartmentName = departmentName;
if (StringUtils.isBlank(departmentName)) {
DepartmentSimpleDTO departmentSimpleDTO = departmentService.getSimple(departmentId);
@ -72,19 +72,19 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe
params.put("departmentId", departmentId);
params.put("userIds", userIds);
departmentUserDao.delete(params);
departmentAdjustmentService.addUserDepartmentAdjustment(userIds, departmentId, adjustmentDepartmentName, USER_DEPARTMENT_TYPE_LEAVE);
departmentAdjustmentService.save(userIds, departmentId, adjustmentDepartmentName, USER_DEPARTMENT_TYPE_LEAVE);
}
@Override
public void deleteUserByDepartmentId(String departmentId) {
public void delete(String departmentId) {
Map<String, Object> params = getHashMap(2);
params.put("departmentId", departmentId);
List<String> userIds = departmentUserDao.listUserId(params);
deleteByDepartmentIdAndUserIds(departmentId, null, userIds);
delete(departmentId, null, userIds);
}
@Override
public void updateByDepartmentIdAndUserIds(String departmentId, List<String> userIds) {
public void update(String departmentId, List<String> userIds) {
if (userIds.isEmpty()) {
return;
}
@ -110,7 +110,7 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe
newUserIds.add(userId);
}
}
departmentAdjustmentService.addUserDepartmentAdjustment(newUserIds, departmentId, departmentSimpleDTO.getDepartmentName(), USER_DEPARTMENT_TYPE_JOIN);
departmentAdjustmentService.save(newUserIds, departmentId, departmentSimpleDTO.getDepartmentName(), USER_DEPARTMENT_TYPE_JOIN);
}
@Override

View File

@ -421,7 +421,7 @@
</select>
<!-- 组织部门列表 -->
<select id="list" parameterType="map" resultMap="departmentDTO" useCache="false">
<select id="list" parameterType="map" resultMap="departmentDTO" useCache="true">
SELECT
department_id,
department_parent_id,

View File

@ -94,8 +94,7 @@
return '<button type="button" class="layui-btn layui-btn-xs" lay-event="userEvent"><i class="fa fa-users"></i> 查看</button>';
}
},
{field:'departmentName', width:180, title: '组织名称', align:'center',},
{field:'departmentNameEn', width:140, title: '名称(英文)', align:'center',},
{field:'departmentName', width:180, title: '组织机构名称', align:'center',},
{field:'departmentSummary', width:180, title: '组织说明', align:'center',},
{field:'departmentCode', width:100, title: '组织编码', align:'center',},
{field:'departmentType', width:100, title: '组织类型', align:'center',
@ -367,7 +366,7 @@
if(layEvent === 'userEvent') {
top.dialog.open({
url: top.restAjax.path('route/department/user/list?departmentId={departmentId}', [data.departmentId]),
title: '组织用户列表',
title: '【'+ data.departmentName +'】用户列表',
width: '800px',
height: '500px',
onClose: function() {}

View File

@ -237,7 +237,6 @@
</form>
</div>
</div>
<input id="hasArea" th:if="${hasArea}">
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>

View File

@ -112,14 +112,6 @@
return value;
}
},
{field:'departmentName', width:200, title: '机构', align:'center',
templet: function(item) {
if(!item.departmentName) {
return '-';
}
return item.departmentName;
}
},
]
],
page: true,
@ -175,13 +167,13 @@
// 初始化角色用户ID列表
function initSelectUserIds() {
var layIndex;
top.restAjax.get(top.restAjax.path('api/department/user/listuseridbydepartmentid/{departmentId}', [departmentId]), {}, null, function(code, data) {
top.restAjax.get(top.restAjax.path('api/department/user/listuserid/{departmentId}', [departmentId]), {}, null, function(code, data) {
var selectedUserIds = '';
for(var i = 0, item; item = data[i++]; ) {
if('' != selectedUserIds) {
selectedUserIds += '_';
}
selectedUserIds += item.userId;
selectedUserIds += item;
}
$('#selectedUserIds').val(selectedUserIds);
initTable();
@ -215,19 +207,14 @@
top.dialog.dialogData.selectedUserIds = $('#selectedUserIds').val();
top.dialog.open({
url: top.restAjax.path('route/department/user/select-user', []),
title: '选择组织部门人员',
title: '选择用户',
width: '500px',
height: '500px',
onClose: function() {
var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers;
if(selectedUsers != null && selectedUsers.length > 0) {
var selectedUserIds = '';
var ids = [];
for (var i = 0, item; item = selectedUsers[i++];) {
if ('' != selectedUserIds) {
selectedUserIds += '_';
}
selectedUserIds += item.userId;
ids.push(item.userId);
}
top.dialog.msg(top.dataMessage.update, {
@ -240,8 +227,7 @@
ids: ids
}, null, function (code, data) {
top.dialog.msg(top.dataMessage.updated);
$('#selectedUserIds').val(selectedUserIds);
reloadTable();
initSelectUserIds();
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {

View File

@ -85,9 +85,7 @@ public class GroupController extends DefaultBaseController {
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("get/{groupId}")
public GroupDTO get(@PathVariable("groupId") String groupId) {
Map<String, Object> params = getParams();
params.put("groupId", groupId);
return groupService.get(params);
return groupService.get(groupId);
}
@ApiOperation(value = "zTree列表", notes = "zTree列表接口")
@ -129,15 +127,10 @@ public class GroupController extends DefaultBaseController {
}
@ApiOperation(value = "通过ID列表获取组列表", notes = "通过ID列表获取用户组接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "groupIds", value = "组ID列表用下划线分隔1_2_3", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("listbyids/{groupIds}")
@PostMapping("listbyids")
public List<GroupDTO> listByIds(@RequestBody IdsVO idsVO) {
Map<String, Object> params = getParams();
params.put("groupIds", idsVO.getIds());
return groupService.list(params);
return groupService.list(idsVO.getIds());
}
}

View File

@ -1,18 +1,19 @@
package ink.wgink.service.group.controller.api;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.group.GroupUserDTO;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.pojo.vos.IdsVO;
import ink.wgink.service.group.service.IGroupUserService;
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;
@ -26,14 +27,39 @@ import java.util.Map;
* @Date: 2021/2/16 11:31 上午
* @Version: 1.0
*/
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "织部门用户")
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "用户组用户")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/group/user")
public class GroupUserController {
public class GroupUserController extends DefaultBaseController {
@Autowired
private IGroupUserService groupUserService;
@ApiOperation(value = "更新用户组人员列表", notes = "更新用户组人员列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("update/{groupId}")
public synchronized SuccessResult update(@PathVariable("groupId") String groupId,
@RequestBody IdsVO idsVO) {
groupUserService.update(groupId, idsVO.getIds());
return new SuccessResult();
}
@ApiOperation(value = "用户组人员删除", notes = "用户组人员删除接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "groupId", value = "部门ID", paramType = "path"),
@ApiImplicitParam(name = "ids", value = "人员ID列表用下划线分隔", paramType = "path", example = "1_2_3")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@DeleteMapping("remove/{groupId}/{ids}")
public synchronized SuccessResult remove(@PathVariable("groupId") String groupId,
@PathVariable("ids") String ids) {
groupUserService.delete(groupId, Arrays.asList(ids.split("_")));
return new SuccessResult();
}
@ApiOperation(value = "组人员列表", notes = "组人员列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "groupId", value = "组ID", paramType = "path", dataType = "String"),
@ -44,7 +70,19 @@ public class GroupUserController {
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpage/{groupId}")
public SuccessResultList<List<GroupUserDTO>> listPage(@PathVariable("groupId") String groupId, ListPage page) {
Map<String, Object> params = requestParams();
page.setParams(params);
return groupUserService.listPage(groupId, page);
}
@ApiOperation(value = "人员ID列表", notes = "人员ID列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "groupId", value = "用户组ID", paramType = "path"),
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listuserid/{groupId}")
public List<String> listUserId(@PathVariable("groupId") String groupId) {
return groupUserService.listUserId(groupId);
}
}

View File

@ -17,7 +17,7 @@ import org.springframework.web.servlet.ModelAndView;
* @Date: 2021/2/16 11:45 上午
* @Version: 1.0
*/
@Api(tags = ISystemConstant.ROUTE_TAGS_PREFIX + "用户组路由接口")
@Api(tags = ISystemConstant.ROUTE_TAGS_PREFIX + "用户组用户路由接口")
@Controller
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/group/user")
public class GroupUserRouteController {

View File

@ -70,7 +70,7 @@ public interface IGroupDao {
* @return
* @throws SearchException
*/
GroupDTO getGroup(Map<String, Object> params) throws SearchException;
GroupDTO get(Map<String, Object> params) throws SearchException;
/**
* 组详情
@ -79,7 +79,7 @@ public interface IGroupDao {
* @return
* @throws SearchException
*/
GroupPO getGroupPO(Map<String, Object> params) throws SearchException;
GroupPO getPO(Map<String, Object> params) throws SearchException;
/**
* 获取最后一个字组

View File

@ -1,5 +1,7 @@
package ink.wgink.service.group.dao;
import ink.wgink.exceptions.RemoveException;
import ink.wgink.exceptions.SaveException;
import ink.wgink.exceptions.SearchException;
import ink.wgink.exceptions.UpdateException;
import org.springframework.stereotype.Repository;
@ -27,6 +29,22 @@ public interface IGroupUserDao {
*/
void createTable() throws UpdateException;
/**
* 新增
*
* @param params
* @throws SaveException
*/
void save(Map<String, Object> params) throws SaveException;
/**
* 删除
*
* @param params
* @throws RemoveException
*/
void delete(Map<String, Object> params) throws RemoveException;
/**
* 用户ID列表
*
@ -44,4 +62,5 @@ public interface IGroupUserDao {
* @throws SearchException
*/
List<String> listGroupUserId(Map<String, Object> params) throws SearchException;
}

View File

@ -1,6 +1,7 @@
package ink.wgink.service.group.service;
import ink.wgink.interfaces.group.IGroupBaseService;
import ink.wgink.interfaces.group.IGroupCheckService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.bos.GroupBO;
import ink.wgink.pojo.dtos.ZTreeDTO;
@ -19,12 +20,12 @@ import java.util.Map;
* @Date: 2019/1/6 3:20 PM
* @Version: 1.0
**/
public interface IGroupService extends IGroupBaseService {
public interface IGroupService extends IGroupBaseService, IGroupCheckService {
/**
* 新增组
*
* @param params
* @param groupVO
* @return
*/
void save(GroupVO groupVO);
@ -32,7 +33,7 @@ public interface IGroupService extends IGroupBaseService {
/**
* 删除组
*
* @param params
* @param ids
* @return
*/
void remove(List<String> ids);
@ -40,56 +41,10 @@ public interface IGroupService extends IGroupBaseService {
/**
* 修改组
*
* @param params
* @param groupId
* @param groupVO
* @return
*/
void update(String groupId, GroupVO groupVO);
/**
* 全部组JSON列表
*
* @param groupParentId
* @return
*/
List<GroupDTO> listAllByParentId(String groupParentId);
/**
* 组列表递归获取全部内容
*
* @param params
* @return
*/
List<GroupDTO> listAll(Map<String, Object> params);
/**
* 组详情
*
* @param params
* @return
*/
GroupDTO get(Map<String, Object> params);
/**
* 组zTree列表
*
* @param params
* @return
*/
List<ZTreeDTO> listZTree(Map<String, Object> params);
/**
* 组EasyUI列表
*
* @param page
* @return
*/
SuccessResultList<List<GroupDTO>> listPage(ListPage page);
/**
* 组列表
*
* @param params
* @return
*/
List<GroupDTO> list(Map<String, Object> params);
}

View File

@ -2,6 +2,8 @@ package ink.wgink.service.group.service;
import ink.wgink.interfaces.group.IGroupUserBaseService;
import java.util.List;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
@ -13,4 +15,20 @@ import ink.wgink.interfaces.group.IGroupUserBaseService;
* @Version: 1.0
*/
public interface IGroupUserService extends IGroupUserBaseService {
/**
* 更新用户组人员列表
*
* @param groupId 用户组ID
* @param userIds 用户ID列表
*/
void update(String groupId, List<String> userIds);
/**
* 用户组人员删除
*
* @param groupId 用户组ID
* @param userIds 用户ID列表
*/
void delete(String groupId, List<String> userIds);
}

View File

@ -6,6 +6,7 @@ import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.ZTreeDTO;
import ink.wgink.pojo.dtos.department.DepartmentDTO;
import ink.wgink.pojo.dtos.group.GroupDTO;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.service.group.dao.IGroupDao;
@ -16,8 +17,7 @@ import ink.wgink.util.map.HashMapUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @ClassName: GroupServiceImpl
@ -39,7 +39,7 @@ public class GroupServiceImpl extends DefaultBaseService implements IGroupServic
String groupParentId = params.get("groupParentId").toString();
if (!ISystemConstant.TREE_ROOT_ID.equals(groupParentId)) {
params.put("groupId", groupParentId);
GroupDTO groupDTO = groupDao.getGroup(params);
GroupDTO groupDTO = groupDao.get(params);
parentCode = groupDTO.getGroupCode();
}
String groupCode = getCode(parentCode, groupParentId);
@ -80,7 +80,14 @@ public class GroupServiceImpl extends DefaultBaseService implements IGroupServic
@Override
public GroupDTO get(Map<String, Object> params) {
return groupDao.getGroup(params);
return groupDao.get(params);
}
@Override
public GroupDTO get(String groupId) {
Map<String, Object> params = getHashMap(2);
params.put("groupId", groupId);
return get(params);
}
@Override
@ -103,7 +110,17 @@ public class GroupServiceImpl extends DefaultBaseService implements IGroupServic
@Override
public List<GroupDTO> list(Map<String, Object> params) {
return groupDao.list(params);
List<GroupDTO> srcGroupDTOs = groupDao.list(params);
List<GroupDTO> destGroupDTOs = new ArrayList<>(Arrays.asList(new GroupDTO[srcGroupDTOs.size()]));
Collections.copy(destGroupDTOs, srcGroupDTOs);
return destGroupDTOs;
}
@Override
public List<GroupDTO> list(List<String> groupIds) {
Map<String, Object> params = getHashMap(2);
params.put("groupIds", groupIds);
return list(params);
}
/**

View File

@ -36,6 +36,27 @@ public class GroupUserServiceImpl extends DefaultBaseService implements IGroupUs
@Autowired
private IUserBaseService userBaseService;
@Override
public void update(String groupId, List<String> userIds) {
delete(groupId, userIds);
if (!userIds.isEmpty()) {
Map<String, Object> params = getHashMap(4);
params.put("groupId", groupId);
for (String userId : userIds) {
params.put("userId", userId);
groupUserDao.save(params);
}
}
}
@Override
public void delete(String groupId, List<String> userIds) {
Map<String, Object> params = getHashMap(4);
params.put("groupId", groupId);
params.put("userIds", userIds);
groupUserDao.delete(params);
}
@Override
public List<String> listUserId(String groupId) {
Map<String, Object> params = getHashMap(2);

View File

@ -2,6 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="ink.wgink.service.group.dao.IGroupDao">
<cache flushInterval="3600000"/>
<resultMap id="groupDTO" type="ink.wgink.pojo.dtos.group.GroupDTO">
<id property="groupId" column="group_id"/>
<result property="groupParentId" column="group_parent_id"/>
@ -50,7 +52,7 @@
</update>
<!-- 新增组 -->
<insert id="save" parameterType="map">
<insert id="save" parameterType="map" flushCache="true">
INSERT INTO sys_group(
group_id,
group_parent_id,
@ -77,7 +79,7 @@
</insert>
<!-- 删除组 -->
<update id="remove" parameterType="map">
<update id="remove" parameterType="map" flushCache="true">
UPDATE
sys_group
SET
@ -92,7 +94,7 @@
</update>
<!-- 修改组 -->
<update id="update" parameterType="map">
<update id="update" parameterType="map" flushCache="true">
UPDATE
sys_group
SET
@ -112,7 +114,7 @@
</update>
<!-- ztree列表 -->
<select id="listZTree" parameterType="map" resultMap="groupZTreeDTO">
<select id="listZTree" parameterType="map" resultMap="groupZTreeDTO" useCache="true">
SELECT
*
FROM
@ -126,7 +128,7 @@
</select>
<!-- 组列表 -->
<select id="list" parameterType="map" resultMap="groupDTO">
<select id="list" parameterType="map" resultMap="groupDTO" useCache="true">
SELECT
*
FROM
@ -168,13 +170,13 @@
</when>
<otherwise>
ORDER BY
gmt_create desc
group_code
</otherwise>
</choose>
</select>
<!-- 组详情 -->
<select id="getGroup" parameterType="map" resultMap="groupDTO">
<select id="get" parameterType="map" resultMap="groupDTO" useCache="false">
SELECT
t1.*,
t2.group_name group_parent_name
@ -195,7 +197,7 @@
</select>
<!-- 组详情 -->
<select id="getGroupPO" parameterType="map" resultMap="groupPO">
<select id="getPO" parameterType="map" resultMap="groupPO" useCache="false">
SELECT
*
FROM
@ -209,7 +211,7 @@
</select>
<!-- 子节点数量 -->
<select id="countByParentId" parameterType="String" resultType="Integer">
<select id="countByParentId" parameterType="String" resultType="Integer" useCache="false">
SELECT
COUNT(*)
FROM
@ -221,7 +223,7 @@
</select>
<!-- 获取最后一个子组,实际数据,包含已删除,方式编码重复 -->
<select id="getLastByParentId" parameterType="String" resultMap="groupDTO">
<select id="getLastByParentId" parameterType="String" resultMap="groupDTO" useCache="false">
SELECT
*
FROM

View File

@ -16,8 +16,42 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
</update>
<!-- 新增 -->
<insert id="save" parameterType="map" flushCache="true">
INSERT INTO sys_group_user(
group_id,
user_id
) VALUES(
#{groupId},
#{userId}
)
</insert>
<!-- 删除 -->
<delete id="delete" parameterType="map" flushCache="true">
DELETE FROM
sys_group_user
WHERE
1 = 1
<if test="groupId != null and groupId != ''">
AND
group_id = #{groupId}
</if>
<if test="userId != null and userId != ''">
AND
user_id = #{userId}
</if>
<if test="userIds != null and userIds.size > 0">
AND
user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
</delete>
<!-- 用户ID列表 -->
<select id="listUserId" parameterType="map" resultType="java.lang.String">
<select id="listUserId" parameterType="map" resultType="java.lang.String" useCache="true">
SELECT
user_id
FROM
@ -36,7 +70,7 @@
</select>
<!-- 用户ID列表 -->
<select id="listGroupUserId" parameterType="map" resultType="java.lang.String">
<select id="listGroupUserId" parameterType="map" resultType="java.lang.String" useCache="true">
SELECT
user_id
FROM

View File

@ -206,7 +206,7 @@
if(layEvent === 'userEvent') {
top.dialog.open({
url: top.restAjax.path('route/group/user/list?groupId={groupId}', [data.groupId]),
title: '用户组用户列表',
title: '【'+ data.groupName +'】用户列表',
width: '800px',
height: '500px',
onClose: function() {}

View File

@ -112,14 +112,6 @@
return value;
}
},
{field:'groupName', width:200, title: '组', align:'center',
templet: function(item) {
if(!item.groupName) {
return '-';
}
return item.groupName;
}
},
]
],
page: true,
@ -175,13 +167,13 @@
// 初始化角色用户ID列表
function initSelectUserIds() {
var layIndex;
top.restAjax.get(top.restAjax.path('api/group/user/listuseridbygroupid/{groupId}', [groupId]), {}, null, function(code, data) {
top.restAjax.get(top.restAjax.path('api/group/user/listuserid/{groupId}', [groupId]), {}, null, function(code, data) {
var selectedUserIds = '';
for(var i = 0, item; item = data[i++]; ) {
if('' != selectedUserIds) {
if(selectedUserIds.length > 0) {
selectedUserIds += '_';
}
selectedUserIds += item.userId;
selectedUserIds += item;
}
$('#selectedUserIds').val(selectedUserIds);
initTable();
@ -215,19 +207,14 @@
top.dialog.dialogData.selectedUserIds = $('#selectedUserIds').val();
top.dialog.open({
url: top.restAjax.path('route/department/user/select-user', []),
title: '选择组织部门人员',
title: '选择用户',
width: '500px',
height: '500px',
onClose: function() {
var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers;
if(selectedUsers != null && selectedUsers.length > 0) {
var selectedUserIds = '';
var ids = [];
for (var i = 0, item; item = selectedUsers[i++];) {
if ('' != selectedUserIds) {
selectedUserIds += '_';
}
selectedUserIds += item.userId;
ids.push(item.userId);
}
top.dialog.msg(top.dataMessage.update, {
@ -240,8 +227,7 @@
ids: ids
}, null, function (code, data) {
top.dialog.msg(top.dataMessage.updated);
$('#selectedUserIds').val(selectedUserIds);
reloadTable();
initSelectUserIds();
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {

View File

@ -2,7 +2,9 @@ package ink.wgink.module.menu.startup;
import ink.wgink.interfaces.department.IDepartmentCheckService;
import ink.wgink.interfaces.dictionary.IDictionaryCheckService;
import ink.wgink.interfaces.group.IGroupCheckService;
import ink.wgink.interfaces.menu.IMenuBaseService;
import ink.wgink.interfaces.position.IPositionCheckService;
import ink.wgink.interfaces.user.IUserCheckService;
import ink.wgink.pojo.dtos.menu.MenuDTO;
import ink.wgink.module.menu.dao.IMenuDao;
@ -39,6 +41,10 @@ public class ServiceMenuStartUp implements ApplicationRunner {
private IUserCheckService userCheckService;
@Autowired(required = false)
private IDepartmentCheckService departmentCheckService;
@Autowired(required = false)
private IGroupCheckService groupCheckService;
@Autowired(required = false)
private IPositionCheckService positionCheckService;
@Override
public void run(ApplicationArguments args) throws Exception {
@ -225,6 +231,7 @@ public class ServiceMenuStartUp implements ApplicationRunner {
initUserManage(params, menuId);
initDepartmentManage(params, menuId);
initGroupManage(params, menuId);
initPositionManage(params, menuId);
}
/**
@ -238,6 +245,7 @@ public class ServiceMenuStartUp implements ApplicationRunner {
return;
}
LOG.debug("初始化菜单:用户管理");
params.remove("menuId");
params.put("menuCode", "000100020001");
MenuDTO menuDTO = menuDao.getSimple(params);
@ -264,10 +272,11 @@ public class ServiceMenuStartUp implements ApplicationRunner {
* @param menuParentId
*/
private void initDepartmentManage(Map<String, Object> params, String menuParentId) {
LOG.debug("初始化菜单:组织机构管理");
if (departmentCheckService == null) {
return;
}
LOG.debug("初始化菜单:组织机构管理");
params.remove("menuId");
params.put("menuCode", "000100020002");
MenuDTO menuDTO = menuDao.getSimple(params);
@ -294,10 +303,11 @@ public class ServiceMenuStartUp implements ApplicationRunner {
* @param menuParentId
*/
private void initGroupManage(Map<String, Object> params, String menuParentId) {
LOG.debug("初始化菜单:用户组管理");
if (departmentCheckService == null) {
if (groupCheckService == null) {
return;
}
LOG.debug("初始化菜单:用户组管理");
params.remove("menuId");
params.put("menuCode", "000100020003");
MenuDTO menuDTO = menuDao.getSimple(params);
@ -317,14 +327,39 @@ public class ServiceMenuStartUp implements ApplicationRunner {
}
}
private void initMenuPosition() {
/**
* 职位管理
*
* @param params
* @param menuParentId
*/
private void initPositionManage(Map<String, Object> params, String menuParentId) {
if (positionCheckService == null) {
return;
}
LOG.debug("初始化菜单:职位管理");
LOG.debug("初始化菜单:权限管理");
LOG.debug("初始化菜单:角色管理");
params.remove("menuId");
params.put("menuCode", "000100020004");
MenuDTO menuDTO = menuDao.getSimple(params);
String menuId = UUIDUtil.getUUID();
if (menuDTO == null) {
params.put("menuId", menuId);
params.put("menuParentId", menuParentId);
params.put("menuName", "用户组管理");
params.put("menuSummary", "用户组管理");
params.put("menuUrl", "/route/position/list-tree");
params.put("menuType", "1");
params.put("menuIcon", "fa-icon-color-white fa fa-users");
params.put("menuOrder", "4");
params.put("menuStatus", "0");
params.put("openType", "1");
menuDao.save(params);
}
}
private void initMenuPermission() {
LOG.debug("初始化菜单:权限管理");
LOG.debug("初始化菜单:角色管理");
}
private void initMenuRole() {

View File

@ -1,119 +0,0 @@
package ink.wgink.module.position.service;
import ink.wgink.interfaces.position.IPositionBaseService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.bos.PositionBO;
import ink.wgink.pojo.dtos.ZTreeDTO;
import ink.wgink.pojo.dtos.position.PositionDTO;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.pojo.result.SuccessResultList;
import java.util.List;
import java.util.Map;
/**
* @ClassName: IPositionService
* @Description: 职位
* @Author: admin
* @Date: 2019-04-11 22:41:20
* @Version: 1.0
**/
public interface IPositionService extends IPositionBaseService {
/**
* 新增职位
*
* @param params
* @return
*/
SuccessResult save(Map<String, Object> params);
/**
* 删除职位
*
* @param params
* @return
* @throws RemoveException
*/
SuccessResult remove(Map<String, Object> params);
/**
* 修改职位
*
* @param params
* @return
*/
SuccessResult update(Map<String, Object> params);
/**
* 全部职位JSON列表
*
* @param params
* @return
*/
List<PositionDTO> listAllJson(Map<String, Object> params);
/**
* 组列表递归获取全部内容
*
* @param params
* @return
*/
List<PositionDTO> listAll(Map<String, Object> params);
/**
* 职位详情
*
* @param params
* @return
*/
PositionDTO get(Map<String, Object> params);
/**
* 职位zTree列表
*
* @param params
* @return
*/
List<ZTreeDTO> listZTree(Map<String, Object> params);
/**
* 职位分页列表
*
* @param page
* @return
*/
SuccessResultList<List<PositionDTO>> listPage(ListPage page);
/**
* 职位列表无分页
*
* @param params
* @return
*/
List<PositionDTO> list(Map<String, Object> params);
/**
* 用户职位列表
*
* @param params
* @return
*/
List<PositionBO> listBOByUser(Map<String, Object> params);
/**
* 用户职位列表
*
* @param params
* @return
*/
List<PositionDTO> listUser(Map<String, Object> params);
/**
* 统计职位
*
* @param params
* @return
*/
Integer count(Map<String, Object> params);
}

View File

@ -1,7 +1,7 @@
package ink.wgink.module.position.controller.api;
package ink.wgink.service.position.controller.api;
import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.exceptions.ParamsException;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.ZTreeDTO;
@ -9,13 +9,15 @@ import ink.wgink.pojo.dtos.position.PositionDTO;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.module.position.pojo.vos.PositionVO;
import ink.wgink.module.position.service.IPositionService;
import ink.wgink.service.position.pojo.vos.PositionVO;
import ink.wgink.service.position.service.IPositionService;
import ink.wgink.pojo.vos.IdsVO;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -36,11 +38,11 @@ public class PositionController extends DefaultBaseController {
@ApiOperation(value = "职位新增", notes = "职位新增接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("saveposition")
@PostMapping("save")
@CheckRequestBodyAnnotation
public SuccessResult savePosition(@RequestBody PositionVO positionVO) {
Map<String, Object> params = getParams();
checkParams(positionVO, params);
return positionService.save(params);
positionService.save(positionVO);
return new SuccessResult();
}
@ApiOperation(value = "职位删除", notes = "通过id列表批量删除职位接口")
@ -48,85 +50,59 @@ public class PositionController extends DefaultBaseController {
@ApiImplicitParam(name = "ids", value = "职位ID列表用下划线分隔", paramType = "path", example = "1_2_3")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@DeleteMapping("removeposition/{ids}")
@DeleteMapping("remove/{ids}")
public SuccessResult removePosition(@PathVariable("ids") String ids) {
Map<String, Object> params = getParams();
params.put("positionIds", ids);
return positionService.remove(params);
positionService.remove(Arrays.asList(ids.split("\\_")));
return new SuccessResult();
}
@ApiOperation(value = "职位修改", notes = "职位修改接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "positionId", value = "职位ID", paramType = "path")
@ApiImplicitParam(name = "groupId", value = "职位ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("updateposition/{positionId}")
public SuccessResult updatePosition(@PathVariable("positionId") String positionId, @RequestBody PositionVO positionVO) {
Map<String, Object> params = getParams();
params.put("positionId", positionId);
checkParams(positionVO, params);
return positionService.update(params);
}
/**
* 校验参数
*
* @param positionVO
* @param params
*/
private void checkParams(PositionVO positionVO, Map<String, Object> params) {
if (StringUtils.isBlank(positionVO.getPositionParentId())) {
throw new ParamsException("父ID不能为空");
}
params.put("positionParentId", positionVO.getPositionParentId());
if (StringUtils.isBlank(positionVO.getPositionName())) {
throw new ParamsException("职位名称不能为空");
}
params.put("positionName", positionVO.getPositionName());
params.put("positionSummary", positionVO.getPositionSummary());
params.put("positionNameEn", positionVO.getPositionNameEn());
@PutMapping("update/{groupId}")
@CheckRequestBodyAnnotation
public SuccessResult update(@PathVariable("groupId") String groupId, @RequestBody PositionVO positionVO) {
positionService.update(groupId, positionVO);
return new SuccessResult();
}
@ApiOperation(value = "职位列表", notes = "职位列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "positionParentId", value = "职位上级ID", paramType = "path")
@ApiImplicitParam(name = "groupParentId", value = "职位上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listposition/{positionParentId}")
public List<PositionDTO> listPosition(@PathVariable("positionParentId") String positionParentId) {
Map<String, Object> params = getParams();
params.put("positionParentId", positionParentId);
return positionService.list(params);
@GetMapping("listallbyparentid/{groupParentId}")
public List<PositionDTO> listAllByParentId(@PathVariable("groupParentId") String groupParentId) {
return positionService.listAllByParentId(groupParentId);
}
@ApiOperation(value = "职位详情", notes = "职位详情接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "positionId", value = "职位ID", paramType = "path")
@ApiImplicitParam(name = "groupId", value = "职位ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("getposition/{positionId}")
public PositionDTO getPosition(@PathVariable("positionId") String positionId) {
@GetMapping("get/{groupId}")
public PositionDTO get(@PathVariable("groupId") String groupId) {
Map<String, Object> params = getParams();
params.put("positionId", positionId);
params.put("groupId", groupId);
return positionService.get(params);
}
@ApiOperation(value = "zTree职位列表", notes = "zTree职位列表接口")
@ApiOperation(value = "zTree列表", notes = "zTree列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "父ID", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listztreeposition")
public List<ZTreeDTO> listZTreePosition() {
@GetMapping("listztree")
public List<ZTreeDTO> listZTree() {
Map<String, Object> params = requestParams();
String positionParentId = "0";
if (!StringUtils.isBlank(params.get("id") == null ? null : params.get("id").toString())) {
positionParentId = params.get("id").toString();
String groupParentId = "0";
if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_ID) == null ? null : params.get(ISystemConstant.PARAMS_ID).toString())) {
groupParentId = params.get(ISystemConstant.PARAMS_ID).toString();
}
params.put("positionParentId", positionParentId);
params.put("groupParentId", groupParentId);
return positionService.listZTree(params);
}
@ -140,16 +116,23 @@ public class PositionController extends DefaultBaseController {
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpageposition")
public SuccessResultList<List<PositionDTO>> listPagePosition(ListPage page) {
@GetMapping("listpage")
public SuccessResultList<List<PositionDTO>> listPage(ListPage page) {
Map<String, Object> params = requestParams();
String positionParentId = "0";
String groupParentId = "0";
if (!StringUtils.isBlank(params.get("parentId") == null ? null : params.get("parentId").toString())) {
positionParentId = params.get("parentId").toString();
groupParentId = params.get("parentId").toString();
}
params.put("positionParentId", positionParentId);
params.put("groupParentId", groupParentId);
page.setParams(params);
return positionService.listPage(page);
}
@ApiOperation(value = "通过ID列表获取职位列表", notes = "通过ID列表获取用户职位接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("listbyids")
public List<PositionDTO> listByIds(@RequestBody IdsVO idsVO) {
return positionService.list(idsVO.getIds());
}
}

View File

@ -0,0 +1,88 @@
package ink.wgink.service.position.controller.api;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.position.PositionUserDTO;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.pojo.vos.IdsVO;
import ink.wgink.service.position.service.IPositionUserService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: PositionUserController
* @Description: 职位用户
* @Author: wanggeng
* @Date: 2021/2/16 11:31 上午
* @Version: 1.0
*/
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "职位用户")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/position/user")
public class PositionUserController extends DefaultBaseController {
@Autowired
private IPositionUserService positionUserService;
@ApiOperation(value = "更新职位人员列表", notes = "更新职位人员列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("update/{positionId}")
public synchronized SuccessResult update(@PathVariable("positionId") String positionId,
@RequestBody IdsVO idsVO) {
positionUserService.update(positionId, idsVO.getIds());
return new SuccessResult();
}
@ApiOperation(value = "职位人员删除", notes = "职位人员删除接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "positionId", value = "部门ID", paramType = "path"),
@ApiImplicitParam(name = "ids", value = "人员ID列表用下划线分隔", paramType = "path", example = "1_2_3")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@DeleteMapping("remove/{positionId}/{ids}")
public synchronized SuccessResult remove(@PathVariable("positionId") String positionId,
@PathVariable("ids") String ids) {
positionUserService.delete(positionId, Arrays.asList(ids.split("_")));
return new SuccessResult();
}
@ApiOperation(value = "组人员列表", notes = "组人员列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "positionId", value = "组ID", paramType = "path", dataType = "String"),
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpage/{positionId}")
public SuccessResultList<List<PositionUserDTO>> listPage(@PathVariable("positionId") String positionId, ListPage page) {
Map<String, Object> params = requestParams();
page.setParams(params);
return positionUserService.listPage(positionId, page);
}
@ApiOperation(value = "人员ID列表", notes = "人员ID列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "positionId", value = "职位ID", paramType = "path"),
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listuserid/{positionId}")
public List<String> listUserId(@PathVariable("positionId") String positionId) {
return positionUserService.listUserId(positionId);
}
}

View File

@ -0,0 +1,44 @@
package ink.wgink.service.position.controller.route;
import ink.wgink.interfaces.consts.ISystemConstant;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: GroupRouteController
* @Description: 职位路由
* @Author: wanggeng
* @Date: 2021/2/15 9:07 上午
* @Version: 1.0
*/
@Api(tags = ISystemConstant.ROUTE_TAGS_PREFIX + "职位路由接口")
@Controller
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/position")
public class PositionRouteController {
@GetMapping("save")
public ModelAndView save() {
return new ModelAndView("position/save");
}
@GetMapping("update")
public ModelAndView update() {
return new ModelAndView("position/update");
}
@GetMapping("list")
public ModelAndView list() {
return new ModelAndView("position/list");
}
@GetMapping("list-tree")
public ModelAndView listTree() {
return new ModelAndView("position/list-tree");
}
}

View File

@ -0,0 +1,30 @@
package ink.wgink.service.position.controller.route;
import ink.wgink.interfaces.consts.ISystemConstant;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: GroupUserRouteController
* @Description: 职位用户路由
* @Author: wanggeng
* @Date: 2021/2/16 11:45 上午
* @Version: 1.0
*/
@Api(tags = ISystemConstant.ROUTE_TAGS_PREFIX + "职位用户路由接口")
@Controller
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/position/user")
public class PositionUserRouteController {
@GetMapping("list")
public ModelAndView list() {
return new ModelAndView("position/user/list");
}
}

View File

@ -1,4 +1,4 @@
package ink.wgink.module.position.dao;
package ink.wgink.service.position.dao;
import ink.wgink.exceptions.RemoveException;
import ink.wgink.exceptions.SaveException;
@ -22,6 +22,13 @@ import java.util.Map;
@Repository
public interface IPositionDao {
/**
* 建表
*
* @throws UpdateException
*/
void createTable() throws UpdateException;
/**
* 新增职位
*
@ -100,15 +107,6 @@ public interface IPositionDao {
*/
List<PositionBO> listBOByUser(Map<String, Object> params) throws SearchException;
/**
* 用户职位列表
*
* @param params
* @return
* @throws SearchException
*/
List<PositionDTO> listUser(Map<String, Object> params) throws SearchException;
/**
* 统计职位
*

View File

@ -0,0 +1,66 @@
package ink.wgink.service.position.dao;
import ink.wgink.exceptions.RemoveException;
import ink.wgink.exceptions.SaveException;
import ink.wgink.exceptions.SearchException;
import ink.wgink.exceptions.UpdateException;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: IPositionUserDao
* @Description: 职位用户
* @Author: WangGeng
* @Date: 2021/2/16 17:45
* @Version: 1.0
**/
@Repository
public interface IPositionUserDao {
/**
* 建表
*
* @throws UpdateException
*/
void createTable() throws UpdateException;
/**
* 新增
*
* @param params
* @throws SaveException
*/
void save(Map<String, Object> params) throws SaveException;
/**
* 删除
*
* @param params
* @throws RemoveException
*/
void delete(Map<String, Object> params) throws RemoveException;
/**
* 用户ID列表
*
* @param params
* @return
* @throws SearchException
*/
List<String> listUserId(Map<String, Object> params) throws SearchException;
/**
* 用户ID列表
*
* @param params
* @return
* @throws SearchException
*/
List<String> listGroupUserId(Map<String, Object> params) throws SearchException;
}

View File

@ -1,4 +1,4 @@
package ink.wgink.module.position.pojo.vos;
package ink.wgink.service.position.pojo.vos;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -0,0 +1,42 @@
package ink.wgink.service.position.service;
import ink.wgink.interfaces.position.IPositionBaseService;
import ink.wgink.interfaces.position.IPositionCheckService;
import ink.wgink.service.position.pojo.vos.PositionVO;
import java.util.List;
/**
* @ClassName: IPositionService
* @Description: 职位
* @Author: admin
* @Date: 2019-04-11 22:41:20
* @Version: 1.0
**/
public interface IPositionService extends IPositionBaseService, IPositionCheckService {
/**
* 新增职位
*
* @param positionVO
* @return
*/
void save(PositionVO positionVO);
/**
* 删除职位
*
* @param ids
* @return
*/
void remove(List<String> ids);
/**
* 修改职位
*
* @param groupId
* @param positionVO
* @return
*/
void update(String groupId, PositionVO positionVO);
}

View File

@ -0,0 +1,35 @@
package ink.wgink.service.position.service;
import ink.wgink.interfaces.position.IPositionUserBaseService;
import java.util.List;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: IPositionUserService
* @Description: 职位用户业务
* @Author: WangGeng
* @Date: 2021/2/16 17:49
* @Version: 1.0
**/
public interface IPositionUserService extends IPositionUserBaseService {
/**
* 更新职位人员列表
*
* @param positionId 职位ID
* @param userIds 用户ID列表
*/
void update(String positionId, List<String> userIds);
/**
* 职位人员删除
*
* @param positionId 职位ID
* @param userIds 用户ID列表
*/
void delete(String positionId, List<String> userIds);
}

View File

@ -1,23 +1,22 @@
package ink.wgink.module.position.service.impl;
package ink.wgink.service.position.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.service.position.pojo.vos.PositionVO;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.bos.PositionBO;
import ink.wgink.pojo.dtos.ZTreeDTO;
import ink.wgink.pojo.dtos.position.PositionDTO;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.module.position.dao.IPositionDao;
import ink.wgink.module.position.service.IPositionService;
import ink.wgink.service.position.dao.IPositionDao;
import ink.wgink.service.position.service.IPositionService;
import ink.wgink.util.UUIDUtil;
import ink.wgink.util.map.HashMapUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @ClassName: PositionServiceImpl
@ -33,10 +32,11 @@ public class PositionServiceImpl extends DefaultBaseService implements IPosition
private IPositionDao positionDao;
@Override
public SuccessResult save(Map<String, Object> params) {
public void save(PositionVO positionVO) {
String parentCode = null;
Map<String, Object> params = HashMapUtil.beanToMap(positionVO);
String positionParentId = params.get("positionParentId").toString();
if (!"0".equals(positionParentId)) {
if (!ISystemConstant.TREE_ROOT_ID.equals(positionParentId)) {
params.put("positionId", positionParentId);
PositionDTO positionDTO = positionDao.get(params);
parentCode = positionDTO.getPositionCode();
@ -46,33 +46,34 @@ public class PositionServiceImpl extends DefaultBaseService implements IPosition
params.put("positionId", UUIDUtil.getUUID());
setSaveInfo(params);
positionDao.save(params);
return new SuccessResult();
}
@Override
public SuccessResult remove(Map<String, Object> params) {
params.put("positionIds", Arrays.asList(params.get("positionIds").toString().split("_")));
public void remove(List<String> ids) {
Map<String, Object> params = getHashMap(2);
params.put("positionIds", ids);
setUpdateInfo(params);
positionDao.remove(params);
return new SuccessResult();
}
@Override
public SuccessResult update(Map<String, Object> params) {
public void update(String positionId, PositionVO positionVO) {
Map<String, Object> params = HashMapUtil.beanToMap(positionVO);
setUpdateInfo(params);
positionDao.update(params);
return new SuccessResult();
}
@Override
public List<PositionDTO> listAllJson(Map<String, Object> params) {
public List<PositionDTO> listAllByParentId(String positionParentId) {
Map<String, Object> params = getHashMap(2);
params.put("positionParentId", positionParentId);
return listAll(params);
}
@Override
public List<PositionDTO> listAll(Map<String, Object> params) {
List<PositionDTO> positionDTOs = positionDao.list(params);
listSub(positionDTOs, params);
List<PositionDTO> positionDTOs = list(params);
listSubPositions(positionDTOs, params);
return positionDTOs;
}
@ -81,6 +82,13 @@ public class PositionServiceImpl extends DefaultBaseService implements IPosition
return positionDao.get(params);
}
@Override
public PositionDTO get(String positionId) {
Map<String, Object> params = getHashMap(2);
params.put("positionId", positionId);
return get(params);
}
@Override
public List<ZTreeDTO> listZTree(Map<String, Object> params) {
List<ZTreeDTO> zTreeDTOs = positionDao.listZTree(params);
@ -94,44 +102,38 @@ public class PositionServiceImpl extends DefaultBaseService implements IPosition
@Override
public SuccessResultList<List<PositionDTO>> listPage(ListPage page) {
PageHelper.startPage(page.getPage(), page.getRows());
List<PositionDTO> positionDTOs = positionDao.list(page.getParams());
List<PositionDTO> positionDTOs = list(page.getParams());
PageInfo<PositionDTO> pageInfo = new PageInfo<>(positionDTOs);
return new SuccessResultList<>(positionDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
}
@Override
public List<PositionDTO> list(Map<String, Object> params) {
return positionDao.list(params);
List<PositionDTO> srcPositionDTOs = positionDao.list(params);
List<PositionDTO> destPositionDTO = new ArrayList<>(Arrays.asList(new PositionDTO[srcPositionDTOs.size()]));
Collections.copy(destPositionDTO, srcPositionDTOs);
return destPositionDTO;
}
@Override
public List<PositionBO> listBOByUser(Map<String, Object> params) {
return positionDao.listBOByUser(params);
}
@Override
public List<PositionDTO> listUser(Map<String, Object> params) {
return positionDao.listUser(params);
}
@Override
public Integer count(Map<String, Object> params) {
Integer positionCount = positionDao.count(params);
return positionCount == null ? 0 : positionCount;
public List<PositionDTO> list(List<String> positionIds) {
Map<String, Object> params = getHashMap(2);
params.put("positionIds", positionIds);
return list(params);
}
/**
* 递归查询子职位
* 递归查询子组
*
* @param positionDTOs
* @param params
*/
private void listSub(List<PositionDTO> positionDTOs, Map<String, Object> params) {
private void listSubPositions(List<PositionDTO> positionDTOs, Map<String, Object> params) {
for (PositionDTO positionDTO : positionDTOs) {
params.put("positionParentId", positionDTO.getPositionId());
List<PositionDTO> subPositionDTOs = positionDao.list(params);
List<PositionDTO> subPositionDTOs = list(params);
positionDTO.setSubPositions(subPositionDTOs);
listSub(subPositionDTOs, params);
listSubPositions(subPositionDTOs, params);
}
}

View File

@ -0,0 +1,121 @@
package ink.wgink.service.position.service.impl;
import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.interfaces.user.IUserBaseService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.position.PositionUserDTO;
import ink.wgink.pojo.dtos.user.UserDTO;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.service.position.dao.IPositionUserDao;
import ink.wgink.service.position.service.IPositionUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: IPositionUserServiceImpl
* @Description: 职位用户业务
* @Author: WangGeng
* @Date: 2021/2/16 17:49
* @Version: 1.0
**/
@Service
public class PositionUserServiceImpl extends DefaultBaseService implements IPositionUserService {
@Autowired
private IPositionUserDao positionUserDao;
@Autowired
private IUserBaseService userBaseService;
@Override
public void update(String positionId, List<String> userIds) {
delete(positionId, userIds);
if (!userIds.isEmpty()) {
Map<String, Object> params = getHashMap(4);
params.put("positionId", positionId);
for (String userId : userIds) {
params.put("userId", userId);
positionUserDao.save(params);
}
}
}
@Override
public void delete(String positionId, List<String> userIds) {
Map<String, Object> params = getHashMap(4);
params.put("positionId", positionId);
params.put("userIds", userIds);
positionUserDao.delete(params);
}
@Override
public List<String> listUserId(String positionId) {
Map<String, Object> params = getHashMap(2);
params.put("positionId", positionId);
return positionUserDao.listUserId(params);
}
@Override
public List<String> listUserId(List<String> positionIds) {
Map<String, Object> params = getHashMap(2);
params.put("positionIds", positionIds);
return positionUserDao.listUserId(params);
}
@Override
public SuccessResultList<List<PositionUserDTO>> listPage(String positionId, ListPage page) {
SuccessResultList<List<UserDTO>> successResultList;
if (StringUtils.equals(positionId, ISystemConstant.TREE_BASE_ROOT_ID_VALUE)) {
successResultList = listPageUserDTOByExcludePosition(page);
} else {
successResultList = listPageUser(positionId, page);
}
List<UserDTO> userDTOs = successResultList.getRows();
List<PositionUserDTO> positionUserDTOs = new ArrayList<>();
for (UserDTO userDTO : userDTOs) {
PositionUserDTO positionUserDTO = new PositionUserDTO(userDTO);
positionUserDTOs.add(positionUserDTO);
}
return new SuccessResultList<>(positionUserDTOs, successResultList.getPage(), successResultList.getTotal());
}
private List<String> listGroupUserId(Map<String, Object> params) {
return positionUserDao.listGroupUserId(params);
}
/**
* 没有用户组的用户分页列表
*
* @param page
* @return
*/
private SuccessResultList<List<UserDTO>> listPageUserDTOByExcludePosition(ListPage page) {
List<String> hasPositionUserIds = listGroupUserId(new HashMap<>(0));
return userBaseService.listPageByExcludeIds(hasPositionUserIds, page);
}
/**
* 用户组的用户分页列表
*
* @param positionId 用户组ID
* @param page
* @return
*/
private SuccessResultList<List<UserDTO>> listPageUser(String positionId, ListPage page) {
List<String> userIds = listUserId(positionId);
if (userIds.isEmpty()) {
return new SuccessResultList<>(new ArrayList<>(), 1, 0L);
}
return userBaseService.listPageByIds(userIds, page);
}
}

View File

@ -0,0 +1,46 @@
package ink.wgink.service.position.startup;
import ink.wgink.service.position.dao.IPositionDao;
import ink.wgink.service.position.dao.IPositionUserDao;
import ink.wgink.service.position.service.IPositionUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: ServicePositionStartUp
* @Description: 职位业务
* @Author: WangGeng
* @Date: 2021/2/16 17:42
* @Version: 1.0
**/
@Component
public class ServicePositionStartUp implements ApplicationRunner {
private static final Logger LOG = LoggerFactory.getLogger(ServicePositionStartUp.class);
@Autowired
private IPositionDao positionDao;
@Autowired
private IPositionUserDao positionUserDao;
@Override
public void run(ApplicationArguments args) throws Exception {
initTable();
}
private void initTable() {
LOG.debug("创建 sys_position 表");
positionDao.createTable();
LOG.debug("创建 sys_position_user 表");
positionUserDao.createTable();
}
}

View File

@ -1,6 +1,8 @@
<?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="ink.wgink.module.position.dao.IPositionDao">
<mapper namespace="ink.wgink.service.position.dao.IPositionDao">
<cache flushInterval="3600000"/>
<resultMap id="positionDTO" type="ink.wgink.pojo.dtos.position.PositionDTO">
<id property="positionId" column="position_id"/>
@ -24,6 +26,25 @@
<result property="name" column="position_name"/>
</resultMap>
<!-- 建表 -->
<update id="createTable">
CREATE TABLE IF NOT EXISTS `sys_position` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`position_id` char(36) NOT NULL COMMENT '职位主键',
`position_parent_id` char(36) NOT NULL DEFAULT '0' COMMENT '职位父ID',
`position_name` varchar(255) NOT NULL COMMENT '职位名称',
`position_summary` varchar(255) DEFAULT NULL COMMENT '职位说明',
`position_code` varchar(255) NOT NULL COMMENT '职位编码',
`position_name_en` varchar(255) DEFAULT NULL COMMENT '英文名称',
`creator` char(36) DEFAULT NULL,
`gmt_create` datetime DEFAULT NULL,
`modifier` char(36) DEFAULT NULL,
`gmt_modified` datetime DEFAULT NULL,
`is_delete` int(2) DEFAULT '0',
PRIMARY KEY (`id`,`position_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
</update>
<!-- 新增职位 -->
<insert id="save" parameterType="map" flushCache="true">
INSERT INTO sys_position(
@ -106,7 +127,7 @@
</select>
<!-- 职位列表 -->
<select id="list" parameterType="map" resultMap="positionDTO" useCache="false">
<select id="list" parameterType="map" resultMap="positionDTO" useCache="true">
SELECT
*
FROM
@ -217,22 +238,6 @@
t1.user_id = #{userId}
</select>
<!-- 用户职位列表 -->
<select id="listUser" parameterType="map" resultMap="positionDTO" useCache="false">
SELECT
t2.*
FROM
sys_position_user t1
INNER JOIN
sys_position t2
ON
t1.position_id = t2.position_id
WHERE
t2.is_delete = 0
AND
t1.user_id = #{userId}
</select>
<!-- 统计职位 -->
<select id="count" resultType="java.lang.Integer" useCache="true">
SELECT

View File

@ -0,0 +1,85 @@
<?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="ink.wgink.service.position.dao.IPositionUserDao">
<cache flushInterval="3600000"/>
<!-- 建表 -->
<update id="createTable">
CREATE TABLE IF NOT EXISTS `sys_position_user` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`position_id` char(36) NOT NULL,
`user_id` char(36) NOT NULL,
PRIMARY KEY (`id`),
KEY `user_id_idx` (`user_id`) USING BTREE,
KEY `position_id_idx` (`position_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
</update>
<!-- 新增 -->
<insert id="save" parameterType="map" flushCache="true">
INSERT INTO sys_position_user(
position_id,
user_id
) VALUES(
#{positionId},
#{userId}
)
</insert>
<!-- 删除 -->
<delete id="delete" parameterType="map" flushCache="true">
DELETE FROM
sys_position_user
WHERE
1 = 1
<if test="positionId != null and positionId != ''">
AND
position_id = #{positionId}
</if>
<if test="userId != null and userId != ''">
AND
user_id = #{userId}
</if>
<if test="userIds != null and userIds.size > 0">
AND
user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
</delete>
<!-- 用户ID列表 -->
<select id="listUserId" parameterType="map" resultType="java.lang.String" useCache="true">
SELECT
user_id
FROM
sys_position_user
WHERE
<if test="positionId != null and positionId != ''">
position_id = #{positionId}
</if>
<if test="positionIds != null and positionIds.size > 0">
position_id IN (
<foreach collection="positionIds" index="index" open="(" separator="," close=")">
#{positionIds[${index}]}
</foreach>
)
</if>
</select>
<!-- 用户ID列表 -->
<select id="listGroupUserId" parameterType="map" resultType="java.lang.String" useCache="true">
SELECT
user_id
FROM
sys_position_user
WHERE
1 = 1
GROUP BY
user_id
</select>
</mapper>

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base href="/usercenter/">
<base th:href="${#request.getContextPath() + '/'}">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
@ -49,7 +49,7 @@
// 初始化IFrame
function initIFrame() {
$('#listContent').attr('src', top.restAjax.path('route/system/position/list.html?parentId={parentId}', [parentId]));
$('#listContent').attr('src', top.restAjax.path('route/position/list?parentId={parentId}', [parentId]));
}
// 初始化大小
function initSize() {
@ -68,7 +68,7 @@
enable: true,
autoLoad: false,
type: 'get',
url: top.restAjax.path('api/position/listztreeposition', []),
url: top.restAjax.path('api/position/listztree', []),
autoParam: ['id'],
otherParam: {},
dataFilter: function (treeId, parentNode, childNodes) {

View File

@ -1,7 +1,7 @@
<!doctype html>
<html lang="en">
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base href="/usercenter/">
<base th:href="${#request.getContextPath() + '/'}">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
@ -57,13 +57,14 @@
var admin = layui.admin;
var laydate = layui.laydate;
var parentId = top.restAjax.params(window.location.href).parentId;
var tableUrl = 'api/position/listpage?parentId={parentId}';
// 初始化表格
function initTable() {
table.render({
elem: '#dataTable',
id: 'dataTable',
url: top.restAjax.path('api/position/listpageposition?parentId={parentId}', [parentId]),
url: top.restAjax.path(tableUrl, [parentId]),
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 60,
limit: 20,
@ -73,19 +74,21 @@
pageName: 'page',
limitName: 'rows'
},
cols: [[
{type:'checkbox', fixed: 'left'},
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
{field:'users', width:100, title: '人员列表', align:'center',
templet: function(item) {
return '<button type="button" class="layui-btn layui-btn-xs" lay-event="userEvent"><i class="fa fa-users"></i> 查看</button>';
}
},
{field:'positionName', width:170, title: '职位名称', align:'center',},
{field:'positionSummary', width:170, title: '职位说明', align:'center',},
{field:'positionCode', width:170, title: '职位编码', align:'center',},
{field:'positionNameEn', width:100, title: '英文名称', align:'center',}
]],
cols: [
[
{type:'checkbox', fixed: 'left'},
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
{field:'users', width:100, title: '人员列表', align:'center',
templet: function(item) {
return '<button type="button" class="layui-btn layui-btn-xs" lay-event="userEvent"><i class="fa fa-users"></i> 查看</button>';
}
},
{field:'positionName', width:170, title: '职位名称', align:'center',},
{field:'positionSummary', width:170, title: '职位说明', align:'center',},
{field:'positionCode', width:170, title: '职位编码', align:'center',},
{field:'positionNameEn', width:100, title: '英文名称', align:'center',}
]
],
page: true,
parseData: function(data) {
return {
@ -100,7 +103,7 @@
// 重载表格
function reloadTable(currentPage) {
table.reload('dataTable', {
url: top.restAjax.path('api/position/listpageposition?parentId={parentId}', [parentId]),
url: top.restAjax.path(tableUrl, [parentId]),
where: {
keywords: $('#keywords').val(),
},
@ -110,10 +113,6 @@
height: $win.height() - 60,
});
}
function refreshTable() {
parent.common.refreshTree('leftTree');
reloadTable();
}
// 初始化日期
function initDate() {}
// 删除
@ -125,10 +124,10 @@
yes: function (index) {
top.dialog.close(index);
var layIndex;
top.restAjax.delete(top.restAjax.path('api/position/removeposition/{ids}', [ids]), {}, null, function (code, data) {
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000}, function () {
refreshTable();
});
top.restAjax.delete(top.restAjax.path('api/position/remove/{ids}', [ids]), {}, null, function (code, data) {
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
parent.common.refreshTree('leftTree');
reloadTable();
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {
@ -163,9 +162,9 @@
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/system/position/save.html?positionParentId={parentId}', [parentId]),
content: top.restAjax.path('route/position/save?positionParentId={parentId}', [parentId]),
end: function() {
refreshTable();
reloadTable();
}
});
} else if(layEvent === 'update') {
@ -181,9 +180,9 @@
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/system/position/update.html?positionId={positionId}', [checkDatas[0].positionId]),
content: top.restAjax.path('route/position/update?positionId={positionId}', [checkDatas[0].positionId]),
end: function() {
refreshTable();
reloadTable();
}
});
}
@ -207,8 +206,8 @@
var layEvent = obj.event;
if(layEvent === 'userEvent') {
top.dialog.open({
url: top.restAjax.path('route/system/user/list-position-user.html?positionId={positionId}', [data.positionId]),
title: '职位用户列表',
url: top.restAjax.path('route/position/user/list?positionId={positionId}', [data.positionId]),
title: '【'+ data.positionName +'】用户列表',
width: '800px',
height: '500px',
onClose: function() {}

View File

@ -1,7 +1,7 @@
<!doctype html>
<html lang="en">
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base href="/usercenter/">
<base th:href="${#request.getContextPath() + '/'}">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
@ -85,7 +85,7 @@
return;
}
var loadLayerIndex;
top.restAjax.get(top.restAjax.path('api/position/getposition/{positionParentId}', [positionParentId]), {}, null, function(code, data) {
top.restAjax.get(top.restAjax.path('api/position/get/{positionParentId}', [positionParentId]), {}, null, function(code, data) {
form.val('dataForm', {
positionParentName: data.positionName
});
@ -105,7 +105,8 @@
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.post(top.restAjax.path('api/position/saveposition', []), formData.field, null, function(code, data) {
top.restAjax.post(top.restAjax.path('api/position/save', []), formData.field, null, function(code, data) {
parent.parent.common.refreshTree('leftTree');
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],

View File

@ -1,7 +1,7 @@
<!doctype html>
<html lang="en">
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base href="/usercenter/">
<base th:href="${#request.getContextPath() + '/'}">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
@ -75,7 +75,7 @@
// 初始化
function initData() {
var loadLayerIndex;
top.restAjax.get(top.restAjax.path('api/position/getposition/{positionId}', [positionId]), {}, null, function(code, data) {
top.restAjax.get(top.restAjax.path('api/position/get/{positionId}', [positionId]), {}, null, function(code, data) {
form.val('dataForm', {
positionParentName: data.positionParentName == '' ? '根节点' : data.positionParentName,
positionParentId: data.positionParentId,
@ -99,7 +99,8 @@
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.put(top.restAjax.path('api/position/updateposition/{positionId}', [positionId]), formData.field, null, function(code, data) {
top.restAjax.put(top.restAjax.path('api/position/update/{positionId}', [positionId]), formData.field, null, function(code, data) {
parent.parent.common.refreshTree('leftTree');
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],

View File

@ -0,0 +1,265 @@
<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#request.getContextPath() + '/'}">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein" style="padding: 0;">
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
<div class="layui-inline">
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
</div>
<button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索
</button>
</div>
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
<!-- 表头按钮组 -->
<script type="text/html" id="headerToolBar">
<div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
<i class="fa fa-lg fa-plus"></i> 新增
</button>
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="removeEvent">
<i class="fa fa-lg fa-trash"></i> 删除
</button>
</div>
</script>
</div>
</div>
</div>
</div>
</div>
<input id="selectedUserIds" type="hidden"/>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'table', 'common'], function() {
var $ = layui.$;
var $win = $(window);
var table = layui.table;
var admin = layui.admin;
var common = layui.common;
var positionId = top.restAjax.params(window.location.href).positionId;
var resizeTimeout = null;
var tableUrl = 'api/position/user/listpage/{positionId}';
// 初始化表格
function initTable() {
table.render({
elem: '#dataTable',
id: 'dataTable',
url: top.restAjax.path(tableUrl, [positionId]),
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 60,
limit: 20,
limits: [20, 40, 60, 80, 100, 200],
toolbar: '#headerToolBar',
request: {
pageName: 'page',
limitName: 'rows'
},
cols: [
[
{type:'checkbox', fixed: 'left'},
{field:'rowNum', width:80, title: '序号', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
{field:'userUsername', width:140, title: '用户名', align:'center'},
{field:'userName', width:140, title: '昵称', align:'center'},
{field:'userPhone', width:140, title: '手机', align:'center',
templet: function(item) {
if(!item.userPhone) {
return '-';
}
return item.userPhone;
}
},
{field:'userEmail', width: 160, title: '邮箱', align:'center',
templet: function(item) {
if(!item.userEmail) {
return '-';
}
return item.userEmail;
}
},
{field:'userState', width:80, title: '状态', align:'center',
templet: function(item) {
var value;
switch (item.userState) {
case 1:
value = '冻结';
break;
case 2:
value = '锁定';
break;
default:
value = '正常';
}
return value;
}
},
]
],
page: true,
parseData: function(data) {
return {
'code': 0,
'msg': '',
'count': data.total,
'data': data.rows
};
}
});
}
// 重载表格
function reloadTable(currentPage) {
table.reload('dataTable', {
url: top.restAjax.path(tableUrl, [positionId]),
where: {
keywords: $('#keywords').val(),
},
page: {
curr: currentPage
},
height: $win.height() - 60,
});
}
// 删除
function removeData(ids) {
top.dialog.msg(top.dataMessage.delete, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function(index) {
top.dialog.close(index);
var layIndex;
top.restAjax.delete(top.restAjax.path('api/position/user/remove/{positionId}/{ids}', [positionId, ids]), {}, null, function(code, data) {
top.dialog.msg(top.dataMessage.deleteSuccess);
var deleteUserIds = ids.split('_');
var selectedUserIds = $('#selectedUserIds').val().split('_');
var tempIds = common.resultIdsOfDeleteIds(deleteUserIds, selectedUserIds);
$('#selectedUserIds').val(tempIds);
reloadTable();
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(layIndex);
});
}
});
}
// 初始化角色用户ID列表
function initSelectUserIds() {
var layIndex;
top.restAjax.get(top.restAjax.path('api/position/user/listuserid/{groupId}', [positionId]), {}, null, function(code, data) {
var selectedUserIds = '';
for(var i = 0, item; item = data[i++]; ) {
if(selectedUserIds.length > 0) {
selectedUserIds += '_';
}
selectedUserIds += item;
}
$('#selectedUserIds').val(selectedUserIds);
initTable();
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
layIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(layIndex);
});
}
initSelectUserIds();
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
reloadTable();
}, 500);
});
// 事件 - 搜索
$(document).on('click', '#search', function() {
reloadTable(1);
});
// 事件 - 增删
table.on('toolbar(dataTable)', function(obj) {
var layEvent = obj.event;
var checkStatus = table.checkStatus('dataTable');
var checkDatas = checkStatus.data;
if(layEvent === 'saveEvent') {
top.dialog.dialogData.selectedUserIds = $('#selectedUserIds').val();
top.dialog.open({
url: top.restAjax.path('route/department/user/select-user', []),
title: '选择组织部门人员',
width: '500px',
height: '500px',
onClose: function() {
var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers;
if(selectedUsers != null && selectedUsers.length > 0) {
var ids = [];
for (var i = 0, item; item = selectedUsers[i++];) {
ids.push(item.userId);
}
top.dialog.msg(top.dataMessage.update, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
yes: function (index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.put(top.restAjax.path('api/group/user/update/{groupId}', [positionId]), {
ids: ids
}, null, function (code, data) {
top.dialog.msg(top.dataMessage.updated);
initSelectUserIds();
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {
loadLayerIndex = top.dialog.msg(top.dataMessage.updating, {
icon: 16,
time: 0,
shade: 0.3
});
}, function () {
top.dialog.close(loadLayerIndex);
});
},
});
}
}
})
} else if(layEvent === 'removeEvent') {
if(checkDatas.length === 0) {
top.dialog.msg(top.dataMessage.table.selectDelete);
} else {
var ids = '';
for(var i = 0, item; item = checkDatas[i++];) {
if(i > 1) {
ids += '_';
}
ids += item.userId;
}
removeData(ids);
}
}
});
});
</script>
</body>
</html>