feat(shop): 添加根据企业ID获取店铺列表功能并修正限购数量类型

- 在ShopService接口和实现类中添加getShopListByCorpid方法
- 在ShopApplicationService中实现业务逻辑
- 在ShopController中新增/list接口
- 将monthlyPurchaseLimit字段类型从String改为Integer
This commit is contained in:
dzq 2025-06-10 11:16:05 +08:00
parent a4f79e3e28
commit cf5e5fa673
7 changed files with 32 additions and 4 deletions

View File

@ -20,6 +20,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import com.agileboot.domain.shop.shop.ShopApplicationService;
import com.agileboot.domain.shop.shop.db.ShopEntity;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
@ -34,10 +36,21 @@ import org.springframework.web.util.UriComponentsBuilder;
@Slf4j
@RequiredArgsConstructor
public class ShopController {
private final ShopApplicationService shopApplicationService;
private final GoodsApplicationService goodsApplicationService;
private final CategoryApplicationService categoryApplicationService;
@GetMapping("/list")
public ResponseDTO<List<ShopEntity>> getShopList(@RequestParam(required = false) String corpid) {
List<ShopEntity> shopList;
if (StringUtils.isNotBlank(corpid)) {
shopList = shopApplicationService.getShopListByCorpid(corpid);
} else {
shopList = shopApplicationService.getShopListByCorpid(WeixinConstants.corpid);
}
return ResponseDTO.ok(shopList);
}
@GetMapping("/goods")
public ResponseDTO<ShopGoodsResponse> getShopGoodsInfo(@RequestParam(required = false) Long shopId) {
/*// 获取商品列表

View File

@ -51,6 +51,6 @@ public class PostAssetGoodsCommand {
private Integer belongType;
@ApiModelProperty("每人每月限购数量")
private String monthlyPurchaseLimit;
private Integer monthlyPurchaseLimit;
}
}

View File

@ -50,7 +50,7 @@ public class ShopGoodsEntity extends BaseEntity<ShopGoodsEntity> {
@ApiModelProperty("每人每月限购数量")
@TableField("monthly_purchase_limit")
private String monthlyPurchaseLimit;
private Integer monthlyPurchaseLimit;
@ApiModelProperty("销售价格")
@TableField("price")

View File

@ -103,5 +103,5 @@ public class ShopGoodsDTO {
private String usageInstruction;
@ExcelColumn(name = "每人每月限购数量")
private String monthlyPurchaseLimit;
private Integer monthlyPurchaseLimit;
}

View File

@ -32,6 +32,10 @@ public class ShopApplicationService {
return new PageDTO<>(dtoList, page.getTotal());
}
public List<ShopEntity> getShopListByCorpid(String corpid) {
return shopService.getShopListByCorpid(corpid);
}
public void addShop(AddShopCommand command) {
ShopModel model = shopModelFactory.create();
model.loadAddCommand(command);

View File

@ -27,4 +27,6 @@ public interface ShopService extends IService<ShopEntity> {
ShopEntity selectByShopName(String shopName);
Long countAllRecord();
List<ShopEntity> getShopListByCorpid(String corpid);
}

View File

@ -1,6 +1,7 @@
package com.agileboot.domain.shop.shop.db;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
@ -47,4 +48,12 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopEntity> impleme
public Long countAllRecord() {
return baseMapper.countAllRecord();
}
@Override
public List<ShopEntity> getShopListByCorpid(String corpid) {
QueryWrapper<ShopEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("corpid", corpid)
.eq("deleted", 0);
return this.list(queryWrapper);
}
}