Pad点餐后台配置接口
This commit is contained in:
parent
ddc95cf170
commit
42fcd08d00
|
|
@ -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<String, Object> params) {
|
||||
List<TbPadLayout> list = mpPadLayoutService.findList();
|
||||
return ResponseEntity.ok().body(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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<String, Object> params) {
|
||||
Map<String, Object> 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<PadProductGroupDTO> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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<Long> productIdList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
private List<TbProduct> productList = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
|
@ -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<TbPadLayout> {
|
||||
|
||||
}
|
||||
|
|
@ -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<TbPadProductGroupDetail> {
|
||||
|
||||
}
|
||||
|
|
@ -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<TbPadProductGroup> {
|
||||
|
||||
List<PadProductGroupDTO> findList(Map<String, Object> params);
|
||||
|
||||
}
|
||||
|
|
@ -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<TbPadLayout> {
|
||||
|
||||
List<TbPadLayout> findList();
|
||||
|
||||
}
|
||||
|
|
@ -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<TbPadProductGroupDetail> {
|
||||
|
||||
}
|
||||
|
|
@ -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<TbPadProductGroup> {
|
||||
|
||||
Map<String,Object> findPage(Map<String, Object> params);
|
||||
|
||||
PadProductGroupDTO get(Long id);
|
||||
|
||||
void save(PadProductGroupDTO dto);
|
||||
|
||||
void update(PadProductGroupDTO dto);
|
||||
|
||||
void sort(List<PadProductGroupDTO> sortList);
|
||||
|
||||
void delete(Long id);
|
||||
|
||||
void copy(Long id);
|
||||
|
||||
}
|
||||
|
|
@ -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<TbPadLayoutMapper, TbPadLayout> implements TbPadLayoutService {
|
||||
|
||||
private LambdaQueryWrapper<TbPadLayout> getWrapper(Map<String, Object> params) {
|
||||
TbPadLayout param = BeanUtil.toBean(params, TbPadLayout.class);
|
||||
LambdaQueryWrapper<TbPadLayout> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(TbPadLayout::getDelFlag, 0);
|
||||
wrapper.orderByAsc(TbPadLayout::getSort);
|
||||
wrapper.orderByAsc(TbPadLayout::getId);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<TbPadLayout> findList() {
|
||||
return super.list(this.getWrapper(new HashMap<>(1)));
|
||||
}
|
||||
}
|
||||
|
|
@ -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<TbPadProductGroupDetailMapper, TbPadProductGroupDetail> implements TbPadProductGroupDetailService {
|
||||
|
||||
public QueryWrapper<TbPadProductGroupDetail> getWrapper(Map<String, Object> params){
|
||||
QueryWrapper<TbPadProductGroupDetail> wrapper = new QueryWrapper<>();
|
||||
|
||||
wrapper.orderByDesc("id");
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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<TbPadProductGroupMapper, TbPadProductGroup> implements TbPadProductGroupService {
|
||||
|
||||
@Resource
|
||||
private TbPadLayoutMapper tbPadLayoutMapper;
|
||||
|
||||
@Resource
|
||||
private TbPadProductGroupDetailMapper tbPadProductGroupDetailMapper;
|
||||
@Resource
|
||||
private TbProductMapper tbProductMapper;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> findPage(Map<String, Object> params) {
|
||||
MapProxy mapProxy = MapProxy.create(params);
|
||||
int pageNum = mapProxy.getInt("page", 1);
|
||||
int pageSize = mapProxy.getInt("size", 10);
|
||||
Page<PadProductGroupDTO> page = new Page<>(pageNum, pageSize);
|
||||
page.addOrder(OrderItem.asc("sort"));
|
||||
params.put("page", page);
|
||||
List<PadProductGroupDTO> 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<String,Object> params = new HashMap<>(2);
|
||||
params.put("id", id);
|
||||
params.put("shopId", entity.getShopId());
|
||||
List<PadProductGroupDTO> list = baseMapper.findList(params);
|
||||
PadProductGroupDTO dto = list.get(0);
|
||||
if(entity.getProductGroupId().longValue() == 0L){
|
||||
dto.setProductGroupName("推荐菜");
|
||||
}
|
||||
List<TbPadProductGroupDetail> subList = tbPadProductGroupDetailMapper.selectList(Wrappers.<TbPadProductGroupDetail>lambdaQuery().eq(TbPadProductGroupDetail::getPadProductGroupId, entity.getId()));
|
||||
if(CollUtil.isNotEmpty(subList)){
|
||||
List<Long> productIdList = subList.stream().map(TbPadProductGroupDetail::getProductId).collect(Collectors.toList());
|
||||
dto.setProductIdList(productIdList);
|
||||
List<List<Long>> splitIdList = CollUtil.split(productIdList, 10);
|
||||
List<TbProduct> productList = dto.getProductList();
|
||||
for (List<Long> ids : splitIdList) {
|
||||
List<TbProduct> splitList = tbProductMapper.selectList(Wrappers.<TbProduct>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<Long> 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<Long> 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.<TbPadProductGroupDetail>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<PadProductGroupDTO> sortList) {
|
||||
if(CollUtil.isEmpty(sortList)) {
|
||||
throw new BadRequestException("排序列表不能为空");
|
||||
}
|
||||
for (PadProductGroupDTO dto : sortList) {
|
||||
super.update(null, Wrappers.<TbPadProductGroup>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.<TbPadProductGroupDetail>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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -4,17 +4,6 @@
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.ysk.cashier.mybatis.mapper.TbActivateMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="cn.ysk.cashier.mybatis.pojo.TbActivatetb">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="shop_id" column="shop_id" jdbcType="INTEGER"/>
|
||||
<result property="min_num" column="min_num" jdbcType="INTEGER"/>
|
||||
<result property="max_num" column="max_num" jdbcType="INTEGER"/>
|
||||
<result property="handsel_num" column="handsel_num" jdbcType="DECIMAL"/>
|
||||
<result property="handsel_type" column="handsel_type" jdbcType="VARCHAR"/>
|
||||
<result property="is_del" column="is_del" jdbcType="VARCHAR"/>
|
||||
<result property="is_user" column="is_user" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,shop_id,min_num,
|
||||
max_num,handsel_num,handsel_type,
|
||||
|
|
|
|||
|
|
@ -4,15 +4,6 @@
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.ysk.cashier.mybatis.mapper.TbShopMsgStateMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="cn.ysk.cashier.mybatis.pojo.TbShopMsgStatetb">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="shop_id" column="shop_id" jdbcType="INTEGER"/>
|
||||
<result property="type" column="type" jdbcType="INTEGER"/>
|
||||
<result property="state" column="state" jdbcType="INTEGER"/>
|
||||
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="update_time" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,shop_id,type,
|
||||
state,create_time,update_time
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.ysk.cashier.mybatis.mapper.TbPadProductGroupMapper">
|
||||
|
||||
<select id="findList" resultType="cn.ysk.cashier.dto.product.PadProductGroupDTO">
|
||||
SELECT
|
||||
t1.*,
|
||||
t3.name as productGroupName,
|
||||
GROUP_CONCAT(t4.name) as productNames,
|
||||
t5.code as padLayoutCode,
|
||||
t5.name as padLayoutName
|
||||
FROM
|
||||
tb_pad_product_group t1
|
||||
LEFT JOIN tb_pad_product_group_detail t2 on t1.id = t2.pad_product_group_id
|
||||
LEFT JOIN tb_product_group t3 on t1.product_group_id = t3.id
|
||||
LEFT JOIN tb_product t4 on t2.product_id = t4.id
|
||||
LEFT JOIN tb_pad_layout t5 on t1.pad_layout_id = t5.id
|
||||
<where>
|
||||
and t1.shop_id = #{shopId}
|
||||
<if test="id != null and id!=''">
|
||||
and t1.id = #{id}
|
||||
</if>
|
||||
<if test="customName != null and customName != ''">
|
||||
and t1.custom_name like concat(#{customName},'%')
|
||||
</if>
|
||||
<if test="productGroupId != null and productGroupId != ''">
|
||||
and t1.product_group_id = #{productGroupId}
|
||||
</if>
|
||||
<if test="padLayoutId != null and padLayoutId != ''">
|
||||
and t1.pad_layout_id = #{padLayoutId}
|
||||
</if>
|
||||
<if test="padLayoutCode != null and padLayoutCode != ''">
|
||||
and t5.code = #{padLayoutCode}
|
||||
</if>
|
||||
</where>
|
||||
group by t1.id
|
||||
order by t1.id asc
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue