mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 17:38:48 +08:00
代码优化
This commit is contained in:
parent
0710caa975
commit
9f4a703415
@ -7,6 +7,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MessageUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
@ -133,7 +134,9 @@ public class EqDeviceController extends BaseController {
|
||||
@GetMapping("/getDeviceLogs")
|
||||
public Map<String, List<EqEquipmentLogVo>> getDeviceLogs(EqAppHomeBo bo,PageQuery pageQuery){
|
||||
if (bo.getEquipmentId() == null) throw new ServiceException("设备ID不能为空");
|
||||
if (bo.getZoneId() == null) throw new ServiceException("时区zoneId(如 UTC+08:00)不能为空");
|
||||
String zoneId = bo.getZoneId();
|
||||
if (StringUtils.isEmpty(zoneId)) throw new ServiceException("时区zoneId(如 UTC+08:00)不能为空");
|
||||
if (zoneId.contains(" ")) zoneId = zoneId.replace(" ", "+");
|
||||
EqEquipmentLogBo eqEquipmentLogBo = new EqEquipmentLogBo();
|
||||
eqEquipmentLogBo.setEquipmentId(bo.getEquipmentId());
|
||||
TableDataInfo<EqEquipmentLogVo> data = logService.queryPageList(eqEquipmentLogBo, pageQuery);
|
||||
@ -141,7 +144,7 @@ public class EqDeviceController extends BaseController {
|
||||
if (CollUtil.isEmpty(rows)) return new HashMap<>();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String defaultZone = "UTC+08:00";
|
||||
String targetZone = bo.getZoneId();
|
||||
String targetZone = zoneId;
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
List<EqEquipmentLogVo> rowsData = rows.stream().peek(x -> {
|
||||
Integer status = x.getStatus();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package org.dromara.web.controller.app;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -68,7 +69,7 @@ public class EqHomeController extends BaseController {
|
||||
return toAjax(eqUserConfigService.updateByBo(bo));
|
||||
}
|
||||
/**
|
||||
* 首页切换 查询家庭主体
|
||||
* 首页切换 查询家庭主体(显示用户名称)
|
||||
*/
|
||||
@GetMapping("/familyList")
|
||||
public R<List<EqShareVo>> familyList(){
|
||||
@ -86,6 +87,52 @@ public class EqHomeController extends BaseController {
|
||||
return R.ok(eqShareVos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页切换 新版家庭主体(显示家庭账号)
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/homeFamilyList")
|
||||
public R<List<EqShareDetailVo>> homeFamilyList(){
|
||||
List<EqShareDetailVo> result = new ArrayList<>();
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
Long userId = loginUser.getUserId();
|
||||
String username = loginUser.getUsername();
|
||||
|
||||
EqShareVo firstVo = new EqShareVo();
|
||||
firstVo.setShareUserId(userId);
|
||||
firstVo.setShareUserName(username);
|
||||
firstVo.setSharedUserId(userId);//为了方便前端操作 统一放在被分享者字段中
|
||||
firstVo.setSharedUserName(username);
|
||||
|
||||
EqShareBo bo = new EqShareBo();
|
||||
bo.setSharedUserId(userId);
|
||||
List<EqShareVo> eqShareVos = shareService.queryList(bo);
|
||||
eqShareVos.add(0,firstVo);
|
||||
|
||||
for (EqShareVo eqShareVo : eqShareVos) {
|
||||
Long shareUserId = eqShareVo.getShareUserId();
|
||||
EqShareDetailVo eqShareDetailVo = new EqShareDetailVo();
|
||||
|
||||
eqShareDetailVo.setShareId(eqShareVo.getShareId());
|
||||
eqShareDetailVo.setShareUserId(eqShareVo.getShareUserId());
|
||||
eqShareDetailVo.setShareUserName(eqShareVo.getShareUserName());
|
||||
eqShareDetailVo.setSharedUserId(eqShareVo.getSharedUserId());
|
||||
eqShareDetailVo.setSharedUserName(eqShareVo.getSharedUserName());
|
||||
|
||||
List<EqFamilyVo> familyVos = eqFamilyService.queryList(new EqFamilyBo(shareUserId));
|
||||
String familyName = "";
|
||||
if (!familyVos.isEmpty()) {
|
||||
familyName = familyVos.get(0).getFamilyName()+"的家";
|
||||
}else{
|
||||
familyName = userId.equals(shareUserId)?"我的家":eqShareVo.getShareUserName()+"的家";
|
||||
}
|
||||
eqShareDetailVo.setFamilyName(familyName);
|
||||
|
||||
result.add(eqShareDetailVo);
|
||||
}
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的家庭 查询家庭列表详细
|
||||
* @return
|
||||
@ -96,8 +143,6 @@ public class EqHomeController extends BaseController {
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
Long userId = loginUser.getUserId();
|
||||
String username = loginUser.getUsername();
|
||||
List<EqFamilyVo> eqFamilyVos = eqFamilyService.queryList(new EqFamilyBo(userId));
|
||||
|
||||
|
||||
EqShareVo firstVo = new EqShareVo();
|
||||
firstVo.setShareUserId(userId);
|
||||
@ -265,6 +310,16 @@ public class EqHomeController extends BaseController {
|
||||
return toAjax(eqEquipmentService.updateByBos(bos));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备信息
|
||||
*/
|
||||
@Log(title = "设备信息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/editEquipment")
|
||||
public R<Void> editEquipment(@RequestBody EqEquipmentBo bo) {
|
||||
return toAjax(eqEquipmentService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备详情 (暂时无用)
|
||||
* 传参 设备id
|
||||
|
||||
@ -24,10 +24,7 @@ import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.system.domain.bo.SysUserBo;
|
||||
import org.dromara.system.domain.bo.SysUserPasswordBo;
|
||||
import org.dromara.system.domain.bo.SysUserProfileBo;
|
||||
import org.dromara.system.domain.vo.AvatarVo;
|
||||
import org.dromara.system.domain.vo.SysOssVo;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.dromara.system.domain.vo.UserInfoVo;
|
||||
import org.dromara.system.domain.vo.*;
|
||||
import org.dromara.system.service.*;
|
||||
import org.dromara.web.domain.bo.EqAppHomeBo;
|
||||
import org.dromara.web.domain.bo.EqAreaBo;
|
||||
@ -46,6 +43,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@ -201,8 +199,20 @@ public class EqUserController extends BaseController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private final ISysDictTypeService dictTypeService;
|
||||
/**
|
||||
* 根据字典类型查询字典数据信息
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
*/
|
||||
@GetMapping(value = "/type/{dictType}")
|
||||
public R<List<SysDictDataVo>> dictType(@PathVariable String dictType) {
|
||||
List<SysDictDataVo> data = dictTypeService.selectDictDataByType(dictType);
|
||||
if (ObjectUtil.isNull(data)) {
|
||||
data = new ArrayList<>();
|
||||
}
|
||||
return R.ok(data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -146,3 +146,4 @@ public class EqEquipmentLogVo implements Serializable {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user