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
package cn.iocoder.yudao.module.wxcp.controller.admin.member;
 
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.wxcp.controller.admin.member.vo.WxCpDepartmentRespVO;
import cn.iocoder.yudao.module.wxcp.controller.admin.member.vo.WxCpMemberRespVO;
import cn.iocoder.yudao.module.wxcp.service.member.WxCpMemberService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
/**
 * 管理后台 - 企业微信通讯录(成员与部门)
 *
 * 数据实时取自企业微信,可用于推送时挑选目标成员/部门
 *
 * @author 超级管理员
 */
@Tag(name = "管理后台 - 企业微信通讯录")
@RestController
@RequestMapping("/wxcp/member")
@Validated
public class WxCpMemberController {
 
    @Resource
    private WxCpMemberService memberService;
 
    @GetMapping("/department/tree")
    @Operation(summary = "获得部门树")
    @PreAuthorize("@ss.hasPermission('wxcp:member:query')")
    public CommonResult<List<WxCpDepartmentRespVO>> getDepartmentTree() {
        return success(memberService.getDepartmentTree());
    }
 
    @GetMapping("/department/list")
    @Operation(summary = "获得部门平铺列表", description = "便于做下拉选择,无需自行拍平树")
    @PreAuthorize("@ss.hasPermission('wxcp:member:query')")
    public CommonResult<List<WxCpDepartmentRespVO>> getDepartmentList() {
        return success(memberService.getDepartmentList());
    }
 
    @GetMapping("/list")
    @Operation(summary = "获得成员列表")
    @Parameter(name = "departmentId", description = "部门ID,不传取根部门")
    @Parameter(name = "fetchChild", description = "是否包含子部门成员,默认 true")
    @PreAuthorize("@ss.hasPermission('wxcp:member:query')")
    public CommonResult<List<WxCpMemberRespVO>> getMemberList(
            @RequestParam(value = "departmentId", required = false) Long departmentId,
            @RequestParam(value = "fetchChild", required = false) Boolean fetchChild) {
        return success(memberService.getMemberList(departmentId, fetchChild));
    }
 
}