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)));
|
}
|
}
|