郑永安
2023-06-19 7a6abd05683528032687c75e80e0bd2030a3e46c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.gkhy.safePlatform.account.controller;
 
 
import com.alibaba.fastjson.JSONObject;
import com.gkhy.safePlatform.account.model.annotation.CommonLogEnable;
import com.gkhy.safePlatform.account.model.dto.req.GroupAddDTO;
import com.gkhy.safePlatform.account.model.dto.req.GroupModDTO;
import com.gkhy.safePlatform.account.model.dto.resp.*;
import com.gkhy.safePlatform.account.model.query.GroupMemberPageQuery;
import com.gkhy.safePlatform.account.model.query.GroupPageQuery;
import com.gkhy.safePlatform.account.model.query.GroupQuery;
import com.gkhy.safePlatform.account.model.query.GroupScheduleQuery;
import com.gkhy.safePlatform.account.service.GroupService;
import com.gkhy.safePlatform.account.service.GroupStrategyTimeTableService;
import com.gkhy.safePlatform.commons.co.ContextCacheUser;
import com.gkhy.safePlatform.commons.enums.Module;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.query.PageQuery;
import com.gkhy.safePlatform.commons.utils.PageUtils;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
/**
* @Description: 班组
*/
 
@RestController
@RequestMapping("/schedule/group")
public class GroupController  {
 
    @Autowired
    private GroupService groupService;
 
 
 
    @RequestMapping(value = "/page/list",method = RequestMethod.POST)
    public ResultVO<List<GroupPageRespDTO>> listGroupByPage(Authentication authentication, @RequestBody PageQuery<GroupPageQuery> query){
        PageUtils.checkCheck(query);
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        return groupService.listGroupInfoByPage(currentUser, query);
    }
 
 
 
    @RequestMapping(value = "/list",method = RequestMethod.POST)
    public ResultVO<List<GroupRespDTO>> listGroup(Authentication authentication,@RequestBody GroupQuery query){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        List<GroupRespDTO> groupList = groupService.listGroupInfo(currentUser, query);
        return new ResultVO<>(ResultCodes.OK,groupList);
    }
 
    /**
    * @Description: 成员
    */
    @RequestMapping(value = "/member/list",method = RequestMethod.GET)
    public ResultVO<List<GroupMemberRespDTO>> listMembers(Authentication authentication, Long groupId){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        List<GroupMemberRespDTO> members = groupService.listGroupMembersByGroupId(currentUser,groupId);
        return new ResultVO<>(ResultCodes.OK,members);
    }
 
    /**
     * @Description: 成员分页
     */
    @RequestMapping(value = "/member/page/list", method = RequestMethod.POST)
    public ResultVO<List<GroupMemberPageRespDTO>> listMembersByPage(Authentication authentication,@RequestBody PageQuery<GroupMemberPageQuery> query) {
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        PageUtils.checkCheck(query);
        return groupService.listGroupMembersByPage(currentUser, query);
    }
 
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    @CommonLogEnable(module = Module.ACCOUNT,content = "新增班组")
    public ResultVO<String> addGroup(Authentication authentication,@RequestBody GroupAddDTO groupAddDTO) {
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        groupService.saveGroupInfo(currentUser,groupAddDTO);
        return new ResultVO<>(ResultCodes.OK);
    }
 
 
    @RequestMapping(value = "/mod",method = RequestMethod.POST)
    @CommonLogEnable(module = Module.ACCOUNT,content = "修改班组")
    public ResultVO<String> modGroup(Authentication authentication,@RequestBody GroupModDTO groupModDTO) {
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        groupService.modGroupInfo(currentUser,groupModDTO);
        return new ResultVO<>(ResultCodes.OK);
    }
 
    @RequestMapping(value = "/del",method = RequestMethod.POST)
    @CommonLogEnable(module = Module.ACCOUNT,content = "删除班组")
    public ResultVO<String> delGroup(Authentication authentication, @RequestBody JSONObject json) {
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        Long groupId = json.getLong("groupId");
        groupService.delGroupInfo(currentUser,groupId);
        return new ResultVO<>(ResultCodes.OK);
    }
 
 
    /**
    * @Description: 获取班组的作息表
    */
    @RequestMapping(value = "/schedule", method = RequestMethod.POST)
    public ResultVO<GroupTimeTableRespDTO> getTimeTable(Authentication authentication, @RequestBody GroupScheduleQuery groupScheduleQuery) {
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        GroupTimeTableRespDTO timeTableInfo = groupService.getTimeTableInfo(currentUser, groupScheduleQuery);
        return new ResultVO<>(ResultCodes.OK,timeTableInfo);
    }
 
}