Browse Source

群组部分 + 用户注销

hxd 4 tháng trước cách đây
mục cha
commit
3c7f2172cb
34 tập tin đã thay đổi với 1094 bổ sung77 xóa
  1. 4 7
      portal-service-application/src/main/java/com/hfln/portal/application/controller/wap/DeviceController.java
  2. 89 0
      portal-service-application/src/main/java/com/hfln/portal/application/controller/wap/GroupController.java
  3. 7 5
      portal-service-application/src/main/java/com/hfln/portal/application/controller/wap/UserController.java
  4. 43 0
      portal-service-common/src/main/java/com/hfln/portal/common/dto/data/group/GroupDTO.java
  5. 56 0
      portal-service-common/src/main/java/com/hfln/portal/common/dto/data/group/GroupShareDTO.java
  6. 4 3
      portal-service-common/src/main/java/com/hfln/portal/common/request/device/DeviceBandingParams.java
  7. 1 1
      portal-service-common/src/main/java/com/hfln/portal/common/request/device/DeviceLocationParams.java
  8. 24 0
      portal-service-common/src/main/java/com/hfln/portal/common/request/group/AddDeviceToGroupParams.java
  9. 25 0
      portal-service-common/src/main/java/com/hfln/portal/common/request/group/DeleteDeviceFromGroupParams.java
  10. 27 0
      portal-service-common/src/main/java/com/hfln/portal/common/request/group/GroupAddParams.java
  11. 23 0
      portal-service-common/src/main/java/com/hfln/portal/common/request/group/GroupDeleteParams.java
  12. 21 0
      portal-service-common/src/main/java/com/hfln/portal/common/request/group/GroupListParams.java
  13. 28 0
      portal-service-common/src/main/java/com/hfln/portal/common/request/group/GroupShareConfirmParams.java
  14. 24 0
      portal-service-common/src/main/java/com/hfln/portal/common/request/group/GroupShareHandleParams.java
  15. 35 0
      portal-service-common/src/main/java/com/hfln/portal/common/request/group/GroupUpdateParams.java
  16. 28 0
      portal-service-common/src/main/java/com/hfln/portal/common/request/group/ShareGroupParams.java
  17. 22 0
      portal-service-common/src/main/java/com/hfln/portal/common/request/user/UserLogoutParams.java
  18. 2 1
      portal-service-common/src/main/java/com/hfln/portal/common/request/user/UserUpdatePasswordParams.java
  19. 7 0
      portal-service-domain/src/main/java/com/hfln/portal/domain/exception/ErrorEnum.java
  20. 2 3
      portal-service-domain/src/main/java/com/hfln/portal/domain/gateway/DeviceGateway.java
  21. 31 0
      portal-service-domain/src/main/java/com/hfln/portal/domain/gateway/GroupGateway.java
  22. 3 4
      portal-service-domain/src/main/java/com/hfln/portal/domain/gateway/UserGateway.java
  23. 28 21
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/DeviceGatewayImpl.java
  24. 418 0
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/GroupGatewayImpl.java
  25. 79 9
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/UserGatewayImpl.java
  26. 14 2
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/po/DevGroup.java
  27. 4 4
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/po/DevInfo.java
  28. 2 2
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/po/DevShare.java
  29. 29 8
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/po/GroupShare.java
  30. 1 1
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/po/UserInfo.java
  31. 10 3
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/impl/DevInfoServiceImpl.java
  32. 1 1
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/impl/DevShareServiceImpl.java
  33. 1 1
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/impl/GroupShareServiceImpl.java
  34. 1 1
      portal-service-server/src/main/resources/bootstrap-dev.yml

+ 4 - 7
portal-service-application/src/main/java/com/hfln/portal/application/controller/wap/DeviceController.java

@@ -3,9 +3,7 @@ package com.hfln.portal.application.controller.wap;
 import cn.hfln.framework.catchlog.CatchAndLog;
 import cn.hfln.framework.dto.ApiResult;
 import com.hfln.portal.common.dto.data.device.DeviceDTO;
-import com.hfln.portal.common.request.device.DeviceBandingParams;
-import com.hfln.portal.common.request.device.DeviceListParams;
-import com.hfln.portal.common.request.device.DeviceLocationParams;
+import com.hfln.portal.common.request.device.*;
 import com.hfln.portal.domain.gateway.DeviceGateway;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -25,7 +23,7 @@ public class DeviceController {
     private DeviceGateway deviceGateway;
 
     @PostMapping("wap/device/deviceList")
-    @ApiOperation(value = "获取个人首页信息")
+    @ApiOperation(value = "获取设备列表")
     public ApiResult<List<DeviceDTO>> deviceList(@RequestBody @Valid DeviceListParams request) {
         return ApiResult.success(deviceGateway.queryDeviceList(request));
     }
@@ -33,8 +31,8 @@ public class DeviceController {
 
     @GetMapping("/wap/device/deviceUnBind")
     @ApiOperation(value = "解绑设备")
-    public ApiResult<Boolean> deviceUnBind(@RequestParam("userId") Long userId, @RequestParam("deviceId") String deviceId) {
-        return ApiResult.success(deviceGateway.deviceUnBind(userId, deviceId));
+    public ApiResult<Boolean> deviceUnBind(@RequestParam("userId") Long userId, @RequestParam("clientId") String clientId) {
+        return ApiResult.success(deviceGateway.deviceUnBind(userId, clientId));
     }
 
     @PostMapping("/wap/device/deviceBinding")
@@ -72,5 +70,4 @@ public class DeviceController {
     }
 
 
-
 }

+ 89 - 0
portal-service-application/src/main/java/com/hfln/portal/application/controller/wap/GroupController.java

@@ -0,0 +1,89 @@
+package com.hfln.portal.application.controller.wap;
+
+
+import cn.hfln.framework.catchlog.CatchAndLog;
+import cn.hfln.framework.dto.ApiResult;
+import com.hfln.portal.common.dto.data.device.DeviceDTO;
+import com.hfln.portal.common.dto.data.group.GroupDTO;
+import com.hfln.portal.common.request.group.*;
+import com.hfln.portal.domain.gateway.GroupGateway;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
+
+@RestController
+@CatchAndLog
+@Api(tags = "群组相关")
+@Slf4j
+public class GroupController {
+
+    @Autowired
+    private GroupGateway groupGateway;
+
+    @PostMapping("/wap/group/addGroup")
+    @ApiOperation(value = "添加群组")
+    public ApiResult<Boolean> addGroup(@RequestBody @Valid GroupAddParams request){
+        return ApiResult.success(groupGateway.addGroup(request));
+    }
+
+
+    @DeleteMapping("/wap/group/deleteGroup")
+    @ApiOperation(value = "删除群组")
+    public ApiResult<Boolean> deleteGroup(@RequestParam("group_id") Long groupId){
+        return ApiResult.success(groupGateway.deleteGroup(groupId));
+    }
+
+    @PostMapping("/wap/group/updateGroup")
+    @ApiOperation(value = "更新群组")
+    public ApiResult<Boolean> updateGroup(@RequestBody @Valid GroupUpdateParams params){
+        return ApiResult.success(groupGateway.updateGroup(params));
+    }
+
+    @GetMapping("/wap/group/groupLits")
+    @ApiOperation(value = "获取群组列表")
+    public ApiResult<List<GroupDTO>> GroupList(@RequestBody @Valid GroupListParams request){
+        return ApiResult.success(groupGateway.queryGroupList(request));
+    }
+
+    @GetMapping("/wap/group/queryGroupById")
+    @ApiOperation(value = "获取群组设备列表")
+    public ApiResult<List<DeviceDTO>> queryGroupById(@RequestParam("group_id") Long groupId){
+        return ApiResult.success(groupGateway.queryGroupDeviceInfoById(groupId));
+    }
+
+
+    @PostMapping("/wap/group/addDeviceToGroup")
+    @ApiOperation(value = "添加设备到群组")
+    public ApiResult<Boolean> addDeviceToGroup(@RequestBody @Valid AddDeviceToGroupParams request) {
+        return ApiResult.success(groupGateway.addDeviceToGroup(request));
+    }
+
+    @DeleteMapping("/wap/group/deleteDeviceFromGroup")
+    @ApiOperation(value = "删除设备从群组")
+    public ApiResult<Boolean> deleteDeviceFromGroup(@RequestBody @Valid DeleteDeviceFromGroupParams request){
+        return ApiResult.success(groupGateway.deleteDeviceFromGroup(request));
+    }
+
+    @PostMapping("/wap/group/shareGroup")
+    @ApiOperation(value = "通过链接分享群组")
+    public ApiResult<Boolean> shareGroup(@RequestBody @Valid ShareGroupParams request){
+        return ApiResult.success(groupGateway.shareGroup(request));
+    }
+
+    @PostMapping("/wap/group/GroupShareConfirm")
+    @ApiOperation(value = "群组分享确认")
+    public ApiResult<Boolean> GroupShareConfirm(@RequestBody @Valid GroupShareConfirmParams request){
+        return ApiResult.success(groupGateway.groupShareConfirm(request));
+    }
+
+    @PostMapping("/wap/group/groupShareHandle")
+    @ApiOperation(value = "群组分享处理")
+    public ApiResult<Boolean> groupShareHandle(@RequestBody @Valid GroupShareHandleParams request){
+        return ApiResult.success(groupGateway.groupShareHandle(request));
+    }
+}

+ 7 - 5
portal-service-application/src/main/java/com/hfln/portal/application/controller/wap/UserController.java

@@ -3,10 +3,7 @@ package com.hfln.portal.application.controller.wap;
 import cn.hfln.framework.catchlog.CatchAndLog;
 import cn.hfln.framework.dto.ApiResult;
 import com.hfln.portal.common.dto.data.user.UserDto;
-import com.hfln.portal.common.request.user.LoginBySmsCodeParams;
-import com.hfln.portal.common.request.user.UserLoginParams;
-import com.hfln.portal.common.request.user.UserSignupParams;
-import com.hfln.portal.common.request.user.UserUpdatePasswordParams;
+import com.hfln.portal.common.request.user.*;
 import com.hfln.portal.domain.gateway.UserGateway;
 import com.hfln.portal.domain.gateway.sms.SmsGateway;
 import io.swagger.annotations.Api;
@@ -116,6 +113,11 @@ public class UserController {
         return ApiResult.success();
     }
 
-
+    @PostMapping("wap/user/logout")
+    @ApiOperation(value = "用户注销")
+    public ApiResult<?> logout(@RequestBody @Valid UserLogoutParams request){
+        userGateway.logout(request);
+        return ApiResult.success();
+    }
 
 }

+ 43 - 0
portal-service-common/src/main/java/com/hfln/portal/common/dto/data/group/GroupDTO.java

@@ -0,0 +1,43 @@
+package com.hfln.portal.common.dto.data.group;
+
+
+import com.hfln.portal.common.vo.BaseVO;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class GroupDTO extends BaseVO {
+
+    /**
+     * 主键ID
+     */
+    private Long devGroupId;
+
+    /**
+     * 群组UUID
+     */
+    private String groupUuid;
+
+    /**
+     * 群组名称
+     */
+    private String groupName;
+
+    /**
+     * 群组下设备总数
+     */
+    private Integer  totalDevice;
+
+    /**
+     * 群组下设备在线状态数量
+     */
+    private Integer  onlineDevice;
+
+    /**
+     * 群组下设备告警状态数量
+     */
+    private Integer  warningDevice;
+
+
+}

+ 56 - 0
portal-service-common/src/main/java/com/hfln/portal/common/dto/data/group/GroupShareDTO.java

@@ -0,0 +1,56 @@
+package com.hfln.portal.common.dto.data.group;
+
+import com.hfln.portal.common.vo.BaseVO;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class GroupShareDTO extends BaseVO {
+
+
+    /**
+     * 主键ID
+     */
+    private Long shareId;
+
+
+    /**
+     * 群组uuid
+     */
+    private String groupUuid;
+
+
+    /**
+     * 群组分享uuid
+     */
+    private String uuid;
+
+    /**
+     * 分享人userid
+     */
+    private String sharer;
+
+
+    /**
+     * 分享人手机号
+     */
+    private String sharerPhone;
+
+
+    /**
+     * 被分享人userid
+     */
+    private String shared;
+
+    /**
+     * 被分享人手机号
+     */
+    private String sharedPhone;
+
+    /**
+     * 分享状态: 0-待确认 1-已确认 2-已拒绝
+     */
+    private Integer status;
+}

+ 4 - 3
portal-service-common/src/main/java/com/hfln/portal/common/request/device/DeviceBandingParams.java

@@ -7,6 +7,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 
 @EqualsAndHashCode(callSuper = true)
@@ -16,10 +17,10 @@ public class DeviceBandingParams extends BaseVO {
 
     @NotEmpty(message = "设备Id不能为空")
     @ApiModelProperty(value = "设备ID",required = true)
-    private String devId;
+    private String clientId;
 
-    @NotEmpty(message = "用户Id不能为空")
-    @ApiModelProperty("用户Id")
+    @NotNull(message = "用户Id不能为空")
+    @ApiModelProperty(value = "用户Id",required = true)
     private Long userId;
 
     @ApiModelProperty("设备名称")

+ 1 - 1
portal-service-common/src/main/java/com/hfln/portal/common/request/device/DeviceLocationParams.java

@@ -11,7 +11,7 @@ import java.math.BigDecimal;
 
 @EqualsAndHashCode(callSuper = true)
 @Data
-@ApiModel(description = "设备为止更新")
+@ApiModel(description = "设备位置更新")
 public class DeviceLocationParams extends BaseVO {
 
 

+ 24 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/group/AddDeviceToGroupParams.java

@@ -0,0 +1,24 @@
+package com.hfln.portal.common.request.group;
+
+import com.hfln.portal.common.vo.BaseVO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import javax.validation.constraints.NotNull;
+
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel(description = "群组添加设备")
+public class AddDeviceToGroupParams  extends BaseVO {
+
+    @NotNull(message = "群组Id不能为空!")
+    @ApiModelProperty(value = "群组Id",required = true)
+    private Long groupId;
+
+    @NotNull(message = "设备Id不能为空!")
+    @ApiModelProperty(value = "设备Id",required = true)
+    private Long devId;
+
+}

+ 25 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/group/DeleteDeviceFromGroupParams.java

@@ -0,0 +1,25 @@
+package com.hfln.portal.common.request.group;
+
+
+import com.hfln.portal.common.vo.BaseVO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.NotNull;
+
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel(description = "删除设备从群组")
+public class DeleteDeviceFromGroupParams extends BaseVO {
+
+    @NotNull(message = "群组Id不能为空!")
+    @ApiModelProperty(value = "群组Id",required = true)
+    private Long groupId;
+
+    @NotNull(message = "设备Id不能为空!")
+    @ApiModelProperty(value = "设备Id",required = true)
+    private Long devId;
+}

+ 27 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/group/GroupAddParams.java

@@ -0,0 +1,27 @@
+package com.hfln.portal.common.request.group;
+
+
+import com.hfln.portal.common.vo.BaseVO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel(description = "添加群组")
+public class GroupAddParams extends BaseVO {
+
+    @NotEmpty(message = "群组名称不能为空!")
+    @ApiModelProperty(value = "群组名称",required = true)
+    private String groupName;
+
+    @NotNull(message = "用户Id不能为空!")
+    @ApiModelProperty(value = "用户Id",required = true)
+    private Long userId;
+
+
+}

+ 23 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/group/GroupDeleteParams.java

@@ -0,0 +1,23 @@
+package com.hfln.portal.common.request.group;
+
+import com.hfln.portal.common.vo.BaseVO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.NotNull;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel(description = "删除群组")
+public class GroupDeleteParams extends BaseVO {
+
+
+        @NotNull(message = "群组Id不能为空!")
+        @ApiModelProperty(value = "用户Id",required = true)
+        private Long devGroupId;
+
+}
+
+

+ 21 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/group/GroupListParams.java

@@ -0,0 +1,21 @@
+package com.hfln.portal.common.request.group;
+
+import com.hfln.portal.common.vo.BaseVO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.NotNull;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel(description = "群组列表查询")
+
+public class GroupListParams extends BaseVO {
+
+    @NotNull(message = "用户Id不能为空!")
+    @ApiModelProperty(value = "用户Id",required = true)
+    private Long userId;
+
+}

+ 28 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/group/GroupShareConfirmParams.java

@@ -0,0 +1,28 @@
+package com.hfln.portal.common.request.group;
+
+import com.hfln.portal.common.vo.BaseVO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel(description = "群组分享确认")
+public class GroupShareConfirmParams extends BaseVO {
+
+    @NotNull(message = "被分享人userid不能为空")
+    @ApiModelProperty(value = "被分享人userid",required = true)
+    private Long shared;
+
+    @NotEmpty(message = "被分享人shared_phone不能为空")
+    @ApiModelProperty(value = "被分享人shared_phone",required = true)
+    private String sharedPhone;
+
+    @NotEmpty(message = "分享群组uuid不能为空")
+    @ApiModelProperty(value = "分享群组uuid",required = true)
+    private String uuid;
+}

+ 24 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/group/GroupShareHandleParams.java

@@ -0,0 +1,24 @@
+package com.hfln.portal.common.request.group;
+
+import com.hfln.portal.common.vo.BaseVO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel(description = "群组分享处理")
+public class GroupShareHandleParams extends BaseVO {
+
+    @NotNull(message = "状态标识不能为空")
+    @ApiModelProperty(value = "状态标识",required = true)
+    private Integer state;
+
+    @NotEmpty(message = "共享群组uuid不能为空")
+    @ApiModelProperty(value = "共享群组uuid",required = true)
+    private String  uuid;
+}

+ 35 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/group/GroupUpdateParams.java

@@ -0,0 +1,35 @@
+package com.hfln.portal.common.request.group;
+
+
+import com.hfln.portal.common.vo.BaseVO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import javax.validation.constraints.NotEmpty;
+import java.math.BigDecimal;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel(description = "更新群组")
+public class GroupUpdateParams extends BaseVO {
+
+    @NotEmpty(message = "群组Uuid不能为空!")
+    @ApiModelProperty(value = "群组Uuid",required = true)
+    private String groupUuid;
+
+    @NotEmpty(message = "群组名称不能为空!")
+    @ApiModelProperty(value = "群组名称",required = true)
+    private String groupName;
+
+    @ApiModelProperty(value = "长度")
+    private BigDecimal length;
+
+    @ApiModelProperty(value = "宽度")
+    private BigDecimal width;
+
+    @ApiModelProperty(value = "北向夹角")
+    private BigDecimal northAngle;
+
+
+}

+ 28 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/group/ShareGroupParams.java

@@ -0,0 +1,28 @@
+package com.hfln.portal.common.request.group;
+
+import com.hfln.portal.common.vo.BaseVO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel(description = "通过链接分享群组")
+public class ShareGroupParams extends BaseVO {
+
+    @NotNull(message = "群组uuid不能为空")
+    @ApiModelProperty(value = "群组uuid",required = true)
+    private Long groupUuid;
+
+    @NotNull(message = "分享人userid不能为空")
+    @ApiModelProperty(value = "分享人userid",required = true)
+    private Long sharer;
+
+    @NotEmpty(message = "分享人手机号不能为空")
+    @ApiModelProperty(value = "分享人手机号",required = true)
+    private String sharerPhone;
+}

+ 22 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/user/UserLogoutParams.java

@@ -0,0 +1,22 @@
+package com.hfln.portal.common.request.user;
+
+import com.hfln.portal.common.vo.BaseVO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+
+import javax.validation.constraints.NotNull;
+
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel(description = "用户注销参数")
+public class UserLogoutParams extends BaseVO {
+
+    @NotNull(message = "用户ID不能为空!")
+    @ApiModelProperty(value = "用户ID",required = true)
+    private Long userId;
+
+}

+ 2 - 1
portal-service-common/src/main/java/com/hfln/portal/common/request/user/UserUpdatePasswordParams.java

@@ -7,13 +7,14 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
 
 @EqualsAndHashCode(callSuper = true)
 @Data
 @ApiModel(description = "用户修改密码")
 public class UserUpdatePasswordParams extends BaseVO {
 
-    @NotEmpty(message = "用户Id不能为空!")
+    @NotNull(message = "用户Id不能为空!")
     @ApiModelProperty("用户ID")
     private Long userId;
 

+ 7 - 0
portal-service-domain/src/main/java/com/hfln/portal/domain/exception/ErrorEnum.java

@@ -47,6 +47,13 @@ public enum ErrorEnum implements ErrorEnumInterface{
     DEVICE_IS_NOT_EXIST("50001", "设备不存在!"),
     DEVICE_IS_BINDING("50002", "当前设备已经被绑定!"),
 
+    /**
+     * 群组相关
+     */
+    GROUP_NAME_ISNULL("70001", "群组名称不能为空!"),
+    GROUP_IS_NOT_EXIST("70002", "群组不存在!"),
+    SHARE_IS_EXPIRED("70003", "分享已过期!"),
+    SHARE_GROUP_IS_NOT_EXIST("70004", "共享群组不存在!"),
 
 
 

+ 2 - 3
portal-service-domain/src/main/java/com/hfln/portal/domain/gateway/DeviceGateway.java

@@ -3,10 +3,9 @@ package com.hfln.portal.domain.gateway;
 import com.hfln.portal.common.dto.data.device.DeviceDTO;
 import com.hfln.portal.common.dto.data.event.EventListDTO;
 import com.hfln.portal.common.dto.data.home.HomeInfoDTO;
-import com.hfln.portal.common.request.device.DeviceBandingParams;
-import com.hfln.portal.common.request.device.DeviceListParams;
-import com.hfln.portal.common.request.device.DeviceLocationParams;
+import com.hfln.portal.common.request.device.*;
 import com.hfln.portal.common.request.event.EventListParams;
+
 import com.hfln.portal.common.vo.PageRecord;
 
 import java.util.List;

+ 31 - 0
portal-service-domain/src/main/java/com/hfln/portal/domain/gateway/GroupGateway.java

@@ -0,0 +1,31 @@
+package com.hfln.portal.domain.gateway;
+
+import com.hfln.portal.common.dto.data.device.DeviceDTO;
+import com.hfln.portal.common.dto.data.group.GroupDTO;
+import com.hfln.portal.common.request.group.*;
+
+import java.util.List;
+
+public interface GroupGateway {
+
+    Boolean addGroup(GroupAddParams request);
+
+    Boolean deleteGroup(Long GroupId);
+
+    Boolean updateGroup(GroupUpdateParams params);
+
+    List<GroupDTO> queryGroupList(GroupListParams request);
+
+    List<DeviceDTO> queryGroupDeviceInfoById(Long groupId);
+
+    Boolean addDeviceToGroup(AddDeviceToGroupParams  request);
+
+    Boolean deleteDeviceFromGroup(DeleteDeviceFromGroupParams request);
+
+    Boolean shareGroup(ShareGroupParams request);
+
+    Boolean groupShareConfirm(GroupShareConfirmParams request);
+
+    Boolean groupShareHandle(GroupShareHandleParams request);
+
+}

+ 3 - 4
portal-service-domain/src/main/java/com/hfln/portal/domain/gateway/UserGateway.java

@@ -1,10 +1,7 @@
 package com.hfln.portal.domain.gateway;
 
 import com.hfln.portal.common.dto.data.user.UserDto;
-import com.hfln.portal.common.request.user.LoginBySmsCodeParams;
-import com.hfln.portal.common.request.user.UserLoginParams;
-import com.hfln.portal.common.request.user.UserSignupParams;
-import com.hfln.portal.common.request.user.UserUpdatePasswordParams;
+import com.hfln.portal.common.request.user.*;
 
 public interface UserGateway {
 
@@ -32,4 +29,6 @@ public interface UserGateway {
 
     void updatePassword(UserUpdatePasswordParams request);
 
+    void logout(UserLogoutParams request);
+
 }

+ 28 - 21
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/DeviceGatewayImpl.java

@@ -7,9 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.hfln.portal.common.dto.data.device.DeviceDTO;
 import com.hfln.portal.common.dto.data.event.EventListDTO;
 import com.hfln.portal.common.dto.data.home.HomeInfoDTO;
-import com.hfln.portal.common.request.device.DeviceBandingParams;
-import com.hfln.portal.common.request.device.DeviceListParams;
-import com.hfln.portal.common.request.device.DeviceLocationParams;
+import com.hfln.portal.common.request.device.*;
 import com.hfln.portal.common.request.event.EventListParams;
 import com.hfln.portal.common.vo.PageRecord;
 import com.hfln.portal.domain.exception.ErrorEnum;
@@ -50,8 +48,8 @@ public class DeviceGatewayImpl implements DeviceGateway {
 
 
     @Override
-    public HomeInfoDTO queryHomeInfo(Long userId) {
-        HomeInfoDTO homeInfoDTO = new HomeInfoDTO();
+    public HomeInfoDTO queryHomeInfo(Long userId) {  //入参 userId  出参  HomeInfoDTO
+        HomeInfoDTO homeInfoDTO = new HomeInfoDTO();  //初始化DTO对象
         //todo 添加轮播图相关信息
         homeInfoDTO.setCarouselImage(null);
         /*
@@ -89,25 +87,32 @@ public class DeviceGatewayImpl implements DeviceGateway {
 
     @Override
     public List<DeviceDTO> queryDeviceList(DeviceListParams request) {
-
+//    输入:DeviceListParams 封装查询条件(用户ID、关键词、状态等)
+//    输出:List<DeviceDTO> 设备数据传输对象列表
         Optional<List<String>> sharedDevIds = devShareService.queryDeviceIdByUserId(request.getUserId());
-
+/*        作用:
+        通过 devShareService 查询当前用户有权限访问的共享设备ID列表
+        关键点:
+        返回 Optional<List<String>> 避免空指针
+        若用户无共享设备,后续会传入空列表(见第2步)*/
         List<DeviceDTO> deviceDTOs = new ArrayList<>();
         List<DevInfo> devInfos = devInfoService.queryDeviceList(request.getUserId(), request.getKeyWord(),
                 request.getStatus(), sharedDevIds.orElse(Collections.emptyList()));
+        //根据UserID,KeyWord,status查询设备列表,sharedDevIds查共享列表,返回一个新的列表集合
 
-        for (DevInfo devInfo : devInfos) {
-            DeviceDTO dto = new DeviceDTO();
-            BeanUtils.copyProperties(devInfo, dto);
-            deviceDTOs.add(dto);
+        for (DevInfo devInfo : devInfos) {              //遍历设备列表
+            DeviceDTO dto = new DeviceDTO();            //创建空的DTO对象
+            BeanUtils.copyProperties(devInfo, dto);     //属性拷贝
+            deviceDTOs.add(dto);                        //加入结果列表
         }
-        return deviceDTOs;
+
+        return deviceDTOs;                              //返回给前端
     }
 
     @Override
     @Transactional
-    public Boolean deviceUnBind(Long userId, String deviceId) {
-        List<DevInfo> devInfos = devInfoService.queryDevices(userId, deviceId);
+    public Boolean deviceUnBind(Long userId, String clientId) {
+        List<DevInfo> devInfos = devInfoService.queryDevices(userId, clientId);
         boolean updateFlag;
         // 绑定人解绑
         if (CollectionUtils.isNotEmpty(devInfos) && !devInfos.isEmpty()) {
@@ -115,13 +120,13 @@ public class DeviceGatewayImpl implements DeviceGateway {
             boolean flag = devInfoService.update(null,
                     Wrappers.<DevInfo>lambdaUpdate()
                             .set(DevInfo::getUserId, null)
-                            .eq(DevInfo::getDevId, deviceId));
+                            .eq(DevInfo::getDevId, clientId));
             //更新设备分享表
             boolean flagV2 = devShareService.update(null,
                     Wrappers.<DevShare>lambdaUpdate()
                             .set(DevShare::getState, 0)
                             .set(DevShare::getIsDeleted, 1)
-                            .eq(DevShare::getDevId, deviceId));
+                            .eq(DevShare::getClientId, clientId));
             updateFlag = flag && flagV2;
         } else {
             // 被分享者解绑
@@ -129,7 +134,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
                     Wrappers.<DevShare>lambdaUpdate()
                             .set(DevShare::getState, 0)
                             .set(DevShare::getIsDeleted, 1)
-                            .eq(DevShare::getDevId, deviceId)
+                            .eq(DevShare::getClientId, clientId)
                             .eq(DevShare::getSharedUserId, userId));
         }
 
@@ -142,7 +147,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
         // 1. 检查设备是否存在
         DevInfo devInfo = devInfoService.getOne(
                 Wrappers.<DevInfo>lambdaQuery()
-                        .eq(DevInfo::getDevId, request.getDevId())
+                        .eq(DevInfo::getDevId, request.getClientId())
         );
         if (Objects.isNull(devInfo)) {
             throw new BizException(ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorCode(), ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorMessage());
@@ -152,7 +157,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
         }
 
         // 3. 更新设备信息
-        return devInfoService.updateDevice(devInfo.getDevInfoId(), request);
+        return devInfoService.updateDevice(devInfo.getDevId(), request);
     }
 
 
@@ -234,10 +239,10 @@ public class DeviceGatewayImpl implements DeviceGateway {
         setIfNull(request::getYEnd, () -> halfWidth, request::setYEnd);
 
 
-        Boolean flag = devInfoService.updateDevice(request.getDevId(), request);
+        Boolean flag = devInfoService.updateDevice(request.getClientId(), request);
         DevInfo devInfo = devInfoService.getOne(
                 Wrappers.<DevInfo>lambdaQuery()
-                        .eq(DevInfo::getDevId, request.getDevId()));
+                        .eq(DevInfo::getDevId, request.getClientId()));
 
         //检查parts.length >= 2确保数组有足够元素,提供默认值"2.0"
         String result = Optional.ofNullable(devInfo.getSoftware())
@@ -285,4 +290,6 @@ public class DeviceGatewayImpl implements DeviceGateway {
         }
         return devInfoService.update(updateWrapper);
     }
+
+
 }

+ 418 - 0
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/GroupGatewayImpl.java

@@ -0,0 +1,418 @@
+package com.hfln.portal.infrastructure.gateway.impl;
+
+import cn.hfln.framework.extension.BizException;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.hfln.portal.common.dto.data.device.DeviceDTO;
+import com.hfln.portal.common.dto.data.group.GroupDTO;
+import com.hfln.portal.common.request.group.*;
+import com.hfln.portal.domain.exception.ErrorEnum;
+import com.hfln.portal.domain.gateway.GroupGateway;
+import com.hfln.portal.infrastructure.po.DevGroup;
+import com.hfln.portal.infrastructure.po.DevInfo;
+import com.hfln.portal.infrastructure.po.GroupDevMap;
+import com.hfln.portal.infrastructure.po.GroupShare;
+import com.hfln.portal.infrastructure.mapper.GroupDevMapMapper;
+import com.hfln.portal.infrastructure.service.DevGroupService;
+import com.hfln.portal.infrastructure.service.DevInfoService;
+import com.hfln.portal.infrastructure.service.GroupShareService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Service
+@Slf4j
+public class GroupGatewayImpl implements GroupGateway {
+
+    @Autowired
+    private DevGroupService devGroupService;
+
+    @Autowired
+    private GroupShareService groupShareService;
+
+    @Autowired
+    private DevInfoService devInfoService;
+    
+    @Autowired
+    private GroupDevMapMapper groupDevMapMapper;
+
+    /**
+     * 添加群组
+     * @param (groupName)群组名称 (userId)用户id
+     * @return
+     */
+
+    @Override
+    public Boolean addGroup(GroupAddParams request) {
+        //1.设置群组属性
+        DevGroup devGroup = new DevGroup();
+        devGroup.setGroupName(request.getGroupName());
+        devGroup.setUserId(request.getUserId());
+        if (Objects.isNull(request.getUserId())){
+            throw new BizException(ErrorEnum.USER_IS_NOT_EXIST.getErrorCode(), ErrorEnum.USER_IS_NOT_EXIST.getErrorMessage());
+        }
+        devGroup.setGroupUuid(UUID.randomUUID().toString());
+        devGroup.setIsDeleted(0);
+        //2.把群组名称和UUID存储数据库
+        // TODO mqtt消息 主题 /mps/add_group
+
+        return devGroupService.save(devGroup);
+    }
+
+
+
+    /**
+     * 删除群组
+     * @param  (groupId)  群组id
+     * @return
+     */
+    @Override
+    public Boolean deleteGroup(Long devGroupId) {
+        //1.查询群组信息
+        DevGroup devGroup = devGroupService.getById(devGroupId);
+        if (Objects.isNull(devGroup)){
+            throw new BizException(ErrorEnum.GROUP_IS_NOT_EXIST.getErrorCode(), ErrorEnum.GROUP_IS_NOT_EXIST.getErrorMessage());
+        }
+        //2.删除群组信息
+        devGroup.setIsDeleted(1);
+
+        //3.TODO  MQTT消息  主题 /mps/delete_group
+        return devGroupService.updateById(devGroup);
+    }
+
+    /**
+     * 更新群组
+     * @param (群组Uuid)groupUuid  (群组名称)groupName (长度)length     (宽度)width  (北向夹角)northAngle
+     * @return
+     */
+    @Override
+    public Boolean updateGroup(GroupUpdateParams params) {
+        //1.检查群组是否存
+        DevGroup devGroup = devGroupService.getOne(
+                Wrappers.<DevGroup>lambdaQuery()
+                        .eq(DevGroup::getGroupUuid, params.getGroupUuid()));
+        if (Objects.isNull(devGroup)) {
+            throw new BizException(ErrorEnum.GROUP_IS_NOT_EXIST.getErrorCode(), ErrorEnum.GROUP_IS_NOT_EXIST.getErrorMessage());
+        }
+        //2.创建更新包装器
+        LambdaUpdateWrapper<DevGroup> updateWrapper = Wrappers.lambdaUpdate();
+        //设置更新条件
+        updateWrapper.eq(DevGroup::getGroupUuid, params.getGroupUuid());
+        // 仅当字段非空时才更新
+        boolean hasUpdate = false;
+        if (Objects.nonNull(params.getGroupName())) {
+            updateWrapper.set(DevGroup::getGroupName, params.getGroupName());
+            hasUpdate = true;
+        }
+        if (Objects.nonNull(params.getLength())) {
+            updateWrapper.set(DevGroup::getLength, params.getLength());
+            hasUpdate = true;
+        }
+        if (Objects.nonNull(params.getWidth())){
+            updateWrapper.set(DevGroup::getWidth, params.getWidth());
+            hasUpdate = true;
+        }
+        if (Objects.nonNull(params.getNorthAngle())){
+            updateWrapper.set(DevGroup::getNorthAngle, params.getNorthAngle());
+            hasUpdate = true;
+        }
+        // 如果所有字段均为空,无需更新
+        if (!hasUpdate){
+            return false;
+        }
+        return devGroupService.update(updateWrapper);
+    }
+
+
+    /**
+     * 获取群组列表
+     * @param (用户id)userId
+     * @return
+     */
+    @Override
+    public List<GroupDTO> queryGroupList(GroupListParams request) {
+        // 1. 查询被分享群组
+        List<String> groupUUids = groupShareService.queryGroupUUidByUserId(request.getUserId());
+
+        // 2. 获取用户自己创建的群组和被分享的群组
+        List<DevGroup> devGroups = devGroupService.queryGroupByUserId(request.getUserId(), groupUUids);
+
+        // 3. 将群组信息转化为DTO
+        List<GroupDTO> groupDTOs = new ArrayList<>();
+        for (DevGroup devGroup : devGroups) {
+            GroupDTO dto = new GroupDTO();
+            BeanUtils.copyProperties(devGroup, dto);
+
+            // 4. 查询该群组下的设备列表
+            List<DevInfo> groupDevices = queryDevicesByGroupUuid(devGroup.getGroupUuid());
+
+            // 5. 统计设备信息
+            int totalDevice = groupDevices.size();
+            int onlineDevice = 0;
+            int warningDevice = 0;
+
+            // 6. 统计在线和告警设备数量
+            for (DevInfo device : groupDevices) {
+                // 使用online字段判断在线状态(根据DevInfo类定义)
+                if (Objects.nonNull(device.getOnline()) && device.getOnline() == DevInfo.Constants.OnlineStatus.ONLINE) {
+                    onlineDevice++;
+                }
+
+                // 使用devWarn字段判断告警状态(根据DevInfo类定义)
+                if (Objects.nonNull(device.getDevWarn()) && device.getDevWarn() == DevInfo.Constants.DevWarnStatus.WARNING) {
+                    warningDevice++;
+                }
+            }
+
+            // 7. 设置统计值
+            dto.setTotalDevice(totalDevice);
+            dto.setOnlineDevice(onlineDevice);
+            dto.setWarningDevice(warningDevice);
+
+            groupDTOs.add(dto);
+        }
+
+        return groupDTOs;
+    }
+
+
+    /**
+     * 获取群组中设备列表
+     * @param (群组id)groupId
+     * @return
+     */
+    @Override
+    public List<DeviceDTO> queryGroupDeviceInfoById(Long groupId) {
+        if (Objects.isNull(groupId)) {
+            return Collections.emptyList();
+        }
+
+        // 1. 查询群组信息
+        DevGroup devGroup = devGroupService.getById(groupId);
+        if (Objects.isNull(devGroup)) {
+            throw new BizException(ErrorEnum.GROUP_IS_NOT_EXIST.getErrorCode(), ErrorEnum.GROUP_IS_NOT_EXIST.getErrorMessage());
+        }
+
+        // 2. 查询设备并转换为DTO
+        List<DevInfo> deviceList = queryDevicesByGroupUuid(devGroup.getGroupUuid());
+        
+        // 3. 转换为DTO列表
+        List<DeviceDTO> deviceDTOs = new ArrayList<>();
+        for (DevInfo devInfo : deviceList) {
+            DeviceDTO dto = new DeviceDTO();
+            BeanUtils.copyProperties(devInfo, dto);
+            deviceDTOs.add(dto);
+        }
+        
+        return deviceDTOs;
+    }
+    
+    /**
+     * 根据群组UUID查询设备列表(私有方法 不对外接口)
+     * @param (groupUuid) 群组UUID
+     * @return 设备列表
+     */
+    private List<DevInfo> queryDevicesByGroupUuid(String groupUuid) {
+        if (Objects.isNull(groupUuid)) {
+            return Collections.emptyList();
+        }
+        
+        // 1. 查询群组设备映射表获取设备ID列表
+        LambdaQueryWrapper<GroupDevMap> mapWrapper = new LambdaQueryWrapper<>();
+        mapWrapper.eq(GroupDevMap::getGroupUuid, groupUuid);
+        List<GroupDevMap> devMaps = groupDevMapMapper.selectList(mapWrapper);
+
+        // 如果没有关联设备,返回空列表
+        if (CollectionUtils.isEmpty(devMaps)) {
+            return Collections.emptyList();
+        }
+
+        // 2. 提取设备ID列表
+        List<String> devIds = devMaps.stream()
+                .map(GroupDevMap::getDevId)
+                .collect(Collectors.toList());
+
+        // 3. 查询所有设备详情
+        return devInfoService.list(
+                Wrappers.<DevInfo>lambdaQuery()
+                        .in(DevInfo::getDevId, devIds));
+    }
+
+    /**
+     * 添加设备到群组
+     * @param (设备ID)dev_id (群组ID) group_id
+     * @return
+     */
+    @Override
+    public Boolean addDeviceToGroup(AddDeviceToGroupParams params) {
+        // 1. 查询设备和群组是否存在
+        DevInfo devInfo = devInfoService.getOne(
+                Wrappers.<DevInfo>lambdaQuery()
+                        .eq(DevInfo::getDevId, params.getDevId()));
+        if (Objects.isNull(devInfo)) {
+            throw new BizException(ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorCode(), ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorMessage());
+        }
+        
+        DevGroup devGroup = devGroupService.getById(params.getGroupId());
+        if (Objects.isNull(devGroup)) {
+            throw new BizException(ErrorEnum.GROUP_IS_NOT_EXIST.getErrorCode(), ErrorEnum.GROUP_IS_NOT_EXIST.getErrorMessage());
+        }
+        
+        // 2. 检查设备是否已经添加到群组中
+        LambdaQueryWrapper<GroupDevMap> queryWrapper = Wrappers.<GroupDevMap>lambdaQuery()
+                .eq(GroupDevMap::getDevId, devInfo.getClientId())
+                .eq(GroupDevMap::getGroupUuid, devGroup.getGroupUuid());
+        
+        GroupDevMap groupDevMap = groupDevMapMapper.selectOne(queryWrapper);
+        
+        // 3. 如果已存在记录
+        if (Objects.nonNull(groupDevMap)) {
+            // 检查是否已添加(is_delete为0)
+            if (groupDevMap.getIsDeleted() == 0) {
+                throw new BizException(ErrorEnum.ERROR_BIZ_FAIL.getErrorCode(), "请勿重复添加设备");
+            } 
+            // 如果是逻辑删除状态,恢复关系
+            else {
+                groupDevMap.setIsDeleted(0);
+                return groupDevMapMapper.updateById(groupDevMap) > 0;
+            }
+        }
+        
+        // 4. 不存在记录,创建新的映射关系
+        GroupDevMap newMap = new GroupDevMap();
+        newMap.setDevGroupId(params.getGroupId());
+        newMap.setGroupUuid(devGroup.getGroupUuid());
+        newMap.setDevInfoId(params.getDevId());
+        newMap.setDevId(devInfo.getClientId());
+        newMap.setIsDeleted(0);
+        
+        return groupDevMapMapper.insert(newMap) > 0;
+    }
+
+
+    /**
+     * 从群组中删除设备
+     * @param (设备ID)dev_id (群组ID) group_id
+     * @return
+     */
+    @Override
+    public Boolean deleteDeviceFromGroup(DeleteDeviceFromGroupParams request) {
+        // 1. 直接查询设备与群组的关联关系
+        LambdaQueryWrapper<GroupDevMap> queryWrapper = Wrappers.<GroupDevMap>lambdaQuery()
+                .eq(GroupDevMap::getDevId, request.getDevId())
+                .eq(GroupDevMap::getDevGroupId, request.getGroupId())
+                .eq(GroupDevMap::getIsDeleted, 0);
+        
+        GroupDevMap groupDevMap = groupDevMapMapper.selectOne(queryWrapper);
+        
+        // 2. 如果关联关系不存在,返回错误
+        if (Objects.isNull(groupDevMap)) {
+            throw new BizException(ErrorEnum.ERROR_BIZ_FAIL.getErrorCode(), "设备不在此群组中");
+        }
+        
+        // 3. 将关联关系标记为逻辑删除
+        groupDevMap.setIsDeleted(1);
+        
+        // 4. 更新数据库并返回结果
+        return groupDevMapMapper.updateById(groupDevMap) > 0;
+    }
+
+    /**
+     * 分享群组
+     * @param (群组uuid) groupUuid  (分享人userid)sharer  (分享人手机号)sharerPhone
+     * @return 分享结果
+     */
+    @Override
+    public Boolean shareGroup(ShareGroupParams request) {
+        // 1. 验证群组是否存在
+        DevGroup devGroup = devGroupService.getOne(
+                Wrappers.<DevGroup>lambdaQuery()
+                        .eq(DevGroup::getGroupUuid, request.getGroupUuid()));
+        if (Objects.isNull(devGroup)) {
+            throw new BizException(ErrorEnum.GROUP_IS_NOT_EXIST.getErrorCode(), ErrorEnum.GROUP_IS_NOT_EXIST.getErrorMessage());
+        }
+        
+        // 2. 创建分享记录
+        GroupShare groupShare = new GroupShare();
+        // 设置群组UUID
+        groupShare.setGroupUuid(request.getGroupUuid().toString());
+        // 生成分享唯一标识
+        String shareUuid = UUID.randomUUID().toString();
+        groupShare.setUuid(shareUuid);
+        // 设置分享人信息
+        groupShare.setSharer(request.getSharer());
+        groupShare.setSharerPhone(request.getSharerPhone());
+        // 初始化其他字段
+        groupShare.setState(0); // 初始状态为待确认
+        groupShare.setIsDeleted(0); // 未删除
+        
+        // 3. 保存分享记录
+        boolean saveResult = groupShareService.save(groupShare);
+        return saveResult;
+    }
+
+    /**
+     * 分享群组确认
+     * @param  (被分享人userid)shared  (被分享人shared_phone)sharedPhone
+     * @return 确认结果
+     */
+    @Override
+    public Boolean groupShareConfirm(GroupShareConfirmParams request) {
+        // 1. 根据uuid查询分享记录
+        LambdaQueryWrapper<GroupShare> queryWrapper = Wrappers.<GroupShare>lambdaQuery()
+                .eq(GroupShare::getUuid, request.getUuid())
+                .eq(GroupShare::getIsDeleted, 0);
+        
+        GroupShare groupShare = groupShareService.getOne(queryWrapper);
+        
+        // 如果记录不存在,返回异常
+        if (Objects.isNull(groupShare)) {
+            throw new BizException(ErrorEnum.SHARE_IS_EXPIRED.getErrorCode(), ErrorEnum.SHARE_IS_EXPIRED.getErrorMessage());
+        }
+        
+        // 2. 检查分享状态
+        if (groupShare.getState() != 0) {
+            throw new BizException(ErrorEnum.SHARE_IS_EXPIRED.getErrorCode(), ErrorEnum.SHARE_IS_EXPIRED.getErrorMessage());
+        }
+        
+        // 3. 更新分享记录
+        groupShare.setState(3); // 更新状态为已确认
+        groupShare.setShared(request.getShared()); // 设置被分享人ID
+        groupShare.setSharedPhone(request.getSharedPhone()); // 设置被分享人手机号
+        
+        // 4. 保存更新
+        return groupShareService.updateById(groupShare);
+    }
+
+    /**
+     * 群组分享处理
+     * @param request 群组分享处理参数
+     * @return 处理结果
+     */
+    @Override
+    public Boolean groupShareHandle(GroupShareHandleParams request){
+        // 1. 根据uuid查询分享记录
+        LambdaQueryWrapper<GroupShare> queryWrapper = Wrappers.<GroupShare>lambdaQuery()
+                .eq(GroupShare::getUuid, request.getUuid())
+                .eq(GroupShare::getIsDeleted, 0);
+        
+        GroupShare groupShare = groupShareService.getOne(queryWrapper);
+        
+        // 如果记录不存在,返回异常
+        if (Objects.isNull(groupShare)) {
+            throw new BizException(ErrorEnum.SHARE_GROUP_IS_NOT_EXIST.getErrorCode(), ErrorEnum.SHARE_GROUP_IS_NOT_EXIST.getErrorMessage());
+        }
+        
+        // 2. 更新分享状态
+        groupShare.setState(request.getState());
+        
+        // 3. 保存更新
+        return groupShareService.updateById(groupShare);
+    }
+}

+ 79 - 9
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/UserGatewayImpl.java

@@ -6,17 +6,23 @@ import cn.dev33.satoken.stp.StpUtil;
 import cn.hfln.framework.common.redis.service.RedisService;
 import cn.hfln.framework.extension.BizException;
 import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.hfln.portal.common.constant.redis.RedisCacheConstant;
 import com.hfln.portal.common.dto.data.user.UserDto;
-import com.hfln.portal.common.request.user.LoginBySmsCodeParams;
-import com.hfln.portal.common.request.user.UserLoginParams;
-import com.hfln.portal.common.request.user.UserSignupParams;
-import com.hfln.portal.common.request.user.UserUpdatePasswordParams;
+import com.hfln.portal.common.request.user.*;
 import com.hfln.portal.domain.customer.util.PasswordUtil;
 import com.hfln.portal.domain.exception.ErrorEnum;
 import com.hfln.portal.domain.gateway.UserGateway;
 import com.hfln.portal.infrastructure.mapper.UserInfoMapper;
+import com.hfln.portal.infrastructure.po.DevGroup;
+import com.hfln.portal.infrastructure.po.DevInfo;
+import com.hfln.portal.infrastructure.po.DevShare;
+import com.hfln.portal.infrastructure.po.GroupShare;
 import com.hfln.portal.infrastructure.po.UserInfo;
+import com.hfln.portal.infrastructure.service.DevGroupService;
+import com.hfln.portal.infrastructure.service.DevInfoService;
+import com.hfln.portal.infrastructure.service.DevShareService;
+import com.hfln.portal.infrastructure.service.GroupShareService;
 import com.hfln.portal.infrastructure.service.UserService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -27,6 +33,7 @@ import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.client.RestTemplate;
 
 import java.util.Objects;
@@ -47,6 +54,18 @@ public class UserGatewayImpl implements UserGateway {
     @Autowired
     private UserService userService;
 
+    @Autowired
+    private DevInfoService devInfoService;
+
+    @Autowired
+    private DevGroupService devGroupService;
+
+    @Autowired
+    private DevShareService devShareService;
+
+    @Autowired
+    private GroupShareService groupShareService;
+
     @Value("${lnxx.wechat.appid}")
     private String appid;
 
@@ -60,15 +79,19 @@ public class UserGatewayImpl implements UserGateway {
 
     @Override
     public String getOpenId(String code) {
+        //首先检查传入的code是否为空,如果为空则抛出业务异常
         if (StringUtils.isEmpty(code)) {
             throw new BizException(ErrorEnum.WECHAT_CODE_ISNULL.getErrorCode(), ErrorEnum.WECHAT_CODE_ISNULL.getErrorMessage());
         }
+        //构建请求URL
         String url = String.format("https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code", appid, secret, code);
         try {
+            //调用微信接口
             String res = restTemplate.getForObject(url, String.class);
+            //解析返回结果
             JSONObject obj = JSONObject.parseObject(res);
             return Objects.requireNonNull(obj).getString("openid");
-        } catch (Exception e) {
+        } catch (Exception e) {   //异常处理
             log.error("微信登录接口异常", e);
             throw new BizException(ErrorEnum.WECHAT_INTERFACE_CALL_EXCEPTION.getErrorCode(), ErrorEnum.WECHAT_INTERFACE_CALL_EXCEPTION.getErrorMessage());
         }
@@ -121,13 +144,13 @@ public class UserGatewayImpl implements UserGateway {
             redisService.deleteObject(RedisCacheConstant.SMS_LOGIN_CODE + phone);
         }
         BeanUtils.copyProperties(user, userDto);
-        userDto.setUserId(user.getUserInfoId()
+        userDto.setUserId(user.getUserId()
         );
 
         /*
         通过sa-token获取token
          */
-        StpUtil.login(user.getUserInfoId());
+        StpUtil.login(user.getUserId());
         SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
 
         return userDto;
@@ -142,7 +165,7 @@ public class UserGatewayImpl implements UserGateway {
             throw new BizException(ErrorEnum.USERNAME_OR_PASSWORD_ERROR.getErrorCode(), ErrorEnum.USERNAME_OR_PASSWORD_ERROR.getErrorMessage());
         }
         BeanUtils.copyProperties(user, userDto);
-        userDto.setUserId(user.getUserInfoId());
+        userDto.setUserId(user.getUserId());
         return userDto;
     }
 
@@ -201,8 +224,55 @@ public class UserGatewayImpl implements UserGateway {
             throw new BizException(ErrorEnum.OLD_PASSWORD_ERROR.getErrorCode(), ErrorEnum.OLD_PASSWORD_ERROR.getErrorMessage());
         }
         UserInfo info = new UserInfo();
-        info.setUserInfoId(request.getUserId());
+        info.setUserId(request.getUserId());
         info.setPassword(request.getNewPassword());
         userService.updateById(userInfo);
     }
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void logout(UserLogoutParams request){
+        //1.用户id参数校验
+        UserInfo userInfo = userService.getById(request.getUserId());
+        if (Objects.isNull(userInfo)){
+            throw new BizException(ErrorEnum.USER_IS_NOT_EXIST.getErrorCode(), ErrorEnum.USER_IS_NOT_EXIST.getErrorMessage());
+        }
+
+        //2.消除登录凭证
+        StpUtil.logout(request.getUserId());
+
+        //3.修改用户信息表中的is_delete字段为1
+        UserInfo info = new UserInfo();
+        info.setUserId(request.getUserId());
+        info.setIsDeleted(1);
+        userService.updateById(info);
+
+        //4.批量更新其他相关表中的is_delete字段
+        // 更新设备信息表
+        devInfoService.update(
+                Wrappers.<DevInfo>lambdaUpdate()
+                        .eq(DevInfo::getUserId, request.getUserId())
+                        .set(DevInfo::getIsDeleted, 1)
+        );
+        
+        // 更新设备组表
+        devGroupService.update(
+                Wrappers.<DevGroup>lambdaUpdate()
+                        .eq(DevGroup::getUserId, request.getUserId())
+                        .set(DevGroup::getIsDeleted, 1)
+        );
+        
+        // 更新设备分享表
+        devShareService.update(
+                Wrappers.<DevShare>lambdaUpdate()
+                        .eq(DevShare::getSharerUserId, request.getUserId())
+                        .set(DevShare::getIsDeleted, 1)
+        );
+        
+        // 更新群组分享表
+        groupShareService.update(
+                Wrappers.<GroupShare>lambdaUpdate()
+                        .eq(GroupShare::getSharer, request.getUserId())
+                        .set(GroupShare::getIsDeleted, 1)
+        );
+    }
 }

+ 14 - 2
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/po/DevGroup.java

@@ -20,8 +20,8 @@ public class DevGroup extends BasePO {
     /**
      * 主键ID
      */
-    @TableId(type = IdType.ASSIGN_ID)
-    private Long devGroupId;
+    @TableId(value = "group_id",type = IdType.ASSIGN_ID)
+    private Long groupId;
 
     /**
      * 群组UUID
@@ -59,5 +59,17 @@ public class DevGroup extends BasePO {
     @TableField("width")
     private BigDecimal width;
 
+    /**
+     * 删除标记:0-未删除 1-已删除
+     */
+    @TableField("is_deleted")
+    private Integer isDeleted;
+
+    /**
+     * 备注
+     */
+    @TableField("remark")
+    private String remark;
+
 
 }

+ 4 - 4
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/po/DevInfo.java

@@ -17,14 +17,14 @@ public class DevInfo extends BasePO {
     /**
      * 主键ID
      */
-    @TableId(value = "dev_info_id", type = IdType.ASSIGN_ID)
-    private Long devInfoId;
+    @TableId(value = "dev_id", type = IdType.ASSIGN_ID)
+    private Long devId;
 
     /**
      * 设备ID
      */
-    @TableField("dev_id")
-    private String devId;
+    @TableField("client_id")
+    private String clientId;
 
     /**
      * 用户openid

+ 2 - 2
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/po/DevShare.java

@@ -17,12 +17,12 @@ public class DevShare extends BasePO {
      * 主键ID
      */
     @TableId(type = IdType.ASSIGN_ID)
-    private Long devShareId;
+    private Long ShareId;
 
     /**
      * 设备ID
      */
-    private String devId;
+    private String clientId;
 
     /**
      * 分享人userId

+ 29 - 8
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/po/GroupShare.java

@@ -17,43 +17,64 @@ public class GroupShare extends BasePO {
      * 主键ID(自增)
      */
     @TableId(type = IdType.ASSIGN_ID)
-    private Long groupShareId;
+    private Long shareId;
 
     /**
-     * uuid(唯一标识)
+     * 群组uuid(唯一标识)
      */
-    private String uuid;
+    @TableField("group_uuid ")
+    private String groupUuid;
 
     /**
-     * 群组uuid
+     * uuid
      */
-    private String groupUuid;
+    @TableField("uuid ")
+    private String uuid;
 
     /**
      * 分享人userId
      */
-    private Long sharerUserId;
+    @TableField("sharer")
+    private Long sharer;
 
     /**
      * 分享人手机号
      */
+    @TableField("sharer_phone")
     private String sharerPhone;
 
     /**
      * 被分享人userId
      */
-    private Long sharedUserId;
+    @TableField("shared")
+    private Long shared;
 
     /**
      * 被分享人手机号
      */
+    @TableField("share_phone")
     private String sharedPhone;
 
     /**
-     * 分享状态:0-待确认,1-已接收,2-已拒绝,3-已确认
+     * 分享状态:0-待确认,1-已确认,2-已拒绝
      */
+    @TableField("state")
     private Integer state;
 
+
+    /**
+     * 删除标记:0-未删除,1-已删除
+     */
+    @TableField("is_deleted")
+    private Integer isDeleted;
+
+    /**
+     * 备注
+     */
+    @TableField("remark")
+    private String remark;
+
+
     /**
      * 分享常量类
      */

+ 1 - 1
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/po/UserInfo.java

@@ -16,7 +16,7 @@ public class UserInfo extends BasePO {
      * 主键ID,自增策略
      */
     @TableId(type = IdType.ASSIGN_ID)
-    private Long userInfoId;
+    private Long userId;
 
     /**
      * 用户openid,唯一标识

+ 10 - 3
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/impl/DevInfoServiceImpl.java

@@ -6,21 +6,28 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.hfln.portal.common.request.device.DeviceBandingParams;
 import com.hfln.portal.domain.customer.util.UpdateWrapperBuilder;
 import com.hfln.portal.infrastructure.mapper.DevInfoMapper;
+import com.hfln.portal.infrastructure.mapper.GroupDevMapMapper;
 import com.hfln.portal.infrastructure.po.DevInfo;
+import com.hfln.portal.infrastructure.po.GroupDevMap;
 import com.hfln.portal.infrastructure.service.DevInfoService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
 import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 @Service
 @Slf4j
 public class DevInfoServiceImpl extends ServiceImpl<DevInfoMapper, DevInfo> implements DevInfoService {
 
+    @Autowired
+    private GroupDevMapMapper groupDevMapMapper;
+
     @Override
     public List<DevInfo> queryDeviceList(Long userId, String keyWord, Integer status, List<String> sharedDevIds) {
         // 参数校验
@@ -81,7 +88,7 @@ public class DevInfoServiceImpl extends ServiceImpl<DevInfoMapper, DevInfo> impl
 
         // 构建更新条件
         UpdateWrapperBuilder<DevInfo> builder = UpdateWrapperBuilder.<DevInfo>create()
-                .setIfNotNull(DevInfo::getDevId, request.getDevId())
+                .setIfNotNull(DevInfo::getDevId, request.getClientId())
                 .setIfNotNull(DevInfo::getUserId, request.getUserId())
                 .setIfNotBlank(DevInfo::getDevName, request.getDevName())
                 .setIfNotNull(DevInfo::getLength, request.getLength())
@@ -100,9 +107,9 @@ public class DevInfoServiceImpl extends ServiceImpl<DevInfoMapper, DevInfo> impl
 
         // 根据identifier类型决定使用哪个条件
         if (identifier instanceof Long) {
-            builder.eq(DevInfo::getDevInfoId, identifier);
-        } else if (identifier instanceof String) {
             builder.eq(DevInfo::getDevId, identifier);
+        } else if (identifier instanceof String) {
+            builder.eq(DevInfo::getClientId, identifier);
         } else {
             throw new IllegalArgumentException("不支持的设备标识类型");
         }

+ 1 - 1
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/impl/DevShareServiceImpl.java

@@ -22,7 +22,7 @@ public class DevShareServiceImpl extends ServiceImpl<DevShareMapper, DevShare> i
         }
         List<String> deviceIds = this.baseMapper.selectObjs(
                         new LambdaQueryWrapper<DevShare>()
-                                .select(DevShare::getDevId)
+                                .select(DevShare::getClientId)
                                 .eq(DevShare::getSharedUserId, userId)
                                 .eq(DevShare::getState, 1)
                                 .eq(DevShare::getIsDeleted, 0)

+ 1 - 1
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/impl/GroupShareServiceImpl.java

@@ -25,7 +25,7 @@ public class GroupShareServiceImpl extends ServiceImpl<GroupShareMapper, GroupSh
         return this.baseMapper.selectObjs(
                         new LambdaQueryWrapper<GroupShare>()
                                 .select(GroupShare::getGroupUuid)
-                                .eq(GroupShare::getSharedUserId, userId)
+                                .eq(GroupShare::getShared, userId)
                                 .eq(GroupShare::getState, 1)
                                 .eq(GroupShare::getIsDeleted, 0)
                 ).stream()

+ 1 - 1
portal-service-server/src/main/resources/bootstrap-dev.yml

@@ -31,7 +31,7 @@ spring:
         max-wait: -1ms
   datasource:
     driver-class-name: com.mysql.cj.jdbc.Driver
-    url: jdbc:mysql://8.130.28.21:3306/lnxx_dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=Asia/Shanghai
+    url: jdbc:mysql://8.130.28.21:3306/jkld?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=Asia/Shanghai
     username: root
     password: Hfln@1024
     druid: