From 42fcd08d00b2c6dfb92970b0b82082e6df92207c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Wed, 23 Oct 2024 14:51:21 +0800 Subject: [PATCH] =?UTF-8?q?Pad=E7=82=B9=E9=A4=90=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/TbPadLayoutController.java | 37 +++ .../product/TbPadProductGroupController.java | 76 ++++++ .../dto/product/PadProductGroupDTO.java | 89 +++++++ .../mybatis/mapper/TbPadLayoutMapper.java | 16 ++ .../mapper/TbPadProductGroupDetailMapper.java | 16 ++ .../mapper/TbPadProductGroupMapper.java | 22 ++ .../mybatis/service/TbPadLayoutService.java | 18 ++ .../TbPadProductGroupDetailService.java | 14 ++ .../service/TbPadProductGroupService.java | 32 +++ .../service/impl/TbPadLayoutServiceImpl.java | 40 +++ .../TbPadProductGroupDetailServiceImpl.java | 28 +++ .../impl/TbPadProductGroupServiceImpl.java | 232 ++++++++++++++++++ .../ysk/cashier/pojo/product/TbPadLayout.java | 56 +++++ .../pojo/product/TbPadProductGroup.java | 60 +++++ .../pojo/product/TbPadProductGroupDetail.java | 40 +++ .../src/main/resources/config/application.yml | 4 +- .../resources/mapper/TbActivateMapper.xml | 11 - .../resources/mapper/TbShopMsgStateMapper.xml | 9 - .../mapper/{ => plus}/SysParamsMapper.xml | 0 .../mapper/plus/TbPadProductGroupMapper.xml | 39 +++ 20 files changed, 817 insertions(+), 22 deletions(-) create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPadLayoutController.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPadProductGroupController.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/dto/product/PadProductGroupDTO.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadLayoutMapper.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadProductGroupDetailMapper.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadProductGroupMapper.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadLayoutService.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadProductGroupDetailService.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadProductGroupService.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadLayoutServiceImpl.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadProductGroupDetailServiceImpl.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadProductGroupServiceImpl.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadLayout.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadProductGroup.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadProductGroupDetail.java rename eladmin-system/src/main/resources/mapper/{ => plus}/SysParamsMapper.xml (100%) create mode 100644 eladmin-system/src/main/resources/mapper/plus/TbPadProductGroupMapper.xml diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPadLayoutController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPadLayoutController.java new file mode 100644 index 00000000..90d0e081 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPadLayoutController.java @@ -0,0 +1,37 @@ +package cn.ysk.cashier.controller.product; + +import cn.ysk.cashier.mybatis.service.TbPadLayoutService; +import cn.ysk.cashier.pojo.product.TbPadLayout; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +/** + * Pad商品布局版式 + * @author tankaikai + * @since 2024-10-22 16:38 + */ +@RestController +@RequestMapping("/api/pad/layout") +@Api(tags="Pad商品布局版式") +public class TbPadLayoutController { + + @Resource + private TbPadLayoutService mpPadLayoutService; + + @GetMapping("list") + @ApiOperation("分页") + public ResponseEntity list(@RequestParam Map params) { + List list = mpPadLayoutService.findList(); + return ResponseEntity.ok().body(list); + } + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPadProductGroupController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPadProductGroupController.java new file mode 100644 index 00000000..509384d2 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPadProductGroupController.java @@ -0,0 +1,76 @@ +package cn.ysk.cashier.controller.product; + +import cn.ysk.cashier.dto.product.PadProductGroupDTO; +import cn.ysk.cashier.mybatis.service.TbPadProductGroupService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +/** + * Pad商品自定义分组 + * @author tankaikai + * @since 2024-10-22 16:38 + */ +@RestController +@RequestMapping("/api/pad/productGroup") +@Api(tags="Pad商品自定义分组") +public class TbPadProductGroupController { + + @Resource + private TbPadProductGroupService mpPadProductGroupService; + + @GetMapping("page") + @ApiOperation("分页") + public ResponseEntity page(@RequestParam Map params) { + Map page = mpPadProductGroupService.findPage(params); + return ResponseEntity.ok().body(page); + } + + @GetMapping("{id}") + @ApiOperation("详情") + public ResponseEntity get(@PathVariable("id") Long id) { + PadProductGroupDTO data = mpPadProductGroupService.get(id); + return ResponseEntity.ok().body(data); + } + + @PostMapping + @ApiOperation("保存") + public ResponseEntity save(@RequestBody PadProductGroupDTO dto) { + mpPadProductGroupService.save(dto); + return ResponseEntity.ok().body(dto.getId()); + } + + @PutMapping + @ApiOperation("修改") + public ResponseEntity update(@RequestBody PadProductGroupDTO dto) { + mpPadProductGroupService.update(dto); + return ResponseEntity.ok().body(dto.getId()); + } + + @DeleteMapping("{id}") + @ApiOperation("删除") + public ResponseEntity delete(@PathVariable("id") Long id) { + mpPadProductGroupService.delete(id); + return ResponseEntity.ok().build(); + } + + @PostMapping("sort") + @ApiOperation("排序") + public ResponseEntity sort(@RequestBody List sortList) { + mpPadProductGroupService.sort(sortList); + return ResponseEntity.ok().build(); + } + + @PostMapping("copy/{id}") + @ApiOperation("复制") + public ResponseEntity copy(@PathVariable("id") Long id) { + mpPadProductGroupService.copy(id); + return ResponseEntity.ok().build(); + } + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/PadProductGroupDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/PadProductGroupDTO.java new file mode 100644 index 00000000..00b74611 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/PadProductGroupDTO.java @@ -0,0 +1,89 @@ +package cn.ysk.cashier.dto.product; + +import cn.ysk.cashier.pojo.product.TbProduct; +import lombok.Data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * Pad商品自定义分组 + * + * @author tankaikai + * @since 2024-10-22 17:07 + */ +@Data +public class PadProductGroupDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + private Long id; + /** + * 布局版式id + */ + private Long padLayoutId; + + /** + * 自定义名称 + */ + private String customName; + /** + * 商品分类id + */ + private Long productGroupId; + /** + * 店铺id + */ + private Long shopId; + /** + * 排序 + */ + private Integer sort; + /** + * 备注 + */ + private String remark; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 商品名称 + */ + private String productNames; + + /** + * 布局版式代码 + */ + private String padLayoutCode; + + /** + * 布局类型 + */ + private String padLayoutName; + + /** + * 布局类型 + */ + private String productGroupName; + + /** + * 商品id列表 + */ + private List productIdList = new ArrayList<>(); + + /** + * 商品列表 + */ + private List productList = new ArrayList<>(); + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadLayoutMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadLayoutMapper.java new file mode 100644 index 00000000..f01e7879 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadLayoutMapper.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.pojo.product.TbPadLayout; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* Pad商品布局版式 +* +* @author Tankaikai tankaikai@aliyun.com +* @since 2.0 2024-10-22 +*/ +@Mapper +public interface TbPadLayoutMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadProductGroupDetailMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadProductGroupDetailMapper.java new file mode 100644 index 00000000..b9429073 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadProductGroupDetailMapper.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.pojo.product.TbPadProductGroupDetail; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* Pad商品自定义分组明细 +* +* @author Tankaikai tankaikai@aliyun.com +* @since 2.0 2024-10-22 +*/ +@Mapper +public interface TbPadProductGroupDetailMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadProductGroupMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadProductGroupMapper.java new file mode 100644 index 00000000..5eea4391 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadProductGroupMapper.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.dto.product.PadProductGroupDTO; +import cn.ysk.cashier.pojo.product.TbPadProductGroup; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +/** +* Pad商品自定义分组 +* +* @author Tankaikai tankaikai@aliyun.com +* @since 2.0 2024-10-22 +*/ +@Mapper +public interface TbPadProductGroupMapper extends BaseMapper { + + List findList(Map params); + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadLayoutService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadLayoutService.java new file mode 100644 index 00000000..9ad903cc --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadLayoutService.java @@ -0,0 +1,18 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.pojo.product.TbPadLayout; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +/** + * Pad商品布局版式 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +public interface TbPadLayoutService extends IService { + + List findList(); + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadProductGroupDetailService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadProductGroupDetailService.java new file mode 100644 index 00000000..82ee7bf9 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadProductGroupDetailService.java @@ -0,0 +1,14 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.pojo.product.TbPadProductGroupDetail; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * Pad商品自定义分组明细 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +public interface TbPadProductGroupDetailService extends IService { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadProductGroupService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadProductGroupService.java new file mode 100644 index 00000000..cf5a7383 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadProductGroupService.java @@ -0,0 +1,32 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.dto.product.PadProductGroupDTO; +import cn.ysk.cashier.pojo.product.TbPadProductGroup; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; +import java.util.Map; + +/** + * Pad商品自定义分组 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +public interface TbPadProductGroupService extends IService { + + Map findPage(Map params); + + PadProductGroupDTO get(Long id); + + void save(PadProductGroupDTO dto); + + void update(PadProductGroupDTO dto); + + void sort(List sortList); + + void delete(Long id); + + void copy(Long id); + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadLayoutServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadLayoutServiceImpl.java new file mode 100644 index 00000000..a745baa2 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadLayoutServiceImpl.java @@ -0,0 +1,40 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.ysk.cashier.mybatis.mapper.TbPadLayoutMapper; +import cn.ysk.cashier.mybatis.service.TbPadLayoutService; +import cn.ysk.cashier.pojo.product.TbPadLayout; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Pad商品布局版式 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +@Service +public class TbPadLayoutServiceImpl extends ServiceImpl implements TbPadLayoutService { + + private LambdaQueryWrapper getWrapper(Map params) { + TbPadLayout param = BeanUtil.toBean(params, TbPadLayout.class); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(TbPadLayout::getDelFlag, 0); + wrapper.orderByAsc(TbPadLayout::getSort); + wrapper.orderByAsc(TbPadLayout::getId); + return wrapper; + } + + + + @Override + public List findList() { + return super.list(this.getWrapper(new HashMap<>(1))); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadProductGroupDetailServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadProductGroupDetailServiceImpl.java new file mode 100644 index 00000000..c891202b --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadProductGroupDetailServiceImpl.java @@ -0,0 +1,28 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.ysk.cashier.mybatis.mapper.TbPadProductGroupDetailMapper; +import cn.ysk.cashier.mybatis.service.TbPadProductGroupDetailService; +import cn.ysk.cashier.pojo.product.TbPadProductGroupDetail; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * Pad商品自定义分组明细 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +@Service +public class TbPadProductGroupDetailServiceImpl extends ServiceImpl implements TbPadProductGroupDetailService { + + public QueryWrapper getWrapper(Map params){ + QueryWrapper wrapper = new QueryWrapper<>(); + + wrapper.orderByDesc("id"); + return wrapper; + } + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadProductGroupServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadProductGroupServiceImpl.java new file mode 100644 index 00000000..6fe70be0 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadProductGroupServiceImpl.java @@ -0,0 +1,232 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.map.MapProxy; +import cn.ysk.cashier.dto.product.PadProductGroupDTO; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.mapper.TbPadLayoutMapper; +import cn.ysk.cashier.mybatis.mapper.TbPadProductGroupDetailMapper; +import cn.ysk.cashier.mybatis.mapper.TbPadProductGroupMapper; +import cn.ysk.cashier.mybatis.mapper.TbProductMapper; +import cn.ysk.cashier.mybatis.service.TbPadProductGroupService; +import cn.ysk.cashier.pojo.product.TbPadLayout; +import cn.ysk.cashier.pojo.product.TbPadProductGroup; +import cn.ysk.cashier.pojo.product.TbPadProductGroupDetail; +import cn.ysk.cashier.pojo.product.TbProduct; +import cn.ysk.cashier.utils.PageUtil; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * Pad商品自定义分组 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +@Service +public class TbPadProductGroupServiceImpl extends ServiceImpl implements TbPadProductGroupService { + + @Resource + private TbPadLayoutMapper tbPadLayoutMapper; + + @Resource + private TbPadProductGroupDetailMapper tbPadProductGroupDetailMapper; + @Resource + private TbProductMapper tbProductMapper; + + @Override + public Map findPage(Map params) { + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + Page page = new Page<>(pageNum, pageSize); + page.addOrder(OrderItem.asc("sort")); + params.put("page", page); + List list = baseMapper.findList(params); + return PageUtil.toPlusPage(list, Convert.toInt(page.getTotal())); + } + + @Override + public PadProductGroupDTO get(Long id) { + TbPadProductGroup entity = baseMapper.selectById(id); + if (entity == null) { + throw new BadRequestException("id对应的数据不存在"); + } + TbPadLayout padLayout = tbPadLayoutMapper.selectById(entity.getPadLayoutId()); + if (padLayout == null) { + throw new BadRequestException("引用的布局版式不存在"); + } + Map params = new HashMap<>(2); + params.put("id", id); + params.put("shopId", entity.getShopId()); + List list = baseMapper.findList(params); + PadProductGroupDTO dto = list.get(0); + if(entity.getProductGroupId().longValue() == 0L){ + dto.setProductGroupName("推荐菜"); + } + List subList = tbPadProductGroupDetailMapper.selectList(Wrappers.lambdaQuery().eq(TbPadProductGroupDetail::getPadProductGroupId, entity.getId())); + if(CollUtil.isNotEmpty(subList)){ + List productIdList = subList.stream().map(TbPadProductGroupDetail::getProductId).collect(Collectors.toList()); + dto.setProductIdList(productIdList); + List> splitIdList = CollUtil.split(productIdList, 10); + List productList = dto.getProductList(); + for (List ids : splitIdList) { + List splitList = tbProductMapper.selectList(Wrappers.lambdaQuery().in(TbProduct::getId, ids)); + productList.addAll(splitList); + } + dto.setProductList(productList); + } + return dto; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(PadProductGroupDTO dto) { + Long padLayoutId = dto.getPadLayoutId(); + if (padLayoutId == null) { + throw new BadRequestException("布局版式id不能为空"); + } + Long productGroupId = dto.getProductGroupId(); + if (productGroupId == null) { + throw new BadRequestException("商品分组不能为空"); + } + Long shopId = dto.getShopId(); + if (shopId == null) { + throw new BadRequestException("店铺id不能为空"); + } + Integer sort = dto.getSort(); + if (sort == null) { + throw new BadRequestException("排序码不能为空"); + } + if (sort.intValue() < 0) { + throw new BadRequestException("排序码不能小于0"); + } + List productIdList = dto.getProductIdList(); + if (CollUtil.isEmpty(productIdList)) { + throw new BadRequestException("商品id列表不能为空"); + } + TbPadLayout padLayout = tbPadLayoutMapper.selectById(padLayoutId); + if (padLayout == null) { + throw new BadRequestException("引用的布局版式不存在"); + } + if(padLayout.getDelFlag() == 1) { + throw new BadRequestException("引用的布局版式已停用"); + } + Integer maximum = padLayout.getMaximum(); + if (productIdList.size() > maximum.intValue()) { + throw new BadRequestException("商品数量不能超过布局版式最大限制:" + maximum.intValue()); + } + TbPadProductGroup entity = new TbPadProductGroup(); + BeanUtil.copyProperties(dto, entity); + entity.setCreateTime(new Date()); + super.save(entity); + for (Long productId : productIdList) { + TbPadProductGroupDetail subEntity = new TbPadProductGroupDetail(); + subEntity.setProductId(productId); + subEntity.setPadProductGroupId(entity.getId()); + subEntity.setCreateTime(new Date()); + tbPadProductGroupDetailMapper.insert(subEntity); + } + } + + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(PadProductGroupDTO dto) { + Long id = dto.getId(); + if (id == null) { + throw new BadRequestException("id不能为空"); + } + Long padLayoutId = dto.getPadLayoutId(); + if (padLayoutId == null) { + throw new BadRequestException("布局版式id不能为空"); + } + Long productGroupId = dto.getProductGroupId(); + if (productGroupId == null) { + throw new BadRequestException("商品分组不能为空"); + } + Long shopId = dto.getShopId(); + if (shopId == null) { + throw new BadRequestException("店铺id不能为空"); + } + Integer sort = dto.getSort(); + if (sort == null) { + throw new BadRequestException("排序码不能为空"); + } + if (sort.intValue() < 0) { + throw new BadRequestException("排序码不能小于0"); + } + List productIdList = dto.getProductIdList(); + if (CollUtil.isEmpty(productIdList)) { + throw new BadRequestException("商品id列表不能为空"); + } + TbPadLayout padLayout = tbPadLayoutMapper.selectById(padLayoutId); + if (padLayout == null) { + throw new BadRequestException("引用的布局版式不存在"); + } + if(padLayout.getDelFlag() == 1) { + throw new BadRequestException("引用的布局版式已停用"); + } + Integer maximum = padLayout.getMaximum(); + if (productIdList.size() > maximum.intValue()) { + throw new BadRequestException("商品数量不能超过布局版式最大限制:" + maximum.intValue()); + } + TbPadProductGroup entity = baseMapper.selectById(id); + if (entity == null) { + throw new BadRequestException("id对应的数据不存在"); + } + BeanUtil.copyProperties(dto, entity,"createTime"); + entity.setUpdateTime(new Date()); + super.updateById(entity); + for (Long productId : productIdList) { + tbPadProductGroupDetailMapper.delete(Wrappers.lambdaQuery().eq(TbPadProductGroupDetail::getPadProductGroupId, entity.getId())); + TbPadProductGroupDetail subEntity = new TbPadProductGroupDetail(); + subEntity.setProductId(productId); + subEntity.setPadProductGroupId(entity.getId()); + subEntity.setCreateTime(new Date()); + tbPadProductGroupDetailMapper.insert(subEntity); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void sort(List sortList) { + if(CollUtil.isEmpty(sortList)) { + throw new BadRequestException("排序列表不能为空"); + } + for (PadProductGroupDTO dto : sortList) { + super.update(null, Wrappers.lambdaUpdate().eq(TbPadProductGroup::getId, dto.getId()).set(TbPadProductGroup::getSort, dto.getSort())); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(Long id) { + super.removeById(id); + tbPadProductGroupDetailMapper.delete(Wrappers.lambdaQuery().eq(TbPadProductGroupDetail::getPadProductGroupId, id)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void copy(Long id) { + PadProductGroupDTO dto = get(id); + dto.setId(null); + dto.setCreateTime(null); + dto.setUpdateTime(null); + save(dto); + } + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadLayout.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadLayout.java new file mode 100644 index 00000000..5551d65d --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadLayout.java @@ -0,0 +1,56 @@ +package cn.ysk.cashier.pojo.product; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * Pad商品布局版式 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_pad_layout") +public class TbPadLayout { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 布局版式名称 + */ + private String name; + /** + * 布局版式代码 + */ + private String code; + /** + * 允许展示最大商品数 + */ + private Integer maximum; + /** + * 详细描述 + */ + private String remark; + /** + * 排序号,升序 + */ + private Integer sort; + /** + * 创建时间 + */ + private Date createTime; + /** + * 删除标志 0-正常 1-已删除 + */ + private Integer delFlag; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadProductGroup.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadProductGroup.java new file mode 100644 index 00000000..bbbcd49f --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadProductGroup.java @@ -0,0 +1,60 @@ +package cn.ysk.cashier.pojo.product; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * Pad商品自定义分组 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_pad_product_group") +public class TbPadProductGroup { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 布局版式id + */ + private Long padLayoutId; + /** + * 自定义名称 + */ + private String customName; + /** + * 商品分类id + */ + private Long productGroupId; + /** + * 店铺id + */ + private Long shopId; + /** + * 排序 + */ + private Integer sort; + /** + * 备注 + */ + private String remark; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新时间 + */ + private Date updateTime; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadProductGroupDetail.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadProductGroupDetail.java new file mode 100644 index 00000000..3f1da24e --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadProductGroupDetail.java @@ -0,0 +1,40 @@ +package cn.ysk.cashier.pojo.product; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * Pad商品自定义分组明细 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_pad_product_group_detail") +public class TbPadProductGroupDetail { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * Pad商品自定义分组id + */ + private Long padProductGroupId; + /** + * 商品id + */ + private Long productId; + /** + * 创建时间 + */ + private Date createTime; +} \ No newline at end of file diff --git a/eladmin-system/src/main/resources/config/application.yml b/eladmin-system/src/main/resources/config/application.yml index b77a4176..bf5881c8 100644 --- a/eladmin-system/src/main/resources/config/application.yml +++ b/eladmin-system/src/main/resources/config/application.yml @@ -72,8 +72,8 @@ thirdPay: fstReturn: https://admintestpapi.sxczgkj.cn/notify/fstReturn mybatis-plus: - mapper-locations: classpath:/cn/ysk/cashier/mybatis/mapper/*Mapper.xml - type-aliases-package: me.zhengjie.mybatis.entity + mapper-locations: classpath*:/mapper/plus/*.xml + #type-aliases-package: cn.ysk.cashier.pojo,cn.ysk.cashier.pojo.*,cn.ysk.cashier.system.domain.* configuration: map-underscore-to-camel-case: true cache-enabled: true diff --git a/eladmin-system/src/main/resources/mapper/TbActivateMapper.xml b/eladmin-system/src/main/resources/mapper/TbActivateMapper.xml index 77ad900a..13c82e34 100644 --- a/eladmin-system/src/main/resources/mapper/TbActivateMapper.xml +++ b/eladmin-system/src/main/resources/mapper/TbActivateMapper.xml @@ -4,17 +4,6 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - id,shop_id,min_num, max_num,handsel_num,handsel_type, diff --git a/eladmin-system/src/main/resources/mapper/TbShopMsgStateMapper.xml b/eladmin-system/src/main/resources/mapper/TbShopMsgStateMapper.xml index a6ccca7d..728b48b4 100644 --- a/eladmin-system/src/main/resources/mapper/TbShopMsgStateMapper.xml +++ b/eladmin-system/src/main/resources/mapper/TbShopMsgStateMapper.xml @@ -4,15 +4,6 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - id,shop_id,type, state,create_time,update_time diff --git a/eladmin-system/src/main/resources/mapper/SysParamsMapper.xml b/eladmin-system/src/main/resources/mapper/plus/SysParamsMapper.xml similarity index 100% rename from eladmin-system/src/main/resources/mapper/SysParamsMapper.xml rename to eladmin-system/src/main/resources/mapper/plus/SysParamsMapper.xml diff --git a/eladmin-system/src/main/resources/mapper/plus/TbPadProductGroupMapper.xml b/eladmin-system/src/main/resources/mapper/plus/TbPadProductGroupMapper.xml new file mode 100644 index 00000000..2aee8bc6 --- /dev/null +++ b/eladmin-system/src/main/resources/mapper/plus/TbPadProductGroupMapper.xml @@ -0,0 +1,39 @@ + + + + + + \ No newline at end of file