From 1e4eec84012d5e3ebe63cf4bc35516187e63ced4 Mon Sep 17 00:00:00 2001 From: zcxlsm Date: Sat, 6 Sep 2025 14:26:44 +0800 Subject: [PATCH] =?UTF-8?q?refactor(property):=20=20-=20TbMeterInfoService?= =?UTF-8?q?Impl=20=E4=B8=AD=E6=A8=A1=E6=8B=9F=20token=20=E4=B8=8A=E4=B8=8B?= =?UTF-8?q?=E6=96=87=20=20-=20resident=E6=9C=8D=E5=8A=A1=E5=88=86=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ResidentPersonController.java | 2 +- .../property/controller/ResidentUnitController.java | 2 +- .../controller/xcx/XResidentPersonController.java | 2 +- .../dubbo/RemoteResidentPersonServiceImpl.java | 2 +- .../listener/ResidentPersonImportListener.java | 4 ++-- .../ResidentPersonServiceImpl.java | 13 +++++++++---- .../{ => residentImpl}/ResidentUnitServiceImpl.java | 6 +++--- .../smartDevicesImpl/TbMeterInfoServiceImpl.java | 9 +++++++-- .../IResidentPersonService.java | 2 +- .../{ => residentService}/IResidentUnitService.java | 2 +- .../org/dromara/property/utils/UploadFaceUtil.java | 2 +- 11 files changed, 28 insertions(+), 18 deletions(-) rename ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/{ => residentImpl}/ResidentPersonServiceImpl.java (95%) rename ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/{ => residentImpl}/ResidentUnitServiceImpl.java (97%) rename ruoyi-modules/Property/src/main/java/org/dromara/property/service/{ => residentService}/IResidentPersonService.java (97%) rename ruoyi-modules/Property/src/main/java/org/dromara/property/service/{ => residentService}/IResidentUnitService.java (96%) diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/ResidentPersonController.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/ResidentPersonController.java index 773c5223..29f9c45f 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/ResidentPersonController.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/ResidentPersonController.java @@ -27,7 +27,7 @@ import org.dromara.common.log.enums.BusinessType; import org.dromara.common.excel.utils.ExcelUtil; import org.dromara.property.domain.vo.residentVo.ResidentPersonVo; import org.dromara.property.domain.bo.residentBo.ResidentPersonBo; -import org.dromara.property.service.IResidentPersonService; +import org.dromara.property.service.residentService.IResidentPersonService; import org.dromara.common.mybatis.core.page.TableDataInfo; import org.springframework.web.multipart.MultipartFile; diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/ResidentUnitController.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/ResidentUnitController.java index 0ae747e8..f9570734 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/ResidentUnitController.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/ResidentUnitController.java @@ -19,7 +19,7 @@ import org.dromara.common.log.enums.BusinessType; import org.dromara.common.excel.utils.ExcelUtil; import org.dromara.property.domain.vo.residentVo.ResidentUnitVo; import org.dromara.property.domain.bo.residentBo.ResidentUnitBo; -import org.dromara.property.service.IResidentUnitService; +import org.dromara.property.service.residentService.IResidentUnitService; import org.dromara.common.mybatis.core.page.TableDataInfo; /** diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/xcx/XResidentPersonController.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/xcx/XResidentPersonController.java index 43491054..c34c4ada 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/xcx/XResidentPersonController.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/xcx/XResidentPersonController.java @@ -18,7 +18,7 @@ import org.dromara.common.web.core.BaseController; import org.dromara.property.api.model.LoginResidentPerson; import org.dromara.property.domain.bo.residentBo.ResidentPersonBo; import org.dromara.property.domain.vo.residentVo.ResidentPersonVo; -import org.dromara.property.service.IResidentPersonService; +import org.dromara.property.service.residentService.IResidentPersonService; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteResidentPersonServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteResidentPersonServiceImpl.java index 8e5a84f4..3f9400ae 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteResidentPersonServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteResidentPersonServiceImpl.java @@ -11,7 +11,7 @@ import org.dromara.property.api.model.LoginResidentPerson; import org.dromara.property.domain.bo.residentBo.ResidentPersonBo; import org.dromara.property.domain.vo.residentVo.ResidentPersonVo; import org.dromara.common.core.exception.residentPerson.ResidentPersonException; -import org.dromara.property.service.IResidentPersonService; +import org.dromara.property.service.residentService.IResidentPersonService; import java.util.List; diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/listener/ResidentPersonImportListener.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/listener/ResidentPersonImportListener.java index 93e9ca70..786ce5ed 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/listener/ResidentPersonImportListener.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/listener/ResidentPersonImportListener.java @@ -19,8 +19,8 @@ import org.dromara.property.domain.bo.residentBo.ResidentPersonBo; import org.dromara.property.domain.vo.residentVo.ResidentPersonImportVo; import org.dromara.property.domain.vo.residentVo.ResidentPersonVo; import org.dromara.property.domain.vo.residentVo.ResidentUnitVo; -import org.dromara.property.service.IResidentPersonService; -import org.dromara.property.service.IResidentUnitService; +import org.dromara.property.service.residentService.IResidentPersonService; +import org.dromara.property.service.residentService.IResidentUnitService; import java.util.Date; import java.util.List; diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/ResidentPersonServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/residentImpl/ResidentPersonServiceImpl.java similarity index 95% rename from ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/ResidentPersonServiceImpl.java rename to ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/residentImpl/ResidentPersonServiceImpl.java index 45d6532c..597a51e9 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/ResidentPersonServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/residentImpl/ResidentPersonServiceImpl.java @@ -1,6 +1,7 @@ -package org.dromara.property.service.impl; +package org.dromara.property.service.impl.residentImpl; import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.digest.BCrypt; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import org.apache.dubbo.config.annotation.DubboReference; @@ -13,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.extern.slf4j.Slf4j; import org.dromara.property.domain.vo.residentVo.ResidentUnitVo; -import org.dromara.property.service.IResidentUnitService; +import org.dromara.property.service.residentService.IResidentUnitService; import org.dromara.sis.api.RemoteSisAuthService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; @@ -22,7 +23,7 @@ import org.dromara.property.domain.bo.residentBo.ResidentPersonBo; import org.dromara.property.domain.vo.residentVo.ResidentPersonVo; import org.dromara.property.domain.entity.resident.ResidentPerson; import org.dromara.property.mapper.ResidentPersonMapper; -import org.dromara.property.service.IResidentPersonService; +import org.dromara.property.service.residentService.IResidentPersonService; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; @@ -147,7 +148,11 @@ public class ResidentPersonServiceImpl implements IResidentPersonService { // 首次入驻新用户权限组默认使用公司权限 ResidentUnitVo ruVo = residentUnitService.queryById(bo.getUnitId()); // 密码加密,不存明文密码 - add.setPassword(BCrypt.hashpw("123456")); + if (Objects.equals(add.getPassword(), "") || add.getPassword() == null){ + add.setPassword(BCrypt.hashpw("123456")); + }else { + add.setPassword(BCrypt.hashpw(add.getPassword())); + } //查询该单位下是否有管理员 new LambdaQueryWrapper().eq(ResidentPerson::getUnitId, bo.getUnitId()) .eq(ResidentPerson::getUserRoles, 1); diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/ResidentUnitServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/residentImpl/ResidentUnitServiceImpl.java similarity index 97% rename from ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/ResidentUnitServiceImpl.java rename to ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/residentImpl/ResidentUnitServiceImpl.java index e85c84b3..b1fbf5b0 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/ResidentUnitServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/residentImpl/ResidentUnitServiceImpl.java @@ -1,4 +1,4 @@ -package org.dromara.property.service.impl; +package org.dromara.property.service.impl.residentImpl; import cn.hutool.core.collection.CollUtil; import cn.hutool.crypto.digest.BCrypt; @@ -13,14 +13,14 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.dromara.property.domain.entity.resident.ResidentPerson; import org.dromara.property.mapper.ResidentPersonMapper; -import org.dromara.property.service.IResidentPersonService; +import org.dromara.property.service.residentService.IResidentPersonService; import org.dromara.property.service.ITbRoomService; import org.springframework.stereotype.Service; import org.dromara.property.domain.bo.residentBo.ResidentUnitBo; import org.dromara.property.domain.vo.residentVo.ResidentUnitVo; import org.dromara.property.domain.entity.resident.ResidentUnit; import org.dromara.property.mapper.ResidentUnitMapper; -import org.dromara.property.service.IResidentUnitService; +import org.dromara.property.service.residentService.IResidentUnitService; import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/smartDevicesImpl/TbMeterInfoServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/smartDevicesImpl/TbMeterInfoServiceImpl.java index 2a83acc9..565b37fc 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/smartDevicesImpl/TbMeterInfoServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/smartDevicesImpl/TbMeterInfoServiceImpl.java @@ -1,5 +1,6 @@ package org.dromara.property.service.impl.smartDevicesImpl; +import cn.dev33.satoken.context.mock.SaTokenContextMockUtil; import cn.dev33.satoken.stp.StpUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.lang.Assert; @@ -335,7 +336,9 @@ public class TbMeterInfoServiceImpl implements ITbMeterInfoService { private void handleMeterCommunicationFailure(LoginUser user, JSONObject jsonObject, List meterInfoVoList, String tokenValue) { meterInfoVoList.forEach(item -> item.setCommunicationState(0L)); jsonObject.put("data", meterInfoVoList); - remoteMessageService.sendMessage(user.getUserId(), tokenValue, jsonObject.toString()); + SaTokenContextMockUtil.setMockContext(() -> { + remoteMessageService.sendMessage(user.getUserId(), tokenValue, jsonObject.toString()); + }); } /** @@ -377,6 +380,8 @@ public class TbMeterInfoServiceImpl implements ITbMeterInfoService { } jsonObject.put("data", meterInfoVoList); - remoteMessageService.sendMessage(user.getUserId(), tokenValue, jsonObject.toString()); + SaTokenContextMockUtil.setMockContext(() -> { + remoteMessageService.sendMessage(user.getUserId(), tokenValue, jsonObject.toString()); + }); } } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/IResidentPersonService.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/residentService/IResidentPersonService.java similarity index 97% rename from ruoyi-modules/Property/src/main/java/org/dromara/property/service/IResidentPersonService.java rename to ruoyi-modules/Property/src/main/java/org/dromara/property/service/residentService/IResidentPersonService.java index 485c7332..cfd79358 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/IResidentPersonService.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/residentService/IResidentPersonService.java @@ -1,4 +1,4 @@ -package org.dromara.property.service; +package org.dromara.property.service.residentService; import org.dromara.property.domain.vo.residentVo.ResidentPersonVo; import org.dromara.property.domain.bo.residentBo.ResidentPersonBo; diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/IResidentUnitService.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/residentService/IResidentUnitService.java similarity index 96% rename from ruoyi-modules/Property/src/main/java/org/dromara/property/service/IResidentUnitService.java rename to ruoyi-modules/Property/src/main/java/org/dromara/property/service/residentService/IResidentUnitService.java index c840b6e2..cc6d23e5 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/IResidentUnitService.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/residentService/IResidentUnitService.java @@ -1,4 +1,4 @@ -package org.dromara.property.service; +package org.dromara.property.service.residentService; import org.dromara.property.domain.vo.residentVo.ResidentUnitVo; import org.dromara.property.domain.bo.residentBo.ResidentUnitBo; diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/utils/UploadFaceUtil.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/utils/UploadFaceUtil.java index 38a93128..c17836fc 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/utils/UploadFaceUtil.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/utils/UploadFaceUtil.java @@ -6,7 +6,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.config.annotation.DubboReference; import org.dromara.property.domain.bo.residentBo.ResidentPersonBo; import org.dromara.property.domain.vo.residentVo.ResidentPersonVo; -import org.dromara.property.service.IResidentPersonService; +import org.dromara.property.service.residentService.IResidentPersonService; import org.dromara.resource.api.RemoteFileService; import org.dromara.resource.api.domain.RemoteFile; import org.springframework.stereotype.Service;