台桌管理接口
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.ShopArea;
|
||||
|
||||
/**
|
||||
* 店铺区域 映射层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
public interface ShopAreaMapper extends BaseMapper<ShopArea> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopArea;
|
||||
import com.czg.account.service.ShopAreaService;
|
||||
import com.czg.service.account.mapper.ShopAreaMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 店铺区域 服务层实现。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
@Service
|
||||
public class ShopAreaServiceImpl extends ServiceImpl<ShopAreaMapper, ShopArea> implements ShopAreaService{
|
||||
|
||||
}
|
||||
@@ -1,11 +1,24 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.account.dto.table.ShopTableAddDTO;
|
||||
import com.czg.account.entity.ShopArea;
|
||||
import com.czg.account.service.ShopAreaService;
|
||||
import com.czg.enums.ShopTableStatusEnum;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopTable;
|
||||
import com.czg.account.service.ShopTableService;
|
||||
import com.czg.service.account.mapper.ShopTableMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 台桌配置 服务层实现。
|
||||
*
|
||||
@@ -14,5 +27,40 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable> implements ShopTableService{
|
||||
@Resource
|
||||
private ShopAreaService shopAreaService;
|
||||
|
||||
@Override
|
||||
public Boolean add(Long shopId, ShopTableAddDTO shopTableAddDTO) {
|
||||
ShopArea shopArea = shopAreaService.getOne(new QueryWrapper().eq(ShopArea::getShopId, shopId)
|
||||
.eq(ShopArea::getId, shopTableAddDTO.getAreaId()));
|
||||
if (shopArea == null) {
|
||||
throw new ApiNotPrintException("台桌区域不存在");
|
||||
}
|
||||
|
||||
List<String> existisList = queryChain().eq(ShopTable::getShopId, shopId).like(ShopTable::getName, shopTableAddDTO.getSign()).list().stream().map(ShopTable::getName).toList();
|
||||
StringBuilder msg = new StringBuilder();
|
||||
ArrayList<ShopTable> tableArrayList = new ArrayList<>();
|
||||
for (int i = shopTableAddDTO.getStart(); i <= shopTableAddDTO.getEnd(); i++) {
|
||||
String name = shopTableAddDTO.getSign() + i;
|
||||
if (!existisList.isEmpty() && existisList.contains(name)) {
|
||||
msg.append(name).append(";");
|
||||
continue;
|
||||
}
|
||||
ShopTable shopTable = new ShopTable();
|
||||
shopTable.setShopId(shopId);
|
||||
shopTable.setName(name);
|
||||
shopTable.setMaxCapacity(shopTableAddDTO.getCapacity());
|
||||
shopTable.setAreaId(shopTableAddDTO.getAreaId());
|
||||
shopTable.setStatus(ShopTableStatusEnum.CLOSED.getValue());
|
||||
tableArrayList.add(shopTable);
|
||||
}
|
||||
|
||||
saveBatch(tableArrayList);
|
||||
if (StrUtil.isNotBlank(msg.toString())) {
|
||||
msg.append("台桌名已存在,未添加");
|
||||
throw new ApiNotPrintException(msg.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?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="com.czg.service.account.mapper.ShopAreaMapper">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user