Merge branch '6170' into prod

This commit is contained in:
2025-11-28 10:18:54 +08:00
13 changed files with 61 additions and 19 deletions

View File

@ -4,6 +4,7 @@ import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.fuyuanshen.app.domain.bo.AppDeviceBindRecordBo;
import com.fuyuanshen.app.domain.bo.AppDeviceShareBo;
import com.fuyuanshen.app.domain.vo.AppDeviceBindRecordVo;
@ -27,6 +28,8 @@ import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
import com.fuyuanshen.common.satoken.utils.LoginHelper;
import com.fuyuanshen.common.tenant.exception.TenantException;
import com.fuyuanshen.common.tenant.helper.TenantHelper;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.service.DeviceService;
import com.fuyuanshen.system.domain.vo.SysTenantVo;
import com.fuyuanshen.system.service.ISysTenantService;
import lombok.RequiredArgsConstructor;
@ -59,6 +62,7 @@ public class AppLoginService {
private final IAppUserService appUserService;
private final IAppDeviceShareService appDeviceShareService;
private final IAppDeviceBindRecordService appDeviceBindRecordService;
private final DeviceService deviceService;
/**
@ -209,8 +213,7 @@ public class AppLoginService {
if(ObjectUtil.length(appDeviceBindRecordVos)>0){
// 根据设备id批量删除
List<Long> deviceIds = appDeviceBindRecordVos.stream().map(AppDeviceBindRecordVo::getDeviceId).toList();
Set<Long> deviceIds = appDeviceBindRecordVos.stream().map(AppDeviceBindRecordVo::getDeviceId).collect(Collectors.toSet());
appDeviceShareService.deleteByDeviceIds(deviceIds);
@ -219,6 +222,21 @@ public class AppLoginService {
.collect(Collectors.toList());
appDeviceBindRecordService.deleteWithValidByIds(ids, true);
log.info("删除绑定关系表数据ids={}",ids);
// 检查设备id是否存在绑定关系
for (Long deviceId : deviceIds){
// 根据设备id查询是否存在绑定关系
Long count = appDeviceBindRecordService.checkDeviceExistBindRecord(deviceId);
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id",deviceId);
if(count>0){
updateWrapper.set("binding_status",1);
}else{
updateWrapper.set("binding_status",0);
}
deviceService.update(updateWrapper);
}
}
if (TenantHelper.isEnable() && LoginHelper.isSuperAdmin()) {

View File

@ -101,13 +101,13 @@ public class AuthController {
// 登录
LoginVo loginVo = IAuthStrategy.login(body, client, grantType);
Long userId = LoginHelper.getUserId();
scheduledExecutorService.schedule(() -> {
SseMessageDto dto = new SseMessageDto();
dto.setMessage("欢迎登录fys-Vue-Plus后台管理系统");
dto.setUserIds(List.of(userId));
SseMessageUtils.publishMessage(dto);
}, 5, TimeUnit.SECONDS);
// Long userId = LoginHelper.getUserId();
// scheduledExecutorService.schedule(() -> {
// SseMessageDto dto = new SseMessageDto();
// dto.setMessage("欢迎登录fys-Vue-Plus后台管理系统");
// dto.setUserIds(List.of(userId));
// SseMessageUtils.publishMessage(dto);
// }, 5, TimeUnit.SECONDS);
return R.ok(loginVo);
}