feat(新增): 强制用户下线

This commit is contained in:
Bunny 2024-10-05 15:21:15 +08:00
parent f73a3e539a
commit 4c9db97991
15 changed files with 68 additions and 33 deletions

View File

@ -28,8 +28,5 @@ public class DeptAddDto {
@Schema(name = "summary", title = "部门简介")
private String summary;
@Schema(name = "remarks", title = "备注信息")
private String remarks;
}

View File

@ -25,8 +25,5 @@ public class DeptDto {
@Schema(name = "summary", title = "部门简介")
private String summary;
@Schema(name = "remarks", title = "备注信息")
private String remarks;
}

View File

@ -33,8 +33,5 @@ public class DeptUpdateDto {
@Schema(name = "summary", title = "部门简介")
private String summary;
@Schema(name = "remarks", title = "备注信息")
private String remarks;
}

View File

@ -14,6 +14,10 @@ import lombok.NoArgsConstructor;
@Schema(name = "MenuIconAddDto对象", title = "系统菜单图标", description = "系统菜单图标管理")
public class MenuIconAddDto {
@Schema(name = "iconCode", title = "icon类名")
@NotBlank(message = "iconCode不能为空")
private String iconCode;
@Schema(name = "iconName", title = "icon 名称")
@NotBlank(message = "icon 名称不能为空")
private String iconName;

View File

@ -13,6 +13,9 @@ import lombok.NoArgsConstructor;
@Schema(name = "MenuIconDto对象", title = "系统菜单图标", description = "系统菜单图标管理")
public class MenuIconDto {
@Schema(name = "iconCode", title = "icon类名")
private String iconCode;
@Schema(name = "iconName", title = "icon 名称")
private String iconName;

View File

@ -19,6 +19,10 @@ public class MenuIconUpdateDto {
@NotNull(message = "id不能为空")
private Long id;
@Schema(name = "iconCode", title = "icon类名")
@NotBlank(message = "iconCode不能为空")
private String iconCode;
@Schema(name = "iconName", title = "icon 名称")
@NotBlank(message = "icon 名称不能为空")
private String iconName;

View File

@ -34,8 +34,5 @@ public class Dept extends BaseEntity {
@Schema(name = "summary", title = "部门简介")
private String summary;
@Schema(name = "remarks", title = "备注信息")
private String remarks;
}

View File

@ -14,6 +14,9 @@ import lombok.experimental.Accessors;
@Schema(name = "MenuIcon对象", title = "系统菜单图标", description = "系统菜单图标")
public class MenuIcon extends BaseEntity {
@Schema(name = "iconCode", title = "icon类名")
private String iconCode;
@Schema(name = "iconName", title = "icon 名称")
private String iconName;

View File

@ -24,7 +24,4 @@ public class DeptVo extends BaseVo {
@Schema(name = "summary", title = "部门简介")
private String summary;
@Schema(name = "remarks", title = "备注信息")
private String remarks;
}

View File

@ -12,6 +12,9 @@ import lombok.*;
@Schema(name = "MenuIconVo对象", title = "系统菜单图标", description = "系统菜单图标")
public class MenuIconVo extends BaseVo {
@Schema(name = "iconCode", title = "icon类名")
private String iconCode;
@Schema(name = "iconName", title = "icon 名称")
private String iconName;

View File

@ -92,6 +92,13 @@ public class UserController {
return Result.success(vo);
}
@Operation(summary = "强制退出", description = "强制退出")
@PutMapping("forcedOffline")
public Result<String> forcedOffline(@RequestBody Long id) {
userService.forcedOffline(id);
return Result.success();
}
@Operation(summary = "退出登录", description = "退出登录")
@PostMapping("logout")
public Result<String> logout() {

View File

@ -93,4 +93,11 @@ public interface UserService extends IService<AdminUser> {
* @param dto 管理员用户修改头像
*/
void uploadAvatarByAdmin(UserUpdateWithAvatarDto dto);
/**
* * 强制退出
*
* @param id 用户id
*/
void forcedOffline(Long id);
}

View File

@ -200,6 +200,23 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
updateById(adminUser);
}
/**
* * 强制退出
*
* @param id 用户id
*/
@Override
public void forcedOffline(Long id) {
if (id == null) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
// 根据id查询用户登录前缀
AdminUser adminUser = getOne(Wrappers.<AdminUser>lambdaQuery().eq(AdminUser::getId, id));
String email = adminUser.getEmail();
String adminLoginInfoPrefix = RedisUserConstant.getAdminLoginInfoPrefix(email);
redisTemplate.delete(adminLoginInfoPrefix);
}
/**
* * 用户信息 服务实现类
*

View File

@ -14,34 +14,31 @@
<id column="manager_id" property="managerId"/>
<id column="dept_name" property="deptName"/>
<id column="summary" property="summary"/>
<id column="remarks" property="remarks"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, create_time, update_time, create_user, update_user, is_deleted, parent_id, manager_id, dept_name, summary, remarks
id, create_time, update_time, create_user, update_user, is_deleted, parent_id, manager_id, dept_name, summary
</sql>
<!-- 分页查询部门内容 -->
<select id="selectListByPage" resultType="cn.bunny.dao.entity.system.Dept">
select <include refid="Base_Column_List"/>
select
<include refid="Base_Column_List"/>
from sys_dept
<where>
<if test="dto.parentId != null and dto.parentId != ''">
<if test="dto.parentId != null and dto.parentId != ''">
parent_id like CONCAT('%',#{dto.parentId},'%')
</if>
<if test="dto.managerId != null and dto.managerId != ''">
</if>
<if test="dto.managerId != null and dto.managerId != ''">
manager_id like CONCAT('%',#{dto.managerId},'%')
</if>
<if test="dto.deptName != null and dto.deptName != ''">
</if>
<if test="dto.deptName != null and dto.deptName != ''">
dept_name like CONCAT('%',#{dto.deptName},'%')
</if>
<if test="dto.summary != null and dto.summary != ''">
</if>
<if test="dto.summary != null and dto.summary != ''">
summary like CONCAT('%',#{dto.summary},'%')
</if>
<if test="dto.remarks != null and dto.remarks != ''">
remarks like CONCAT('%',#{dto.remarks},'%')
</if>
</if>
</where>
order by update_time
</select>

View File

@ -11,21 +11,26 @@
<id column="update_user" property="updateUser"/>
<id column="is_deleted" property="isDeleted"/>
<id column="icon_name" property="iconName"/>
<id column="icon_code" property="iconCode"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, create_time, update_time, create_user, update_user, is_deleted, icon_name
id, create_time, update_time, create_user, update_user, is_deleted, icon_name, icon_code
</sql>
<!-- 分页查询系统菜单图标内容 -->
<select id="selectListByPage" resultType="cn.bunny.dao.entity.system.MenuIcon">
select <include refid="Base_Column_List"/>
select
<include refid="Base_Column_List"/>
from sys_menu_icon
<where>
<if test="dto.iconName != null and dto.iconName != ''">
<if test="dto.iconCode != null and dto.iconCode != ''">
icon_code like CONCAT('%',#{dto.iconCode},'%')
</if>
<if test="dto.iconName != null and dto.iconName != ''">
icon_name like CONCAT('%',#{dto.iconName},'%')
</if>
</if>
</where>
order by update_time
</select>