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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package com.qianwen.smartman.modules.system.controller;
 
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.lang.invoke.SerializedLambda;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import com.qianwen.smartman.common.cache.RegionCache;
import com.qianwen.smartman.common.utils.Lambda;
import com.qianwen.core.boot.ctrl.BladeController;
import com.qianwen.core.mp.support.Condition;
import com.qianwen.core.mp.support.Query;
import com.qianwen.core.scanner.modular.annotation.DeleteResource;
import com.qianwen.core.scanner.modular.annotation.GetResource;
import com.qianwen.core.scanner.modular.annotation.PostResource;
import com.qianwen.core.scanner.modular.annotation.PutResource;
import com.qianwen.core.scanner.modular.stereotype.ApiResource;
import com.qianwen.core.tool.api.R;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.modules.system.convert.GalleryConvert;
import com.qianwen.smartman.modules.system.convert.GalleryItemConvert;
import com.qianwen.smartman.modules.system.entity.Gallery;
import com.qianwen.smartman.modules.system.entity.GalleryItem;
import com.qianwen.smartman.modules.system.service.IGalleryItemService;
import com.qianwen.smartman.modules.system.service.IGalleryService;
import com.qianwen.smartman.modules.system.vo.GalleryTreeVO;
import com.qianwen.smartman.modules.system.vo.GalleryVO;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
 
@Api(value = "图库管理", tags = {"图库管理"})
@ApiResource({"blade-system/gallery"})
@RestController
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/system/controller/GalleryController.class */
public class GalleryController extends BladeController {
    private IGalleryService galleryService;
    private IGalleryItemService galleryItemService;
 
    private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) {
        String implMethodName = lambda.getImplMethodName();
        boolean z = true;
        switch (implMethodName.hashCode()) {
            case 98245393:
                if (implMethodName.equals("getId")) {
                    z = false;
                    break;
                }
                break;
            case 309945687:
                if (implMethodName.equals("getGalleryId")) {
                    z = true;
                    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/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getId();
                    };
                }
                break;
            case true:
                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/modules/system/entity/GalleryItem") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getGalleryId();
                    };
                }
                break;
        }
        throw new IllegalArgumentException("Invalid lambda deserialization");
    }
 
    public GalleryController(final IGalleryService galleryService, final IGalleryItemService galleryItemService) {
        this.galleryService = galleryService;
        this.galleryItemService = galleryItemService;
    }
 
    @ApiOperationSupport(order = 1)
    @GetResource({"/get/{id}"})
    @ApiOperation(value = "图库详情", notes = "传入gallery")
    public R<GalleryVO> detail(@PathVariable String id) {
        Gallery gallery = (Gallery) this.galleryService.getById(id);
        return R.data(GalleryConvert.INSTANCE.convert(gallery));
    }
 
    @ApiOperationSupport(order = 2)
    @GetResource({"/list"})
    @ApiOperation(value = "图库列表", notes = "传入map")
    public R<List<GalleryVO>> list(@RequestParam @ApiIgnore Map<String, Object> params) {
        List<Gallery> list = this.galleryService.list(Condition.getQueryWrapper(params, Gallery.class));
        return R.data(GalleryConvert.INSTANCE.convert(list));
    }
 
    @ApiOperationSupport(order = 2)
    @ApiImplicitParams({@ApiImplicitParam(name = "itemCount", value = "图库图片类别ID", paramType = "query", dataType = "int")})
    @GetResource({"/tree"})
    @ApiOperation(value = "图库树结构, 带图片", notes = "传入map")
    public R<List<GalleryTreeVO>> tree(@RequestParam @ApiIgnore Map<String, Object> params) {
        String count = params.get("itemCount") == null ? "3" : params.get("itemCount").toString();
        List<Gallery> list = this.galleryService.list(Lambda.create());
        List<GalleryTreeVO> treeVOS = GalleryConvert.INSTANCE.convertTree(list);
        for (GalleryTreeVO tree : treeVOS) {
            List<GalleryItem> items = this.galleryItemService.list((Wrapper) Lambda.eq((v0) -> {
                return v0.getGalleryId();
            }, tree.getId()).limit(count).orderByDesc((v0) -> {
                return v0.getId();
            }));
            tree.setChildren(GalleryItemConvert.INSTANCE.convert(items));
        }
        return R.data(treeVOS);
    }
 
    @ApiOperationSupport(order = 2)
    @GetResource({"/count"})
    @ApiOperation(value = "图库统计值", notes = "传入map")
    public R<Long> count(@RequestParam @ApiIgnore Map<String, Object> params) {
        Long count = Long.valueOf(this.galleryService.count(Condition.getQueryWrapper(params, Gallery.class)));
        return R.data(count);
    }
 
    @ApiOperationSupport(order = 3)
    @GetResource({"/page"})
    @ApiOperation(value = "图库分页", notes = "传入map")
    public R<IPage<GalleryVO>> page(@RequestParam @ApiIgnore Map<String, Object> params, Query query) {
        IPage<Gallery> pages = this.galleryService.page(Condition.getPage(query), Condition.getQueryWrapper(params, Gallery.class));
        return R.data(GalleryConvert.INSTANCE.convert(pages));
    }
 
    @ApiOperationSupport(order = 4)
    @PostResource({"/insert"})
    @ApiOperation(value = "图库新增", notes = "传入galleryVO")
    public R<GalleryVO> insert(@Valid @RequestBody GalleryVO galleryVO) {
        Gallery gallery = GalleryConvert.INSTANCE.convert(galleryVO);
        this.galleryService.save(gallery);
        return R.data(GalleryConvert.INSTANCE.convert(gallery));
    }
 
    @ApiOperationSupport(order = RegionCache.VILLAGE_LEVEL)
    @PutResource({"/update"})
    @ApiOperation(value = "图库修改", notes = "传入galleryVO")
    public R<GalleryVO> update(@Valid @RequestBody GalleryVO galleryVO) {
        Gallery gallery = GalleryConvert.INSTANCE.convert(galleryVO);
        this.galleryService.updateById(gallery);
        return R.data(GalleryConvert.INSTANCE.convert(gallery));
    }
 
    @ApiOperationSupport(order = 6)
    @DeleteResource({"/remove"})
    @ApiOperation(value = "图库删除", notes = "传入ids")
    public R remove(@ApiParam(value = "主键", required = true) @RequestBody List<String> ids) {
        if (ids.isEmpty()) {
            return R.status(false);
        }
        return R.status(this.galleryService.removeByIds(Func.toLongList(ids)));
    }
}