Merge branch 'main' of https://git.jsspisoft.com/ry-das
This commit is contained in:
commit
43c063f63f
8
das/src/main/java/com/das/common/config/SessionUtil.java
Normal file
8
das/src/main/java/com/das/common/config/SessionUtil.java
Normal file
@ -0,0 +1,8 @@
|
||||
package com.das.common.config;
|
||||
|
||||
/**
|
||||
* Session 变量定义
|
||||
*/
|
||||
public class SessionUtil {
|
||||
public static final String SESSION_USER_KEY = "current_user";
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.das.common.config;
|
||||
|
||||
import cn.dev33.satoken.stp.StpInterface;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.das.modules.auth.domain.vo.SysUserVo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自定义权限验证接口扩展
|
||||
*/
|
||||
@Component // 保证此类被springboot扫描,完成sa-token的自定义权限验证扩展
|
||||
public class StpInterfaceImpl implements StpInterface {
|
||||
@Override
|
||||
public List<String> getPermissionList(Object loginId, String s) {
|
||||
SysUserVo currentUser = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||
if(currentUser==null){
|
||||
return Collections.emptyList();
|
||||
}else{
|
||||
List<String> list = new ArrayList<>();
|
||||
currentUser.getAuthorities().forEach(item->{
|
||||
list.add(item.toString());
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限判断这块 全部采用权限Permission 判断,不采用角色Role判断
|
||||
* @param loginId
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<String> getRoleList(Object loginId, String s) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
@ -26,12 +26,6 @@ public class RedisConfig {
|
||||
|
||||
// 使用Jackson2JsonRedisSerialize 替换默认序列化
|
||||
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
|
||||
// FastJson2RedisSerializer<Object> fastJsonRedisSerializer = new FastJson2RedisSerializer<>(Object.class);
|
||||
// GenericJackson2JsonRedisSerializer genericJackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
|
||||
|
||||
// ObjectMapper objectMapper = new ObjectMapper();
|
||||
// objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
// jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
|
||||
|
||||
// 设置key和value的序列化规则
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
|
@ -4,12 +4,15 @@ package com.das.common.exceptions;
|
||||
import com.das.common.result.IResultCode;
|
||||
import com.das.common.result.ResultCode;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* @author chenhaojie
|
||||
* @Description oss存储服务异常
|
||||
*/
|
||||
public class OssException extends RuntimeException {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int code = ResultCode.FAILURE.getCode();
|
||||
|
@ -3,13 +3,18 @@ package com.das.common.exceptions;
|
||||
|
||||
import com.das.common.result.IResultCode;
|
||||
import com.das.common.result.ResultCode;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* @author chenhaojie
|
||||
* @Description 频率限制异常
|
||||
*/
|
||||
@Getter
|
||||
public class RateLimiterException extends RuntimeException {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int code = ResultCode.FAILURE.getCode();
|
||||
@ -46,18 +51,10 @@ public class RateLimiterException extends RuntimeException {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
@ -3,13 +3,18 @@ package com.das.common.exceptions;
|
||||
|
||||
import com.das.common.result.IResultCode;
|
||||
import com.das.common.result.ResultCode;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* @author chenhaojie
|
||||
* @Description 频率限制异常
|
||||
*/
|
||||
@Getter
|
||||
public class RepeatSubmitException extends RuntimeException {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int code = ResultCode.FAILURE.getCode();
|
||||
@ -46,18 +51,10 @@ public class RepeatSubmitException extends RuntimeException {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
@ -104,9 +104,6 @@ public class GlobalExceptionHandler {
|
||||
if (exception instanceof MethodArgumentNotValidException e){
|
||||
bindingResult = e.getBindingResult();
|
||||
if (bindingResult.hasErrors()) {
|
||||
// String collect = bindingResult.getAllErrors().stream()
|
||||
// .map(ObjectError::getDefaultMessage)
|
||||
// .collect(Collectors.joining(";"));
|
||||
FieldError fieldError = bindingResult.getFieldError();
|
||||
if (fieldError != null) {
|
||||
return R.fail(fieldError.getField()+ ":" + fieldError.getDefaultMessage());
|
||||
@ -120,9 +117,6 @@ public class GlobalExceptionHandler {
|
||||
}else if (exception instanceof BindException e){
|
||||
bindingResult = e.getBindingResult();
|
||||
if (bindingResult.hasErrors()) {
|
||||
// String collect = bindingResult.getAllErrors().stream()
|
||||
// .map(ObjectError::getDefaultMessage)
|
||||
// .collect(Collectors.joining(";"));
|
||||
FieldError fieldError = bindingResult.getFieldError();
|
||||
if (fieldError != null) {
|
||||
return R.fail(fieldError.getField()+ ":" + fieldError.getDefaultMessage());
|
||||
@ -151,21 +145,10 @@ public class GlobalExceptionHandler {
|
||||
return R.fail(message);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 捕获授权异常 403
|
||||
// **/
|
||||
// @ExceptionHandler(value = AccessDeniedException.class)
|
||||
// @ResponseStatus(HttpStatus.FORBIDDEN)
|
||||
// public R handlerAccessDeniedException(AccessDeniedException exception) {
|
||||
// String message = exception.getMessage();
|
||||
// log.error("全局捕获授权错误信息,{}", message ,exception);
|
||||
// return R.fail(HttpStatus.FORBIDDEN.value(),"权限不足");
|
||||
// }
|
||||
|
||||
/**
|
||||
* 捕获 404 异常
|
||||
* @param exception
|
||||
* @return
|
||||
* @param exception 异常
|
||||
* @return R
|
||||
*/
|
||||
@ExceptionHandler({NoHandlerFoundException.class, HttpRequestMethodNotSupportedException.class})
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
|
@ -1,15 +1,21 @@
|
||||
package com.das.modules.auth.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.das.common.config.SessionUtil;
|
||||
import com.das.common.config.SysAuthorityIds;
|
||||
import com.das.common.result.R;
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
import com.das.common.utils.PageQuery;
|
||||
import com.das.modules.auth.domain.dto.DeleteDto;
|
||||
import com.das.modules.auth.domain.dto.SysMenuDto;
|
||||
import com.das.modules.auth.domain.dto.SysMenuQueryDto;
|
||||
import com.das.modules.auth.domain.vo.SysUserVo;
|
||||
import com.das.modules.auth.entity.SysMenu;
|
||||
import com.das.modules.auth.service.SysMenuService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -32,6 +38,12 @@ public class SysMenusController {
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public R<?> createMenu(@RequestBody SysMenuDto sysMenuDto) {
|
||||
|
||||
//判断是否有权限
|
||||
// boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN.toString());
|
||||
// if(!hasPermission){
|
||||
// return R.fail("没有系统管理权限");
|
||||
// }
|
||||
return R.success(sysMenuService.createMenu(sysMenuDto));
|
||||
}
|
||||
|
||||
@ -41,6 +53,12 @@ public class SysMenusController {
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public R<?> updateMenu(@RequestBody SysMenuDto sysMenuDto) {
|
||||
//判断是否有权限
|
||||
// boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN.toString());
|
||||
// if(!hasPermission){
|
||||
// return R.fail("没有系统管理权限");
|
||||
// }
|
||||
|
||||
sysMenuService.updateMenu(sysMenuDto);
|
||||
return R.success();
|
||||
}
|
||||
@ -51,6 +69,12 @@ public class SysMenusController {
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public R<?> deleteMenu(@RequestBody DeleteDto deleteDto) {
|
||||
//判断是否有权限
|
||||
// boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN.toString());
|
||||
// if(!hasPermission){
|
||||
// return R.fail("没有系统管理权限");
|
||||
// }
|
||||
|
||||
sysMenuService.deleteMenu(deleteDto);
|
||||
return R.success();
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.das.modules.auth.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.das.common.config.SysAuthorityIds;
|
||||
import com.das.common.result.R;
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
import com.das.common.utils.PageQuery;
|
||||
@ -32,6 +34,12 @@ public class SysOrgController {
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public R<?> createOrg(@RequestBody SysOrgDto sysOrgDto) {
|
||||
//判断是否有权限
|
||||
// boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN.toString());
|
||||
// if(!hasPermission){
|
||||
// return R.fail("没有系统管理权限");
|
||||
// }
|
||||
|
||||
return R.success(sysOrgService.createOrg(sysOrgDto));
|
||||
}
|
||||
|
||||
@ -41,6 +49,12 @@ public class SysOrgController {
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public R<?> updateOrg(@RequestBody SysOrgDto sysOrgDto) {
|
||||
//判断是否有权限
|
||||
// boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN.toString());
|
||||
// if(!hasPermission){
|
||||
// return R.fail("没有系统管理权限");
|
||||
// }
|
||||
|
||||
sysOrgService.updateOrg(sysOrgDto);
|
||||
return R.success();
|
||||
}
|
||||
@ -51,6 +65,12 @@ public class SysOrgController {
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public R<?> deleteOrg(@RequestBody DeleteDto deleteDto) {
|
||||
//判断是否有权限
|
||||
// boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN.toString());
|
||||
// if(!hasPermission){
|
||||
// return R.fail("没有系统管理权限");
|
||||
// }
|
||||
|
||||
sysOrgService.deleteOrg(deleteDto);
|
||||
return R.success();
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
package com.das.modules.auth.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.das.common.config.SysAuthorityIds;
|
||||
import com.das.common.result.R;
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
import com.das.common.utils.PageQuery;
|
||||
import com.das.modules.auth.domain.dto.*;
|
||||
import com.das.modules.auth.domain.vo.SysRoleVo;
|
||||
import com.das.modules.auth.entity.SysRole;
|
||||
import com.das.modules.auth.service.SysRoleService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -31,6 +34,12 @@ public class SysRoleController {
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public R<?> createRole(@RequestBody SysRoleDto sysRoleDto) {
|
||||
//判断是否有权限
|
||||
// boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN.toString());
|
||||
// if(!hasPermission){
|
||||
// return R.fail("没有系统管理权限");
|
||||
// }
|
||||
|
||||
return R.success(sysRoleService.createRole(sysRoleDto));
|
||||
}
|
||||
|
||||
@ -40,6 +49,12 @@ public class SysRoleController {
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public R<?> updateRole(@RequestBody SysRoleDto sysRoleDto) {
|
||||
//判断是否有权限
|
||||
// boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN.toString());
|
||||
// if(!hasPermission){
|
||||
// return R.fail("没有系统管理权限");
|
||||
// }
|
||||
|
||||
return R.success(sysRoleService.updateRole(sysRoleDto));
|
||||
}
|
||||
|
||||
@ -49,12 +64,18 @@ public class SysRoleController {
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public R<?> deleteRole(@RequestBody DeleteDto deleteDto) {
|
||||
//判断是否有权限
|
||||
// boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN.toString());
|
||||
// if(!hasPermission){
|
||||
// return R.fail("没有系统管理权限");
|
||||
// }
|
||||
|
||||
sysRoleService.deleteRole(deleteDto);
|
||||
return R.success();
|
||||
}
|
||||
|
||||
@PostMapping("/query")
|
||||
public PageDataInfo<SysRole> queryRoleList(@RequestBody SysRoleQueryDto sysRoleQueryDto, PageQuery pageQuery) {
|
||||
public PageDataInfo<SysRoleVo> queryRoleList(@RequestBody SysRoleQueryDto sysRoleQueryDto, PageQuery pageQuery) {
|
||||
return sysRoleService.queryRoleList(sysRoleQueryDto, pageQuery);
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,14 @@
|
||||
package com.das.modules.auth.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.das.common.config.SysAuthorityIds;
|
||||
import com.das.common.result.R;
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
import com.das.common.utils.PageQuery;
|
||||
import com.das.modules.auth.domain.dto.DeleteDto;
|
||||
import com.das.modules.auth.domain.dto.SysUserDto;
|
||||
import com.das.modules.auth.domain.dto.SysUserQueryDto;
|
||||
import com.das.modules.auth.domain.vo.SysUserVo;
|
||||
import com.das.modules.auth.entity.SysUser;
|
||||
import com.das.modules.auth.service.SysUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -32,6 +35,12 @@ public class SysUserController {
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public R<?> createUser(@RequestBody SysUserDto sysUserDto) {
|
||||
//判断是否有权限
|
||||
// boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN.toString());
|
||||
// if(!hasPermission){
|
||||
// return R.fail("没有系统管理权限");
|
||||
// }
|
||||
|
||||
return R.success(sysUserService.createUser(sysUserDto));
|
||||
}
|
||||
|
||||
@ -41,6 +50,12 @@ public class SysUserController {
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public R<?> updateUser(@RequestBody SysUserDto sysUserDto) {
|
||||
//判断是否有权限
|
||||
// boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN.toString());
|
||||
// if(!hasPermission){
|
||||
// return R.fail("没有系统管理权限");
|
||||
// }
|
||||
|
||||
sysUserService.updateUser(sysUserDto);
|
||||
return R.success();
|
||||
}
|
||||
@ -51,12 +66,18 @@ public class SysUserController {
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public R<?> deleteUser(@RequestBody DeleteDto deleteDto) {
|
||||
//判断是否有权限
|
||||
// boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN.toString());
|
||||
// if(!hasPermission){
|
||||
// return R.fail("没有系统管理权限");
|
||||
// }
|
||||
|
||||
sysUserService.deleteUser(deleteDto);
|
||||
return R.success();
|
||||
}
|
||||
|
||||
@PostMapping("/query")
|
||||
public PageDataInfo<SysUser> queryUserList(@RequestBody SysUserQueryDto sysUserQueryDto, PageQuery pageQuery) {
|
||||
public PageDataInfo<SysUserVo> queryUserList(@RequestBody SysUserQueryDto sysUserQueryDto, PageQuery pageQuery) {
|
||||
return sysUserService.queryUserList(sysUserQueryDto, pageQuery);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import java.io.Serializable;
|
||||
public class SysMenuQueryDto implements Serializable {
|
||||
/** 菜单ID */
|
||||
private Long id ;
|
||||
|
||||
/** 菜单名称 */
|
||||
private String menuName ;
|
||||
/** 上级菜单ID */
|
||||
private Long parentMenuId ;
|
||||
|
||||
|
@ -1,36 +1,55 @@
|
||||
package com.das.modules.auth.domain.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SysUserDto implements Serializable {
|
||||
/** 角色ID */
|
||||
private Long id ;
|
||||
/** 账号 */
|
||||
private String account ;
|
||||
/** 密码 */
|
||||
private String password ;
|
||||
/** 职员名称 */
|
||||
private String userName ;
|
||||
/** 职员邮箱 */
|
||||
private String email ;
|
||||
/** 手机号 */
|
||||
private String phone ;
|
||||
/** 所属机构id */
|
||||
private Long orgId ;
|
||||
/** 最后登录时间 */
|
||||
private Date lastLogin ;
|
||||
/** 乐观锁 */
|
||||
private Integer revision ;
|
||||
/** 创建人 */
|
||||
private String createdBy ;
|
||||
/** 创建时间 */
|
||||
private Date createdTime ;
|
||||
/** 更新人 */
|
||||
private String updatedBy ;
|
||||
/** 更新时间 */
|
||||
private Date updatedTime ;
|
||||
}
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
private String account;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 职员名称
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* 职员邮箱
|
||||
*/
|
||||
private String email;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phone;
|
||||
/**
|
||||
* 所属机构id
|
||||
*/
|
||||
private Long orgId;
|
||||
/**
|
||||
* 最后登录时间
|
||||
*/
|
||||
private Date lastLogin;
|
||||
/**
|
||||
* 乐观锁
|
||||
*/
|
||||
private Integer revision;
|
||||
/**
|
||||
* 角色列表
|
||||
*/
|
||||
private List<Long> roleList;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.das.modules.auth.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
@ -13,6 +15,7 @@ public class SysMenuVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 菜单ID */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id ;
|
||||
/** 菜单名称 */
|
||||
private String menuName ;
|
||||
|
@ -0,0 +1,39 @@
|
||||
package com.das.modules.auth.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class SysOrgVo implements Serializable {
|
||||
/** 机构id */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id ;
|
||||
/** 机构名称 */
|
||||
private String name ;
|
||||
/** 机构编码 */
|
||||
private String mrid ;
|
||||
/** 省份 */
|
||||
private String province ;
|
||||
/** 城市 */
|
||||
private String city ;
|
||||
/** 区县 */
|
||||
private String county ;
|
||||
/** 具体地址 */
|
||||
private String address ;
|
||||
/** 联系电话 */
|
||||
private String contactPhone ;
|
||||
/** 备注 */
|
||||
private String remarks ;
|
||||
/** 机构简称 */
|
||||
private String aliasName;
|
||||
/** 上级组织机构id */
|
||||
private Long parentOrgId ;
|
||||
|
||||
private String parentOrgName ;
|
||||
/** 乐观锁 */
|
||||
private Integer revision ;
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.das.modules.auth.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
@ -17,6 +19,7 @@ public class SysRoleAuthVo implements Serializable {
|
||||
/**
|
||||
* 账号ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,46 @@
|
||||
package com.das.modules.auth.domain.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.Version;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色前端回显
|
||||
*
|
||||
* @author guchengwei
|
||||
*/
|
||||
@Data
|
||||
public class SysRoleVo implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 账号ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String roleCode;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String roleName;
|
||||
|
||||
/**
|
||||
* 乐观锁
|
||||
*/
|
||||
private Integer revision;
|
||||
|
||||
private List<SysRoleAuthVo> list;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.das.modules.auth.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 账号信息
|
||||
*
|
||||
* @author guchengwei
|
||||
*/
|
||||
@Data
|
||||
public class SysUserRoleVo implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 账号ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String roleCode;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String roleName;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private Integer revision;
|
||||
|
||||
|
||||
}
|
@ -1,9 +1,13 @@
|
||||
package com.das.modules.auth.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 账号信息
|
||||
@ -17,6 +21,7 @@ public class SysUserVo implements Serializable {
|
||||
/**
|
||||
* 账号ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@ -29,6 +34,12 @@ public class SysUserVo implements Serializable {
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
|
||||
/**
|
||||
* 乐观锁
|
||||
*/
|
||||
private Integer revision;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@ -43,7 +54,16 @@ public class SysUserVo implements Serializable {
|
||||
/**
|
||||
* 所属机构
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long orgId;
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
*/
|
||||
private List<SysUserRoleVo> roleList;
|
||||
|
||||
/**
|
||||
*权限列表
|
||||
*/
|
||||
private List<Integer> authorities=new ArrayList<>();
|
||||
}
|
||||
|
@ -0,0 +1,57 @@
|
||||
package com.das.modules.auth.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.Version;
|
||||
import com.das.common.constant.BaseEntity;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* (sys_r_role_authority)实体类
|
||||
*
|
||||
* @author chenhaojie
|
||||
* @since 2024-06-25
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("sys_r_user_role")
|
||||
public class SysUserRole extends BaseEntity implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId("id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField("user_id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
@TableField("role_id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 乐观锁
|
||||
*/
|
||||
@Version
|
||||
@TableField("revision")
|
||||
private Integer revision;
|
||||
}
|
@ -22,7 +22,5 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||
|
||||
List<SysMenuVo> queryAllMenuList(@Param("sysMenu") SysMenuQueryDto sysMenuQueryDto);
|
||||
|
||||
List<SysMenuVo> queryAllMenuListByParentId(@Param("sysMenu") SysMenuQueryDto sysMenuQueryDto);
|
||||
|
||||
SysMenuVo createTree();
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.modules.auth.domain.dto.SysRoleQueryDto;
|
||||
import com.das.modules.auth.domain.vo.SysRoleAuthVo;
|
||||
import com.das.modules.auth.domain.vo.SysRoleVo;
|
||||
import com.das.modules.auth.entity.SysRole;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@ -25,11 +26,13 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
* @return 0 - 不存在 1 - 存在
|
||||
*/
|
||||
long existRoleByRoleCode(@Param("roleCode") String roleCode);
|
||||
IPage<SysRole> queryRoleList(IPage<SysRole> page, @Param("sysRole") SysRoleQueryDto sysRoleQueryDto);
|
||||
IPage<SysRoleVo> queryRoleList(IPage<SysRole> page, @Param("sysRole") SysRoleQueryDto sysRoleQueryDto);
|
||||
|
||||
List<SysRoleAuthVo> queryAuthorityById(@Param("id")Long id);
|
||||
|
||||
SysRole selectByCode(@Param("roleCode") String roleCode);
|
||||
|
||||
long existRoleByRoleId(@Param("id")Long id);
|
||||
|
||||
long existRoleByName(@Param("name") String name);
|
||||
}
|
||||
|
@ -2,10 +2,13 @@ package com.das.modules.auth.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.modules.auth.domain.dto.SysUserQueryDto;
|
||||
import com.das.modules.auth.domain.vo.SysUserVo;
|
||||
import com.das.modules.auth.entity.SysUser;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户信息 Mapper 接口
|
||||
@ -14,5 +17,21 @@ import org.apache.ibatis.annotations.Param;
|
||||
* @author chenhaojie
|
||||
*/
|
||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
IPage<SysUser> queryUserList(IPage<SysUser> page, @Param("sysUser") SysUserQueryDto sysUserQueryDto);
|
||||
|
||||
/**
|
||||
* 判断用户是否存在
|
||||
*
|
||||
* @param account 用户账号
|
||||
* @return 0 - 不存在 1 - 存在
|
||||
*/
|
||||
long existUserByAccount(@Param("account") String account);
|
||||
IPage<SysUserVo> queryUserList(IPage<SysUserVo> page, @Param("sysUser") SysUserQueryDto sysUserQueryDto);
|
||||
|
||||
long existUserByUserName(@Param("userName") String userName);
|
||||
/**
|
||||
* 根据用户id查询权限列表
|
||||
* @param userId 用户id
|
||||
* @return 该用户拥有的权限id列表
|
||||
*/
|
||||
List<Integer> queryAuthoritiesByUserId(@Param("userId") Long userId);
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.das.modules.auth.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.das.modules.auth.entity.SysRoleAuthority;
|
||||
import com.das.modules.auth.entity.SysUserRole;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户信息 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaojie
|
||||
*/
|
||||
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
|
||||
|
||||
|
||||
}
|
@ -15,9 +15,9 @@ public interface SysMenuService {
|
||||
|
||||
SysMenu createMenu(SysMenuDto sysMenuDto);
|
||||
|
||||
int updateMenu(SysMenuDto sysMenuDto);
|
||||
void updateMenu(SysMenuDto sysMenuDto);
|
||||
|
||||
int deleteMenu(DeleteDto deleteDto);
|
||||
void deleteMenu(DeleteDto deleteDto);
|
||||
|
||||
PageDataInfo<SysMenu> queryMenuList(SysMenuQueryDto sysMenuQueryDto, PageQuery pageQuery);
|
||||
|
||||
|
@ -10,9 +10,9 @@ import java.util.List;
|
||||
public interface SysOrgService {
|
||||
SysOrg createOrg(SysOrgDto sysUserDto);
|
||||
|
||||
int updateOrg(SysOrgDto sysUserDto);
|
||||
void updateOrg(SysOrgDto sysUserDto);
|
||||
|
||||
int deleteOrg(DeleteDto deleteDto);
|
||||
void deleteOrg(DeleteDto deleteDto);
|
||||
|
||||
PageDataInfo<SysOrg> queryOrgList(SysOrgQueryDto sysOrgQueryDto, PageQuery pageQuery);
|
||||
|
||||
|
@ -4,6 +4,7 @@ import com.das.common.utils.PageDataInfo;
|
||||
import com.das.common.utils.PageQuery;
|
||||
import com.das.modules.auth.domain.dto.*;
|
||||
import com.das.modules.auth.domain.vo.SysRoleAuthVo;
|
||||
import com.das.modules.auth.domain.vo.SysRoleVo;
|
||||
import com.das.modules.auth.entity.SysRole;
|
||||
|
||||
import java.util.List;
|
||||
@ -13,9 +14,9 @@ public interface SysRoleService {
|
||||
|
||||
SysRoleDto updateRole(SysRoleDto sysRoleDto);
|
||||
|
||||
int deleteRole(DeleteDto deleteDto);
|
||||
void deleteRole(DeleteDto deleteDto);
|
||||
|
||||
PageDataInfo<SysRole> queryRoleList(SysRoleQueryDto sysRoleQueryDto, PageQuery pageQuery);
|
||||
PageDataInfo<SysRoleVo> queryRoleList(SysRoleQueryDto sysRoleQueryDto, PageQuery pageQuery);
|
||||
|
||||
List<SysRoleAuthVo> queryAuthorityById(SysRoleQueryDto sysRoleQueryDto);
|
||||
}
|
||||
|
@ -5,14 +5,15 @@ import com.das.common.utils.PageQuery;
|
||||
import com.das.modules.auth.domain.dto.DeleteDto;
|
||||
import com.das.modules.auth.domain.dto.SysUserDto;
|
||||
import com.das.modules.auth.domain.dto.SysUserQueryDto;
|
||||
import com.das.modules.auth.domain.vo.SysUserVo;
|
||||
import com.das.modules.auth.entity.SysUser;
|
||||
|
||||
public interface SysUserService {
|
||||
SysUser createUser(SysUserDto sysUserDto);
|
||||
SysUserDto createUser(SysUserDto sysUserDto);
|
||||
|
||||
int updateUser(SysUserDto sysUserDto);
|
||||
SysUserDto updateUser(SysUserDto sysUserDto);
|
||||
|
||||
int deleteUser(DeleteDto deleteDto);
|
||||
void deleteUser(DeleteDto deleteDto);
|
||||
|
||||
PageDataInfo<SysUser> queryUserList(SysUserQueryDto sysUserQueryDto, PageQuery pageQuery);
|
||||
PageDataInfo<SysUserVo> queryUserList(SysUserQueryDto sysUserQueryDto, PageQuery pageQuery);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.das.common.captcha.CaptchaUtils;
|
||||
import com.das.common.config.SaTokenProperties;
|
||||
import com.das.common.config.SessionUtil;
|
||||
import com.das.common.utils.AdminRedisTemplate;
|
||||
import com.das.modules.auth.domain.vo.LoginUserDetailsVo;
|
||||
import com.das.modules.auth.domain.dto.LoginDto;
|
||||
@ -75,10 +76,18 @@ public class LoginServiceImpl implements LoginService {
|
||||
sysUserVo.setEmail(sysUser.getEmail());
|
||||
sysUserVo.setOrgId(sysUser.getOrgId());
|
||||
|
||||
//查询用户权限列表
|
||||
sysUserVo.setAuthorities(sysUserMapper.queryAuthoritiesByUserId(sysUser.getId()));
|
||||
|
||||
loginInfo.setSysUser(sysUserVo); // 存储用户信息到会话
|
||||
loginInfo.setToken(token);
|
||||
loginInfo.setRefreshToken(refreshTokenUuid);
|
||||
|
||||
adminRedisTemplate.setEx(refreshToken, loginInfo, Duration.ofSeconds(saTokenProperties.getRefreshExpireTime()));
|
||||
|
||||
//将登录用户信息存入 Session
|
||||
StpUtil.getTokenSession().set(SessionUtil.SESSION_USER_KEY, sysUserVo);
|
||||
|
||||
return loginInfo;
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,9 @@ public class SysAuthorityServiceImpl implements SysAuthorityService {
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
List<SysAuthority> list = new ArrayList<>();
|
||||
list.add(new SysAuthority(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN,"systemMgr","系统管理权限",1));
|
||||
list.add(new SysAuthority(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR,"equipmentLedgerManagement","设备台账维护权限",1));
|
||||
list.add(new SysAuthority(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_VIEW,"equipmentLedgerView","设备台账浏览权限",1));
|
||||
list.add(new SysAuthority(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN,"SYS_AUTHORITY_ID_ADMIN","系统管理权限",1));
|
||||
list.add(new SysAuthority(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR,"SYS_AUTHORITY_ID_DEVICE_MGR","设备台账维护权限",1));
|
||||
list.add(new SysAuthority(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_VIEW,"SYS_AUTHORITY_ID_DEVICE_VIEW","设备台账浏览权限",1));
|
||||
|
||||
try {
|
||||
// 性能优化:先查询所有需要的权限是否存在,减少数据库访问次数
|
||||
|
@ -39,15 +39,16 @@ public class SysMenuServiceImpl implements SysMenuService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateMenu(SysMenuDto sysMenuDto) {
|
||||
public void updateMenu(SysMenuDto sysMenuDto) {
|
||||
SysMenu sysMenu = new SysMenu();
|
||||
BeanCopyUtils.copy(sysMenuDto,sysMenu);
|
||||
return sysMenuMapper.updateById(sysMenu);
|
||||
sysMenu.setUpdatedTime(new Date());
|
||||
sysMenuMapper.updateById(sysMenu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteMenu(DeleteDto deleteDto) {
|
||||
return sysMenuMapper.deleteById(deleteDto.getId());
|
||||
public void deleteMenu(DeleteDto deleteDto) {
|
||||
sysMenuMapper.deleteById(deleteDto.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -58,14 +59,10 @@ public class SysMenuServiceImpl implements SysMenuService {
|
||||
|
||||
@Override
|
||||
public List<SysMenuVo> queryAllMenuList(SysMenuQueryDto sysMenuQueryDto) {
|
||||
List<SysMenuVo> list = new ArrayList<>();
|
||||
if(sysMenuQueryDto.getRecursive()) {
|
||||
sysMenuQueryDto.setParentMenuId(0L);
|
||||
list = sysMenuMapper.queryAllMenuList(sysMenuQueryDto);
|
||||
} else {
|
||||
list = sysMenuMapper.queryAllMenuListByParentId(sysMenuQueryDto);
|
||||
}
|
||||
|
||||
List<SysMenuVo> list = sysMenuMapper.queryAllMenuList(sysMenuQueryDto);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.das.modules.auth.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.common.utils.BeanCopyUtils;
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
@ -37,15 +36,15 @@ public class SysOrgServiceImpl implements SysOrgService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateOrg(SysOrgDto sysOrgDto) {
|
||||
public void updateOrg(SysOrgDto sysOrgDto) {
|
||||
SysOrg sysOrg = new SysOrg();
|
||||
BeanCopyUtils.copy(sysOrgDto,sysOrg);
|
||||
return sysOrgMapper.updateById(sysOrg);
|
||||
sysOrgMapper.updateById(sysOrg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteOrg(DeleteDto deleteDto) {
|
||||
return sysOrgMapper.deleteById(deleteDto.getId());
|
||||
public void deleteOrg(DeleteDto deleteDto) {
|
||||
sysOrgMapper.deleteById(deleteDto.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,6 +11,7 @@ import com.das.modules.auth.domain.dto.DeleteDto;
|
||||
import com.das.modules.auth.domain.dto.SysRoleDto;
|
||||
import com.das.modules.auth.domain.dto.SysRoleQueryDto;
|
||||
import com.das.modules.auth.domain.vo.SysRoleAuthVo;
|
||||
import com.das.modules.auth.domain.vo.SysRoleVo;
|
||||
import com.das.modules.auth.entity.SysRole;
|
||||
import com.das.modules.auth.entity.SysRoleAuthority;
|
||||
import com.das.modules.auth.mapper.SysAuthorityMapper;
|
||||
@ -160,7 +161,7 @@ public class SysRoleServiceImpl implements SysRoleService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteRole(DeleteDto deleteDto) {
|
||||
public void deleteRole(DeleteDto deleteDto) {
|
||||
SysRole sysRole = sysRoleMapper.selectById(deleteDto.getId());
|
||||
if (StringUtils.isEmpty(deleteDto.getId())) {
|
||||
throw new ServiceException("参数缺失");
|
||||
@ -178,12 +179,12 @@ public class SysRoleServiceImpl implements SysRoleService {
|
||||
authorityInfoQueryWrapper.eq("role_id", deleteDto.getId());
|
||||
sysRoleAuthorityMapper.delete(authorityInfoQueryWrapper);
|
||||
//删除角色
|
||||
return sysRoleMapper.deleteById(deleteDto.getId());
|
||||
sysRoleMapper.deleteById(deleteDto.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageDataInfo<SysRole> queryRoleList(SysRoleQueryDto sysRoleQueryDto, PageQuery pageQuery) {
|
||||
IPage<SysRole> iPage = sysRoleMapper.queryRoleList(pageQuery.build(), sysRoleQueryDto);
|
||||
public PageDataInfo<SysRoleVo> queryRoleList(SysRoleQueryDto sysRoleQueryDto, PageQuery pageQuery) {
|
||||
IPage<SysRoleVo> iPage = sysRoleMapper.queryRoleList(pageQuery.build(), sysRoleQueryDto);
|
||||
return PageDataInfo.build(iPage.getRecords(), iPage.getTotal());
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
package com.das.modules.auth.service.impl;
|
||||
|
||||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.common.exceptions.ServiceException;
|
||||
import com.das.common.utils.BeanCopyUtils;
|
||||
import com.das.common.utils.SequenceUtils;
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
@ -8,46 +11,183 @@ import com.das.common.utils.PageQuery;
|
||||
import com.das.modules.auth.domain.dto.DeleteDto;
|
||||
import com.das.modules.auth.domain.dto.SysUserDto;
|
||||
import com.das.modules.auth.domain.dto.SysUserQueryDto;
|
||||
import com.das.modules.auth.domain.vo.SysUserVo;
|
||||
import com.das.modules.auth.entity.SysRole;
|
||||
import com.das.modules.auth.entity.SysRoleAuthority;
|
||||
import com.das.modules.auth.entity.SysUser;
|
||||
import com.das.modules.auth.entity.SysUserRole;
|
||||
import com.das.modules.auth.mapper.SysRoleMapper;
|
||||
import com.das.modules.auth.mapper.SysUserMapper;
|
||||
import com.das.modules.auth.mapper.SysUserRoleMapper;
|
||||
import com.das.modules.auth.service.SysUserService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SysUserServiceImpl implements SysUserService {
|
||||
|
||||
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
|
||||
|
||||
|
||||
@Autowired
|
||||
SysUserMapper sysUserMapper;
|
||||
|
||||
@Autowired
|
||||
SysRoleMapper sysRoleMapper;
|
||||
|
||||
@Autowired
|
||||
SysUserRoleMapper sysUserRoleMapper;
|
||||
|
||||
@Override
|
||||
public SysUser createUser(SysUserDto sysUserDto) {
|
||||
public SysUserDto createUser(SysUserDto sysUserDto) {
|
||||
|
||||
//根据账号account判断是否存在
|
||||
long roleCount = sysUserMapper.existUserByAccount(sysUserDto.getAccount());
|
||||
if (roleCount > 0) {
|
||||
throw new ServiceException(String.format("账号 %s 已存在", sysUserDto.getAccount()));
|
||||
}
|
||||
|
||||
SysUser sysUser = new SysUser();
|
||||
BeanCopyUtils.copy(sysUserDto,sysUser);
|
||||
//密码加密
|
||||
String passwordEncode = BCrypt.hashpw(sysUserDto.getPassword(), BCrypt.gensalt());
|
||||
sysUser.setId(SequenceUtils.generateId());
|
||||
sysUser.setRevision(1);
|
||||
sysUser.setCreatedTime(new Date());
|
||||
sysUser.setUpdatedTime(new Date());
|
||||
sysUser.setPassword(passwordEncode);
|
||||
sysUserMapper.insert(sysUser);
|
||||
return sysUser;
|
||||
|
||||
if (sysUserDto.getRoleList() != null && sysUserDto.getRoleList().size() > 0) {
|
||||
//验证角色有效性
|
||||
String errorRoles = checkErrorRole(sysUserDto.getRoleList());
|
||||
if (StringUtils.hasText(errorRoles)) {
|
||||
throw new ServiceException("角色不存在 " + errorRoles);
|
||||
}
|
||||
//解锁role与Account绑定
|
||||
QueryWrapper<SysUserRole> accountRoleQueryWrapper = new QueryWrapper<>();
|
||||
accountRoleQueryWrapper.eq("user_id",sysUser.getId());
|
||||
sysUserRoleMapper.delete(accountRoleQueryWrapper);
|
||||
//绑定角色
|
||||
for (Long roleId : sysUserDto.getRoleList()) {
|
||||
SysUserRole accountRole = new SysUserRole();
|
||||
accountRole.setUserId(sysUser.getId());
|
||||
accountRole.setRoleId(roleId);
|
||||
accountRole.setRevision(1);
|
||||
accountRole.setCreatedTime(new Date());
|
||||
accountRole.setUpdatedTime(new Date());
|
||||
sysUserRoleMapper.insert(accountRole);
|
||||
}
|
||||
}
|
||||
// 消除密码
|
||||
sysUserDto.setPassword(null);
|
||||
return sysUserDto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证角色是否存在
|
||||
*/
|
||||
private String checkErrorRole(List<Long> roles) {
|
||||
if (roles != null && roles.size() > 0) {
|
||||
List<Long> errorRole = new ArrayList<>();
|
||||
for (Long roleId : roles) {
|
||||
if (roleId == null) {
|
||||
continue;
|
||||
}
|
||||
long roleCount = sysRoleMapper.existRoleByRoleId(roleId);
|
||||
if (roleCount == 0) {
|
||||
errorRole.add(roleId);
|
||||
}
|
||||
}
|
||||
if (errorRole.size() > 0) {
|
||||
try {
|
||||
return JSON_MAPPER.writeValueAsString(errorRole);
|
||||
} catch (JsonProcessingException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateUser(SysUserDto sysUserDto) {
|
||||
SysUser sysUser = new SysUser();
|
||||
BeanCopyUtils.copy(sysUserDto,sysUser);
|
||||
return sysUserMapper.updateById(sysUser);
|
||||
public SysUserDto updateUser(SysUserDto sysUserDto) {
|
||||
if (sysUserDto.getId() == null) {
|
||||
throw new ServiceException("参数缺失");
|
||||
}
|
||||
|
||||
SysUser sysUser = sysUserMapper.selectById(sysUserDto.getId());
|
||||
if (sysUser == null) {
|
||||
throw new ServiceException(String.format("账号 %d 不存在", sysUserDto.getId()));
|
||||
}
|
||||
if (StringUtils.hasText(sysUserDto.getUserName())) {
|
||||
//若与数据库中账户名相同 则表示未对名称进行修改
|
||||
if (!sysUser.getUserName().equals(sysUserDto.getUserName())) {
|
||||
//判断账户名是否存在
|
||||
long userCount = sysUserMapper.existUserByUserName(sysUserDto.getUserName());
|
||||
if (userCount > 0) {
|
||||
throw new ServiceException(String.format("账户名 %s 已存在", sysUserDto.getUserName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
SysUser newSysUser = new SysUser();
|
||||
BeanUtils.copyProperties(sysUserDto, newSysUser, "password");
|
||||
sysUserMapper.updateById(newSysUser);
|
||||
|
||||
if (sysUserDto.getRoleList() != null) {
|
||||
//验证角色有效性
|
||||
String errorRoles = checkErrorRole(sysUserDto.getRoleList());
|
||||
if (StringUtils.hasText(errorRoles)) {
|
||||
throw new ServiceException("角色不存在 " + errorRoles);
|
||||
}
|
||||
//解锁role与Account绑定
|
||||
QueryWrapper<SysUserRole> accountRoleQueryWrapper = new QueryWrapper<>();
|
||||
accountRoleQueryWrapper.eq("user_id",newSysUser.getId());
|
||||
sysUserRoleMapper.delete(accountRoleQueryWrapper);
|
||||
//绑定角色
|
||||
for (Long roleId : sysUserDto.getRoleList()) {
|
||||
|
||||
SysUserRole accountRole = new SysUserRole();
|
||||
accountRole.setUserId(sysUser.getId());
|
||||
accountRole.setRoleId(roleId);
|
||||
accountRole.setRevision(1);
|
||||
accountRole.setCreatedTime(new Date());
|
||||
accountRole.setUpdatedTime(new Date());
|
||||
sysUserRoleMapper.insert(accountRole);
|
||||
}
|
||||
}
|
||||
return sysUserDto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteUser(DeleteDto deleteDto) {
|
||||
return sysUserMapper.deleteById(deleteDto.getId());
|
||||
public void deleteUser(DeleteDto deleteDto) {
|
||||
if (StringUtils.isEmpty(deleteDto.getId())) {
|
||||
throw new ServiceException("参数缺失");
|
||||
}
|
||||
SysUser sysUser = sysUserMapper.selectById(deleteDto.getId());
|
||||
if (sysUser == null) {
|
||||
throw new ServiceException("账号不存在");
|
||||
}
|
||||
|
||||
//解锁role与用户绑定
|
||||
QueryWrapper<SysUserRole> accountRoleQueryWrapper = new QueryWrapper<>();
|
||||
accountRoleQueryWrapper.eq("user_id", deleteDto.getId());
|
||||
this.sysUserRoleMapper.delete(accountRoleQueryWrapper);
|
||||
//删除角色
|
||||
sysUserMapper.deleteById(deleteDto.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageDataInfo<SysUser> queryUserList(SysUserQueryDto sysUserQueryDto, PageQuery pageQuery) {
|
||||
IPage<SysUser> iPage = sysUserMapper.queryUserList(pageQuery.build(), sysUserQueryDto);
|
||||
public PageDataInfo<SysUserVo> queryUserList(SysUserQueryDto sysUserQueryDto, PageQuery pageQuery) {
|
||||
IPage<SysUserVo> iPage = sysUserMapper.queryUserList(pageQuery.build(), sysUserQueryDto);
|
||||
return PageDataInfo.build(iPage.getRecords(), iPage.getTotal());
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,9 @@
|
||||
<if test="sysMenu.parentMenuId != null and sysMenu.parentMenuId != ''">
|
||||
and parent_menu_id = #{sysMenu.parentMenuId}
|
||||
</if>
|
||||
<if test="sysMenu.menuName != null and sysMenu.menuName != ''">
|
||||
and menu_name = #{sysMenu.menuName}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@ -53,11 +56,6 @@
|
||||
select * from sys_menu where parent_menu_id = #{sysMenu.parentMenuId}
|
||||
</select>
|
||||
|
||||
<select id="queryAllMenuListByParentId" resultMap="SysMenuMap">
|
||||
select * from sys_menu where parent_menu_id = #{sysMenu.parentMenuId}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryChildMenus" resultMap="SysMenuChildMap">
|
||||
select * from sys_menu where parent_menu_id = #{id}
|
||||
</select>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.das.modules.auth.mapper.SysOrgMapper">
|
||||
|
||||
<resultMap type="com.das.modules.auth.entity.SysOrg" id="SysOrgMap">
|
||||
<resultMap type="com.das.modules.auth.domain.vo.SysOrgVo" id="SysOrgMap">
|
||||
<result property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="mrid" column="mrid" jdbcType="VARCHAR"/>
|
||||
@ -13,42 +13,41 @@
|
||||
<result property="contactPhone" column="contact_phone" jdbcType="VARCHAR"/>
|
||||
<result property="remarks" column="remarks" jdbcType="VARCHAR"/>
|
||||
<result property="parentOrgId" column="parent_org_id" jdbcType="VARCHAR"/>
|
||||
<result property="parentOrgName" column="parentOrgName" jdbcType="VARCHAR"/>
|
||||
<result property="revision" column="revision" jdbcType="VARCHAR"/>
|
||||
<result property="createdBy" column="created_by" jdbcType="VARCHAR"/>
|
||||
<result property="createdTime" column="created_time" jdbcType="VARCHAR"/>
|
||||
<result property="updatedBy" column="updated_by" jdbcType="VARCHAR"/>
|
||||
<result property="updatedTime" column="updated_time" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="queryOrgList" resultMap="SysOrgMap">
|
||||
select * from sys_org
|
||||
select t.*, p.name as parentOrgName from sys_org t left join sys_org p on p.id = t.parent_org_id
|
||||
<where>
|
||||
<if test="sysOrg.name != null and sysOrg.name != ''">
|
||||
and name like concat('%',#{sysOrg.name},'%')
|
||||
and t.name like concat('%',#{sysOrg.name},'%')
|
||||
</if>
|
||||
<if test="sysOrg.province != null and sysOrg.province != ''">
|
||||
and province like concat('%',#{sysOrg.province},'%')
|
||||
and t.province like concat('%',#{sysOrg.province},'%')
|
||||
</if>
|
||||
<if test="sysOrg.city != null and sysOrg.city != ''">
|
||||
and city like concat('%',#{sysOrg.city},'%')
|
||||
and t.city like concat('%',#{sysOrg.city},'%')
|
||||
</if>
|
||||
<if test="sysOrg.county != null and sysOrg.county != ''">
|
||||
and county like concat('%',#{sysOrg.county},'%')
|
||||
and t.county like concat('%',#{sysOrg.county},'%')
|
||||
</if>
|
||||
<if test="sysOrg.parentOrgId != null and sysOrg.parentOrgId != ''">
|
||||
and parent_org_id = #{sysOrg.parentOrgId}
|
||||
and t.parent_org_id = #{sysOrg.parentOrgId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryAllOrgTree" resultMap="SysOrgMap">
|
||||
SELECT i.* FROM sys_org i WHERE i.id = #{id}
|
||||
select t.*, p.name as parentOrgName from sys_org t left join sys_org p on p.id = t.parent_org_id
|
||||
WHERE t.id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryAllChildOrgTree" resultMap="SysOrgMap">
|
||||
SELECT i.* FROM sys_org i WHERE i.parent_org_id = #{id}
|
||||
select t.*, p.name as parentOrgName from sys_org t left join sys_org p on p.id = t.parent_org_id
|
||||
WHERE t.parent_org_id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
@ -13,7 +13,15 @@
|
||||
<result property="updatedTime" column="updated_time" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="queryRoleList" resultMap="SysRoleMap">
|
||||
<resultMap type="com.das.modules.auth.domain.vo.SysRoleVo" id="SysRoleAuthMap">
|
||||
<result property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="roleCode" column="role_code" jdbcType="VARCHAR"/>
|
||||
<result property="roleName" column="role_name" jdbcType="VARCHAR"/>
|
||||
<result property="revision" column="revision" jdbcType="VARCHAR"/>
|
||||
<collection property="list" column="id" ofType="com.das.modules.auth.domain.vo.SysRoleAuthVo" select="queryAuthorityById"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="queryRoleList" resultMap="SysRoleAuthMap">
|
||||
select * from sys_role
|
||||
<where>
|
||||
<if test="sysRole.roleName != null and sysRole.roleName != ''">
|
||||
@ -27,6 +35,10 @@
|
||||
select count(1) from sys_role t where t.role_code=#{roleCode}
|
||||
</select>
|
||||
|
||||
<select id="existRoleByRoleId" resultType="java.lang.Long">
|
||||
select count(1) from sys_role t where t.id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="queryAuthorityById" resultType="com.das.modules.auth.domain.vo.SysRoleAuthVo">
|
||||
select sa.id, sa.authority_code as authorityCode, sa.authority_name as authorityName from sys_authority sa left join sys_r_role_authority srra on sa.id = srra.authority_id
|
||||
where srra.role_id = #{id}
|
||||
|
@ -18,7 +18,41 @@
|
||||
<result property="updatedTime" column="updated_time" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="queryUserList" resultMap="SysUserMap">
|
||||
|
||||
<resultMap type="com.das.modules.auth.domain.vo.SysUserVo" id="SysUserRoleMap">
|
||||
<result property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="account" column="account" jdbcType="VARCHAR"/>
|
||||
<result property="userName" column="user_name" jdbcType="VARCHAR"/>
|
||||
<result property="email" column="email" jdbcType="VARCHAR"/>
|
||||
<result property="phone" column="phone" jdbcType="VARCHAR"/>
|
||||
<result property="orgId" column="org_id" jdbcType="VARCHAR"/>
|
||||
<result property="revision" column="revision" jdbcType="VARCHAR"/>
|
||||
<collection property="roleList" column="id" ofType="com.das.modules.auth.domain.vo.SysUserRoleVo" select="queryRoleByUserId"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<resultMap type="com.das.modules.auth.domain.vo.SysUserRoleVo" id="UserRoleRelationMap">
|
||||
<result property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="roleCode" column="role_code" jdbcType="VARCHAR"/>
|
||||
<result property="roleName" column="role_name" jdbcType="VARCHAR"/>
|
||||
<result property="revision" column="revision" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="existUserByAccount" resultType="java.lang.Long">
|
||||
select count(1) from sys_user t where t.account=#{account}
|
||||
</select>
|
||||
|
||||
<select id="existUserByUserName" resultType="java.lang.Long">
|
||||
select count(1) from sys_user t where t.user_name=#{userName}
|
||||
</select>
|
||||
|
||||
<select id="queryRoleByUserId" resultMap="UserRoleRelationMap">
|
||||
select sr.role_code,sr.role_name ,sr.id ,sr.revision from sys_role sr left join sys_r_user_role srur on sr.id = srur.role_id
|
||||
where srur.user_id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryUserList" resultMap="SysUserRoleMap">
|
||||
select * from sys_user
|
||||
<where>
|
||||
<if test="sysUser.userName != null and sysUser.userName != ''">
|
||||
@ -30,4 +64,24 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="queryAuthoritiesByUserId" resultType="java.lang.Integer" parameterType="java.lang.Long">
|
||||
select
|
||||
t2.id
|
||||
from
|
||||
sys_authority t2
|
||||
where
|
||||
t2.id in(
|
||||
select
|
||||
t1.authority_id
|
||||
from
|
||||
sys_r_role_authority t1
|
||||
where
|
||||
t1.role_id in(
|
||||
select
|
||||
t.role_id
|
||||
from
|
||||
sys_r_user_role t
|
||||
where
|
||||
t.user_id = #{userId}))
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -757,8 +757,7 @@
|
||||
```json
|
||||
{
|
||||
"userName":"xx",
|
||||
"orgId":"xxx",
|
||||
"phone":"xxx"
|
||||
"orgId":"xxx"
|
||||
}
|
||||
```
|
||||
|
||||
@ -768,41 +767,51 @@
|
||||
|:---------| :------: | :---: |:--------------------------|
|
||||
| userName | String | Yes | 模糊查询职员名称,当职员名称为空时查询所有职员信息 |
|
||||
| orgId | BIGINT | Yes | 所属机构ID |
|
||||
| phone | String | Yes | 手机号,模糊查询 |
|
||||
|
||||
调用成功返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code":"200",
|
||||
"msg":"调用成功",
|
||||
"data": [
|
||||
"total": 1,
|
||||
"rows": [
|
||||
{
|
||||
"id": "xxxx",
|
||||
"account": "xxx",
|
||||
"password": "xxx",
|
||||
"userName": "xxx",
|
||||
"email":"xxx",
|
||||
"phone":"xxx",
|
||||
"orgId":"xxx"
|
||||
},
|
||||
{
|
||||
...
|
||||
"id": 73238484643741696,
|
||||
"account": "test1",
|
||||
"userName": "测试1",
|
||||
"revision": 1,
|
||||
"phone": "1231212",
|
||||
"email": "测试",
|
||||
"orgId": 1,
|
||||
"roleList": [
|
||||
{
|
||||
"id": 73220290639036416,
|
||||
"roleCode": "1212",
|
||||
"roleName": "测试角色1",
|
||||
"revision": 1
|
||||
},
|
||||
{
|
||||
"id": 73212978522226688,
|
||||
"roleCode": "0011",
|
||||
"roleName": "测试角色",
|
||||
"revision": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"success": true
|
||||
"code": 200,
|
||||
"msg": "查询成功"
|
||||
}
|
||||
```
|
||||
|
||||
| 变量名 | 变量类型 | 可为NULL | 描述 |
|
||||
| -------- | -------- | -------- | ------------------ |
|
||||
| id | BIGINT | No | 主键(雪花算法生成) |
|
||||
| account | String | No | 登录账号 |
|
||||
| password | String | No | 加密后的密码 |
|
||||
| userName | String | No | 职员名称 |
|
||||
| email | String | No | 职员邮箱 |
|
||||
| phone | String | No | 职员联系电话 |
|
||||
| orgId | BIGINT | No | 所属机构ID |
|
||||
| 变量名 | 变量类型 | 可为NULL | 描述 |
|
||||
| -------- |--------| -------- |------------|
|
||||
| id | BIGINT | No | 主键(雪花算法生成) |
|
||||
| account | String | No | 登录账号 |
|
||||
| userName | String | No | 职员名称 |
|
||||
| email | String | No | 职员邮箱 |
|
||||
| phone | String | No | 职员联系电话 |
|
||||
| orgId | BIGINT | No | 所属机构ID |
|
||||
| roleList | List | No | 角色集合 |
|
||||
|
||||
## 职员创建
|
||||
|
||||
@ -819,29 +828,37 @@
|
||||
"userName": "xxx",
|
||||
"email":"xxx",
|
||||
"phone":"xxx",
|
||||
"orgId":"xxx"
|
||||
"orgId":"xxx",
|
||||
"roleList":[73220290639036416,73212978522226688]
|
||||
}
|
||||
```
|
||||
|
||||
入参描述
|
||||
|
||||
| 变量名 | 变量类型 | 可为NULL | 描述 |
|
||||
| -------- | -------- | -------- | ------------ |
|
||||
| account | String | No | 登录账号 |
|
||||
| password | String | No | 加密后的密码 |
|
||||
| userName | String | No | 职员名称 |
|
||||
| email | String | No | 职员邮箱 |
|
||||
| phone | String | No | 职员联系电话 |
|
||||
| orgId | BIGINT | No | 所属机构ID |
|
||||
| 变量名 | 变量类型 | 可为NULL | 描述 |
|
||||
| -------- |--------| -------- |--------|
|
||||
| account | String | No | 登录账号 |
|
||||
| password | String | No | 加密后的密码 |
|
||||
| userName | String | No | 职员名称 |
|
||||
| email | String | No | 职员邮箱 |
|
||||
| phone | String | No | 职员联系电话 |
|
||||
| orgId | BIGINT | No | 所属机构ID |
|
||||
| roleList | List | No | 角色id集合 |
|
||||
|
||||
调用成功返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code":"200",
|
||||
"msg":"创建成功",
|
||||
"data":"null",
|
||||
"success": true
|
||||
"code": 200,
|
||||
"success": true,
|
||||
"data": {
|
||||
"account": "test1",
|
||||
"roleList": [
|
||||
73220290639036416,
|
||||
73212978522226688
|
||||
]
|
||||
},
|
||||
"msg": "操作成功"
|
||||
}
|
||||
```
|
||||
|
||||
@ -859,11 +876,11 @@
|
||||
{
|
||||
"id":"xxx",
|
||||
"account": "xxx",
|
||||
"password": "xxx",
|
||||
"userName": "xxx",
|
||||
"email":"xxx",
|
||||
"phone":"xxx",
|
||||
"orgId":"xxx"
|
||||
"orgId":"xxx",
|
||||
"roleList":[73220290639036416,73212978522226688]
|
||||
}
|
||||
```
|
||||
|
||||
@ -873,20 +890,19 @@
|
||||
| -------- | -------- | -------- | ------------------ |
|
||||
| id | BIGINT | No | 主键(雪花算法生成) |
|
||||
| account | String | No | 登录账号 |
|
||||
| password | String | No | 加密后的密码 |
|
||||
| userName | String | No | 职员名称 |
|
||||
| email | String | No | 职员邮箱 |
|
||||
| phone | String | No | 职员联系电话 |
|
||||
| orgId | BIGINT | No | 所属机构ID |
|
||||
| roleList | List | No | 角色id集合 |
|
||||
|
||||
调用成功返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code":"200",
|
||||
"msg":"修改成功",
|
||||
"data":"null",
|
||||
"success": true
|
||||
"code": 200,
|
||||
"success": true,
|
||||
"msg": "操作成功"
|
||||
}
|
||||
```
|
||||
|
||||
@ -914,10 +930,9 @@
|
||||
|
||||
```json
|
||||
{
|
||||
"code":"200",
|
||||
"msg":"修改成功",
|
||||
"data":"null",
|
||||
"success": true
|
||||
"code": 200,
|
||||
"success": true,
|
||||
"msg": "操作成功"
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -28,3 +28,102 @@ export function logout() {
|
||||
method: 'POST',
|
||||
})
|
||||
}
|
||||
//菜单树
|
||||
export function menusTree(params: object = {}) {
|
||||
return createAxios({
|
||||
url: '/api/menus/list',
|
||||
method: 'POST',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 菜单管理查询
|
||||
export function menusQuery(params: object = {}) {
|
||||
return createAxios({
|
||||
url: '/api/menus/query',
|
||||
method: 'POST',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
// 菜单修改
|
||||
export function menusUpdate(params: object = {}) {
|
||||
return createAxios({
|
||||
url: '/api/menus/update',
|
||||
method: 'POST',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
// 菜单删除
|
||||
export function menuDelete(params: object = {}) {
|
||||
return createAxios({
|
||||
url: '/api/menus/delete',
|
||||
method: 'POST',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
// 菜单新增
|
||||
export function menuAdd(params: object = {}) {
|
||||
return createAxios({
|
||||
url: '/api/menus/add',
|
||||
method: 'POST',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
// 用户查询
|
||||
export function userQuery(params: object = {}) {
|
||||
return createAxios({
|
||||
url: '/api/user/query',
|
||||
method: 'POST',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
// 用户修改
|
||||
export function userUpdate(params: object = {}) {
|
||||
return createAxios({
|
||||
url: '/api/user/update',
|
||||
method: 'POST',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
// 用户删除
|
||||
export function userDelete(params: object = {}) {
|
||||
return createAxios({
|
||||
url: '/api/user/delete',
|
||||
method: 'POST',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
// 用户新增
|
||||
export function userAdd(params: object = {}) {
|
||||
return createAxios({
|
||||
url: '/api/user/add',
|
||||
method: 'POST',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
// 用户左边树
|
||||
export function userList(params: object = {}) {
|
||||
return createAxios({
|
||||
url: 'api/org/list',
|
||||
method: 'POST',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
// 所有权限查询
|
||||
export function allPermissionQuery(params: object = {}) {
|
||||
return createAxios({
|
||||
url: '/api/authority/query',
|
||||
method: 'POST',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
@ -99,107 +99,35 @@ const menu = [
|
||||
extend: 'none',
|
||||
children: [
|
||||
{
|
||||
id: 99,
|
||||
pid: 98,
|
||||
id: 816,
|
||||
pid: 108,
|
||||
type: 'menu',
|
||||
title: '角色管理',
|
||||
name: 'auth\/RoleManagement',
|
||||
path: 'auth\/RoleManagement',
|
||||
title: '菜单配置',
|
||||
name: 'auth\/menuManagement',
|
||||
path: 'auth\/menuManagement',
|
||||
icon: 'fa fa-group',
|
||||
menu_type: 'tab',
|
||||
url: '',
|
||||
component: '\/src\/views\/backend\/RoleManagement\/RoleManagement.vue',
|
||||
keepalive: 'auth\/RoleManagement',
|
||||
component: '\/src\/views\/backend\/auth\/menuManagement\/index.vue',
|
||||
keepalive: 'auth\/menuManagement',
|
||||
extend: 'none',
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
id: 97,
|
||||
pid: 96,
|
||||
id: 777,
|
||||
pid: 201,
|
||||
type: 'menu',
|
||||
title: '机构管理',
|
||||
name: 'auth\/InstitutionalManagement',
|
||||
path: 'auth\/InstitutionalManagement',
|
||||
title: '用户管理',
|
||||
name: 'auth\/userManagement',
|
||||
path: 'auth\/userManagement',
|
||||
icon: 'fa fa-group',
|
||||
menu_type: 'tab',
|
||||
url: '',
|
||||
component: '\/src\/views\/backend\/InstitutionalManagement\/InstitutionalManagement.vue',
|
||||
keepalive: 'auth\/InstitutionalManagement',
|
||||
component: '\/src\/views\/backend\/auth\/userManagement\/index.vue',
|
||||
keepalive: 'auth\/userManagement',
|
||||
extend: 'none',
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
pid: 2,
|
||||
type: 'menu',
|
||||
title: '角色组管理',
|
||||
name: 'auth\/group',
|
||||
path: 'auth\/group',
|
||||
icon: 'fa fa-group',
|
||||
menu_type: 'tab',
|
||||
url: '',
|
||||
component: '\/src\/views\/backend\/auth\/group\/index.vue',
|
||||
keepalive: 'auth\/group',
|
||||
extend: 'none',
|
||||
children: [
|
||||
{
|
||||
id: 4,
|
||||
pid: 3,
|
||||
type: 'button',
|
||||
title: '查看',
|
||||
name: 'auth\/group\/index',
|
||||
path: '',
|
||||
icon: '',
|
||||
menu_type: null,
|
||||
url: '',
|
||||
component: '',
|
||||
keepalive: 0,
|
||||
extend: 'none',
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
pid: 3,
|
||||
type: 'button',
|
||||
title: '添加',
|
||||
name: 'auth\/group\/add',
|
||||
path: '',
|
||||
icon: '',
|
||||
menu_type: null,
|
||||
url: '',
|
||||
component: '',
|
||||
keepalive: 0,
|
||||
extend: 'none',
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
pid: 3,
|
||||
type: 'button',
|
||||
title: '编辑',
|
||||
name: 'auth\/group\/edit',
|
||||
path: '',
|
||||
icon: '',
|
||||
menu_type: null,
|
||||
url: '',
|
||||
component: '',
|
||||
keepalive: 0,
|
||||
extend: 'none',
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
pid: 3,
|
||||
type: 'button',
|
||||
title: '删除',
|
||||
name: 'auth\/group\/del',
|
||||
path: '',
|
||||
icon: '',
|
||||
menu_type: null,
|
||||
url: '',
|
||||
component: '',
|
||||
keepalive: 0,
|
||||
extend: 'none',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
pid: 2,
|
||||
|
@ -1,178 +0,0 @@
|
||||
<template>
|
||||
<div class="default-main ba-table-box">
|
||||
<el-alert class="ba-table-alert" v-if="!adminInfo.super" :title="t('auth.group.Manage subordinate role groups here')" type="info" show-icon />
|
||||
<el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
|
||||
|
||||
<!-- 表格顶部菜单 -->
|
||||
<TableHeader
|
||||
:buttons="['refresh', 'add', 'edit', 'delete', 'unfold', 'quickSearch', 'columnDisplay']"
|
||||
:quick-search-placeholder="t('Quick search placeholder', { fields: t('auth.group.GroupName') })"
|
||||
/>
|
||||
|
||||
<!-- 表格 -->
|
||||
<!-- 要使用`el-table`组件原有的属性,直接加在Table标签上即可 -->
|
||||
<Table ref="tableRef" :pagination="false" />
|
||||
|
||||
<!-- 表单 -->
|
||||
<PopupForm ref="formRef" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, provide } from 'vue'
|
||||
import baTableClass from '/@/utils/baTable'
|
||||
import { baTableApi } from '/@/api/common'
|
||||
import Table from '/@/components/table/index.vue'
|
||||
import TableHeader from '/@/components/table/header/index.vue'
|
||||
import PopupForm from './popupForm.vue'
|
||||
import { defaultOptButtons } from '/@/components/table'
|
||||
import { getAdminRules } from '/@/api/backend/auth/group'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { getArrayKey } from '/@/utils/common'
|
||||
import { useAdminInfo } from '/@/stores/adminInfo'
|
||||
import { uuid } from '/@/utils/random'
|
||||
|
||||
defineOptions({
|
||||
name: 'auth/group',
|
||||
})
|
||||
|
||||
const formRef = ref()
|
||||
const tableRef = ref()
|
||||
const { t } = useI18n()
|
||||
const adminInfo = useAdminInfo()
|
||||
|
||||
const baTable: baTableClass = new baTableClass(
|
||||
new baTableApi('/admin/auth.Group/'),
|
||||
{
|
||||
expandAll: true,
|
||||
dblClickNotEditColumn: [undefined],
|
||||
column: [
|
||||
{ type: 'selection', align: 'center' },
|
||||
{ label: t('auth.group.Group name'), prop: 'name', align: 'left', width: '200' },
|
||||
{ label: t('auth.group.jurisdiction'), prop: 'rules', align: 'center' },
|
||||
{
|
||||
label: t('State'),
|
||||
prop: 'status',
|
||||
align: 'center',
|
||||
render: 'tag',
|
||||
custom: { '0': 'danger', '1': 'success' },
|
||||
replaceValue: { '0': t('Disable'), '1': t('Enable') },
|
||||
},
|
||||
{ label: t('Update time'), prop: 'update_time', align: 'center', width: '160', render: 'datetime' },
|
||||
{ label: t('Create time'), prop: 'create_time', align: 'center', width: '160', render: 'datetime' },
|
||||
{ label: t('Operate'), align: 'center', width: '130', render: 'buttons', buttons: defaultOptButtons(['edit', 'delete']) },
|
||||
],
|
||||
},
|
||||
{
|
||||
defaultItems: {
|
||||
status: '1',
|
||||
},
|
||||
},
|
||||
{
|
||||
// 提交前
|
||||
onSubmit: ({ formEl, operate, items }) => {
|
||||
var items = cloneDeep(items)
|
||||
|
||||
items.rules = formRef.value.getCheckeds()
|
||||
|
||||
for (const key in items) {
|
||||
if (items[key] === null) {
|
||||
delete items[key]
|
||||
}
|
||||
}
|
||||
|
||||
operate = operate.replace(operate[0], operate[0].toLowerCase())
|
||||
|
||||
// 表单验证通过后执行的api请求操作
|
||||
let submitCallback = () => {
|
||||
baTable.form.submitLoading = true
|
||||
baTable.api
|
||||
.postData(operate, items)
|
||||
.then((res) => {
|
||||
baTable.onTableHeaderAction('refresh', {})
|
||||
baTable.form.submitLoading = false
|
||||
baTable.form.operateIds?.shift()
|
||||
if (baTable.form.operateIds!.length > 0) {
|
||||
baTable.toggleForm('Edit', baTable.form.operateIds)
|
||||
} else {
|
||||
baTable.toggleForm()
|
||||
}
|
||||
baTable.runAfter('onSubmit', { res })
|
||||
})
|
||||
.catch(() => {
|
||||
baTable.form.submitLoading = false
|
||||
})
|
||||
}
|
||||
|
||||
if (formEl) {
|
||||
baTable.form.ref = formEl
|
||||
formEl.validate((valid) => {
|
||||
if (valid) {
|
||||
submitCallback()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
submitCallback()
|
||||
}
|
||||
return false
|
||||
},
|
||||
// 双击编辑前
|
||||
onTableDblclick: ({ row }) => {
|
||||
return baTable.table.extend!.adminGroup.indexOf(row.id) === -1
|
||||
},
|
||||
},
|
||||
{
|
||||
getIndex: ({ res }) => {
|
||||
baTable.table.extend!.adminGroup = res.data.group
|
||||
let buttonsKey = getArrayKey(baTable.table.column, 'render', 'buttons')
|
||||
baTable.table.column[buttonsKey].buttons!.forEach((value: OptButton) => {
|
||||
value.display = (row) => {
|
||||
return res.data.group.indexOf(row.id) === -1
|
||||
}
|
||||
})
|
||||
},
|
||||
// 切换表单后
|
||||
toggleForm({ operate }) {
|
||||
if (operate == 'Add') {
|
||||
menuRuleTreeUpdate()
|
||||
}
|
||||
},
|
||||
// 编辑请求完成后
|
||||
requestEdit() {
|
||||
menuRuleTreeUpdate()
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
const menuRuleTreeUpdate = () => {
|
||||
getAdminRules().then((res) => {
|
||||
baTable.form.extend!.menuRules = res.data.list
|
||||
|
||||
if (baTable.form.items!.rules && baTable.form.items!.rules.length) {
|
||||
if (baTable.form.items!.rules.includes('*')) {
|
||||
let arr: number[] = []
|
||||
for (const key in baTable.form.extend!.menuRules) {
|
||||
arr.push(baTable.form.extend!.menuRules[key].id)
|
||||
}
|
||||
baTable.form.extend!.defaultCheckedKeys = arr
|
||||
} else {
|
||||
baTable.form.extend!.defaultCheckedKeys = baTable.form.items!.rules
|
||||
}
|
||||
} else {
|
||||
baTable.form.extend!.defaultCheckedKeys = []
|
||||
}
|
||||
baTable.form.extend!.treeKey = uuid()
|
||||
})
|
||||
}
|
||||
|
||||
provide('baTable', baTable)
|
||||
|
||||
onMounted(() => {
|
||||
baTable.table.ref = tableRef.value
|
||||
baTable.mount()
|
||||
baTable.getIndex()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
@ -1,168 +0,0 @@
|
||||
<template>
|
||||
<!-- 对话框表单 -->
|
||||
<el-dialog
|
||||
class="ba-operate-dialog"
|
||||
:close-on-click-modal="false"
|
||||
:model-value="['Add', 'Edit'].includes(baTable.form.operate!)"
|
||||
@close="baTable.toggleForm"
|
||||
:destroy-on-close="true"
|
||||
>
|
||||
<template #header>
|
||||
<div class="title" v-drag="['.ba-operate-dialog', '.el-dialog__header']" v-zoom="'.ba-operate-dialog'">
|
||||
{{ baTable.form.operate ? t(baTable.form.operate) : '' }}
|
||||
</div>
|
||||
</template>
|
||||
<el-scrollbar v-loading="baTable.form.loading" class="ba-table-form-scrollbar">
|
||||
<div
|
||||
class="ba-operate-form"
|
||||
:class="'ba-' + baTable.form.operate + '-form'"
|
||||
:style="config.layout.shrink ? '' : 'width: calc(100% - ' + baTable.form.labelWidth! / 2 + 'px)'"
|
||||
>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
@keyup.enter="baTable.onSubmit(formRef)"
|
||||
:model="baTable.form.items"
|
||||
:label-position="config.layout.shrink ? 'top' : 'right'"
|
||||
:label-width="baTable.form.labelWidth + 'px'"
|
||||
:rules="rules"
|
||||
v-if="!baTable.form.loading"
|
||||
>
|
||||
<FormItem
|
||||
:label="t('auth.group.Parent group')"
|
||||
v-model="baTable.form.items!.pid"
|
||||
type="remoteSelect"
|
||||
prop="pid"
|
||||
:input-attr="{
|
||||
params: { isTree: true },
|
||||
field: 'name',
|
||||
'remote-url': baTable.api.actionUrl.get('index'),
|
||||
placeholder: t('Click select'),
|
||||
}"
|
||||
/>
|
||||
|
||||
<el-form-item prop="name" :label="t('auth.group.Group name')">
|
||||
<el-input
|
||||
v-model="baTable.form.items!.name"
|
||||
type="string"
|
||||
:placeholder="t('Please input field', { field: t('auth.group.Group name') })"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="auth" :label="t('auth.group.jurisdiction')">
|
||||
<el-tree
|
||||
ref="treeRef"
|
||||
:key="baTable.form.extend!.treeKey"
|
||||
:default-checked-keys="baTable.form.extend!.defaultCheckedKeys"
|
||||
:default-expand-all="true"
|
||||
show-checkbox
|
||||
node-key="id"
|
||||
:props="{ children: 'children', label: 'title', class: treeNodeClass }"
|
||||
:data="baTable.form.extend!.menuRules"
|
||||
class="w100"
|
||||
/>
|
||||
</el-form-item>
|
||||
<FormItem
|
||||
:label="t('State')"
|
||||
v-model="baTable.form.items!.status"
|
||||
type="radio"
|
||||
:data="{ content: { '0': t('Disable'), '1': t('Enable') }, childrenAttr: { border: true } }"
|
||||
/>
|
||||
</el-form>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
<template #footer>
|
||||
<div :style="'width: calc(100% - ' + baTable.form.labelWidth! / 1.8 + 'px)'">
|
||||
<el-button @click="baTable.toggleForm('')">{{ t('Cancel') }}</el-button>
|
||||
<el-button v-blur :loading="baTable.form.submitLoading" @click="baTable.onSubmit(formRef)" type="primary">
|
||||
{{ baTable.form.operateIds && baTable.form.operateIds.length > 1 ? t('Save and edit next item') : t('Save') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, inject } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import type baTableClass from '/@/utils/baTable'
|
||||
import FormItem from '/@/components/formItem/index.vue'
|
||||
import type { FormInstance, ElTree, FormItemRule } from 'element-plus'
|
||||
import { buildValidatorData } from '/@/utils/validate'
|
||||
import type Node from 'element-plus/es/components/tree/src/model/node'
|
||||
import { useConfig } from '/@/stores/config'
|
||||
|
||||
const config = useConfig()
|
||||
const formRef = ref<FormInstance>()
|
||||
const treeRef = ref<InstanceType<typeof ElTree>>()
|
||||
const baTable = inject('baTable') as baTableClass
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
||||
name: [buildValidatorData({ name: 'required', title: t('auth.group.Group name') })],
|
||||
auth: [
|
||||
{
|
||||
required: true,
|
||||
validator: (rule: any, val: string, callback: Function) => {
|
||||
let ids = getCheckeds()
|
||||
if (ids.length <= 0) {
|
||||
return callback(new Error(t('Please select field', { field: t('auth.group.jurisdiction') })))
|
||||
}
|
||||
return callback()
|
||||
},
|
||||
},
|
||||
],
|
||||
pid: [
|
||||
{
|
||||
validator: (rule: any, val: string, callback: Function) => {
|
||||
if (!val) {
|
||||
return callback()
|
||||
}
|
||||
if (parseInt(val) == parseInt(baTable.form.items!.id)) {
|
||||
return callback(new Error(t('auth.group.The parent group cannot be the group itself')))
|
||||
}
|
||||
return callback()
|
||||
},
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
const getCheckeds = () => {
|
||||
return treeRef.value!.getCheckedKeys().concat(treeRef.value!.getHalfCheckedKeys())
|
||||
}
|
||||
|
||||
const treeNodeClass = (data: anyObj, node: Node) => {
|
||||
if (node.isLeaf) return ''
|
||||
let addClass = true
|
||||
for (const key in node.childNodes) {
|
||||
if (!node.childNodes[key].isLeaf) {
|
||||
addClass = false
|
||||
}
|
||||
}
|
||||
return addClass ? 'penultimate-node' : ''
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
getCheckeds,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
:deep(.penultimate-node) {
|
||||
.el-tree-node__children {
|
||||
padding-left: 60px;
|
||||
white-space: pre-wrap;
|
||||
line-height: 12px;
|
||||
.el-tree-node {
|
||||
display: inline-block;
|
||||
}
|
||||
.el-tree-node__content {
|
||||
padding-left: 5px !important;
|
||||
padding-right: 5px;
|
||||
.el-tree-node__expand-icon {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
666
ui/dasadmin/src/views/backend/auth/menuManagement/index.vue
Normal file
666
ui/dasadmin/src/views/backend/auth/menuManagement/index.vue
Normal file
@ -0,0 +1,666 @@
|
||||
<template>
|
||||
<div style="width: 98%; margin-left: 25px">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="6" style="padding: 2.2% 1.4%; border-right: 1px solid #eaebed">
|
||||
<el-input v-model="input1" size="large" placeholder="搜索" :suffix-icon="Search" style="width: 100%" />
|
||||
<el-tree
|
||||
style="max-width: 600px; margin-top: 2.2%; font-size: 16px"
|
||||
:data="menuData"
|
||||
:props="defaultProps"
|
||||
node-key="id"
|
||||
:load="loadNode"
|
||||
lazy
|
||||
@node-click="handleNodeClick"
|
||||
/>
|
||||
</el-col>
|
||||
<el-col :span="18" style="padding: 2.2% 1.4%">
|
||||
<el-container>
|
||||
<el-header style="display: flex; justify-content: space-between">
|
||||
<div>
|
||||
<el-input v-model="input2" size="large" placeholder="请输入菜单名称 " style="width: 220px; margin-right: 10px" />
|
||||
<el-button type="primary" size="large" :icon="Search" @click="clickQuery">查询</el-button>
|
||||
</div>
|
||||
<el-button type="primary" size="large" :icon="CirclePlusFilled" @click="fromAdd">新增</el-button>
|
||||
</el-header>
|
||||
<el-main>
|
||||
<el-table :data="tableData" style="width: 100%" :header-cell-style="{ color: '#333333', background: '#EFF0F1' }">
|
||||
<el-table-column prop="menuName" label="菜单名称" width="180" />
|
||||
<el-table-column prop="funParam" label="菜单路径" width="180" />
|
||||
<el-table-column prop="menuOrder" label="菜单排序" width="180" />
|
||||
<el-table-column prop="menuIcon" label="图标" width="180" />
|
||||
<!-- <el-table-column prop="name" label="状态" width="180">
|
||||
<el-switch v-model="switchValue" />
|
||||
</el-table-column> -->
|
||||
<el-table-column label="操作" width="180">
|
||||
<template #default="scope">
|
||||
<span style="color: #0064aa; cursor: pointer" @click="menuEdit(scope)">编辑</span>
|
||||
|
|
||||
<span style="color: #0064aa; cursor: pointer" @click="fromDelete(scope)">删除</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-main>
|
||||
<!-- <el-footer>
|
||||
<div style="display: flex; justify-content: right">
|
||||
<el-pagination
|
||||
v-model:current-page="currentPage4"
|
||||
v-model:page-size="pageSize4"
|
||||
:page-sizes="[5, 10, 15, 400]"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="400"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
</el-footer> -->
|
||||
</el-container>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<!-- 编辑弹框 -->
|
||||
<el-dialog v-model="visible" title="编辑菜单" width="500" :before-close="handleClose">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:inline="true"
|
||||
:model="fromUpDate"
|
||||
:rules="rules"
|
||||
style="padding: 24px 40px; font-size: 14px; line-height: 1.5; word-wrap: break-word; font-size: 20px"
|
||||
>
|
||||
<el-form-item label="菜单路径:" prop="funParam">
|
||||
<el-input v-model="fromUpDate.funParam" placeholder="" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="菜单名称:" prop="menuName">
|
||||
<el-input v-model="fromUpDate.menuName" placeholder="" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label=" 菜单图标:">
|
||||
<BaInput type="icon" v-model="fromUpDate.menuIcon" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label=" 菜单顺序:">
|
||||
<el-input-number :min="0" v-model="fromUpDate.menuOrder" placeholder="" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label=" 菜单动作:">
|
||||
<el-radio-group v-model="fromUpDate.funType" size="large">
|
||||
<el-radio-button label="原页面" value="1" />
|
||||
<el-radio-button label="新窗口" value="2" />
|
||||
<el-radio-button label="编辑页面" value="3" />
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label=" 动作参数:">
|
||||
<el-input v-model="fromUpDate.funParam" :disabled="true">
|
||||
<template #append>
|
||||
<el-icon style="cursor: pointer; font-size: 23px" @click="clickParam"><Setting /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label=" 菜单权限:">
|
||||
<el-select v-model="fromUpDate.authorityId" placeholder="选择菜单权限" style="width: 240px">
|
||||
<el-option v-for="item in allPermissionData" :key="item.index" :label="item.authorityName" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="visible = false"> 取消 </el-button>
|
||||
<el-button type="primary" @click="onSubmit">提交</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 编辑页面的动作参数弹框 -->
|
||||
<el-dialog v-model="visibleParam" title="选择页面" width="500" :before-close="handleCloseParam">
|
||||
<el-table :data="ParamTableData" style="width: 100%">
|
||||
<el-table-column label="页面名称" width="180" />
|
||||
<el-table-column label="页面路径" width="180" />
|
||||
</el-table>
|
||||
<
|
||||
<el-form
|
||||
ref="formActionRef"
|
||||
:inline="true"
|
||||
:model="fromUpDate"
|
||||
:rules="rules"
|
||||
style="padding: 24px 40px; font-size: 14px; line-height: 1.5; word-wrap: break-word; font-size: 20px"
|
||||
>
|
||||
<el-form-item label="页面路径:" prop="funParam">
|
||||
<el-input v-model="fromUpDate.funParam" placeholder="" clearable />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="visibleParam = false">取消</el-button>
|
||||
<el-button type="primary" @click="visibleParam1"> 确定 </el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<!-- 新增弹框 -->
|
||||
<el-dialog v-model="visibleAdd" title="新增菜单" width="500" :before-close="handleCloseAdd">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:inline="true"
|
||||
:model="formInlineAdd"
|
||||
:rules="rules"
|
||||
style="padding: 24px 40px; font-size: 14px; line-height: 1.5; word-wrap: break-word; font-size: 20px"
|
||||
>
|
||||
<el-form-item label="菜单路径:" prop="funParam">
|
||||
<el-input v-model="formInlineAdd.funParam" placeholder="" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="菜单名称:" prop="menuName">
|
||||
<el-input v-model="formInlineAdd.menuName" placeholder="" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label=" 菜单图标:">
|
||||
<BaInput type="icon" v-model="formInlineAdd.menuIcon" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label=" 菜单顺序:">
|
||||
<el-input-number :min="0" v-model="formInlineAdd.menuOrder" placeholder="" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label=" 菜单动作:">
|
||||
<el-radio-group v-model="formInlineAdd.funType" size="large">
|
||||
<el-radio-button label="原页面" value="1" />
|
||||
<el-radio-button label="新窗口" value="2" />
|
||||
<el-radio-button label="编辑页面" value="3" />
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label=" 动作参数:">
|
||||
<el-input v-model="formInlineAdd.funParam" :disabled="true">
|
||||
<template #append>
|
||||
<el-icon style="cursor: pointer; font-size: 23px" @click="clickParam"><Setting /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label=" 菜单权限:">
|
||||
<el-select v-model="formInlineAdd.authorityId" placeholder="选择菜单权限" style="width: 240px">
|
||||
<el-option v-for="item in allPermissionData" :key="item.index" :label="item.authorityName" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="visibleAdd = false"> 取消 </el-button>
|
||||
<el-button type="primary" @click="addOnSubmit">提交</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<!-- 新增页面动作参数弹框 -->
|
||||
<el-dialog v-model="visibleParam" title="选择页面" width="500" :before-close="handleCloseParam">
|
||||
<el-table :data="ParamTableData" style="width: 100%">
|
||||
<el-table-column label="页面名称" width="180" />
|
||||
<el-table-column label="页面路径" width="180" />
|
||||
</el-table>
|
||||
<el-form
|
||||
ref="formActionRef"
|
||||
:inline="true"
|
||||
:model="formInlineAdd"
|
||||
:rules="rules"
|
||||
style="padding: 24px 40px; font-size: 14px; line-height: 1.5; word-wrap: break-word; font-size: 20px"
|
||||
>
|
||||
<el-form-item label="页面路径:" prop="funParam">
|
||||
<el-input v-model="formInlineAdd.funParam" placeholder="" clearable />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="visibleParam = false">取消</el-button>
|
||||
<el-button type="primary" @click="visibleParam1"> 确定 </el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<!-- 删除确认弹框 -->
|
||||
<el-dialog v-model="dialogVisibleDelete" title="操作提示" width="500" :before-close="handleCloseDelete">
|
||||
<span>确定是否删除?</span>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="dialogVisibleDelete = false">取消</el-button>
|
||||
<el-button type="primary" @click="dialogVisibleDelete = false"> 确定 </el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { Search, CirclePlusFilled, Setting } from '@element-plus/icons-vue'
|
||||
import { useAdminInfo } from '/@/stores/adminInfo'
|
||||
import { menusQuery, menusUpdate, menuDelete, menuAdd, menusTree, allPermissionQuery } from '/@/api/backend'
|
||||
import { ElMessage, ElMessageBox, FormRules } from 'element-plus'
|
||||
import BaInput from '/@/components/baInput/index.vue'
|
||||
import type Node from 'element-plus/es/components/tree/src/model/node'
|
||||
|
||||
const adminInfo = useAdminInfo()
|
||||
console.log(adminInfo, 'adminInfo')
|
||||
|
||||
// 树查询
|
||||
const menuData = ref()
|
||||
const fromParameter = {
|
||||
parentMenuId: adminInfo.orgid,
|
||||
recursive: true,
|
||||
}
|
||||
interface menusTree {
|
||||
rows?: any[]
|
||||
}
|
||||
const RyMenusTreeQuery = () => {
|
||||
menusTree(fromParameter).then((res) => {
|
||||
if (res.code == 200) {
|
||||
console.log(res, 'res111')
|
||||
menuData.value = res.data
|
||||
} else {
|
||||
ElMessage.error({
|
||||
message: res.msg,
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
RyMenusTreeQuery(), allPermission()
|
||||
})
|
||||
|
||||
interface Tree {
|
||||
name: string
|
||||
leaf?: boolean
|
||||
}
|
||||
|
||||
const props = {
|
||||
label: 'name',
|
||||
children: 'zones',
|
||||
isLeaf: 'leaf',
|
||||
}
|
||||
|
||||
const loadNode = (node: Node, resolve: (data: Tree[]) => void) => {
|
||||
if (node.level === 0) {
|
||||
}
|
||||
if (node.level > 1) return resolve([])
|
||||
|
||||
setTimeout(() => {
|
||||
const data: Tree[] = []
|
||||
|
||||
resolve(data)
|
||||
}, 500)
|
||||
}
|
||||
// 菜单搜索查询
|
||||
const input2 = ref('')
|
||||
const queryListData = {
|
||||
menuName: '',
|
||||
}
|
||||
const clickQuery = () => {
|
||||
queryListData.menuName = input2.value
|
||||
queryMenuMethod(queryListData)
|
||||
}
|
||||
// 菜单查询
|
||||
const input1 = ref('')
|
||||
const switchValue = ref(true)
|
||||
interface Tree {
|
||||
authorityId: number
|
||||
funParam: string
|
||||
funType: number
|
||||
id: number
|
||||
menuIcon: string
|
||||
menuName: string
|
||||
menuOrder: number
|
||||
parentMenuId: number
|
||||
revision: number
|
||||
}
|
||||
const fromDataId = ref()
|
||||
const tableData = ref()
|
||||
const handleNodeClick = (data: Tree) => {
|
||||
console.log(data, '1111')
|
||||
fromDataId.value = data.id
|
||||
const queryData = {
|
||||
parentMenuId: data.id,
|
||||
recursive: false,
|
||||
}
|
||||
console.log(queryData, 'queryData')
|
||||
|
||||
queryMenuMethod(queryData)
|
||||
}
|
||||
// 查询接口
|
||||
const queryMenuMethod = (data: any) => {
|
||||
menusQuery(data).then((res) => {
|
||||
console.log(res, 888)
|
||||
|
||||
if (res.code == 200) {
|
||||
console.log(res.rows, '菜单页面')
|
||||
tableData.value = res.rows
|
||||
} else {
|
||||
ElMessage.error({
|
||||
message: res.msg,
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const defaultProps = {
|
||||
children: 'children',
|
||||
label: 'menuName',
|
||||
}
|
||||
|
||||
// 菜单
|
||||
const visible = ref(false)
|
||||
const menuEdit = (data: any) => {
|
||||
console.log(data.row, 'data1111111')
|
||||
visible.value = true
|
||||
fromUpDate.id = data.row.id
|
||||
fromUpDate.revision = data.row.revision
|
||||
fromUpDate.menuName = data.row.menuName
|
||||
fromUpDate.menuOrder = data.row.menuOrder
|
||||
fromUpDate.menuIcon = data.row.menuIcon
|
||||
fromUpDate.funType = data.row.funType
|
||||
fromUpDate.funParam = data.row.funParam
|
||||
fromUpDate.authorityId = data.row.authorityId
|
||||
}
|
||||
|
||||
const handleClose = (done: () => void) => {
|
||||
visible.value = false
|
||||
}
|
||||
|
||||
const handleCloseAdd = () => {
|
||||
visibleAdd.value = false
|
||||
}
|
||||
|
||||
const handleCloseParam = (done: () => void) => {
|
||||
visibleParam.value = false
|
||||
}
|
||||
|
||||
interface RuleForm {
|
||||
menuName: string | undefined
|
||||
menuOrder: number
|
||||
menuIcon: string
|
||||
funType: number
|
||||
funParam: string | undefined
|
||||
authorityId: string
|
||||
parentMenuId: string
|
||||
revision: number
|
||||
createdBy: string
|
||||
createdTime: number
|
||||
updatedBy: string
|
||||
updatedTime: number
|
||||
}
|
||||
|
||||
// const formInline = reactive<RuleForm>({
|
||||
// menuName: undefined,
|
||||
// menuOrder: 0,
|
||||
// menuIcon: '',
|
||||
// funType: 1,
|
||||
// funParam: undefined,
|
||||
// authorityId: '',
|
||||
// parentMenuId: '',
|
||||
// revision: 1,
|
||||
// createdBy: 'aaa',
|
||||
// createdTime: 123456,
|
||||
// updatedBy: 'aaa',
|
||||
// updatedTime: 12345,
|
||||
// })
|
||||
|
||||
const formRef = ref()
|
||||
const formActionRef = ref()
|
||||
|
||||
const rules = reactive<FormRules<RuleForm>>({
|
||||
funParam: [
|
||||
{
|
||||
required: true,
|
||||
message: '菜单路径不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
menuName: [
|
||||
{
|
||||
required: true,
|
||||
message: '菜单名称不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
// 动作参数
|
||||
interface RyReplaceFields {
|
||||
children: string
|
||||
title: string
|
||||
key: string
|
||||
value: string
|
||||
}
|
||||
|
||||
// 菜单修改
|
||||
const fromUpDate = reactive({
|
||||
id: '',
|
||||
menuName: '',
|
||||
menuOrder: 0,
|
||||
menuIcon: '',
|
||||
funType: 0,
|
||||
funParam: '',
|
||||
authorityId: '',
|
||||
parentMenuId: '',
|
||||
revision: 1,
|
||||
})
|
||||
|
||||
interface menusUpdate {
|
||||
// rows?: any[]
|
||||
}
|
||||
const onSubmit = () => {
|
||||
console.log(fromUpDate, 'fromUpDate')
|
||||
formRef.value.validate((valid: any) => {
|
||||
if (valid) {
|
||||
menusUpdate(fromUpDate).then((res) => {
|
||||
console.log(res, '更新')
|
||||
if (res.code == 200) {
|
||||
ElMessage({
|
||||
message: res.msg,
|
||||
type: 'success',
|
||||
})
|
||||
} else {
|
||||
ElMessage.error({
|
||||
message: res.msg,
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
})
|
||||
debugger
|
||||
|
||||
visible.value = false
|
||||
const queryData2 = {
|
||||
parentMenuId: fromDataId.value,
|
||||
recursive: false,
|
||||
}
|
||||
console.log(queryData2, 'queryData2')
|
||||
|
||||
queryMenuMethod(queryData2)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 菜单权限
|
||||
const allPermissionData = ref()
|
||||
// 菜单权限
|
||||
const allPermission = () => {
|
||||
allPermissionQuery().then((res) => {
|
||||
console.log(res.data, 'resdata')
|
||||
|
||||
allPermissionData.value = res.data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除
|
||||
const fromDeleteData = reactive({
|
||||
id: '',
|
||||
})
|
||||
interface fromDelete {
|
||||
row?: any[]
|
||||
}
|
||||
// interface menuDelete {
|
||||
// rows?: any[]
|
||||
// }
|
||||
const fromDelete = (data: any) => {
|
||||
dialogVisibleDelete.value = true
|
||||
fromDeleteData.id = data.row.id
|
||||
menuDelete(fromDeleteData).then((res) => {
|
||||
console.log(res, data, '删除')
|
||||
if (res.code == 200) {
|
||||
setTimeout(() => {
|
||||
ElMessage({
|
||||
message: res.msg,
|
||||
type: 'success',
|
||||
})
|
||||
}, 1000)
|
||||
} else {
|
||||
ElMessage.error({
|
||||
message: res.msg,
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 删除提示弹框
|
||||
const dialogVisibleDelete = ref(false)
|
||||
|
||||
const handleCloseDelete = (done: () => void) => {
|
||||
ElMessageBox.confirm('确定是否删除?')
|
||||
.then(() => {
|
||||
done()
|
||||
})
|
||||
.catch(() => {
|
||||
// catch error
|
||||
})
|
||||
}
|
||||
// 菜单新增
|
||||
const visibleAdd = ref(false)
|
||||
|
||||
const formInlineAdd = reactive<RuleForm>({
|
||||
menuName: '',
|
||||
menuOrder: 0,
|
||||
menuIcon: '',
|
||||
funType: 1,
|
||||
funParam: '',
|
||||
authorityId: '',
|
||||
parentMenuId: '',
|
||||
revision: 1,
|
||||
createdBy: 'aaa',
|
||||
createdTime: 123456,
|
||||
updatedBy: 'aaa',
|
||||
updatedTime: 12345,
|
||||
})
|
||||
|
||||
// interface menuAdd {
|
||||
// res?: any[]
|
||||
// }
|
||||
const fromAdd = () => {
|
||||
visibleAdd.value = true
|
||||
formInlineAdd.menuName = ''
|
||||
formInlineAdd.menuOrder = 0
|
||||
formInlineAdd.menuIcon = ''
|
||||
formInlineAdd.funType = 1
|
||||
formInlineAdd.funParam = ''
|
||||
formInlineAdd.authorityId = ''
|
||||
formInlineAdd.parentMenuId = ''
|
||||
formInlineAdd.revision = 1
|
||||
formInlineAdd.createdBy = 'aaa'
|
||||
formInlineAdd.createdTime = 123456
|
||||
formInlineAdd.updatedBy = 'aaa'
|
||||
formInlineAdd.updatedTime = 12345
|
||||
}
|
||||
const addOnSubmit = () => {
|
||||
formInlineAdd.parentMenuId = fromDataId.value
|
||||
console.log(formInlineAdd, 'formInlineAdd')
|
||||
formRef.value.validate((valid: any) => {
|
||||
if (valid) {
|
||||
menuAdd(formInlineAdd).then((res: any) => {
|
||||
console.log(res, '增加')
|
||||
if (res.code == 200) {
|
||||
ElMessage({
|
||||
message: res.msg,
|
||||
type: 'success',
|
||||
})
|
||||
} else {
|
||||
ElMessage.error({
|
||||
message: res.msg,
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
})
|
||||
const queryData = {
|
||||
parentMenuId: fromDataId.value,
|
||||
recursive: true,
|
||||
}
|
||||
console.log(queryData, 666)
|
||||
|
||||
queryMenuMethod(queryData)
|
||||
visibleAdd.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 显示
|
||||
const visibleParam = ref(false)
|
||||
const clickParam = () => {
|
||||
visibleParam.value = true
|
||||
}
|
||||
|
||||
//
|
||||
const ParamTableData = reactive([
|
||||
{
|
||||
name: '页面名称',
|
||||
},
|
||||
{
|
||||
name: '页面路径',
|
||||
},
|
||||
])
|
||||
|
||||
const visibleParam1 = () => {
|
||||
formActionRef.value.validate((valid: any) => {
|
||||
if (valid) {
|
||||
visibleParam.value = false
|
||||
} else {
|
||||
visibleParam.value = true
|
||||
}
|
||||
})
|
||||
}
|
||||
// 分页
|
||||
const currentPage4 = ref(4)
|
||||
const pageSize4 = ref(100)
|
||||
|
||||
const handleSizeChange = (val: number) => {
|
||||
console.log(`${val} items per page`)
|
||||
}
|
||||
const handleCurrentChange = (val: number) => {
|
||||
console.log(`current page: ${val}`)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.el-row {
|
||||
margin-bottom: 20px;
|
||||
width: 99%;
|
||||
height: 823px;
|
||||
}
|
||||
.el-row:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.el-col {
|
||||
// border-radius: 4px;
|
||||
background-color: #fff;
|
||||
}
|
||||
#el-id-6028-4 {
|
||||
position: absolute;
|
||||
top: 500px;
|
||||
}
|
||||
.menu_popover {
|
||||
z-index: 2009;
|
||||
position: absolute;
|
||||
left: 500px;
|
||||
top: 600px;
|
||||
display: none;
|
||||
}
|
||||
.el-input-group__append {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
378
ui/dasadmin/src/views/backend/auth/userManagement/index.vue
Normal file
378
ui/dasadmin/src/views/backend/auth/userManagement/index.vue
Normal file
@ -0,0 +1,378 @@
|
||||
<template>
|
||||
<!-- 用户 -->
|
||||
<div style="margin-left: 25px">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="6" style="padding: 2.2% 1.4%; border-right: 1px solid #eaebed">
|
||||
<el-input v-model="input1" size="large" placeholder="搜索" :suffix-icon="Search" style="width: 100%" />
|
||||
<el-tree style="max-width: 600px; margin-top: 2.2%" :data="userData" :props="defaultProps" @node-click="handleNodeClick" />
|
||||
</el-col>
|
||||
<el-col :span="18" style="padding: 2.2% 1.4%">
|
||||
<el-container>
|
||||
<el-header style="display: flex; justify-content: space-between">
|
||||
<div>
|
||||
<el-input v-model="input2" size="large" style="width: 220px; margin-right: 10px" />
|
||||
<el-button type="primary" size="large" :icon="Search" @click="userFromQuery">查询</el-button>
|
||||
</div>
|
||||
<el-button type="primary" size="large" :icon="CirclePlusFilled" @click="addUserFromData">新增</el-button>
|
||||
</el-header>
|
||||
<el-main>
|
||||
<el-table
|
||||
ref="multipleTableRef"
|
||||
:data="tableData"
|
||||
style="width: 100%"
|
||||
:header-cell-style="{ color: '#333333', background: '#EFF0F1' }"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="180" />
|
||||
<el-table-column property="account" label="账户名称" width="200" />
|
||||
|
||||
<el-table-column property="userName" label="账户中文名" width="200" />
|
||||
<!-- <el-table-column property="address" label="是否禁用" /> -->
|
||||
<!-- <el-table-column property="updatedTime" label="令牌超时" /> -->
|
||||
<el-table-column property="address" label="操作">
|
||||
<template #default="scope">
|
||||
<span style="color: #0064aa; cursor: pointer" @click="viewUsers(scope)">查看 </span>
|
||||
<span style="color: #0064aa"> | </span>
|
||||
<span style="color: #0064aa; cursor: pointer" @click="userFromDelete(scope)"> 删除 </span>
|
||||
<!-- <span style="color: #0064aa"> | </span>
|
||||
<span style="color: #0064aa"> 门户 </span>
|
||||
<span style="color: #0064aa"> | </span>
|
||||
<span style="color: #0064aa"> 密码</span> -->
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-main>
|
||||
<el-footer>
|
||||
<div style="display: flex; justify-content: right">
|
||||
<el-pagination
|
||||
v-model:current-page="currentPage4"
|
||||
v-model:page-size="pageSize4"
|
||||
:page-sizes="[100, 200, 300, 400]"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="400"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
</el-footer>
|
||||
</el-container>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<!-- 用户新增页面 -->
|
||||
<el-dialog v-model="visibleParam" title="新增账户" width="500" :before-close="handleCloseParam">
|
||||
<el-form
|
||||
:inline="true"
|
||||
:model="formUserAdd"
|
||||
style="padding: 24px 40px; font-size: 14px; line-height: 1.5; word-wrap: break-word; font-size: 20px"
|
||||
>
|
||||
<el-form-item label="账户名称:" prop="account">
|
||||
<el-input v-model="formUserAdd.account" placeholder="" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="密码: ">
|
||||
<el-input v-model="formUserAdd.password" placeholder="" type="password" show-password clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="职员名称:" prop="userName">
|
||||
<el-input v-model="formUserAdd.userName" placeholder="" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="职员邮箱:" prop="email">
|
||||
<el-input v-model="formUserAdd.email" placeholder="" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="职员联系电话:" prop="phone">
|
||||
<el-input v-model="formUserAdd.phone" placeholder="" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="所属机构ID:" prop="orgId">
|
||||
<el-input v-model="formUserAdd.orgId" placeholder="" clearable />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="visibleParam = false"> 取消 </el-button>
|
||||
<el-button type="primary" @click="addOnSubmit">提交</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<!-- 用户修改页面 -->
|
||||
<el-dialog v-model="visibleParamUpData" title="查看账户" width="500" :before-close="handleCloseParamUp">
|
||||
<el-form
|
||||
:inline="true"
|
||||
:model="formUserUpData"
|
||||
style="padding: 24px 40px; font-size: 14px; line-height: 1.5; word-wrap: break-word; font-size: 20px"
|
||||
>
|
||||
<el-form-item label="账户名称:" prop="account">
|
||||
<el-input v-model="formUserUpData.account" placeholder="" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="密码: " prop="password">
|
||||
<el-input v-model="formUserUpData.password" placeholder="" type="password" show-password clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="职员名称:" prop="userName">
|
||||
<el-input v-model="formUserUpData.userName" placeholder="" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="职员邮箱:" prop="email">
|
||||
<el-input v-model="formUserUpData.email" placeholder="" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="职员联系电话:" prop="phone">
|
||||
<el-input v-model="formUserUpData.phone" placeholder="" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="所属机构ID:" prop="orgId">
|
||||
<el-input v-model="formUserUpData.orgId" placeholder="" clearable />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="visibleParamUpData = false"> 取消 </el-button>
|
||||
<el-button type="primary" @click="upDataOnSubmit">提交</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<!-- 删除确认弹框 -->
|
||||
<el-dialog v-model="userDeleteDialog" title="操作提示" width="500" :before-close="handleCloseDelete">
|
||||
<span>确定是否删除?</span>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="userDeleteDialog = false">取消</el-button>
|
||||
<el-button type="primary" @click="userDeleteDialog1"> 确定 </el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { Search, CirclePlusFilled } from '@element-plus/icons-vue'
|
||||
import { userQuery, userUpdate, userDelete, userAdd, userList } from '/@/api/backend'
|
||||
import { ElTable, ElMessage } from 'element-plus'
|
||||
import { useAdminInfo } from '/@/stores/adminInfo'
|
||||
import { fa } from 'element-plus/es/locales.mjs'
|
||||
import { values } from 'lodash-es'
|
||||
const adminInfo = useAdminInfo()
|
||||
const input1 = ref('')
|
||||
const input2 = ref('')
|
||||
interface Tree {
|
||||
label: string
|
||||
children?: Tree[]
|
||||
id: string
|
||||
}
|
||||
|
||||
// 用户左边树
|
||||
const treeQuery = reactive({
|
||||
parentOrgId: adminInfo.orgid,
|
||||
recursive: true,
|
||||
})
|
||||
|
||||
const userData = ref()
|
||||
|
||||
const getTree = () => {
|
||||
console.log(treeQuery, 'treeQuery')
|
||||
|
||||
userList(treeQuery).then((res) => {
|
||||
console.log(res, '树')
|
||||
userData.value = res.data
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getTree()
|
||||
})
|
||||
|
||||
const formQuery = reactive({
|
||||
orgId: '',
|
||||
recursive: false,
|
||||
})
|
||||
|
||||
const treeId = ref()
|
||||
|
||||
const handleNodeClick = (data: Tree) => {
|
||||
console.log(data.id, 'data')
|
||||
|
||||
treeId.value = data.id
|
||||
formQuery.orgId = data.id
|
||||
console.log(formQuery, '闵1')
|
||||
|
||||
RyUserQuery(formQuery)
|
||||
}
|
||||
|
||||
const defaultProps = {
|
||||
children: 'children',
|
||||
label: 'name',
|
||||
}
|
||||
|
||||
// 用户查询
|
||||
interface userQuery {
|
||||
// rows?: any[]
|
||||
}
|
||||
const tableData = ref()
|
||||
const RyUserQuery = (data: any) => {
|
||||
userQuery(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
console.log(res.rows, 'res111')
|
||||
tableData.value = res.rows
|
||||
} else {
|
||||
ElMessage.error({
|
||||
message: res.msg,
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
interface User {
|
||||
date: string
|
||||
name: string
|
||||
address: string
|
||||
}
|
||||
|
||||
const multipleTableRef = ref<InstanceType<typeof ElTable>>()
|
||||
const multipleSelection = ref<User[]>([])
|
||||
|
||||
const handleSelectionChange = (val: User[]) => {
|
||||
multipleSelection.value = val
|
||||
}
|
||||
|
||||
// 用户搜索
|
||||
const formQuery1 = reactive({
|
||||
userName: '',
|
||||
})
|
||||
const userFromQuery = () => {
|
||||
formQuery1.userName = input2.value
|
||||
console.log(formQuery1, '闵2')
|
||||
|
||||
RyUserQuery(formQuery1)
|
||||
}
|
||||
|
||||
// 用户增加
|
||||
const visibleParam = ref(false)
|
||||
interface RuleUser {
|
||||
account: string
|
||||
password: string
|
||||
userName: string
|
||||
email: string
|
||||
phone: string
|
||||
orgId: string
|
||||
}
|
||||
const formUserAdd = reactive({
|
||||
account: '',
|
||||
password: '',
|
||||
userName: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
orgId: '',
|
||||
})
|
||||
|
||||
const addUserFromData = () => {
|
||||
visibleParam.value = true
|
||||
formUserAdd.account = ''
|
||||
formUserAdd.password = ''
|
||||
formUserAdd.userName = ''
|
||||
formUserAdd.email = ''
|
||||
formUserAdd.phone = ''
|
||||
formUserAdd.orgId = ''
|
||||
}
|
||||
|
||||
const handleCloseParam = (data: any) => {
|
||||
visibleParam.value = false
|
||||
console.log(data)
|
||||
}
|
||||
|
||||
const addOnSubmit = () => {
|
||||
visibleParam.value = false
|
||||
userAdd(formUserAdd).then((res) => {
|
||||
console.log(res, '新增')
|
||||
})
|
||||
formQuery1.userName = input2.value
|
||||
RyUserQuery(formQuery1)
|
||||
}
|
||||
|
||||
// 页面修改
|
||||
const visibleParamUpData = ref(false)
|
||||
|
||||
const formUserUpData = reactive({ id: '', account: '', password: '', userName: '', email: '', phone: '', orgId: '' })
|
||||
const viewUsers = (data: any) => {
|
||||
console.log(data, '页面修改数据')
|
||||
visibleParamUpData.value = true
|
||||
formUserUpData.id = data.row.id
|
||||
formUserUpData.account = data.row.account
|
||||
formUserUpData.password = data.row.password
|
||||
formUserUpData.userName = data.row.userName
|
||||
formUserUpData.email = data.row.email
|
||||
formUserUpData.phone = data.row.phone
|
||||
formUserUpData.orgId = data.row.orgId
|
||||
}
|
||||
const upDataOnSubmit = () => {
|
||||
console.log(formUserUpData, 'formUserUpData')
|
||||
|
||||
userUpdate(formUserUpData).then((res) => {
|
||||
console.log(res, '修改成功')
|
||||
})
|
||||
visibleParamUpData.value = false
|
||||
}
|
||||
|
||||
const handleCloseParamUp = () => {
|
||||
visibleParamUpData.value = false
|
||||
}
|
||||
|
||||
// 页面删除
|
||||
const userListDelete = reactive({
|
||||
id: '',
|
||||
})
|
||||
const userFromDelete = (data: any) => {
|
||||
userDeleteDialog.value = true
|
||||
userListDelete.id = data.row.id
|
||||
userDelete(userListDelete).then((res) => {
|
||||
if (res.code == 200) {
|
||||
setTimeout(() => {
|
||||
ElMessage({
|
||||
message: res.msg,
|
||||
type: 'success',
|
||||
})
|
||||
}, 1000)
|
||||
} else {
|
||||
ElMessage.error({
|
||||
message: res.msg,
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const userDeleteDialog = ref(false)
|
||||
|
||||
const handleCloseDelete = () => {
|
||||
userDeleteDialog.value = false
|
||||
}
|
||||
|
||||
const userDeleteDialog1 = () => {
|
||||
userDeleteDialog.value = false
|
||||
formQuery.orgId = treeId.value
|
||||
console.log(formQuery, 'formQuery')
|
||||
RyUserQuery(formQuery)
|
||||
}
|
||||
|
||||
// 分页
|
||||
const currentPage4 = ref(4)
|
||||
const pageSize4 = ref(100)
|
||||
|
||||
const handleSizeChange = (val: number) => {
|
||||
console.log(`${val} items per page`)
|
||||
}
|
||||
const handleCurrentChange = (val: number) => {
|
||||
console.log(`current page: ${val}`)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.el-row {
|
||||
margin-bottom: 20px;
|
||||
width: 99%;
|
||||
height: 823px;
|
||||
}
|
||||
.el-row:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.el-col {
|
||||
// border-radius: 4px;
|
||||
background-color: #fff;
|
||||
}
|
||||
</style>
|
@ -188,13 +188,13 @@ const onSubmit = () => {
|
||||
id: res.data.sysUser.id,
|
||||
username: res.data.sysUser.account,
|
||||
nickname: res.data.sysUser.userName,
|
||||
orgid: res.data.sysUser.orgId,
|
||||
avatar: '',
|
||||
last_login_time: '',
|
||||
token: res.data.token,
|
||||
refresh_token: res.data.refershToken,
|
||||
// 是否是superAdmin,用于判定是否显示终端按钮等,不做任何权限判断
|
||||
super: false,
|
||||
orgid:res.data.sysUser.orgId
|
||||
})
|
||||
router.push({ path: adminBaseRoutePath })
|
||||
} else {
|
||||
@ -213,8 +213,6 @@ const onSubmit = () => {
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.login-div {
|
||||
}
|
||||
.switch-language {
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
|
1
ui/dasadmin/types/global.d.ts
vendored
1
ui/dasadmin/types/global.d.ts
vendored
@ -23,6 +23,7 @@ interface ApiResponse<T = any> {
|
||||
data: T
|
||||
msg: string
|
||||
time: number
|
||||
rows: object
|
||||
}
|
||||
|
||||
type ApiPromise<T = any> = Promise<ApiResponse<T>>
|
||||
|
Loading…
Reference in New Issue
Block a user