2021与蓝度共同重构项目,服务端
fix
zhanzhiqin
2022-04-27 0064fa7e640994b361d34fef55e13a9d0157f8bd
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
@@ -5,6 +5,7 @@
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.sandu.common.domain.CommonPage;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.redis.RedisService;
import com.sandu.common.service.impl.BaseServiceImpl;
@@ -116,7 +117,7 @@
                );
                for (LightReportData lightReportData : reportDataList) {
                    if (StrUtil.equals(lightBo.getDeviceCode(), lightReportData.getDeviceCode())) {
                        lightBo.setReportTime(lightReportData.getCreateTime());
                        lightBo.setReportTime(lightReportData.getCreateTime1());
                        break;
                    }
                }
@@ -470,8 +471,27 @@
    /**
     * 获取用户所有的设备码
     */
    public List<String> listDeviceCode(/*int start, int end*/) {
        return baseMapper.listCode(/*start,end,*/SecurityUtils.getClientId());
    public CommonPage<String> listDeviceCode(int pageNo, int pageSize, String keyword, String deviceCode) {
        List<String> list;
        if (SecurityUtils.getClientId() != null) {
            PageHelper.startPage(pageNo, pageSize);
            list = baseMapper.listCode(SecurityUtils.getUserId(), keyword, deviceCode);
        } else {
            PageHelper.startPage(pageNo, pageSize);
            list = baseMapper.listCode(null, keyword, deviceCode);
        }
        return CommonPage.restPage(list);
    }
    public boolean setPower(List<Long> ids, Integer power1, Integer power2) {
        List<Light> lights = listByIds(ids);
        lights.forEach(light -> {
                    light.setPower1(power1);
                    light.setPower2(power2);
                }
        );
        return updateBatchById(lights);
    }
}