Parcourir la source

plus套餐设备选择-按商户分页查设备

tanbin il y a 1 an
Parent
commit
ed581c5f79

+ 12 - 0
device-api-service-merc-mini/src/main/java/com/xy/controller/MercMiniDeviceController.java

@@ -118,6 +118,18 @@ public class MercMiniDeviceController {
         return deviceInfoService.pageByAdminName(dto);
         return deviceInfoService.pageByAdminName(dto);
     }
     }
 
 
+    @ApiOperation("设备分页-商户")
+    @PostMapping("pageByMerc")
+    public R<PageBean<DeviceInfoDto.Vo>> pageByMerc(@RequestBody @Validated DeviceInfoDto.PageByMercDto dto) {
+        List<Long> deviceIds = dto.getDeviceIds();
+        dto.setMercId(MercAuthUtils.getMercId());
+        Boolean choosed = dto.getChoosed();
+        if (BooleanUtil.isTrue(choosed)) {
+            //查询已选择,为前端传入 deviceIds
+            dto.setDeviceIds(deviceIds);
+        }
+        return R.ok(deviceInfoService.pageByMerc(dto));
+    }
 
 
     @ApiOperation("商户设备列表分页-穿梭框用")
     @ApiOperation("商户设备列表分页-穿梭框用")
     @PostMapping("myDeviceList")
     @PostMapping("myDeviceList")

+ 44 - 0
device-api-service/src/main/java/com/xy/service/DeviceInfoServiceImpl.java

@@ -410,6 +410,50 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         return R.ok(toPageBean(DeviceInfoDto.Vo.class, iPage));
         return R.ok(toPageBean(DeviceInfoDto.Vo.class, iPage));
     }
     }
 
 
+    /**
+     * 按商户分页查设备
+     *
+     * @param dto
+     * @return {@link PageBean}<{@link DeviceInfoDto.Vo}>
+     */
+    public PageBean<DeviceInfoDto.Vo> pageByMerc(DeviceInfoDto.PageByMercDto dto) {
+        PageBean pageBean = dto.getPage();
+        String deviceSearch = dto.getDeviceSearch();
+        List<Long> myDeviceIds = dto.getMyDeviceIds();
+        LambdaQueryWrapper<DeviceInfo> lqw = new MybatisPlusQuery().eqWrapper(dto, DeviceInfo.class)
+                .build();
+        List<Long> deviceIds = dto.getDeviceIds();
+        Boolean choosed = dto.getChoosed();
+
+
+        if (BooleanUtil.isFalse(choosed)) {
+            //未选择 排除已选择
+            if (CollUtil.isNotEmpty(deviceIds)) {
+                lqw.notIn(DeviceInfo::getDeviceId, deviceIds);
+            } else {
+                lqw.in(DeviceInfo::getDeviceId, myDeviceIds);
+            }
+        } else {
+            //已选择
+            //指定设备 已选择
+            if (CollUtil.isNotEmpty(deviceIds)) {
+                lqw.in(DeviceInfo::getDeviceId, deviceIds);
+            } else {
+                return new PageBean<>();
+            }
+        }
+
+        //设备搜索
+        lqw.and(StrUtil.isNotEmpty(deviceSearch),
+                wrapper -> wrapper
+                        .likeRight(DeviceInfo::getDeviceName, deviceSearch)
+                        .or()
+                        .likeRight(DeviceInfo::getDeviceId, deviceSearch)
+        );
+        IPage<DeviceInfo> iPage = page(toIPage(pageBean), lqw);
+        return toPageBean(DeviceInfoDto.Vo.class, iPage);
+    }
+
     @Override
     @Override
     @ApiOperation("对象查询")
     @ApiOperation("对象查询")
     public R<DeviceInfoDto.Vo> obj(DeviceInfoDto.Obj obj) {
     public R<DeviceInfoDto.Vo> obj(DeviceInfoDto.Obj obj) {

+ 30 - 0
device-api/src/main/java/com/xy/dto/DeviceInfoDto.java

@@ -16,6 +16,7 @@ import lombok.Data;
 import lombok.experimental.Accessors;
 import lombok.experimental.Accessors;
 
 
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDate;
@@ -47,6 +48,34 @@ public class DeviceInfoDto {
         private Long mercId;
         private Long mercId;
     }
     }
 
 
+    @Data
+    @Accessors(chain = true)
+    public static class PageByMercDto {
+        @NotNull(message = "分页信息不能为空")
+        @ApiModelProperty(value = "商户ID", required = true)
+        private PageBean page;
+
+        @ApiModelProperty("设备类型")
+        private Integer deviceType;
+
+
+        @ApiModelProperty("是否已选择")
+        private Boolean choosed;
+
+
+        @ApiModelProperty("设备id多个")
+        private List<Long> deviceIds;
+
+        @ApiModelProperty("权限设备id多个")
+        private List<Long> myDeviceIds;
+
+        @ApiModelProperty("设备搜索")
+        private String deviceSearch;
+
+        @ApiModelProperty(value = "商户ID", required = true)
+        private Long mercId;
+
+    }
 
 
     @Data
     @Data
     @Accessors(chain = true)
     @Accessors(chain = true)
@@ -880,6 +909,7 @@ public class DeviceInfoDto {
     @Data
     @Data
     @Accessors(chain = true)
     @Accessors(chain = true)
     public static class MercDeviceUnBindDto {
     public static class MercDeviceUnBindDto {
+        @NotEmpty(message = "请选择设备!")
         @ApiModelProperty(value = "设备ID", required = false)
         @ApiModelProperty(value = "设备ID", required = false)
         private List<Long> deviceIds;
         private List<Long> deviceIds;