mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-07 21:09:33 +00:00
update 补全 接口文档注解 调整返回类型为 R
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package com.ruoyi.common.core.domain;
|
package com.ruoyi.common.core.domain;
|
||||||
|
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@@ -9,10 +11,11 @@ import java.io.Serializable;
|
|||||||
/**
|
/**
|
||||||
* 响应信息主体
|
* 响应信息主体
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
@ApiModel("请求响应对象")
|
||||||
public class R<T> implements Serializable {
|
public class R<T> implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -26,10 +29,13 @@ public class R<T> implements Serializable {
|
|||||||
*/
|
*/
|
||||||
public static final int FAIL = Constants.FAIL;
|
public static final int FAIL = Constants.FAIL;
|
||||||
|
|
||||||
|
@ApiModelProperty("消息状态码")
|
||||||
private int code;
|
private int code;
|
||||||
|
|
||||||
|
@ApiModelProperty("消息内容")
|
||||||
private String msg;
|
private String msg;
|
||||||
|
|
||||||
|
@ApiModelProperty("数据对象")
|
||||||
private T data;
|
private T data;
|
||||||
|
|
||||||
public static <T> R<T> ok() {
|
public static <T> R<T> ok() {
|
||||||
@@ -40,6 +46,10 @@ public class R<T> implements Serializable {
|
|||||||
return restResult(data, SUCCESS, null);
|
return restResult(data, SUCCESS, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> R<T> ok(String msg) {
|
||||||
|
return restResult(null, SUCCESS, msg);
|
||||||
|
}
|
||||||
|
|
||||||
public static <T> R<T> ok(T data, String msg) {
|
public static <T> R<T> ok(T data, String msg) {
|
||||||
return restResult(data, SUCCESS, msg);
|
return restResult(data, SUCCESS, msg);
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package com.ruoyi.common.core.web.controller;
|
package com.ruoyi.common.core.web.controller;
|
||||||
|
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,8 +17,8 @@ public class BaseController {
|
|||||||
* @param rows 影响行数
|
* @param rows 影响行数
|
||||||
* @return 操作结果
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
protected AjaxResult toAjax(int rows) {
|
protected R<Void> toAjax(int rows) {
|
||||||
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
return rows > 0 ? R.ok() : R.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,35 +27,35 @@ public class BaseController {
|
|||||||
* @param result 结果
|
* @param result 结果
|
||||||
* @return 操作结果
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
protected AjaxResult toAjax(boolean result) {
|
protected R<Void> toAjax(boolean result) {
|
||||||
return result ? success() : error();
|
return result ? success() : error();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回成功
|
* 返回成功
|
||||||
*/
|
*/
|
||||||
public AjaxResult success() {
|
public R<Void> success() {
|
||||||
return AjaxResult.success();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回失败消息
|
* 返回失败消息
|
||||||
*/
|
*/
|
||||||
public AjaxResult error() {
|
public R<Void> error() {
|
||||||
return AjaxResult.error();
|
return R.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回成功消息
|
* 返回成功消息
|
||||||
*/
|
*/
|
||||||
public AjaxResult success(String message) {
|
public R<Void> success(String message) {
|
||||||
return AjaxResult.success(message);
|
return R.ok(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回失败消息
|
* 返回失败消息
|
||||||
*/
|
*/
|
||||||
public AjaxResult error(String message) {
|
public R<Void> error(String message) {
|
||||||
return AjaxResult.error(message);
|
return R.fail(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,156 +0,0 @@
|
|||||||
package com.ruoyi.common.core.web.domain;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.ruoyi.common.core.constant.HttpStatus;
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作消息提醒
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class AjaxResult extends HashMap<String, Object> {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态码
|
|
||||||
*/
|
|
||||||
public static final String CODE_TAG = "code";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回内容
|
|
||||||
*/
|
|
||||||
public static final String MSG_TAG = "msg";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据对象
|
|
||||||
*/
|
|
||||||
public static final String DATA_TAG = "data";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
|
|
||||||
*/
|
|
||||||
public AjaxResult() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化一个新创建的 AjaxResult 对象
|
|
||||||
*
|
|
||||||
* @param code 状态码
|
|
||||||
* @param msg 返回内容
|
|
||||||
*/
|
|
||||||
public AjaxResult(int code, String msg) {
|
|
||||||
super.put(CODE_TAG, code);
|
|
||||||
super.put(MSG_TAG, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化一个新创建的 AjaxResult 对象
|
|
||||||
*
|
|
||||||
* @param code 状态码
|
|
||||||
* @param msg 返回内容
|
|
||||||
* @param data 数据对象
|
|
||||||
*/
|
|
||||||
public AjaxResult(int code, String msg, Object data) {
|
|
||||||
super.put(CODE_TAG, code);
|
|
||||||
super.put(MSG_TAG, msg);
|
|
||||||
if (ObjectUtil.isNotNull(data)) {
|
|
||||||
super.put(DATA_TAG, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 方便链式调用
|
|
||||||
*
|
|
||||||
* @param key
|
|
||||||
* @param value
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public AjaxResult put(String key, Object value) {
|
|
||||||
super.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回成功消息
|
|
||||||
*
|
|
||||||
* @return 成功消息
|
|
||||||
*/
|
|
||||||
public static AjaxResult success() {
|
|
||||||
return AjaxResult.success("操作成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回成功数据
|
|
||||||
*
|
|
||||||
* @return 成功消息
|
|
||||||
*/
|
|
||||||
public static AjaxResult success(Object data) {
|
|
||||||
return AjaxResult.success("操作成功", data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回成功消息
|
|
||||||
*
|
|
||||||
* @param msg 返回内容
|
|
||||||
* @return 成功消息
|
|
||||||
*/
|
|
||||||
public static AjaxResult success(String msg) {
|
|
||||||
return AjaxResult.success(msg, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回成功消息
|
|
||||||
*
|
|
||||||
* @param msg 返回内容
|
|
||||||
* @param data 数据对象
|
|
||||||
* @return 成功消息
|
|
||||||
*/
|
|
||||||
public static AjaxResult success(String msg, Object data) {
|
|
||||||
return new AjaxResult(HttpStatus.SUCCESS, msg, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回错误消息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static AjaxResult error() {
|
|
||||||
return AjaxResult.error("操作失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回错误消息
|
|
||||||
*
|
|
||||||
* @param msg 返回内容
|
|
||||||
* @return 警告消息
|
|
||||||
*/
|
|
||||||
public static AjaxResult error(String msg) {
|
|
||||||
return AjaxResult.error(msg, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回错误消息
|
|
||||||
*
|
|
||||||
* @param msg 返回内容
|
|
||||||
* @param data 数据对象
|
|
||||||
* @return 警告消息
|
|
||||||
*/
|
|
||||||
public static AjaxResult error(String msg, Object data) {
|
|
||||||
return new AjaxResult(HttpStatus.ERROR, msg, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回错误消息
|
|
||||||
*
|
|
||||||
* @param code 状态码
|
|
||||||
* @param msg 返回内容
|
|
||||||
* @return 警告消息
|
|
||||||
*/
|
|
||||||
public static AjaxResult error(int code, String msg) {
|
|
||||||
return new AjaxResult(code, msg, null);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -6,9 +6,9 @@ import cn.dev33.satoken.exception.NotPermissionException;
|
|||||||
import cn.dev33.satoken.exception.NotRoleException;
|
import cn.dev33.satoken.exception.NotRoleException;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.HttpStatus;
|
import com.ruoyi.common.core.constant.HttpStatus;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.exception.DemoModeException;
|
import com.ruoyi.common.core.exception.DemoModeException;
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.validation.BindException;
|
import org.springframework.validation.BindException;
|
||||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||||
@@ -31,108 +31,108 @@ public class GlobalExceptionHandler {
|
|||||||
* 权限码异常
|
* 权限码异常
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(NotPermissionException.class)
|
@ExceptionHandler(NotPermissionException.class)
|
||||||
public AjaxResult handleNotPermissionException(NotPermissionException e, HttpServletRequest request) {
|
public R<Void> handleNotPermissionException(NotPermissionException e, HttpServletRequest request) {
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
log.error("请求地址'{}',权限码校验失败'{}'", requestURI, e.getMessage());
|
log.error("请求地址'{}',权限码校验失败'{}'", requestURI, e.getMessage());
|
||||||
return AjaxResult.error(HttpStatus.FORBIDDEN, "没有访问权限,请联系管理员授权");
|
return R.fail(HttpStatus.FORBIDDEN, "没有访问权限,请联系管理员授权");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色权限异常
|
* 角色权限异常
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(NotRoleException.class)
|
@ExceptionHandler(NotRoleException.class)
|
||||||
public AjaxResult handleNotRoleException(NotRoleException e, HttpServletRequest request) {
|
public R<Void> handleNotRoleException(NotRoleException e, HttpServletRequest request) {
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
log.error("请求地址'{}',角色权限校验失败'{}'", requestURI, e.getMessage());
|
log.error("请求地址'{}',角色权限校验失败'{}'", requestURI, e.getMessage());
|
||||||
return AjaxResult.error(HttpStatus.FORBIDDEN, "没有访问权限,请联系管理员授权");
|
return R.fail(HttpStatus.FORBIDDEN, "没有访问权限,请联系管理员授权");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 认证失败
|
* 认证失败
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(NotLoginException.class)
|
@ExceptionHandler(NotLoginException.class)
|
||||||
public AjaxResult handleNotLoginException(NotLoginException e, HttpServletRequest request) {
|
public R<Void> handleNotLoginException(NotLoginException e, HttpServletRequest request) {
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
log.error("请求地址'{}',认证失败'{}',无法访问系统资源", requestURI, e.getMessage());
|
log.error("请求地址'{}',认证失败'{}',无法访问系统资源", requestURI, e.getMessage());
|
||||||
return AjaxResult.error(HttpStatus.UNAUTHORIZED, "认证失败,无法访问系统资源");
|
return R.fail(HttpStatus.UNAUTHORIZED, "认证失败,无法访问系统资源");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 无效认证
|
* 无效认证
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(IdTokenInvalidException.class)
|
@ExceptionHandler(IdTokenInvalidException.class)
|
||||||
public AjaxResult handleIdTokenInvalidException(IdTokenInvalidException e, HttpServletRequest request) {
|
public R<Void> handleIdTokenInvalidException(IdTokenInvalidException e, HttpServletRequest request) {
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
log.error("请求地址'{}',内网认证失败'{}',无法访问系统资源", requestURI, e.getMessage());
|
log.error("请求地址'{}',内网认证失败'{}',无法访问系统资源", requestURI, e.getMessage());
|
||||||
return AjaxResult.error(HttpStatus.UNAUTHORIZED, "认证失败,无法访问系统资源");
|
return R.fail(HttpStatus.UNAUTHORIZED, "认证失败,无法访问系统资源");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求方式不支持
|
* 请求方式不支持
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||||
public AjaxResult handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e,
|
public R<Void> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
|
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
|
||||||
return AjaxResult.error(e.getMessage());
|
return R.fail(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务异常
|
* 业务异常
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(ServiceException.class)
|
@ExceptionHandler(ServiceException.class)
|
||||||
public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request) {
|
public R<Void> handleServiceException(ServiceException e, HttpServletRequest request) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
Integer code = e.getCode();
|
Integer code = e.getCode();
|
||||||
return ObjectUtil.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage());
|
return ObjectUtil.isNotNull(code) ? R.fail(code.intValue(), e.getMessage()) : R.fail(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拦截未知的运行时异常
|
* 拦截未知的运行时异常
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(RuntimeException.class)
|
@ExceptionHandler(RuntimeException.class)
|
||||||
public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request) {
|
public R<Void> handleRuntimeException(RuntimeException e, HttpServletRequest request) {
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
log.error("请求地址'{}',发生未知异常.", requestURI, e);
|
log.error("请求地址'{}',发生未知异常.", requestURI, e);
|
||||||
return AjaxResult.error(e.getMessage());
|
return R.fail(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统异常
|
* 系统异常
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(Exception.class)
|
@ExceptionHandler(Exception.class)
|
||||||
public AjaxResult handleException(Exception e, HttpServletRequest request) {
|
public R<Void> handleException(Exception e, HttpServletRequest request) {
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
log.error("请求地址'{}',发生系统异常.", requestURI, e);
|
log.error("请求地址'{}',发生系统异常.", requestURI, e);
|
||||||
return AjaxResult.error(e.getMessage());
|
return R.fail(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义验证异常
|
* 自定义验证异常
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(BindException.class)
|
@ExceptionHandler(BindException.class)
|
||||||
public AjaxResult handleBindException(BindException e) {
|
public R<Void> handleBindException(BindException e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
String message = e.getAllErrors().get(0).getDefaultMessage();
|
String message = e.getAllErrors().get(0).getDefaultMessage();
|
||||||
return AjaxResult.error(message);
|
return R.fail(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义验证异常
|
* 自定义验证异常
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||||
public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
|
public R<Void> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
String message = e.getBindingResult().getFieldError().getDefaultMessage();
|
String message = e.getBindingResult().getFieldError().getDefaultMessage();
|
||||||
return AjaxResult.error(message);
|
return R.fail(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 演示模式异常
|
* 演示模式异常
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(DemoModeException.class)
|
@ExceptionHandler(DemoModeException.class)
|
||||||
public AjaxResult handleDemoModeException(DemoModeException e) {
|
public R<Void> handleDemoModeException(DemoModeException e) {
|
||||||
return AjaxResult.error("演示模式,不允许操作");
|
return R.fail("演示模式,不允许操作");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,37 +1,38 @@
|
|||||||
package com.ruoyi.gateway.handler;
|
package com.ruoyi.gateway.handler;
|
||||||
|
|
||||||
import com.ruoyi.common.core.exception.CaptchaException;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.exception.CaptchaException;
|
||||||
import com.ruoyi.gateway.service.ValidateCodeService;
|
import com.ruoyi.gateway.service.ValidateCodeService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.reactive.function.BodyInserters;
|
import org.springframework.web.reactive.function.BodyInserters;
|
||||||
import org.springframework.web.reactive.function.server.HandlerFunction;
|
import org.springframework.web.reactive.function.server.HandlerFunction;
|
||||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
/**
|
|
||||||
* 验证码获取
|
/**
|
||||||
*
|
* 验证码获取
|
||||||
* @author ruoyi
|
*
|
||||||
*/
|
* @author ruoyi
|
||||||
@Component
|
*/
|
||||||
public class ValidateCodeHandler implements HandlerFunction<ServerResponse> {
|
@Component
|
||||||
@Autowired
|
public class ValidateCodeHandler implements HandlerFunction<ServerResponse> {
|
||||||
private ValidateCodeService validateCodeService;
|
@Autowired
|
||||||
|
private ValidateCodeService validateCodeService;
|
||||||
@Override
|
|
||||||
public Mono<ServerResponse> handle(ServerRequest serverRequest) {
|
@Override
|
||||||
AjaxResult ajax;
|
public Mono<ServerResponse> handle(ServerRequest serverRequest) {
|
||||||
try {
|
R<Map<String, Object>> ajax;
|
||||||
ajax = validateCodeService.createCapcha();
|
try {
|
||||||
} catch (CaptchaException | IOException e) {
|
ajax = validateCodeService.createCapcha();
|
||||||
return Mono.error(e);
|
} catch (CaptchaException | IOException e) {
|
||||||
}
|
return Mono.error(e);
|
||||||
return ServerResponse.status(HttpStatus.OK).body(BodyInserters.fromValue(ajax));
|
}
|
||||||
}
|
return ServerResponse.status(HttpStatus.OK).body(BodyInserters.fromValue(ajax));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@@ -1,23 +1,24 @@
|
|||||||
package com.ruoyi.gateway.service;
|
package com.ruoyi.gateway.service;
|
||||||
|
|
||||||
import com.ruoyi.common.core.exception.CaptchaException;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.exception.CaptchaException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
/**
|
|
||||||
* 验证码处理
|
/**
|
||||||
*
|
* 验证码处理
|
||||||
* @author ruoyi
|
*
|
||||||
*/
|
* @author ruoyi
|
||||||
public interface ValidateCodeService {
|
*/
|
||||||
/**
|
public interface ValidateCodeService {
|
||||||
* 生成验证码
|
/**
|
||||||
*/
|
* 生成验证码
|
||||||
AjaxResult createCapcha() throws IOException, CaptchaException;
|
*/
|
||||||
|
R<Map<String, Object>> createCapcha() throws IOException, CaptchaException;
|
||||||
/**
|
|
||||||
* 校验验证码
|
/**
|
||||||
*/
|
* 校验验证码
|
||||||
void checkCapcha(String key, String value) throws CaptchaException;
|
*/
|
||||||
}
|
void checkCapcha(String key, String value) throws CaptchaException;
|
||||||
|
}
|
||||||
|
@@ -5,11 +5,11 @@ import cn.hutool.captcha.generator.CodeGenerator;
|
|||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.exception.CaptchaException;
|
import com.ruoyi.common.core.exception.CaptchaException;
|
||||||
import com.ruoyi.common.core.utils.SpringUtils;
|
import com.ruoyi.common.core.utils.SpringUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.reflect.ReflectUtils;
|
import com.ruoyi.common.core.utils.reflect.ReflectUtils;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.redis.utils.RedisUtils;
|
import com.ruoyi.common.redis.utils.RedisUtils;
|
||||||
import com.ruoyi.gateway.config.properties.CaptchaProperties;
|
import com.ruoyi.gateway.config.properties.CaptchaProperties;
|
||||||
import com.ruoyi.gateway.enums.CaptchaType;
|
import com.ruoyi.gateway.enums.CaptchaType;
|
||||||
@@ -18,6 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,12 +36,12 @@ public class ValidateCodeServiceImpl implements ValidateCodeService {
|
|||||||
* 生成验证码
|
* 生成验证码
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult createCapcha() throws IOException, CaptchaException {
|
public R<Map<String, Object>> createCapcha() throws IOException, CaptchaException {
|
||||||
AjaxResult ajax = AjaxResult.success();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
boolean captchaOnOff = captchaProperties.getEnabled();
|
boolean captchaOnOff = captchaProperties.getEnabled();
|
||||||
ajax.put("captchaOnOff", captchaOnOff);
|
ajax.put("captchaOnOff", captchaOnOff);
|
||||||
if (!captchaOnOff) {
|
if (!captchaOnOff) {
|
||||||
return ajax;
|
return R.ok(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存验证码信息
|
// 保存验证码信息
|
||||||
@@ -57,7 +59,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService {
|
|||||||
RedisUtils.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
|
RedisUtils.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
|
||||||
ajax.put("uuid", uuid);
|
ajax.put("uuid", uuid);
|
||||||
ajax.put("img", captcha.getImageBase64());
|
ajax.put("img", captcha.getImageBase64());
|
||||||
return ajax;
|
return R.ok(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCodeResult(String capStr) {
|
private String getCodeResult(String capStr) {
|
||||||
|
@@ -3,8 +3,8 @@ package com.ruoyi.gen.controller;
|
|||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.mybatis.core.page.PageQuery;
|
import com.ruoyi.common.mybatis.core.page.PageQuery;
|
||||||
@@ -14,6 +14,7 @@ import com.ruoyi.gen.domain.GenTableColumn;
|
|||||||
import com.ruoyi.gen.service.IGenTableColumnService;
|
import com.ruoyi.gen.service.IGenTableColumnService;
|
||||||
import com.ruoyi.gen.service.IGenTableService;
|
import com.ruoyi.gen.service.IGenTableService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -27,12 +28,13 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* 代码生成 操作处理
|
* 代码生成 操作处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@Validated
|
||||||
|
@Api(value = "代码生成", tags = {"代码生成管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RequestMapping("/gen")
|
@RequestMapping("/gen")
|
||||||
@RestController
|
@RestController
|
||||||
@Api(tags = "代码生成")
|
|
||||||
public class GenController extends BaseController {
|
public class GenController extends BaseController {
|
||||||
|
|
||||||
private final IGenTableService genTableService;
|
private final IGenTableService genTableService;
|
||||||
@@ -41,6 +43,7 @@ public class GenController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 查询代码生成列表
|
* 查询代码生成列表
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("查询代码生成列表")
|
||||||
@SaCheckPermission("tool:gen:list")
|
@SaCheckPermission("tool:gen:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<GenTable> genList(GenTable genTable, PageQuery pageQuery) {
|
public TableDataInfo<GenTable> genList(GenTable genTable, PageQuery pageQuery) {
|
||||||
@@ -50,9 +53,10 @@ public class GenController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 修改代码生成业务
|
* 修改代码生成业务
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("修改代码生成业务")
|
||||||
@SaCheckPermission("tool:gen:query")
|
@SaCheckPermission("tool:gen:query")
|
||||||
@GetMapping(value = "/{talbleId}")
|
@GetMapping(value = "/{talbleId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long talbleId) {
|
public R<Map<String, Object>> getInfo(@PathVariable Long talbleId) {
|
||||||
GenTable table = genTableService.selectGenTableById(talbleId);
|
GenTable table = genTableService.selectGenTableById(talbleId);
|
||||||
List<GenTable> tables = genTableService.selectGenTableAll();
|
List<GenTable> tables = genTableService.selectGenTableAll();
|
||||||
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId);
|
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId);
|
||||||
@@ -60,12 +64,13 @@ public class GenController extends BaseController {
|
|||||||
map.put("info", table);
|
map.put("info", table);
|
||||||
map.put("rows", list);
|
map.put("rows", list);
|
||||||
map.put("tables", tables);
|
map.put("tables", tables);
|
||||||
return AjaxResult.success(map);
|
return R.ok(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询数据库列表
|
* 查询数据库列表
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("查询数据库列表")
|
||||||
@SaCheckPermission("tool:gen:list")
|
@SaCheckPermission("tool:gen:list")
|
||||||
@GetMapping("/db/list")
|
@GetMapping("/db/list")
|
||||||
public TableDataInfo<GenTable> dataList(GenTable genTable, PageQuery pageQuery) {
|
public TableDataInfo<GenTable> dataList(GenTable genTable, PageQuery pageQuery) {
|
||||||
@@ -75,6 +80,7 @@ public class GenController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 查询数据表字段列表
|
* 查询数据表字段列表
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("查询数据表字段列表")
|
||||||
@GetMapping(value = "/column/{talbleId}")
|
@GetMapping(value = "/column/{talbleId}")
|
||||||
public TableDataInfo<GenTableColumn> columnList(Long tableId) {
|
public TableDataInfo<GenTableColumn> columnList(Long tableId) {
|
||||||
TableDataInfo<GenTableColumn> dataInfo = new TableDataInfo<>();
|
TableDataInfo<GenTableColumn> dataInfo = new TableDataInfo<>();
|
||||||
@@ -87,53 +93,58 @@ public class GenController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 导入表结构(保存)
|
* 导入表结构(保存)
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("导入表结构(保存)")
|
||||||
@SaCheckPermission("tool:gen:import")
|
@SaCheckPermission("tool:gen:import")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
||||||
@PostMapping("/importTable")
|
@PostMapping("/importTable")
|
||||||
public AjaxResult importTableSave(String tables) {
|
public R<Void> importTableSave(String tables) {
|
||||||
String[] tableNames = Convert.toStrArray(tables);
|
String[] tableNames = Convert.toStrArray(tables);
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
|
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
|
||||||
genTableService.importGenTable(tableList);
|
genTableService.importGenTable(tableList);
|
||||||
return AjaxResult.success();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存代码生成业务
|
* 修改保存代码生成业务
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("修改保存代码生成业务")
|
||||||
@SaCheckPermission("tool:gen:edit")
|
@SaCheckPermission("tool:gen:edit")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult editSave(@Validated @RequestBody GenTable genTable) {
|
public R<Void> editSave(@Validated @RequestBody GenTable genTable) {
|
||||||
genTableService.validateEdit(genTable);
|
genTableService.validateEdit(genTable);
|
||||||
genTableService.updateGenTable(genTable);
|
genTableService.updateGenTable(genTable);
|
||||||
return AjaxResult.success();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除代码生成
|
* 删除代码生成
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("删除代码生成")
|
||||||
@SaCheckPermission("tool:gen:remove")
|
@SaCheckPermission("tool:gen:remove")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.DELETE)
|
@Log(title = "代码生成", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{tableIds}")
|
@DeleteMapping("/{tableIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] tableIds) {
|
public R<Void> remove(@PathVariable Long[] tableIds) {
|
||||||
genTableService.deleteGenTableByIds(tableIds);
|
genTableService.deleteGenTableByIds(tableIds);
|
||||||
return AjaxResult.success();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预览代码
|
* 预览代码
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("预览代码")
|
||||||
@SaCheckPermission("tool:gen:preview")
|
@SaCheckPermission("tool:gen:preview")
|
||||||
@GetMapping("/preview/{tableId}")
|
@GetMapping("/preview/{tableId}")
|
||||||
public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException {
|
public R<Map<String, String>> preview(@PathVariable("tableId") Long tableId) throws IOException {
|
||||||
Map<String, String> dataMap = genTableService.previewCode(tableId);
|
Map<String, String> dataMap = genTableService.previewCode(tableId);
|
||||||
return AjaxResult.success(dataMap);
|
return R.ok(dataMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成代码(下载方式)
|
* 生成代码(下载方式)
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("生成代码(下载方式)")
|
||||||
@SaCheckPermission("tool:gen:code")
|
@SaCheckPermission("tool:gen:code")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
||||||
@GetMapping("/download/{tableName}")
|
@GetMapping("/download/{tableName}")
|
||||||
@@ -145,28 +156,31 @@ public class GenController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 生成代码(自定义路径)
|
* 生成代码(自定义路径)
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("生成代码(自定义路径)")
|
||||||
@SaCheckPermission("tool:gen:code")
|
@SaCheckPermission("tool:gen:code")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
||||||
@GetMapping("/genCode/{tableName}")
|
@GetMapping("/genCode/{tableName}")
|
||||||
public AjaxResult genCode(@PathVariable("tableName") String tableName) {
|
public R<Void> genCode(@PathVariable("tableName") String tableName) {
|
||||||
genTableService.generatorCode(tableName);
|
genTableService.generatorCode(tableName);
|
||||||
return AjaxResult.success();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 同步数据库
|
* 同步数据库
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("同步数据库")
|
||||||
@SaCheckPermission("tool:gen:edit")
|
@SaCheckPermission("tool:gen:edit")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
||||||
@GetMapping("/synchDb/{tableName}")
|
@GetMapping("/synchDb/{tableName}")
|
||||||
public AjaxResult synchDb(@PathVariable("tableName") String tableName) {
|
public R<Void> synchDb(@PathVariable("tableName") String tableName) {
|
||||||
genTableService.synchDb(tableName);
|
genTableService.synchDb(tableName);
|
||||||
return AjaxResult.success();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量生成代码
|
* 批量生成代码
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("批量生成代码")
|
||||||
@SaCheckPermission("tool:gen:code")
|
@SaCheckPermission("tool:gen:code")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
||||||
@GetMapping("/batchGenCode")
|
@GetMapping("/batchGenCode")
|
||||||
|
@@ -17,7 +17,7 @@ import com.ruoyi.common.security.annotation.RequiresPermissions;
|
|||||||
import ${packageName}.domain.${ClassName};
|
import ${packageName}.domain.${ClassName};
|
||||||
import ${packageName}.service.I${ClassName}Service;
|
import ${packageName}.service.I${ClassName}Service;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||||
#if($table.crud || $table.sub)
|
#if($table.crud || $table.sub)
|
||||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
@@ -50,10 +50,10 @@ public class ${ClassName}Controller extends BaseController
|
|||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
public AjaxResult list(${ClassName} ${className})
|
public R<List<${ClassName}>> list(${ClassName} ${className})
|
||||||
{
|
{
|
||||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
||||||
return AjaxResult.success(list);
|
return R.ok(list);
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
|
||||||
@@ -75,9 +75,9 @@ public class ${ClassName}Controller extends BaseController
|
|||||||
*/
|
*/
|
||||||
@SaCheckPermission("${permissionPrefix}:query")
|
@SaCheckPermission("${permissionPrefix}:query")
|
||||||
@GetMapping(value = "/{${pkColumn.javaField}}")
|
@GetMapping(value = "/{${pkColumn.javaField}}")
|
||||||
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
|
public R<${ClassName}> getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
|
||||||
{
|
{
|
||||||
return AjaxResult.success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
|
return R.ok(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,7 +86,7 @@ public class ${ClassName}Controller extends BaseController
|
|||||||
@SaCheckPermission("${permissionPrefix}:add")
|
@SaCheckPermission("${permissionPrefix}:add")
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody ${ClassName} ${className})
|
public R<Void> add(@RequestBody ${ClassName} ${className})
|
||||||
{
|
{
|
||||||
return toAjax(${className}Service.insert${ClassName}(${className}));
|
return toAjax(${className}Service.insert${ClassName}(${className}));
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ public class ${ClassName}Controller extends BaseController
|
|||||||
@SaCheckPermission("${permissionPrefix}:edit")
|
@SaCheckPermission("${permissionPrefix}:edit")
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody ${ClassName} ${className})
|
public R<Void> edit(@RequestBody ${ClassName} ${className})
|
||||||
{
|
{
|
||||||
return toAjax(${className}Service.update${ClassName}(${className}));
|
return toAjax(${className}Service.update${ClassName}(${className}));
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ public class ${ClassName}Controller extends BaseController
|
|||||||
@SaCheckPermission("${permissionPrefix}:remove")
|
@SaCheckPermission("${permissionPrefix}:remove")
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{${pkColumn.javaField}s}")
|
@DeleteMapping("/{${pkColumn.javaField}s}")
|
||||||
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
public R<Void> remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
||||||
{
|
{
|
||||||
return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s));
|
return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s));
|
||||||
}
|
}
|
||||||
|
@@ -2,16 +2,17 @@ package com.ruoyi.system.controller;
|
|||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.excel.utils.ExcelUtil;
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.mybatis.core.page.PageQuery;
|
import com.ruoyi.common.mybatis.core.page.PageQuery;
|
||||||
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.satoken.utils.LoginHelper;
|
|
||||||
import com.ruoyi.system.domain.SysConfig;
|
import com.ruoyi.system.domain.SysConfig;
|
||||||
import com.ruoyi.system.service.ISysConfigService;
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -22,8 +23,10 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* 参数配置 信息操作处理
|
* 参数配置 信息操作处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@Validated
|
||||||
|
@Api(value = "参数配置控制器", tags = {"参数配置管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/config")
|
@RequestMapping("/config")
|
||||||
@@ -34,12 +37,14 @@ public class SysConfigController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 获取参数配置列表
|
* 获取参数配置列表
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("获取参数配置列表")
|
||||||
@SaCheckPermission("system:config:list")
|
@SaCheckPermission("system:config:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysConfig> list(SysConfig config, PageQuery pageQuery) {
|
public TableDataInfo<SysConfig> list(SysConfig config, PageQuery pageQuery) {
|
||||||
return configService.selectPageConfigList(config, pageQuery);
|
return configService.selectPageConfigList(config, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("导出参数配置列表")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:config:export")
|
@SaCheckPermission("system:config:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@@ -51,54 +56,57 @@ public class SysConfigController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 根据参数编号获取详细信息
|
* 根据参数编号获取详细信息
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("根据参数编号获取详细信息")
|
||||||
@GetMapping(value = "/{configId}")
|
@GetMapping(value = "/{configId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long configId) {
|
public R<SysConfig> getInfo(@PathVariable Long configId) {
|
||||||
return AjaxResult.success(configService.selectConfigById(configId));
|
return R.ok(configService.selectConfigById(configId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据参数键名查询参数值
|
* 根据参数键名查询参数值
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("根据参数键名查询参数值")
|
||||||
@GetMapping(value = "/configKey/{configKey}")
|
@GetMapping(value = "/configKey/{configKey}")
|
||||||
public AjaxResult getConfigKey(@PathVariable String configKey) {
|
public R<Void> getConfigKey(@PathVariable String configKey) {
|
||||||
return AjaxResult.success(configService.selectConfigByKey(configKey));
|
return R.ok(configService.selectConfigByKey(configKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增参数配置
|
* 新增参数配置
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("新增参数配置")
|
||||||
@SaCheckPermission("system:config:add")
|
@SaCheckPermission("system:config:add")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysConfig config) {
|
public R<Void> add(@Validated @RequestBody SysConfig config) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
||||||
return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
return R.fail("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
}
|
}
|
||||||
config.setCreateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(configService.insertConfig(config));
|
return toAjax(configService.insertConfig(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改参数配置
|
* 修改参数配置
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("修改参数配置")
|
||||||
@SaCheckPermission("system:config:edit")
|
@SaCheckPermission("system:config:edit")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysConfig config) {
|
public R<Void> edit(@Validated @RequestBody SysConfig config) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
||||||
return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
return R.fail("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
}
|
}
|
||||||
config.setUpdateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(configService.updateConfig(config));
|
return toAjax(configService.updateConfig(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除参数配置
|
* 删除参数配置
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("删除参数配置")
|
||||||
@SaCheckPermission("system:config:remove")
|
@SaCheckPermission("system:config:remove")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{configIds}")
|
@DeleteMapping("/{configIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] configIds) {
|
public R<Void> remove(@PathVariable Long[] configIds) {
|
||||||
configService.deleteConfigByIds(configIds);
|
configService.deleteConfigByIds(configIds);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
@@ -106,11 +114,12 @@ public class SysConfigController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 刷新参数缓存
|
* 刷新参数缓存
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("刷新参数缓存")
|
||||||
@SaCheckPermission("system:config:remove")
|
@SaCheckPermission("system:config:remove")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
||||||
@DeleteMapping("/refreshCache")
|
@DeleteMapping("/refreshCache")
|
||||||
public AjaxResult refreshCache() {
|
public R<Void> refreshCache() {
|
||||||
configService.resetConfigCache();
|
configService.resetConfigCache();
|
||||||
return AjaxResult.success();
|
return R.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,27 +1,33 @@
|
|||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.satoken.utils.LoginHelper;
|
|
||||||
import com.ruoyi.system.api.domain.SysDept;
|
import com.ruoyi.system.api.domain.SysDept;
|
||||||
import com.ruoyi.system.service.ISysDeptService;
|
import com.ruoyi.system.service.ISysDeptService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门信息
|
* 部门信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@Validated
|
||||||
|
@Api(value = "部门控制器", tags = {"部门管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/dept")
|
@RequestMapping("/dept")
|
||||||
@@ -32,103 +38,109 @@ public class SysDeptController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 获取部门列表
|
* 获取部门列表
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("获取部门列表")
|
||||||
@SaCheckPermission("system:dept:list")
|
@SaCheckPermission("system:dept:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult list(SysDept dept) {
|
public R<List<SysDept>> list(SysDept dept) {
|
||||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||||
return AjaxResult.success(depts);
|
return R.ok(depts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询部门列表(排除节点)
|
* 查询部门列表(排除节点)
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("查询部门列表(排除节点)")
|
||||||
@SaCheckPermission("system:dept:list")
|
@SaCheckPermission("system:dept:list")
|
||||||
@GetMapping("/list/exclude/{deptId}")
|
@GetMapping("/list/exclude/{deptId}")
|
||||||
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
|
public R<List<SysDept>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
|
||||||
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||||
depts.removeIf(d -> d.getDeptId().equals(deptId)
|
depts.removeIf(d -> d.getDeptId().equals(deptId)
|
||||||
|| ArrayUtil.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
|
|| ArrayUtil.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
|
||||||
return AjaxResult.success(depts);
|
return R.ok(depts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据部门编号获取详细信息
|
* 根据部门编号获取详细信息
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("根据部门编号获取详细信息")
|
||||||
@SaCheckPermission("system:dept:query")
|
@SaCheckPermission("system:dept:query")
|
||||||
@GetMapping(value = "/{deptId}")
|
@GetMapping(value = "/{deptId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long deptId) {
|
public R<SysDept> getInfo(@PathVariable Long deptId) {
|
||||||
deptService.checkDeptDataScope(deptId);
|
deptService.checkDeptDataScope(deptId);
|
||||||
return AjaxResult.success(deptService.selectDeptById(deptId));
|
return R.ok(deptService.selectDeptById(deptId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取部门下拉树列表
|
* 获取部门下拉树列表
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("获取部门下拉树列表")
|
||||||
@GetMapping("/treeselect")
|
@GetMapping("/treeselect")
|
||||||
public AjaxResult treeselect(SysDept dept) {
|
public R<List<Tree<Long>>> treeselect(SysDept dept) {
|
||||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||||
return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
|
return R.ok(deptService.buildDeptTreeSelect(depts));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载对应角色部门列表树
|
* 加载对应角色部门列表树
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("加载对应角色部门列表树")
|
||||||
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
|
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
|
||||||
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId) {
|
public R<Map<String, Object>> roleDeptTreeselect(@PathVariable("roleId") Long roleId) {
|
||||||
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||||
AjaxResult ajax = AjaxResult.success();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
||||||
ajax.put("depts", deptService.buildDeptTreeSelect(depts));
|
ajax.put("depts", deptService.buildDeptTreeSelect(depts));
|
||||||
return ajax;
|
return R.ok(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增部门
|
* 新增部门
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("新增部门")
|
||||||
@SaCheckPermission("system:dept:add")
|
@SaCheckPermission("system:dept:add")
|
||||||
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysDept dept) {
|
public R<Void> add(@Validated @RequestBody SysDept dept) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
|
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
|
||||||
return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
return R.fail("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
}
|
}
|
||||||
dept.setCreateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(deptService.insertDept(dept));
|
return toAjax(deptService.insertDept(dept));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改部门
|
* 修改部门
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("修改部门")
|
||||||
@SaCheckPermission("system:dept:edit")
|
@SaCheckPermission("system:dept:edit")
|
||||||
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysDept dept) {
|
public R<Void> edit(@Validated @RequestBody SysDept dept) {
|
||||||
Long deptId = dept.getDeptId();
|
Long deptId = dept.getDeptId();
|
||||||
deptService.checkDeptDataScope(deptId);
|
deptService.checkDeptDataScope(deptId);
|
||||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
|
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
|
||||||
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
return R.fail("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
} else if (dept.getParentId().equals(deptId)) {
|
} else if (dept.getParentId().equals(deptId)) {
|
||||||
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
return R.fail("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||||
} else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
} else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
||||||
&& deptService.selectNormalChildrenDeptById(deptId) > 0) {
|
&& deptService.selectNormalChildrenDeptById(deptId) > 0) {
|
||||||
return AjaxResult.error("该部门包含未停用的子部门!");
|
return R.fail("该部门包含未停用的子部门!");
|
||||||
}
|
}
|
||||||
dept.setUpdateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(deptService.updateDept(dept));
|
return toAjax(deptService.updateDept(dept));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除部门
|
* 删除部门
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("删除部门")
|
||||||
@SaCheckPermission("system:dept:remove")
|
@SaCheckPermission("system:dept:remove")
|
||||||
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{deptId}")
|
@DeleteMapping("/{deptId}")
|
||||||
public AjaxResult remove(@PathVariable Long deptId) {
|
public R<Void> remove(@PathVariable Long deptId) {
|
||||||
if (deptService.hasChildByDeptId(deptId)) {
|
if (deptService.hasChildByDeptId(deptId)) {
|
||||||
return AjaxResult.error("存在下级部门,不允许删除");
|
return R.fail("存在下级部门,不允许删除");
|
||||||
}
|
}
|
||||||
if (deptService.checkDeptExistUser(deptId)) {
|
if (deptService.checkDeptExistUser(deptId)) {
|
||||||
return AjaxResult.error("部门存在用户,不允许删除");
|
return R.fail("部门存在用户,不允许删除");
|
||||||
}
|
}
|
||||||
deptService.checkDeptDataScope(deptId);
|
deptService.checkDeptDataScope(deptId);
|
||||||
return toAjax(deptService.deleteDeptById(deptId));
|
return toAjax(deptService.deleteDeptById(deptId));
|
||||||
|
@@ -2,17 +2,18 @@ package com.ruoyi.system.controller;
|
|||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.excel.utils.ExcelUtil;
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.mybatis.core.page.PageQuery;
|
import com.ruoyi.common.mybatis.core.page.PageQuery;
|
||||||
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.satoken.utils.LoginHelper;
|
|
||||||
import com.ruoyi.system.api.domain.SysDictData;
|
import com.ruoyi.system.api.domain.SysDictData;
|
||||||
import com.ruoyi.system.service.ISysDictDataService;
|
import com.ruoyi.system.service.ISysDictDataService;
|
||||||
import com.ruoyi.system.service.ISysDictTypeService;
|
import com.ruoyi.system.service.ISysDictTypeService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -24,8 +25,10 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* 数据字典信息
|
* 数据字典信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@Validated
|
||||||
|
@Api(value = "数据字典信息控制器", tags = {"数据字典信息管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/dict/data")
|
@RequestMapping("/dict/data")
|
||||||
@@ -34,12 +37,14 @@ public class SysDictDataController extends BaseController {
|
|||||||
private final ISysDictDataService dictDataService;
|
private final ISysDictDataService dictDataService;
|
||||||
private final ISysDictTypeService dictTypeService;
|
private final ISysDictTypeService dictTypeService;
|
||||||
|
|
||||||
|
@ApiOperation("查询字典数据列表")
|
||||||
@SaCheckPermission("system:dict:list")
|
@SaCheckPermission("system:dict:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysDictData> list(SysDictData dictData, PageQuery pageQuery) {
|
public TableDataInfo<SysDictData> list(SysDictData dictData, PageQuery pageQuery) {
|
||||||
return dictDataService.selectPageDictDataList(dictData, pageQuery);
|
return dictDataService.selectPageDictDataList(dictData, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("导出字典数据列表")
|
||||||
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:dict:export")
|
@SaCheckPermission("system:dict:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@@ -51,53 +56,56 @@ public class SysDictDataController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 查询字典数据详细
|
* 查询字典数据详细
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("查询字典数据详细")
|
||||||
@SaCheckPermission("system:dict:query")
|
@SaCheckPermission("system:dict:query")
|
||||||
@GetMapping(value = "/{dictCode}")
|
@GetMapping(value = "/{dictCode}")
|
||||||
public AjaxResult getInfo(@PathVariable Long dictCode) {
|
public R<SysDictData> getInfo(@PathVariable Long dictCode) {
|
||||||
return AjaxResult.success(dictDataService.selectDictDataById(dictCode));
|
return R.ok(dictDataService.selectDictDataById(dictCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据字典类型查询字典数据信息
|
* 根据字典类型查询字典数据信息
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("根据字典类型查询字典数据信息")
|
||||||
@GetMapping(value = "/type/{dictType}")
|
@GetMapping(value = "/type/{dictType}")
|
||||||
public AjaxResult dictType(@PathVariable String dictType) {
|
public R<List<SysDictData>> dictType(@PathVariable String dictType) {
|
||||||
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
||||||
if (ObjectUtil.isNull(data)) {
|
if (ObjectUtil.isNull(data)) {
|
||||||
data = new ArrayList<SysDictData>();
|
data = new ArrayList<SysDictData>();
|
||||||
}
|
}
|
||||||
return AjaxResult.success(data);
|
return R.ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增字典类型
|
* 新增字典类型
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("新增字典类型")
|
||||||
@SaCheckPermission("system:dict:add")
|
@SaCheckPermission("system:dict:add")
|
||||||
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysDictData dict) {
|
public R<Void> add(@Validated @RequestBody SysDictData dict) {
|
||||||
dict.setCreateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(dictDataService.insertDictData(dict));
|
return toAjax(dictDataService.insertDictData(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存字典类型
|
* 修改保存字典类型
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("修改保存字典类型")
|
||||||
@SaCheckPermission("system:dict:edit")
|
@SaCheckPermission("system:dict:edit")
|
||||||
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysDictData dict) {
|
public R<Void> edit(@Validated @RequestBody SysDictData dict) {
|
||||||
dict.setUpdateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(dictDataService.updateDictData(dict));
|
return toAjax(dictDataService.updateDictData(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除字典类型
|
* 删除字典类型
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("删除字典类型")
|
||||||
@SaCheckPermission("system:dict:remove")
|
@SaCheckPermission("system:dict:remove")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{dictCodes}")
|
@DeleteMapping("/{dictCodes}")
|
||||||
public AjaxResult remove(@PathVariable Long[] dictCodes) {
|
public R<Void> remove(@PathVariable Long[] dictCodes) {
|
||||||
dictDataService.deleteDictDataByIds(dictCodes);
|
dictDataService.deleteDictDataByIds(dictCodes);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
@@ -2,16 +2,17 @@ package com.ruoyi.system.controller;
|
|||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.excel.utils.ExcelUtil;
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.mybatis.core.page.PageQuery;
|
import com.ruoyi.common.mybatis.core.page.PageQuery;
|
||||||
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.satoken.utils.LoginHelper;
|
|
||||||
import com.ruoyi.system.api.domain.SysDictType;
|
import com.ruoyi.system.api.domain.SysDictType;
|
||||||
import com.ruoyi.system.service.ISysDictTypeService;
|
import com.ruoyi.system.service.ISysDictTypeService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -22,8 +23,10 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* 数据字典信息
|
* 数据字典信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@Validated
|
||||||
|
@Api(value = "数据字典信息控制器", tags = {"数据字典信息管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/dict/type")
|
@RequestMapping("/dict/type")
|
||||||
@@ -31,12 +34,14 @@ public class SysDictTypeController extends BaseController {
|
|||||||
|
|
||||||
private final ISysDictTypeService dictTypeService;
|
private final ISysDictTypeService dictTypeService;
|
||||||
|
|
||||||
|
@ApiOperation("查询字典类型列表")
|
||||||
@SaCheckPermission("system:dict:list")
|
@SaCheckPermission("system:dict:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysDictType> list(SysDictType dictType, PageQuery pageQuery) {
|
public TableDataInfo<SysDictType> list(SysDictType dictType, PageQuery pageQuery) {
|
||||||
return dictTypeService.selectPageDictTypeList(dictType, pageQuery);
|
return dictTypeService.selectPageDictTypeList(dictType, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("导出字典类型列表")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:dict:export")
|
@SaCheckPermission("system:dict:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@@ -48,47 +53,49 @@ public class SysDictTypeController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 查询字典类型详细
|
* 查询字典类型详细
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("查询字典类型详细")
|
||||||
@SaCheckPermission("system:dict:query")
|
@SaCheckPermission("system:dict:query")
|
||||||
@GetMapping(value = "/{dictId}")
|
@GetMapping(value = "/{dictId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long dictId) {
|
public R<SysDictType> getInfo(@PathVariable Long dictId) {
|
||||||
return AjaxResult.success(dictTypeService.selectDictTypeById(dictId));
|
return R.ok(dictTypeService.selectDictTypeById(dictId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增字典类型
|
* 新增字典类型
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("新增字典类型")
|
||||||
@SaCheckPermission("system:dict:add")
|
@SaCheckPermission("system:dict:add")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysDictType dict) {
|
public R<Void> add(@Validated @RequestBody SysDictType dict) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
||||||
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
return R.fail("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||||
}
|
}
|
||||||
dict.setCreateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(dictTypeService.insertDictType(dict));
|
return toAjax(dictTypeService.insertDictType(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改字典类型
|
* 修改字典类型
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("修改字典类型")
|
||||||
@SaCheckPermission("system:dict:edit")
|
@SaCheckPermission("system:dict:edit")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysDictType dict) {
|
public R<Void> edit(@Validated @RequestBody SysDictType dict) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
||||||
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
return R.fail("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||||
}
|
}
|
||||||
dict.setUpdateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(dictTypeService.updateDictType(dict));
|
return toAjax(dictTypeService.updateDictType(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除字典类型
|
* 删除字典类型
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("删除字典类型")
|
||||||
@SaCheckPermission("system:dict:remove")
|
@SaCheckPermission("system:dict:remove")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{dictIds}")
|
@DeleteMapping("/{dictIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] dictIds) {
|
public R<Void> remove(@PathVariable Long[] dictIds) {
|
||||||
dictTypeService.deleteDictTypeByIds(dictIds);
|
dictTypeService.deleteDictTypeByIds(dictIds);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
@@ -96,20 +103,21 @@ public class SysDictTypeController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 刷新字典缓存
|
* 刷新字典缓存
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("刷新字典缓存")
|
||||||
@SaCheckPermission("system:dict:remove")
|
@SaCheckPermission("system:dict:remove")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
||||||
@DeleteMapping("/refreshCache")
|
@DeleteMapping("/refreshCache")
|
||||||
public AjaxResult refreshCache() {
|
public R<Void> refreshCache() {
|
||||||
dictTypeService.resetDictCache();
|
dictTypeService.resetDictCache();
|
||||||
return AjaxResult.success();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取字典选择框列表
|
* 获取字典选择框列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public AjaxResult optionselect() {
|
public R<List<SysDictType>> optionselect() {
|
||||||
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
||||||
return AjaxResult.success(dictTypes);
|
return R.ok(dictTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.excel.utils.ExcelUtil;
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
@@ -10,7 +10,10 @@ import com.ruoyi.common.mybatis.core.page.PageQuery;
|
|||||||
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.ruoyi.system.api.domain.SysLogininfor;
|
import com.ruoyi.system.api.domain.SysLogininfor;
|
||||||
import com.ruoyi.system.service.ISysLogininforService;
|
import com.ruoyi.system.service.ISysLogininforService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@@ -19,8 +22,10 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* 系统访问记录
|
* 系统访问记录
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@Validated
|
||||||
|
@Api(value = "系统访问记录", tags = {"系统访问记录管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/logininfor")
|
@RequestMapping("/logininfor")
|
||||||
@@ -28,12 +33,14 @@ public class SysLogininforController extends BaseController {
|
|||||||
|
|
||||||
private final ISysLogininforService logininforService;
|
private final ISysLogininforService logininforService;
|
||||||
|
|
||||||
|
@ApiOperation("查询系统访问记录列表")
|
||||||
@SaCheckPermission("system:logininfor:list")
|
@SaCheckPermission("system:logininfor:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysLogininfor> list(SysLogininfor logininfor, PageQuery pageQuery) {
|
public TableDataInfo<SysLogininfor> list(SysLogininfor logininfor, PageQuery pageQuery) {
|
||||||
return logininforService.selectPageLogininforList(logininfor, pageQuery);
|
return logininforService.selectPageLogininforList(logininfor, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("导出系统访问记录列表")
|
||||||
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:logininfor:export")
|
@SaCheckPermission("system:logininfor:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@@ -42,24 +49,21 @@ public class SysLogininforController extends BaseController {
|
|||||||
ExcelUtil.exportExcel(list, "登录日志", SysLogininfor.class, response);
|
ExcelUtil.exportExcel(list, "登录日志", SysLogininfor.class, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("删除系统访问记录")
|
||||||
@SaCheckPermission("system:logininfor:remove")
|
@SaCheckPermission("system:logininfor:remove")
|
||||||
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{infoIds}")
|
@DeleteMapping("/{infoIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] infoIds) {
|
public R<Void> remove(@PathVariable Long[] infoIds) {
|
||||||
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("清空系统访问记录")
|
||||||
@SaCheckPermission("system:logininfor:remove")
|
@SaCheckPermission("system:logininfor:remove")
|
||||||
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/clean")
|
@DeleteMapping("/clean")
|
||||||
public AjaxResult clean() {
|
public R<Void> clean() {
|
||||||
logininforService.cleanLogininfor();
|
logininforService.cleanLogininfor();
|
||||||
return AjaxResult.success();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @InnerAuth
|
|
||||||
@PostMapping
|
|
||||||
public AjaxResult add(@RequestBody SysLogininfor logininfor) {
|
|
||||||
return toAjax(logininforService.insertLogininfor(logininfor));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,26 +1,34 @@
|
|||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.satoken.utils.LoginHelper;
|
import com.ruoyi.common.satoken.utils.LoginHelper;
|
||||||
import com.ruoyi.system.domain.SysMenu;
|
import com.ruoyi.system.domain.SysMenu;
|
||||||
|
import com.ruoyi.system.domain.vo.RouterVo;
|
||||||
import com.ruoyi.system.service.ISysMenuService;
|
import com.ruoyi.system.service.ISysMenuService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单信息
|
* 菜单信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@Validated
|
||||||
|
@Api(value = "菜单信息控制器", tags = {"菜单信息管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/menu")
|
@RequestMapping("/menu")
|
||||||
@@ -31,92 +39,97 @@ public class SysMenuController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 获取菜单列表
|
* 获取菜单列表
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("获取菜单列表")
|
||||||
@SaCheckPermission("system:menu:list")
|
@SaCheckPermission("system:menu:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult list(SysMenu menu) {
|
public R<List<SysMenu>> list(SysMenu menu) {
|
||||||
Long userId = LoginHelper.getUserId();
|
Long userId = LoginHelper.getUserId();
|
||||||
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
||||||
return AjaxResult.success(menus);
|
return R.ok(menus);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据菜单编号获取详细信息
|
* 根据菜单编号获取详细信息
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("根据菜单编号获取详细信息")
|
||||||
@SaCheckPermission("system:menu:query")
|
@SaCheckPermission("system:menu:query")
|
||||||
@GetMapping(value = "/{menuId}")
|
@GetMapping(value = "/{menuId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long menuId) {
|
public R<SysMenu> getInfo(@PathVariable Long menuId) {
|
||||||
return AjaxResult.success(menuService.selectMenuById(menuId));
|
return R.ok(menuService.selectMenuById(menuId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取菜单下拉树列表
|
* 获取菜单下拉树列表
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("获取菜单下拉树列表")
|
||||||
@GetMapping("/treeselect")
|
@GetMapping("/treeselect")
|
||||||
public AjaxResult treeselect(SysMenu menu) {
|
public R<List<Tree<Long>>> treeselect(SysMenu menu) {
|
||||||
Long userId = LoginHelper.getUserId();
|
Long userId = LoginHelper.getUserId();
|
||||||
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
||||||
return AjaxResult.success(menuService.buildMenuTreeSelect(menus));
|
return R.ok(menuService.buildMenuTreeSelect(menus));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载对应角色菜单列表树
|
* 加载对应角色菜单列表树
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("加载对应角色菜单列表树")
|
||||||
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
||||||
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
|
public R<Map<String, Object>> roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
|
||||||
Long userId = LoginHelper.getUserId();
|
Long userId = LoginHelper.getUserId();
|
||||||
List<SysMenu> menus = menuService.selectMenuList(userId);
|
List<SysMenu> menus = menuService.selectMenuList(userId);
|
||||||
AjaxResult ajax = AjaxResult.success();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
||||||
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
|
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
|
||||||
return ajax;
|
return R.ok(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增菜单
|
* 新增菜单
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("新增菜单")
|
||||||
@SaCheckPermission("system:menu:add")
|
@SaCheckPermission("system:menu:add")
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysMenu menu) {
|
public R<Void> add(@Validated @RequestBody SysMenu menu) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
||||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
return R.fail("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||||
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
|
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
|
||||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
return R.fail("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||||
}
|
}
|
||||||
menu.setCreateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(menuService.insertMenu(menu));
|
return toAjax(menuService.insertMenu(menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改菜单
|
* 修改菜单
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("修改菜单")
|
||||||
@SaCheckPermission("system:menu:edit")
|
@SaCheckPermission("system:menu:edit")
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysMenu menu) {
|
public R<Void> edit(@Validated @RequestBody SysMenu menu) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
||||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
return R.fail("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||||
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
|
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
|
||||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
return R.fail("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||||
} else if (menu.getMenuId().equals(menu.getParentId())) {
|
} else if (menu.getMenuId().equals(menu.getParentId())) {
|
||||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
return R.fail("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
||||||
}
|
}
|
||||||
menu.setUpdateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(menuService.updateMenu(menu));
|
return toAjax(menuService.updateMenu(menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除菜单
|
* 删除菜单
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("删除菜单")
|
||||||
@SaCheckPermission("system:menu:remove")
|
@SaCheckPermission("system:menu:remove")
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{menuId}")
|
@DeleteMapping("/{menuId}")
|
||||||
public AjaxResult remove(@PathVariable("menuId") Long menuId) {
|
public R<Void> remove(@PathVariable("menuId") Long menuId) {
|
||||||
if (menuService.hasChildByMenuId(menuId)) {
|
if (menuService.hasChildByMenuId(menuId)) {
|
||||||
return AjaxResult.error("存在子菜单,不允许删除");
|
return R.fail("存在子菜单,不允许删除");
|
||||||
}
|
}
|
||||||
if (menuService.checkMenuExistRole(menuId)) {
|
if (menuService.checkMenuExistRole(menuId)) {
|
||||||
return AjaxResult.error("菜单已分配,不允许删除");
|
return R.fail("菜单已分配,不允许删除");
|
||||||
}
|
}
|
||||||
return toAjax(menuService.deleteMenuById(menuId));
|
return toAjax(menuService.deleteMenuById(menuId));
|
||||||
}
|
}
|
||||||
@@ -126,10 +139,11 @@ public class SysMenuController extends BaseController {
|
|||||||
*
|
*
|
||||||
* @return 路由信息
|
* @return 路由信息
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("获取路由信息")
|
||||||
@GetMapping("getRouters")
|
@GetMapping("getRouters")
|
||||||
public AjaxResult getRouters() {
|
public R<List<RouterVo>> getRouters() {
|
||||||
Long userId = LoginHelper.getUserId();
|
Long userId = LoginHelper.getUserId();
|
||||||
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
||||||
return AjaxResult.success(menuService.buildMenus(menus));
|
return R.ok(menuService.buildMenus(menus));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,15 +1,16 @@
|
|||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.mybatis.core.page.PageQuery;
|
import com.ruoyi.common.mybatis.core.page.PageQuery;
|
||||||
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.satoken.utils.LoginHelper;
|
|
||||||
import com.ruoyi.system.domain.SysNotice;
|
import com.ruoyi.system.domain.SysNotice;
|
||||||
import com.ruoyi.system.service.ISysNoticeService;
|
import com.ruoyi.system.service.ISysNoticeService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -17,8 +18,10 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
/**
|
/**
|
||||||
* 公告 信息操作处理
|
* 公告 信息操作处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@Validated
|
||||||
|
@Api(value = "公告信息控制器", tags = {"公告信息管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/notice")
|
@RequestMapping("/notice")
|
||||||
@@ -29,6 +32,7 @@ public class SysNoticeController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 获取通知公告列表
|
* 获取通知公告列表
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("获取通知公告列表")
|
||||||
@SaCheckPermission("system:notice:list")
|
@SaCheckPermission("system:notice:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysNotice> list(SysNotice notice, PageQuery pageQuery) {
|
public TableDataInfo<SysNotice> list(SysNotice notice, PageQuery pageQuery) {
|
||||||
@@ -38,41 +42,43 @@ public class SysNoticeController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 根据通知公告编号获取详细信息
|
* 根据通知公告编号获取详细信息
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("根据通知公告编号获取详细信息")
|
||||||
@SaCheckPermission("system:notice:query")
|
@SaCheckPermission("system:notice:query")
|
||||||
@GetMapping(value = "/{noticeId}")
|
@GetMapping(value = "/{noticeId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long noticeId) {
|
public R<SysNotice> getInfo(@PathVariable Long noticeId) {
|
||||||
return AjaxResult.success(noticeService.selectNoticeById(noticeId));
|
return R.ok(noticeService.selectNoticeById(noticeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增通知公告
|
* 新增通知公告
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("新增通知公告")
|
||||||
@SaCheckPermission("system:notice:add")
|
@SaCheckPermission("system:notice:add")
|
||||||
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysNotice notice) {
|
public R<Void> add(@Validated @RequestBody SysNotice notice) {
|
||||||
notice.setCreateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(noticeService.insertNotice(notice));
|
return toAjax(noticeService.insertNotice(notice));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改通知公告
|
* 修改通知公告
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("修改通知公告")
|
||||||
@SaCheckPermission("system:notice:edit")
|
@SaCheckPermission("system:notice:edit")
|
||||||
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysNotice notice) {
|
public R<Void> edit(@Validated @RequestBody SysNotice notice) {
|
||||||
notice.setUpdateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(noticeService.updateNotice(notice));
|
return toAjax(noticeService.updateNotice(notice));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除通知公告
|
* 删除通知公告
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("删除通知公告")
|
||||||
@SaCheckPermission("system:notice:remove")
|
@SaCheckPermission("system:notice:remove")
|
||||||
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{noticeIds}")
|
@DeleteMapping("/{noticeIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] noticeIds) {
|
public R<Void> remove(@PathVariable Long[] noticeIds) {
|
||||||
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.excel.utils.ExcelUtil;
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
@@ -10,7 +10,10 @@ import com.ruoyi.common.mybatis.core.page.PageQuery;
|
|||||||
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.ruoyi.system.api.domain.SysOperLog;
|
import com.ruoyi.system.api.domain.SysOperLog;
|
||||||
import com.ruoyi.system.service.ISysOperLogService;
|
import com.ruoyi.system.service.ISysOperLogService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@@ -19,20 +22,25 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* 操作日志记录
|
* 操作日志记录
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@Validated
|
||||||
|
@Api(value = "操作日志记录", tags = {"操作日志记录管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/operlog")
|
@RequestMapping("/operlog")
|
||||||
public class SysOperlogController extends BaseController {
|
public class SysOperlogController extends BaseController {
|
||||||
|
|
||||||
private final ISysOperLogService operLogService;
|
private final ISysOperLogService operLogService;
|
||||||
|
|
||||||
|
@ApiOperation("查询操作日志记录列表")
|
||||||
@SaCheckPermission("system:operlog:list")
|
@SaCheckPermission("system:operlog:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysOperLog> list(SysOperLog operLog, PageQuery pageQuery) {
|
public TableDataInfo<SysOperLog> list(SysOperLog operLog, PageQuery pageQuery) {
|
||||||
return operLogService.selectPageOperLogList(operLog, pageQuery);
|
return operLogService.selectPageOperLogList(operLog, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("导出操作日志记录列表")
|
||||||
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:operlog:export")
|
@SaCheckPermission("system:operlog:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@@ -41,24 +49,21 @@ public class SysOperlogController extends BaseController {
|
|||||||
ExcelUtil.exportExcel(list, "操作日志", SysOperLog.class, response);
|
ExcelUtil.exportExcel(list, "操作日志", SysOperLog.class, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("删除操作日志记录")
|
||||||
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
||||||
@SaCheckPermission("system:operlog:remove")
|
@SaCheckPermission("system:operlog:remove")
|
||||||
@DeleteMapping("/{operIds}")
|
@DeleteMapping("/{operIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] operIds) {
|
public R<Void> remove(@PathVariable Long[] operIds) {
|
||||||
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("清空操作日志记录")
|
||||||
@SaCheckPermission("system:operlog:remove")
|
@SaCheckPermission("system:operlog:remove")
|
||||||
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
||||||
@DeleteMapping("/clean")
|
@DeleteMapping("/clean")
|
||||||
public AjaxResult clean() {
|
public R<Void> clean() {
|
||||||
operLogService.cleanOperLog();
|
operLogService.cleanOperLog();
|
||||||
return AjaxResult.success();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @InnerAuth
|
|
||||||
@PostMapping
|
|
||||||
public AjaxResult add(@RequestBody SysOperLog operLog) {
|
|
||||||
return toAjax(operLogService.insertOperlog(operLog));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -2,16 +2,17 @@ package com.ruoyi.system.controller;
|
|||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.excel.utils.ExcelUtil;
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.mybatis.core.page.PageQuery;
|
import com.ruoyi.common.mybatis.core.page.PageQuery;
|
||||||
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.satoken.utils.LoginHelper;
|
|
||||||
import com.ruoyi.system.domain.SysPost;
|
import com.ruoyi.system.domain.SysPost;
|
||||||
import com.ruoyi.system.service.ISysPostService;
|
import com.ruoyi.system.service.ISysPostService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -22,8 +23,10 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* 岗位信息操作处理
|
* 岗位信息操作处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@Validated
|
||||||
|
@Api(value = "岗位信息控制器", tags = {"岗位信息管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/post")
|
@RequestMapping("/post")
|
||||||
@@ -34,12 +37,14 @@ public class SysPostController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 获取岗位列表
|
* 获取岗位列表
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("获取岗位列表")
|
||||||
@SaCheckPermission("system:post:list")
|
@SaCheckPermission("system:post:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysPost> list(SysPost post, PageQuery pageQuery) {
|
public TableDataInfo<SysPost> list(SysPost post, PageQuery pageQuery) {
|
||||||
return postService.selectPagePostList(post, pageQuery);
|
return postService.selectPagePostList(post, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("导出岗位列表")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:post:export")
|
@SaCheckPermission("system:post:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@@ -51,60 +56,63 @@ public class SysPostController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 根据岗位编号获取详细信息
|
* 根据岗位编号获取详细信息
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("根据岗位编号获取详细信息")
|
||||||
@SaCheckPermission("system:post:query")
|
@SaCheckPermission("system:post:query")
|
||||||
@GetMapping(value = "/{postId}")
|
@GetMapping(value = "/{postId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long postId) {
|
public R<SysPost> getInfo(@PathVariable Long postId) {
|
||||||
return AjaxResult.success(postService.selectPostById(postId));
|
return R.ok(postService.selectPostById(postId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增岗位
|
* 新增岗位
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("新增岗位")
|
||||||
@SaCheckPermission("system:post:add")
|
@SaCheckPermission("system:post:add")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysPost post) {
|
public R<Void> add(@Validated @RequestBody SysPost post) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
|
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
|
||||||
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
return R.fail("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||||
} else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) {
|
} else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) {
|
||||||
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
return R.fail("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||||
}
|
}
|
||||||
post.setCreateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(postService.insertPost(post));
|
return toAjax(postService.insertPost(post));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改岗位
|
* 修改岗位
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("修改岗位")
|
||||||
@SaCheckPermission("system:post:edit")
|
@SaCheckPermission("system:post:edit")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysPost post) {
|
public R<Void> edit(@Validated @RequestBody SysPost post) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
|
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
|
||||||
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||||
} else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) {
|
} else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) {
|
||||||
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||||
}
|
}
|
||||||
post.setUpdateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(postService.updatePost(post));
|
return toAjax(postService.updatePost(post));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除岗位
|
* 删除岗位
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("删除岗位")
|
||||||
@SaCheckPermission("system:post:remove")
|
@SaCheckPermission("system:post:remove")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{postIds}")
|
@DeleteMapping("/{postIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] postIds) {
|
public R<Void> remove(@PathVariable Long[] postIds) {
|
||||||
return toAjax(postService.deletePostByIds(postIds));
|
return toAjax(postService.deletePostByIds(postIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取岗位选择框列表
|
* 获取岗位选择框列表
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("获取岗位选择框列表")
|
||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public AjaxResult optionselect() {
|
public R<List<SysPost>> optionselect() {
|
||||||
List<SysPost> posts = postService.selectPostAll();
|
List<SysPost> posts = postService.selectPostAll();
|
||||||
return AjaxResult.success(posts);
|
return R.ok(posts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,9 +2,9 @@ package com.ruoyi.system.controller;
|
|||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.satoken.utils.LoginHelper;
|
import com.ruoyi.common.satoken.utils.LoginHelper;
|
||||||
@@ -13,18 +13,28 @@ import com.ruoyi.file.api.RemoteFileService;
|
|||||||
import com.ruoyi.file.api.domain.SysFile;
|
import com.ruoyi.file.api.domain.SysFile;
|
||||||
import com.ruoyi.system.api.domain.SysUser;
|
import com.ruoyi.system.api.domain.SysUser;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 个人信息 业务处理
|
* 个人信息 业务处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@Validated
|
||||||
|
@Api(value = "个人信息控制器", tags = {"个人信息管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/user/profile")
|
@RequestMapping("/user/profile")
|
||||||
@@ -38,93 +48,92 @@ public class SysProfileController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 个人信息
|
* 个人信息
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("个人信息")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public AjaxResult profile() {
|
public R<Map<String, Object>> profile() {
|
||||||
String username = LoginHelper.getUsername();
|
String username = LoginHelper.getUsername();
|
||||||
SysUser user = userService.selectUserByUserName(username);
|
SysUser user = userService.selectUserByUserName(username);
|
||||||
AjaxResult ajax = AjaxResult.success(user);
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
|
ajax.put("user", user);
|
||||||
ajax.put("roleGroup", userService.selectUserRoleGroup(username));
|
ajax.put("roleGroup", userService.selectUserRoleGroup(username));
|
||||||
ajax.put("postGroup", userService.selectUserPostGroup(username));
|
ajax.put("postGroup", userService.selectUserPostGroup(username));
|
||||||
return ajax;
|
return R.ok(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户
|
* 修改用户
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("修改用户")
|
||||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult updateProfile(@RequestBody SysUser user) {
|
public R<Void> updateProfile(@RequestBody SysUser user) {
|
||||||
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
||||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
return R.fail("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
} else if (StringUtils.isNotEmpty(user.getEmail())
|
} else if (StringUtils.isNotEmpty(user.getEmail())
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
return R.fail("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}
|
||||||
user.setUserId(LoginHelper.getUserId());
|
user.setUserId(LoginHelper.getUserId());
|
||||||
user.setUserName(null);
|
user.setUserName(null);
|
||||||
user.setPassword(null);
|
user.setPassword(null);
|
||||||
if (userService.updateUserProfile(user) > 0) {
|
if (userService.updateUserProfile(user) > 0) {
|
||||||
// 更新缓存用户信息
|
return R.ok();
|
||||||
// loginUser.getSysUser().setNickName(user.getNickName());
|
|
||||||
// loginUser.getSysUser().setPhonenumber(user.getPhonenumber());
|
|
||||||
// loginUser.getSysUser().setEmail(user.getEmail());
|
|
||||||
// loginUser.getSysUser().setSex(user.getSex());
|
|
||||||
// tokenService.setLoginUser(loginUser);
|
|
||||||
return AjaxResult.success();
|
|
||||||
}
|
}
|
||||||
return AjaxResult.error("修改个人信息异常,请联系管理员");
|
return R.fail("修改个人信息异常,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重置密码
|
* 重置密码
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("重置密码")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "oldPassword", value = "旧密码", paramType = "query", dataTypeClass = String.class),
|
||||||
|
@ApiImplicitParam(name = "newPassword", value = "新密码", paramType = "query", dataTypeClass = String.class)
|
||||||
|
})
|
||||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/updatePwd")
|
@PutMapping("/updatePwd")
|
||||||
public AjaxResult updatePwd(String oldPassword, String newPassword) {
|
public R<Void> updatePwd(String oldPassword, String newPassword) {
|
||||||
SysUser user = userService.selectUserById(LoginHelper.getUserId());
|
SysUser user = userService.selectUserById(LoginHelper.getUserId());
|
||||||
String password = user.getPassword();
|
String password = user.getPassword();
|
||||||
if (!SecurityUtils.matchesPassword(oldPassword, password)) {
|
if (!SecurityUtils.matchesPassword(oldPassword, password)) {
|
||||||
return AjaxResult.error("修改密码失败,旧密码错误");
|
return R.fail("修改密码失败,旧密码错误");
|
||||||
}
|
}
|
||||||
if (SecurityUtils.matchesPassword(newPassword, password)) {
|
if (SecurityUtils.matchesPassword(newPassword, password)) {
|
||||||
return AjaxResult.error("新密码不能与旧密码相同");
|
return R.fail("新密码不能与旧密码相同");
|
||||||
}
|
}
|
||||||
if (userService.resetUserPwd(user.getUserName(), SecurityUtils.encryptPassword(newPassword)) > 0) {
|
if (userService.resetUserPwd(user.getUserName(), SecurityUtils.encryptPassword(newPassword)) > 0) {
|
||||||
// 更新缓存用户密码
|
return R.ok();
|
||||||
// LoginUser loginUser = LoginHelper.getLoginUser();
|
|
||||||
// loginUser.getSysUser().setPassword(SecurityUtils.encryptPassword(newPassword));
|
|
||||||
// tokenService.setLoginUser(loginUser);
|
|
||||||
// return AjaxResult.success();
|
|
||||||
}
|
}
|
||||||
return AjaxResult.error("修改密码异常,请联系管理员");
|
return R.fail("修改密码异常,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 头像上传
|
* 头像上传
|
||||||
*/
|
*/
|
||||||
// @GlobalTransactional(rollbackFor = Exception.class)
|
// @GlobalTransactional(rollbackFor = Exception.class)
|
||||||
|
@ApiOperation("头像上传")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "avatarfile", value = "用户头像", dataTypeClass = File.class, required = true),
|
||||||
|
})
|
||||||
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/avatar")
|
@PostMapping("/avatar")
|
||||||
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException {
|
public R<Map<String, Object>> avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException {
|
||||||
// todo 临时用于测试 seata
|
// todo 临时用于测试 seata
|
||||||
// userService.insertUser(new SysUser().setUserName("test").setNickName("test"));
|
// userService.insertUser(new SysUser().setUserName("test").setNickName("test"));
|
||||||
|
|
||||||
if (!file.isEmpty()) {
|
if (!file.isEmpty()) {
|
||||||
SysFile sysFile = remoteFileService.upload(file.getName(), file.getOriginalFilename(), file.getContentType(), file.getBytes());
|
SysFile sysFile = remoteFileService.upload(file.getName(), file.getOriginalFilename(), file.getContentType(), file.getBytes());
|
||||||
if (ObjectUtil.isNull(sysFile)) {
|
if (ObjectUtil.isNull(sysFile)) {
|
||||||
return AjaxResult.error("文件服务异常,请联系管理员");
|
return R.fail("文件服务异常,请联系管理员");
|
||||||
}
|
}
|
||||||
String url = sysFile.getUrl();
|
String url = sysFile.getUrl();
|
||||||
if (userService.updateUserAvatar(LoginHelper.getUsername(), url)) {
|
if (userService.updateUserAvatar(LoginHelper.getUsername(), url)) {
|
||||||
AjaxResult ajax = AjaxResult.success();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
ajax.put("imgUrl", url);
|
ajax.put("imgUrl", url);
|
||||||
// 更新缓存用户头像
|
return R.ok(ajax);
|
||||||
// loginUser.getSysUser().setAvatar(url);
|
|
||||||
// tokenService.setLoginUser(loginUser);
|
|
||||||
return ajax;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return AjaxResult.error("上传图片异常,请联系管理员");
|
return R.fail("上传图片异常,请联系管理员");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,19 +2,26 @@ package com.ruoyi.system.controller;
|
|||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.excel.utils.ExcelUtil;
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.mybatis.core.page.PageQuery;
|
import com.ruoyi.common.mybatis.core.page.PageQuery;
|
||||||
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.satoken.utils.LoginHelper;
|
import com.ruoyi.common.satoken.utils.LoginHelper;
|
||||||
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
import com.ruoyi.system.api.domain.SysRole;
|
import com.ruoyi.system.api.domain.SysRole;
|
||||||
import com.ruoyi.system.api.domain.SysUser;
|
import com.ruoyi.system.api.domain.SysUser;
|
||||||
|
import com.ruoyi.system.api.model.LoginUser;
|
||||||
import com.ruoyi.system.domain.SysUserRole;
|
import com.ruoyi.system.domain.SysUserRole;
|
||||||
|
import com.ruoyi.system.service.ISysPermissionService;
|
||||||
import com.ruoyi.system.service.ISysRoleService;
|
import com.ruoyi.system.service.ISysRoleService;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -25,8 +32,10 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* 角色信息
|
* 角色信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@Validated
|
||||||
|
@Api(value = "角色信息控制器", tags = {"角色信息管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/role")
|
@RequestMapping("/role")
|
||||||
@@ -34,13 +43,16 @@ public class SysRoleController extends BaseController {
|
|||||||
|
|
||||||
private final ISysRoleService roleService;
|
private final ISysRoleService roleService;
|
||||||
private final ISysUserService userService;
|
private final ISysUserService userService;
|
||||||
|
private final ISysPermissionService permissionService;
|
||||||
|
|
||||||
|
@ApiOperation("查询角色信息列表")
|
||||||
@SaCheckPermission("system:role:list")
|
@SaCheckPermission("system:role:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysRole> list(SysRole role, PageQuery pageQuery) {
|
public TableDataInfo<SysRole> list(SysRole role, PageQuery pageQuery) {
|
||||||
return roleService.selectPageRoleList(role, pageQuery);
|
return roleService.selectPageRoleList(role, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("导出角色信息列表")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:role:export")
|
@SaCheckPermission("system:role:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@@ -52,26 +64,27 @@ public class SysRoleController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 根据角色编号获取详细信息
|
* 根据角色编号获取详细信息
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("根据角色编号获取详细信息")
|
||||||
@SaCheckPermission("system:role:query")
|
@SaCheckPermission("system:role:query")
|
||||||
@GetMapping(value = "/{roleId}")
|
@GetMapping(value = "/{roleId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long roleId) {
|
public R<SysRole> getInfo(@PathVariable Long roleId) {
|
||||||
roleService.checkRoleDataScope(roleId);
|
roleService.checkRoleDataScope(roleId);
|
||||||
return AjaxResult.success(roleService.selectRoleById(roleId));
|
return R.ok(roleService.selectRoleById(roleId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增角色
|
* 新增角色
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("新增角色")
|
||||||
@SaCheckPermission("system:role:add")
|
@SaCheckPermission("system:role:add")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysRole role) {
|
public R<Void> add(@Validated @RequestBody SysRole role) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
|
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
|
||||||
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
return R.fail("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||||
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
|
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
|
||||||
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
return R.fail("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||||
}
|
}
|
||||||
role.setCreateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(roleService.insertRole(role));
|
return toAjax(roleService.insertRole(role));
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -79,28 +92,39 @@ public class SysRoleController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 修改保存角色
|
* 修改保存角色
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("修改保存角色")
|
||||||
@SaCheckPermission("system:role:edit")
|
@SaCheckPermission("system:role:edit")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysRole role) {
|
public R<Void> edit(@Validated @RequestBody SysRole role) {
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
roleService.checkRoleDataScope(role.getRoleId());
|
roleService.checkRoleDataScope(role.getRoleId());
|
||||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
|
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
|
||||||
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
return R.fail("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||||
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
|
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
|
||||||
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
return R.fail("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||||
}
|
}
|
||||||
role.setUpdateBy(LoginHelper.getUsername());
|
if (roleService.updateRole(role) > 0) {
|
||||||
return toAjax(roleService.updateRole(role));
|
// 更新缓存用户权限
|
||||||
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||||
|
Long userId = loginUser.getUserId();
|
||||||
|
if (!SecurityUtils.isAdmin(userId)) {
|
||||||
|
loginUser.setMenuPermission(permissionService.getMenuPermission(userId));
|
||||||
|
LoginHelper.setLoginUser(loginUser);
|
||||||
|
}
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
return R.fail("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存数据权限
|
* 修改保存数据权限
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("修改保存数据权限")
|
||||||
@SaCheckPermission("system:role:edit")
|
@SaCheckPermission("system:role:edit")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/dataScope")
|
@PutMapping("/dataScope")
|
||||||
public AjaxResult dataScope(@RequestBody SysRole role) {
|
public R<Void> dataScope(@RequestBody SysRole role) {
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
roleService.checkRoleDataScope(role.getRoleId());
|
roleService.checkRoleDataScope(role.getRoleId());
|
||||||
return toAjax(roleService.authDataScope(role));
|
return toAjax(roleService.authDataScope(role));
|
||||||
@@ -109,23 +133,24 @@ public class SysRoleController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 状态修改
|
* 状态修改
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("状态修改")
|
||||||
@SaCheckPermission("system:role:edit")
|
@SaCheckPermission("system:role:edit")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/changeStatus")
|
@PutMapping("/changeStatus")
|
||||||
public AjaxResult changeStatus(@RequestBody SysRole role) {
|
public R<Void> changeStatus(@RequestBody SysRole role) {
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
roleService.checkRoleDataScope(role.getRoleId());
|
roleService.checkRoleDataScope(role.getRoleId());
|
||||||
role.setUpdateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(roleService.updateRoleStatus(role));
|
return toAjax(roleService.updateRoleStatus(role));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除角色
|
* 删除角色
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("删除角色")
|
||||||
@SaCheckPermission("system:role:remove")
|
@SaCheckPermission("system:role:remove")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{roleIds}")
|
@DeleteMapping("/{roleIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] roleIds) {
|
public R<Void> remove(@PathVariable Long[] roleIds) {
|
||||||
return toAjax(roleService.deleteRoleByIds(roleIds));
|
return toAjax(roleService.deleteRoleByIds(roleIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,13 +159,14 @@ public class SysRoleController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@SaCheckPermission("system:role:query")
|
@SaCheckPermission("system:role:query")
|
||||||
@GetMapping("/optionselect")
|
@GetMapping("/optionselect")
|
||||||
public AjaxResult optionselect() {
|
public R<List<SysRole>> optionselect() {
|
||||||
return AjaxResult.success(roleService.selectRoleAll());
|
return R.ok(roleService.selectRoleAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询已分配用户角色列表
|
* 查询已分配用户角色列表
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("查询已分配用户角色列表")
|
||||||
@SaCheckPermission("system:role:list")
|
@SaCheckPermission("system:role:list")
|
||||||
@GetMapping("/authUser/allocatedList")
|
@GetMapping("/authUser/allocatedList")
|
||||||
public TableDataInfo<SysUser> allocatedList(SysUser user, PageQuery pageQuery) {
|
public TableDataInfo<SysUser> allocatedList(SysUser user, PageQuery pageQuery) {
|
||||||
@@ -150,6 +176,7 @@ public class SysRoleController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 查询未分配用户角色列表
|
* 查询未分配用户角色列表
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("查询未分配用户角色列表")
|
||||||
@SaCheckPermission("system:role:list")
|
@SaCheckPermission("system:role:list")
|
||||||
@GetMapping("/authUser/unallocatedList")
|
@GetMapping("/authUser/unallocatedList")
|
||||||
public TableDataInfo<SysUser> unallocatedList(SysUser user, PageQuery pageQuery) {
|
public TableDataInfo<SysUser> unallocatedList(SysUser user, PageQuery pageQuery) {
|
||||||
@@ -159,30 +186,41 @@ public class SysRoleController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 取消授权用户
|
* 取消授权用户
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("取消授权用户")
|
||||||
@SaCheckPermission("system:role:edit")
|
@SaCheckPermission("system:role:edit")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||||
@PutMapping("/authUser/cancel")
|
@PutMapping("/authUser/cancel")
|
||||||
public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole) {
|
public R<Void> cancelAuthUser(@RequestBody SysUserRole userRole) {
|
||||||
return toAjax(roleService.deleteAuthUser(userRole));
|
return toAjax(roleService.deleteAuthUser(userRole));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量取消授权用户
|
* 批量取消授权用户
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("批量取消授权用户")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "query", dataTypeClass = String.class),
|
||||||
|
@ApiImplicitParam(name = "userIds", value = "用户ID串", paramType = "query", dataTypeClass = String.class)
|
||||||
|
})
|
||||||
@SaCheckPermission("system:role:edit")
|
@SaCheckPermission("system:role:edit")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||||
@PutMapping("/authUser/cancelAll")
|
@PutMapping("/authUser/cancelAll")
|
||||||
public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds) {
|
public R<Void> cancelAuthUserAll(Long roleId, Long[] userIds) {
|
||||||
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
|
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量选择用户授权
|
* 批量选择用户授权
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("批量选择用户授权")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "query", dataTypeClass = String.class),
|
||||||
|
@ApiImplicitParam(name = "userIds", value = "用户ID串", paramType = "query", dataTypeClass = String.class)
|
||||||
|
})
|
||||||
@SaCheckPermission("system:role:edit")
|
@SaCheckPermission("system:role:edit")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||||
@PutMapping("/authUser/selectAll")
|
@PutMapping("/authUser/selectAll")
|
||||||
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds) {
|
public R<Void> selectAuthUserAll(Long roleId, Long[] userIds) {
|
||||||
roleService.checkRoleDataScope(roleId);
|
roleService.checkRoleDataScope(roleId);
|
||||||
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
||||||
}
|
}
|
||||||
|
@@ -4,9 +4,9 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
|
|||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.excel.core.ExcelResult;
|
import com.ruoyi.common.excel.core.ExcelResult;
|
||||||
import com.ruoyi.common.excel.utils.ExcelUtil;
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
@@ -25,6 +25,10 @@ import com.ruoyi.system.service.ISysPermissionService;
|
|||||||
import com.ruoyi.system.service.ISysPostService;
|
import com.ruoyi.system.service.ISysPostService;
|
||||||
import com.ruoyi.system.service.ISysRoleService;
|
import com.ruoyi.system.service.ISysRoleService;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -33,16 +37,16 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户信息
|
* 用户信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@Validated
|
||||||
|
@Api(value = "用户信息控制器", tags = {"用户信息管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/user")
|
@RequestMapping("/user")
|
||||||
@@ -56,12 +60,14 @@ public class SysUserController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 获取用户列表
|
* 获取用户列表
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("获取用户列表")
|
||||||
@SaCheckPermission("system:user:list")
|
@SaCheckPermission("system:user:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysUser> list(SysUser user, PageQuery pageQuery) {
|
public TableDataInfo<SysUser> list(SysUser user, PageQuery pageQuery) {
|
||||||
return userService.selectPageUserList(user, pageQuery);
|
return userService.selectPageUserList(user, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("导出用户列表")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("system:user:export")
|
@SaCheckPermission("system:user:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@@ -79,14 +85,19 @@ public class SysUserController extends BaseController {
|
|||||||
ExcelUtil.exportExcel(listVo, "用户数据", SysUserExportVo.class, response);
|
ExcelUtil.exportExcel(listVo, "用户数据", SysUserExportVo.class, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("导入用户列表")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "file", value = "导入文件", dataType = "java.io.File", required = true),
|
||||||
|
})
|
||||||
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
||||||
@SaCheckPermission("system:user:import")
|
@SaCheckPermission("system:user:import")
|
||||||
@PostMapping("/importData")
|
@PostMapping("/importData")
|
||||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
|
public R<Void> importData(MultipartFile file, boolean updateSupport) throws Exception {
|
||||||
ExcelResult<SysUserImportVo> result = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class, new SysUserImportListener(updateSupport));
|
ExcelResult<SysUserImportVo> result = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class, new SysUserImportListener(updateSupport));
|
||||||
return AjaxResult.success(result.getAnalysis());
|
return R.ok(result.getAnalysis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("下载导入模板")
|
||||||
@PostMapping("/importTemplate")
|
@PostMapping("/importTemplate")
|
||||||
public void importTemplate(HttpServletResponse response) throws IOException {
|
public void importTemplate(HttpServletResponse response) throws IOException {
|
||||||
ExcelUtil.exportExcel(new ArrayList<>(), "用户数据", SysUserImportVo.class, response);
|
ExcelUtil.exportExcel(new ArrayList<>(), "用户数据", SysUserImportVo.class, response);
|
||||||
@@ -97,58 +108,59 @@ public class SysUserController extends BaseController {
|
|||||||
*
|
*
|
||||||
* @return 用户信息
|
* @return 用户信息
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("根据用户编号获取详细信息")
|
||||||
@GetMapping("getInfo")
|
@GetMapping("getInfo")
|
||||||
public AjaxResult getInfo() {
|
public R<Map<String, Object>> getInfo() {
|
||||||
//Long userId = SecurityUtils.getUserId();
|
|
||||||
Long userId = LoginHelper.getUserId();
|
Long userId = LoginHelper.getUserId();
|
||||||
// 角色集合
|
// 角色集合
|
||||||
Set<String> roles = permissionService.getRolePermission(userId);
|
Set<String> roles = permissionService.getRolePermission(userId);
|
||||||
// 权限集合
|
// 权限集合
|
||||||
Set<String> permissions = permissionService.getMenuPermission(userId);
|
Set<String> permissions = permissionService.getMenuPermission(userId);
|
||||||
AjaxResult ajax = AjaxResult.success();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
ajax.put("user", userService.selectUserById(userId));
|
ajax.put("user", userService.selectUserById(userId));
|
||||||
ajax.put("roles", roles);
|
ajax.put("roles", roles);
|
||||||
ajax.put("permissions", permissions);
|
ajax.put("permissions", permissions);
|
||||||
return ajax;
|
return R.ok(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户编号获取详细信息
|
* 根据用户编号获取详细信息
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("根据用户编号获取详细信息")
|
||||||
@SaCheckPermission("system:user:query")
|
@SaCheckPermission("system:user:query")
|
||||||
@GetMapping(value = {"/", "/{userId}"})
|
@GetMapping(value = {"/", "/{userId}"})
|
||||||
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) {
|
public R<Map<String, Object>> getInfo(@PathVariable(value = "userId", required = false) Long userId) {
|
||||||
userService.checkUserDataScope(userId);
|
userService.checkUserDataScope(userId);
|
||||||
AjaxResult ajax = AjaxResult.success();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
List<SysRole> roles = roleService.selectRoleAll();
|
List<SysRole> roles = roleService.selectRoleAll();
|
||||||
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||||
ajax.put("posts", postService.selectPostAll());
|
ajax.put("posts", postService.selectPostAll());
|
||||||
if (ObjectUtil.isNotNull(userId)) {
|
if (ObjectUtil.isNotNull(userId)) {
|
||||||
SysUser sysUser = userService.selectUserById(userId);
|
SysUser sysUser = userService.selectUserById(userId);
|
||||||
ajax.put(AjaxResult.DATA_TAG, sysUser);
|
ajax.put("user", sysUser);
|
||||||
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
||||||
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
|
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
return ajax;
|
return R.ok(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增用户
|
* 新增用户
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("新增用户")
|
||||||
@SaCheckPermission("system:user:add")
|
@SaCheckPermission("system:user:add")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysUser user) {
|
public R<Void> add(@Validated @RequestBody SysUser user) {
|
||||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) {
|
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) {
|
||||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
return R.fail("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||||
} else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
} else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
||||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
return R.fail("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
} else if (StringUtils.isNotEmpty(user.getEmail())
|
} else if (StringUtils.isNotEmpty(user.getEmail())
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
return R.fail("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}
|
||||||
user.setCreateBy(LoginHelper.getUsername());
|
|
||||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
return toAjax(userService.insertUser(user));
|
return toAjax(userService.insertUser(user));
|
||||||
}
|
}
|
||||||
@@ -156,32 +168,33 @@ public class SysUserController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 修改用户
|
* 修改用户
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("修改用户")
|
||||||
@SaCheckPermission("system:user:edit")
|
@SaCheckPermission("system:user:edit")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysUser user) {
|
public R<Void> edit(@Validated @RequestBody SysUser user) {
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
userService.checkUserDataScope(user.getUserId());
|
userService.checkUserDataScope(user.getUserId());
|
||||||
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
||||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
return R.fail("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
} else if (StringUtils.isNotEmpty(user.getEmail())
|
} else if (StringUtils.isNotEmpty(user.getEmail())
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
return R.fail("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}
|
||||||
user.setUpdateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(userService.updateUser(user));
|
return toAjax(userService.updateUser(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除用户
|
* 删除用户
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("删除用户")
|
||||||
@SaCheckPermission("system:user:remove")
|
@SaCheckPermission("system:user:remove")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{userIds}")
|
@DeleteMapping("/{userIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] userIds) {
|
public R<Void> remove(@PathVariable Long[] userIds) {
|
||||||
if (ArrayUtils.contains(userIds, LoginHelper.getUserId())) {
|
if (ArrayUtils.contains(userIds, LoginHelper.getUserId())) {
|
||||||
return AjaxResult.error("当前用户不能删除");
|
return R.fail("当前用户不能删除");
|
||||||
}
|
}
|
||||||
return toAjax(userService.deleteUserByIds(userIds));
|
return toAjax(userService.deleteUserByIds(userIds));
|
||||||
}
|
}
|
||||||
@@ -189,51 +202,57 @@ public class SysUserController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 重置密码
|
* 重置密码
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("重置密码")
|
||||||
@SaCheckPermission("system:user:edit")
|
@SaCheckPermission("system:user:edit")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/resetPwd")
|
@PutMapping("/resetPwd")
|
||||||
public AjaxResult resetPwd(@RequestBody SysUser user) {
|
public R<Void> resetPwd(@RequestBody SysUser user) {
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
userService.checkUserDataScope(user.getUserId());
|
userService.checkUserDataScope(user.getUserId());
|
||||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
user.setUpdateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(userService.resetPwd(user));
|
return toAjax(userService.resetPwd(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态修改
|
* 状态修改
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("状态修改")
|
||||||
@SaCheckPermission("system:user:edit")
|
@SaCheckPermission("system:user:edit")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/changeStatus")
|
@PutMapping("/changeStatus")
|
||||||
public AjaxResult changeStatus(@RequestBody SysUser user) {
|
public R<Void> changeStatus(@RequestBody SysUser user) {
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
userService.checkUserDataScope(user.getUserId());
|
userService.checkUserDataScope(user.getUserId());
|
||||||
user.setUpdateBy(LoginHelper.getUsername());
|
|
||||||
return toAjax(userService.updateUserStatus(user));
|
return toAjax(userService.updateUserStatus(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户编号获取授权角色
|
* 根据用户编号获取授权角色
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("根据用户编号获取授权角色")
|
||||||
@SaCheckPermission("system:user:query")
|
@SaCheckPermission("system:user:query")
|
||||||
@GetMapping("/authRole/{userId}")
|
@GetMapping("/authRole/{userId}")
|
||||||
public AjaxResult authRole(@PathVariable("userId") Long userId) {
|
public R<Map<String, Object>> authRole(@PathVariable("userId") Long userId) {
|
||||||
AjaxResult ajax = AjaxResult.success();
|
Map<String, Object> ajax = new HashMap<>();
|
||||||
SysUser user = userService.selectUserById(userId);
|
SysUser user = userService.selectUserById(userId);
|
||||||
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
||||||
ajax.put("user", user);
|
ajax.put("user", user);
|
||||||
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||||
return ajax;
|
return R.ok(ajax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户授权角色
|
* 用户授权角色
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("用户授权角色")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "userId", value = "用户Id", paramType = "query", dataTypeClass = String.class),
|
||||||
|
@ApiImplicitParam(name = "roleIds", value = "角色ID串", paramType = "query", dataTypeClass = String.class)
|
||||||
|
})
|
||||||
@SaCheckPermission("system:user:edit")
|
@SaCheckPermission("system:user:edit")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
||||||
@PutMapping("/authRole")
|
@PutMapping("/authRole")
|
||||||
public AjaxResult insertAuthRole(Long userId, Long[] roleIds) {
|
public R<Void> insertAuthRole(Long userId, Long[] roleIds) {
|
||||||
userService.checkUserDataScope(userId);
|
userService.checkUserDataScope(userId);
|
||||||
userService.insertUserAuth(userId, roleIds);
|
userService.insertUserAuth(userId, roleIds);
|
||||||
return success();
|
return success();
|
||||||
|
@@ -4,15 +4,16 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
|
|||||||
import cn.dev33.satoken.exception.NotLoginException;
|
import cn.dev33.satoken.exception.NotLoginException;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import com.ruoyi.common.core.constant.CacheConstants;
|
import com.ruoyi.common.core.constant.CacheConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.redis.utils.RedisUtils;
|
import com.ruoyi.common.redis.utils.RedisUtils;
|
||||||
import com.ruoyi.system.api.domain.SysUserOnline;
|
import com.ruoyi.system.api.domain.SysUserOnline;
|
||||||
import com.ruoyi.system.service.ISysUserOnlineService;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -24,15 +25,15 @@ import java.util.stream.Collectors;
|
|||||||
/**
|
/**
|
||||||
* 在线用户监控
|
* 在线用户监控
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@Api(value = "在线用户监控", tags = {"在线用户监控管理"})
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/online")
|
@RequestMapping("/online")
|
||||||
public class SysUserOnlineController extends BaseController {
|
public class SysUserOnlineController extends BaseController {
|
||||||
|
|
||||||
private final ISysUserOnlineService userOnlineService;
|
@ApiOperation("在线用户列表")
|
||||||
|
|
||||||
@SaCheckPermission("monitor:online:list")
|
@SaCheckPermission("monitor:online:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SysUserOnline> list(String ipaddr, String userName) {
|
public TableDataInfo<SysUserOnline> list(String ipaddr, String userName) {
|
||||||
@@ -69,15 +70,15 @@ public class SysUserOnlineController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 强退用户
|
* 强退用户
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("强退用户")
|
||||||
@SaCheckPermission("monitor:online:forceLogout")
|
@SaCheckPermission("monitor:online:forceLogout")
|
||||||
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
||||||
@DeleteMapping("/{tokenId}")
|
@DeleteMapping("/{tokenId}")
|
||||||
public AjaxResult forceLogout(@PathVariable String tokenId) {
|
public R<Void> forceLogout(@PathVariable String tokenId) {
|
||||||
try {
|
try {
|
||||||
StpUtil.kickoutByTokenValue(tokenId);
|
StpUtil.kickoutByTokenValue(tokenId);
|
||||||
} catch (NotLoginException e) {
|
} catch (NotLoginException e) {
|
||||||
}
|
}
|
||||||
//RedisUtils.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
|
return R.ok();
|
||||||
return AjaxResult.success();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,47 +0,0 @@
|
|||||||
package com.ruoyi.system.service;
|
|
||||||
|
|
||||||
import com.ruoyi.system.api.model.LoginUser;
|
|
||||||
import com.ruoyi.system.api.domain.SysUserOnline;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在线用户 服务层
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public interface ISysUserOnlineService {
|
|
||||||
/**
|
|
||||||
* 通过登录地址查询信息
|
|
||||||
*
|
|
||||||
* @param ipaddr 登录地址
|
|
||||||
* @param user 用户信息
|
|
||||||
* @return 在线用户信息
|
|
||||||
*/
|
|
||||||
SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过用户名称查询信息
|
|
||||||
*
|
|
||||||
* @param userName 用户名称
|
|
||||||
* @param user 用户信息
|
|
||||||
* @return 在线用户信息
|
|
||||||
*/
|
|
||||||
SysUserOnline selectOnlineByUserName(String userName, LoginUser user);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过登录地址/用户名称查询信息
|
|
||||||
*
|
|
||||||
* @param ipaddr 登录地址
|
|
||||||
* @param userName 用户名称
|
|
||||||
* @param user 用户信息
|
|
||||||
* @return 在线用户信息
|
|
||||||
*/
|
|
||||||
SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置在线用户信息
|
|
||||||
*
|
|
||||||
* @param user 用户信息
|
|
||||||
* @return 在线用户
|
|
||||||
*/
|
|
||||||
SysUserOnline loginUserToUserOnline(LoginUser user);
|
|
||||||
}
|
|
@@ -1,81 +0,0 @@
|
|||||||
package com.ruoyi.system.service.impl;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
|
||||||
import com.ruoyi.system.api.model.LoginUser;
|
|
||||||
import com.ruoyi.system.api.domain.SysUserOnline;
|
|
||||||
import com.ruoyi.system.service.ISysUserOnlineService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在线用户 服务层处理
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class SysUserOnlineServiceImpl implements ISysUserOnlineService {
|
|
||||||
/**
|
|
||||||
* 通过登录地址查询信息
|
|
||||||
*
|
|
||||||
* @param ipaddr 登录地址
|
|
||||||
* @param user 用户信息
|
|
||||||
* @return 在线用户信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user) {
|
|
||||||
if (StringUtils.equals(ipaddr, user.getIpaddr())) {
|
|
||||||
return loginUserToUserOnline(user);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过用户名称查询信息
|
|
||||||
*
|
|
||||||
* @param userName 用户名称
|
|
||||||
* @param user 用户信息
|
|
||||||
* @return 在线用户信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public SysUserOnline selectOnlineByUserName(String userName, LoginUser user) {
|
|
||||||
if (StringUtils.equals(userName, user.getUsername())) {
|
|
||||||
return loginUserToUserOnline(user);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过登录地址/用户名称查询信息
|
|
||||||
*
|
|
||||||
* @param ipaddr 登录地址
|
|
||||||
* @param userName 用户名称
|
|
||||||
* @param user 用户信息
|
|
||||||
* @return 在线用户信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user) {
|
|
||||||
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) {
|
|
||||||
return loginUserToUserOnline(user);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置在线用户信息
|
|
||||||
*
|
|
||||||
* @param user 用户信息
|
|
||||||
* @return 在线用户
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public SysUserOnline loginUserToUserOnline(LoginUser user) {
|
|
||||||
if (ObjectUtil.isNull(user)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
SysUserOnline sysUserOnline = new SysUserOnline();
|
|
||||||
sysUserOnline.setTokenId(user.getToken());
|
|
||||||
sysUserOnline.setUserName(user.getUsername());
|
|
||||||
sysUserOnline.setIpaddr(user.getIpaddr());
|
|
||||||
sysUserOnline.setLoginTime(user.getLoginTime());
|
|
||||||
return sysUserOnline;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -56,11 +56,11 @@ const user = {
|
|||||||
GetInfo({ commit, state }) {
|
GetInfo({ commit, state }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
getInfo().then(res => {
|
getInfo().then(res => {
|
||||||
const user = res.user
|
const user = res.data.user
|
||||||
const avatar = user.avatar == "" ? require("@/assets/images/profile.jpg") : user.avatar;
|
const avatar = user.avatar == "" ? require("@/assets/images/profile.jpg") : user.avatar;
|
||||||
if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
|
if (res.data.roles && res.data.roles.length > 0) { // 验证返回的roles是否是一个非空数组
|
||||||
commit('SET_ROLES', res.roles)
|
commit('SET_ROLES', res.data.roles)
|
||||||
commit('SET_PERMISSIONS', res.permissions)
|
commit('SET_PERMISSIONS', res.data.permissions)
|
||||||
} else {
|
} else {
|
||||||
commit('SET_ROLES', ['ROLE_DEFAULT'])
|
commit('SET_ROLES', ['ROLE_DEFAULT'])
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,91 +1,91 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="6" :xs="24">
|
<el-col :span="6" :xs="24">
|
||||||
<el-card class="box-card">
|
<el-card class="box-card">
|
||||||
<div slot="header" class="clearfix">
|
<div slot="header" class="clearfix">
|
||||||
<span>个人信息</span>
|
<span>个人信息</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<userAvatar :user="user" />
|
<userAvatar :user="user" />
|
||||||
</div>
|
</div>
|
||||||
<ul class="list-group list-group-striped">
|
<ul class="list-group list-group-striped">
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<svg-icon icon-class="user" />用户名称
|
<svg-icon icon-class="user" />用户名称
|
||||||
<div class="pull-right">{{ user.userName }}</div>
|
<div class="pull-right">{{ user.userName }}</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<svg-icon icon-class="phone" />手机号码
|
<svg-icon icon-class="phone" />手机号码
|
||||||
<div class="pull-right">{{ user.phonenumber }}</div>
|
<div class="pull-right">{{ user.phonenumber }}</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<svg-icon icon-class="email" />用户邮箱
|
<svg-icon icon-class="email" />用户邮箱
|
||||||
<div class="pull-right">{{ user.email }}</div>
|
<div class="pull-right">{{ user.email }}</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<svg-icon icon-class="tree" />所属部门
|
<svg-icon icon-class="tree" />所属部门
|
||||||
<div class="pull-right" v-if="user.dept">{{ user.dept.deptName }} / {{ postGroup }}</div>
|
<div class="pull-right" v-if="user.dept">{{ user.dept.deptName }} / {{ postGroup }}</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<svg-icon icon-class="peoples" />所属角色
|
<svg-icon icon-class="peoples" />所属角色
|
||||||
<div class="pull-right">{{ roleGroup }}</div>
|
<div class="pull-right">{{ roleGroup }}</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<svg-icon icon-class="date" />创建日期
|
<svg-icon icon-class="date" />创建日期
|
||||||
<div class="pull-right">{{ user.createTime }}</div>
|
<div class="pull-right">{{ user.createTime }}</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="18" :xs="24">
|
<el-col :span="18" :xs="24">
|
||||||
<el-card>
|
<el-card>
|
||||||
<div slot="header" class="clearfix">
|
<div slot="header" class="clearfix">
|
||||||
<span>基本资料</span>
|
<span>基本资料</span>
|
||||||
</div>
|
</div>
|
||||||
<el-tabs v-model="activeTab">
|
<el-tabs v-model="activeTab">
|
||||||
<el-tab-pane label="基本资料" name="userinfo">
|
<el-tab-pane label="基本资料" name="userinfo">
|
||||||
<userInfo :user="user" />
|
<userInfo :user="user" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="修改密码" name="resetPwd">
|
<el-tab-pane label="修改密码" name="resetPwd">
|
||||||
<resetPwd :user="user" />
|
<resetPwd :user="user" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import userAvatar from "./userAvatar";
|
import userAvatar from "./userAvatar";
|
||||||
import userInfo from "./userInfo";
|
import userInfo from "./userInfo";
|
||||||
import resetPwd from "./resetPwd";
|
import resetPwd from "./resetPwd";
|
||||||
import { getUserProfile } from "@/api/system/user";
|
import { getUserProfile } from "@/api/system/user";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Profile",
|
name: "Profile",
|
||||||
components: { userAvatar, userInfo, resetPwd },
|
components: { userAvatar, userInfo, resetPwd },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
user: {},
|
user: {},
|
||||||
roleGroup: {},
|
roleGroup: {},
|
||||||
postGroup: {},
|
postGroup: {},
|
||||||
activeTab: "userinfo"
|
activeTab: "userinfo"
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getUser();
|
this.getUser();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getUser() {
|
getUser() {
|
||||||
getUserProfile().then(response => {
|
getUserProfile().then(response => {
|
||||||
this.user = response.data;
|
this.user = response.data.user;
|
||||||
this.roleGroup = response.roleGroup;
|
this.roleGroup = response.data.roleGroup;
|
||||||
this.postGroup = response.postGroup;
|
this.postGroup = response.data.postGroup;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@@ -1,172 +1,172 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="user-info-head" @click="editCropper()"><img v-bind:src="options.img" title="点击上传头像" class="img-circle img-lg" /></div>
|
<div class="user-info-head" @click="editCropper()"><img v-bind:src="options.img" title="点击上传头像" class="img-circle img-lg" /></div>
|
||||||
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @opened="modalOpened" @close="closeDialog">
|
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @opened="modalOpened" @close="closeDialog">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :xs="24" :md="12" :style="{height: '350px'}">
|
<el-col :xs="24" :md="12" :style="{height: '350px'}">
|
||||||
<vue-cropper
|
<vue-cropper
|
||||||
ref="cropper"
|
ref="cropper"
|
||||||
:img="options.img"
|
:img="options.img"
|
||||||
:info="true"
|
:info="true"
|
||||||
:autoCrop="options.autoCrop"
|
:autoCrop="options.autoCrop"
|
||||||
:autoCropWidth="options.autoCropWidth"
|
:autoCropWidth="options.autoCropWidth"
|
||||||
:autoCropHeight="options.autoCropHeight"
|
:autoCropHeight="options.autoCropHeight"
|
||||||
:fixedBox="options.fixedBox"
|
:fixedBox="options.fixedBox"
|
||||||
@realTime="realTime"
|
@realTime="realTime"
|
||||||
v-if="visible"
|
v-if="visible"
|
||||||
/>
|
/>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :xs="24" :md="12" :style="{height: '350px'}">
|
<el-col :xs="24" :md="12" :style="{height: '350px'}">
|
||||||
<div class="avatar-upload-preview">
|
<div class="avatar-upload-preview">
|
||||||
<img :src="previews.url" :style="previews.img" />
|
<img :src="previews.url" :style="previews.img" />
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<br />
|
<br />
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :lg="2" :md="2">
|
<el-col :lg="2" :md="2">
|
||||||
<el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload">
|
<el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload">
|
||||||
<el-button size="small">
|
<el-button size="small">
|
||||||
选择
|
选择
|
||||||
<i class="el-icon-upload el-icon--right"></i>
|
<i class="el-icon-upload el-icon--right"></i>
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="{span: 1, offset: 2}" :md="2">
|
<el-col :lg="{span: 1, offset: 2}" :md="2">
|
||||||
<el-button icon="el-icon-plus" size="small" @click="changeScale(1)"></el-button>
|
<el-button icon="el-icon-plus" size="small" @click="changeScale(1)"></el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="{span: 1, offset: 1}" :md="2">
|
<el-col :lg="{span: 1, offset: 1}" :md="2">
|
||||||
<el-button icon="el-icon-minus" size="small" @click="changeScale(-1)"></el-button>
|
<el-button icon="el-icon-minus" size="small" @click="changeScale(-1)"></el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="{span: 1, offset: 1}" :md="2">
|
<el-col :lg="{span: 1, offset: 1}" :md="2">
|
||||||
<el-button icon="el-icon-refresh-left" size="small" @click="rotateLeft()"></el-button>
|
<el-button icon="el-icon-refresh-left" size="small" @click="rotateLeft()"></el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="{span: 1, offset: 1}" :md="2">
|
<el-col :lg="{span: 1, offset: 1}" :md="2">
|
||||||
<el-button icon="el-icon-refresh-right" size="small" @click="rotateRight()"></el-button>
|
<el-button icon="el-icon-refresh-right" size="small" @click="rotateRight()"></el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="{span: 2, offset: 6}" :md="2">
|
<el-col :lg="{span: 2, offset: 6}" :md="2">
|
||||||
<el-button type="primary" size="small" @click="uploadImg()">提 交</el-button>
|
<el-button type="primary" size="small" @click="uploadImg()">提 交</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import { VueCropper } from "vue-cropper";
|
import { VueCropper } from "vue-cropper";
|
||||||
import { uploadAvatar } from "@/api/system/user";
|
import { uploadAvatar } from "@/api/system/user";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { VueCropper },
|
components: { VueCropper },
|
||||||
props: {
|
props: {
|
||||||
user: {
|
user: {
|
||||||
type: Object
|
type: Object
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
open: false,
|
open: false,
|
||||||
// 是否显示cropper
|
// 是否显示cropper
|
||||||
visible: false,
|
visible: false,
|
||||||
// 弹出层标题
|
// 弹出层标题
|
||||||
title: "修改头像",
|
title: "修改头像",
|
||||||
options: {
|
options: {
|
||||||
img: store.getters.avatar, //裁剪图片的地址
|
img: store.getters.avatar, //裁剪图片的地址
|
||||||
autoCrop: true, // 是否默认生成截图框
|
autoCrop: true, // 是否默认生成截图框
|
||||||
autoCropWidth: 200, // 默认生成截图框宽度
|
autoCropWidth: 200, // 默认生成截图框宽度
|
||||||
autoCropHeight: 200, // 默认生成截图框高度
|
autoCropHeight: 200, // 默认生成截图框高度
|
||||||
fixedBox: true // 固定截图框大小 不允许改变
|
fixedBox: true // 固定截图框大小 不允许改变
|
||||||
},
|
},
|
||||||
previews: {}
|
previews: {}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 编辑头像
|
// 编辑头像
|
||||||
editCropper() {
|
editCropper() {
|
||||||
this.open = true;
|
this.open = true;
|
||||||
},
|
},
|
||||||
// 打开弹出层结束时的回调
|
// 打开弹出层结束时的回调
|
||||||
modalOpened() {
|
modalOpened() {
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
},
|
},
|
||||||
// 覆盖默认的上传行为
|
// 覆盖默认的上传行为
|
||||||
requestUpload() {
|
requestUpload() {
|
||||||
},
|
},
|
||||||
// 向左旋转
|
// 向左旋转
|
||||||
rotateLeft() {
|
rotateLeft() {
|
||||||
this.$refs.cropper.rotateLeft();
|
this.$refs.cropper.rotateLeft();
|
||||||
},
|
},
|
||||||
// 向右旋转
|
// 向右旋转
|
||||||
rotateRight() {
|
rotateRight() {
|
||||||
this.$refs.cropper.rotateRight();
|
this.$refs.cropper.rotateRight();
|
||||||
},
|
},
|
||||||
// 图片缩放
|
// 图片缩放
|
||||||
changeScale(num) {
|
changeScale(num) {
|
||||||
num = num || 1;
|
num = num || 1;
|
||||||
this.$refs.cropper.changeScale(num);
|
this.$refs.cropper.changeScale(num);
|
||||||
},
|
},
|
||||||
// 上传预处理
|
// 上传预处理
|
||||||
beforeUpload(file) {
|
beforeUpload(file) {
|
||||||
if (file.type.indexOf("image/") == -1) {
|
if (file.type.indexOf("image/") == -1) {
|
||||||
this.$modal.msgError("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。");
|
this.$modal.msgError("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。");
|
||||||
} else {
|
} else {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
reader.onload = () => {
|
reader.onload = () => {
|
||||||
this.options.img = reader.result;
|
this.options.img = reader.result;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 上传图片
|
// 上传图片
|
||||||
uploadImg() {
|
uploadImg() {
|
||||||
this.$refs.cropper.getCropBlob(data => {
|
this.$refs.cropper.getCropBlob(data => {
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
formData.append("avatarfile", data);
|
formData.append("avatarfile", data);
|
||||||
uploadAvatar(formData).then(response => {
|
uploadAvatar(formData).then(response => {
|
||||||
this.open = false;
|
this.open = false;
|
||||||
this.options.img = response.imgUrl;
|
this.options.img = response.data.imgUrl;
|
||||||
store.commit('SET_AVATAR', this.options.img);
|
store.commit('SET_AVATAR', this.options.img);
|
||||||
this.$modal.msgSuccess("修改成功");
|
this.$modal.msgSuccess("修改成功");
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 实时预览
|
// 实时预览
|
||||||
realTime(data) {
|
realTime(data) {
|
||||||
this.previews = data;
|
this.previews = data;
|
||||||
},
|
},
|
||||||
// 关闭窗口
|
// 关闭窗口
|
||||||
closeDialog() {
|
closeDialog() {
|
||||||
this.options.img = store.getters.avatar
|
this.options.img = store.getters.avatar
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.user-info-head {
|
.user-info-head {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
height: 120px;
|
height: 120px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-info-head:hover:after {
|
.user-info-head:hover:after {
|
||||||
content: '+';
|
content: '+';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
color: #eee;
|
color: #eee;
|
||||||
background: rgba(0, 0, 0, 0.5);
|
background: rgba(0, 0, 0, 0.5);
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
line-height: 110px;
|
line-height: 110px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Reference in New Issue
Block a user