diff --git a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/domain/Customer.java b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/domain/Customer.java index 9886065..418a1bf 100644 --- a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/domain/Customer.java +++ b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/domain/Customer.java @@ -92,7 +92,7 @@ public class Customer extends TenantEntity { /** * 帐号状态(0正常 1停用) */ - private String status; + private String status = "0"; /** * 删除标志(0代表存在 1代表删除) diff --git a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/service/impl/CustomerServiceImpl.java b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/service/impl/CustomerServiceImpl.java index 85cffbf..b67ca9b 100644 --- a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/service/impl/CustomerServiceImpl.java +++ b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/service/impl/CustomerServiceImpl.java @@ -1,5 +1,6 @@ package com.fuyuanshen.customer.service.impl; +import cn.dev33.satoken.stp.StpUtil; import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -93,6 +94,7 @@ public class CustomerServiceImpl extends ServiceImpl i } customer.setUserLevel((byte) (loginUser.getUserLevel() + 1)); customer.setPid(loginUser.getUserId()); + customer.setStatus("0"); save(customer); @@ -127,7 +129,18 @@ public class CustomerServiceImpl extends ServiceImpl i if (customer.getEnabled()) { customer.setStatus("0"); } else { + // 强制下线 + // StpUtil.logout(customer.getCustomerId()); + // StpUtil.kickout(customer.getCustomerId()); customer.setStatus("1"); + // 检查目标用户是否有有效的登录状态 + if (StpUtil.isLogin(customer.getCustomerId())) { + // 用户已登录,可以执行踢出操作 + StpUtil.kickout(customer.getCustomerId()); + } else { + // 用户未登录,无法踢出 + System.out.println("目标用户未登录,无法执行踢出操作"); + } } saveOrUpdate(customer); }