yangys
2024-09-04 04c57331cf84c8f606c2838dcb6fe5463fb9b68c
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
package com.qianwen.smartman.modules.auth.endpoint;
 
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.qianwen.smartman.common.cache.RegionCache;
import com.qianwen.core.log.annotation.ApiLog;
import com.qianwen.core.tenant.annotation.NonDS;
import com.qianwen.core.tool.api.R;
import com.qianwen.core.tool.support.Kv;
import com.qianwen.smartman.modules.auth.service.OuterAppScanService;
import com.qianwen.smartman.modules.sync.service.IDingSyncService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
@RequestMapping({"blade-auth"})
@Api(value = "第三方应用扫码登录", tags = {"第三方应用扫码登录"})
@RestController
@NonDS
@ApiSort(RegionCache.VILLAGE_LEVEL)
public class OuterAppScanEndpoint {
    private final IDingSyncService dingSyncService;
    private final OuterAppScanService outerAppScanService;
 
    public OuterAppScanEndpoint(final IDingSyncService dingSyncService, final OuterAppScanService outerAppScanService) {
        this.dingSyncService = dingSyncService;
        this.outerAppScanService = outerAppScanService;
    }
 
    @ApiLog("员工钉钉扫码登录回调接口")
    @GetMapping({"/ding/token"})
    @ApiOperation(value = "员工钉钉扫码登录回调接口", notes = "传入扫码回调code")
    public R<Kv> token(@RequestParam("code") String code) {
        String userId = this.dingSyncService.getDingUserId(code);
        return this.outerAppScanService.loginByOuterUserId(userId);
    }
 
    @ApiLog("员工企业微信扫码登录回调接口")
    @GetMapping({"/qy-wechat/token"})
    @ApiOperation(value = "员工企业微信扫码登录回调接口", notes = "传入扫码授权code")
    public R<Kv> scanLogin(@RequestParam("clientId") String clientId, @RequestParam("code") String authCode) {
        return this.outerAppScanService.qyScanLogin(clientId, authCode);
    }
}