yangys
2024-05-07 ec2552d891e163bd9054e0554188afc575bcdb70
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
package com.qianwen.smartman.modules.sync.controller;
 
import cn.hutool.json.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.validation.constraints.NotNull;
import com.qianwen.core.tool.api.R;
import com.qianwen.smartman.modules.sync.constant.QyWechatConstant;
import com.qianwen.smartman.modules.sync.service.IDingSyncService;
import com.qianwen.smartman.modules.sync.service.IWechatSyncService;
import com.qianwen.smartman.modules.sync.vo.SyncResultVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
@RequestMapping({"blade-sync/wechat"})
@Api(tags = {"企业微信同步相关接口"})
@RestController
public class QyWechatSyncController {
    private final IWechatSyncService wechatSyncService;
    private final IDingSyncService dingSyncService;
 
    public QyWechatSyncController(final IWechatSyncService wechatSyncService, final IDingSyncService dingSyncService) {
        this.wechatSyncService = wechatSyncService;
        this.dingSyncService = dingSyncService;
    }
 
    @PostMapping({"/sync"})
    @ApiOperation("同步组织架构")
    public R<SyncResultVO> synchronizeOrganization() {
        return R.data(this.wechatSyncService.syncOrganization());
    }
 
    @GetMapping({"/scan"})
    @ApiOperation("扫码绑定")
    public R<Boolean> scanCodeBind(@RequestParam("code") String code, @RequestParam("clientId") String clientId, @RequestParam("state") @NotNull String empId) {
        return this.wechatSyncService.scanCodeBind(code, clientId, empId);
    }
 
    @GetMapping({"/generate"})
    @ApiOperation("生成二维码")
    public R<JSONObject> generateCode(@RequestParam("clientId") String clientId, @RequestParam("type") Integer type, @RequestParam(value = "empId", required = false) Long empId) {
        return R.data(this.wechatSyncService.generateCode(clientId, type, empId));
    }
 
    @GetMapping({"/unbind"})
    @ApiOperation("解除员工与企业微信的绑定")
    public R<Boolean> unbind(@RequestParam("id") String id) {
        return R.status(this.dingSyncService.unbind(Long.valueOf(id), QyWechatConstant.QY_SOURCE).booleanValue());
    }
}