yangys
2024-03-31 53c8d3e3bd3596132b362f20e52aef380d493a84
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package com.qianwen.smartman.modules.system.controller;
 
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.lang.invoke.SerializedLambda;
import java.util.List;
import javax.validation.Valid;
import com.qianwen.smartman.common.cache.RegionCache;
import com.qianwen.smartman.common.constant.ExtCacheConstant;
import com.qianwen.core.boot.ctrl.BladeController;
import com.qianwen.core.cache.utils.CacheUtil;
import com.qianwen.core.mp.support.Condition;
import com.qianwen.core.mp.support.Query;
import com.qianwen.core.scanner.modular.annotation.GetResource;
import com.qianwen.core.scanner.modular.annotation.PostResource;
import com.qianwen.core.scanner.modular.model.ResourceDefinition;
import com.qianwen.core.scanner.modular.stereotype.ApiResource;
import com.qianwen.core.secure.annotation.PreAuth;
import com.qianwen.core.tenant.annotation.NonDS;
import com.qianwen.core.tool.api.R;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.modules.system.entity.ApiScope;
import com.qianwen.smartman.modules.system.mapper.ResourceDefinitionMapper;
import com.qianwen.smartman.modules.system.service.IApiScopeService;
import com.qianwen.smartman.modules.system.vo.ApiScopeVO;
import com.qianwen.smartman.modules.system.wrapper.ApiScopeWrapper;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
@Api(value = "接口权限", tags = {"接口权限"})
@RestController
@ApiResource({"blade-system/api-scope"})
@NonDS
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/system/controller/ApiScopeController.class */
public class ApiScopeController extends BladeController {
    private final IApiScopeService apiScopeService;
    private final ResourceDefinitionMapper resourceDefinitionMapper;
 
    private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) {
        String implMethodName = lambda.getImplMethodName();
        boolean z = true;
        switch (implMethodName.hashCode()) {
            case -75622813:
                if (implMethodName.equals("getCode")) {
                    z = false;
                    break;
                }
                break;
        }
        switch (z) {
            case false:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/scanner/modular/model/ResourceDefinition") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getCode();
                    };
                }
                break;
        }
        throw new IllegalArgumentException("Invalid lambda deserialization");
    }
 
    public ApiScopeController(final IApiScopeService apiScopeService, final ResourceDefinitionMapper resourceDefinitionMapper) {
        this.apiScopeService = apiScopeService;
        this.resourceDefinitionMapper = resourceDefinitionMapper;
    }
 
    @ApiOperationSupport(order = 1)
    @GetResource({"/detail"})
    @ApiOperation(value = "详情", notes = "传入dataScope")
    public R<ApiScope> detail(ApiScope dataScope) {
        ApiScope detail = (ApiScope) this.apiScopeService.getOne(Condition.getQueryWrapper(dataScope));
        return R.data(detail);
    }
 
    @ApiOperationSupport(order = 2)
    @GetResource({"/list"})
    @ApiOperation(value = "分页", notes = "传入dataScope")
    @PreAuth
    public R<IPage<ApiScopeVO>> list(ApiScope dataScope, Query query) {
        IPage<ApiScope> pages = this.apiScopeService.page(Condition.getPage(query), Condition.getQueryWrapper(dataScope));
        IPage<ApiScopeVO> data = ApiScopeWrapper.build().pageVO(pages);
        data.getRecords().forEach(apiScopeVO -> {
            ResourceDefinition resourceDefinition = (ResourceDefinition) this.resourceDefinitionMapper.selectOne((Wrapper) Wrappers.lambdaQuery().eq((v0) -> {
                return v0.getCode();
            }, apiScopeVO.getResourceCode()));
            if (Func.isNotEmpty(resourceDefinition)) {
                apiScopeVO.setControllerCode(resourceDefinition.getControllerCode());
                apiScopeVO.setModuleCode(resourceDefinition.getModuleCode());
            }
        });
        return R.data(data);
    }
 
    @ApiOperationSupport(order = 3)
    @PostResource({"/save"})
    @ApiOperation(value = "新增", notes = "传入dataScope")
    @PreAuth
    public R save(@RequestParam String menuId, @RequestParam List<String> resourceCodeList) {
        CacheUtil.clear("blade:sys", ExtCacheConstant.TENANT_MODE);
        return R.data(this.apiScopeService.insertBatch(Long.valueOf(menuId), resourceCodeList));
    }
 
    @ApiOperationSupport(order = 4)
    @PostResource({"/update"})
    @ApiOperation(value = "修改", notes = "传入dataScope")
    public R update(@Valid @RequestBody ApiScope dataScope) {
        CacheUtil.clear("blade:sys", ExtCacheConstant.TENANT_MODE);
        return R.status(this.apiScopeService.updateById(dataScope));
    }
 
    @ApiOperationSupport(order = RegionCache.VILLAGE_LEVEL)
    @PostResource({"/submit"})
    @ApiOperation(value = "新增或修改", notes = "传入dataScope")
    public R submit(@Valid @RequestBody ApiScope dataScope) {
        CacheUtil.clear("blade:sys", ExtCacheConstant.TENANT_MODE);
        return R.status(this.apiScopeService.saveOrUpdate(dataScope));
    }
 
    @ApiOperationSupport(order = 6)
    @PostResource({"/remove"})
    @ApiOperation(value = "逻辑删除", notes = "传入ids")
    @PreAuth
    public R remove(@RequestParam @ApiParam(value = "主键集合", required = true) String ids) {
        CacheUtil.clear("blade:sys", ExtCacheConstant.TENANT_MODE);
        return R.status(this.apiScopeService.deleteLogic(Func.toLongList(ids)));
    }
}