Compare commits

..

No commits in common. "eb1399cea8137cbd165f0b0aa7ad39a172644db8" and "f73a3e539a48547fb74493bac94bb4f40da5243b" have entirely different histories.

36 changed files with 42 additions and 431 deletions

View File

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

View File

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

View File

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

View File

@ -14,10 +14,6 @@ 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,9 +13,6 @@ 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,10 +19,6 @@ 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

@ -1,24 +0,0 @@
package cn.bunny.dao.dto.system.router;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "AssignRolesToRoutersDto对象", title = "路由分配角色", description = "路由分配角色")
public class AssignRolesToRoutersDto {
@Schema(name = "routerId", title = "路由id")
private Long routerId;
@Schema(name = "roleIds", title = "角色id列表")
private List<Long> roleIds;
}

View File

@ -1,25 +0,0 @@
package cn.bunny.dao.dto.system.user;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "AssignRolesToUsersDto对象", title = "用户分配角色", description = "用户分配角色")
public class AssignRolesToUsersDto {
@Schema(name = "userId", title = "用户id")
private Long userId;
@Schema(name = "roleIds", title = "角色id列表")
private List<Long> roleIds;
}

View File

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

View File

@ -14,9 +14,6 @@ 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

@ -15,9 +15,9 @@ import lombok.experimental.Accessors;
public class UserRole extends BaseEntity {
@Schema(name = "userId", title = "用户id")
private Long userId;
private String userId;
@Schema(name = "roleId", title = "角色id")
private Long roleId;
private String roleId;
}

View File

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

View File

@ -12,9 +12,6 @@ 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

@ -4,8 +4,6 @@ import cn.bunny.dao.vo.BaseVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.List;
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@ -26,7 +24,4 @@ public class PowerVo extends BaseVo {
@Schema(name = "requestUrl", title = "请求路径")
private String requestUrl;
@Schema(name = "children", title = "子级")
private List<PowerVo> children;
}

View File

@ -69,11 +69,4 @@ public class PowerController {
powerService.deletePower(ids);
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
}
@Operation(summary = "获取所有权限", description = "获取所有权限")
@GetMapping("getAllPowers")
public Mono<Result<List<PowerVo>>> getAllPowers() {
List<PowerVo> voList = powerService.getAllPowers();
return Mono.just(Result.success(voList));
}
}

View File

@ -69,11 +69,4 @@ public class RoleController {
roleService.deleteRole(ids);
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
}
@Operation(summary = "获取所有角色", description = "获取所有角色")
@GetMapping("getAllRoles")
public Mono<Result<List<RoleVo>>> getAllRoles() {
List<RoleVo> roleVoList = roleService.getAllRoles();
return Mono.just(Result.success(roleVoList));
}
}

View File

@ -1,15 +1,7 @@
package cn.bunny.services.controller;
import cn.bunny.dao.dto.system.router.AssignRolesToRoutersDto;
import cn.bunny.dao.pojo.result.Result;
import cn.bunny.services.service.RouterRoleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;
import java.util.List;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
@ -19,25 +11,8 @@ import java.util.List;
* @author Bunny
* @since 2024-09-26
*/
@Tag(name = "路由和角色", description = "路由和角色相关接口")
@RestController
@RequestMapping("admin/routerRole")
@RequestMapping("/routerRole")
public class RouterRoleController {
@Autowired
private RouterRoleService routerRoleService;
@Operation(summary = "根据路由id获取所有角色", description = "根据路由id获取所有角色")
@GetMapping("getRoleListByRouterId")
public Mono<Result<List<String>>> getRoleListByRouterId(Long routerId) {
List<String> roleListByRouterId = routerRoleService.getRoleListByRouterId(routerId);
return Mono.just(Result.success(roleListByRouterId));
}
@Operation(summary = "为菜单分配角色", description = "为菜单分配角色")
@PostMapping("assignRolesToRouter")
public Mono<Result<String>> assignRolesToRouter(@RequestBody AssignRolesToRoutersDto dto) {
routerRoleService.assignRolesToRouter(dto);
return Mono.just(Result.success());
}
}

View File

@ -92,13 +92,6 @@ 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

@ -1,15 +1,7 @@
package cn.bunny.services.controller;
import cn.bunny.dao.dto.system.user.AssignRolesToUsersDto;
import cn.bunny.dao.pojo.result.Result;
import cn.bunny.services.service.UserRoleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;
import java.util.List;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
@ -19,25 +11,8 @@ import java.util.List;
* @author Bunny
* @since 2024-09-26
*/
@Tag(name = "用户和角色", description = "用户和角色相关接口")
@RestController
@RequestMapping("admin/userRole")
@RequestMapping("/userRole")
public class UserRoleController {
@Autowired
private UserRoleService userRoleService;
@Operation(summary = "根据用户id获取角色列表", description = "根据用户id获取角色列表")
@GetMapping("getRoleListByUserId")
public Mono<Result<List<String>>> getRoleListByUserId(Long userId) {
List<String> roleVoList = userRoleService.getRoleListByUserId(userId);
return Mono.just(Result.success(roleVoList));
}
@Operation(summary = "为用户分配角色", description = "为用户分配角色")
@PostMapping("assignRolesToUsers")
public Mono<Result<String>> assignRolesToUsers(@RequestBody AssignRolesToUsersDto dto) {
userRoleService.assignRolesToUsers(dto);
return Mono.just(Result.success());
}
}

View File

@ -1,25 +0,0 @@
package cn.bunny.services.factory;
import cn.bunny.dao.vo.system.rolePower.PowerVo;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class PowerFactory {
/**
* * 构建权限树形结构
*
* @param id 节点ID
* @param powerVoList 节点列表
* @return 树形列表
*/
public List<PowerVo> handlePowerVoChildren(Long id, List<PowerVo> powerVoList) {
return powerVoList.stream()
.filter(powerVo -> powerVo.getParentId().equals(id))
.peek(powerVo -> powerVo.setChildren(handlePowerVoChildren(powerVo.getId(), powerVoList)))
.toList();
}
}

View File

@ -15,10 +15,4 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface RouterRoleMapper extends BaseMapper<RouterRole> {
/**
* 根据路由id删除所有角色和路由信息
*
* @param routerId 路由id
*/
void deleteBatchIdsWithPhysicsByRouterId(Long routerId);
}

View File

@ -15,10 +15,4 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UserRoleMapper extends BaseMapper<UserRole> {
/**
* * 删除这个用户id下所有的角色信息
*
* @param userId 用户id
*/
void deleteBatchIdsWithPhysicsByUserId(Long userId);
}

View File

@ -49,12 +49,4 @@ public interface PowerService extends IService<Power> {
* @param ids 删除id列表
*/
void deletePower(List<Long> ids);
/**
* * 获取所有权限
*
* @return 所有权限列表
*/
List<PowerVo> getAllPowers();
}

View File

@ -49,11 +49,4 @@ public interface RoleService extends IService<Role> {
* @param ids 删除id列表
*/
void deleteRole(List<Long> ids);
/**
* * 获取所有角色
*
* @return 所有角色列表
*/
List<RoleVo> getAllRoles();
}

View File

@ -1,11 +1,8 @@
package cn.bunny.services.service;
import cn.bunny.dao.dto.system.router.AssignRolesToRoutersDto;
import cn.bunny.dao.entity.system.RouterRole;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类
@ -16,18 +13,4 @@ import java.util.List;
*/
public interface RouterRoleService extends IService<RouterRole> {
/**
* * 根据路由id获取所有角色
*
* @param routerId 路由id
* @return 角色列表
*/
List<String> getRoleListByRouterId(Long routerId);
/**
* * 为菜单分配角色
*
* @param dto 路由分配角色
*/
void assignRolesToRouter(AssignRolesToRoutersDto dto);
}

View File

@ -1,11 +1,8 @@
package cn.bunny.services.service;
import cn.bunny.dao.dto.system.user.AssignRolesToUsersDto;
import cn.bunny.dao.entity.system.UserRole;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类
@ -16,18 +13,4 @@ import java.util.List;
*/
public interface UserRoleService extends IService<UserRole> {
/**
* * 为用户分配角色
*
* @param dto 用户分配角色
*/
void assignRolesToUsers(AssignRolesToUsersDto dto);
/**
* * 根据用户id获取角色列表
*
* @param userId 用户id
* @return 角色列表
*/
List<String> getRoleListByUserId(Long userId);
}

View File

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

View File

@ -6,7 +6,6 @@ import cn.bunny.dao.dto.system.rolePower.PowerUpdateDto;
import cn.bunny.dao.entity.system.Power;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.system.rolePower.PowerVo;
import cn.bunny.services.factory.PowerFactory;
import cn.bunny.services.mapper.PowerMapper;
import cn.bunny.services.service.PowerService;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -16,7 +15,6 @@ import jakarta.validation.Valid;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
@ -30,12 +28,6 @@ import java.util.List;
@Service
public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements PowerService {
private final PowerFactory powerFactory;
public PowerServiceImpl(PowerFactory powerFactory) {
this.powerFactory = powerFactory;
}
/**
* * 权限 服务实现类
*
@ -97,30 +89,4 @@ public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements
public void deletePower(List<Long> ids) {
baseMapper.deleteBatchIdsWithPhysics(ids);
}
/**
* * 获取所有权限
*
* @return 所有权限列表
*/
@Override
public List<PowerVo> getAllPowers() {
List<Power> powerList = list();
ArrayList<PowerVo> powerVos = new ArrayList<>();
// 构建返回波对象
List<PowerVo> powerVoList = powerList.stream().map(power -> {
PowerVo powerVo = new PowerVo();
BeanUtils.copyProperties(power, powerVo);
return powerVo;
}).toList();
powerVoList.stream()
.filter(power -> power.getParentId() == 0)
.forEach(powerVo -> {
powerVo.setChildren(powerFactory.handlePowerVoChildren(powerVo.getId(), powerVoList));
powerVos.add(powerVo);
});
return powerVos;
}
}

View File

@ -89,18 +89,4 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
public void deleteRole(List<Long> ids) {
baseMapper.deleteBatchIdsWithPhysics(ids);
}
/**
* * 获取所有角色
*
* @return 所有角色列表
*/
@Override
public List<RoleVo> getAllRoles() {
return list().stream().map(role -> {
RoleVo roleVo = new RoleVo();
BeanUtils.copyProperties(role, roleVo);
return roleVo;
}).toList();
}
}

View File

@ -1,15 +1,10 @@
package cn.bunny.services.service.impl;
import cn.bunny.dao.dto.system.router.AssignRolesToRoutersDto;
import cn.bunny.dao.entity.system.RouterRole;
import cn.bunny.services.mapper.RouterRoleMapper;
import cn.bunny.services.service.RouterRoleService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* <p>
@ -20,41 +15,6 @@ import java.util.List;
* @since 2024-09-26
*/
@Service
@Transactional
public class RouterRoleServiceImpl extends ServiceImpl<RouterRoleMapper, RouterRole> implements RouterRoleService {
/**
* * 根据路由id获取所有角色
*
* @param routerId 路由id
* @return 角色列表
*/
@Override
public List<String> getRoleListByRouterId(Long routerId) {
return list(Wrappers.<RouterRole>lambdaQuery().eq(RouterRole::getRouterId, routerId)).stream()
.map(routerRole -> routerRole.getRoleId().toString()).toList();
}
/**
* * 为菜单分配角色
*
* @param dto 路由分配角色
*/
@Override
public void assignRolesToRouter(AssignRolesToRoutersDto dto) {
Long routerId = dto.getRouterId();
List<Long> roleIds = dto.getRoleIds();
// 删除这个用户下所有已经分配好的角色内容
baseMapper.deleteBatchIdsWithPhysicsByRouterId(routerId);
// 保存分配好的角色信息
List<RouterRole> roleList = roleIds.stream().map(roleId -> {
RouterRole routerRole = new RouterRole();
routerRole.setRouterId(routerId);
routerRole.setRoleId(roleId);
return routerRole;
}).toList();
saveBatch(roleList);
}
}

View File

@ -1,18 +1,10 @@
package cn.bunny.services.service.impl;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.dao.dto.system.user.AssignRolesToUsersDto;
import cn.bunny.dao.entity.system.UserRole;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
import cn.bunny.services.mapper.UserRoleMapper;
import cn.bunny.services.service.UserRoleService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* <p>
@ -23,46 +15,6 @@ import java.util.List;
* @since 2024-09-26
*/
@Service
@Transactional
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements UserRoleService {
@Autowired
private UserRoleMapper userRoleMapper;
/**
* * 根据用户id获取角色列表
*
* @param userId 用户id
* @return 角色列表
*/
@Override
public List<String> getRoleListByUserId(Long userId) {
if (userId == null) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
List<UserRole> userRoles = userRoleMapper.selectList(Wrappers.<UserRole>lambdaQuery().eq(UserRole::getUserId, userId));
return userRoles.stream().map(userRole -> userRole.getRoleId().toString()).toList();
}
/**
* * 为用户分配角色
*
* @param dto 用户分配角色
*/
@Override
public void assignRolesToUsers(AssignRolesToUsersDto dto) {
Long userId = dto.getUserId();
List<Long> roleIds = dto.getRoleIds();
// 删除这个用户下所有已经分配好的角色内容
baseMapper.deleteBatchIdsWithPhysicsByUserId(userId);
// 保存分配好的角色信息
List<UserRole> roleList = roleIds.stream().map(roleId -> {
UserRole userRole = new UserRole();
userRole.setUserId(userId);
userRole.setRoleId(roleId);
return userRole;
}).toList();
saveBatch(roleList);
}
}

View File

@ -200,23 +200,6 @@ 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,17 +14,17 @@
<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
id, create_time, update_time, create_user, update_user, is_deleted, parent_id, manager_id, dept_name, summary, remarks
</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 != ''">
@ -39,6 +39,9 @@
<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>
</where>
order by update_time
</select>

View File

@ -11,23 +11,18 @@
<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, icon_code
id, create_time, update_time, create_user, update_user, is_deleted, icon_name
</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.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>

View File

@ -19,11 +19,4 @@
id, router_id, role_id, create_user, update_time, update_user, create_time, is_deleted
</sql>
<!-- 根据路由id删除所有角色和路由信息 -->
<delete id="deleteBatchIdsWithPhysicsByRouterId">
delete
from sys_router_role
where router_id = #{routerId}
</delete>
</mapper>

View File

@ -19,11 +19,4 @@
id, user_id, role_id, create_time, update_time, create_user, update_user, is_deleted
</sql>
<!-- 删除这个用户id下所有的角色信息 -->
<delete id="deleteBatchIdsWithPhysicsByUserId">
delete
from sys_user_role
where user_id = #{userId}
</delete>
</mapper>