Commit d95d0696 authored by hongguangwu's avatar hongguangwu

1.5.8-hgw-权限-角色-账号

parent f5b2c1c5
package com.yifu.cloud.plus.v1.yifu.permission.vo;/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
import cn.hutool.core.lang.tree.Tree;
import com.yifu.cloud.plus.v1.yifu.permission.entity.SysRoleInfo;
import com.yifu.cloud.plus.v1.yifu.permission.entity.SysRoleMenuRes;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 角色新增vo
*
* @author hgw
* @date 2023-08-29 14:49:40
*/
@Data
public class SysRoleInfoSaveVo implements Serializable {
private SysRoleInfo role;
private List<SysRoleMenuRes> resList;
private List<Tree<String>> tree;
}
package com.yifu.cloud.plus.v1.yifu.permission.vo;
import com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserInfo;
import com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserRoleRes;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 账号新增vo
*
* @author hgw
* @date 2023-08-29 14:49:40
*/
@Data
public class SysUserInfoSaveVo implements Serializable {
private SysUserInfo user;
private List<SysUserRoleRes> resList;
private String dataAuth;
}
...@@ -3,20 +3,19 @@ package com.yifu.cloud.plus.v1.permission.controller; ...@@ -3,20 +3,19 @@ package com.yifu.cloud.plus.v1.permission.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.permission.service.SysRoleInfoService; import com.yifu.cloud.plus.v1.permission.service.SysRoleInfoService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage; import com.yifu.cloud.plus.v1.permission.service.SysUserRoleResService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog; import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.permission.entity.SysRoleInfo; import com.yifu.cloud.plus.v1.yifu.permission.entity.SysRoleInfo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSaveVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSearchVo; import com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSearchVo;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
...@@ -33,6 +32,7 @@ import java.util.List; ...@@ -33,6 +32,7 @@ import java.util.List;
public class SysRoleInfoController { public class SysRoleInfoController {
private final SysRoleInfoService sysRoleInfoService; private final SysRoleInfoService sysRoleInfoService;
private final SysUserRoleResService sysUserRoleResService;
/** /**
...@@ -70,22 +70,22 @@ public class SysRoleInfoController { ...@@ -70,22 +70,22 @@ public class SysRoleInfoController {
@Operation(summary = "通过id查询", description = "通过id查询:hasPermission('ekp_sysroleinfo_get')") @Operation(summary = "通过id查询", description = "通过id查询:hasPermission('ekp_sysroleinfo_get')")
@GetMapping("/{fdId}") @GetMapping("/{fdId}")
@PreAuthorize("@pms.hasPermission('ekp_sysroleinfo_get')") @PreAuthorize("@pms.hasPermission('ekp_sysroleinfo_get')")
public R<SysRoleInfo> getById(@PathVariable("fdId") String fdId) { public R<SysRoleInfoSaveVo> getById(@PathVariable("fdId") String fdId) {
return R.ok(sysRoleInfoService.getById(fdId)); return sysRoleInfoService.getInfoById(fdId);
} }
/** /**
* 新增新权限-角色表 * 新增新权限-角色表
* *
* @param sysRoleInfo 新权限-角色表 * @param vo 新权限-角色表
* @return R * @return R
*/ */
@Operation(summary = "新增新权限-角色表", description = "新增新权限-角色表:hasPermission('ekp_sysroleinfo_add')") @Operation(summary = "新增或编辑新权限-角色表", description = "新增或保存新权限-角色表:hasPermission('ekp_sysroleinfo_add')")
@SysLog("新增新权限-角色表") @SysLog("新增或编辑新权限-角色表")
@PostMapping @PostMapping
@PreAuthorize("@pms.hasPermission('ekp_sysroleinfo_add')") @PreAuthorize("@pms.hasPermission('ekp_sysroleinfo_add')")
public R<Boolean> save(@RequestBody SysRoleInfo sysRoleInfo) { public R<String> saveOrUpdateRoleInfo(@RequestBody SysRoleInfoSaveVo vo) {
return R.ok(sysRoleInfoService.save(sysRoleInfo)); return sysRoleInfoService.saveOrUpdateRoleInfo(vo);
} }
/** /**
...@@ -94,7 +94,7 @@ public class SysRoleInfoController { ...@@ -94,7 +94,7 @@ public class SysRoleInfoController {
* @param sysRoleInfo 新权限-角色表 * @param sysRoleInfo 新权限-角色表
* @return R * @return R
*/ */
@Operation(summary = "修改新权限-角色表", description = "修改新权限-角色表:hasPermission('ekp_sysroleinfo_edit')") @Operation(summary = "修改新权限-角色表(可以修改状态)", description = "修改新权限-角色表:hasPermission('ekp_sysroleinfo_edit')")
@SysLog("修改新权限-角色表") @SysLog("修改新权限-角色表")
@PutMapping @PutMapping
@PreAuthorize("@pms.hasPermission('ekp_sysroleinfo_edit')") @PreAuthorize("@pms.hasPermission('ekp_sysroleinfo_edit')")
...@@ -108,39 +108,38 @@ public class SysRoleInfoController { ...@@ -108,39 +108,38 @@ public class SysRoleInfoController {
* @param fdId id * @param fdId id
* @return R * @return R
*/ */
@Operation(summary = "通过id删除新权限-角色表", description = "通过id删除新权限-角色表:hasPermission('ekp_sysroleinfo_del')") @Operation(summary = "通过id删除新权限-角色表-假删除", description = "通过id删除新权限-角色表:hasPermission('ekp_sysroleinfo_del')")
@SysLog("通过id删除新权限-角色表") @SysLog("通过id删除新权限-角色表")
@DeleteMapping("/{fdId}") @DeleteMapping("/{fdId}")
@PreAuthorize("@pms.hasPermission('ekp_sysroleinfo_del')") @PreAuthorize("@pms.hasPermission('ekp_sysroleinfo_del')")
public R<Boolean> removeById(@PathVariable String fdId) { public R<Boolean> removeById(@PathVariable String fdId) {
return R.ok(sysRoleInfoService.removeById(fdId)); // 删除关联表
sysUserRoleResService.deleteByRoleId(fdId);
// 假删除角色表
SysRoleInfo roleInfo = sysRoleInfoService.getById(fdId);
roleInfo.setDeleteFlag(CommonConstants.ONE_INT);
sysRoleInfoService.updateById(roleInfo);
return R.ok();
} }
/** /**
* 新权限-角色表 批量导入 * 通过id删除新权限-角色表
* *
* @author hgw * @param fdId id
* @date 2023-08-29 14:49:40 * @return R
**/ */
@SneakyThrows @Operation(summary = "冻结-角色表", description = "冻结-角色表:hasPermission('ekp_sysroleinfo_freeze')")
@Operation(description = "批量新增新权限-角色表 hasPermission('ekp_sysroleinfo-batch-import')") @SysLog("冻结-角色表")
@SysLog("批量新增新权限-角色表") @PostMapping("/freezeById")
@PostMapping("/importListAdd") @PreAuthorize("@pms.hasPermission('ekp_sysroleinfo_freeze')")
@PreAuthorize("@pms.hasPermission('ekp_sysroleinfo-batch-import')") public R<Boolean> freezeById(@RequestParam String fdId) {
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file) { // 删除关联表
return sysRoleInfoService.importDiy(file.getInputStream()); sysUserRoleResService.deleteByRoleId(fdId);
// 冻结角色表
SysRoleInfo roleInfo = sysRoleInfoService.getById(fdId);
roleInfo.setStatus(CommonConstants.ONE_INT);
sysRoleInfoService.updateById(roleInfo);
return R.ok();
} }
/**
* 新权限-角色表 批量导出
*
* @author hgw
* @date 2023-08-29 14:49:40
**/
@Operation(description = "导出新权限-角色表 hasPermission('ekp_sysroleinfo-export')")
@PostMapping("/export")
@PreAuthorize("@pms.hasPermission('ekp_sysroleinfo-export')")
public void export(HttpServletResponse response, @RequestBody SysRoleInfoSearchVo searchVo) {
sysRoleInfoService.listExport(response, searchVo);
}
} }
...@@ -6,6 +6,7 @@ import com.yifu.cloud.plus.v1.permission.service.SysUserInfoService; ...@@ -6,6 +6,7 @@ import com.yifu.cloud.plus.v1.permission.service.SysUserInfoService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog; import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserInfo; import com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserInfo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserInfoSaveVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserInfoSearchVo; import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserInfoSearchVo;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
...@@ -67,22 +68,22 @@ public class SysUserInfoController { ...@@ -67,22 +68,22 @@ public class SysUserInfoController {
@Operation(summary = "通过id查询", description = "通过id查询:hasPermission('ekp_sysuserinfo_get')") @Operation(summary = "通过id查询", description = "通过id查询:hasPermission('ekp_sysuserinfo_get')")
@GetMapping("/{fdId}") @GetMapping("/{fdId}")
@PreAuthorize("@pms.hasPermission('ekp_sysuserinfo_get')") @PreAuthorize("@pms.hasPermission('ekp_sysuserinfo_get')")
public R<SysUserInfo> getById(@PathVariable("fdId") String fdId) { public R<SysUserInfoSaveVo> getById(@PathVariable("fdId") String fdId) {
return R.ok(sysUserInfoService.getById(fdId)); return sysUserInfoService.getInfoById(fdId);
} }
/** /**
* 新增新权限-账号管理表 * 新增新权限-账号管理表
* *
* @param sysUserInfo 新权限-账号管理表 * @param vo 新权限-账号管理表
* @return R * @return R
*/ */
@Operation(summary = "新增新权限-账号管理表", description = "新增新权限-账号管理表:hasPermission('ekp_sysuserinfo_add')") @Operation(summary = "新增或编辑新权限-账号管理表", description = "新增或编辑新权限-账号管理表:hasPermission('ekp_sysuserinfo_add')")
@SysLog("新增新权限-账号管理表") @SysLog("新增或编辑新权限-账号管理表")
@PostMapping @PostMapping
@PreAuthorize("@pms.hasPermission('ekp_sysuserinfo_add')") @PreAuthorize("@pms.hasPermission('ekp_sysuserinfo_add')")
public R<Boolean> save(@RequestBody SysUserInfo sysUserInfo) { public R<String> saveOrUpdateUserInfo(@RequestBody SysUserInfoSaveVo vo) {
return R.ok(sysUserInfoService.save(sysUserInfo)); return sysUserInfoService.saveOrUpdateUserInfo(vo);
} }
/** /**
...@@ -113,16 +114,4 @@ public class SysUserInfoController { ...@@ -113,16 +114,4 @@ public class SysUserInfoController {
return R.ok(sysUserInfoService.removeById(fdId)); return R.ok(sysUserInfoService.removeById(fdId));
} }
/**
* 新权限-账号管理表 批量导出
*
* @author hgw
* @date 2023-08-29 14:49:40
**/
@Operation(description = "导出新权限-账号管理表 hasPermission('ekp_sysuserinfo-export')")
@PostMapping("/export")
@PreAuthorize("@pms.hasPermission('ekp_sysuserinfo-export')")
public void export(HttpServletResponse response, @RequestBody SysUserInfoSearchVo searchVo) {
sysUserInfoService.listExport(response, searchVo);
}
} }
...@@ -23,6 +23,8 @@ import com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSearchVo; ...@@ -23,6 +23,8 @@ import com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSearchVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 新权限-角色表 * 新权限-角色表
* *
...@@ -38,4 +40,9 @@ public interface SysRoleInfoMapper extends BaseMapper<SysRoleInfo> { ...@@ -38,4 +40,9 @@ public interface SysRoleInfoMapper extends BaseMapper<SysRoleInfo> {
* @return * @return
*/ */
IPage<SysRoleInfo> getSysRoleInfoPage(Page<SysRoleInfo> page, @Param("sysRoleInfo") SysRoleInfoSearchVo sysRoleInfo); IPage<SysRoleInfo> getSysRoleInfoPage(Page<SysRoleInfo> page, @Param("sysRoleInfo") SysRoleInfoSearchVo sysRoleInfo);
List<String> getAllRoleDataAuthByUserId(@Param("userId") String userId);
int checkExistenceRole(@Param("roleName") String roleName, @Param("roleId") String roleId);
} }
...@@ -37,4 +37,13 @@ public interface SysRoleMenuResMapper extends BaseMapper<SysRoleMenuRes> { ...@@ -37,4 +37,13 @@ public interface SysRoleMenuResMapper extends BaseMapper<SysRoleMenuRes> {
* @return * @return
*/ */
IPage<SysRoleMenuRes> getSysRoleMenuResPage(Page<SysRoleMenuRes> page, @Param("sysRoleMenuRes") SysRoleMenuRes sysRoleMenuRes); IPage<SysRoleMenuRes> getSysRoleMenuResPage(Page<SysRoleMenuRes> page, @Param("sysRoleMenuRes") SysRoleMenuRes sysRoleMenuRes);
/**
* @param roleId
* @Description: 根据角色删除关联表
* @Author: hgw
* @Date: 2023/8/30 15:19
* @return: boolean
**/
boolean deleteByRoleId(@Param("roleId") String roleId);
} }
...@@ -37,4 +37,8 @@ public interface SysUserRoleResMapper extends BaseMapper<SysUserRoleRes> { ...@@ -37,4 +37,8 @@ public interface SysUserRoleResMapper extends BaseMapper<SysUserRoleRes> {
* @return * @return
*/ */
IPage<SysUserRoleRes> getSysUserRoleResPage(Page<SysUserRoleRes> page, @Param("sysUserRoleRes") SysUserRoleRes sysUserRoleRes); IPage<SysUserRoleRes> getSysUserRoleResPage(Page<SysUserRoleRes> page, @Param("sysUserRoleRes") SysUserRoleRes sysUserRoleRes);
boolean deleteByUserId(@Param("userId") String userId);
boolean deleteByRoleId(@Param("roleId") String roleId);
} }
...@@ -18,13 +18,11 @@ package com.yifu.cloud.plus.v1.permission.service;/* ...@@ -18,13 +18,11 @@ package com.yifu.cloud.plus.v1.permission.service;/*
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.permission.entity.SysRoleInfo; import com.yifu.cloud.plus.v1.yifu.permission.entity.SysRoleInfo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSaveVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSearchVo; import com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSearchVo;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List; import java.util.List;
/** /**
...@@ -42,9 +40,33 @@ public interface SysRoleInfoService extends IService<SysRoleInfo> { ...@@ -42,9 +40,33 @@ public interface SysRoleInfoService extends IService<SysRoleInfo> {
*/ */
IPage<SysRoleInfo> getSysRoleInfoPage(Page<SysRoleInfo> page, SysRoleInfoSearchVo sysRoleInfo); IPage<SysRoleInfo> getSysRoleInfoPage(Page<SysRoleInfo> page, SysRoleInfoSearchVo sysRoleInfo);
R<List<ErrorMessage>> importDiy(InputStream inputStream); /**
* @param fdId
* @Description: 查看
* @Author: hgw
* @Date: 2023/8/30 15:10
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSaveVo>
**/
R<SysRoleInfoSaveVo> getInfoById(String fdId);
void listExport(HttpServletResponse response, SysRoleInfoSearchVo searchVo); /**
* @param vo
* @Description: 新增或编辑新权限-角色表
* @Author: hgw
* @Date: 2023/8/30 15:10
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.Boolean>
**/
R<String> saveOrUpdateRoleInfo(SysRoleInfoSaveVo vo);
List<SysRoleInfo> noPageDiy(SysRoleInfoSearchVo searchVo); List<SysRoleInfo> noPageDiy(SysRoleInfoSearchVo searchVo);
/**
* @param userId
* @Description: 各种角色的权限融合
* @Author: hgw
* @Date: 2023/8/30 18:06
* @return: java.lang.String
**/
String getAllRoleDataAuthByUserId(String userId);
} }
...@@ -39,4 +39,14 @@ public interface SysRoleMenuResService extends IService<SysRoleMenuRes> { ...@@ -39,4 +39,14 @@ public interface SysRoleMenuResService extends IService<SysRoleMenuRes> {
IPage<SysRoleMenuRes> getSysRoleMenuResPage(Page<SysRoleMenuRes> page, SysRoleMenuResSearchVo sysRoleMenuRes); IPage<SysRoleMenuRes> getSysRoleMenuResPage(Page<SysRoleMenuRes> page, SysRoleMenuResSearchVo sysRoleMenuRes);
List<SysRoleMenuRes> noPageDiy(SysRoleMenuResSearchVo searchVo); List<SysRoleMenuRes> noPageDiy(SysRoleMenuResSearchVo searchVo);
/**
* @param roleId
* @Description: 根据角色删除关联表
* @Author: hgw
* @Date: 2023/8/30 15:19
* @return: boolean
**/
boolean deleteByRoleId(String roleId);
} }
...@@ -18,13 +18,12 @@ package com.yifu.cloud.plus.v1.permission.service;/* ...@@ -18,13 +18,12 @@ package com.yifu.cloud.plus.v1.permission.service;/*
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserInfo; import com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserInfo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSaveVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserInfoSaveVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserInfoSearchVo; import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserInfoSearchVo;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List; import java.util.List;
/** /**
...@@ -42,9 +41,23 @@ public interface SysUserInfoService extends IService<SysUserInfo> { ...@@ -42,9 +41,23 @@ public interface SysUserInfoService extends IService<SysUserInfo> {
*/ */
IPage<SysUserInfo> getSysUserInfoPage(Page<SysUserInfo> page, SysUserInfoSearchVo sysUserInfo); IPage<SysUserInfo> getSysUserInfoPage(Page<SysUserInfo> page, SysUserInfoSearchVo sysUserInfo);
R<List<ErrorMessage>> importDiy(InputStream inputStream); List<SysUserInfo> noPageDiy(SysUserInfoSearchVo searchVo);
void listExport(HttpServletResponse response, SysUserInfoSearchVo searchVo); /**
* @param fdId
* @Description: 查看
* @Author: hgw
* @Date: 2023/8/30 15:10
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserInfoSaveVo>
**/
R<SysUserInfoSaveVo> getInfoById(String fdId);
List<SysUserInfo> noPageDiy(SysUserInfoSearchVo searchVo); /**
* @param vo
* @Description: 新增或编辑新权限-账号表
* @Author: hgw
* @Date: 2023/8/30 15:10
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.Boolean>
**/
R<String> saveOrUpdateUserInfo(SysUserInfoSaveVo vo);
} }
package com.yifu.cloud.plus.v1.permission.service;/* package com.yifu.cloud.plus.v1.permission.service;
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -39,4 +24,23 @@ public interface SysUserRoleResService extends IService<SysUserRoleRes> { ...@@ -39,4 +24,23 @@ public interface SysUserRoleResService extends IService<SysUserRoleRes> {
IPage<SysUserRoleRes> getSysUserRoleResPage(Page<SysUserRoleRes> page, SysUserRoleResSearchVo sysUserRoleRes); IPage<SysUserRoleRes> getSysUserRoleResPage(Page<SysUserRoleRes> page, SysUserRoleResSearchVo sysUserRoleRes);
List<SysUserRoleRes> noPageDiy(SysUserRoleResSearchVo searchVo); List<SysUserRoleRes> noPageDiy(SysUserRoleResSearchVo searchVo);
/**
* @param userId
* @Description: 根据账号删除关联表
* @Author: hgw
* @Date: 2023/8/30 15:45
* @return: boolean
**/
boolean deleteByUserId(String userId);
/**
* @param roleId
* @Description: 根据角色删除关联表
* @Author: hgw
* @Date: 2023/8/30 15:45
* @return: boolean
**/
boolean deleteByRoleId(String roleId);
} }
...@@ -66,6 +66,18 @@ public class SysRoleMenuResServiceImpl extends ServiceImpl<SysRoleMenuResMapper, ...@@ -66,6 +66,18 @@ public class SysRoleMenuResServiceImpl extends ServiceImpl<SysRoleMenuResMapper,
return baseMapper.selectList(wrapper); return baseMapper.selectList(wrapper);
} }
/**
* @param roleId
* @Description: 根据角色删除关联表
* @Author: hgw
* @Date: 2023/8/30 15:19
* @return: boolean
**/
@Override
public boolean deleteByRoleId(String roleId) {
return baseMapper.deleteByRoleId(roleId);
}
private LambdaQueryWrapper buildQueryWrapper(SysRoleMenuResSearchVo entity) { private LambdaQueryWrapper buildQueryWrapper(SysRoleMenuResSearchVo entity) {
LambdaQueryWrapper<SysRoleMenuRes> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<SysRoleMenuRes> wrapper = Wrappers.lambdaQuery();
if (ArrayUtil.isNotEmpty(entity.getCreateTimes())) { if (ArrayUtil.isNotEmpty(entity.getCreateTimes())) {
......
...@@ -66,6 +66,16 @@ public class SysUserRoleResServiceImpl extends ServiceImpl<SysUserRoleResMapper, ...@@ -66,6 +66,16 @@ public class SysUserRoleResServiceImpl extends ServiceImpl<SysUserRoleResMapper,
return baseMapper.selectList(wrapper); return baseMapper.selectList(wrapper);
} }
@Override
public boolean deleteByUserId(String userId) {
return baseMapper.deleteByUserId(userId);
}
@Override
public boolean deleteByRoleId(String roleId) {
return baseMapper.deleteByRoleId(roleId);
}
private LambdaQueryWrapper buildQueryWrapper(SysUserRoleResSearchVo entity) { private LambdaQueryWrapper buildQueryWrapper(SysUserRoleResSearchVo entity) {
LambdaQueryWrapper<SysUserRoleRes> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<SysUserRoleRes> wrapper = Wrappers.lambdaQuery();
if (ArrayUtil.isNotEmpty(entity.getCreateTimes())) { if (ArrayUtil.isNotEmpty(entity.getCreateTimes())) {
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
AND a.fd_id = #{sysRoleInfo.fdId} AND a.fd_id = #{sysRoleInfo.fdId}
</if> </if>
<if test="sysRoleInfo.roleName != null and sysRoleInfo.roleName.trim() != ''"> <if test="sysRoleInfo.roleName != null and sysRoleInfo.roleName.trim() != ''">
AND a.role_name = #{sysRoleInfo.roleName} AND a.role_name like concat('%',#{sysRoleInfo.roleName},'%')
</if> </if>
<if test="sysRoleInfo.remark != null and sysRoleInfo.remark.trim() != ''"> <if test="sysRoleInfo.remark != null and sysRoleInfo.remark.trim() != ''">
AND a.remark = #{sysRoleInfo.remark} AND a.remark = #{sysRoleInfo.remark}
...@@ -98,8 +98,30 @@ ...@@ -98,8 +98,30 @@
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
FROM sys_role_info a FROM sys_role_info a
<where> <where>
1=1 a.delete_flag = 0
<include refid="sysRoleInfo_where"/> <include refid="sysRoleInfo_where"/>
</where> </where>
order by a.CREATE_TIME desc
</select> </select>
<!-- 根据用户Id获取所有的角色的权限-->
<select id="getAllRoleDataAuthByUserId" resultType="java.lang.String">
SELECT
a.data_auth
FROM sys_role_info a
left join sys_user_role_res r on r.role_id = a.fd_id
where a.delete_flag = 0 and r.user_id = #{userId}
</select>
<!-- 查找名称是否存在-->
<select id="checkExistenceRole" resultType="java.lang.Integer">
SELECT
count(1)
FROM sys_role_info a
where a.delete_flag = 0 and a.role_name = #{roleName}
<if test="roleId != null and roleId.trim() != ''">
AND a.fd_id != #{roleId}
</if>
</select>
</mapper> </mapper>
...@@ -56,4 +56,10 @@ ...@@ -56,4 +56,10 @@
<include refid="sysRoleMenuRes_where"/> <include refid="sysRoleMenuRes_where"/>
</where> </where>
</select> </select>
<!-- 根据角色删除关联表 -->
<delete id="deleteByRoleId">
delete from sys_role_menu_res where role_id = #{roleId}
</delete>
</mapper> </mapper>
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
AND a.fd_id = #{sysUserInfo.fdId} AND a.fd_id = #{sysUserInfo.fdId}
</if> </if>
<if test="sysUserInfo.fdName != null and sysUserInfo.fdName.trim() != ''"> <if test="sysUserInfo.fdName != null and sysUserInfo.fdName.trim() != ''">
AND a.fd_name = #{sysUserInfo.fdName} AND a.fd_name like concat('%',#{sysUserInfo.fdName},'%')
</if> </if>
<if test="sysUserInfo.fdLoginName != null and sysUserInfo.fdLoginName.trim() != ''"> <if test="sysUserInfo.fdLoginName != null and sysUserInfo.fdLoginName.trim() != ''">
AND a.fd_login_name = #{sysUserInfo.fdLoginName} AND a.fd_login_name = #{sysUserInfo.fdLoginName}
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
AND a.fd_ldap_dn = #{sysUserInfo.fdLdapDn} AND a.fd_ldap_dn = #{sysUserInfo.fdLdapDn}
</if> </if>
<if test="sysUserInfo.fdDeptName != null and sysUserInfo.fdDeptName.trim() != ''"> <if test="sysUserInfo.fdDeptName != null and sysUserInfo.fdDeptName.trim() != ''">
AND a.fd_dept_name = #{sysUserInfo.fdDeptName} AND a.fd_dept_name like concat('%',#{sysUserInfo.fdDeptName},'%')
</if> </if>
<if test="sysUserInfo.fdMobileNo != null and sysUserInfo.fdMobileNo.trim() != ''"> <if test="sysUserInfo.fdMobileNo != null and sysUserInfo.fdMobileNo.trim() != ''">
AND a.fd_mobile_no = #{sysUserInfo.fdMobileNo} AND a.fd_mobile_no = #{sysUserInfo.fdMobileNo}
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
AND a.status = #{sysUserInfo.status} AND a.status = #{sysUserInfo.status}
</if> </if>
<if test="sysUserInfo.roleNames != null and sysUserInfo.roleNames.trim() != ''"> <if test="sysUserInfo.roleNames != null and sysUserInfo.roleNames.trim() != ''">
AND a.role_names = #{sysUserInfo.roleNames} AND a.role_names like concat('%',#{sysUserInfo.roleNames},'%')
</if> </if>
<if test="sysUserInfo.createBy != null and sysUserInfo.createBy.trim() != ''"> <if test="sysUserInfo.createBy != null and sysUserInfo.createBy.trim() != ''">
AND a.CREATE_BY = #{sysUserInfo.createBy} AND a.CREATE_BY = #{sysUserInfo.createBy}
...@@ -110,5 +110,6 @@ ...@@ -110,5 +110,6 @@
1=1 1=1
<include refid="sysUserInfo_where"/> <include refid="sysUserInfo_where"/>
</where> </where>
order by a.CREATE_TIME desc
</select> </select>
</mapper> </mapper>
...@@ -56,4 +56,15 @@ ...@@ -56,4 +56,15 @@
<include refid="sysUserRoleRes_where"/> <include refid="sysUserRoleRes_where"/>
</where> </where>
</select> </select>
<!-- 根据账号删除关联表 -->
<delete id="deleteByUserId">
delete from sys_user_role_res where user_id = #{userId}
</delete>
<!-- 根据角色删除关联表 -->
<delete id="deleteByRoleId">
delete from sys_user_role_res where role_id = #{roleId}
</delete>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment