|
@@ -1,181 +0,0 @@
|
|
|
-package org.springblade.client.affairs.controller;
|
|
|
-
|
|
|
-import com.alibaba.cloud.commons.lang.StringUtils;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import io.swagger.annotations.ApiParam;
|
|
|
-import lombok.AllArgsConstructor;
|
|
|
-import org.springblade.client.entity.GoodsDesc;
|
|
|
-import org.springblade.client.goods.enums.GoodsTypeEnum;
|
|
|
-import org.springblade.client.goods.service.IGoodsDescService;
|
|
|
-import org.springblade.client.vo.GoodsDescVO;
|
|
|
-import org.springblade.core.boot.ctrl.BladeController;
|
|
|
-import org.springblade.core.log.exception.ServiceException;
|
|
|
-import org.springblade.core.mp.support.Condition;
|
|
|
-import org.springblade.core.mp.support.Query;
|
|
|
-import org.springblade.core.secure.utils.AuthUtil;
|
|
|
-import org.springblade.core.tool.api.R;
|
|
|
-import org.springblade.core.tool.utils.Func;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-
|
|
|
-import javax.validation.Valid;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-/**
|
|
|
- * 商品详情表 控制器
|
|
|
- *
|
|
|
- * @author BladeX
|
|
|
- * @since 2021-09-18
|
|
|
- */
|
|
|
-@RestController
|
|
|
-@AllArgsConstructor
|
|
|
-@RequestMapping("/affairsdesc")
|
|
|
-@Api(value = "商品详情表", tags = "商品详情表接口")
|
|
|
-public class AffairsController extends BladeController {
|
|
|
-
|
|
|
- private final IGoodsDescService goodsDescService;
|
|
|
-
|
|
|
- /**
|
|
|
- * 详情
|
|
|
- */
|
|
|
- @GetMapping("/detail")
|
|
|
- @ApiOperationSupport(order = 1)
|
|
|
- @ApiOperation(value = "详情", notes = "传入goodsDesc")
|
|
|
- public R<GoodsDesc> detail(GoodsDesc goodsDesc) {
|
|
|
- goodsDesc.setTenantId(AuthUtil.getTenantId());
|
|
|
- goodsDesc.setType(GoodsTypeEnum.AFFAIRS.getType());
|
|
|
- GoodsDesc detail = goodsDescService.getMessageById(goodsDesc);
|
|
|
- return R.data(detail);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 分页 商品详情表
|
|
|
- */
|
|
|
- @GetMapping("/list")
|
|
|
- @ApiOperationSupport(order = 2)
|
|
|
- @ApiOperation(value = "分页", notes = "传入goodsDesc")
|
|
|
- public R<IPage<GoodsDesc>> list(GoodsDescVO goodsDesc, Query query) {
|
|
|
- LambdaQueryWrapper<GoodsDesc> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(StringUtils.isNotBlank(goodsDesc.getGoodsTypeId()), GoodsDesc::getGoodsTypeId, goodsDesc.getGoodsTypeId());
|
|
|
- queryWrapper.like(StringUtils.isNotBlank(goodsDesc.getCname()), GoodsDesc::getCname, goodsDesc.getCname());
|
|
|
- queryWrapper.like(StringUtils.isNotBlank(goodsDesc.getCode()), GoodsDesc::getCode, goodsDesc.getCode());
|
|
|
- queryWrapper.eq(GoodsDesc::getTenantId, AuthUtil.getTenantId());
|
|
|
- queryWrapper.eq(GoodsDesc::getIsDeleted, 0);
|
|
|
- queryWrapper.eq(GoodsDesc::getType, GoodsTypeEnum.AFFAIRS.getType());
|
|
|
- IPage<GoodsDesc> pages = goodsDescService.page(Condition.getPage(query), queryWrapper);
|
|
|
- return R.data(pages);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 自定义分页 商品详情表
|
|
|
- */
|
|
|
- @GetMapping("/page")
|
|
|
- @ApiOperationSupport(order = 3)
|
|
|
- @ApiOperation(value = "分页", notes = "传入goodsDesc")
|
|
|
- public R<IPage<GoodsDescVO>> page(GoodsDescVO goodsDesc, Query query) {
|
|
|
- goodsDesc.setTenantId(AuthUtil.getTenantId());
|
|
|
- goodsDesc.setType(GoodsTypeEnum.AFFAIRS.getType());
|
|
|
- IPage<GoodsDescVO> pages = goodsDescService.selectGoodsDescPage(Condition.getPage(query), goodsDesc);
|
|
|
- return R.data(pages);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增 商品详情表
|
|
|
- */
|
|
|
- @PostMapping("/save")
|
|
|
- @ApiOperationSupport(order = 4)
|
|
|
- @ApiOperation(value = "新增", notes = "传入goodsDesc")
|
|
|
- public R save(@Valid @RequestBody GoodsDesc goodsDesc) {
|
|
|
- goodsDesc.setTenantId(AuthUtil.getTenantId());
|
|
|
- goodsDesc.setType(GoodsTypeEnum.AFFAIRS.getType());
|
|
|
- return R.status(goodsDescService.save(goodsDesc));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改 商品详情表
|
|
|
- */
|
|
|
- @PostMapping("/update")
|
|
|
- @ApiOperationSupport(order = 5)
|
|
|
- @ApiOperation(value = "修改", notes = "传入goodsDesc")
|
|
|
- public R update(@Valid @RequestBody GoodsDesc goodsDesc) {
|
|
|
- if (goodsDesc.getId() == null) {
|
|
|
- return R.fail(500, "请选择要删除的数据");
|
|
|
- }
|
|
|
- goodsDesc.setIsDeleted(1);
|
|
|
- return R.status(goodsDescService.updateById(goodsDesc));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增或修改 商品详情表
|
|
|
- */
|
|
|
- @PostMapping("/submit")
|
|
|
- @ApiOperationSupport(order = 6)
|
|
|
- @ApiOperation(value = "新增或修改", notes = "传入goodsDesc")
|
|
|
- public R submit(@Valid @RequestBody GoodsDesc goodsDesc) {
|
|
|
- //验证唯一性
|
|
|
- LambdaQueryWrapper<GoodsDesc> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.eq(GoodsDesc::getCode, goodsDesc.getCode());
|
|
|
- lambdaQueryWrapper.eq(GoodsDesc::getCname, goodsDesc.getCname());
|
|
|
- lambdaQueryWrapper.eq(GoodsDesc::getType, 1);
|
|
|
- GoodsDesc serviceOne = goodsDescService.getOne(lambdaQueryWrapper);
|
|
|
- if (serviceOne != null && serviceOne.getId() == null) {
|
|
|
- throw new ServiceException("存在重复数据,请修改后添加");
|
|
|
- }
|
|
|
- if (StringUtils.isBlank(goodsDesc.getTenantId())) {
|
|
|
- goodsDesc.setTenantId(AuthUtil.getTenantId());
|
|
|
- }
|
|
|
- if (StringUtils.isBlank(goodsDesc.getCode())) {
|
|
|
- return R.fail(500, "事务编码不能为空");
|
|
|
- }
|
|
|
- if (StringUtils.isBlank(goodsDesc.getCname())) {
|
|
|
- return R.fail(500, "事务名称不能为空");
|
|
|
- }
|
|
|
- // 校验唯一性
|
|
|
- goodsDescService.selectGoodsCode(goodsDesc);
|
|
|
- goodsDescService.selectGoodsCname(goodsDesc);
|
|
|
- goodsDesc.setType(GoodsTypeEnum.AFFAIRS.getType());
|
|
|
- return R.data(goodsDescService.saveMessage(goodsDesc));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除 商品详情表
|
|
|
- */
|
|
|
- @PostMapping("/remove")
|
|
|
- @ApiOperationSupport(order = 8)
|
|
|
- @ApiOperation(value = "删除", notes = "传入ids")
|
|
|
- public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
- return R.status(goodsDescService.removeByIds(Func.toLongList(ids)));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取商品详情
|
|
|
- */
|
|
|
- @GetMapping("/selectGoods")
|
|
|
- @ApiOperationSupport(order = 5)
|
|
|
- @ApiOperation(value = "获取商品详情", notes = "传入goodsDesc")
|
|
|
- public R<IPage<GoodsDescVO>> selectGoods(GoodsDesc goodsDesc, Query query) {
|
|
|
- goodsDesc.setIsDeleted(0);
|
|
|
- goodsDesc.setTenantId(AuthUtil.getTenantId());
|
|
|
- goodsDesc.setType(GoodsTypeEnum.AFFAIRS.getType());
|
|
|
- return R.data(goodsDescService.selectGoods(Condition.getPage(query), goodsDesc));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取项目名称
|
|
|
- */
|
|
|
- @GetMapping("/getGoodsDescList")
|
|
|
- @ApiOperation(value = "获取项目名称")
|
|
|
- public R getGoodsDescList() {
|
|
|
- LambdaQueryWrapper<GoodsDesc> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(GoodsDesc::getTenantId, AuthUtil.getTenantId());
|
|
|
- queryWrapper.eq(GoodsDesc::getIsDeleted, 0);
|
|
|
- queryWrapper.eq(GoodsDesc::getType, GoodsTypeEnum.AFFAIRS.getType());
|
|
|
- List<GoodsDesc> goodsDescList = goodsDescService.list(queryWrapper);
|
|
|
- return R.data(goodsDescList);
|
|
|
- }
|
|
|
-
|
|
|
-}
|