16 changed files with 57 additions and 304 deletions
@ -1,49 +1,49 @@ |
|||||
package com.qs.serve.common.model.enums; |
package com.qs.serve.common.model.enums; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Getter; |
||||
|
|
||||
/** |
/** |
||||
* @author YenHex |
* @author YenHex |
||||
* @since 2022/3/8 |
* @since 2022/3/8 |
||||
*/ |
*/ |
||||
|
@Getter |
||||
|
@AllArgsConstructor |
||||
public enum BizType { |
public enum BizType { |
||||
|
|
||||
/** 其它 */ |
/** 其它 */ |
||||
OTHER, |
OTHER("其它"), |
||||
|
|
||||
/** 新增 */ |
/** 新增 */ |
||||
INSERT, |
INSERT("新增"), |
||||
|
|
||||
/** 修改 */ |
/** 修改 */ |
||||
UPDATE, |
UPDATE("修改"), |
||||
|
|
||||
/** 删除 */ |
/** 删除 */ |
||||
DELETE, |
DELETE("删除"), |
||||
|
|
||||
/** 授权 */ |
/** 授权 */ |
||||
GRANT, |
GRANT("授权"), |
||||
|
|
||||
/** 导出 */ |
|
||||
EXPORT, |
|
||||
|
|
||||
/** 导入 */ |
|
||||
IMPORT, |
|
||||
|
|
||||
/** 强退 */ |
/** 强退 */ |
||||
FORCE, |
FORCE("强退"), |
||||
|
|
||||
/** 清空数据 */ |
/** 清空数据 */ |
||||
CLEAN, |
CLEAN("清空"), |
||||
|
|
||||
/** 登录 */ |
/** 登录 */ |
||||
LOGIN, |
LOGIN("登录"), |
||||
|
|
||||
LOGOUT, |
LOGOUT("登出"), |
||||
|
|
||||
UPLOAD, |
UPLOAD("上传"), |
||||
|
|
||||
DOWNLOAD, |
DOWNLOAD("下载"), |
||||
|
|
||||
QUERY, |
QUERY("查询"), |
||||
|
|
||||
RESET |
RESET("重置"); |
||||
|
|
||||
|
String value; |
||||
} |
} |
||||
|
@ -1,57 +0,0 @@ |
|||||
package com.qs.serve.modules.sys.entity; |
|
||||
|
|
||||
import java.time.LocalDateTime; |
|
||||
import java.io.Serializable; |
|
||||
|
|
||||
import com.baomidou.mybatisplus.annotation.*; |
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|
||||
import lombok.Data; |
|
||||
import org.springframework.format.annotation.DateTimeFormat; |
|
||||
|
|
||||
/** |
|
||||
* 角色权限 实体类 |
|
||||
* @author YenHex |
|
||||
* @since 2022-03-01 |
|
||||
*/ |
|
||||
@Data |
|
||||
@TableName("sys_role_permit") |
|
||||
public class SysRolePermit implements Serializable { |
|
||||
|
|
||||
private static final long serialVersionUID = 1L; |
|
||||
|
|
||||
/** id */ |
|
||||
@TableId(type = IdType.ASSIGN_UUID) |
|
||||
private String id; |
|
||||
|
|
||||
/** 角色ID */ |
|
||||
private String roleId; |
|
||||
|
|
||||
/** 权限ID */ |
|
||||
private String permitId; |
|
||||
|
|
||||
/** 创建时间 */ |
|
||||
@TableField(fill = FieldFill.INSERT) |
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
|
||||
private LocalDateTime createTime; |
|
||||
|
|
||||
/** 创建人 */ |
|
||||
@TableField(fill = FieldFill.INSERT) |
|
||||
private String createBy; |
|
||||
|
|
||||
/** 更新时间 */ |
|
||||
@TableField(fill = FieldFill.UPDATE) |
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
|
||||
private LocalDateTime updateTime; |
|
||||
|
|
||||
/** 更新人 */ |
|
||||
@TableField(fill = FieldFill.UPDATE) |
|
||||
private String updateBy; |
|
||||
|
|
||||
/** 删除标识 */ |
|
||||
@JsonIgnore |
|
||||
private Boolean delFlag; |
|
||||
} |
|
||||
|
|
@ -1,18 +0,0 @@ |
|||||
package com.qs.serve.modules.sys.entity.dto; |
|
||||
|
|
||||
import lombok.Data; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
/** |
|
||||
* @author JcYen |
|
||||
* @date 2022/3/12 |
|
||||
*/ |
|
||||
@Data |
|
||||
public class SysRolePermitParam { |
|
||||
|
|
||||
String roleId; |
|
||||
|
|
||||
List<String> permitIds; |
|
||||
|
|
||||
} |
|
@ -1,63 +0,0 @@ |
|||||
package com.qs.serve.modules.sys.mapper; |
|
||||
|
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|
||||
import com.qs.serve.modules.sys.entity.SysPermit; |
|
||||
import com.qs.serve.modules.sys.entity.SysRolePermit; |
|
||||
import org.apache.ibatis.annotations.Select; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
/** |
|
||||
* 角色权限 Mapper |
|
||||
* @author YenHex |
|
||||
* @date 2022-03-01 |
|
||||
*/ |
|
||||
public interface SysRolePermitMapper extends BaseMapper<SysRolePermit> { |
|
||||
|
|
||||
/** |
|
||||
* 查询权限编码 |
|
||||
* @param roleIds |
|
||||
* @deprecated 新版使用菜单加载 listPermitCode2 |
|
||||
* @return |
|
||||
*/ |
|
||||
@Select("<script>" + |
|
||||
"select p.`id` , p.`code`" + |
|
||||
" from sys_role_permit rp" + |
|
||||
" LEFT JOIN sys_permit" + |
|
||||
" p on rp.permit_id = p.id" + |
|
||||
" where rp.del_flag=b'0' " + |
|
||||
" and rp.role_id in " + |
|
||||
" <foreach collection='roleIds' item='id' open='(' separator=',' close=')'> " + |
|
||||
" #{id} " + |
|
||||
" </foreach> " + |
|
||||
"</script>") |
|
||||
@Deprecated |
|
||||
List<SysPermit> listPermitCode(List<String> roleIds); |
|
||||
|
|
||||
|
|
||||
/** |
|
||||
* 查询权限编码 |
|
||||
* @param roleIds |
|
||||
* @return |
|
||||
*/ |
|
||||
@Select("<script>" + |
|
||||
"SELECT permit.id,permit.`code` " + |
|
||||
" FROM `sys_role_menu` rme" + |
|
||||
" LEFT JOIN `sys_menu_permit` mp" + |
|
||||
" ON rme.menu_id = mp.menu_id" + |
|
||||
" LEFT JOIN `sys_permit` permit" + |
|
||||
" ON mp.permit_id = permit.id" + |
|
||||
" WHERE rme.role_id IN " + |
|
||||
" <foreach collection='roleIds' item='id' open='(' separator=',' close=')'> " + |
|
||||
" #{id} " + |
|
||||
" </foreach> " + |
|
||||
" and rme.del_flag= b'0'" + |
|
||||
" and mp.del_flag= b'0'" + |
|
||||
" and permit.del_flag= b'0'" + |
|
||||
"</script>") |
|
||||
@InterceptorIgnore(tenantLine = "1") |
|
||||
List<SysPermit> listPermitCode2(List<String> roleIds); |
|
||||
|
|
||||
} |
|
||||
|
|
@ -1,21 +0,0 @@ |
|||||
package com.qs.serve.modules.sys.service; |
|
||||
|
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
|
||||
import com.qs.serve.modules.sys.entity.SysPermit; |
|
||||
import com.qs.serve.modules.sys.entity.SysRolePermit; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
/** |
|
||||
* 角色权限 服务接口 |
|
||||
* @author YenHex |
|
||||
* @date 2022-03-01 |
|
||||
*/ |
|
||||
public interface SysRolePermitService extends IService<SysRolePermit> { |
|
||||
|
|
||||
boolean removeByRoleId(String roleId); |
|
||||
|
|
||||
List<SysPermit> listByRoleId(String roleId); |
|
||||
|
|
||||
} |
|
||||
|
|
@ -1,53 +0,0 @@ |
|||||
package com.qs.serve.modules.sys.service.impl; |
|
||||
|
|
||||
import cn.hutool.core.collection.CollectionUtil; |
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
||||
import com.qs.serve.modules.sys.entity.SysPermit; |
|
||||
import com.qs.serve.modules.sys.entity.SysRolePermit; |
|
||||
import com.qs.serve.modules.sys.mapper.SysRolePermitMapper; |
|
||||
import com.qs.serve.modules.sys.service.SysPermitService; |
|
||||
import com.qs.serve.modules.sys.service.SysRolePermitService; |
|
||||
import lombok.AllArgsConstructor; |
|
||||
import lombok.extern.slf4j.Slf4j; |
|
||||
import org.springframework.stereotype.Service; |
|
||||
|
|
||||
import java.util.List; |
|
||||
import java.util.stream.Collectors; |
|
||||
|
|
||||
/** |
|
||||
* 角色权限 服务实现类 |
|
||||
* @author YenHex |
|
||||
* @since 2022-03-01 |
|
||||
*/ |
|
||||
@Slf4j |
|
||||
@Service |
|
||||
@AllArgsConstructor |
|
||||
public class SysRolePermitServiceImpl extends ServiceImpl<SysRolePermitMapper, SysRolePermit> implements SysRolePermitService { |
|
||||
|
|
||||
private final SysPermitService sysPermitService; |
|
||||
|
|
||||
@Override |
|
||||
public boolean removeByRoleId(String roleId) { |
|
||||
LambdaQueryWrapper<SysRolePermit> wrapper = new LambdaQueryWrapper<>(); |
|
||||
wrapper.eq(SysRolePermit::getRoleId,roleId); |
|
||||
remove(wrapper); |
|
||||
return true; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public List<SysPermit> listByRoleId(String roleId) { |
|
||||
LambdaQueryWrapper<SysRolePermit> wrapper = new LambdaQueryWrapper<>(); |
|
||||
wrapper.eq(SysRolePermit::getRoleId,roleId); |
|
||||
List<SysRolePermit> rolePermits = list(wrapper); |
|
||||
List<String> permitIds = rolePermits.stream().map(SysRolePermit::getPermitId).distinct().collect(Collectors.toList()); |
|
||||
if(CollectionUtil.isNotEmpty(permitIds)){ |
|
||||
LambdaQueryWrapper<SysPermit> wrapper2 = new LambdaQueryWrapper<>(); |
|
||||
wrapper2.in(SysPermit::getId,permitIds); |
|
||||
return sysPermitService.list(wrapper2); |
|
||||
} |
|
||||
return null; |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
|
|
Loading…
Reference in new issue