mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-19 01:48:47 +08:00
家庭主体需求变更
This commit is contained in:
parent
e6701636c5
commit
6582f477f4
@ -4,6 +4,7 @@ import cn.dev33.satoken.secure.BCrypt;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.domain.model.LoginUser;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
@ -23,6 +24,7 @@ import org.dromara.web.domain.bo.EqAppHomeBo;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -39,7 +41,7 @@ import java.util.List;
|
||||
public class EqHomeController extends BaseController {
|
||||
|
||||
private final IEqAreaService eqAreaService;
|
||||
|
||||
private final IEqFamilyService eqFamilyService;
|
||||
private final IEqEquipmentService eqEquipmentService;
|
||||
|
||||
private final IEqShareService shareService;
|
||||
@ -84,6 +86,84 @@ public class EqHomeController extends BaseController {
|
||||
return R.ok(eqShareVos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的家庭 查询家庭列表详细
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/familyListDetail")
|
||||
public R<List<EqShareDetailVo>> familyListDetail(){
|
||||
List<EqShareDetailVo> result = new ArrayList<>();
|
||||
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);
|
||||
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<EqAreaVo> eqAreaVos = eqAreaService.queryList(new EqAreaBo(shareUserId));
|
||||
List<EqEquipmentVo> eqEquipmentVos = eqEquipmentService.queryList(new EqEquipmentBo(shareUserId));
|
||||
eqShareDetailVo.setEqAreaVos(eqAreaVos);
|
||||
eqShareDetailVo.setEqEquipmentVos(eqEquipmentVos);
|
||||
eqShareDetailVo.setAreaNum(eqAreaVos.size());
|
||||
eqShareDetailVo.setEqNum(eqEquipmentVos.size());
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改家庭名称
|
||||
*/
|
||||
@PostMapping("/updateFamilyName")
|
||||
public R<Void> updateFamilyName(@RequestBody EqFamilyBo bo) {
|
||||
if (bo.getFamilyName() == null) return R.fail("家庭名称不能为空");
|
||||
if (bo.getUserId() == null) return R.fail("用户id不能为空");
|
||||
if (!LoginHelper.getUserId().equals(bo.getUserId())) throw new RuntimeException("不能操作其他家庭主体名称");
|
||||
List<EqFamilyVo> eqFamilyVos = eqFamilyService.queryList(new EqFamilyBo(bo.getUserId()));
|
||||
if (eqFamilyVos.isEmpty()) {
|
||||
EqFamilyBo eqFamilyBo = new EqFamilyBo();
|
||||
eqFamilyBo.setUserId(bo.getUserId());
|
||||
eqFamilyBo.setFamilyName(bo.getFamilyName());
|
||||
eqFamilyService.insertByBo(eqFamilyBo);
|
||||
}else{
|
||||
EqFamilyVo eqFamilyVo = eqFamilyVos.get(0);
|
||||
eqFamilyVo.setFamilyName(bo.getFamilyName());
|
||||
eqFamilyService.updateByBo(bo);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 成员管理 查询家庭成员
|
||||
*/
|
||||
@ -168,7 +248,7 @@ public class EqHomeController extends BaseController {
|
||||
public TableDataInfo<EqEquipmentVo> list(EqAppHomeBo bo, PageQuery pageQuery){
|
||||
//当前用户为家庭主体 切换用户后需要传输用户id
|
||||
if (bo.getUserId() == null) bo.setUserId(LoginHelper.getUserId());
|
||||
//TODO 下面返回的状态 会在设备状态变化时更新设备状态
|
||||
// 下面返回的状态 会在设备状态变化时更新设备状态 状态更新由iot触发
|
||||
EqEquipmentBo eqEquipmentBo = new EqEquipmentBo();
|
||||
eqEquipmentBo.setUserId(bo.getUserId());
|
||||
return eqEquipmentService.queryPageList(eqEquipmentBo, pageQuery); //在设备表中增加了分布id
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package org.dromara.web.domain.bo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.dromara.web.domain.EqArea;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
@ -16,6 +18,8 @@ import jakarta.validation.constraints.*;
|
||||
* @date 2024-07-19
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = EqArea.class, reverseConvertGenerate = false)
|
||||
public class EqAreaBo extends BaseEntity {
|
||||
@ -44,5 +48,7 @@ public class EqAreaBo extends BaseEntity {
|
||||
@NotBlank(message = "位置描述不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String description;
|
||||
|
||||
|
||||
public EqAreaBo(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package org.dromara.web.domain.bo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.dromara.web.domain.EqEquipment;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
@ -18,6 +20,8 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
* @date 2024-07-19
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = EqEquipment.class, reverseConvertGenerate = false)
|
||||
public class EqEquipmentBo extends BaseEntity {
|
||||
@ -102,4 +106,9 @@ public class EqEquipmentBo extends BaseEntity {
|
||||
*/
|
||||
@NotNull(message = "排序", groups = { AddGroup.class, EditGroup.class })
|
||||
private Integer orderNum;
|
||||
|
||||
|
||||
public EqEquipmentBo(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package org.dromara.web.domain.bo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.dromara.web.domain.EqFamily;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
@ -16,6 +18,8 @@ import jakarta.validation.constraints.*;
|
||||
* @date 2024-07-19
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = EqFamily.class, reverseConvertGenerate = false)
|
||||
public class EqFamilyBo extends BaseEntity {
|
||||
@ -38,5 +42,7 @@ public class EqFamilyBo extends BaseEntity {
|
||||
@NotBlank(message = "家庭名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String familyName;
|
||||
|
||||
|
||||
public EqFamilyBo(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
package org.dromara.web.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.web.domain.EqShare;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 分享明细视图对象
|
||||
*
|
||||
* @author zzc
|
||||
* @date 2024-07-19
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class EqShareDetailVo extends EqShareVo {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 家庭名称
|
||||
*/
|
||||
private String familyName;
|
||||
|
||||
/**
|
||||
* 分布(区域)个数
|
||||
*/
|
||||
private int areaNum;
|
||||
|
||||
/**
|
||||
* 设备个数
|
||||
*/
|
||||
private int eqNum;
|
||||
|
||||
/**
|
||||
* 分布列表
|
||||
*/
|
||||
private List<EqAreaVo> eqAreaVos;
|
||||
|
||||
/**
|
||||
* 设备列表
|
||||
*/
|
||||
private List<EqEquipmentVo> eqEquipmentVos;
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user