This commit is contained in:
seesaw
2024-10-17 16:01:04 +08:00
parent b8f709f284
commit 8d4f8a6706
19 changed files with 792 additions and 78 deletions

View File

@ -30,6 +30,8 @@ public interface DishesMapper extends BaseMapperX<DishesDO> {
.eqIfPresent(DishesDO::getDishesVipWeighPrice, reqVO.getDishesVipWeighPrice())
.eqIfPresent(DishesDO::getDishecCook, reqVO.getDishecCook())
.eqIfPresent(DishesDO::getDishecType, reqVO.getDishecType())
.eqIfPresent(DishesDO::getWeekTime, reqVO.getWeekTime())
.eqIfPresent(DishesDO::getTimeSlot,reqVO.getTimeSlot())
.inIfPresent(DishesDO::getWeekTime, reqVO.getWeekTimes())
.betweenIfPresent(DishesDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(DishesDO::getId));

View File

@ -69,7 +69,7 @@ public class DishesServiceImpl implements DishesService {
DishesDO dishes = BeanUtils.toBean(createReqVO, DishesDO.class);
dishes.setDeleted(Boolean.FALSE);
checkDishes(dishes.getDishesName(),dishes.getCarteenId());
checkDishes(dishes.getDishesName(),dishes.getCarteenId(),null);
LocalDateTime today = LocalDateTime.now();
int hour = today.getHour();
@ -117,7 +117,7 @@ public class DishesServiceImpl implements DishesService {
dishes.setCarteenId(carteenId);
dishes.setDishesNumber(new BigDecimal("50"));
checkDishes(dishes.getDishesName(),dishes.getCarteenId());
checkDishes(dishes.getDishesName(),dishes.getCarteenId(),null);
LocalDateTime today = LocalDateTime.now();
int hour = today.getHour();
@ -148,7 +148,7 @@ public class DishesServiceImpl implements DishesService {
// 更新
DishesDO updateObj = BeanUtils.toBean(updateReqVO, DishesDO.class);
checkDishes(updateObj.getDishesName(),updateObj.getCarteenId());
checkDishes(updateObj.getDishesName(),updateObj.getCarteenId(),updateReqVO.getId());
//计算每g多少钱
BigDecimal dishesSumPrice = updateObj.getDishesSumPrice();
@ -175,10 +175,10 @@ public class DishesServiceImpl implements DishesService {
@Override
public void updateDishesApp(AppUpdateVO vo) {
validateDishesExists(vo.getId());
DishesDO dishesDO = validateDishesExists(vo.getId());
DishesDO updateObj = BeanUtils.toBean(vo, DishesDO.class);
checkDishes(updateObj.getDishesName(),updateObj.getCarteenId());
checkDishes(updateObj.getDishesName(),dishesDO.getCarteenId(),vo.getId());
//计算每g多少钱
BigDecimal dishesSumPrice = updateObj.getDishesSumPrice();
@ -201,10 +201,12 @@ public class DishesServiceImpl implements DishesService {
dishesMapper.deleteById(id);
}
private void validateDishesExists(Long id) {
if (dishesMapper.selectById(id) == null) {
private DishesDO validateDishesExists(Long id) {
DishesDO dishesDO = dishesMapper.selectById(id);
if ( dishesDO == null) {
throw exception(ErrorCodeConstants.DISHES_NOT_EXISTS);
}
return dishesDO;
}
/**
@ -308,13 +310,13 @@ public class DishesServiceImpl implements DishesService {
}
void checkDishes(String dishName,Long carteenId){
void checkDishes(String dishName,Long carteenId,Long id){
List<DishesDO> dishesDOS = dishesMapper.selectList(Wrappers.<DishesDO>lambdaQuery()
.eq(DishesDO::getCarteenId, carteenId)
.eq(DishesDO::getDishesName, dishName));
.eq(DishesDO::getDishesName, dishName)
.ne(id!=null, DishesDO::getId, id));
if(!dishesDOS.isEmpty()){
throw exception(2000_10_002, "菜品名称已存在");
throw exception(ErrorCodeConstants.DISHES_EXISTS);
}
}