yangys
2024-03-27 e48aa2ac8dea1be5db11c63edf0b912c4ad5ce65
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
package com.qianwen.smartman.modules.sync.controller;
 
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import com.qianwen.smartman.common.constant.CommonConstant;
import com.qianwen.core.boot.ctrl.BladeController;
import com.qianwen.core.tool.api.R;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.modules.sync.constant.OuterAppConfigConstant;
import com.qianwen.smartman.modules.sync.convert.OuterAppConfigConvert;
import com.qianwen.smartman.modules.sync.entity.OuterAppConfig;
import com.qianwen.smartman.modules.sync.service.IDingSyncService;
import com.qianwen.smartman.modules.sync.service.IOuterAppConfigService;
import com.qianwen.smartman.modules.sync.service.IWechatSyncService;
import com.qianwen.smartman.modules.sync.vo.OuterAppConfigVO;
import com.qianwen.smartman.modules.sync.vo.OuterAppStatusVO;
import com.qianwen.smartman.modules.sync.vo.SyncResultVO;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
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 springfox.documentation.annotations.ApiIgnore;
 
@Api(value = "第三方应用配置管理", tags = {"第三方应用配置管理"})
@RequestMapping({"blade-sync/outer-app-config"})
@RestController
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/sync/controller/OuterAppConfigController.class */
public class OuterAppConfigController extends BladeController {
    private IOuterAppConfigService outerAppConfigService;
    private final IWechatSyncService wechatSyncService;
    private final IDingSyncService dingSyncService;
 
    public OuterAppConfigController(final IOuterAppConfigService outerAppConfigService, final IWechatSyncService wechatSyncService, final IDingSyncService dingSyncService) {
        this.outerAppConfigService = outerAppConfigService;
        this.wechatSyncService = wechatSyncService;
        this.dingSyncService = dingSyncService;
    }
 
    @ApiOperationSupport(order = 1)
    @GetMapping({"/appStatus"})
    @ApiOperation(value = "用于首页第三方应用判断", notes = "")
    public R getAppStatus() {
        OuterAppConfig outerAppConfigDing = this.outerAppConfigService.getAppConfig(OuterAppConfigConstant.DING);
        OuterAppConfig outerAppConfigQy = this.outerAppConfigService.getAppConfig(OuterAppConfigConstant.QY_WECHAT);
        OuterAppStatusVO result = new OuterAppStatusVO();
        if (Func.isNotEmpty(outerAppConfigDing) && outerAppConfigDing.getStatus().equals(CommonConstant.ENABLE)) {
            result.setDingStatus(true);
            result.setDingAppkey(outerAppConfigDing.getDingAppKey());
            result.setDomain(outerAppConfigDing.getDomainUrl());
        }
        if (Func.isNotEmpty(outerAppConfigQy) && outerAppConfigQy.getStatus().equals(CommonConstant.ENABLE)) {
            result.setWxStatus(true);
            result.setDomain(outerAppConfigQy.getDomainUrl());
        }
        return R.data(result);
    }
 
    @ApiOperationSupport(order = 1)
    @GetMapping({"/get/{type}"})
    @ApiOperation(value = "根据类型获取配置详情", notes = "传入类型")
    public R<OuterAppConfigVO> detail(@PathVariable Integer type) {
        OuterAppConfig outerAppConfig = this.outerAppConfigService.getAppConfig(type);
        return R.data(OuterAppConfigConvert.INSTANCE.convert(outerAppConfig));
    }
 
    @ApiOperationSupport(order = 2)
    @GetMapping({"/list"})
    @ApiOperation(value = "应用配置列表", notes = "传入map")
    public R<List<OuterAppConfigVO>> list(@RequestParam @ApiIgnore Map<String, Object> params) {
        return R.data(this.outerAppConfigService.getConfigs(params));
    }
 
    @PostMapping({"/submit"})
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "配置新增或更新", notes = "传入outerAppConfigVO")
    public R<SyncResultVO> submit(@Valid @RequestBody OuterAppConfigVO outerAppConfigVO) {
        this.outerAppConfigService.submit(outerAppConfigVO);
        if (outerAppConfigVO.getAppType().equals(OuterAppConfigConstant.QY_WECHAT)) {
            return R.data(this.wechatSyncService.syncOrganization());
        }
        return R.data(this.dingSyncService.syncImmediately());
    }
 
    @ApiOperationSupport(order = 4)
    @GetMapping({"/unbind/{type}"})
    @ApiOperation(value = "解绑应用", notes = "传入type类型")
    public R unbind(@PathVariable Integer type) {
        return R.data(this.outerAppConfigService.unbind(type));
    }
 
    @DeleteMapping({"/remove"})
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "配置删除", notes = "传入ids")
    public R remove(@ApiParam(value = "主键", required = true) @RequestBody List<Long> ids) {
        if (ids.isEmpty()) {
            return R.status(false);
        }
        return R.status(this.outerAppConfigService.removeByIds(ids));
    }
}