Pad点餐后台配置接口
This commit is contained in:
parent
d9859647b4
commit
bc587c196d
|
|
@ -1,7 +1,7 @@
|
|||
package cn.ysk.cashier.controller.product;
|
||||
|
||||
import cn.ysk.cashier.dto.product.PadProductGroupDTO;
|
||||
import cn.ysk.cashier.mybatis.service.TbPadProductGroupService;
|
||||
import cn.ysk.cashier.dto.product.PadProductCategoryDTO;
|
||||
import cn.ysk.cashier.mybatis.service.TbPadProductCategoryService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
|
@ -12,64 +12,64 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Pad商品自定义分组
|
||||
* Pad商品自定义分类
|
||||
* @author tankaikai
|
||||
* @since 2024-10-22 16:38
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/pad/productGroup")
|
||||
@Api(tags="Pad商品自定义分组")
|
||||
public class TbPadProductGroupController {
|
||||
@RequestMapping("/api/pad/productCategory")
|
||||
@Api(tags="Pad商品自定义分类")
|
||||
public class TbPadProductCategoryController {
|
||||
|
||||
@Resource
|
||||
private TbPadProductGroupService mpPadProductGroupService;
|
||||
private TbPadProductCategoryService mpPadProductCategoryService;
|
||||
|
||||
@GetMapping("page")
|
||||
@ApiOperation("分页")
|
||||
public ResponseEntity page(@RequestParam Map<String, Object> params) {
|
||||
Map<String, Object> page = mpPadProductGroupService.findPage(params);
|
||||
Map<String, Object> page = mpPadProductCategoryService.findPage(params);
|
||||
return ResponseEntity.ok().body(page);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@ApiOperation("详情")
|
||||
public ResponseEntity get(@PathVariable("id") Long id) {
|
||||
PadProductGroupDTO data = mpPadProductGroupService.get(id);
|
||||
PadProductCategoryDTO data = mpPadProductCategoryService.get(id);
|
||||
return ResponseEntity.ok().body(data);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation("保存")
|
||||
public ResponseEntity save(@RequestBody PadProductGroupDTO dto) {
|
||||
mpPadProductGroupService.save(dto);
|
||||
public ResponseEntity save(@RequestBody PadProductCategoryDTO dto) {
|
||||
mpPadProductCategoryService.save(dto);
|
||||
return ResponseEntity.ok().body(dto.getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation("修改")
|
||||
public ResponseEntity update(@RequestBody PadProductGroupDTO dto) {
|
||||
mpPadProductGroupService.update(dto);
|
||||
public ResponseEntity update(@RequestBody PadProductCategoryDTO dto) {
|
||||
mpPadProductCategoryService.update(dto);
|
||||
return ResponseEntity.ok().body(dto.getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{id}")
|
||||
@ApiOperation("删除")
|
||||
public ResponseEntity delete(@PathVariable("id") Long id) {
|
||||
mpPadProductGroupService.delete(id);
|
||||
mpPadProductCategoryService.delete(id);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@PostMapping("sort")
|
||||
@ApiOperation("排序")
|
||||
public ResponseEntity sort(@RequestBody List<PadProductGroupDTO> sortList) {
|
||||
mpPadProductGroupService.sort(sortList);
|
||||
public ResponseEntity sort(@RequestBody List<PadProductCategoryDTO> sortList) {
|
||||
mpPadProductCategoryService.sort(sortList);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@PostMapping("copy/{id}")
|
||||
@ApiOperation("复制")
|
||||
public ResponseEntity copy(@PathVariable("id") Long id) {
|
||||
mpPadProductGroupService.copy(id);
|
||||
mpPadProductCategoryService.copy(id);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
|
|
@ -9,13 +9,13 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Pad商品自定义分组
|
||||
* Pad商品自定义分类
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-10-22 17:07
|
||||
*/
|
||||
@Data
|
||||
public class PadProductGroupDTO implements Serializable {
|
||||
public class PadProductCategoryDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
|
@ -34,7 +34,7 @@ public class PadProductGroupDTO implements Serializable {
|
|||
/**
|
||||
* 商品分类id
|
||||
*/
|
||||
private Long productGroupId;
|
||||
private Long productCategoryId;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
|
|
@ -72,9 +72,9 @@ public class PadProductGroupDTO implements Serializable {
|
|||
private String padLayoutName;
|
||||
|
||||
/**
|
||||
* 布局类型
|
||||
* 分类名称
|
||||
*/
|
||||
private String productGroupName;
|
||||
private String productCategoryName;
|
||||
|
||||
/**
|
||||
* 商品id列表
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.pojo.product.TbPadProductGroupDetail;
|
||||
import cn.ysk.cashier.pojo.product.TbPadProductCategoryDetail;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* Pad商品自定义分组明细
|
||||
* Pad商品自定义分类明细
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 2.0 2024-10-22
|
||||
*/
|
||||
@Mapper
|
||||
public interface TbPadProductGroupDetailMapper extends BaseMapper<TbPadProductGroupDetail> {
|
||||
public interface TbPadProductCategoryDetailMapper extends BaseMapper<TbPadProductCategoryDetail> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.dto.product.PadProductCategoryDTO;
|
||||
import cn.ysk.cashier.pojo.product.TbPadProductCategory;
|
||||
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 TbPadProductCategoryMapper extends BaseMapper<TbPadProductCategory> {
|
||||
|
||||
List<PadProductCategoryDTO> findList(Map<String, Object> params);
|
||||
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
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,14 @@
|
|||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.pojo.product.TbPadProductCategoryDetail;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* Pad商品自定义分类明细
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 2.0 2024-10-22
|
||||
*/
|
||||
public interface TbPadProductCategoryDetailService extends IService<TbPadProductCategoryDetail> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.dto.product.PadProductCategoryDTO;
|
||||
import cn.ysk.cashier.pojo.product.TbPadProductCategory;
|
||||
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 TbPadProductCategoryService extends IService<TbPadProductCategory> {
|
||||
|
||||
Map<String,Object> findPage(Map<String, Object> params);
|
||||
|
||||
PadProductCategoryDTO get(Long id);
|
||||
|
||||
void save(PadProductCategoryDTO dto);
|
||||
|
||||
void update(PadProductCategoryDTO dto);
|
||||
|
||||
void sort(List<PadProductCategoryDTO> sortList);
|
||||
|
||||
void delete(Long id);
|
||||
|
||||
void copy(Long id);
|
||||
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
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> {
|
||||
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
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,28 @@
|
|||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.ysk.cashier.mybatis.mapper.TbPadProductCategoryDetailMapper;
|
||||
import cn.ysk.cashier.mybatis.service.TbPadProductCategoryDetailService;
|
||||
import cn.ysk.cashier.pojo.product.TbPadProductCategoryDetail;
|
||||
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 TbPadProductCategoryDetailServiceImpl extends ServiceImpl<TbPadProductCategoryDetailMapper, TbPadProductCategoryDetail> implements TbPadProductCategoryDetailService {
|
||||
|
||||
public QueryWrapper<TbPadProductCategoryDetail> getWrapper(Map<String, Object> params){
|
||||
QueryWrapper<TbPadProductCategoryDetail> wrapper = new QueryWrapper<>();
|
||||
|
||||
wrapper.orderByDesc("id");
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,16 +4,16 @@ 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.dto.product.PadProductCategoryDTO;
|
||||
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.TbPadProductCategoryDetailMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbPadProductCategoryMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbProductMapper;
|
||||
import cn.ysk.cashier.mybatis.service.TbPadProductGroupService;
|
||||
import cn.ysk.cashier.mybatis.service.TbPadProductCategoryService;
|
||||
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.TbPadProductCategory;
|
||||
import cn.ysk.cashier.pojo.product.TbPadProductCategoryDetail;
|
||||
import cn.ysk.cashier.pojo.product.TbProduct;
|
||||
import cn.ysk.cashier.utils.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
|
|
@ -31,19 +31,19 @@ import java.util.Map;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Pad商品自定义分组
|
||||
* Pad商品自定义分类
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 2.0 2024-10-22
|
||||
*/
|
||||
@Service
|
||||
public class TbPadProductGroupServiceImpl extends ServiceImpl<TbPadProductGroupMapper, TbPadProductGroup> implements TbPadProductGroupService {
|
||||
public class TbPadProductCategoryServiceImpl extends ServiceImpl<TbPadProductCategoryMapper, TbPadProductCategory> implements TbPadProductCategoryService {
|
||||
|
||||
@Resource
|
||||
private TbPadLayoutMapper tbPadLayoutMapper;
|
||||
|
||||
@Resource
|
||||
private TbPadProductGroupDetailMapper tbPadProductGroupDetailMapper;
|
||||
private TbPadProductCategoryDetailMapper tbPadProductCategoryDetailMapper;
|
||||
@Resource
|
||||
private TbProductMapper tbProductMapper;
|
||||
|
||||
|
|
@ -52,16 +52,16 @@ public class TbPadProductGroupServiceImpl extends ServiceImpl<TbPadProductGroupM
|
|||
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<PadProductCategoryDTO> page = new Page<>(pageNum, pageSize);
|
||||
page.addOrder(OrderItem.asc("sort"));
|
||||
params.put("page", page);
|
||||
List<PadProductGroupDTO> list = baseMapper.findList(params);
|
||||
List<PadProductCategoryDTO> list = baseMapper.findList(params);
|
||||
return PageUtil.toPlusPage(list, Convert.toInt(page.getTotal()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PadProductGroupDTO get(Long id) {
|
||||
TbPadProductGroup entity = baseMapper.selectById(id);
|
||||
public PadProductCategoryDTO get(Long id) {
|
||||
TbPadProductCategory entity = baseMapper.selectById(id);
|
||||
if (entity == null) {
|
||||
throw new BadRequestException("id对应的数据不存在");
|
||||
}
|
||||
|
|
@ -72,14 +72,14 @@ public class TbPadProductGroupServiceImpl extends ServiceImpl<TbPadProductGroupM
|
|||
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<PadProductCategoryDTO> list = baseMapper.findList(params);
|
||||
PadProductCategoryDTO dto = list.get(0);
|
||||
if(entity.getProductCategoryId().longValue() == 0L){
|
||||
dto.setProductCategoryName("推荐菜");
|
||||
}
|
||||
List<TbPadProductGroupDetail> subList = tbPadProductGroupDetailMapper.selectList(Wrappers.<TbPadProductGroupDetail>lambdaQuery().eq(TbPadProductGroupDetail::getPadProductGroupId, entity.getId()));
|
||||
List<TbPadProductCategoryDetail> subList = tbPadProductCategoryDetailMapper.selectList(Wrappers.<TbPadProductCategoryDetail>lambdaQuery().eq(TbPadProductCategoryDetail::getPadProductCategoryId, entity.getId()));
|
||||
if(CollUtil.isNotEmpty(subList)){
|
||||
List<Long> productIdList = subList.stream().map(TbPadProductGroupDetail::getProductId).collect(Collectors.toList());
|
||||
List<Long> productIdList = subList.stream().map(TbPadProductCategoryDetail::getProductId).collect(Collectors.toList());
|
||||
dto.setProductIdList(productIdList);
|
||||
List<List<Long>> splitIdList = CollUtil.split(productIdList, 10);
|
||||
List<TbProduct> productList = dto.getProductList();
|
||||
|
|
@ -94,14 +94,14 @@ public class TbPadProductGroupServiceImpl extends ServiceImpl<TbPadProductGroupM
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(PadProductGroupDTO dto) {
|
||||
public void save(PadProductCategoryDTO dto) {
|
||||
Long padLayoutId = dto.getPadLayoutId();
|
||||
if (padLayoutId == null) {
|
||||
throw new BadRequestException("布局版式id不能为空");
|
||||
}
|
||||
Long productGroupId = dto.getProductGroupId();
|
||||
if (productGroupId == null) {
|
||||
throw new BadRequestException("商品分组不能为空");
|
||||
Long productCategoryId = dto.getProductCategoryId();
|
||||
if (productCategoryId == null) {
|
||||
throw new BadRequestException("商品分类不能为空");
|
||||
}
|
||||
Long shopId = dto.getShopId();
|
||||
if (shopId == null) {
|
||||
|
|
@ -129,23 +129,23 @@ public class TbPadProductGroupServiceImpl extends ServiceImpl<TbPadProductGroupM
|
|||
if (productIdList.size() > maximum.intValue()) {
|
||||
throw new BadRequestException("商品数量不能超过布局版式最大限制:" + maximum.intValue());
|
||||
}
|
||||
TbPadProductGroup entity = new TbPadProductGroup();
|
||||
TbPadProductCategory entity = new TbPadProductCategory();
|
||||
BeanUtil.copyProperties(dto, entity);
|
||||
entity.setCreateTime(new Date());
|
||||
super.save(entity);
|
||||
for (Long productId : productIdList) {
|
||||
TbPadProductGroupDetail subEntity = new TbPadProductGroupDetail();
|
||||
TbPadProductCategoryDetail subEntity = new TbPadProductCategoryDetail();
|
||||
subEntity.setProductId(productId);
|
||||
subEntity.setPadProductGroupId(entity.getId());
|
||||
subEntity.setPadProductCategoryId(entity.getId());
|
||||
subEntity.setCreateTime(new Date());
|
||||
tbPadProductGroupDetailMapper.insert(subEntity);
|
||||
tbPadProductCategoryDetailMapper.insert(subEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(PadProductGroupDTO dto) {
|
||||
public void update(PadProductCategoryDTO dto) {
|
||||
Long id = dto.getId();
|
||||
if (id == null) {
|
||||
throw new BadRequestException("id不能为空");
|
||||
|
|
@ -154,9 +154,9 @@ public class TbPadProductGroupServiceImpl extends ServiceImpl<TbPadProductGroupM
|
|||
if (padLayoutId == null) {
|
||||
throw new BadRequestException("布局版式id不能为空");
|
||||
}
|
||||
Long productGroupId = dto.getProductGroupId();
|
||||
if (productGroupId == null) {
|
||||
throw new BadRequestException("商品分组不能为空");
|
||||
Long productCategoryId = dto.getProductCategoryId();
|
||||
if (productCategoryId == null) {
|
||||
throw new BadRequestException("商品分类不能为空");
|
||||
}
|
||||
Long shopId = dto.getShopId();
|
||||
if (shopId == null) {
|
||||
|
|
@ -184,7 +184,7 @@ public class TbPadProductGroupServiceImpl extends ServiceImpl<TbPadProductGroupM
|
|||
if (productIdList.size() > maximum.intValue()) {
|
||||
throw new BadRequestException("商品数量不能超过布局版式最大限制:" + maximum.intValue());
|
||||
}
|
||||
TbPadProductGroup entity = baseMapper.selectById(id);
|
||||
TbPadProductCategory entity = baseMapper.selectById(id);
|
||||
if (entity == null) {
|
||||
throw new BadRequestException("id对应的数据不存在");
|
||||
}
|
||||
|
|
@ -192,23 +192,23 @@ public class TbPadProductGroupServiceImpl extends ServiceImpl<TbPadProductGroupM
|
|||
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();
|
||||
tbPadProductCategoryDetailMapper.delete(Wrappers.<TbPadProductCategoryDetail>lambdaQuery().eq(TbPadProductCategoryDetail::getPadProductCategoryId, entity.getId()));
|
||||
TbPadProductCategoryDetail subEntity = new TbPadProductCategoryDetail();
|
||||
subEntity.setProductId(productId);
|
||||
subEntity.setPadProductGroupId(entity.getId());
|
||||
subEntity.setPadProductCategoryId(entity.getId());
|
||||
subEntity.setCreateTime(new Date());
|
||||
tbPadProductGroupDetailMapper.insert(subEntity);
|
||||
tbPadProductCategoryDetailMapper.insert(subEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void sort(List<PadProductGroupDTO> sortList) {
|
||||
public void sort(List<PadProductCategoryDTO> 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()));
|
||||
for (PadProductCategoryDTO dto : sortList) {
|
||||
super.update(null, Wrappers.<TbPadProductCategory>lambdaUpdate().eq(TbPadProductCategory::getId, dto.getId()).set(TbPadProductCategory::getSort, dto.getSort()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -216,13 +216,13 @@ public class TbPadProductGroupServiceImpl extends ServiceImpl<TbPadProductGroupM
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long id) {
|
||||
super.removeById(id);
|
||||
tbPadProductGroupDetailMapper.delete(Wrappers.<TbPadProductGroupDetail>lambdaQuery().eq(TbPadProductGroupDetail::getPadProductGroupId, id));
|
||||
tbPadProductCategoryDetailMapper.delete(Wrappers.<TbPadProductCategoryDetail>lambdaQuery().eq(TbPadProductCategoryDetail::getPadProductCategoryId, id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void copy(Long id) {
|
||||
PadProductGroupDTO dto = get(id);
|
||||
PadProductCategoryDTO dto = get(id);
|
||||
dto.setId(null);
|
||||
dto.setCreateTime(null);
|
||||
dto.setUpdateTime(null);
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,15 +9,15 @@ import lombok.EqualsAndHashCode;
|
|||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Pad商品自定义分组
|
||||
* Pad商品自定义分类
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 2.0 2024-10-22
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@TableName("tb_pad_product_group")
|
||||
public class TbPadProductGroup {
|
||||
@TableName("tb_pad_product_category")
|
||||
public class TbPadProductCategory {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
|
@ -36,7 +36,7 @@ public class TbPadProductGroup {
|
|||
/**
|
||||
* 商品分类id
|
||||
*/
|
||||
private Long productGroupId;
|
||||
private Long productCategoryId;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
|
|
@ -9,15 +9,15 @@ import lombok.EqualsAndHashCode;
|
|||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Pad商品自定义分组明细
|
||||
* 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 {
|
||||
@TableName("tb_pad_product_category_detail")
|
||||
public class TbPadProductCategoryDetail {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
|
@ -26,9 +26,9 @@ public class TbPadProductGroupDetail {
|
|||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
/**
|
||||
* Pad商品自定义分组id
|
||||
* Pad商品自定义分类id
|
||||
*/
|
||||
private Long padProductGroupId;
|
||||
private Long padProductCategoryId;
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
<?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">
|
||||
<mapper namespace="cn.ysk.cashier.mybatis.mapper.TbPadProductCategoryMapper">
|
||||
|
||||
<select id="findList" resultType="cn.ysk.cashier.dto.product.PadProductGroupDTO">
|
||||
<select id="findList" resultType="cn.ysk.cashier.dto.product.PadProductCategoryDTO">
|
||||
SELECT
|
||||
t1.*,
|
||||
t3.name as productGroupName,
|
||||
t3.name as productCategoryName,
|
||||
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
|
||||
tb_pad_product_category t1
|
||||
LEFT JOIN tb_pad_product_category_detail t2 on t1.id = t2.pad_product_category_id
|
||||
LEFT JOIN tb_shop_category t3 on t1.product_category_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>
|
||||
|
|
@ -23,8 +23,8 @@
|
|||
<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 test="productCategoryId != null and productCategoryId != ''">
|
||||
and t1.product_category_id = #{productCategoryId}
|
||||
</if>
|
||||
<if test="padLayoutId != null and padLayoutId != ''">
|
||||
and t1.pad_layout_id = #{padLayoutId}
|
||||
Loading…
Reference in New Issue