新增部门人员接口

This commit is contained in:
wanggeng 2021-11-01 11:26:17 +08:00
parent db892fa00a
commit f4aca5806a
6 changed files with 292 additions and 4 deletions

View File

@ -73,6 +73,18 @@ public class DepartmentUserController extends DefaultBaseController {
return new SuccessResult();
}
@ApiOperation(value = "组织部门用户列表", notes = "组织部门用户列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list")
public List<DepartmentUserDTO> list() {
Map<String, Object> params = requestParams();
return departmentUserService.list(params);
}
@ApiOperation(value = "组织部门用户列表", notes = "组织部门用户列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),

View File

@ -0,0 +1,136 @@
package ink.wgink.service.department.controller.app.api;
import ink.wgink.common.base.DefaultBaseController;
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.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResultData;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.service.department.service.IDepartmentService;
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.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @ClassName: DepartmentController
* @Description: 组织部门
* @Author: wenc
* @Date: 2019/1/8 7:23 PM
* @Version: 1.0
**/
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "组织部门")
@RestController
@RequestMapping(ISystemConstant.APP_PREFIX + "/department")
public class DepartmentAppController extends DefaultBaseController {
@Autowired
private IDepartmentService departmentService;
@ApiOperation(value = "组织部门列表", notes = "组织部门列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "departmentParentId", value = "组织部门上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list")
public List<DepartmentDTO> list(@RequestHeader("token") String token) {
Map<String, Object> params = requestParams();
return departmentService.list(params);
}
@ApiOperation(value = "组织部门列表", notes = "组织部门列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "departmentParentId", value = "组织部门上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-all/{departmentParentId}")
public List<DepartmentDTO> listAll(@RequestHeader("token") String token,
@PathVariable("departmentParentId") String departmentParentId) {
Map<String, Object> params = new HashMap<>(0);
params.put("departmentParentId", departmentParentId);
return departmentService.listAll(params);
}
@ApiOperation(value = "组织部门zTree列表", notes = "组织部门zTree列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "id", value = "父ID", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listztree")
public List<ZTreeDTO> listZTree(@RequestHeader("token") String token) {
Map<String, Object> params = requestParams();
String departmentParentId = "0";
if (!StringUtils.isBlank(params.get("id") == null ? null : params.get("id").toString())) {
departmentParentId = params.get("id").toString();
}
return departmentService.listZTree(departmentParentId, params);
}
@ApiOperation(value = "组织部门详情", notes = "组织部门详情接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("get/{departmentId}")
public DepartmentDTO get(@RequestHeader("token") String token,
@PathVariable("departmentId") String departmentId) {
return departmentService.get(departmentId);
}
@ApiOperation(value = "组织部门分页列表", notes = "组织部门分页列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "parentId", value = "上级ID", paramType = "query", 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"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpage")
public SuccessResultList<List<DepartmentDTO>> listPage(@RequestHeader("token") String token,
ListPage page) {
Map<String, Object> params = requestParams();
String departmentParentId = "0";
if (!StringUtils.isBlank(params.get("parentId") == null ? null : params.get("parentId").toString())) {
departmentParentId = params.get("parentId").toString();
}
params.put("departmentParentId", departmentParentId);
page.setParams(params);
return departmentService.listPage(page);
}
@ApiOperation(value = "组织部门获得同一级部门数量(按部门名称)", notes = "组织部门获得同一级部门数量(按部门名称)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "departmentParentId", value = "上级部门ID", paramType = "path"),
@ApiImplicitParam(name = "departmentName", value = "上级部门ID", paramType = "path"),
@ApiImplicitParam(name = "noDepartmentId", value = "不统计的部门ID", paramType = "query"),
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("countbyparentidandname/{departmentParentId}/{departmentName}")
public SuccessResultData<Integer> countByParentIdAndName(@RequestHeader("token") String token,
@PathVariable("departmentParentId") String departmentParentId,
@PathVariable("departmentName") String departmentName,
@RequestParam(name = "noDepartmentId", required = false) String noDepartmentId) throws UnsupportedEncodingException {
Map<String, Object> params = getParams();
params.put("departmentParentId", departmentParentId);
params.put("departmentName", URLDecoder.decode(departmentName, "UTF-8"));
params.put("noDepartmentId", noDepartmentId);
return new SuccessResultData<>(departmentService.count(params));
}
}

View File

@ -0,0 +1,91 @@
package ink.wgink.service.department.controller.app.api;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.service.department.service.IDepartmentUserService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: DepartmentUserController
* @Description: 组织部门用户
* @Author: wanggeng
* @Date: 2021/1/28 4:19 下午
* @Version: 1.0
*/
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "组织部门用户")
@RestController
@RequestMapping(ISystemConstant.APP_PREFIX + "/department/user")
public class DepartmentUserAppController extends DefaultBaseController {
@Autowired
private IDepartmentUserService departmentUserService;
@ApiOperation(value = "组织部门用户列表", notes = "组织部门用户列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-with-user")
public List<DepartmentUserDTO> listWithUser(@RequestHeader("token") String token) {
Map<String, Object> params = requestParams();
return departmentUserService.listWithUser(params);
}
@ApiOperation(value = "组织部门用户列表", notes = "组织部门用户列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
@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")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpage/{departmentId}")
public SuccessResultList<List<DepartmentUserDTO>> listPage(@RequestHeader("token") String token,
@PathVariable("departmentId") String departmentId, ListPage page) {
Map<String, Object> params = requestParams();
page.setParams(params);
return departmentUserService.listPage(departmentId, page);
}
@ApiOperation(value = "组织部门用户列表", notes = "组织部门用户列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list/{departmentId}")
public List<DepartmentUserDTO> list(@RequestHeader("token") String token,
@PathVariable("departmentId") String departmentId) {
Map<String, Object> params = requestParams();
return departmentUserService.list(departmentId, params);
}
@ApiOperation(value = "组织部门用户ID列表", notes = "组织部门用户ID列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listuserid/{departmentId}")
public List<String> listUserId(@RequestHeader("token") String token,
@PathVariable("departmentId") String departmentId) {
return departmentUserService.listUserId(departmentId);
}
}

View File

@ -2,10 +2,12 @@ package ink.wgink.service.department.service;
import ink.wgink.interfaces.department.IDepartmentUserBaseService;
import ink.wgink.pojo.dtos.department.DepartmentSimpleDTO;
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
import ink.wgink.pojo.pos.DepartmentPO;
import ink.wgink.service.department.pojo.vos.DepartmentUserSortVO;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
@ -85,4 +87,11 @@ public interface IDepartmentUserService extends IDepartmentUserBaseService {
*/
List<DepartmentSimpleDTO> listSimple(List<DepartmentPO> departmentPOs);
/**
* 部门用户列表
*
* @param params
* @return
*/
List<DepartmentUserDTO> listWithUser(Map<String, Object> params);
}

View File

@ -19,9 +19,7 @@ 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.List;
import java.util.Map;
import java.util.*;
/**
* When you feel like quitting. Think about why you started
@ -151,6 +149,13 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe
return departmentSimpleDTOs;
}
@Override
public List<DepartmentUserDTO> listWithUser(Map<String, Object> params) {
List<DepartmentUserDTO> departmentUserDTOs = list(params);
setUser(departmentUserDTOs);
return departmentUserDTOs;
}
@Override
public List<DepartmentUserDTO> list(Map<String, Object> params) {
return departmentUserDao.list(params);
@ -360,4 +365,28 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe
return departmentUserDTOs;
}
/**
* 设置用户
*
* @param departmentUserDTOs
*/
private void setUser(List<DepartmentUserDTO> departmentUserDTOs) {
if (departmentUserDTOs.isEmpty()) {
return;
}
Set<String> userIdSet = new HashSet<>();
for (DepartmentUserDTO hasDepartmentUserId : departmentUserDTOs) {
userIdSet.add(hasDepartmentUserId.getUserId());
}
List<UserDTO> userDTOs = userBaseService.listByUserIds(new ArrayList<>(userIdSet));
for (DepartmentUserDTO departmentUserDTO : departmentUserDTOs) {
for (UserDTO userDTO : userDTOs) {
if (StringUtils.equals(departmentUserDTO.getUserId(), userDTO.getUserId())) {
departmentUserDTO.setUser(userDTO);
break;
}
}
}
}
}

View File

@ -103,8 +103,19 @@
</foreach>
</if>
</where>
<if test="order != null and order != ''">
ORDER BY
user_sort
<trim suffixOverrides=",">
<if test="order == 'userSort'">
user_sort <if test="sort != null and sort != ''"><if test="sort == 'asc'">ASC</if><if test="sort == 'desc'">DESC</if></if>,
</if>
</trim>
<trim suffixOverrides=",">
<if test="order == 'userSort'">
user_sort <if test="sort != null and sort != ''"><if test="sort == 'asc'">ASC</if><if test="sort == 'desc'">DESC</if></if>,
</if>
</trim>
</if>
</select>
<!-- 用户ID列表 -->