feat(店铺/智能柜): 增加按店铺ID和模式筛选功能
修改店铺列表接口,支持传入mode参数进行筛选 智能柜详情接口改为按shopId查询相关数据
This commit is contained in:
parent
ad1d764991
commit
4e4c4876b6
agileboot-api/src/main/java/com/agileboot/api/controller
agileboot-domain/src/main/java/com/agileboot/domain
cabinet/smartCabinet
shop/shop
|
@ -41,8 +41,8 @@ public class CabinetCellController {
|
|||
private final CabinetMainboardModelFactory cabinetMainboardModelFactory;
|
||||
|
||||
@GetMapping("/detail")
|
||||
public ResponseDTO<List<CabinetDetailDTO>> getCabinetDetail() {
|
||||
return ResponseDTO.ok(smartCabinetApplicationService.getCabinetDetail());
|
||||
public ResponseDTO<List<CabinetDetailDTO>> getCabinetDetail(@RequestParam Long shopId) {
|
||||
return ResponseDTO.ok(smartCabinetApplicationService.getCabinetDetail(shopId));
|
||||
}
|
||||
|
||||
@PostMapping("/openCabinet/{cabinetId}/{pinNo}")
|
||||
|
|
|
@ -41,12 +41,14 @@ public class ShopController {
|
|||
private final CategoryApplicationService categoryApplicationService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public ResponseDTO<List<ShopEntity>> getShopList(@RequestParam(required = false) String corpid) {
|
||||
public ResponseDTO<List<ShopEntity>> getShopList(@RequestParam(required = false) String corpid,
|
||||
@RequestParam(required = false) Long mode) {
|
||||
List<ShopEntity> shopList;
|
||||
Long modeValue = mode != null ? mode : 4L;
|
||||
if (StringUtils.isNotBlank(corpid)) {
|
||||
shopList = shopApplicationService.getShopListByCorpid(corpid);
|
||||
shopList = shopApplicationService.getShopListByCorpid(corpid, modeValue);
|
||||
} else {
|
||||
shopList = shopApplicationService.getShopListByCorpid(WeixinConstants.corpid);
|
||||
shopList = shopApplicationService.getShopListByCorpid(WeixinConstants.corpid, modeValue);
|
||||
}
|
||||
return ResponseDTO.ok(shopList);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -146,11 +147,32 @@ public class SmartCabinetApplicationService {
|
|||
* 获取所有智能柜的详细信息
|
||||
* @return 包含柜体信息、单元格信息和商品信息的列表
|
||||
*/
|
||||
public List<CabinetDetailDTO> getCabinetDetail() {
|
||||
public List<CabinetDetailDTO> getCabinetDetail(Long shopId) {
|
||||
// 获取所有智能柜、单元格和商品的基础数据
|
||||
List<SmartCabinetEntity> smartCabinets = smartCabinetService.selectAll();
|
||||
List<CabinetCellEntity> cabinetCells = cabinetCellService.selectAll();
|
||||
List<ShopGoodsEntity> goodsList = shopGoodsService.selectAll();
|
||||
QueryWrapper<SmartCabinetEntity> smartCabinetEntityQueryWrapper = new QueryWrapper<>();
|
||||
smartCabinetEntityQueryWrapper.eq("shop_id", shopId)
|
||||
.eq("deleted", false);
|
||||
List<SmartCabinetEntity> smartCabinets = smartCabinetService.list(smartCabinetEntityQueryWrapper);
|
||||
|
||||
QueryWrapper<CabinetCellEntity> cabinetCellEntityQueryWrapper = new QueryWrapper<>();
|
||||
cabinetCellEntityQueryWrapper.in("cabinet_id",
|
||||
smartCabinets.stream()
|
||||
.map(SmartCabinetEntity::getCabinetId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList()))
|
||||
.eq("deleted", false);
|
||||
List<CabinetCellEntity> cabinetCells = cabinetCellService.list(cabinetCellEntityQueryWrapper);
|
||||
|
||||
QueryWrapper<ShopGoodsEntity> shopGoodsEntityQueryWrapper = new QueryWrapper<>();
|
||||
shopGoodsEntityQueryWrapper.in("goods_id",
|
||||
cabinetCells.stream()
|
||||
.map(CabinetCellEntity::getGoodsId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList()))
|
||||
.eq("deleted", false);
|
||||
List<ShopGoodsEntity> goodsList = shopGoodsService.list(shopGoodsEntityQueryWrapper);
|
||||
|
||||
List<CabinetDetailDTO> result = new ArrayList<>();
|
||||
// 遍历每个智能柜构建详细信息
|
||||
|
|
|
@ -37,8 +37,8 @@ public class ShopApplicationService {
|
|||
return new ShopDTO(shopEntity);
|
||||
}
|
||||
|
||||
public List<ShopEntity> getShopListByCorpid(String corpid) {
|
||||
return shopService.getShopListByCorpid(corpid);
|
||||
public List<ShopEntity> getShopListByCorpid(String corpid, Long mode) {
|
||||
return shopService.getShopListByCorpid(corpid, mode);
|
||||
}
|
||||
|
||||
public void addShop(AddShopCommand command) {
|
||||
|
|
|
@ -28,5 +28,5 @@ public interface ShopService extends IService<ShopEntity> {
|
|||
|
||||
Long countAllRecord();
|
||||
|
||||
List<ShopEntity> getShopListByCorpid(String corpid);
|
||||
List<ShopEntity> getShopListByCorpid(String corpid, Long mode);
|
||||
}
|
||||
|
|
|
@ -50,10 +50,10 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopEntity> impleme
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ShopEntity> getShopListByCorpid(String corpid) {
|
||||
public List<ShopEntity> getShopListByCorpid(String corpid, Long mode) {
|
||||
QueryWrapper<ShopEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("corpid", corpid)
|
||||
.ne("mode", 4)
|
||||
.ne("mode", mode)
|
||||
.eq("deleted", 0);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue