Explorar o código

feta: 修改查询门店接口

pangqijun hai 3 meses
pai
achega
9f3178ebad

+ 12 - 6
src/main/java/org/springblade/modules/api/controller/ApiShopController.java

@@ -1,9 +1,7 @@
 package org.springblade.modules.api.controller;
 
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.lang.Assert;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
@@ -11,6 +9,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.AllArgsConstructor;
+import org.springblade.common.base.BaseEntity;
 import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.utils.DistanceUtils;
 import org.springblade.core.mp.support.Condition;
@@ -24,6 +23,7 @@ import org.springblade.modules.business.service.IFacilityService;
 import org.springblade.modules.business.service.IShopService;
 import org.springblade.modules.business.vo.ShopVO;
 import org.springblade.modules.business.wrapper.ShopWrapper;
+import org.springblade.modules.system.service.IUserMerchantService;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
@@ -33,10 +33,11 @@ import java.util.List;
 @AllArgsConstructor
 @RequestMapping(CommonConstant.API_URL + "/shop")
 @Api(value = "门店管理接口", tags = "门店管理接口")
-public class ApiShopController {
+public class ApiShopController extends BaseController {
 
     private final IShopService iShopService;
     private final IFacilityService iFacilityService;
+    private final IUserMerchantService iUserMerchantService;
 
     @PostMapping("/add")
     @ApiOperationSupport(order = 1)
@@ -60,9 +61,14 @@ public class ApiShopController {
     @ApiOperationSupport(order = 3)
     @ApiOperation(value = "分页查询门店列表", notes = "传入shop")
     public R<IPage<ShopVO>> page(ShopVO shop, Query query) {
+        LambdaQueryWrapper<Shop> wrapper = Wrappers.lambdaQuery(Shop.class);
+        wrapper.eq(Shop::getMerchantId, AuthUtil.getUserId());
         shop.setMerchantId(AuthUtil.getUserId());
-        IPage<ShopVO> pages = iShopService.selectShopPage(Condition.getPage(query), shop);
-        return R.data(pages);
+        if (!isMerchant()) {
+            wrapper.in(BaseEntity::getId, iUserMerchantService.getByUserId(AuthUtil.getUserId()));
+        }
+        IPage<Shop> pages = iShopService.page(Condition.getPage(query), wrapper);
+        return R.data(ShopWrapper.build().pageVO(pages));
     }
 
     @GetMapping("/detail")