|
@@ -1,6 +1,7 @@
|
|
|
package com.qunzhixinxi.hnqz.admin.controller;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -30,11 +31,14 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 团队管理控制层
|
|
@@ -136,6 +140,7 @@ public class WmTeamController {
|
|
|
|
|
|
/**
|
|
|
* TODO
|
|
|
+ *
|
|
|
* @param teamExcelModelList
|
|
|
* @return
|
|
|
*/
|
|
@@ -153,7 +158,7 @@ public class WmTeamController {
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/{id}")
|
|
|
- public R<?> getById(@PathVariable("id") Integer id) {
|
|
|
+ public R<WmTeam> getById(@PathVariable("id") Integer id) {
|
|
|
WmTeam team = wmTeamService.getById(id);
|
|
|
if (team != null) {
|
|
|
if (team.getLeader() != null) {
|
|
@@ -192,6 +197,58 @@ public class WmTeamController {
|
|
|
return R.ok(teamManagePage);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据deptId查询团队列表
|
|
|
+ *
|
|
|
+ * @param page
|
|
|
+ * @param deptId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/list-by-dept")
|
|
|
+ public R<IPage<WmTeam>> list(Page<WmTeam> page, @RequestParam(value = "deptId", required = false) Integer deptId) {
|
|
|
+ if (deptId == null) {
|
|
|
+ return R.ok(page);
|
|
|
+ }
|
|
|
+ Page<WmTeam> teamManagePage = wmTeamService.page(page, Wrappers.<WmTeam>lambdaQuery()
|
|
|
+ .eq(WmTeam::getDeptId, deptId)
|
|
|
+ .eq(WmTeam::getDelFlag, DelEnum.NOT_DEL.val()));
|
|
|
+ teamManagePage.getRecords().forEach(wmTeamManage -> {
|
|
|
+ if (wmTeamManage.getLeader() != null) {
|
|
|
+ SysUser leaderUser = sysUserMapper.selectById(wmTeamManage.getLeader());
|
|
|
+ wmTeamManage.setLeaderName(leaderUser.getRealname());
|
|
|
+ }
|
|
|
+ if (ArrayUtil.isNotEmpty(wmTeamManage.getMember())) {
|
|
|
+ List<SysUser> userList = sysUserMapper.selectBatchIds(CollectionUtil.toList(wmTeamManage.getMember()));
|
|
|
+ wmTeamManage.setMemberName(userList.stream().map(SysUser::getRealname).toArray(String[]::new));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return R.ok(teamManagePage);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询团队名称
|
|
|
+ *
|
|
|
+ * @param deptId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/list-team-name/{deptId}")
|
|
|
+ public R<?> listTeamNameByDeptId(@PathVariable("deptId") Integer deptId) {
|
|
|
+ List<WmTeam> list = wmTeamService.list(Wrappers.<WmTeam>lambdaQuery()
|
|
|
+ .eq(WmTeam::getDeptId, deptId)
|
|
|
+ .eq(WmTeam::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
+ .eq(WmTeam::getEnableFlag, EnableEnum.ENABLE.val()));
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
+ List<Map<String, Object>> mapList = list.stream().map(wmTeam -> {
|
|
|
+ Map<String, Object> teamMap = MapUtil.newHashMap(2);
|
|
|
+ teamMap.put("name", wmTeam.getName());
|
|
|
+ teamMap.put("id", wmTeam.getId());
|
|
|
+ return teamMap;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return R.ok(mapList);
|
|
|
+ }
|
|
|
+ return R.ok(new ArrayList<>());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询团队可选择人员
|
|
|
*
|
|
@@ -199,7 +256,7 @@ public class WmTeamController {
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/list-selectable-user")
|
|
|
- public R<?> listSelectableUser(Integer teamId) {
|
|
|
+ public R<Map<String, Object>> listSelectableUser(Integer teamId) {
|
|
|
Map<String, Object> map = wmTeamService.listSelectableUser(teamId);
|
|
|
return R.ok(map);
|
|
|
}
|