yangys
2024-04-01 86cdd920b68274185233383f69ddb974052b6b6f
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
package com.qianwen.smartman.modules.system.controller;
 
import java.util.List;
import java.util.Map;
 
import javax.validation.Valid;
 
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 com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
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.common.cache.RegionCache;
import com.qianwen.smartman.common.utils.Lambda;
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 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 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;
 
    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(Lambda.eq(GalleryItem::getGalleryId, tree.getId()).limit(count).orderByDesc(GalleryItem::getId));
            /*
            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)));
    }
}