|
@@ -0,0 +1,91 @@
|
|
|
+package com.hfln.portal.infrastructure.gateway.impl;
|
|
|
+
|
|
|
+
|
|
|
+import cn.hfln.framework.extension.BizException;
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.hfln.portal.common.request.web.AdminDealUnbindParam;
|
|
|
+import com.hfln.portal.common.request.web.AdminQueryWxUserParam;
|
|
|
+import com.hfln.portal.common.response.user.UserInfoDto;
|
|
|
+import com.hfln.portal.domain.customer.OprLogType;
|
|
|
+import com.hfln.portal.domain.customer.util.CopyUtils;
|
|
|
+import com.hfln.portal.domain.exception.ErrorEnum;
|
|
|
+import com.hfln.portal.domain.gateway.WebAdminDealGateway;
|
|
|
+import com.hfln.portal.infrastructure.po.DevInfo;
|
|
|
+import com.hfln.portal.infrastructure.po.DevShare;
|
|
|
+import com.hfln.portal.infrastructure.po.GroupDevMap;
|
|
|
+import com.hfln.portal.infrastructure.po.UserInfo;
|
|
|
+import com.hfln.portal.infrastructure.service.*;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+public class WebAdminDealGatewayImpl implements WebAdminDealGateway {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DevInfoService devInfoService;
|
|
|
+ @Autowired
|
|
|
+ private DevShareService devShareService;
|
|
|
+ @Autowired
|
|
|
+ private GroupDevMapService groupDevMapService;
|
|
|
+ @Autowired
|
|
|
+ private TblOprLogService tblOprLogService;
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void unbind(AdminDealUnbindParam param) {
|
|
|
+
|
|
|
+ // 设备解绑
|
|
|
+ // 1 设备主绑人 解绑
|
|
|
+ // 3 设备所属租户 解绑
|
|
|
+ // 2 设备被分享者 逻辑删除
|
|
|
+ // 4 群组分享表 逻辑删除
|
|
|
+ log.info("超管对设备devId:{}, 进行解绑", param.getDevId());
|
|
|
+
|
|
|
+ DevInfo devInfo = devInfoService.getById(param.getDevId());
|
|
|
+ if (devInfo == null) {
|
|
|
+ throw new BizException(ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorCode(), ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ tblOprLogService.saveLog(OprLogType.ADMIN_DEAL_UNBIND.getCode(), devInfo);
|
|
|
+ log.info("设备信息:{}", JSON.toJSONString(devInfo));
|
|
|
+
|
|
|
+ // 查询设备分享者 逻辑删除
|
|
|
+ List<DevShare> shares = devShareService.list(new LambdaQueryWrapper<DevShare>().eq(DevShare::getDevId, devInfo.getDevId()));
|
|
|
+ log.info("设备被分享者:{}", JSON.toJSONString(shares));
|
|
|
+ devShareService.update(
|
|
|
+ Wrappers.<DevShare>lambdaUpdate()
|
|
|
+ .eq(DevShare::getDevId, devInfo.getDevId())
|
|
|
+ .eq(DevShare::getIsDeleted, 0)
|
|
|
+ .set(DevShare::getIsDeleted, 1)
|
|
|
+ );
|
|
|
+ // 群组设备分享表 逻辑删除
|
|
|
+ List<GroupDevMap> groupDevMaps = groupDevMapService.queryByDevId(devInfo.getDevId());
|
|
|
+ log.info("群组设备分享表:{}", JSON.toJSONString(groupDevMaps));
|
|
|
+ groupDevMapService.update(
|
|
|
+ Wrappers.<GroupDevMap>lambdaUpdate()
|
|
|
+ .eq(GroupDevMap::getDevId, devInfo.getDevId())
|
|
|
+ .eq(GroupDevMap::getIsDeleted, 0)
|
|
|
+ .set(GroupDevMap::getIsDeleted, 1)
|
|
|
+ );
|
|
|
+
|
|
|
+ // 对设备 绑定信息置空信息
|
|
|
+ devInfoService.resetDevInfo(devInfo.getDevId());
|
|
|
+ log.info("超管设备解绑完成");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public UserInfoDto queryWxUser(AdminQueryWxUserParam param) {
|
|
|
+
|
|
|
+ UserInfo userInfo = userService.queryById(param.getUserId());
|
|
|
+ return CopyUtils.copy(userInfo, UserInfoDto.class);
|
|
|
+ }
|
|
|
+}
|