新增每日菜谱选择接口
This commit is contained in:
1 parent
5e8f5a2e2e
commit
2333d0d28f
5 files changed
+118
-3
No files matched your search
+61
@@ -0,0 +1,61 @@
|
||||
package com.bsd.pjcloud.canteen.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 每日菜谱选择菜品dto
|
||||
*
|
||||
* @author zhangjiafu
|
||||
* @date 2024-12-10 12:51:53
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "菜品spudto")
|
||||
public class CanteenDailySpuDTO {
|
||||
|
||||
|
||||
/**
|
||||
* 商品 SPU 编号,自增
|
||||
*/
|
||||
@Schema(description="商品 SPU 编号,自增")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@Schema(description="商品名称")
|
||||
private String name;
|
||||
|
||||
|
||||
/**
|
||||
* 商品分类编号
|
||||
*/
|
||||
@Schema(description="商品分类编号")
|
||||
private Long categoryId;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "开始时间")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@NotNull
|
||||
private LocalDate startTime;
|
||||
|
||||
|
||||
/**
|
||||
* 时间类型
|
||||
*/
|
||||
@Schema(description = "时间类型")
|
||||
@NotNull
|
||||
private Integer hourType;
|
||||
|
||||
|
||||
}
|
||||
+16
@@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenDailySpuDTO;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenOnlineSpuEntity;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
@@ -60,6 +61,21 @@ public class CanteenSpuController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 每日分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "每日菜谱选择菜品分页查询", description = "每日菜谱选择菜品分页查询")
|
||||
@GetMapping("/pageDaily")
|
||||
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_view')")
|
||||
public R getCanteenSpuPageDaily(@ParameterObject Page page, @ParameterObject CanteenDailySpuDTO canteenDailySpuDTO) {
|
||||
return R.ok(canteenSpuService.pageDailyScope(page,canteenDailySpuDTO));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询菜品spu
|
||||
*
|
||||
|
||||
+10
@@ -3,6 +3,7 @@ package com.bsd.pjcloud.canteen.service;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenDailySpuDTO;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenSpuEntity;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
@@ -41,4 +42,13 @@ public interface CanteenSpuService extends IService<CanteenSpuEntity> {
|
||||
* @return
|
||||
*/
|
||||
Object pageScope(Page page, LambdaQueryWrapper<CanteenSpuEntity> wrapper);
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询,并且过滤已选择的菜品
|
||||
* @param page
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
Object pageDailyScope(Page page, CanteenDailySpuDTO canteenDailySpuDTO);
|
||||
}
|
||||
+27
@@ -1,9 +1,13 @@
|
||||
package com.bsd.pjcloud.canteen.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenDailySpuDTO;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenDailyMenuEntity;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenOnlineSpuEntity;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenSpuEntity;
|
||||
import com.bsd.pjcloud.canteen.mapper.CanteenSpuMapper;
|
||||
@@ -17,8 +21,10 @@ import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 菜品spu
|
||||
@@ -30,6 +36,8 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
public class CanteenSpuServiceImpl extends ServiceImpl<CanteenSpuMapper, CanteenSpuEntity> implements CanteenSpuService {
|
||||
|
||||
|
||||
private final CanteenDailyMenuService canteenDailyMenuService;
|
||||
@Override
|
||||
public Object selectFoodList(LambdaQueryWrapper<CanteenSpuEntity> wrapper) {
|
||||
return baseMapper.selectListByScope(wrapper, DataScope.of());
|
||||
@@ -73,5 +81,24 @@ public class CanteenSpuServiceImpl extends ServiceImpl<CanteenSpuMapper, Canteen
|
||||
return baseMapper.selectPageByScope(page, wrapper, DataScope.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object pageDailyScope(Page page, CanteenDailySpuDTO canteenDailySpuDTO) {
|
||||
LambdaQueryWrapper<CanteenSpuEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.like(StrUtil.isNotBlank(canteenDailySpuDTO.getName()), CanteenSpuEntity::getName, canteenDailySpuDTO.getName());
|
||||
wrapper.eq(Objects.nonNull(canteenDailySpuDTO.getCategoryId()), CanteenSpuEntity::getCategoryId, canteenDailySpuDTO.getCategoryId());
|
||||
|
||||
//查询今时今日已经选择的菜品
|
||||
LambdaQueryWrapper<CanteenDailyMenuEntity> DyWrapper = Wrappers.lambdaQuery();
|
||||
DyWrapper.eq(CanteenDailyMenuEntity::getStartTime, canteenDailySpuDTO.getStartTime());
|
||||
DyWrapper.eq(CanteenDailyMenuEntity::getHourType, canteenDailySpuDTO.getHourType());
|
||||
List<CanteenDailyMenuEntity> list = canteenDailyMenuService.list(DyWrapper);
|
||||
|
||||
List<Long> spuIds = list.stream().map(CanteenDailyMenuEntity::getSpuId).distinct().collect(java.util.stream.Collectors.toList());
|
||||
wrapper.notIn(!CollectionUtils.isEmpty(list), CanteenSpuEntity::getId, spuIds);
|
||||
|
||||
return baseMapper.selectPageByScope(page, wrapper, DataScope.of());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+4
-3
@@ -20,6 +20,7 @@ import com.bsd.pjcloud.supermarket.service.SupermarketAuxiliaryCodeService;
|
||||
import com.bsd.pjcloud.supermarket.service.SupermarketSpuService;
|
||||
import com.bsd.pjcloud.supermarket.service.SupermarketUnitService;
|
||||
import com.bsd.pjcloud.supermarket.vo.app.SupermarketAppSpuVo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
@@ -63,9 +64,9 @@ public class SupermarketSpuController {
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')" )
|
||||
public R getSupermarketSpuPage(@ParameterObject Page page, @ParameterObject SupermarketSpuEntity supermarketSpu) {
|
||||
LambdaQueryWrapper<SupermarketSpuEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(StrUtil.isNotBlank(supermarketSpu.getProductCode()),SupermarketSpuEntity::getProductCode,supermarketSpu.getProductCode());
|
||||
wrapper.eq(StrUtil.isNotBlank(supermarketSpu.getBarcode()),SupermarketSpuEntity::getBarcode,supermarketSpu.getBarcode());
|
||||
wrapper.eq(StrUtil.isNotBlank(supermarketSpu.getProductName()),SupermarketSpuEntity::getProductName,supermarketSpu.getProductName());
|
||||
wrapper.eq(StringUtils.isNotBlank(supermarketSpu.getProductCode()),SupermarketSpuEntity::getProductCode,supermarketSpu.getProductCode());
|
||||
wrapper.eq(StringUtils.isNotBlank(supermarketSpu.getBarcode()),SupermarketSpuEntity::getBarcode,supermarketSpu.getBarcode());
|
||||
wrapper.eq(StringUtils.isNotBlank(supermarketSpu.getProductName()),SupermarketSpuEntity::getProductName,supermarketSpu.getProductName());
|
||||
return R.ok(supermarketSpuService.pageScope(page, wrapper));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user