diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceQuery.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceQuery.java index 2222e046..a922ff89 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceQuery.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceQuery.java @@ -94,4 +94,7 @@ public class DeviceQuery extends Device { @ApiModelProperty("排除ID") private Long excludeDeviceId; + + @ApiModelProperty("关键词") + private String keyword; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.xml index 7e3b690e..d80b9af0 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.xml @@ -126,6 +126,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and sd.version like concat('%', #{version}, '%') and find_in_set(#{modelTag}, sm.tags) and sd.device_id != #{excludeDeviceId} + + and ( + sd.device_name like concat('%', #{keyword}, '%') or + sd.device_no like concat('%', #{keyword}, '%') or + su.phonenumber like concat('%', #{keyword}, '%') or + su.user_name like concat('%', #{keyword}, '%') + ) + and (sd.rent_time is null or sd.rent_time <= now()) diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java index d367ac86..d6f3d1ef 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java @@ -55,6 +55,7 @@ import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO; import com.ruoyi.ss.transactionBill.service.TransactionBillService; import com.ruoyi.ss.user.domain.SmUserVO; import com.ruoyi.ss.user.service.ISmUserService; +import com.ruoyi.ss.user.service.UserValidator; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -135,6 +136,9 @@ public class DeviceServiceImpl implements DeviceService @Autowired private DeviceSuitConverter deviceConverter; + @Autowired + private UserValidator userValidator; + /** * 查询设备 * @@ -742,6 +746,7 @@ public class DeviceServiceImpl implements DeviceService if (deviceId == null || agentId == null || agentServiceRate == null) { return 0; } + ServiceUtil.assertion(!userValidator.isAgent(agentId), "该用户不是代理商,无法绑定为设备代理商"); Integer result = transactionTemplate.execute(status -> { // 绑定 diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/mapper/SmUserMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/user/mapper/SmUserMapper.xml index 26a17736..ecaf4bca 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/user/mapper/SmUserMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/mapper/SmUserMapper.xml @@ -134,7 +134,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"