菜单和用户页面
This commit is contained in:
commit
760c86b649
@ -26,7 +26,7 @@ public class CaptchaUtils {
|
||||
public static boolean checkVerificationCode(String uuid, String codeAnswer, AdminRedisTemplate adminRedisTemplate){
|
||||
String verifyKey = AdminConstant.CAPTCHA_CODE_KEY + uuid;
|
||||
String answer = adminRedisTemplate.get(verifyKey);
|
||||
return StrUtil.isNotEmpty(codeAnswer) && answer != null && answer.equals(codeAnswer);
|
||||
return StrUtil.isNotEmpty(codeAnswer) && answer != null && answer.equalsIgnoreCase(codeAnswer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.das.common.config;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
@ -15,7 +15,10 @@ import org.springframework.stereotype.Component;
|
||||
@Setter
|
||||
@ConfigurationProperties(prefix = "sa-token")
|
||||
public class SaTokenProperties {
|
||||
|
||||
/**
|
||||
* 是否开启Sa-Token全局拦截器,默认为true
|
||||
*/
|
||||
private boolean enabled=true;
|
||||
/**
|
||||
* token 请求头
|
||||
*/
|
||||
|
19
das/src/main/java/com/das/common/config/SysAuthorityIds.java
Normal file
19
das/src/main/java/com/das/common/config/SysAuthorityIds.java
Normal file
@ -0,0 +1,19 @@
|
||||
package com.das.common.config;
|
||||
|
||||
/**
|
||||
* 系统权限ID定义列表
|
||||
*/
|
||||
public class SysAuthorityIds {
|
||||
/**
|
||||
* 系统管理权限
|
||||
*/
|
||||
public static final Long SYS_AUTHORITY_ID_ADMIN = 101L;
|
||||
/**
|
||||
* 设备台账维护权限
|
||||
*/
|
||||
public static final Long SYS_AUTHORITY_ID_DEVICE_MGR = 102L;
|
||||
/**
|
||||
* 设备台账浏览权限
|
||||
*/
|
||||
public static final Long SYS_AUTHORITY_ID_DEVICE_VIEW = 103L;
|
||||
}
|
@ -32,6 +32,11 @@ public class MybatisPlusConfig {
|
||||
return interceptor;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor() {
|
||||
return new OptimisticLockerInnerInterceptor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Id 生成器-->
|
||||
* 特殊的一些类使用
|
||||
|
@ -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());
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.das.common.constant;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
@ -10,7 +8,6 @@ import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@ -25,7 +22,7 @@ public class BaseEntity implements Serializable {
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@TableField("created_by")
|
||||
private Long createdBy;
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
@ -40,7 +37,7 @@ public class BaseEntity implements Serializable {
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@TableField("updated_by")
|
||||
private Long updatedBy;
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
|
@ -3,13 +3,16 @@ package com.das.common.exceptions;
|
||||
import com.das.common.result.IResultCode;
|
||||
import com.das.common.result.ResultCode;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* @author chenhaojie
|
||||
* @Description
|
||||
*/
|
||||
public class EasyExcelException extends RuntimeException {
|
||||
|
||||
private final long serialVersionUID = 1L;
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int code = ResultCode.FAILURE.getCode();
|
||||
|
||||
|
@ -4,13 +4,16 @@ 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 {
|
||||
|
||||
private final long serialVersionUID = 1L;
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int code = ResultCode.FAILURE.getCode();
|
||||
|
||||
@ -22,43 +25,43 @@ public class OssException extends RuntimeException {
|
||||
|
||||
public OssException(String msg) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
this.setMsg(msg);
|
||||
}
|
||||
|
||||
public OssException(IResultCode resultCode, String msg) {
|
||||
super(msg);
|
||||
this.code = resultCode.getCode();
|
||||
this.msg = msg;
|
||||
this.setCode(resultCode.getCode());
|
||||
this.setMsg(msg);
|
||||
}
|
||||
|
||||
public OssException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
this.msg = msg;
|
||||
this.setMsg(msg);
|
||||
}
|
||||
|
||||
public OssException(IResultCode resultCode, String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
this.code = resultCode.getCode();
|
||||
this.msg = msg;
|
||||
this.setCode(resultCode.getCode());
|
||||
this.setMsg(msg);
|
||||
}
|
||||
|
||||
public OssException(Throwable cause) {
|
||||
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;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,19 @@ 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 {
|
||||
|
||||
private final long serialVersionUID = 1L;
|
||||
@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,14 +3,19 @@ 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 {
|
||||
|
||||
private final long serialVersionUID = 1L;
|
||||
@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;
|
||||
}
|
||||
|
@ -4,13 +4,16 @@ package com.das.common.exceptions;
|
||||
import com.das.common.result.IResultCode;
|
||||
import com.das.common.result.ResultCode;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* @author chenhaojie
|
||||
* @Description 自定义服务异常
|
||||
*/
|
||||
public class ServiceException extends RuntimeException {
|
||||
|
||||
private final long serialVersionUID = 1L;
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int code = ResultCode.FAILURE.getCode();
|
||||
|
||||
|
@ -101,31 +101,22 @@ public class GlobalExceptionHandler {
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public R handleValidatedException(Exception exception) {
|
||||
BindingResult bindingResult = null;
|
||||
if (exception instanceof MethodArgumentNotValidException){
|
||||
MethodArgumentNotValidException e = (MethodArgumentNotValidException) exception;
|
||||
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());
|
||||
}
|
||||
}
|
||||
}else if (exception instanceof ConstraintViolationException){
|
||||
ConstraintViolationException e = (ConstraintViolationException) exception;
|
||||
}else if (exception instanceof ConstraintViolationException e){
|
||||
String collect = e.getConstraintViolations().stream()
|
||||
.map(ConstraintViolation::getMessage)
|
||||
.collect(Collectors.joining(";"));
|
||||
return R.fail(collect);
|
||||
}else if (exception instanceof BindException){
|
||||
BindException e = (BindException) exception;
|
||||
}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());
|
||||
@ -150,25 +141,14 @@ public class GlobalExceptionHandler {
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public R handlerNullPointException(NullPointerException exception) {
|
||||
String message = exception.getMessage();
|
||||
log.error("全局捕获null错误信息: {}", exception.toString(), exception);
|
||||
log.error("全局捕获null错误信息: {}", exception, exception);
|
||||
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)
|
||||
@ -185,7 +165,7 @@ public class GlobalExceptionHandler {
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public R handlerBindException(Exception exception) {
|
||||
String message = exception.getMessage();
|
||||
log.error("全局捕获错误信息: {}", exception.toString(), exception);
|
||||
log.error("全局捕获错误信息: {}", exception, exception);
|
||||
return R.fail(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,16 +74,16 @@ public class DecryptingOncePerRequestFilter extends OncePerRequestFilter {
|
||||
private final String bodyData;
|
||||
private final String token;
|
||||
|
||||
public DecryptingHttpServletRequestWrapper(HttpServletRequest request, String bodayData, String token) {
|
||||
public DecryptingHttpServletRequestWrapper(HttpServletRequest request, String bodyData, String token) {
|
||||
super(request);
|
||||
this.bodyData = bodayData;
|
||||
this.bodyData = bodyData;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
final ByteArrayInputStream bais = new ByteArrayInputStream(bodyData.getBytes("UTF-8"));
|
||||
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bodyData.getBytes(StandardCharsets.UTF_8));
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
@ -102,7 +102,7 @@ public class DecryptingOncePerRequestFilter extends OncePerRequestFilter {
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return bais.read();
|
||||
return byteArrayInputStream.read();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class RequestIdUtils {
|
||||
}
|
||||
|
||||
public static UUID getRequestId() {
|
||||
return (UUID)requestIdHolder.get();
|
||||
return requestIdHolder.get();
|
||||
}
|
||||
|
||||
public static void removeRequestId() {
|
||||
|
@ -2,6 +2,7 @@ package com.das.common.result;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -11,6 +12,7 @@ import java.util.Optional;
|
||||
*/
|
||||
public class R<T> implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
@ -57,7 +59,7 @@ public class R<T> implements Serializable {
|
||||
}
|
||||
|
||||
public static boolean isSuccess(@Nullable R<?> result) {
|
||||
return (Boolean) Optional.ofNullable(result).map((x) -> {
|
||||
return Optional.ofNullable(result).map((x) -> {
|
||||
return ResultCode.SUCCESS.code == x.code;
|
||||
}).orElse(Boolean.FALSE);
|
||||
}
|
||||
@ -103,7 +105,7 @@ public class R<T> implements Serializable {
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(int code, String msg) {
|
||||
return new R(code, (Object)null, msg);
|
||||
return new R(code, null, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(IResultCode resultCode) {
|
||||
|
@ -36,7 +36,7 @@ public enum ResultCode implements IResultCode {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
private ResultCode(final int code, final String message) {
|
||||
ResultCode(final int code, final String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
@ -1,14 +1,11 @@
|
||||
package com.das.common.utils;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.crypto.Mode;
|
||||
import cn.hutool.crypto.Padding;
|
||||
import cn.hutool.crypto.symmetric.AES;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* @author xxx
|
||||
@ -22,10 +19,10 @@ public class AESUtil {
|
||||
* @param content 待加密的内容
|
||||
* @return 加密后的Base64字符串
|
||||
*/
|
||||
// public String encrypt(String content, String iv) {
|
||||
// AES aes = new AES(Mode.CBC, Padding.PKCS5Padding, key.getBytes(), iv.getBytes());
|
||||
// return Base64.encode(aes.encrypt(content, Charset.forName("UTF-8")));
|
||||
// }
|
||||
public static String encrypt(String key,String content, String iv) {
|
||||
AES aes = new AES(Mode.CBC, Padding.ZeroPadding, key.getBytes(), iv.getBytes());
|
||||
return Base64.encode(aes.encrypt(content, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
/**
|
||||
* AES解密
|
||||
@ -34,6 +31,6 @@ public class AESUtil {
|
||||
*/
|
||||
public static String decrypt(String key, String encryptStr, String iv) {
|
||||
AES aes = new AES(Mode.CBC, Padding.ZeroPadding, key.getBytes(), iv.getBytes());
|
||||
return aes.decryptStr(Base64.decode(encryptStr), Charset.forName("UTF-8"));
|
||||
return aes.decryptStr(Base64.decode(encryptStr), StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class AdminRedisTemplate {
|
||||
* @return
|
||||
*/
|
||||
public String randomKey() {
|
||||
return (String) redisTemplate.randomKey();
|
||||
return redisTemplate.randomKey();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -189,7 +189,7 @@ public class AdminRedisTemplate {
|
||||
* @return value存储类型
|
||||
*/
|
||||
public String type(String key) {
|
||||
return redisTemplate.type(key).code();
|
||||
return Objects.requireNonNull(redisTemplate.type(key)).code();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -682,7 +682,7 @@ public class AdminRedisTemplate {
|
||||
* @return 判断 member 元素是否是集合 key 的成员
|
||||
*/
|
||||
public boolean sIsMember(String key, Object member) {
|
||||
return setOps.isMember(key, member);
|
||||
return Boolean.TRUE.equals(setOps.isMember(key, member));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -725,7 +725,7 @@ public class AdminRedisTemplate {
|
||||
* @return 返回集合中多个随机数
|
||||
*/
|
||||
public List sRandMember(String key, int count) {
|
||||
return setOps.randomMembers(key, (long) count);
|
||||
return setOps.randomMembers(key, count);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -952,4 +952,4 @@ public class AdminRedisTemplate {
|
||||
public ZSetOperations<String, Object> getZSetOps() {
|
||||
return zSetOps;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import cn.hutool.http.HttpStatus;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@ -15,6 +16,7 @@ import java.util.List;
|
||||
@NoArgsConstructor
|
||||
public class PageDataInfo<T> implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
@ -9,6 +9,7 @@ import com.das.common.utils.SqlUtil;
|
||||
import com.das.common.utils.StringUtils;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -20,6 +21,7 @@ import java.util.List;
|
||||
@Data
|
||||
public class PageQuery implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
@ -1,14 +1,14 @@
|
||||
package com.das.common.utils;
|
||||
|
||||
public class SnowFlakeGenerator {
|
||||
private static long datacenterId = 0L;
|
||||
private static final long datacenterId = 0L;
|
||||
private static final long DATACENTER_ID_BITS = 6L;
|
||||
private static final long MAX_DATACENTER_ID = 63L;
|
||||
private static long sequenceBits = 12L;
|
||||
private static final long sequenceBits = 12L;
|
||||
private static final long SEQUENCE_MAX;
|
||||
private static final long TWEPOCH = 1440000000000L;
|
||||
private long datacenterIdShift;
|
||||
private long timestampLeftShift;
|
||||
private final long datacenterIdShift;
|
||||
private final long timestampLeftShift;
|
||||
private volatile long lastTimestamp;
|
||||
private volatile long sequence;
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class SpringUtil implements BeanFactoryPostProcessor, ApplicationContextA
|
||||
public static ListableBeanFactory getBeanFactory() {
|
||||
return null == beanFactory ? applicationContext : beanFactory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 通过name获取 Bean
|
||||
@ -180,9 +180,8 @@ public class SpringUtil implements BeanFactoryPostProcessor, ApplicationContextA
|
||||
public static <T> void registerBean(String beanName, T bean) {
|
||||
if(null != beanFactory){
|
||||
beanFactory.registerSingleton(beanName, bean);
|
||||
} else if(applicationContext instanceof ConfigurableApplicationContext){
|
||||
ConfigurableApplicationContext context = (ConfigurableApplicationContext) applicationContext;
|
||||
context.getBeanFactory().registerSingleton(beanName, bean);
|
||||
} else if(applicationContext instanceof ConfigurableApplicationContext context){
|
||||
context.getBeanFactory().registerSingleton(beanName, bean);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
* @param link 链接
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean ishttp(String link) {
|
||||
public static boolean isHttp(String link) {
|
||||
return Validator.isUrl(link);
|
||||
}
|
||||
|
||||
@ -116,8 +116,8 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
* @param sep 分隔符
|
||||
* @return set集合
|
||||
*/
|
||||
public static Set<String> str2Set(String str, String sep) {
|
||||
return new HashSet<>(str2List(str, sep, true, false));
|
||||
public static Set<String> strToSet(String str, String sep) {
|
||||
return new HashSet<>(strToList(str, sep, true, false));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -129,7 +129,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
* @param trim 去掉首尾空白
|
||||
* @return list集合
|
||||
*/
|
||||
public static List<String> str2List(String str, String sep, boolean filterBlank, boolean trim) {
|
||||
public static List<String> strToList(String str, String sep, boolean filterBlank, boolean trim) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (isEmpty(str)) {
|
||||
return list;
|
||||
@ -239,8 +239,8 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
* @param size 字符串指定长度
|
||||
* @return 返回数字的字符串格式,该字符串为指定长度。
|
||||
*/
|
||||
public static String padl(final Number num, final int size) {
|
||||
return padl(num.toString(), size, '0');
|
||||
public static String padLeft(final Number num, final int size) {
|
||||
return padLeft(num.toString(), size, '0');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -251,22 +251,18 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
* @param c 用于补齐的字符
|
||||
* @return 返回指定长度的字符串,由原字符串左补齐或截取得到。
|
||||
*/
|
||||
public static String padl(final String s, final int size, final char c) {
|
||||
public static String padLeft(final String s, final int size, final char c) {
|
||||
final StringBuilder sb = new StringBuilder(size);
|
||||
if (s != null) {
|
||||
final int len = s.length();
|
||||
if (s.length() <= size) {
|
||||
for (int i = size - len; i > 0; i--) {
|
||||
sb.append(c);
|
||||
}
|
||||
sb.append(String.valueOf(c).repeat(size - len));
|
||||
sb.append(s);
|
||||
} else {
|
||||
return s.substring(len - size, len);
|
||||
}
|
||||
} else {
|
||||
for (int i = size; i > 0; i--) {
|
||||
sb.append(c);
|
||||
}
|
||||
sb.append(String.valueOf(c).repeat(Math.max(0, size)));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.das.modules.auth.controller;
|
||||
|
||||
import com.das.common.result.R;
|
||||
import com.das.modules.auth.service.SysAuthorityService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author chenhaojie
|
||||
* @Description 角色控制层
|
||||
*/
|
||||
@Slf4j
|
||||
@RequestMapping("/api/authority")
|
||||
@RestController
|
||||
public class SysAuthorityController {
|
||||
@Autowired
|
||||
private SysAuthorityService sysAuthorityService;
|
||||
|
||||
/**
|
||||
* 获取所有权限
|
||||
* @return 结果提示信息
|
||||
*/
|
||||
@PostMapping("/query")
|
||||
public R<?> queryAllAuthority() {
|
||||
return R.success(sysAuthorityService.queryAll());
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@Slf4j
|
||||
@RequestMapping("/api/menus")
|
||||
@RestController
|
||||
public class MenusController {
|
||||
public class SysMenusController {
|
||||
@Autowired
|
||||
private SysMenuService sysMenuService;
|
||||
|
||||
@ -59,4 +59,24 @@ public class MenusController {
|
||||
public PageDataInfo<SysMenu> queryMenuList(@RequestBody SysMenuQueryDto categoryBo, PageQuery pageQuery) {
|
||||
return sysMenuService.queryMenuList(categoryBo, pageQuery);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有的菜单
|
||||
* @return 返回菜单树
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public R<?> queryAllMenuList(@RequestBody SysMenuQueryDto sysMenuQueryDto) {
|
||||
return R.success(sysMenuService.queryAllMenuList(sysMenuQueryDto));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取绑定的菜单列表
|
||||
* @return 返回菜单列表
|
||||
*/
|
||||
@PostMapping("/tree")
|
||||
public R<?> createTree() {
|
||||
return R.success(sysMenuService.createTree());
|
||||
}
|
||||
}
|
@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author chenhaojie
|
||||
* @Description 用户控制层
|
||||
@ -20,7 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@Slf4j
|
||||
@RequestMapping("/api/org")
|
||||
@RestController
|
||||
public class OrgController {
|
||||
public class SysOrgController {
|
||||
@Autowired
|
||||
private SysOrgService sysOrgService;
|
||||
|
||||
@ -57,4 +59,13 @@ public class OrgController {
|
||||
public PageDataInfo<SysOrg> queryOrgList(@RequestBody SysOrgQueryDto sysOrgQueryDto, PageQuery pageQuery) {
|
||||
return sysOrgService.queryOrgList(sysOrgQueryDto, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建机构树结构
|
||||
* @return 返回机构树
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public R<?> queryAllOrgTree(@RequestBody SysOrgQueryDto sysOrgQueryDto) {
|
||||
return R.success(sysOrgService.queryAllOrgTree(sysOrgQueryDto));
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package com.das.modules.auth.controller;
|
||||
|
||||
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;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author chenhaojie
|
||||
* @Description 角色控制层
|
||||
*/
|
||||
@Slf4j
|
||||
@RequestMapping("/api/role")
|
||||
@RestController
|
||||
public class SysRoleController {
|
||||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
|
||||
/**
|
||||
* 新增菜单接口
|
||||
* @return 结果提示信息
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public R<?> createRole(@RequestBody SysRoleDto sysRoleDto) {
|
||||
return R.success(sysRoleService.createRole(sysRoleDto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改菜单接口
|
||||
* @return 结果提示信息
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public R<?> updateRole(@RequestBody SysRoleDto sysRoleDto) {
|
||||
return R.success(sysRoleService.updateRole(sysRoleDto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜单接口
|
||||
* @return 结果提示信息
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public R<?> deleteRole(@RequestBody DeleteDto deleteDto) {
|
||||
sysRoleService.deleteRole(deleteDto);
|
||||
return R.success();
|
||||
}
|
||||
|
||||
@PostMapping("/query")
|
||||
public PageDataInfo<SysRoleVo> queryRoleList(@RequestBody SysRoleQueryDto sysRoleQueryDto, PageQuery pageQuery) {
|
||||
return sysRoleService.queryRoleList(sysRoleQueryDto, pageQuery);
|
||||
}
|
||||
|
||||
@PostMapping("/queryAuthorityById")
|
||||
public R<?> queryAuthorityById(@RequestBody SysRoleQueryDto sysRoleQueryDto) {
|
||||
return R.success(sysRoleService.queryAuthorityById(sysRoleQueryDto));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@Slf4j
|
||||
@RequestMapping("/api/user")
|
||||
@RestController
|
||||
public class UserController {
|
||||
public class SysUserController {
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.das.modules.auth.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class SysAuthorityDto implements Serializable {
|
||||
/** 机构id */
|
||||
private Long id ;
|
||||
/** 权限编码 */
|
||||
private String authorityCode;
|
||||
/** 权限名称 */
|
||||
private String authorityName;
|
||||
/** 乐观锁 */
|
||||
private Integer revision ;
|
||||
/** 创建人 */
|
||||
private String createdBy ;
|
||||
/** 创建时间 */
|
||||
private Date createdTime ;
|
||||
/** 更新人 */
|
||||
private String updatedBy ;
|
||||
/** 更新时间 */
|
||||
private Date updatedTime ;
|
||||
}
|
@ -8,6 +8,12 @@ import java.io.Serializable;
|
||||
public class SysMenuQueryDto implements Serializable {
|
||||
/** 菜单ID */
|
||||
private Long id ;
|
||||
|
||||
/** 菜单名称 */
|
||||
private String menuName ;
|
||||
/** 上级菜单ID */
|
||||
private Long parentMenuId ;
|
||||
|
||||
/** 是否是首次查询菜单 */
|
||||
private Boolean recursive;
|
||||
}
|
||||
|
@ -25,6 +25,9 @@ public class SysOrgDto implements Serializable {
|
||||
private String contactPhone ;
|
||||
/** 备注 */
|
||||
private String remarks ;
|
||||
/** 机构简称 */
|
||||
private String aliasName;
|
||||
/** 上级组织机构id */
|
||||
private Long parentOrgId ;
|
||||
/** 乐观锁 */
|
||||
private Integer revision ;
|
||||
|
@ -14,5 +14,7 @@ public class SysOrgQueryDto implements Serializable {
|
||||
private String city ;
|
||||
/** 区县 */
|
||||
private String county ;
|
||||
private Long parentOrgID ;
|
||||
private Long parentOrgId ;
|
||||
/** 是否是首次查询机构 */
|
||||
private Boolean recursive;
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.das.modules.auth.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SysRoleDto implements Serializable {
|
||||
/** 主键id */
|
||||
private Long id ;
|
||||
/** 角色名称 */
|
||||
private String roleName ;
|
||||
/** 角色编码 */
|
||||
private String roleCode ;
|
||||
/** 权限id集合 */
|
||||
private List<Long> authList;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.das.modules.auth.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class SysRoleQueryDto implements Serializable {
|
||||
/** 角色名称 */
|
||||
private String roleName ;
|
||||
|
||||
private String roleId ;
|
||||
}
|
@ -8,8 +8,6 @@ import java.io.Serializable;
|
||||
public class SysUserQueryDto implements Serializable {
|
||||
/** 职员名称 */
|
||||
private String userName ;
|
||||
/** 手机号 */
|
||||
private String phone ;
|
||||
/** 组织机构id */
|
||||
private Long orgId ;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.das.modules.auth.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@ -11,6 +12,7 @@ import java.io.Serializable;
|
||||
@Data
|
||||
public class LoginUserDetailsVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private SysUserVo sysUser;
|
||||
|
@ -2,6 +2,7 @@ package com.das.modules.auth.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@ -11,6 +12,7 @@ import java.io.Serializable;
|
||||
@Data
|
||||
public class LoginVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
156
das/src/main/java/com/das/modules/auth/domain/vo/SysMenuVo.java
Normal file
156
das/src/main/java/com/das/modules/auth/domain/vo/SysMenuVo.java
Normal file
@ -0,0 +1,156 @@
|
||||
package com.das.modules.auth.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SysMenuVo implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 菜单ID */
|
||||
private Long id ;
|
||||
/** 菜单名称 */
|
||||
private String menuName ;
|
||||
/** 菜单排列顺序 */
|
||||
private Integer menuOrder ;
|
||||
/** 菜单图标名称 */
|
||||
private String menuIcon ;
|
||||
/** 菜单操作类型 */
|
||||
private Integer funType ;
|
||||
/** 菜单操作参数 */
|
||||
private String funParam ;
|
||||
/** 权限ID */
|
||||
private Long authorityId ;
|
||||
/** 上级菜单ID */
|
||||
private Long parentMenuId ;
|
||||
/** 乐观锁 */
|
||||
private Integer revision ;
|
||||
/** 创建人 */
|
||||
private String createdBy ;
|
||||
/** 创建时间 */
|
||||
private Date createdTime ;
|
||||
/** 更新人 */
|
||||
private String updatedBy ;
|
||||
/** 更新时间 */
|
||||
private Date updatedTime ;
|
||||
|
||||
private List<SysMenuVo> children;
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMenuName() {
|
||||
return menuName;
|
||||
}
|
||||
|
||||
public void setMenuName(String menuName) {
|
||||
this.menuName = menuName;
|
||||
}
|
||||
|
||||
public Integer getMenuOrder() {
|
||||
return menuOrder;
|
||||
}
|
||||
|
||||
public void setMenuOrder(Integer menuOrder) {
|
||||
this.menuOrder = menuOrder;
|
||||
}
|
||||
|
||||
public String getMenuIcon() {
|
||||
return menuIcon;
|
||||
}
|
||||
|
||||
public void setMenuIcon(String menuIcon) {
|
||||
this.menuIcon = menuIcon;
|
||||
}
|
||||
|
||||
public Integer getFunType() {
|
||||
return funType;
|
||||
}
|
||||
|
||||
public void setFunType(Integer funType) {
|
||||
this.funType = funType;
|
||||
}
|
||||
|
||||
public String getFunParam() {
|
||||
return funParam;
|
||||
}
|
||||
|
||||
public void setFunParam(String funParam) {
|
||||
this.funParam = funParam;
|
||||
}
|
||||
|
||||
public Long getAuthorityId() {
|
||||
return authorityId;
|
||||
}
|
||||
|
||||
public void setAuthorityId(Long authorityId) {
|
||||
this.authorityId = authorityId;
|
||||
}
|
||||
|
||||
public Long getParentMenuId() {
|
||||
return parentMenuId;
|
||||
}
|
||||
|
||||
public void setParentMenuId(Long parentMenuId) {
|
||||
this.parentMenuId = parentMenuId;
|
||||
}
|
||||
|
||||
public Integer getRevision() {
|
||||
return revision;
|
||||
}
|
||||
|
||||
public void setRevision(Integer revision) {
|
||||
this.revision = revision;
|
||||
}
|
||||
|
||||
public String getCreatedBy() {
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
public void setCreatedBy(String createdBy) {
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
public Date getCreatedTime() {
|
||||
return createdTime;
|
||||
}
|
||||
|
||||
public void setCreatedTime(Date createdTime) {
|
||||
this.createdTime = createdTime;
|
||||
}
|
||||
|
||||
public String getUpdatedBy() {
|
||||
return updatedBy;
|
||||
}
|
||||
|
||||
public void setUpdatedBy(String updatedBy) {
|
||||
this.updatedBy = updatedBy;
|
||||
}
|
||||
|
||||
public Date getUpdatedTime() {
|
||||
return updatedTime;
|
||||
}
|
||||
|
||||
public void setUpdatedTime(Date updatedTime) {
|
||||
this.updatedTime = updatedTime;
|
||||
}
|
||||
|
||||
public List<SysMenuVo> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<SysMenuVo> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.das.modules.auth.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 账号信息
|
||||
*
|
||||
* @author guchengwei
|
||||
*/
|
||||
@Data
|
||||
public class SysRoleAuthVo implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 账号ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 权限编码
|
||||
*/
|
||||
private String authorityCode;
|
||||
|
||||
/**
|
||||
* 权限名称
|
||||
*/
|
||||
private String authorityName;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.das.modules.auth.domain.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.Version;
|
||||
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
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String roleCode;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String roleName;
|
||||
|
||||
/**
|
||||
* 乐观锁
|
||||
*/
|
||||
private Integer revision;
|
||||
|
||||
private List<SysRoleAuthVo> list;
|
||||
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package com.das.modules.auth.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@ -11,6 +12,7 @@ import java.io.Serializable;
|
||||
*/
|
||||
@Data
|
||||
public class SysUserVo implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 账号ID
|
||||
|
@ -2,12 +2,18 @@ package com.das.modules.auth.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 令牌实体
|
||||
* @author Administrator
|
||||
*/
|
||||
@Data
|
||||
public class TokenVo {
|
||||
public class TokenVo implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 令牌
|
||||
*/
|
||||
|
@ -0,0 +1,57 @@
|
||||
package com.das.modules.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
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.Serial;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 权限信息
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaojie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_authority")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysAuthority extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 权限编码
|
||||
*/
|
||||
@TableField("authority_code")
|
||||
private String authorityCode;
|
||||
|
||||
/**
|
||||
* 权限名称
|
||||
*/
|
||||
@TableField("authority_name")
|
||||
private String authorityName;
|
||||
|
||||
/**
|
||||
* 乐观锁
|
||||
*/
|
||||
@Version
|
||||
@TableField("revision")
|
||||
private Integer revision;
|
||||
|
||||
}
|
@ -2,20 +2,35 @@ package com.das.modules.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
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.Serial;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单信息
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaojie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_menu")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysMenu extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 菜单ID */
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id ;
|
||||
|
||||
/** 菜单名称 */
|
||||
|
@ -2,12 +2,16 @@ package com.das.modules.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
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 org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serial;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -16,18 +20,21 @@ import java.util.Date;
|
||||
*
|
||||
* @author chenhaojie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_org")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysOrg extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 机构ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@ -82,8 +89,8 @@ public class SysOrg extends BaseEntity {
|
||||
/**
|
||||
* 上级机构id
|
||||
*/
|
||||
@TableField("parent_org_iD")
|
||||
private Long parentOrgID;
|
||||
@TableField("parent_org_id")
|
||||
private Long parentOrgId;
|
||||
|
||||
/**
|
||||
* 乐观锁
|
||||
@ -99,4 +106,10 @@ public class SysOrg extends BaseEntity {
|
||||
@TableField("alias_name")
|
||||
private String aliasName;
|
||||
|
||||
/**
|
||||
* 子节点
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<SysOrg> children;
|
||||
|
||||
}
|
||||
|
57
das/src/main/java/com/das/modules/auth/entity/SysRole.java
Normal file
57
das/src/main/java/com/das/modules/auth/entity/SysRole.java
Normal file
@ -0,0 +1,57 @@
|
||||
package com.das.modules.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
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.Serial;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色信息
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaojie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_role")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysRole extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
@TableField("role_code")
|
||||
private String roleCode;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
@TableField("role_name")
|
||||
private String roleName;
|
||||
|
||||
/**
|
||||
* 乐观锁
|
||||
*/
|
||||
@Version
|
||||
@TableField("revision")
|
||||
private Integer revision;
|
||||
|
||||
}
|
@ -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_role_authority")
|
||||
public class SysRoleAuthority extends BaseEntity implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId("id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 权限id
|
||||
*/
|
||||
@TableField("authority_id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long authorityId;
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
@TableField("role_id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 乐观锁
|
||||
*/
|
||||
@Version
|
||||
@TableField("revision")
|
||||
private Integer revision;
|
||||
}
|
@ -2,9 +2,12 @@ package com.das.modules.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.das.common.constant.BaseEntity;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@ -14,18 +17,21 @@ import java.util.Date;
|
||||
*
|
||||
* @author chenhaojie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_user")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysUser extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.das.modules.auth.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.das.modules.auth.entity.SysAuthority;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户信息 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaojie
|
||||
*/
|
||||
public interface SysAuthorityMapper extends BaseMapper<SysAuthority> {
|
||||
|
||||
List<SysAuthority> selectByAuthorities(@Param("list")List<SysAuthority> list);
|
||||
|
||||
void batchInsert(List<SysAuthority> list);
|
||||
/**
|
||||
* 判断权限是否存在
|
||||
*
|
||||
* @param authId 权限ID
|
||||
* @return 0 - 不存在, 1 - 存在
|
||||
*/
|
||||
long existAuthority(@Param("authId") Long authId);
|
||||
|
||||
}
|
@ -3,9 +3,12 @@ package com.das.modules.auth.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.modules.auth.domain.dto.SysMenuQueryDto;
|
||||
import com.das.modules.auth.domain.vo.SysMenuVo;
|
||||
import com.das.modules.auth.entity.SysMenu;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单信息 Mapper 接口
|
||||
@ -13,7 +16,11 @@ import org.apache.ibatis.annotations.Param;
|
||||
*
|
||||
* @author chenhaojie
|
||||
*/
|
||||
public interface SysMenuMapper extends BaseMapperPlus<SysMenu, SysMenu> {
|
||||
public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||
|
||||
IPage<SysMenu> queryMenuList(IPage<SysMenu> page, @Param("sysMenu") SysMenuQueryDto sysMenuQueryDto);
|
||||
|
||||
List<SysMenuVo> queryAllMenuList(@Param("sysMenu") SysMenuQueryDto sysMenuQueryDto);
|
||||
|
||||
SysMenuVo createTree();
|
||||
}
|
||||
|
@ -3,11 +3,11 @@ package com.das.modules.auth.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.modules.auth.domain.dto.SysOrgQueryDto;
|
||||
import com.das.modules.auth.domain.dto.SysUserQueryDto;
|
||||
import com.das.modules.auth.entity.SysOrg;
|
||||
import com.das.modules.auth.entity.SysUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户信息 Mapper 接口
|
||||
@ -17,4 +17,8 @@ import org.apache.ibatis.annotations.Param;
|
||||
*/
|
||||
public interface SysOrgMapper extends BaseMapper<SysOrg> {
|
||||
IPage<SysOrg> queryOrgList(IPage<SysOrg> page, @Param("sysOrg") SysOrgQueryDto sysOrgQueryDto);
|
||||
|
||||
List<SysOrg> queryAllOrgTree(@Param("id") Long id);
|
||||
|
||||
List<SysOrg> queryAllChildOrgTree(@Param("id") Long id);
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.das.modules.auth.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.das.modules.auth.entity.SysAuthority;
|
||||
import com.das.modules.auth.entity.SysRoleAuthority;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户信息 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaojie
|
||||
*/
|
||||
public interface SysRoleAuthorityMapper extends BaseMapper<SysRoleAuthority> {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.das.modules.auth.mapper;
|
||||
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户信息 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaojie
|
||||
*/
|
||||
public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
|
||||
/**
|
||||
* 判断角色是否存在
|
||||
*
|
||||
* @param roleCode 角色ID
|
||||
* @return 0 - 不存在 1 - 存在
|
||||
*/
|
||||
long existRoleByRoleCode(@Param("roleCode") String roleCode);
|
||||
IPage<SysRoleVo> queryRoleList(IPage<SysRole> page, @Param("sysRole") SysRoleQueryDto sysRoleQueryDto);
|
||||
|
||||
List<SysRoleAuthVo> queryAuthorityById(@Param("id")Long id);
|
||||
|
||||
SysRole selectByCode(@Param("roleCode") String roleCode);
|
||||
|
||||
long existRoleByName(@Param("name") String name);
|
||||
}
|
@ -1,9 +1,7 @@
|
||||
package com.das.modules.auth.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.modules.auth.domain.dto.SysMenuQueryDto;
|
||||
import com.das.modules.auth.domain.dto.SysUserQueryDto;
|
||||
import com.das.modules.auth.entity.SysMenu;
|
||||
import com.das.modules.auth.entity.SysUser;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.das.modules.auth.service;
|
||||
|
||||
import com.das.modules.auth.domain.dto.SysAuthorityDto;
|
||||
import com.das.modules.auth.entity.SysAuthority;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface SysAuthorityService {
|
||||
List<SysAuthority> queryAll();
|
||||
}
|
@ -5,15 +5,32 @@ 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.SysMenuVo;
|
||||
import com.das.modules.auth.entity.SysMenu;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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);
|
||||
|
||||
/**
|
||||
* 查询菜单列表
|
||||
* @param sysMenuQueryDto 查询条件
|
||||
* @return 返回查询列表 按菜单顺序排序
|
||||
*/
|
||||
List<SysMenuVo> queryAllMenuList(SysMenuQueryDto sysMenuQueryDto);
|
||||
|
||||
/**
|
||||
* 构建菜单树结构
|
||||
* @return 返回菜单树
|
||||
*/
|
||||
SysMenuVo createTree();
|
||||
}
|
||||
|
@ -5,12 +5,17 @@ import com.das.common.utils.PageQuery;
|
||||
import com.das.modules.auth.domain.dto.*;
|
||||
import com.das.modules.auth.entity.SysOrg;
|
||||
|
||||
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);
|
||||
|
||||
|
||||
List<SysOrg> queryAllOrgTree(SysOrgQueryDto sysOrgQueryDto);
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.das.modules.auth.service;
|
||||
|
||||
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;
|
||||
|
||||
public interface SysRoleService {
|
||||
SysRoleDto createRole(SysRoleDto sysRoleDto);
|
||||
|
||||
SysRoleDto updateRole(SysRoleDto sysRoleDto);
|
||||
|
||||
void deleteRole(DeleteDto deleteDto);
|
||||
|
||||
PageDataInfo<SysRoleVo> queryRoleList(SysRoleQueryDto sysRoleQueryDto, PageQuery pageQuery);
|
||||
|
||||
List<SysRoleAuthVo> queryAuthorityById(SysRoleQueryDto sysRoleQueryDto);
|
||||
}
|
@ -10,9 +10,9 @@ import com.das.modules.auth.entity.SysUser;
|
||||
public interface SysUserService {
|
||||
SysUser createUser(SysUserDto sysUserDto);
|
||||
|
||||
int updateUser(SysUserDto sysUserDto);
|
||||
void updateUser(SysUserDto sysUserDto);
|
||||
|
||||
int deleteUser(DeleteDto deleteDto);
|
||||
void deleteUser(DeleteDto deleteDto);
|
||||
|
||||
PageDataInfo<SysUser> queryUserList(SysUserQueryDto sysUserQueryDto, PageQuery pageQuery);
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import com.das.modules.auth.domain.vo.SysUserVo;
|
||||
import com.das.modules.auth.entity.SysUser;
|
||||
import com.das.modules.auth.mapper.SysUserMapper;
|
||||
import com.das.modules.auth.service.LoginService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
@ -79,7 +78,6 @@ public class LoginServiceImpl implements LoginService {
|
||||
loginInfo.setSysUser(sysUserVo); // 存储用户信息到会话
|
||||
loginInfo.setToken(token);
|
||||
loginInfo.setRefreshToken(refreshTokenUuid);
|
||||
adminRedisTemplate.setEx(token, loginInfo, Duration.ofSeconds(saTokenProperties.getExpireTime()));
|
||||
adminRedisTemplate.setEx(refreshToken, loginInfo, Duration.ofSeconds(saTokenProperties.getRefreshExpireTime()));
|
||||
return loginInfo;
|
||||
}
|
||||
@ -102,7 +100,7 @@ public class LoginServiceImpl implements LoginService {
|
||||
return loginInfo;
|
||||
}
|
||||
StpUtil.login(loginUserDetailsVo.getSysUser().getAccount());// 执行登录,这里username为用户唯一标识
|
||||
String newToken = StpUtil.getTokenValue().replace("-", "");;
|
||||
String newToken = StpUtil.getTokenValue().replace("-", "");
|
||||
String newRefreshTokenUuid = IdUtil.fastSimpleUUID();
|
||||
String newRefreshToken = "refresh:" + newRefreshTokenUuid;
|
||||
loginInfo.setAccessToken(newToken);
|
||||
@ -111,7 +109,6 @@ public class LoginServiceImpl implements LoginService {
|
||||
loginUserDetailsVo.setRefreshToken(newRefreshTokenUuid);
|
||||
String oldRefreshToken = loginUserDetailsVo.getRefreshToken();
|
||||
|
||||
adminRedisTemplate.setEx(newToken, loginUserDetailsVo, Duration.ofSeconds(saTokenProperties.getExpireTime()));
|
||||
adminRedisTemplate.setEx(newRefreshToken, loginUserDetailsVo, Duration.ofSeconds(saTokenProperties.getRefreshExpireTime()));
|
||||
// 删除原有刷新token
|
||||
adminRedisTemplate.del("refresh:" + oldRefreshToken);
|
||||
|
@ -0,0 +1,76 @@
|
||||
package com.das.modules.auth.service.impl;
|
||||
|
||||
|
||||
import com.das.common.config.SysAuthorityIds;
|
||||
import com.das.common.utils.BeanCopyUtils;
|
||||
import com.das.common.utils.SequenceUtils;
|
||||
import com.das.modules.auth.domain.dto.SysAuthorityDto;
|
||||
import com.das.modules.auth.entity.SysAuthority;
|
||||
import com.das.modules.auth.mapper.SysAuthorityMapper;
|
||||
import com.das.modules.auth.service.SysAuthorityService;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysAuthorityServiceImpl implements SysAuthorityService {
|
||||
@Autowired
|
||||
SysAuthorityMapper sysAuthorityMapper;
|
||||
|
||||
/**
|
||||
* 初始化系统权限
|
||||
*/
|
||||
@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));
|
||||
|
||||
try {
|
||||
// 性能优化:先查询所有需要的权限是否存在,减少数据库访问次数
|
||||
List<SysAuthority> existingAuthorities = sysAuthorityMapper.selectByAuthorities(list);
|
||||
|
||||
// 过滤出需要插入的权限
|
||||
list.removeAll(existingAuthorities);
|
||||
|
||||
// 批量插入不存在的权限
|
||||
if (!list.isEmpty()) {
|
||||
sysAuthorityMapper.batchInsert(list);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 异常处理:记录日志或执行其他恢复策略
|
||||
log.error(e.getMessage(), e); // 实际应用中应使用日志框架如Log4j记录错误信息
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回全部权限列表
|
||||
* 注意:此方法封装了对空结果的处理和基础的异常处理逻辑。
|
||||
* @return 权限列表,如果没有找到任何权限,则返回一个空列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysAuthority> queryAll() {
|
||||
try {
|
||||
List<SysAuthority> authorities = sysAuthorityMapper.selectList(null);
|
||||
// 检查返回的结果是否为空,如果为空则返回一个空的列表
|
||||
if (authorities == null || authorities.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return authorities;
|
||||
} catch (Exception e) {
|
||||
// 处理可能的异常,例如数据库查询异常等
|
||||
// 根据你的项目实践,这里可以记录日志、抛出自定义异常或者进行其他处理
|
||||
// 以下是一个简单的示例,打印异常信息并返回空列表
|
||||
log.error("查询权限列表时发生异常:" + e.getMessage());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
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.SequenceUtils;
|
||||
@ -8,12 +9,17 @@ 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.SysMenuVo;
|
||||
import com.das.modules.auth.entity.SysMenu;
|
||||
import com.das.modules.auth.mapper.SysMenuMapper;
|
||||
import com.das.modules.auth.service.SysMenuService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SysMenuServiceImpl implements SysMenuService {
|
||||
@ -25,20 +31,24 @@ public class SysMenuServiceImpl implements SysMenuService {
|
||||
SysMenu sysMenu = new SysMenu();
|
||||
BeanCopyUtils.copy(sysMenuDto,sysMenu);
|
||||
sysMenu.setId(SequenceUtils.generateId());
|
||||
sysMenu.setRevision(1);
|
||||
sysMenu.setCreatedTime(new Date());
|
||||
sysMenu.setUpdatedTime(new Date());
|
||||
sysMenuMapper.insert(sysMenu);
|
||||
return sysMenu;
|
||||
}
|
||||
|
||||
@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
|
||||
@ -47,4 +57,19 @@ public class SysMenuServiceImpl implements SysMenuService {
|
||||
return PageDataInfo.build(iPage.getRecords(), iPage.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenuVo> queryAllMenuList(SysMenuQueryDto sysMenuQueryDto) {
|
||||
if(sysMenuQueryDto.getRecursive()) {
|
||||
sysMenuQueryDto.setParentMenuId(0L);
|
||||
}
|
||||
List<SysMenuVo> list = sysMenuMapper.queryAllMenuList(sysMenuQueryDto);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysMenuVo createTree() {
|
||||
|
||||
return sysMenuMapper.createTree();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,17 +2,22 @@ package com.das.modules.auth.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.common.utils.BeanCopyUtils;
|
||||
import com.das.common.utils.SequenceUtils;
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
import com.das.common.utils.PageQuery;
|
||||
import com.das.modules.auth.domain.dto.*;
|
||||
import com.das.common.utils.SequenceUtils;
|
||||
import com.das.modules.auth.domain.dto.DeleteDto;
|
||||
import com.das.modules.auth.domain.dto.SysOrgDto;
|
||||
import com.das.modules.auth.domain.dto.SysOrgQueryDto;
|
||||
import com.das.modules.auth.entity.SysOrg;
|
||||
import com.das.modules.auth.mapper.SysOrgMapper;
|
||||
import com.das.modules.auth.service.SysOrgService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SysOrgServiceImpl implements SysOrgService {
|
||||
@Autowired
|
||||
@ -23,20 +28,23 @@ public class SysOrgServiceImpl implements SysOrgService {
|
||||
SysOrg sysOrg = new SysOrg();
|
||||
BeanCopyUtils.copy(sysOrgDto,sysOrg);
|
||||
sysOrg.setId(SequenceUtils.generateId());
|
||||
sysOrg.setRevision(1);
|
||||
sysOrg.setCreatedTime(new Date());
|
||||
sysOrg.setUpdatedTime(new Date());
|
||||
sysOrgMapper.insert(sysOrg);
|
||||
return sysOrg;
|
||||
}
|
||||
|
||||
@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
|
||||
@ -44,4 +52,16 @@ public class SysOrgServiceImpl implements SysOrgService {
|
||||
IPage<SysOrg> iPage = sysOrgMapper.queryOrgList(pageQuery.build(), sysOrgQueryDto);
|
||||
return PageDataInfo.build(iPage.getRecords(), iPage.getTotal());
|
||||
}
|
||||
|
||||
public List<SysOrg> queryAllOrgTree(SysOrgQueryDto sysOrgQueryDto) {
|
||||
List<SysOrg> rootOrgList = new ArrayList<>();
|
||||
if(sysOrgQueryDto.getRecursive()) {
|
||||
rootOrgList = sysOrgMapper.queryAllOrgTree(sysOrgQueryDto.getParentOrgId());
|
||||
} else {
|
||||
rootOrgList = sysOrgMapper.queryAllChildOrgTree(sysOrgQueryDto.getParentOrgId());
|
||||
}
|
||||
|
||||
return rootOrgList;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,195 @@
|
||||
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.exceptions.ServiceException;
|
||||
import com.das.common.utils.BeanCopyUtils;
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
import com.das.common.utils.PageQuery;
|
||||
import com.das.common.utils.SequenceUtils;
|
||||
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;
|
||||
import com.das.modules.auth.mapper.SysRoleAuthorityMapper;
|
||||
import com.das.modules.auth.mapper.SysRoleMapper;
|
||||
import com.das.modules.auth.service.SysRoleService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
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 SysRoleServiceImpl implements SysRoleService {
|
||||
|
||||
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
|
||||
|
||||
@Autowired
|
||||
SysAuthorityMapper sysAuthorityMapper;
|
||||
|
||||
@Autowired
|
||||
SysRoleAuthorityMapper sysRoleAuthorityMapper;
|
||||
|
||||
@Autowired
|
||||
SysRoleMapper sysRoleMapper;
|
||||
|
||||
@Override
|
||||
public SysRoleDto createRole(SysRoleDto sysRoleDto) {
|
||||
if (sysRoleDto.getRoleName() == null || sysRoleDto.getAuthList() == null || StringUtils.isEmpty(sysRoleDto.getRoleCode())) {
|
||||
throw new ServiceException("非法调用,参数缺失");
|
||||
}
|
||||
//判断角色编码code是否存在
|
||||
long roleCount = sysRoleMapper.existRoleByRoleCode(sysRoleDto.getRoleCode());
|
||||
if (roleCount > 0) {
|
||||
throw new ServiceException(String.format("角色 %s 已存在", sysRoleDto.getRoleCode()));
|
||||
}
|
||||
|
||||
SysRole sysRole = new SysRole();
|
||||
BeanCopyUtils.copy(sysRoleDto, sysRole);
|
||||
sysRole.setId(SequenceUtils.generateId());
|
||||
sysRole.setRevision(1);
|
||||
sysRole.setCreatedBy("测试");
|
||||
sysRole.setUpdatedBy("测试");
|
||||
sysRole.setCreatedTime(new Date());
|
||||
sysRole.setUpdatedTime(new Date());
|
||||
sysRoleMapper.insert(sysRole);
|
||||
|
||||
//验证权限有效性
|
||||
String errorAuths = checkErrorAuthorities(sysRoleDto.getAuthList());
|
||||
if (StringUtils.hasText(errorAuths)) {
|
||||
throw new ServiceException("权限不存在 " + errorAuths);
|
||||
}
|
||||
if (sysRoleDto.getAuthList() != null) {
|
||||
//解锁role与auth绑定
|
||||
QueryWrapper<SysRoleAuthority> authorityInfoQueryWrapper = new QueryWrapper<>();
|
||||
authorityInfoQueryWrapper.eq("role_id", sysRoleDto.getId());
|
||||
sysRoleAuthorityMapper.delete(authorityInfoQueryWrapper);
|
||||
//绑定新权限
|
||||
for (Long authId : sysRoleDto.getAuthList()) {
|
||||
SysRoleAuthority roleAuthority = new SysRoleAuthority();
|
||||
roleAuthority.setRoleId(sysRole.getId());
|
||||
roleAuthority.setAuthorityId(authId);
|
||||
roleAuthority.setRevision(1);
|
||||
roleAuthority.setCreatedTime(new Date());
|
||||
roleAuthority.setUpdatedTime(new Date());
|
||||
sysRoleAuthorityMapper.insert(roleAuthority);
|
||||
}
|
||||
}
|
||||
return sysRoleDto;
|
||||
}
|
||||
|
||||
private String checkErrorAuthorities(List<Long> auths) {
|
||||
if (auths != null && auths.size() > 0) {
|
||||
List<Long> errorAuthority = new ArrayList<>();
|
||||
for (Long authId : auths) {
|
||||
if (authId == null) {
|
||||
continue;
|
||||
}
|
||||
long authCount = sysAuthorityMapper.existAuthority(authId);
|
||||
if (authCount == 0) {
|
||||
errorAuthority.add(authId);
|
||||
}
|
||||
}
|
||||
if (errorAuthority.size() > 0) {
|
||||
try {
|
||||
return JSON_MAPPER.writeValueAsString(errorAuthority);
|
||||
} catch (JsonProcessingException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysRoleDto updateRole(SysRoleDto sysRoleDto) {
|
||||
SysRole sysRole = new SysRole();
|
||||
if (StringUtils.isEmpty(sysRoleDto.getId())) {
|
||||
throw new ServiceException("参数缺失");
|
||||
}
|
||||
SysRole role = sysRoleMapper.selectByCode(sysRoleDto.getRoleCode());
|
||||
if (role == null) {
|
||||
throw new ServiceException(String.format("角色 %s 不存在", sysRoleDto.getRoleCode()));
|
||||
}
|
||||
if (StringUtils.hasText(sysRoleDto.getRoleName())) {
|
||||
//若与数据库中角色名相同 则表示未对名称进行修改
|
||||
if (!role.getRoleName().equals(sysRoleDto.getRoleName())) {
|
||||
//判断角色名是否存在
|
||||
long roleCount = sysRoleMapper.existRoleByName(sysRoleDto.getRoleName());
|
||||
if (roleCount > 0) {
|
||||
throw new ServiceException(String.format("角色名 %s 已存在", sysRoleDto.getRoleName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新角色自身
|
||||
sysRole.setRoleName(sysRoleDto.getRoleName());
|
||||
sysRole.setRoleCode(sysRoleDto.getRoleCode());
|
||||
sysRole.setId(sysRoleDto.getId());
|
||||
this.sysRoleMapper.updateById(sysRole);
|
||||
//验证权限有效性
|
||||
String errorAuths = checkErrorAuthorities(sysRoleDto.getAuthList());
|
||||
if (StringUtils.hasText(errorAuths)) {
|
||||
throw new ServiceException("权限不存在 " + errorAuths);
|
||||
}
|
||||
if (sysRoleDto.getAuthList() != null) {
|
||||
//解锁role与auth绑定
|
||||
QueryWrapper<SysRoleAuthority> authorityInfoQueryWrapper = new QueryWrapper<>();
|
||||
authorityInfoQueryWrapper.eq("role_id", sysRoleDto.getId());
|
||||
sysRoleAuthorityMapper.delete(authorityInfoQueryWrapper);
|
||||
//绑定新权限
|
||||
for (Long authId : sysRoleDto.getAuthList()) {
|
||||
SysRoleAuthority roleAuthority = new SysRoleAuthority();
|
||||
roleAuthority.setRoleId(sysRole.getId());
|
||||
roleAuthority.setAuthorityId(authId);
|
||||
roleAuthority.setRevision(1);
|
||||
roleAuthority.setCreatedTime(new Date());
|
||||
roleAuthority.setUpdatedTime(new Date());
|
||||
sysRoleAuthorityMapper.insert(roleAuthority);
|
||||
}
|
||||
}
|
||||
return sysRoleDto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRole(DeleteDto deleteDto) {
|
||||
SysRole sysRole = sysRoleMapper.selectById(deleteDto.getId());
|
||||
if (StringUtils.isEmpty(deleteDto.getId())) {
|
||||
throw new ServiceException("参数缺失");
|
||||
}
|
||||
long roleCount = sysRoleMapper.existRoleByRoleCode(sysRole.getRoleCode());
|
||||
if (roleCount == 0) {
|
||||
throw new ServiceException("角色不存在");
|
||||
}
|
||||
//解锁role与Account绑定
|
||||
QueryWrapper<SysRole> accountRoleQueryWrapper = new QueryWrapper<>();
|
||||
accountRoleQueryWrapper.eq("id", deleteDto.getId());
|
||||
this.sysRoleMapper.delete(accountRoleQueryWrapper);
|
||||
//解除角色与权限绑定
|
||||
QueryWrapper<SysRoleAuthority> authorityInfoQueryWrapper = new QueryWrapper<>();
|
||||
authorityInfoQueryWrapper.eq("role_id", deleteDto.getId());
|
||||
sysRoleAuthorityMapper.delete(authorityInfoQueryWrapper);
|
||||
//删除角色
|
||||
sysRoleMapper.deleteById(deleteDto.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageDataInfo<SysRoleVo> queryRoleList(SysRoleQueryDto sysRoleQueryDto, PageQuery pageQuery) {
|
||||
IPage<SysRoleVo> iPage = sysRoleMapper.queryRoleList(pageQuery.build(), sysRoleQueryDto);
|
||||
return PageDataInfo.build(iPage.getRecords(), iPage.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysRoleAuthVo> queryAuthorityById(SysRoleQueryDto sysRoleQueryDto) {
|
||||
return sysRoleMapper.queryAuthorityById(Long.valueOf(sysRoleQueryDto.getRoleId()));
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.das.modules.auth.service.impl;
|
||||
|
||||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.common.utils.BeanCopyUtils;
|
||||
import com.das.common.utils.SequenceUtils;
|
||||
@ -11,10 +12,11 @@ import com.das.modules.auth.domain.dto.SysUserQueryDto;
|
||||
import com.das.modules.auth.entity.SysUser;
|
||||
import com.das.modules.auth.mapper.SysUserMapper;
|
||||
import com.das.modules.auth.service.SysUserService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
public class SysUserServiceImpl implements SysUserService {
|
||||
|
||||
@ -24,21 +26,27 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
public SysUser createUser(SysUserDto sysUserDto) {
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateUser(SysUserDto sysUserDto) {
|
||||
public void updateUser(SysUserDto sysUserDto) {
|
||||
SysUser sysUser = new SysUser();
|
||||
BeanCopyUtils.copy(sysUserDto,sysUser);
|
||||
return sysUserMapper.updateById(sysUser);
|
||||
sysUserMapper.updateById(sysUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteUser(DeleteDto deleteDto) {
|
||||
return sysUserMapper.deleteById(deleteDto.getId());
|
||||
public void deleteUser(DeleteDto deleteDto) {
|
||||
sysUserMapper.deleteById(deleteDto.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
24
das/src/main/resources/mapper/SysAuthorityMapper.xml
Normal file
24
das/src/main/resources/mapper/SysAuthorityMapper.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!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.SysAuthorityMapper">
|
||||
|
||||
<select id="selectByAuthorities" resultType="com.das.modules.auth.entity.SysAuthority">
|
||||
select * from sys_authority where id in(
|
||||
<foreach collection='list' item='item' index='index ' separator=', '>
|
||||
#{item.id}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
|
||||
<insert id="batchInsert">
|
||||
insert into sys_authority(id,authority_code , authority_name, revision) values
|
||||
<foreach collection='list' item='item' index='index ' separator=', '>
|
||||
(#{item.id}, #{item.authorityCode}, #{item.authorityName}, #{item.revision})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="existAuthority" resultType="java.lang.Long">
|
||||
select count(1) from sys_authority t where t.id=#{authId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -18,6 +18,25 @@
|
||||
<result property="updatedTime" column="updated_time" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<resultMap id="SysMenuChildMap" type="com.das.modules.auth.domain.vo.SysMenuVo">
|
||||
<result property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="menuName" column="menu_name" jdbcType="VARCHAR"/>
|
||||
<result property="menuOrder" column="menu_order" jdbcType="VARCHAR"/>
|
||||
<result property="menuIcon" column="menu_icon" jdbcType="VARCHAR"/>
|
||||
<result property="funType" column="fun_type" jdbcType="VARCHAR"/>
|
||||
<result property="funParam" column="fun_param" jdbcType="VARCHAR"/>
|
||||
<result property="authorityId" column="authority_id" jdbcType="VARCHAR"/>
|
||||
<result property="parentMenuId" column="parent_menu_id" 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"/>
|
||||
<collection property="children" column="id" ofType="com.das.modules.auth.domain.vo.SysMenuVo" select="queryChildMenus"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="queryMenuList" resultMap="SysMenuMap">
|
||||
select * from sys_menu
|
||||
<where>
|
||||
@ -27,7 +46,22 @@
|
||||
<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>
|
||||
|
||||
<select id="queryAllMenuList" 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>
|
||||
|
||||
<select id="createTree" resultMap="SysMenuChildMap">
|
||||
select * from sys_menu where parent_menu_id = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<result property="address" column="address" jdbcType="VARCHAR"/>
|
||||
<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="parentOrgId" column="parent_org_id" 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"/>
|
||||
@ -35,10 +35,20 @@
|
||||
<if test="sysOrg.county != null and sysOrg.county != ''">
|
||||
and county like concat('%',#{sysOrg.county},'%')
|
||||
</if>
|
||||
<if test="sysOrg.parentOrgID != null and sysOrg.parentOrgID != ''">
|
||||
and parent_org_iD = #{sysOrg.parentOrgID}
|
||||
<if test="sysOrg.parentOrgId != null and sysOrg.parentOrgId != ''">
|
||||
and parent_org_id = #{sysOrg.parentOrgId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryAllOrgTree" resultMap="SysOrgMap">
|
||||
SELECT i.* FROM sys_org i WHERE i.id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryAllChildOrgTree" resultMap="SysOrgMap">
|
||||
SELECT i.* FROM sys_org i WHERE i.parent_org_id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
51
das/src/main/resources/mapper/SysRoleMapper.xml
Normal file
51
das/src/main/resources/mapper/SysRoleMapper.xml
Normal file
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!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.SysRoleMapper">
|
||||
|
||||
<resultMap type="com.das.modules.auth.entity.SysRole" id="SysRoleMap">
|
||||
<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"/>
|
||||
<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>
|
||||
|
||||
<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 != ''">
|
||||
and role_name like concat('%',#{sysRole.roleName},'%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="existRoleByRoleCode" resultType="java.lang.Long">
|
||||
select count(1) from sys_role t where t.role_code=#{roleCode}
|
||||
</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}
|
||||
</select>
|
||||
|
||||
<select id="selectByCode" resultMap="SysRoleMap">
|
||||
select * from sys_role t where t.role_code=#{roleCode}
|
||||
</select>
|
||||
|
||||
<select id="existRoleByName" resultType="java.lang.Long">
|
||||
select count(1) from sys_role t where t.role_name=#{name}
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -24,9 +24,6 @@
|
||||
<if test="sysUser.userName != null and sysUser.userName != ''">
|
||||
and user_name like concat('%',#{sysUser.userName},'%')
|
||||
</if>
|
||||
<if test="sysUser.phone != null and sysUser.phone != ''">
|
||||
and phone like concat('%',#{sysUser.phone},'%')
|
||||
</if>
|
||||
<if test="sysUser.orgId != null and sysUser.orgId != ''">
|
||||
and org_id = #{sysUser.orgId}
|
||||
</if>
|
||||
|
@ -182,7 +182,6 @@
|
||||
```json
|
||||
|
||||
{
|
||||
"id": "123",
|
||||
"menuName": "菜单1",
|
||||
"menuOrder": 1,
|
||||
"menuIcon": "icon1",
|
||||
@ -197,6 +196,18 @@
|
||||
"updatedTime": 12345
|
||||
}
|
||||
```
|
||||
入参描述
|
||||
|
||||
| 参数名 | 参数类型 | 可选 | 描述 |
|
||||
| ----------- |---------| ---- |--------|
|
||||
| menuName | String | YES | 菜单名称 |
|
||||
| menuOrder | Integer | YES | 菜单排列顺序 |
|
||||
| menuIcon | String | YES | 菜单图标名称 |
|
||||
| funType | Integer | YES | 菜单操作类型 |
|
||||
| funParam | String | YES | 菜单操作参数 |
|
||||
| authorityId | Long | YES | 权限ID |
|
||||
| parentMenuId | Long | YES | 上级菜单ID |
|
||||
| revision | Integer | YES | 乐观锁 |
|
||||
|
||||
调用成功返回示例
|
||||
|
||||
@ -233,7 +244,6 @@
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "123",
|
||||
"parentMenuId": "0"
|
||||
}
|
||||
```
|
||||
@ -322,7 +332,113 @@
|
||||
}
|
||||
```
|
||||
|
||||
## 2.5、获取所有菜单
|
||||
|
||||
```java
|
||||
请求接口 /api/menus/list
|
||||
```
|
||||
|
||||
入参定义
|
||||
|
||||
```json
|
||||
{
|
||||
"parentMenuId": 0,
|
||||
"recursive": true
|
||||
}
|
||||
```
|
||||
|
||||
调用成功返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "操作成功",
|
||||
"success": true,
|
||||
"data": [
|
||||
{
|
||||
"id": "123",
|
||||
"menuName": "菜单1",
|
||||
"menuOrder": 1,
|
||||
"menuIcon": "icon1",
|
||||
"funType": 1,
|
||||
"funParam": "param",
|
||||
"authorityId": "123",
|
||||
"parentMenuId": "0",
|
||||
"revision": 1,
|
||||
"createdBy": "aaa",
|
||||
"createdTime": 123456,
|
||||
"updatedBy": "aaa",
|
||||
"updatedTime": 12345
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 2.6、获取绑定菜单
|
||||
|
||||
```java
|
||||
请求接口 /api/menus/tree
|
||||
```
|
||||
|
||||
入参定义
|
||||
|
||||
```json
|
||||
|
||||
```
|
||||
|
||||
调用成功返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"success": true,
|
||||
"data": {
|
||||
"id": 73216735447089152,
|
||||
"menuName": "测试1",
|
||||
"menuOrder": 0,
|
||||
"menuIcon": "",
|
||||
"funType": 0,
|
||||
"funParam": "",
|
||||
"authorityId": 101,
|
||||
"parentMenuId": 0,
|
||||
"revision": 2,
|
||||
"createdTime": "2024-06-25 07:14:40",
|
||||
"updatedTime": "2024-06-25 07:14:40",
|
||||
"children": [
|
||||
{
|
||||
"id": 73216795998158848,
|
||||
"menuName": "测试2",
|
||||
"menuOrder": 0,
|
||||
"menuIcon": "",
|
||||
"funType": 1,
|
||||
"funParam": "2",
|
||||
"authorityId": 101,
|
||||
"parentMenuId": 73216735447089152,
|
||||
"revision": 1,
|
||||
"createdTime": "2024-06-25 07:18:31",
|
||||
"updatedTime": "2024-06-25 07:18:31",
|
||||
"children": [
|
||||
{
|
||||
"id": 73216799741313024,
|
||||
"menuName": "测试3",
|
||||
"menuOrder": 0,
|
||||
"menuIcon": "",
|
||||
"funType": 1,
|
||||
"funParam": "333",
|
||||
"authorityId": 101,
|
||||
"parentMenuId": 73216795998158848,
|
||||
"revision": 1,
|
||||
"createdTime": "2024-06-25 07:18:45",
|
||||
"updatedTime": "2024-06-25 07:18:45",
|
||||
"children": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"msg": "操作成功"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
!> 下面的文档有待确认
|
||||
@ -570,7 +686,52 @@
|
||||
}
|
||||
```
|
||||
|
||||
## 获取机构列表
|
||||
根据获取机构列表,POST方式
|
||||
|
||||
>/api/org/list
|
||||
|
||||
入参示例
|
||||
|
||||
```json
|
||||
{
|
||||
"parentOrgId":111,
|
||||
"recursive": true
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
入参描述
|
||||
|
||||
| 参数名 | 参数类型 | 可选 | 描述 |
|
||||
| ------ |---------| ---- |--------|
|
||||
| parentOrgId | Long | No | 机构id |
|
||||
| recursive | boolean | No | 是否是根节点 |
|
||||
|
||||
调用成功返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"success": true,
|
||||
"data": [
|
||||
{
|
||||
"id": "2",
|
||||
"name": "测试子公司",
|
||||
"mrid": "456",
|
||||
"province": "江苏",
|
||||
"city": "南京",
|
||||
"county": "玄武",
|
||||
"address": "测试地址1",
|
||||
"contactPhone": "555889",
|
||||
"remarks": "测试",
|
||||
"parentOrgId": 1,
|
||||
"revision": 1
|
||||
}
|
||||
],
|
||||
"msg": "操作成功"
|
||||
}
|
||||
```
|
||||
|
||||
# 4、职员模块API接口
|
||||
|
||||
@ -596,8 +757,7 @@
|
||||
```json
|
||||
{
|
||||
"userName":"xx",
|
||||
"orgId":"xxx",
|
||||
"phone":"xxx"
|
||||
"orgId":"xxx"
|
||||
}
|
||||
```
|
||||
|
||||
@ -607,7 +767,6 @@
|
||||
|:---------| :------: | :---: |:--------------------------|
|
||||
| userName | String | Yes | 模糊查询职员名称,当职员名称为空时查询所有职员信息 |
|
||||
| orgId | BIGINT | Yes | 所属机构ID |
|
||||
| phone | String | Yes | 手机号,模糊查询 |
|
||||
|
||||
调用成功返回示例
|
||||
|
||||
@ -831,14 +990,13 @@
|
||||
|
||||
提供获取所有系统角色的功能,POST方式
|
||||
|
||||
/api/user/getSysRole
|
||||
/api/role/query
|
||||
|
||||
入参示例
|
||||
|
||||
```
|
||||
```json
|
||||
{
|
||||
"roleName":"xxx",,
|
||||
"token":"xxx"
|
||||
"roleName":"xxx"
|
||||
}
|
||||
```
|
||||
|
||||
@ -847,25 +1005,24 @@
|
||||
| 参数名 | 参数类型 | 可选 | 描述 |
|
||||
| :------- | :------: | :--: | :----------------------------- |
|
||||
| roleName | String | YES | 系统角色为空时查询所有系统角色 |
|
||||
| token | String | NO | token |
|
||||
|
||||
调用成功返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code":"200",
|
||||
"msg":"调用成功",
|
||||
"data":[
|
||||
"total": 1,
|
||||
"rows": [
|
||||
{
|
||||
"id": "xxxx",
|
||||
"roleCode": "xxx",
|
||||
"roleName": "xxx",
|
||||
|
||||
},
|
||||
{
|
||||
...
|
||||
"createdTime": "2024-06-25 11:15:48",
|
||||
"updatedTime": "2024-06-25 11:15:48",
|
||||
"id": "73212978522226688",
|
||||
"roleCode": "001",
|
||||
"roleName": "测试角色",
|
||||
"revision": 1
|
||||
}
|
||||
]
|
||||
],
|
||||
"code": 200,
|
||||
"msg": "查询成功"
|
||||
}
|
||||
```
|
||||
|
||||
@ -879,15 +1036,13 @@
|
||||
|
||||
根据提供的ID,删除系统角色,POST方式
|
||||
|
||||
/api/user/deleteSysRole
|
||||
/api/role/delete
|
||||
|
||||
入参示例
|
||||
|
||||
```
|
||||
```json
|
||||
{
|
||||
"id":"xxx",,
|
||||
"token":"xxx"
|
||||
}
|
||||
"id":"xxx"
|
||||
```
|
||||
|
||||
入参描述
|
||||
@ -895,15 +1050,14 @@
|
||||
| 参数名 | 参数类型 | 可选 | 描述 |
|
||||
| :----- | :------: | :--: | :--------- |
|
||||
| id | BIGINT | NO | 系统角色id |
|
||||
| token | String | NO | token |
|
||||
|
||||
调用成功返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code":"200",
|
||||
"msg":"删除成功",
|
||||
"data":"null"
|
||||
"code": 200,
|
||||
"success": true,
|
||||
"msg": "操作成功"
|
||||
}
|
||||
```
|
||||
|
||||
@ -911,52 +1065,106 @@
|
||||
|
||||
根据添加的信息创建系统角色,POST方式
|
||||
|
||||
/api/user/addSysRole
|
||||
/api/role/add
|
||||
|
||||
入参示例
|
||||
|
||||
```
|
||||
```json
|
||||
{
|
||||
"id":"xxx",
|
||||
"roleCode":"XX",
|
||||
"roleName":"XX",
|
||||
"authorityList":["12","12"],
|
||||
"token":"xxx"
|
||||
"roleName":"测试角色",
|
||||
"roleCode":"001",
|
||||
"authList":[101,102,103]
|
||||
}
|
||||
```
|
||||
|
||||
入参描述
|
||||
|
||||
| 参数名 | 参数类型 | 可选 | 描述 |
|
||||
| :------------ | :----------: | :--: | :----------- |
|
||||
| id | BIGINT | no | 系统角色id |
|
||||
| roleCode | String | no | 角色编码 |
|
||||
| roleName | String | no | 角色名称 |
|
||||
| authorityList | List<String> | yes | 角色的权限id |
|
||||
| token | String | NO | token |
|
||||
| 参数名 | 参数类型 | 可选 | 描述 |
|
||||
| :------------ |:----------:| :--: | :----------- |
|
||||
| roleCode | String | no | 角色编码 |
|
||||
| roleName | String | no | 角色名称 |
|
||||
| authList | List<Long> | yes | 角色的权限id |
|
||||
|
||||
调用成功返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code":"200",
|
||||
"msg":"新增成功",
|
||||
"data":"null"
|
||||
"code": 200,
|
||||
"success": true,
|
||||
"data": {
|
||||
"roleName": "测试角色",
|
||||
"roleCode": "001",
|
||||
"authList": [
|
||||
101,
|
||||
102,
|
||||
103
|
||||
]
|
||||
},
|
||||
"msg": "操作成功"
|
||||
}
|
||||
```
|
||||
### 所有权限查询
|
||||
提供获取所有权限权限的功能,POST方式
|
||||
/api/authority/query
|
||||
|
||||
入参示例
|
||||
|
||||
无入参
|
||||
|
||||
调用成功返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"success": true,
|
||||
"data": [
|
||||
{
|
||||
"id": "101",
|
||||
"authorityCode": "systemMgr",
|
||||
"authorityName": "系统管理权限",
|
||||
"revision": 1
|
||||
},
|
||||
{
|
||||
"id": "102",
|
||||
"authorityCode": "equipmentLedgerManagement",
|
||||
"authorityName": "设备台账维护权限",
|
||||
"revision": 1
|
||||
},
|
||||
{
|
||||
"id": "103",
|
||||
"authorityCode": "equipmentLedgerView",
|
||||
"authorityName": "设备台账浏览权限",
|
||||
"revision": 1
|
||||
}
|
||||
],
|
||||
"msg": "操作成功"
|
||||
}
|
||||
```
|
||||
|
||||
调用成功返回
|
||||
|
||||
| 变量名 | 变量类型 | 可为NULL | 描述 |
|
||||
| -------- | -------- | -------- |------|
|
||||
| id | BIGINT | No | 主键id |
|
||||
| authorityCode | string | No | 权限编码 |
|
||||
| authorityName | string | No | 权限名称 |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### 角色权限查询
|
||||
|
||||
提供获取所有角色权限的功能,POST方式
|
||||
|
||||
/api/user/getAuthorityById
|
||||
/api/role/queryAuthorityById
|
||||
|
||||
入参示例
|
||||
|
||||
```
|
||||
```json
|
||||
{
|
||||
"id":"xxx",
|
||||
"token":"xxx"
|
||||
"id":"xxx"
|
||||
}
|
||||
```
|
||||
|
||||
@ -965,7 +1173,6 @@
|
||||
| 参数名 | 参数类型 | 可选 | 描述 |
|
||||
| :----- | :------: | :--: | :--------- |
|
||||
| id | BIGINT | NO | 系统角色id |
|
||||
| token | String | NO | token |
|
||||
|
||||
调用成功返回示例
|
||||
|
||||
@ -991,65 +1198,30 @@
|
||||
| authorityCode | string | No | 权限编码 |
|
||||
| authorityName | string | No | 权限名称 |
|
||||
|
||||
api/user/addSysRole
|
||||
|
||||
入参示例
|
||||
|
||||
```
|
||||
{
|
||||
"id":"xxx",
|
||||
"roleCode":"XX",
|
||||
"roleName":"XX",
|
||||
"authorityList":["12","12"],
|
||||
"token":"xxx"
|
||||
}
|
||||
```
|
||||
|
||||
入参描述
|
||||
|
||||
| 参数名 | 参数类型 | 可选 | 描述 |
|
||||
| :------------ | :----------: | :--: | :----------- |
|
||||
| id | BIGINT | no | 系统角色id |
|
||||
| roleCode | String | no | 角色编码 |
|
||||
| roleName | String | no | 角色名称 |
|
||||
| authorityList | List<String> | yes | 角色的权限id |
|
||||
| token | String | NO | token |
|
||||
|
||||
调用成功返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code":"200",
|
||||
"msg":"新增成功",
|
||||
"data":"null"
|
||||
}
|
||||
```
|
||||
|
||||
### 角色权限编辑
|
||||
|
||||
根据提供的ID,修改角色权限,POST方式
|
||||
|
||||
/api/user/updateAuthorityById
|
||||
/api/role/update
|
||||
|
||||
入参示例
|
||||
|
||||
```
|
||||
```json
|
||||
{
|
||||
"id":"xxx",
|
||||
"roleName":"XX",
|
||||
"authorityList":["12","12"],
|
||||
"token":"xxx"
|
||||
"authList":[12,13]
|
||||
}
|
||||
```
|
||||
|
||||
入参描述
|
||||
|
||||
| 参数名 | 参数类型 | 可选 | 描述 |
|
||||
| :------------ | :----------: | :--: | :----------- |
|
||||
| id | BIGINT | no | 系统角色id |
|
||||
| roleName | String | no | 角色名称 |
|
||||
| authorityList | List<String> | yes | 角色的权限id |
|
||||
| token | String | NO | token |
|
||||
| 参数名 | 参数类型 | 可选 | 描述 |
|
||||
| :------------ |:----------:| :--: | :----------- |
|
||||
| id | BIGINT | no | 系统角色id |
|
||||
| roleName | String | no | 角色名称 |
|
||||
| authList | List<Long> | yes | 角色的权限id |
|
||||
|
||||
调用成功返回示例
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
"axios": "1.7.2",
|
||||
"countup.js": "2.8.0",
|
||||
"echarts": "5.5.0",
|
||||
"element-china-area-data": "^6.1.0",
|
||||
"element-plus": "2.7.4",
|
||||
"esno": "4.7.0",
|
||||
"font-awesome": "4.7.0",
|
||||
|
6
ui/dasadmin/src/lang/common/en/management.ts
Normal file
6
ui/dasadmin/src/lang/common/en/management.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export default{
|
||||
search:'Search',
|
||||
add:'Add',
|
||||
'Query roles by name':'Query roles by name',
|
||||
'Are you sure to delete this?':'Are you sure to delete this?'
|
||||
}
|
6
ui/dasadmin/src/lang/common/zh-cn/management.ts
Normal file
6
ui/dasadmin/src/lang/common/zh-cn/management.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export default{
|
||||
search:'搜索',
|
||||
add:'新增',
|
||||
'Query roles by name':'按名称查询角色',
|
||||
'Are you sure to delete this?':'确定要删除吗?',
|
||||
}
|
@ -24,6 +24,7 @@ import { useEventListener } from '@vueuse/core'
|
||||
import { BEFORE_RESIZE_LAYOUT } from '/@/stores/constant/cacheKey'
|
||||
import { isEmpty } from 'lodash-es'
|
||||
import { setNavTabsWidth } from '/@/utils/layout'
|
||||
import { id } from 'element-plus/es/locales.mjs'
|
||||
|
||||
defineOptions({
|
||||
components: { Default, Classic, Streamline, Double },
|
||||
|
@ -0,0 +1,485 @@
|
||||
<template>
|
||||
<div class="institutionalManagement">
|
||||
<el-dialog v-model="dialogVible" :title="dialogTitle" width="600">
|
||||
<el-form :model="formModel" ref="formRef">
|
||||
<template v-for="item in addFormItemList" :key="item.prop">
|
||||
<el-form-item :prop="item.prop" :label="item.label" label-width="80" :rules="item.rules">
|
||||
<template v-if="item.type === 'input'">
|
||||
<el-input v-model="formModel[item.prop]" :placeholder="item.placeholder"></el-input>
|
||||
</template>
|
||||
<template v-if="item.type === 'custom'">
|
||||
<el-select
|
||||
v-if="item.prop === 'province'"
|
||||
v-model="formModel[item.prop]"
|
||||
:placeholder="item.placeholder"
|
||||
@change="changeProvince"
|
||||
>
|
||||
<el-option v-for="opt in provinceOptions" :key="opt.value" :label="opt.label" :value="opt.value"></el-option>
|
||||
</el-select>
|
||||
<el-select
|
||||
v-if="item.prop === 'county'"
|
||||
v-model="formModel[item.prop]"
|
||||
:placeholder="item.placeholder"
|
||||
@change="changeCounty"
|
||||
>
|
||||
<el-option v-for="opt in countyOptions" :key="opt.value" :label="opt.label" :value="opt.value"></el-option>
|
||||
</el-select>
|
||||
<el-select v-if="item.prop === 'city'" v-model="formModel[item.prop]" :placeholder="item.placeholder">
|
||||
<el-option v-for="opt in cityOptions" :key="opt.value" :label="opt.label" :value="opt.value"></el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="submitAddForm">提交</el-button>
|
||||
<el-button @click="closeAddForm">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-container>
|
||||
<el-aside class="defaultAside">
|
||||
<el-header class="treeHeader">
|
||||
<el-input v-model="searchInputTreeValue" :placeholder="treeSearchInputPlaceholder" class="searchInput"></el-input>
|
||||
</el-header>
|
||||
<el-main class="treeMain">
|
||||
<el-tree :data="treeData" lazy node-key="id" :load="loadTreeData" :props="treeReplaceProps" @node-click="treeNodeClick"></el-tree>
|
||||
</el-main>
|
||||
</el-aside>
|
||||
<el-container>
|
||||
<el-header class="defaultHeader">
|
||||
<div class="searchPart">
|
||||
<el-input v-model:value="searchTableInput" class="searchInput"></el-input>
|
||||
<el-button @click="searchTable" type="primary" :icon="Search" class="defaultBtn">{{ t('management.search') }}</el-button>
|
||||
</div>
|
||||
<el-button type="primary" :icon="Plus" class="defaultBtn" @click="addInstitutional">{{ t('management.add') }}</el-button>
|
||||
</el-header>
|
||||
<el-main class="defaultMain">
|
||||
<el-table :data="tableData">
|
||||
<el-table-column
|
||||
v-for="item in tableColumn"
|
||||
:key="item.key"
|
||||
:prop="item.prop"
|
||||
:label="item.label"
|
||||
:fixed="item.fixed"
|
||||
:align="item.align ?? 'center'"
|
||||
></el-table-column>
|
||||
<el-table-column fixed="right" label="操作" min-width="80" align="center">
|
||||
<template #default="scope">
|
||||
<div class="tableOperate">
|
||||
<a @click="editForm(scope.row)">编辑</a>
|
||||
<a>|</a>
|
||||
<el-popconfirm title="确定删除么?" @confirm="delForm(scope.row)">
|
||||
<template #reference>
|
||||
<a>删除</a>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-main>
|
||||
</el-container>
|
||||
</el-container>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import {
|
||||
ElContainer,
|
||||
ElAside,
|
||||
ElHeader,
|
||||
ElMain,
|
||||
ElInput,
|
||||
ElButton,
|
||||
ElTable,
|
||||
ElTree,
|
||||
ElDialog,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElSelect,
|
||||
ElOption,
|
||||
ElPopconfirm,
|
||||
ElMessage,
|
||||
} from 'element-plus'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import type Node from 'element-plus/es/components/tree/src/model/node'
|
||||
import { Plus, Search } from '@element-plus/icons-vue'
|
||||
import {
|
||||
getInstitutionalListReq,
|
||||
addInstitutionalListReq,
|
||||
changeInstitutionalListReq,
|
||||
delInstitutionalListReq,
|
||||
getInstitutionalTreeListReq,
|
||||
} from './request'
|
||||
import {
|
||||
addDataEnum,
|
||||
addDataType,
|
||||
formItemListType,
|
||||
addDataEnumKeyJointType,
|
||||
tableColumnType,
|
||||
changeDataType,
|
||||
selectDataType,
|
||||
getTreeDataReturnType,
|
||||
} from './type'
|
||||
import { pcaTextArr } from 'element-china-area-data'
|
||||
import { useAdminInfo } from '/@/stores/adminInfo'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
const { t } = useI18n()
|
||||
const adminInfo = useAdminInfo()
|
||||
const treeSearchInputPlaceholder = '搜索机构'
|
||||
const searchInputTreeValue = ref<string>('')
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const formModel = ref<addDataType | changeDataType>({
|
||||
mrid: '',
|
||||
name: '',
|
||||
aliasName: '',
|
||||
province: '',
|
||||
city: '',
|
||||
county: '',
|
||||
address: '',
|
||||
contactPhone: '',
|
||||
remarks: '',
|
||||
parentOrgId: null,
|
||||
revision: 1,
|
||||
})
|
||||
const defaultFormModel = JSON.parse(JSON.stringify(formModel.value))
|
||||
const provinceOptions: selectDataType[] = pcaTextArr
|
||||
const countyOptions = ref<selectDataType[]>([])
|
||||
const cityOptions = ref<selectDataType[]>([])
|
||||
const changeProvince = (value: string) => {
|
||||
const selectOptions = provinceOptions.find((item) => item.value === value)?.children
|
||||
selectOptions && (countyOptions.value = selectOptions)
|
||||
formModel.value.city = ''
|
||||
formModel.value.county = ''
|
||||
}
|
||||
|
||||
const changeCounty = (value: string) => {
|
||||
const selectOptions = countyOptions.value.find((item) => item.value === value)?.children
|
||||
selectOptions && (cityOptions.value = selectOptions)
|
||||
formModel.value.city = ''
|
||||
}
|
||||
const phoneReg = /^1(3|4|5|7|8|9)\d{9}$/
|
||||
const phoneRule = (rule: any, value: any, callback: any) => {
|
||||
if (!value) {
|
||||
callback(new Error('请输入手机号'))
|
||||
} else if (!phoneReg.test(value)) {
|
||||
callback(new Error('请输入正确的手机号'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const addFormItemList: formItemListType<addDataEnumKeyJointType>[] = [
|
||||
{
|
||||
type: 'input',
|
||||
prop: 'mrid',
|
||||
label: addDataEnum['mrid'],
|
||||
placeholder: `请输入${addDataEnum['mrid']}`,
|
||||
rules: [{ required: true, message: `请输入${addDataEnum['mrid']}`, trigger: 'blur' }],
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
prop: 'name',
|
||||
label: addDataEnum['name'],
|
||||
placeholder: `请输入${addDataEnum['name']}`,
|
||||
rules: [{ required: true, message: `请输入${addDataEnum['name']}`, trigger: 'blur' }],
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
prop: 'aliasName',
|
||||
label: addDataEnum['aliasName'],
|
||||
placeholder: `请输入${addDataEnum['aliasName']}`,
|
||||
rules: [{ required: true, message: `请输入${addDataEnum['aliasName']}`, trigger: 'blur' }],
|
||||
},
|
||||
{
|
||||
type: 'custom',
|
||||
prop: 'province',
|
||||
label: addDataEnum['province'],
|
||||
placeholder: `请选择${addDataEnum['province']}`,
|
||||
rules: [{ required: true, message: `请选择${addDataEnum['province']}`, trigger: 'blur' }],
|
||||
},
|
||||
{
|
||||
type: 'custom',
|
||||
prop: 'county',
|
||||
label: addDataEnum['county'],
|
||||
placeholder: `请选择${addDataEnum['county']}`,
|
||||
rules: [{ required: true, message: '请输入机构名称', trigger: 'blur' }],
|
||||
},
|
||||
|
||||
{
|
||||
type: 'custom',
|
||||
prop: 'city',
|
||||
label: addDataEnum['city'],
|
||||
placeholder: `请选择${addDataEnum['city']}`,
|
||||
rules: [{ required: true, message: `请选择${addDataEnum['city']}`, trigger: 'blur' }],
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
prop: 'address',
|
||||
label: addDataEnum['address'],
|
||||
placeholder: `请输入${addDataEnum['address']}`,
|
||||
rules: [{ required: true, message: `请输入${addDataEnum['address']}`, trigger: 'blur' }],
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
prop: 'contactPhone',
|
||||
label: addDataEnum['contactPhone'],
|
||||
placeholder: `请输入${addDataEnum['contactPhone']}`,
|
||||
rules: [{ required: true, validator: phoneRule, trigger: 'blur' }],
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
prop: 'parentOrgId',
|
||||
label: addDataEnum['parentOrgId'],
|
||||
placeholder: `请选择${addDataEnum['parentOrgId']}`,
|
||||
rules: [{ required: true, message: `请选择${addDataEnum['parentOrgId']}`, trigger: 'blur' }],
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
prop: 'remarks',
|
||||
label: addDataEnum['remarks'],
|
||||
placeholder: `请输入${addDataEnum['remarks']}`,
|
||||
rules: [{ required: true, message: `请输入${addDataEnum['remarks']}`, trigger: 'blur' }],
|
||||
},
|
||||
]
|
||||
const dialogTitle = ref('新增机构')
|
||||
const dialogVible = ref(false)
|
||||
const addInstitutional = () => {
|
||||
dialogTitle.value = '新增机构'
|
||||
formRef.value && formRef.value.resetFields()
|
||||
formModel.value = defaultFormModel
|
||||
dialogVible.value = true
|
||||
}
|
||||
|
||||
const submitAddForm = () => {
|
||||
console.log(formModel.value)
|
||||
if (!formRef.value) return
|
||||
formRef.value.validate((valid) => {
|
||||
if (valid) {
|
||||
if (dialogTitle.value === '新增机构') {
|
||||
addInstitutionalListReq(formModel.value).then((res) => {
|
||||
if (res.success) {
|
||||
ElMessage.success('新增成功')
|
||||
getInstitutionList()
|
||||
dialogVible.value = false
|
||||
}
|
||||
})
|
||||
} else if (dialogTitle.value === '编辑机构') {
|
||||
changeInstitutionalListReq(formModel.value as changeDataType).then((res) => {
|
||||
if (res.success) {
|
||||
ElMessage.success('编辑成功')
|
||||
getInstitutionList()
|
||||
dialogVible.value = false
|
||||
} else {
|
||||
ElMessage.error('编辑失败')
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
const closeAddForm = () => {
|
||||
dialogVible.value = false
|
||||
}
|
||||
|
||||
const getInstitutionList = () => {
|
||||
getInstitutionalListReq({
|
||||
name: null,
|
||||
}).then((res) => {
|
||||
console.log(res)
|
||||
|
||||
tableData.value = res.rows
|
||||
})
|
||||
}
|
||||
|
||||
const tableData = ref<getTreeDataReturnType[]>()
|
||||
const tableColumn: tableColumnType<addDataEnumKeyJointType>[] = [
|
||||
{
|
||||
key: 'mridColumn',
|
||||
prop: 'mrid',
|
||||
label: addDataEnum['mrid'],
|
||||
},
|
||||
{
|
||||
key: 'nameColumn',
|
||||
prop: 'name',
|
||||
label: addDataEnum['name'],
|
||||
},
|
||||
{
|
||||
key: 'aliasNameColumn',
|
||||
prop: 'aliasName',
|
||||
label: addDataEnum['aliasName'],
|
||||
},
|
||||
{
|
||||
key: 'provinceColumn',
|
||||
prop: 'province',
|
||||
label: addDataEnum['province'],
|
||||
},
|
||||
{
|
||||
key: 'cityColumn',
|
||||
prop: 'city',
|
||||
label: addDataEnum['city'],
|
||||
},
|
||||
{
|
||||
key: 'countyColumn',
|
||||
prop: 'county',
|
||||
label: addDataEnum['county'],
|
||||
},
|
||||
{
|
||||
key: 'addressColumn',
|
||||
prop: 'address',
|
||||
label: addDataEnum['address'],
|
||||
},
|
||||
{
|
||||
key: 'contactPhoneColumn',
|
||||
prop: 'contactPhone',
|
||||
label: addDataEnum['contactPhone'],
|
||||
},
|
||||
{
|
||||
key: 'remarksColumn',
|
||||
prop: 'remarks',
|
||||
label: addDataEnum['remarks'],
|
||||
},
|
||||
{
|
||||
key: 'parentOrgIdColumn',
|
||||
prop: 'parentOrgId',
|
||||
label: addDataEnum['parentOrgId'],
|
||||
},
|
||||
]
|
||||
|
||||
const editForm = (column: changeDataType) => {
|
||||
formModel.value = JSON.parse(JSON.stringify(column))
|
||||
formModel.value.parentOrgId = 1
|
||||
|
||||
dialogTitle.value = '编辑机构'
|
||||
dialogVible.value = true
|
||||
}
|
||||
|
||||
const delForm = (column: changeDataType) => {
|
||||
delInstitutionalListReq({ id: column.id }).then((res) => {
|
||||
if (res.success) {
|
||||
ElMessage.success('删除成功')
|
||||
getInstitutionList()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const treeData = ref<getTreeDataReturnType[]>()
|
||||
const treeReplaceProps = {
|
||||
children: 'children',
|
||||
label: 'name',
|
||||
}
|
||||
const loadTreeData = (node: Node, resolve: any) => {
|
||||
if (node.level === 0) {
|
||||
return resolve([])
|
||||
}
|
||||
getTreeData(node.data.id)
|
||||
.then((res) => {
|
||||
if (!res.length) {
|
||||
node.data.isLeaf = true
|
||||
}
|
||||
tableData.value = [...res]
|
||||
return resolve(res)
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
|
||||
const getTreeData = (orgId: number | string, recursive = false) => {
|
||||
return new Promise((resolve: (data: getTreeDataReturnType[]) => unknown) => {
|
||||
getInstitutionalTreeListReq({ parentOrgId: orgId, recursive: recursive }).then((res) => {
|
||||
if (res.data) {
|
||||
resolve(res.data)
|
||||
} else {
|
||||
resolve([])
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
const initData = () => {
|
||||
getTreeData(adminInfo.orgid, true)
|
||||
.then((res) => {
|
||||
console.log(res)
|
||||
treeData.value = [...res]
|
||||
return
|
||||
})
|
||||
.then(() => {
|
||||
return getTreeData(adminInfo.orgid)
|
||||
})
|
||||
.then((res) => {
|
||||
tableData.value = [...res]
|
||||
})
|
||||
}
|
||||
const treeNodeClick = (nodeData: getTreeDataReturnType, node: Node) => {
|
||||
console.log(node.childNodes, nodeData.isLeaf)
|
||||
|
||||
if (node.childNodes.length || nodeData.isLeaf) {
|
||||
getTreeData(nodeData.id).then((res) => {
|
||||
tableData.value = [...res]
|
||||
})
|
||||
}
|
||||
}
|
||||
const searchTableInput = ref('')
|
||||
const searchTable = () => {
|
||||
if (searchTableInput.value === '') return
|
||||
// table搜索
|
||||
}
|
||||
onMounted(() => {
|
||||
initData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@mixin searchInput($value) {
|
||||
margin-right: $value;
|
||||
width: 220px;
|
||||
height: 40px;
|
||||
}
|
||||
.institutionalManagement {
|
||||
.defaultAside {
|
||||
width: 260px;
|
||||
border-right: 1px solid #eaebed;
|
||||
.treeHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
.searchInput {
|
||||
@include searchInput(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
.defaultHeader {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
.searchPart {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.defaultBtn {
|
||||
width: 88px;
|
||||
height: 40px;
|
||||
}
|
||||
.searchInput {
|
||||
@include searchInput(10px);
|
||||
}
|
||||
}
|
||||
.defaultMain {
|
||||
.tableOperate {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
a {
|
||||
margin: 5px;
|
||||
color: #0064aa;
|
||||
font-weight: 600;
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
@ -0,0 +1,43 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
import { getDataType, addDataType, changeDataType, delDataType, getDataReturnType, operateDataReturnType, getTreeDataType,getTreeDataReturnType } from './type'
|
||||
|
||||
export const getInstitutionalListReq = (data: getDataType) => {
|
||||
return createAxios<addDataType, getDataReturnType<changeDataType>>({
|
||||
url: '/api/org/query',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const addInstitutionalListReq = (data: addDataType) => {
|
||||
return createAxios<never, operateDataReturnType>({
|
||||
url: '/api/org/add',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const changeInstitutionalListReq = (data: changeDataType) => {
|
||||
return createAxios<never, operateDataReturnType>({
|
||||
url: '/api/org/update',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const delInstitutionalListReq = (data: delDataType) => {
|
||||
return createAxios<never, operateDataReturnType>({
|
||||
url: '/api/org/delete',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const getInstitutionalTreeListReq = (data: getTreeDataType) => {
|
||||
console.log(data);
|
||||
return createAxios<never, operateDataReturnType<getTreeDataReturnType[]>>({
|
||||
url: '/api/org/list',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
107
ui/dasadmin/src/views/backend/InstitutionalManagement/type.ts
Normal file
107
ui/dasadmin/src/views/backend/InstitutionalManagement/type.ts
Normal file
@ -0,0 +1,107 @@
|
||||
export type getDataType = {
|
||||
name?: string | null
|
||||
parentOrgId?: string
|
||||
province?: string
|
||||
city?: string
|
||||
county?: string
|
||||
}
|
||||
export type getDataReturnType<T extends any> = Promise<{
|
||||
code: number
|
||||
msg: string
|
||||
rows: T[]
|
||||
total: number
|
||||
}>
|
||||
|
||||
export enum addDataEnum {
|
||||
mrid = '机构编码',
|
||||
name = '机构名称',
|
||||
aliasName = '机构简称',
|
||||
province = '机构省份',
|
||||
city = '机构城市',
|
||||
county = '机构区县',
|
||||
address = '详细地址',
|
||||
contactPhone = '联系电话',
|
||||
remarks = '备注',
|
||||
parentOrgId = '上级机构',
|
||||
}
|
||||
export type addDataEnumKeyJointType = keyof typeof addDataEnum
|
||||
export type formItemListType<T extends addDataEnumKeyJointType> = {
|
||||
type: 'input' | 'select' | 'custom'
|
||||
prop: T
|
||||
label: (typeof addDataEnum)[T]
|
||||
placeholder: `请输入${(typeof addDataEnum)[T]}` | `请选择${(typeof addDataEnum)[T]}`
|
||||
rules:
|
||||
| [{ required: boolean; message: `请输入${(typeof addDataEnum)[T]}` | `请选择${(typeof addDataEnum)[T]}`; trigger: 'blur' | 'change' }]
|
||||
| [{ required?: boolean; validator: (rule: any, value: any, callback: any) => void; trigger: 'blur' | 'change' }]
|
||||
}
|
||||
export type selectDataType = {
|
||||
label: string
|
||||
value: string
|
||||
children?: selectDataType[]
|
||||
}
|
||||
export type addDataType = {
|
||||
mrid: string
|
||||
name: string
|
||||
aliasName: string
|
||||
province: string
|
||||
city: string
|
||||
county: string
|
||||
address: string
|
||||
contactPhone: string
|
||||
remarks: string
|
||||
parentOrgId: number | null
|
||||
revision: number
|
||||
}
|
||||
|
||||
export type changeDataType = {
|
||||
id: string
|
||||
mrid: string
|
||||
name: string
|
||||
aliasName: string
|
||||
province: string
|
||||
city: string
|
||||
county: string
|
||||
address: string
|
||||
contactPhone: string
|
||||
remarks: string
|
||||
parentOrgId: number
|
||||
revision: number
|
||||
}
|
||||
export type operateDataReturnType<T = any> = Promise<{
|
||||
code: number
|
||||
msg: string
|
||||
success: boolean
|
||||
data?: T
|
||||
}>
|
||||
|
||||
export type delDataType = {
|
||||
id: string
|
||||
}
|
||||
export type getTreeDataType = {
|
||||
parentOrgId: number|string
|
||||
recursive: boolean
|
||||
}
|
||||
|
||||
export type tableColumnType<T extends addDataEnumKeyJointType> = {
|
||||
key: string
|
||||
prop: T
|
||||
label: (typeof addDataEnum)[T]
|
||||
fixed?: boolean
|
||||
align?: 'left' | 'center' | 'right'
|
||||
}
|
||||
|
||||
export type getTreeDataReturnType = {
|
||||
address: string
|
||||
children?: getTreeDataReturnType[]
|
||||
city: string
|
||||
contactPhone: string
|
||||
county: string
|
||||
id: string
|
||||
mrid: string
|
||||
name: string
|
||||
parentOrgId: number
|
||||
province: string
|
||||
remarks: string
|
||||
revision: number
|
||||
isLeaf?:boolean
|
||||
}
|
246
ui/dasadmin/src/views/backend/RoleManagement/RoleManagement.vue
Normal file
246
ui/dasadmin/src/views/backend/RoleManagement/RoleManagement.vue
Normal file
@ -0,0 +1,246 @@
|
||||
<template>
|
||||
<div class="roleManagement">
|
||||
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="600">
|
||||
<el-form :model="formModel" ref="formRef">
|
||||
<template v-for="item in formColumnList" :key="item.prop">
|
||||
<el-form-item :label="item.label" :rules="item.rule" :label-width="80" :prop="item.prop">
|
||||
<template v-if="item.type === 'input'">
|
||||
<el-input v-model="formModel[item.prop]" :placeholder="'请输入' + item.label"></el-input>
|
||||
</template>
|
||||
<template v-if="item.type === 'custom'">
|
||||
<template v-if="item.prop === 'authList'">
|
||||
<el-select v-model="formModel[item.prop]" multiple :placeholder="'请选择' + item.label">
|
||||
<el-option
|
||||
v-for="item in authorityListOptions"
|
||||
:key="item.id"
|
||||
:label="item.authorityName"
|
||||
:value="item.id"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</template>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="submitForm">提交</el-button>
|
||||
<el-button @click="cancelSubmitForm">取消</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-container>
|
||||
<el-header class="containerHeader">
|
||||
<div class="searchPart">
|
||||
<el-input class="searchInput" v-model:value="searchInputValue" :placeholder="searchInputPlacehoder"></el-input>
|
||||
<el-button type="primary" :icon="Search" class="defaultBtn" @click="searchClick">{{ t('management.search') }}</el-button>
|
||||
</div>
|
||||
<el-button type="primary" :icon="Plus" class="defaultBtn" @click="addClick">{{ t('management.add') }}</el-button>
|
||||
</el-header>
|
||||
<el-main class="containerMain">
|
||||
<el-table :data="tableData">
|
||||
<el-table-column
|
||||
v-for="item in tableColumn"
|
||||
:key="item.key"
|
||||
:prop="item.prop"
|
||||
:label="item.label"
|
||||
:fixed="item.fixed"
|
||||
:align="item.align ?? 'center'"
|
||||
></el-table-column>
|
||||
<el-table-column fixed="right" label="操作" align="center">
|
||||
<template #default="scope">
|
||||
<div class="tableOperate">
|
||||
<a @click="editForm(scope.row)">编辑</a>
|
||||
<a>|</a>
|
||||
<el-popconfirm title="确定删除么?" @confirm="delForm(scope.row)">
|
||||
<template #reference>
|
||||
<a>删除</a>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-main>
|
||||
</el-container>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ElContainer, ElHeader, ElMain, ElInput, ElButton, ElTable, ElTableColumn, ElDialog, ElForm, ElFormItem, ElMessage } from 'element-plus'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import { Plus, Search } from '@element-plus/icons-vue'
|
||||
import {
|
||||
tableDataType,
|
||||
tableColumnType,
|
||||
formDataEnum,
|
||||
formDataEnumKeyJointType,
|
||||
formColumnListType,
|
||||
formDataType,
|
||||
authorityDataListType,
|
||||
} from './type'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { getRoleListReq, changeRoleListReq, addRoleListReq, delRoleListReq, getAllRoleListReq } from './request'
|
||||
import { placeholderSign } from 'element-plus/es/components/table-v2/src/private.mjs'
|
||||
|
||||
const { t } = useI18n()
|
||||
const dialogTitle = ref('新增角色')
|
||||
const dialogVisible = ref(false)
|
||||
const formModel = ref<formDataType>({
|
||||
id: '',
|
||||
authList: [],
|
||||
roleName: '',
|
||||
roleCode: '',
|
||||
})
|
||||
const defaultFormModel = JSON.parse(JSON.stringify(formModel.value))
|
||||
const formColumnList: formColumnListType<formDataEnumKeyJointType>[] = [
|
||||
{ type: 'input', label: formDataEnum['roleName'], prop: 'roleName', rule: [{ required: true, message: '请输入角色名称', trigger: 'blur' }] },
|
||||
{ type: 'input', label: formDataEnum['roleCode'], prop: 'roleCode', rule: [{ required: true, message: '请输入角色编码', trigger: 'blur' }] },
|
||||
{
|
||||
type: 'custom',
|
||||
label: formDataEnum['authList'],
|
||||
prop: 'authList',
|
||||
rule: [{ required: true, message: '请选择权限列表', trigger: 'change' }],
|
||||
},
|
||||
]
|
||||
const authorityListOptions = ref<authorityDataListType[]>([])
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const submitForm = () => {
|
||||
if (!formRef.value) return
|
||||
formRef.value.validate((valid) => {
|
||||
console.log(valid);
|
||||
|
||||
if (valid) {
|
||||
if (dialogTitle.value === '新增角色') {
|
||||
console.log(formModel.value)
|
||||
|
||||
addRoleListReq(formModel.value).then((res) => {
|
||||
if (res.success) {
|
||||
getRoleList()
|
||||
ElMessage.success('新增成功')
|
||||
}
|
||||
}).catch(err=>{
|
||||
ElMessage.error(err?.response?.data?.msg ?? '新增失败')
|
||||
})
|
||||
dialogVisible.value = false
|
||||
} else if (dialogTitle.value === '编辑角色') {
|
||||
changeRoleListReq(formModel.value)
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
getRoleList()
|
||||
ElMessage.success('编辑成功')
|
||||
}
|
||||
|
||||
dialogVisible.value = false
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '编辑失败')
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
const cancelSubmitForm = () => {
|
||||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
const searchInputPlacehoder = t('management.Query roles by name')
|
||||
const searchInputValue = ref<string>('')
|
||||
const searchClick = () => {
|
||||
if (!searchInputValue.value) return
|
||||
}
|
||||
|
||||
const tableColumn = ref<tableColumnType<formDataEnumKeyJointType>[]>([
|
||||
{
|
||||
key: 'roleName-table',
|
||||
prop: 'roleName',
|
||||
label: formDataEnum['roleName'],
|
||||
},
|
||||
{
|
||||
key: 'roleCode_table',
|
||||
prop: 'roleCode',
|
||||
label: formDataEnum['roleCode'],
|
||||
},
|
||||
{
|
||||
label: formDataEnum['authList'],
|
||||
prop: 'authList',
|
||||
key: 'authList-table',
|
||||
},
|
||||
])
|
||||
const tableData = ref<tableDataType[]>([])
|
||||
|
||||
const addClick = () => {
|
||||
// 新增角色
|
||||
dialogTitle.value = '新增角色'
|
||||
formRef.value && formRef.value.resetFields()
|
||||
formModel.value = defaultFormModel
|
||||
|
||||
dialogVisible.value = true
|
||||
}
|
||||
const editForm = (formData: formDataType) => {
|
||||
const data = JSON.parse(JSON.stringify(formData))
|
||||
dialogTitle.value = '编辑角色'
|
||||
formModel.value = data
|
||||
dialogVisible.value = true
|
||||
}
|
||||
const delForm = (formData: formDataType) => {
|
||||
delRoleListReq({ id: formData.id }).then((res) => {
|
||||
if (res.success) {
|
||||
ElMessage.success('删除成功')
|
||||
getRoleList()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const getRoleList = (roleName = '') => {
|
||||
getRoleListReq({
|
||||
roleName,
|
||||
}).then((res) => {
|
||||
tableData.value = res.rows
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
getRoleList()
|
||||
getAllRoleListReq().then((res) => {
|
||||
authorityListOptions.value = [...res.data]
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.roleManagement {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
.containerHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
.searchInput {
|
||||
margin-right: 10px;
|
||||
width: 220px;
|
||||
height: 40px;
|
||||
}
|
||||
.defaultBtn {
|
||||
width: 88px;
|
||||
height: 40px;
|
||||
}
|
||||
}
|
||||
.containerMain {
|
||||
width: 100%;
|
||||
.tableOperate {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
a {
|
||||
margin: 5px;
|
||||
color: #0064aa;
|
||||
font-weight: 600;
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
51
ui/dasadmin/src/views/backend/RoleManagement/request.ts
Normal file
51
ui/dasadmin/src/views/backend/RoleManagement/request.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
import {
|
||||
roleListReturnType,
|
||||
roleListReturnDataType,
|
||||
getDataType,
|
||||
getDataReturnType,
|
||||
changeDataType,
|
||||
changeDataReturnType,
|
||||
addDataType,
|
||||
addDataReturnType,
|
||||
delDataType,
|
||||
authorityDataListType
|
||||
} from './type'
|
||||
export const getRoleListReq = (params: getDataType) => {
|
||||
return createAxios<never, roleListReturnType<getDataReturnType>>({
|
||||
url: '/api/role/query',
|
||||
method: 'post',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
export const changeRoleListReq = (params: changeDataType) => {
|
||||
return createAxios<never,roleListReturnDataType<changeDataReturnType>>({
|
||||
url: '/api/role/update',
|
||||
method: 'post',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
export const addRoleListReq = (params: addDataType) => {
|
||||
return createAxios<never,roleListReturnDataType<addDataReturnType>>({
|
||||
url: '/api/role/add',
|
||||
method: 'post',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
export const delRoleListReq = (params: delDataType) => {
|
||||
return createAxios<never, roleListReturnDataType<never>>({
|
||||
url: '/api/role/delete',
|
||||
method: 'post',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
export const getAllRoleListReq = () => {
|
||||
return createAxios<never,roleListReturnDataType<authorityDataListType>>({
|
||||
url: '/api/authority/query',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
92
ui/dasadmin/src/views/backend/RoleManagement/type.ts
Normal file
92
ui/dasadmin/src/views/backend/RoleManagement/type.ts
Normal file
@ -0,0 +1,92 @@
|
||||
export enum formDataEnum {
|
||||
id = '系统角色id',
|
||||
authList = '角色权限',
|
||||
roleName = '角色名称',
|
||||
roleCode = '角色编码',
|
||||
}
|
||||
|
||||
export type formDataType = {
|
||||
id: string
|
||||
authList: number[]
|
||||
roleName: string
|
||||
roleCode: string
|
||||
}
|
||||
export type formDataEnumKeyJointType = keyof typeof formDataEnum
|
||||
|
||||
export type formColumnListType<T extends formDataEnumKeyJointType> = {
|
||||
key?: string
|
||||
label: (typeof formDataEnum)[T]
|
||||
prop: T
|
||||
type: 'input' | 'custom'
|
||||
fixed?: boolean
|
||||
align?: 'center' | 'left' | 'right'
|
||||
rule:
|
||||
| [{ required: true; message: string; trigger: 'blur' | 'change' }]
|
||||
| [{ validator: (rule: any, value: any, callback: any) => void; trigger: 'blur' | 'change' }]
|
||||
}
|
||||
|
||||
export type tableDataType = {
|
||||
createdTime?: string
|
||||
id: string
|
||||
revision: number
|
||||
roleCode: number
|
||||
roleName: string
|
||||
updatedTime?: string
|
||||
}
|
||||
|
||||
export type tableColumnType<T extends formDataEnumKeyJointType> = {
|
||||
key: string
|
||||
prop: T
|
||||
label: (typeof formDataEnum)[T]
|
||||
fixed?: boolean
|
||||
align?: 'left' | 'center' | 'right'
|
||||
}
|
||||
|
||||
export type authorityDataListType = {
|
||||
authorityCode: string
|
||||
authorityName: string
|
||||
id: string
|
||||
revision: number
|
||||
}
|
||||
|
||||
export type roleListReturnType<T> = Promise<{
|
||||
code: number
|
||||
msg: string
|
||||
rows: T[]
|
||||
total: number
|
||||
}>
|
||||
export type roleListReturnDataType<T> = Promise<{
|
||||
code: number
|
||||
msg: string
|
||||
data: T[]
|
||||
success: boolean
|
||||
}>
|
||||
export type getDataType = {
|
||||
roleName: string
|
||||
}
|
||||
|
||||
export type getDataReturnType = {
|
||||
createdTime: string
|
||||
id: string
|
||||
revision: number
|
||||
roleCode: number
|
||||
roleName: string
|
||||
updatedTime: string
|
||||
}
|
||||
|
||||
export type changeDataType = Omit<formDataType, 'roleCode'>
|
||||
|
||||
export type changeDataReturnType = {
|
||||
authList: number[]
|
||||
id: string
|
||||
roleCode: string
|
||||
roleName: string
|
||||
}
|
||||
export type addDataType = Omit<formDataType, 'id'>
|
||||
|
||||
export type addDataReturnType = changeDataReturnType
|
||||
|
||||
export type delDataType = {
|
||||
id: string
|
||||
}
|
||||
|
@ -183,14 +183,12 @@ const onSubmit = () => {
|
||||
state.submitLoading = true
|
||||
login(form)
|
||||
.then((res) => {
|
||||
console.log(res,"res111111");
|
||||
|
||||
if (res.code == 200) {
|
||||
adminInfo.dataFill({
|
||||
id: res.data.sysUser.id,
|
||||
username: res.data.sysUser.account,
|
||||
nickname: res.data.sysUser.userName,
|
||||
orgid:res.data.sysUser.orgId,
|
||||
orgid: res.data.sysUser.orgId,
|
||||
avatar: '',
|
||||
last_login_time: '',
|
||||
token: res.data.token,
|
||||
|
Loading…
Reference in New Issue
Block a user