Merge branch 'refs/heads/master' into 支付优化测试

# Conflicts:
#	yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dishes/vo/AppSaveVO.java
This commit is contained in:
seesaw
2024-10-21 14:43:45 +08:00
5 changed files with 43 additions and 17 deletions

View File

@ -32,4 +32,7 @@ public class AppUpdateVO {
@Schema(description = "时段", example = "")
private String timeSlot;
@Schema(description = "门店", example = "")
private Long carteenId;
}

View File

@ -37,20 +37,18 @@ public class DishesTypeAppController {
@Resource
private DishesTypeService dishesTypeService;
// @PostMapping("/create")
// @Operation(summary = "创建菜品分类")
// @PreAuthorize("@ss.hasPermission('t:dishes-type:create')")
// public CommonResult<Long> createDishesType(@Valid @RequestBody DishesTypeSaveReqVO createReqVO) {
// return success(dishesTypeService.createDishesType(createReqVO));
// }
//
// @PutMapping("/update")
// @Operation(summary = "更新菜品分类")
// @PreAuthorize("@ss.hasPermission('t:dishes-type:update')")
// public CommonResult<Boolean> updateDishesType(@Valid @RequestBody DishesTypeSaveReqVO updateReqVO) {
// dishesTypeService.updateDishesType(updateReqVO);
// return success(true);
// }
@PostMapping("/create")
@Operation(summary = "创建菜品分类")
public CommonResult<Long> createDishesType(@Valid @RequestBody DishesTypeSaveReqVO createReqVO) {
return success(dishesTypeService.createDishesType(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新菜品分类")
public CommonResult<Boolean> updateDishesType(@Valid @RequestBody DishesTypeSaveReqVO updateReqVO) {
dishesTypeService.updateDishesType(updateReqVO);
return success(true);
}
//
// @DeleteMapping("/delete")
// @Operation(summary = "删除菜品分类")
@ -92,4 +90,6 @@ public class DishesTypeAppController {
// BeanUtils.toBean(list, DishesTypeRespVO.class));
// }
}

View File

@ -113,8 +113,10 @@ public class DishesServiceImpl implements DishesService {
DishesDO dishes = BeanUtils.toBean(vo, DishesDO.class);
dishes.setDeleted(Boolean.FALSE);
Long carteenId = deviceInfoService.getCarteen(getHearder());
dishes.setCarteenId(carteenId);
if(vo.getCarteenId() == null ){
vo.setCarteenId(deviceInfoService.getCarteen(getHearder())) ;
}
dishes.setCarteenId(vo.getCarteenId());
dishes.setDishesNumber(new BigDecimal("50"));
checkDishes(dishes.getDishesName(),dishes.getCarteenId(),null);
@ -178,7 +180,11 @@ public class DishesServiceImpl implements DishesService {
DishesDO dishesDO = validateDishesExists(vo.getId());
DishesDO updateObj = BeanUtils.toBean(vo, DishesDO.class);
checkDishes(updateObj.getDishesName(),dishesDO.getCarteenId(),vo.getId());
if(updateObj.getCarteenId() == null ){
updateObj.setCarteenId(dishesDO.getCarteenId()) ;
}
checkDishes(updateObj.getDishesName(),updateObj.getCarteenId(),vo.getId());
//计算每g多少钱
BigDecimal dishesSumPrice = updateObj.getDishesSumPrice();

View File

@ -17,6 +17,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.dishestype.DishesTypeMapper;
import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.system.enums.TimePeriodEnum;
import cn.iocoder.yudao.module.system.service.dishes.DishesService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -50,6 +51,7 @@ public class DishesTypeServiceImpl implements DishesTypeService {
// 插入
DishesTypeDO dishesType = BeanUtils.toBean(createReqVO, DishesTypeDO.class);
dishesType.setDeleted(Boolean.FALSE);
validateDishesTypeRepeat(dishesType.getCarteenId(),dishesType.getDishesTypeName(),null);
dishesTypeMapper.insert(dishesType);
// 返回
return dishesType.getId();
@ -59,6 +61,7 @@ public class DishesTypeServiceImpl implements DishesTypeService {
public void updateDishesType(DishesTypeSaveReqVO updateReqVO) {
// 校验存在
validateDishesTypeExists(updateReqVO.getId());
validateDishesTypeRepeat(updateReqVO.getCarteenId(),updateReqVO.getDishesTypeName(),updateReqVO.getId());
// 更新
DishesTypeDO updateObj = BeanUtils.toBean(updateReqVO, DishesTypeDO.class);
dishesTypeMapper.updateById(updateObj);
@ -78,6 +81,19 @@ public class DishesTypeServiceImpl implements DishesTypeService {
}
}
private void validateDishesTypeRepeat(Long carteenId,String dishesTypeName,Long id) {
LambdaQueryWrapper<DishesTypeDO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(DishesTypeDO::getCarteenId,carteenId);
wrapper.eq(DishesTypeDO::getDishesTypeName,dishesTypeName);
wrapper.ne(id!=null,DishesTypeDO::getId,id);
List<DishesTypeDO> dishesTypeDOS = dishesTypeMapper.selectList(wrapper);
if (CollectionUtil.isNotEmpty(dishesTypeDOS)) {
throw exception(ErrorCodeConstants.DISHES_TYPE_NAME_REPEAT);
}
}
@Override
public DishesTypeDO getDishesType(Long id) {
return dishesTypeMapper.selectById(id);