30 files deleted
9 files added
2 files renamed
42 files modified
| | |
| | | |
| | | * 采用前后端分离的模式,微服务版本前端(基于 [RuoYi-Vue](https://gitee.com/y_project/RuoYi-Vue))。 |
| | | * 后端采用Spring Boot、Spring Cloud & Alibaba。 |
| | | * 注册中心、配置中心选型Nacos,权限认证使用OAuth2。 |
| | | * 注册中心、配置中心选型Nacos,权限认证使用Redis。 |
| | | * 流量控制框架选型Sentinel。 |
| | | * 如需不分离应用,请移步 [RuoYi](https://gitee.com/y_project/RuoYi),如需分离应用,请移步 [RuoYi-Vue](https://gitee.com/y_project/RuoYi-Vue) |
| | | * 阿里云优惠券:[点我进入](https://www.aliyun.com/minisite/goods?userCode=brki8iof&share_source=copy_link),腾讯云优惠券:[点我领取](https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console) |
| | |
| | | import com.ruoyi.common.core.constant.ServiceNameConstants;
|
| | | import com.ruoyi.common.core.domain.R;
|
| | | import com.ruoyi.system.api.factory.RemoteUserFallbackFactory;
|
| | | import com.ruoyi.system.api.model.UserInfo;
|
| | | import com.ruoyi.system.api.model.LoginUser;
|
| | |
|
| | | /**
|
| | | * 用户服务
|
| | |
| | | * @return 结果
|
| | | */
|
| | | @GetMapping(value = "/user/info/{username}")
|
| | | public R<UserInfo> getUserInfo(@PathVariable("username") String username);
|
| | | public R<LoginUser> getUserInfo(@PathVariable("username") String username);
|
| | | }
|
| | |
| | | import org.springframework.stereotype.Component;
|
| | | import com.ruoyi.common.core.domain.R;
|
| | | import com.ruoyi.system.api.RemoteUserService;
|
| | | import com.ruoyi.system.api.model.UserInfo;
|
| | | import com.ruoyi.system.api.model.LoginUser;
|
| | | import feign.hystrix.FallbackFactory;
|
| | |
|
| | | /**
|
| | |
| | | return new RemoteUserService()
|
| | | {
|
| | | @Override
|
| | | public R<UserInfo> getUserInfo(String username)
|
| | | public R<LoginUser> getUserInfo(String username)
|
| | | {
|
| | | return null;
|
| | | }
|
| New file |
| | |
| | | package com.ruoyi.system.api.model;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.util.Set;
|
| | | import com.ruoyi.system.api.domain.SysUser;
|
| | |
|
| | | /**
|
| | | * 用户信息
|
| | | *
|
| | | * @author ruoyi
|
| | | */
|
| | | public class LoginUser implements Serializable
|
| | | {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | /**
|
| | | * 用户唯一标识
|
| | | */
|
| | | private String token;
|
| | |
|
| | | /**
|
| | | * 用户名id
|
| | | */
|
| | | private Long userid;
|
| | |
|
| | | /**
|
| | | * 用户名
|
| | | */
|
| | | private String username;
|
| | |
|
| | | /**
|
| | | * 登陆时间
|
| | | */
|
| | | private Long loginTime;
|
| | |
|
| | | /**
|
| | | * 过期时间
|
| | | */
|
| | | private Long expireTime;
|
| | |
|
| | | /**
|
| | | * 权限列表
|
| | | */
|
| | | private Set<String> permissions;
|
| | |
|
| | | /**
|
| | | * 角色列表
|
| | | */
|
| | | private Set<String> roles;
|
| | |
|
| | | /**
|
| | | * 用户信息
|
| | | */
|
| | | private SysUser sysUser;
|
| | |
|
| | | public String getToken()
|
| | | {
|
| | | return token;
|
| | | }
|
| | |
|
| | | public void setToken(String token)
|
| | | {
|
| | | this.token = token;
|
| | | }
|
| | |
|
| | | public Long getUserid()
|
| | | {
|
| | | return userid;
|
| | | }
|
| | |
|
| | | public void setUserid(Long userid)
|
| | | {
|
| | | this.userid = userid;
|
| | | }
|
| | |
|
| | | public String getUsername()
|
| | | {
|
| | | return username;
|
| | | }
|
| | |
|
| | | public void setUsername(String username)
|
| | | {
|
| | | this.username = username;
|
| | | }
|
| | |
|
| | | public Long getLoginTime()
|
| | | {
|
| | | return loginTime;
|
| | | }
|
| | |
|
| | | public void setLoginTime(Long loginTime)
|
| | | {
|
| | | this.loginTime = loginTime;
|
| | | }
|
| | |
|
| | | public Long getExpireTime()
|
| | | {
|
| | | return expireTime;
|
| | | }
|
| | |
|
| | | public void setExpireTime(Long expireTime)
|
| | | {
|
| | | this.expireTime = expireTime;
|
| | | }
|
| | |
|
| | | public Set<String> getPermissions()
|
| | | {
|
| | | return permissions;
|
| | | }
|
| | |
|
| | | public void setPermissions(Set<String> permissions)
|
| | | {
|
| | | this.permissions = permissions;
|
| | | }
|
| | |
|
| | | public Set<String> getRoles()
|
| | | {
|
| | | return roles;
|
| | | }
|
| | |
|
| | | public void setRoles(Set<String> roles)
|
| | | {
|
| | | this.roles = roles;
|
| | | }
|
| | |
|
| | | public SysUser getSysUser()
|
| | | {
|
| | | return sysUser;
|
| | | }
|
| | |
|
| | | public void setSysUser(SysUser sysUser)
|
| | | {
|
| | | this.sysUser = sysUser;
|
| | | }
|
| | | }
|
| | |
| | | <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- SpringCloud Netflix Hystrix -->
|
| | | <!-- SpringCloud Ailibaba Sentinel -->
|
| | | <dependency>
|
| | | <groupId>org.springframework.cloud</groupId>
|
| | | <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
|
| | | <groupId>com.alibaba.cloud</groupId>
|
| | | <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- SpringBoot Web -->
|
| | | <dependency>
|
| | | <groupId>org.springframework.boot</groupId>
|
| | | <artifactId>spring-boot-starter-web</artifactId>
|
| | | </dependency>
|
| | | |
| | | <!-- SpringBoot Actuator -->
|
| | | <dependency>
|
| | | <groupId>org.springframework.boot</groupId>
|
| | | <artifactId>spring-boot-starter-actuator</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- Mysql Connector -->
|
| | |
| | | <dependency>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi-common-security</artifactId>
|
| | | </dependency>
|
| | | |
| | | <!-- RuoYi Common Redis-->
|
| | | <dependency>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi-common-redis</artifactId>
|
| | | </dependency>
|
| | |
|
| | | </dependencies>
|
| | |
| | | package com.ruoyi.auth.controller;
|
| | |
|
| | | import java.util.Map;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.http.HttpHeaders;
|
| | | import org.springframework.security.oauth2.common.OAuth2AccessToken;
|
| | | import org.springframework.security.oauth2.common.OAuth2RefreshToken;
|
| | | import org.springframework.security.oauth2.provider.token.TokenStore;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.RequestHeader;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.PostMapping;
|
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.core.constant.Constants;
|
| | | import com.ruoyi.common.core.constant.SecurityConstants;
|
| | | import com.ruoyi.auth.form.LoginBody;
|
| | | import com.ruoyi.auth.service.SysLoginService;
|
| | | import com.ruoyi.common.core.domain.R;
|
| | | import com.ruoyi.common.core.utils.StringUtils;
|
| | | import com.ruoyi.system.api.RemoteLogService;
|
| | | import com.ruoyi.common.security.service.TokenService;
|
| | | import com.ruoyi.system.api.model.LoginUser;
|
| | |
|
| | | /**
|
| | | * token 控制
|
| | |
| | | * @author ruoyi
|
| | | */
|
| | | @RestController
|
| | | @RequestMapping("/token")
|
| | | public class TokenController
|
| | | {
|
| | | @Autowired
|
| | | private TokenStore tokenStore;
|
| | | private TokenService tokenService;
|
| | |
|
| | | @Autowired
|
| | | private RemoteLogService remoteLogService;
|
| | | private SysLoginService sysLoginService;
|
| | |
|
| | | @DeleteMapping("/logout")
|
| | | public R<?> logout(@RequestHeader(value = HttpHeaders.AUTHORIZATION, required = false) String authHeader)
|
| | | @PostMapping("login")
|
| | | public R<?> login(@RequestBody LoginBody form)
|
| | | {
|
| | | if (StringUtils.isEmpty(authHeader))
|
| | | {
|
| | | return R.ok();
|
| | | // 用户登录
|
| | | LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
|
| | | // 获取登录token
|
| | | return R.ok(tokenService.createToken(userInfo));
|
| | | }
|
| | |
|
| | | String tokenValue = authHeader.replace(OAuth2AccessToken.BEARER_TYPE, StringUtils.EMPTY).trim();
|
| | | OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue);
|
| | | if (accessToken == null || StringUtils.isEmpty(accessToken.getValue()))
|
| | | @DeleteMapping("logout")
|
| | | public R<?> logout(HttpServletRequest request)
|
| | | {
|
| | | return R.ok();
|
| | | }
|
| | |
|
| | | // 清空 access token
|
| | | tokenStore.removeAccessToken(accessToken);
|
| | |
|
| | | // 清空 refresh token
|
| | | OAuth2RefreshToken refreshToken = accessToken.getRefreshToken();
|
| | | tokenStore.removeRefreshToken(refreshToken);
|
| | | Map<String, ?> map = accessToken.getAdditionalInformation();
|
| | | if (map.containsKey(SecurityConstants.DETAILS_USERNAME))
|
| | | LoginUser loginUser = tokenService.getLoginUser(request);
|
| | | if (StringUtils.isNotNull(loginUser))
|
| | | {
|
| | | String username = (String) map.get(SecurityConstants.DETAILS_USERNAME);
|
| | | String username = loginUser.getUsername();
|
| | | // 删除用户缓存记录
|
| | | tokenService.delLoginUser(loginUser.getToken());
|
| | | // 记录用户退出日志
|
| | | remoteLogService.saveLogininfor(username, Constants.LOGOUT, "退出成功");
|
| | | sysLoginService.logout(username);
|
| | | }
|
| | | return R.ok();
|
| | | }
|
| | |
|
| | | @PostMapping("refresh")
|
| | | public R<?> refresh(HttpServletRequest request)
|
| | | {
|
| | | LoginUser loginUser = tokenService.getLoginUser(request);
|
| | | if (StringUtils.isNotNull(loginUser))
|
| | | {
|
| | | // 刷新令牌有效期
|
| | | return R.ok(tokenService.refreshToken(loginUser));
|
| | | }
|
| | | return R.ok();
|
| | | }
|
| New file |
| | |
| | | package com.ruoyi.auth.form; |
| | | |
| | | /** |
| | | * 用户登录对象 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class LoginBody |
| | | { |
| | | /** |
| | | * 用户名 |
| | | */ |
| | | private String username; |
| | | |
| | | /** |
| | | * 用户密码 |
| | | */ |
| | | private String password; |
| | | |
| | | /** |
| | | * 验证码 |
| | | */ |
| | | private String code; |
| | | |
| | | /** |
| | | * 唯一标识 |
| | | */ |
| | | private String uuid = ""; |
| | | |
| | | public String getUsername() |
| | | { |
| | | return username; |
| | | } |
| | | |
| | | public void setUsername(String username) |
| | | { |
| | | this.username = username; |
| | | } |
| | | |
| | | public String getPassword() |
| | | { |
| | | return password; |
| | | } |
| | | |
| | | public void setPassword(String password) |
| | | { |
| | | this.password = password; |
| | | } |
| | | |
| | | public String getCode() |
| | | { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(String code) |
| | | { |
| | | this.code = code; |
| | | } |
| | | |
| | | public String getUuid() |
| | | { |
| | | return uuid; |
| | | } |
| | | |
| | | public void setUuid(String uuid) |
| | | { |
| | | this.uuid = uuid; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.ruoyi.auth.service; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.enums.UserStatus; |
| | | import com.ruoyi.common.core.exception.BaseException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.system.api.RemoteLogService; |
| | | import com.ruoyi.system.api.RemoteUserService; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | |
| | | /** |
| | | * 登录校验方法 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class SysLoginService |
| | | { |
| | | @Autowired |
| | | private RemoteLogService remoteLogService; |
| | | |
| | | @Autowired |
| | | private RemoteUserService remoteUserService; |
| | | |
| | | /** |
| | | * 登录 |
| | | */ |
| | | public LoginUser login(String username, String password) |
| | | { |
| | | // 用户名或密码为空 错误 |
| | | if (StringUtils.isAnyBlank(username, password)) |
| | | { |
| | | remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写"); |
| | | throw new BaseException("用户/密码必须填写"); |
| | | } |
| | | // 密码如果不在指定范围内 错误 |
| | | if (password.length() < UserConstants.PASSWORD_MIN_LENGTH |
| | | || password.length() > UserConstants.PASSWORD_MAX_LENGTH) |
| | | { |
| | | remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户密码不在指定范围"); |
| | | throw new BaseException("用户密码不在指定范围"); |
| | | } |
| | | // 用户名不在指定范围内 错误 |
| | | if (username.length() < UserConstants.USERNAME_MIN_LENGTH |
| | | || username.length() > UserConstants.USERNAME_MAX_LENGTH) |
| | | { |
| | | remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围"); |
| | | throw new BaseException("用户名不在指定范围"); |
| | | } |
| | | // 查询用户信息 |
| | | R<LoginUser> userResult = remoteUserService.getUserInfo(username); |
| | | if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) |
| | | { |
| | | remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在"); |
| | | throw new BaseException("登录用户:" + username + " 不存在"); |
| | | } |
| | | LoginUser userInfo = userResult.getData(); |
| | | SysUser user = userResult.getData().getSysUser(); |
| | | if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) |
| | | { |
| | | remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除"); |
| | | |
| | | throw new BaseException("对不起,您的账号:" + username + " 已被删除"); |
| | | } |
| | | if (UserStatus.DISABLE.getCode().equals(user.getStatus())) |
| | | { |
| | | remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员"); |
| | | throw new BaseException("对不起,您的账号:" + username + " 已停用"); |
| | | } |
| | | if (!SecurityUtils.matchesPassword(password, user.getPassword())) |
| | | { |
| | | remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户密码错误"); |
| | | throw new BaseException("用户不存在/密码错误"); |
| | | } |
| | | remoteLogService.saveLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功"); |
| | | return userInfo; |
| | | } |
| | | |
| | | public void logout(String loginName) |
| | | { |
| | | remoteLogService.saveLogininfor(loginName, Constants.LOGOUT, "退出成功"); |
| | | } |
| | | } |
| | |
| | | public class CacheConstants
|
| | | {
|
| | | /**
|
| | | * oauth 缓存前缀
|
| | | * 令牌自定义标识
|
| | | */
|
| | | public static final String OAUTH_ACCESS = "oauth:access:";
|
| | | public static final String HEADER = "Authorization";
|
| | |
|
| | | /**
|
| | | * oauth 客户端信息
|
| | | * 令牌前缀
|
| | | */
|
| | | public static final String CLIENT_DETAILS_KEY = "oauth:client:details";
|
| | | public static final String TOKEN_PREFIX = "Bearer ";
|
| | |
|
| | | /**
|
| | | * 权限缓存前缀
|
| | | */
|
| | | public final static String LOGIN_TOKEN_KEY = "login_tokens:";
|
| | |
|
| | | /**
|
| | | * 用户ID字段
|
| | | */
|
| | | public static final String DETAILS_USER_ID = "user_id";
|
| | |
|
| | | /**
|
| | | * 用户名字段
|
| | | */
|
| | | public static final String DETAILS_USERNAME = "username";
|
| | | }
|
| | |
| | | /**
|
| | | * 验证码有效期(分钟)
|
| | | */
|
| | | public static final Integer CAPTCHA_EXPIRATION = 2;
|
| | | public static final long CAPTCHA_EXPIRATION = 2;
|
| | |
|
| | | /**
|
| | | * 令牌有效期(分钟)
|
| | | */
|
| | | public final static long TOKEN_EXPIRE = 30;
|
| | |
|
| | | /**
|
| | | * 参数管理 cache key
|
| | |
| | |
|
| | | /** 校验返回结果码 */
|
| | | public final static String UNIQUE = "0";
|
| | |
|
| | | public final static String NOT_UNIQUE = "1";
|
| | |
|
| | | /**
|
| | | * 用户名长度限制
|
| | | */
|
| | | public static final int USERNAME_MIN_LENGTH = 2;
|
| | |
|
| | | public static final int USERNAME_MAX_LENGTH = 20;
|
| | |
|
| | | /**
|
| | | * 密码长度限制
|
| | | */
|
| | | public static final int PASSWORD_MIN_LENGTH = 5;
|
| | |
|
| | | public static final int PASSWORD_MAX_LENGTH = 20;
|
| | | }
|
| New file |
| | |
| | | package com.ruoyi.common.core.exception; |
| | | |
| | | /** |
| | | * 权限异常 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class PreAuthorizeException extends RuntimeException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public PreAuthorizeException() |
| | | { |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.core.utils.StringUtils;
|
| | | import com.ruoyi.common.core.web.domain.BaseEntity;
|
| | | import com.ruoyi.common.datascope.annotation.DataScope;
|
| | | import com.ruoyi.common.datascope.service.AwaitUserService;
|
| | | import com.ruoyi.common.security.service.TokenService;
|
| | | import com.ruoyi.system.api.domain.SysRole;
|
| | | import com.ruoyi.system.api.domain.SysUser;
|
| | | import com.ruoyi.system.api.model.UserInfo;
|
| | | import com.ruoyi.system.api.model.LoginUser;
|
| | |
|
| | | /**
|
| | | * 数据过滤处理
|
| | |
| | | public static final String DATA_SCOPE = "dataScope";
|
| | |
|
| | | @Autowired
|
| | | private AwaitUserService awaitUserService;
|
| | | private TokenService tokenService;
|
| | |
|
| | | // 配置织入点
|
| | | @Pointcut("@annotation(com.ruoyi.common.datascope.annotation.DataScope)")
|
| | |
| | | return;
|
| | | }
|
| | | // 获取当前的用户
|
| | | UserInfo loginUser = awaitUserService.info();
|
| | | LoginUser loginUser = tokenService.getLoginUser();
|
| | | SysUser currentUser = loginUser.getSysUser();
|
| | | if (currentUser != null)
|
| | | {
|
| | |
| | | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
| | | com.ruoyi.common.datascope.service.AwaitUserService,\
|
| | | com.ruoyi.common.datascope.aspect.DataScopeAspect
|
| | |
|
| | |
|
| | |
| | | package com.ruoyi.common.log.aspect;
|
| | |
|
| | | import java.lang.reflect.Method;
|
| | | import java.util.Map;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.aspectj.lang.JoinPoint;
|
| | |
| | | import org.springframework.http.HttpMethod;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.springframework.web.servlet.HandlerMapping;
|
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.ruoyi.common.core.constant.CacheConstants;
|
| | | import com.ruoyi.common.core.utils.ServletUtils;
|
| | | import com.ruoyi.common.core.utils.StringUtils;
|
| | | import com.ruoyi.common.core.utils.ip.IpUtils;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessStatus;
|
| | | import com.ruoyi.common.log.service.AsyncLogService;
|
| | | import com.ruoyi.common.security.domain.LoginUser;
|
| | | import com.ruoyi.common.security.utils.SecurityUtils;
|
| | | import com.ruoyi.system.api.domain.SysOperLog;
|
| | |
|
| | | /**
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | // 获取当前的用户
|
| | | LoginUser loginUser = SecurityUtils.getLoginUser();
|
| | |
|
| | | // *========数据库日志=========*//
|
| | | SysOperLog operLog = new SysOperLog();
|
| | | operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
|
| | |
| | | operLog.setJsonResult(JSON.toJSONString(jsonResult));
|
| | |
|
| | | operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
|
| | | if (loginUser != null)
|
| | | HttpServletRequest request = ServletUtils.getRequest();
|
| | | String username = request.getHeader(CacheConstants.DETAILS_USERNAME);
|
| | | if (StringUtils.isNotBlank(username))
|
| | | {
|
| | | operLog.setOperName(loginUser.getUsername());
|
| | | operLog.setOperName(username);
|
| | | }
|
| | |
|
| | | if (e != null)
|
| | |
| | | {
|
| | | String params = argsArrayToString(joinPoint.getArgs());
|
| | | operLog.setOperParam(StringUtils.substring(params, 0, 2000));
|
| | | }
|
| | | else
|
| | | {
|
| | | Map<?, ?> paramsMap = (Map<?, ?>) ServletUtils.getRequest().getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
|
| | | operLog.setOperParam(StringUtils.substring(paramsMap.toString(), 0, 2000));
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | * @param timeout 时间
|
| | | * @param timeUnit 时间颗粒度
|
| | | */
|
| | | public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit)
|
| | | public <T> void setCacheObject(final String key, final T value, final Long timeout, final TimeUnit timeUnit)
|
| | | {
|
| | | redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
|
| | | }
|
| | |
| | |
|
| | | <dependencies>
|
| | |
|
| | | <!-- Spring Security Oauth2 -->
|
| | | <dependency>
|
| | | <groupId>org.springframework.cloud</groupId>
|
| | | <artifactId>spring-cloud-starter-oauth2</artifactId>
|
| | | </dependency>
|
| | | |
| | | <!-- RuoYi Api System -->
|
| | | <dependency>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi-api-system</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- RuoYi Common Redis-->
|
| | | <dependency>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi-common-redis</artifactId>
|
| | | </dependency>
|
| | | |
| | | </dependencies>
|
| | |
|
| | | </project>
|
| | |
| | | import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
| | | import org.springframework.context.annotation.Import;
|
| | | import org.springframework.scheduling.annotation.EnableAsync;
|
| | | import com.ruoyi.common.security.feign.OAuth2FeignConfig;
|
| | | import com.ruoyi.common.security.config.ApplicationConfig;
|
| | | import com.ruoyi.common.security.config.SecurityImportBeanDefinitionRegistrar;
|
| | |
|
| | | @Target(ElementType.TYPE)
|
| | | @Retention(RetentionPolicy.RUNTIME)
|
| | |
| | | // 开启线程异步执行
|
| | | @EnableAsync
|
| | | // 自动加载类
|
| | | @Import({ SecurityImportBeanDefinitionRegistrar.class, OAuth2FeignConfig.class, ApplicationConfig.class })
|
| | | @Import({ApplicationConfig.class})
|
| | | public @interface EnableCustomConfig
|
| | | {
|
| | |
|
| New file |
| | |
| | | package com.ruoyi.common.security.annotation; |
| | | |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * 权限注解 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Target({ ElementType.TYPE, ElementType.METHOD }) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface PreAuthorize |
| | | { |
| | | /** |
| | | * 验证用户是否具备某权限 |
| | | */ |
| | | public String hasPermi() default ""; |
| | | |
| | | /** |
| | | * 验证用户是否不具备某权限,与 hasPermi逻辑相反 |
| | | */ |
| | | public String lacksPermi() default ""; |
| | | |
| | | /** |
| | | * 验证用户是否具有以下任意一个权限 |
| | | */ |
| | | public String[] hasAnyPermi() default {}; |
| | | |
| | | /** |
| | | * 判断用户是否拥有某个角色 |
| | | */ |
| | | public String hasRole() default ""; |
| | | |
| | | /** |
| | | * 验证用户是否不具备某角色,与 isRole逻辑相反 |
| | | */ |
| | | public String lacksRole() default ""; |
| | | |
| | | /** |
| | | * 验证用户是否具有以下任意一个角色 |
| | | */ |
| | | public String[] hasAnyRoles() default {}; |
| | | } |
| New file |
| | |
| | | package com.ruoyi.common.security.aspect; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.Collection; |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.Signature; |
| | | import org.aspectj.lang.annotation.Around; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.reflect.MethodSignature; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.PatternMatchUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import com.ruoyi.common.core.exception.PreAuthorizeException; |
| | | import com.ruoyi.common.security.annotation.PreAuthorize; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | |
| | | @Aspect |
| | | @Component |
| | | public class PreAuthorizeAspect |
| | | { |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | /** 所有权限标识 */ |
| | | private static final String ALL_PERMISSION = "*:*:*"; |
| | | |
| | | /** 管理员角色权限标识 */ |
| | | private static final String SUPER_ADMIN = "admin"; |
| | | |
| | | @Around("@annotation(com.ruoyi.common.security.annotation.PreAuthorize)") |
| | | public Object around(ProceedingJoinPoint point) throws Throwable |
| | | { |
| | | Signature signature = point.getSignature(); |
| | | MethodSignature methodSignature = (MethodSignature) signature; |
| | | Method method = methodSignature.getMethod(); |
| | | PreAuthorize annotation = method.getAnnotation(PreAuthorize.class); |
| | | if (annotation == null) |
| | | { |
| | | return point.proceed(); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(annotation.hasPermi()) && hasPermi(annotation.hasPermi())) |
| | | { |
| | | return point.proceed(); |
| | | } |
| | | else if (StringUtils.isEmpty(annotation.lacksPermi()) && hasPermi(annotation.lacksPermi())) |
| | | { |
| | | return point.proceed(); |
| | | } |
| | | else if (StringUtils.isEmpty(annotation.hasAnyPermi()) && hasAnyPermi(annotation.hasAnyPermi())) |
| | | { |
| | | return point.proceed(); |
| | | } |
| | | else if (StringUtils.isEmpty(annotation.hasRole()) && hasRole(annotation.hasRole())) |
| | | { |
| | | return point.proceed(); |
| | | } |
| | | else if (StringUtils.isEmpty(annotation.lacksRole()) && lacksRole(annotation.lacksRole())) |
| | | { |
| | | return point.proceed(); |
| | | } |
| | | else if (StringUtils.isEmpty(annotation.hasAnyRoles()) && hasAnyRoles(annotation.hasAnyRoles())) |
| | | { |
| | | return point.proceed(); |
| | | } |
| | | else |
| | | { |
| | | throw new PreAuthorizeException(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 验证用户是否具备某权限 |
| | | * |
| | | * @param permission 权限字符串 |
| | | * @return 用户是否具备某权限 |
| | | */ |
| | | public boolean hasPermi(String permission) |
| | | { |
| | | LoginUser userInfo = tokenService.getLoginUser(); |
| | | if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getPermissions())) |
| | | { |
| | | return false; |
| | | } |
| | | return hasPermissions(userInfo.getPermissions(), permission); |
| | | } |
| | | |
| | | /** |
| | | * 验证用户是否不具备某权限,与 hasPermi逻辑相反 |
| | | * |
| | | * @param permission 权限字符串 |
| | | * @return 用户是否不具备某权限 |
| | | */ |
| | | public boolean lacksPermi(String permission) |
| | | { |
| | | return hasPermi(permission) != true; |
| | | } |
| | | |
| | | /** |
| | | * 验证用户是否具有以下任意一个权限 |
| | | * |
| | | * @param permissions 权限列表 |
| | | * @return 用户是否具有以下任意一个权限 |
| | | */ |
| | | public boolean hasAnyPermi(String[] permissions) |
| | | { |
| | | LoginUser userInfo = tokenService.getLoginUser(); |
| | | if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getPermissions())) |
| | | { |
| | | return false; |
| | | } |
| | | Collection<String> authorities = userInfo.getPermissions(); |
| | | for (String permission : permissions) |
| | | { |
| | | if (permission != null && hasPermissions(authorities, permission)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 判断用户是否拥有某个角色 |
| | | * |
| | | * @param role 角色字符串 |
| | | * @return 用户是否具备某角色 |
| | | */ |
| | | public boolean hasRole(String role) |
| | | { |
| | | LoginUser userInfo = tokenService.getLoginUser(); |
| | | if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getRoles())) |
| | | { |
| | | return false; |
| | | } |
| | | for (String roleKey : userInfo.getRoles()) |
| | | { |
| | | if (SUPER_ADMIN.contains(roleKey) || roleKey.contains(role)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 验证用户是否不具备某角色,与 isRole逻辑相反。 |
| | | * |
| | | * @param role 角色名称 |
| | | * @return 用户是否不具备某角色 |
| | | */ |
| | | public boolean lacksRole(String role) |
| | | { |
| | | return hasRole(role) != true; |
| | | } |
| | | |
| | | /** |
| | | * 验证用户是否具有以下任意一个角色 |
| | | * |
| | | * @param roles 角色列表 |
| | | * @return 用户是否具有以下任意一个角色 |
| | | */ |
| | | public boolean hasAnyRoles(String[] roles) |
| | | { |
| | | LoginUser userInfo = tokenService.getLoginUser(); |
| | | if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getRoles())) |
| | | { |
| | | return false; |
| | | } |
| | | for (String role : roles) |
| | | { |
| | | if (hasRole(role)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 判断是否包含权限 |
| | | * |
| | | * @param authorities 权限列表 |
| | | * @param permission 权限字符串 |
| | | * @return 用户是否具备某权限 |
| | | */ |
| | | private boolean hasPermissions(Collection<String> authorities, String permission) |
| | | { |
| | | return authorities.stream().filter(StringUtils::hasText) |
| | | .anyMatch(x -> ALL_PERMISSION.contains(x) || PatternMatchUtils.simpleMatch(permission, x)); |
| | | } |
| | | } |
| | |
| | |
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import org.springframework.security.access.AccessDeniedException;
|
| | | import org.springframework.security.authentication.AccountExpiredException;
|
| | | import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
| | | import org.springframework.validation.BindException;
|
| | | import org.springframework.web.bind.MethodArgumentNotValidException;
|
| | | import org.springframework.web.bind.annotation.ExceptionHandler;
|
| | | import org.springframework.web.bind.annotation.RestControllerAdvice;
|
| | | import org.springframework.web.servlet.NoHandlerFoundException;
|
| | | import com.ruoyi.common.core.constant.HttpStatus;
|
| | | import com.ruoyi.common.core.exception.BaseException;
|
| | | import com.ruoyi.common.core.exception.CustomException;
|
| | | import com.ruoyi.common.core.exception.DemoModeException;
|
| | | import com.ruoyi.common.core.exception.PreAuthorizeException;
|
| | | import com.ruoyi.common.core.utils.StringUtils;
|
| | | import com.ruoyi.common.core.web.domain.AjaxResult;
|
| | |
|
| | |
| | | return AjaxResult.error(e.getCode(), e.getMessage());
|
| | | }
|
| | |
|
| | | @ExceptionHandler(NoHandlerFoundException.class)
|
| | | public AjaxResult handlerNoFoundException(Exception e)
|
| | | {
|
| | | log.error(e.getMessage(), e);
|
| | | return AjaxResult.error(HttpStatus.NOT_FOUND, "路径不存在,请检查路径是否正确");
|
| | | }
|
| | |
|
| | | @ExceptionHandler(AccessDeniedException.class)
|
| | | public AjaxResult handleAuthorizationException(AccessDeniedException e)
|
| | | {
|
| | | log.error(e.getMessage());
|
| | | return AjaxResult.error(HttpStatus.FORBIDDEN, "没有权限,请联系管理员授权");
|
| | | }
|
| | |
|
| | | @ExceptionHandler(AccountExpiredException.class)
|
| | | public AjaxResult handleAccountExpiredException(AccountExpiredException e)
|
| | | {
|
| | | log.error(e.getMessage(), e);
|
| | | return AjaxResult.error(e.getMessage());
|
| | | }
|
| | |
|
| | | @ExceptionHandler(UsernameNotFoundException.class)
|
| | | public AjaxResult handleUsernameNotFoundException(UsernameNotFoundException e)
|
| | | {
|
| | | log.error(e.getMessage(), e);
|
| | | return AjaxResult.error(e.getMessage());
|
| | | }
|
| | |
|
| | | @ExceptionHandler(Exception.class)
|
| | | public AjaxResult handleException(Exception e)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 权限异常
|
| | | */
|
| | | @ExceptionHandler(PreAuthorizeException.class)
|
| | | public AjaxResult preAuthorizeException(PreAuthorizeException e)
|
| | | {
|
| | | return AjaxResult.error("没有权限,请联系管理员授权");
|
| | | }
|
| | | |
| | | /**
|
| | | * 演示模式异常
|
| | | */
|
| | | @ExceptionHandler(DemoModeException.class)
|
| New file |
| | |
| | | package com.ruoyi.common.security.service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.concurrent.TimeUnit; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.utils.IdUtils; |
| | | import com.ruoyi.common.core.utils.ServletUtils; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | |
| | | /** |
| | | * token验证处理 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class TokenService |
| | | { |
| | | @Autowired |
| | | private RedisService redisService; |
| | | |
| | | private final static long EXPIRE_TIME = Constants.TOKEN_EXPIRE * 60; |
| | | |
| | | private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY; |
| | | |
| | | protected static final long MILLIS_SECOND = 1000; |
| | | |
| | | /** |
| | | * 创建令牌 |
| | | */ |
| | | public Map<String, Object> createToken(LoginUser loginUser) |
| | | { |
| | | // 生成token |
| | | String token = IdUtils.fastUUID(); |
| | | loginUser.setToken(token); |
| | | loginUser.setUserid(loginUser.getSysUser().getUserId()); |
| | | loginUser.setUsername(loginUser.getSysUser().getUserName()); |
| | | refreshToken(loginUser); |
| | | |
| | | // 保存或更新用户token |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | map.put("access_token", token); |
| | | map.put("expires_in", EXPIRE_TIME); |
| | | redisService.setCacheObject(ACCESS_TOKEN + token, loginUser, EXPIRE_TIME, TimeUnit.SECONDS); |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 获取用户身份信息 |
| | | * |
| | | * @return 用户信息 |
| | | */ |
| | | public LoginUser getLoginUser() |
| | | { |
| | | return getLoginUser(ServletUtils.getRequest()); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户身份信息 |
| | | * |
| | | * @return 用户信息 |
| | | */ |
| | | public LoginUser getLoginUser(HttpServletRequest request) |
| | | { |
| | | // 获取请求携带的令牌 |
| | | String token = getToken(request); |
| | | if (StringUtils.isNotEmpty(token)) |
| | | { |
| | | String userKey = getTokenKey(token); |
| | | LoginUser user = redisService.getCacheObject(userKey); |
| | | return user; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public void delLoginUser(String token) |
| | | { |
| | | if (StringUtils.isNotEmpty(token)) |
| | | { |
| | | String userKey = getTokenKey(token); |
| | | redisService.deleteObject(userKey); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 刷新令牌有效期 |
| | | * |
| | | * @param loginUser 登录信息 |
| | | */ |
| | | public Long refreshToken(LoginUser loginUser) |
| | | { |
| | | loginUser.setLoginTime(System.currentTimeMillis()); |
| | | loginUser.setExpireTime(loginUser.getLoginTime() + EXPIRE_TIME * MILLIS_SECOND); |
| | | // 根据uuid将loginUser缓存 |
| | | String userKey = getTokenKey(loginUser.getToken()); |
| | | redisService.setCacheObject(userKey, loginUser, EXPIRE_TIME, TimeUnit.SECONDS); |
| | | return EXPIRE_TIME; |
| | | } |
| | | |
| | | private String getTokenKey(String token) |
| | | { |
| | | return ACCESS_TOKEN + token; |
| | | } |
| | | |
| | | /** |
| | | * 获取请求token |
| | | */ |
| | | private String getToken(HttpServletRequest request) |
| | | { |
| | | String token = request.getHeader(CacheConstants.HEADER); |
| | | if (StringUtils.isNotEmpty(token) && token.startsWith(CacheConstants.TOKEN_PREFIX)) |
| | | { |
| | | token = token.replace(CacheConstants.TOKEN_PREFIX, ""); |
| | | } |
| | | return token; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.common.security.utils;
|
| | |
|
| | | import org.springframework.security.core.Authentication;
|
| | | import org.springframework.security.core.context.SecurityContextHolder;
|
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
| | | import com.ruoyi.common.security.domain.LoginUser;
|
| | | import com.ruoyi.common.core.constant.CacheConstants;
|
| | | import com.ruoyi.common.core.text.Convert;
|
| | | import com.ruoyi.common.core.utils.ServletUtils;
|
| | |
|
| | | /**
|
| | | * 权限获取工具类
|
| | |
| | | public class SecurityUtils
|
| | | {
|
| | | /**
|
| | | * 获取Authentication
|
| | | */
|
| | | public static Authentication getAuthentication()
|
| | | {
|
| | | return SecurityContextHolder.getContext().getAuthentication();
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取用户
|
| | | */
|
| | | public static String getUsername()
|
| | | {
|
| | | return getLoginUser().getUsername();
|
| | | return ServletUtils.getRequest().getHeader(CacheConstants.DETAILS_USERNAME);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取用户
|
| | | * 获取用户ID
|
| | | */
|
| | | public static LoginUser getLoginUser(Authentication authentication)
|
| | | public static Long getUserId()
|
| | | {
|
| | | Object principal = authentication.getPrincipal();
|
| | | if (principal instanceof LoginUser)
|
| | | {
|
| | | return (LoginUser) principal;
|
| | | }
|
| | | return null;
|
| | | return Convert.toLong(ServletUtils.getRequest().getHeader(CacheConstants.DETAILS_USER_ID));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取用户
|
| | | * 是否为管理员
|
| | | * |
| | | * @param userId 用户ID
|
| | | * @return 结果
|
| | | */
|
| | | public static LoginUser getLoginUser()
|
| | | public static boolean isAdmin(Long userId)
|
| | | {
|
| | | Authentication authentication = getAuthentication();
|
| | | if (authentication == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | return getLoginUser(authentication);
|
| | | return userId != null && 1L == userId;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | {
|
| | | BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
| | | return passwordEncoder.matches(rawPassword, encodedPassword);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 是否为管理员
|
| | | * |
| | | * @param userId 用户ID
|
| | | * @return 结果
|
| | | */
|
| | | public static boolean isAdmin(Long userId)
|
| | | {
|
| | | return userId != null && 1L == userId;
|
| | | }
|
| | | }
|
| | |
| | | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
| | | com.ruoyi.common.security.service.UserDetailsServiceImpl,\
|
| | | com.ruoyi.common.security.service.PermissionService,\
|
| | | com.ruoyi.common.security.config.MethodSecurityConfig,\
|
| | | com.ruoyi.common.security.handler.CustomAccessDeniedHandler,\
|
| | | com.ruoyi.common.security.service.TokenService,\
|
| | | com.ruoyi.common.security.aspect.PreAuthorizeAspect,\
|
| | | com.ruoyi.common.security.handler.GlobalExceptionHandler
|
| | |
|
| | | |
| | |
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.Collections;
|
| | | import java.util.List;
|
| | | import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
| | |
| | | import springfox.documentation.builders.PathSelectors;
|
| | | import springfox.documentation.builders.RequestHandlerSelectors;
|
| | | import springfox.documentation.service.ApiInfo;
|
| | | import springfox.documentation.service.ApiKey;
|
| | | import springfox.documentation.service.AuthorizationScope;
|
| | | import springfox.documentation.service.Contact;
|
| | | import springfox.documentation.service.GrantType;
|
| | | import springfox.documentation.service.OAuth;
|
| | | import springfox.documentation.service.ResourceOwnerPasswordCredentialsGrant;
|
| | | import springfox.documentation.service.SecurityReference;
|
| | | import springfox.documentation.spi.DocumentationType;
|
| | | import springfox.documentation.spi.service.contexts.SecurityContext;
|
| | |
| | | .apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage()))
|
| | | .paths(Predicates.and(Predicates.not(Predicates.or(excludePath)), Predicates.or(basePath)))
|
| | | .build()
|
| | | .securitySchemes(Collections.singletonList(securitySchema()))
|
| | | .securityContexts(Collections.singletonList(securityContext()))
|
| | | .securitySchemes(securitySchemes())
|
| | | .securityContexts(securityContexts())
|
| | | .pathMapping("/");
|
| | | }
|
| | |
|
| | | /**
|
| | | * 配置默认的全局鉴权策略的开关,通过正则表达式进行匹配;默认匹配所有URL
|
| | | *
|
| | | * @return
|
| | | * 安全模式,这里指定token通过Authorization头请求头传递
|
| | | */
|
| | | private SecurityContext securityContext()
|
| | | private List<ApiKey> securitySchemes()
|
| | | {
|
| | | return SecurityContext.builder()
|
| | | List<ApiKey> apiKeyList = new ArrayList<ApiKey>();
|
| | | apiKeyList.add(new ApiKey("Authorization", "Authorization", "header"));
|
| | | return apiKeyList;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 安全上下文
|
| | | */
|
| | | private List<SecurityContext> securityContexts()
|
| | | {
|
| | | List<SecurityContext> securityContexts = new ArrayList<>();
|
| | | securityContexts.add(
|
| | | SecurityContext.builder()
|
| | | .securityReferences(defaultAuth())
|
| | | .forPaths(PathSelectors.regex(swaggerProperties().getAuthorization().getAuthRegex()))
|
| | | .build();
|
| | | .forPaths(PathSelectors.regex("^(?!auth).*$"))
|
| | | .build());
|
| | | return securityContexts;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | private List<SecurityReference> defaultAuth()
|
| | | {
|
| | | ArrayList<AuthorizationScope> authorizationScopeList = new ArrayList<>();
|
| | | swaggerProperties().getAuthorization().getAuthorizationScopeList().forEach(authorizationScope -> authorizationScopeList.add(new AuthorizationScope(authorizationScope.getScope(), authorizationScope.getDescription())));
|
| | | AuthorizationScope[] authorizationScopes = new AuthorizationScope[authorizationScopeList.size()];
|
| | | return Collections.singletonList(SecurityReference.builder()
|
| | | .reference(swaggerProperties().getAuthorization().getName())
|
| | | .scopes(authorizationScopeList.toArray(authorizationScopes))
|
| | | .build());
|
| | | }
|
| | |
|
| | | private OAuth securitySchema()
|
| | | {
|
| | | ArrayList<AuthorizationScope> authorizationScopeList = new ArrayList<>();
|
| | | swaggerProperties().getAuthorization().getAuthorizationScopeList().forEach(authorizationScope -> authorizationScopeList.add(new AuthorizationScope(authorizationScope.getScope(), authorizationScope.getDescription())));
|
| | | ArrayList<GrantType> grantTypes = new ArrayList<>();
|
| | | swaggerProperties().getAuthorization().getTokenUrlList().forEach(tokenUrl -> grantTypes.add(new ResourceOwnerPasswordCredentialsGrant(tokenUrl)));
|
| | | return new OAuth(swaggerProperties().getAuthorization().getName(), authorizationScopeList, grantTypes);
|
| | | AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
|
| | | AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
| | | authorizationScopes[0] = authorizationScope;
|
| | | List<SecurityReference> securityReferences = new ArrayList<>();
|
| | | securityReferences.add(new SecurityReference("Authorization", authorizationScopes));
|
| | | return securityReferences;
|
| | | }
|
| | |
|
| | | private ApiInfo apiInfo(SwaggerProperties swaggerProperties)
|
| | |
| | | .build();
|
| | | }
|
| | | }
|
| | |
|
| New file |
| | |
| | | package com.ruoyi.gateway.filter; |
| | | |
| | | import java.util.Arrays; |
| | | import javax.annotation.Resource; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
| | | import org.springframework.cloud.gateway.filter.GlobalFilter; |
| | | import org.springframework.core.Ordered; |
| | | import org.springframework.core.io.buffer.DataBufferFactory; |
| | | import org.springframework.data.redis.core.ValueOperations; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | import org.springframework.http.server.reactive.ServerHttpResponse; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | /** |
| | | * 网关鉴权 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class AuthFilter implements GlobalFilter, Ordered |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(AuthFilter.class); |
| | | |
| | | // 排除过滤的 uri 地址,swagger排除自行添加 |
| | | private static final String[] whiteList = { "/auth/login", "/code/v2/api-docs", "/schedule/v2/api-docs", |
| | | "/system/v2/api-docs", "/csrf" }; |
| | | |
| | | @Resource(name = "stringRedisTemplate") |
| | | private ValueOperations<String, String> sops; |
| | | |
| | | @Override |
| | | public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) |
| | | { |
| | | String url = exchange.getRequest().getURI().getPath(); |
| | | // 跳过不需要验证的路径 |
| | | if (Arrays.asList(whiteList).contains(url)) |
| | | { |
| | | return chain.filter(exchange); |
| | | } |
| | | String token = getToken(exchange.getRequest()); |
| | | if (StringUtils.isBlank(token)) |
| | | { |
| | | return setUnauthorizedResponse(exchange, "令牌不能为空"); |
| | | } |
| | | String userStr = sops.get(CacheConstants.LOGIN_TOKEN_KEY + token); |
| | | if (StringUtils.isNull(userStr)) |
| | | { |
| | | return setUnauthorizedResponse(exchange, "令牌验证失败"); |
| | | } |
| | | JSONObject obj = JSONObject.parseObject(userStr); |
| | | String userid = obj.getString("userid"); |
| | | String username = obj.getString("username"); |
| | | if (StringUtils.isBlank(userid) || StringUtils.isBlank(username)) |
| | | { |
| | | return setUnauthorizedResponse(exchange, "令牌验证失败"); |
| | | } |
| | | // 设置用户信息到请求 |
| | | ServerHttpRequest mutableReq = exchange.getRequest().mutate().header(CacheConstants.DETAILS_USER_ID, userid) |
| | | .header(CacheConstants.DETAILS_USERNAME, username).build(); |
| | | ServerWebExchange mutableExchange = exchange.mutate().request(mutableReq).build(); |
| | | |
| | | return chain.filter(mutableExchange); |
| | | } |
| | | |
| | | private Mono<Void> setUnauthorizedResponse(ServerWebExchange exchange, String msg) |
| | | { |
| | | ServerHttpResponse response = exchange.getResponse(); |
| | | response.getHeaders().setContentType(MediaType.APPLICATION_JSON); |
| | | response.setStatusCode(HttpStatus.OK); |
| | | |
| | | log.error("[鉴权异常处理]请求路径:{}", exchange.getRequest().getPath()); |
| | | |
| | | return response.writeWith(Mono.fromSupplier(() -> { |
| | | DataBufferFactory bufferFactory = response.bufferFactory(); |
| | | return bufferFactory.wrap(JSON.toJSONBytes(R.fail(msg))); |
| | | })); |
| | | } |
| | | |
| | | /** |
| | | * 获取请求token |
| | | */ |
| | | private String getToken(ServerHttpRequest request) |
| | | { |
| | | String token = request.getHeaders().getFirst(CacheConstants.HEADER); |
| | | if (StringUtils.isNotEmpty(token) && token.startsWith(CacheConstants.TOKEN_PREFIX)) |
| | | { |
| | | token = token.replace(CacheConstants.TOKEN_PREFIX, ""); |
| | | } |
| | | return token; |
| | | } |
| | | |
| | | @Override |
| | | public int getOrder() |
| | | { |
| | | return -200; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.ruoyi.gateway.filter; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import org.springframework.cloud.gateway.filter.GatewayFilter; |
| | | import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
| | | import org.springframework.cloud.gateway.filter.OrderedGatewayFilter; |
| | | import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; |
| | | import org.springframework.core.io.buffer.DataBuffer; |
| | | import org.springframework.core.io.buffer.DataBufferFactory; |
| | | import org.springframework.core.io.buffer.DataBufferUtils; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.server.reactive.ServerHttpRequestDecorator; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import reactor.core.publisher.Flux; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | @Component |
| | | public class CacheRequestFilter extends AbstractGatewayFilterFactory<CacheRequestFilter.Config> |
| | | { |
| | | public CacheRequestFilter() |
| | | { |
| | | super(Config.class); |
| | | } |
| | | |
| | | @Override |
| | | public String name() |
| | | { |
| | | return "CacheRequestFilter"; |
| | | } |
| | | |
| | | @Override |
| | | public GatewayFilter apply(Config config) |
| | | { |
| | | CacheRequestGatewayFilter cacheRequestGatewayFilter = new CacheRequestGatewayFilter(); |
| | | Integer order = config.getOrder(); |
| | | if (order == null) |
| | | { |
| | | return cacheRequestGatewayFilter; |
| | | } |
| | | return new OrderedGatewayFilter(cacheRequestGatewayFilter, order); |
| | | } |
| | | |
| | | public static class CacheRequestGatewayFilter implements GatewayFilter |
| | | { |
| | | @Override |
| | | public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) |
| | | { |
| | | // GET DELETE 不过滤 |
| | | HttpMethod method = exchange.getRequest().getMethod(); |
| | | if (method == null || method.matches("GET") || method.matches("DELETE")) |
| | | { |
| | | return chain.filter(exchange); |
| | | } |
| | | return DataBufferUtils.join(exchange.getRequest().getBody()).map(dataBuffer -> { |
| | | byte[] bytes = new byte[dataBuffer.readableByteCount()]; |
| | | dataBuffer.read(bytes); |
| | | DataBufferUtils.release(dataBuffer); |
| | | return bytes; |
| | | }).defaultIfEmpty(new byte[0]).flatMap(bytes -> { |
| | | DataBufferFactory dataBufferFactory = exchange.getResponse().bufferFactory(); |
| | | ServerHttpRequestDecorator decorator = new ServerHttpRequestDecorator(exchange.getRequest()) |
| | | { |
| | | @Override |
| | | public Flux<DataBuffer> getBody() |
| | | { |
| | | if (bytes.length > 0) |
| | | { |
| | | return Flux.just(dataBufferFactory.wrap(bytes)); |
| | | } |
| | | return Flux.empty(); |
| | | } |
| | | }; |
| | | return chain.filter(exchange.mutate().request(decorator).build()); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<String> shortcutFieldOrder() |
| | | { |
| | | return Collections.singletonList("order"); |
| | | } |
| | | |
| | | static class Config |
| | | { |
| | | private Integer order; |
| | | |
| | | public Integer getOrder() |
| | | { |
| | | return order; |
| | | } |
| | | |
| | | public void setOrder(Integer order) |
| | | { |
| | | this.order = order; |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.gateway.filter;
|
| | |
|
| | | import java.nio.CharBuffer;
|
| | | import java.nio.charset.StandardCharsets;
|
| | | import java.util.concurrent.atomic.AtomicReference;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.cloud.gateway.filter.GatewayFilter;
|
| | | import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
| | | import org.springframework.http.HttpHeaders;
|
| | | import org.springframework.core.io.buffer.DataBuffer;
|
| | | import org.springframework.core.io.buffer.DataBufferUtils;
|
| | | import org.springframework.http.server.reactive.ServerHttpRequest;
|
| | | import org.springframework.http.server.reactive.ServerHttpResponse;
|
| | | import org.springframework.stereotype.Component;
|
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | | import com.ruoyi.common.core.utils.StringUtils;
|
| | | import com.ruoyi.common.core.web.domain.AjaxResult;
|
| | | import com.ruoyi.gateway.service.ValidateCodeService;
|
| | | import reactor.core.publisher.Flux;
|
| | | import reactor.core.publisher.Mono;
|
| | |
|
| | | /**
|
| | |
| | | @Component
|
| | | public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
|
| | | {
|
| | | private final static String AUTH_URL = "/oauth/token";
|
| | | private final static String AUTH_URL = "/auth/login";
|
| | |
|
| | | @Autowired
|
| | | private ValidateCodeService validateCodeService;
|
| | |
|
| | | private static final String BASIC_ = "Basic ";
|
| | |
|
| | | private static final String CODE = "code";
|
| | |
|
| | | private static final String UUID = "uuid";
|
| | | |
| | | private static final String GRANT_TYPE = "grant_type";
|
| | | |
| | | private static final String REFRESH_TOKEN = "refresh_token";
|
| | |
|
| | | @Override
|
| | | public GatewayFilter apply(Object config)
|
| | |
| | | return chain.filter(exchange);
|
| | | }
|
| | |
|
| | | // 刷新token请求,不处理
|
| | | String grantType = request.getQueryParams().getFirst(GRANT_TYPE);
|
| | | if (StringUtils.containsIgnoreCase(request.getURI().getPath(), AUTH_URL) && StringUtils.containsIgnoreCase(grantType, REFRESH_TOKEN))
|
| | | {
|
| | | return chain.filter(exchange);
|
| | | }
|
| | |
|
| | | // 消息头存在内容,且不存在验证码参数,不处理
|
| | | String header = request.getHeaders().getFirst(HttpHeaders.AUTHORIZATION);
|
| | | if (StringUtils.isNotEmpty(header) && StringUtils.startsWith(header, BASIC_)
|
| | | && !request.getQueryParams().containsKey(CODE) && !request.getQueryParams().containsKey(UUID))
|
| | | {
|
| | | return chain.filter(exchange);
|
| | | }
|
| | | try
|
| | | {
|
| | | validateCodeService.checkCapcha(request.getQueryParams().getFirst(CODE),
|
| | | request.getQueryParams().getFirst(UUID));
|
| | | String rspStr = resolveBodyFromRequest(request);
|
| | | JSONObject obj = JSONObject.parseObject(rspStr);
|
| | | validateCodeService.checkCapcha(obj.getString(CODE), obj.getString(UUID));
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | |
| | | return chain.filter(exchange);
|
| | | };
|
| | | }
|
| | |
|
| | | private String resolveBodyFromRequest(ServerHttpRequest serverHttpRequest)
|
| | | {
|
| | | // 获取请求体
|
| | | Flux<DataBuffer> body = serverHttpRequest.getBody();
|
| | | AtomicReference<String> bodyRef = new AtomicReference<>();
|
| | | body.subscribe(buffer -> {
|
| | | CharBuffer charBuffer = StandardCharsets.UTF_8.decode(buffer.asByteBuffer());
|
| | | DataBufferUtils.release(buffer);
|
| | | bodyRef.set(charBuffer.toString());
|
| | | });
|
| | | return bodyRef.get();
|
| | | }
|
| | | }
|
| | |
| | | <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- SpringBoot Web -->
|
| | | <!-- SpringBoot Actuator -->
|
| | | <dependency>
|
| | | <groupId>org.springframework.boot</groupId>
|
| | | <artifactId>spring-boot-starter-web</artifactId>
|
| | | <artifactId>spring-boot-starter-actuator</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- Swagger -->
|
| | |
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.apache.commons.io.IOUtils;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.validation.annotation.Validated;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | |
| | | import com.ruoyi.common.core.web.page.TableDataInfo;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import com.ruoyi.gen.domain.GenTable;
|
| | | import com.ruoyi.gen.domain.GenTableColumn;
|
| | | import com.ruoyi.gen.service.IGenTableColumnService;
|
| | |
| | | /**
|
| | | * 查询代码生成列表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('tool:gen:list')")
|
| | | @PreAuthorize(hasPermi = "tool:gen:list")
|
| | | @GetMapping("/list")
|
| | | public TableDataInfo genList(GenTable genTable)
|
| | | {
|
| | |
| | | /**
|
| | | * 修改代码生成业务
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('tool:gen:query')")
|
| | | @PreAuthorize(hasPermi = "tool:gen:query")
|
| | | @GetMapping(value = "/{talbleId}")
|
| | | public AjaxResult getInfo(@PathVariable Long talbleId)
|
| | | {
|
| | |
| | | /**
|
| | | * 查询数据库列表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('tool:gen:list')")
|
| | | @PreAuthorize(hasPermi = "tool:gen:list")
|
| | | @GetMapping("/db/list")
|
| | | public TableDataInfo dataList(GenTable genTable)
|
| | | {
|
| | |
| | | /**
|
| | | * 查询数据表字段列表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('tool:gen:list')")
|
| | | @GetMapping(value = "/column/{talbleId}")
|
| | | public TableDataInfo columnList(Long tableId)
|
| | | {
|
| | |
| | | /**
|
| | | * 导入表结构(保存)
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('tool:gen:list')")
|
| | | @PreAuthorize(hasPermi = "tool:gen:list")
|
| | | @Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
| | | @PostMapping("/importTable")
|
| | | public AjaxResult importTableSave(String tables)
|
| | |
| | | /**
|
| | | * 修改保存代码生成业务
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('tool:gen:edit')")
|
| | | @PreAuthorize(hasPermi = "tool:gen:edit")
|
| | | @Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
| | | @PutMapping
|
| | | public AjaxResult editSave(@Validated @RequestBody GenTable genTable)
|
| | |
| | | /**
|
| | | * 删除代码生成
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('tool:gen:remove')")
|
| | | @PreAuthorize(hasPermi = "tool:gen:remove")
|
| | | @Log(title = "代码生成", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{tableIds}")
|
| | | public AjaxResult remove(@PathVariable Long[] tableIds)
|
| | |
| | | /**
|
| | | * 预览代码
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('tool:gen:preview')")
|
| | | @PreAuthorize(hasPermi = "tool:gen:preview")
|
| | | @GetMapping("/preview/{tableId}")
|
| | | public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException
|
| | | {
|
| | |
| | | /**
|
| | | * 生成代码(下载方式)
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('tool:gen:code')")
|
| | | @PreAuthorize(hasPermi = "tool:gen:code")
|
| | | @Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
| | | @GetMapping("/download/{tableName}")
|
| | | public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException
|
| | |
| | | /**
|
| | | * 生成代码(自定义路径)
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('tool:gen:code')")
|
| | | @PreAuthorize(hasPermi = "tool:gen:code")
|
| | | @Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
| | | @GetMapping("/genCode/{tableName}")
|
| | | public AjaxResult genCode(HttpServletResponse response, @PathVariable("tableName") String tableName)
|
| | |
| | | /**
|
| | | * 批量生成代码
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('tool:gen:code')")
|
| | | @PreAuthorize(hasPermi = "tool:gen:code")
|
| | | @Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
| | | @GetMapping("/batchGenCode")
|
| | | public void batchGenCode(HttpServletResponse response, String tables) throws IOException
|
| | |
| | | import java.util.List;
|
| | | import java.io.IOException;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.PostMapping;
|
| | |
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import ${packageName}.domain.${ClassName};
|
| | | import ${packageName}.service.I${ClassName}Service;
|
| | | import com.ruoyi.common.core.web.controller.BaseController;
|
| | |
| | | /**
|
| | | * 查询${functionName}列表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
|
| | | @PreAuthorize(hasPermi = "${permissionPrefix}:list")
|
| | | @GetMapping("/list")
|
| | | #if($table.crud)
|
| | | public TableDataInfo list(${ClassName} ${className})
|
| | |
| | | /**
|
| | | * 导出${functionName}列表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
|
| | | @PreAuthorize(hasPermi = "${permissionPrefix}:export")
|
| | | @Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, ${ClassName} ${className}) throws IOException
|
| | |
| | | /**
|
| | | * 获取${functionName}详细信息
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
|
| | | @PreAuthorize(hasPermi = "${permissionPrefix}:query")
|
| | | @GetMapping(value = "/{${pkColumn.javaField}}")
|
| | | public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
|
| | | {
|
| | |
| | | /**
|
| | | * 新增${functionName}
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
|
| | | @PreAuthorize(hasPermi = "${permissionPrefix}:add")
|
| | | @Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
| | | @PostMapping
|
| | | public AjaxResult add(@RequestBody ${ClassName} ${className})
|
| | |
| | | /**
|
| | | * 修改${functionName}
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
|
| | | @PreAuthorize(hasPermi = "${permissionPrefix}:edit")
|
| | | @Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
| | | @PutMapping
|
| | | public AjaxResult edit(@RequestBody ${ClassName} ${className})
|
| | |
| | | /**
|
| | | * 删除${functionName}
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
|
| | | @PreAuthorize(hasPermi = "${permissionPrefix}:remove")
|
| | | @Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{${pkColumn.javaField}s}")
|
| | | public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
| | |
| | | <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- SpringBoot Web -->
|
| | | <!-- SpringBoot Actuator -->
|
| | | <dependency>
|
| | | <groupId>org.springframework.boot</groupId>
|
| | | <artifactId>spring-boot-starter-web</artifactId>
|
| | | <artifactId>spring-boot-starter-actuator</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- Swagger -->
|
| | |
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.quartz.SchedulerException;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.PathVariable;
|
| | |
| | | import com.ruoyi.common.core.web.page.TableDataInfo;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import com.ruoyi.common.security.utils.SecurityUtils;
|
| | | import com.ruoyi.job.domain.SysJob;
|
| | | import com.ruoyi.job.service.ISysJobService;
|
| | |
| | | /**
|
| | | * 查询定时任务列表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:list')")
|
| | | @PreAuthorize(hasPermi = "monitor:job:list")
|
| | | @GetMapping("/list")
|
| | | public TableDataInfo list(SysJob sysJob)
|
| | | {
|
| | |
| | | /**
|
| | | * 导出定时任务列表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:export')")
|
| | | @PreAuthorize(hasPermi = "monitor:job:export")
|
| | | @Log(title = "定时任务", businessType = BusinessType.EXPORT)
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysJob sysJob) throws IOException
|
| | |
| | | /**
|
| | | * 获取定时任务详细信息
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:query')")
|
| | | @PreAuthorize(hasPermi = "monitor:job:query")
|
| | | @GetMapping(value = "/{jobId}")
|
| | | public AjaxResult getInfo(@PathVariable("jobId") Long jobId)
|
| | | {
|
| | |
| | | /**
|
| | | * 新增定时任务
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:add')")
|
| | | @PreAuthorize(hasPermi = "monitor:job:add")
|
| | | @Log(title = "定时任务", businessType = BusinessType.INSERT)
|
| | | @PostMapping
|
| | | public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException
|
| | |
| | | /**
|
| | | * 修改定时任务
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:edit')")
|
| | | @PreAuthorize(hasPermi = "monitor:job:edit")
|
| | | @Log(title = "定时任务", businessType = BusinessType.UPDATE)
|
| | | @PutMapping
|
| | | public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException
|
| | |
| | | /**
|
| | | * 定时任务状态修改
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
|
| | | @PreAuthorize(hasPermi = "monitor:job:changeStatus")
|
| | | @Log(title = "定时任务", businessType = BusinessType.UPDATE)
|
| | | @PutMapping("/changeStatus")
|
| | | public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException
|
| | |
| | | /**
|
| | | * 定时任务立即执行一次
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
|
| | | @PreAuthorize(hasPermi = "monitor:job:changeStatus")
|
| | | @Log(title = "定时任务", businessType = BusinessType.UPDATE)
|
| | | @PutMapping("/run")
|
| | | public AjaxResult run(@RequestBody SysJob job) throws SchedulerException
|
| | |
| | | /**
|
| | | * 删除定时任务
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:remove')")
|
| | | @PreAuthorize(hasPermi = "monitor:job:remove")
|
| | | @Log(title = "定时任务", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{jobIds}")
|
| | | public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException
|
| | |
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.PathVariable;
|
| | |
| | | import com.ruoyi.common.core.web.page.TableDataInfo;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import com.ruoyi.job.domain.SysJobLog;
|
| | | import com.ruoyi.job.service.ISysJobLogService;
|
| | |
|
| | |
| | | /**
|
| | | * 查询定时任务调度日志列表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:list')")
|
| | | @PreAuthorize(hasPermi = "monitor:job:list")
|
| | | @GetMapping("/list")
|
| | | public TableDataInfo list(SysJobLog sysJobLog)
|
| | | {
|
| | |
| | | /**
|
| | | * 导出定时任务调度日志列表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:export')")
|
| | | @PreAuthorize(hasPermi = "monitor:job:export")
|
| | | @Log(title = "任务调度日志", businessType = BusinessType.EXPORT)
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysJobLog sysJobLog) throws IOException
|
| | |
| | | /**
|
| | | * 根据调度编号获取详细信息
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:query')")
|
| | | @PreAuthorize(hasPermi = "monitor:job:query")
|
| | | @GetMapping(value = "/{configId}")
|
| | | public AjaxResult getInfo(@PathVariable Long jobLogId)
|
| | | {
|
| | |
| | | /**
|
| | | * 删除定时任务调度日志
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:remove')")
|
| | | @PreAuthorize(hasPermi = "monitor:job:remove")
|
| | | @Log(title = "定时任务调度日志", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{jobLogIds}")
|
| | | public AjaxResult remove(@PathVariable Long[] jobLogIds)
|
| | |
| | | /**
|
| | | * 清空定时任务调度日志
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:remove')")
|
| | | @PreAuthorize(hasPermi = "monitor:job:remove")
|
| | | @Log(title = "调度日志", businessType = BusinessType.CLEAN)
|
| | | @DeleteMapping("/clean")
|
| | | public AjaxResult clean()
|
| | |
| | | <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- SpringBoot Web -->
|
| | | <!-- SpringBoot Actuator -->
|
| | | <dependency>
|
| | | <groupId>org.springframework.boot</groupId>
|
| | | <artifactId>spring-boot-starter-web</artifactId>
|
| | | <artifactId>spring-boot-starter-actuator</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- Swagger -->
|
| | |
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.validation.annotation.Validated;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | |
| | | import com.ruoyi.common.core.web.page.TableDataInfo;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import com.ruoyi.common.security.utils.SecurityUtils;
|
| | | import com.ruoyi.system.domain.SysConfig;
|
| | | import com.ruoyi.system.service.ISysConfigService;
|
| | |
| | | /**
|
| | | * 获取参数配置列表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:config:list')")
|
| | | @PreAuthorize(hasPermi = "system:config:list")
|
| | | @GetMapping("/list")
|
| | | public TableDataInfo list(SysConfig config)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | @Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
| | | @PreAuthorize("@ss.hasPermi('system:config:export')")
|
| | | @PreAuthorize(hasPermi = "system:config:export")
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysConfig config) throws IOException
|
| | | {
|
| | |
| | | /**
|
| | | * 新增参数配置
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:config:add')")
|
| | | @PreAuthorize(hasPermi = "system:config:add")
|
| | | @Log(title = "参数管理", businessType = BusinessType.INSERT)
|
| | | @PostMapping
|
| | | public AjaxResult add(@Validated @RequestBody SysConfig config)
|
| | |
| | | /**
|
| | | * 修改参数配置
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:config:edit')")
|
| | | @PreAuthorize(hasPermi = "system:config:edit")
|
| | | @Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
| | | @PutMapping
|
| | | public AjaxResult edit(@Validated @RequestBody SysConfig config)
|
| | |
| | | /**
|
| | | * 删除参数配置
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:config:remove')")
|
| | | @PreAuthorize(hasPermi = "system:config:remove")
|
| | | @Log(title = "参数管理", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{configIds}")
|
| | | public AjaxResult remove(@PathVariable Long[] configIds)
|
| | |
| | | /**
|
| | | * 清空缓存
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:config:remove')")
|
| | | @PreAuthorize(hasPermi = "system:config:remove")
|
| | | @Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
| | | @DeleteMapping("/clearCache")
|
| | | public AjaxResult clearCache()
|
| | |
| | |
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | |
|
| | | import org.apache.commons.lang3.ArrayUtils;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.validation.annotation.Validated;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | |
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | |
|
| | | import com.ruoyi.common.core.constant.UserConstants;
|
| | | import com.ruoyi.common.core.utils.StringUtils;
|
| | | 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.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import com.ruoyi.common.security.utils.SecurityUtils;
|
| | | import com.ruoyi.system.api.domain.SysDept;
|
| | | import com.ruoyi.system.service.ISysDeptService;
|
| | |
| | | /**
|
| | | * 获取部门列表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dept:list')")
|
| | | @PreAuthorize(hasPermi = "system:dept:list")
|
| | | @GetMapping("/list")
|
| | | public AjaxResult list(SysDept dept)
|
| | | {
|
| | |
| | | /**
|
| | | * 查询部门列表(排除节点)
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dept:list')")
|
| | | @PreAuthorize(hasPermi = "system:dept:list")
|
| | | @GetMapping("/list/exclude/{deptId}")
|
| | | public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
|
| | | {
|
| | |
| | | /**
|
| | | * 根据部门编号获取详细信息
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dept:query')")
|
| | | @PreAuthorize(hasPermi = "system:dept:query")
|
| | | @GetMapping(value = "/{deptId}")
|
| | | public AjaxResult getInfo(@PathVariable Long deptId)
|
| | | {
|
| | |
| | | /**
|
| | | * 新增部门
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dept:add')")
|
| | | @PreAuthorize(hasPermi = "system:dept:add")
|
| | | @Log(title = "部门管理", businessType = BusinessType.INSERT)
|
| | | @PostMapping
|
| | | public AjaxResult add(@Validated @RequestBody SysDept dept)
|
| | |
| | | /**
|
| | | * 修改部门
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dept:edit')")
|
| | | @PreAuthorize(hasPermi = "system:dept:edit")
|
| | | @Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
| | | @PutMapping
|
| | | public AjaxResult edit(@Validated @RequestBody SysDept dept)
|
| | |
| | | /**
|
| | | * 删除部门
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dept:remove')")
|
| | | @PreAuthorize(hasPermi = "system:dept:remove")
|
| | | @Log(title = "部门管理", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{deptId}")
|
| | | public AjaxResult remove(@PathVariable Long deptId)
|
| | |
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.validation.annotation.Validated;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | |
| | | import com.ruoyi.common.core.web.page.TableDataInfo;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import com.ruoyi.common.security.utils.SecurityUtils;
|
| | | import com.ruoyi.system.domain.SysDictData;
|
| | | import com.ruoyi.system.service.ISysDictDataService;
|
| | |
| | | @Autowired
|
| | | private ISysDictTypeService dictTypeService;
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('system:dict:list')")
|
| | | @PreAuthorize(hasPermi = "system:dict:list")
|
| | | @GetMapping("/list")
|
| | | public TableDataInfo list(SysDictData dictData)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | @Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
| | | @PreAuthorize("@ss.hasPermi('system:dict:export')")
|
| | | @PreAuthorize(hasPermi = "system:dict:export")
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysDictData dictData) throws IOException
|
| | | {
|
| | |
| | | /**
|
| | | * 查询字典数据详细
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dict:query')")
|
| | | @PreAuthorize(hasPermi = "system:dict:query")
|
| | | @GetMapping(value = "/{dictCode}")
|
| | | public AjaxResult getInfo(@PathVariable Long dictCode)
|
| | | {
|
| | |
| | | /**
|
| | | * 新增字典类型
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dict:add')")
|
| | | @PreAuthorize(hasPermi = "system:dict:add")
|
| | | @Log(title = "字典数据", businessType = BusinessType.INSERT)
|
| | | @PostMapping
|
| | | public AjaxResult add(@Validated @RequestBody SysDictData dict)
|
| | |
| | | /**
|
| | | * 修改保存字典类型
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
| | | @PreAuthorize(hasPermi = "system:dict:edit")
|
| | | @Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
| | | @PutMapping
|
| | | public AjaxResult edit(@Validated @RequestBody SysDictData dict)
|
| | |
| | | /**
|
| | | * 删除字典类型
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
| | | @PreAuthorize(hasPermi = "system:dict:remove")
|
| | | @Log(title = "字典类型", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{dictCodes}")
|
| | | public AjaxResult remove(@PathVariable Long[] dictCodes)
|
| | |
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.validation.annotation.Validated;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | |
| | | import com.ruoyi.common.core.web.page.TableDataInfo;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import com.ruoyi.common.security.utils.SecurityUtils;
|
| | | import com.ruoyi.system.domain.SysDictType;
|
| | | import com.ruoyi.system.service.ISysDictTypeService;
|
| | |
| | | @Autowired
|
| | | private ISysDictTypeService dictTypeService;
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('system:dict:list')")
|
| | | @PreAuthorize(hasPermi = "system:dict:list")
|
| | | @GetMapping("/list")
|
| | | public TableDataInfo list(SysDictType dictType)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | @Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
| | | @PreAuthorize("@ss.hasPermi('system:dict:export')")
|
| | | @PreAuthorize(hasPermi = "system:dict:export")
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysDictType dictType) throws IOException
|
| | | {
|
| | |
| | | /**
|
| | | * 查询字典类型详细
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dict:query')")
|
| | | @PreAuthorize(hasPermi = "system:dict:query")
|
| | | @GetMapping(value = "/{dictId}")
|
| | | public AjaxResult getInfo(@PathVariable Long dictId)
|
| | | {
|
| | |
| | | /**
|
| | | * 新增字典类型
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dict:add')")
|
| | | @PreAuthorize(hasPermi = "system:dict:add")
|
| | | @Log(title = "字典类型", businessType = BusinessType.INSERT)
|
| | | @PostMapping
|
| | | public AjaxResult add(@Validated @RequestBody SysDictType dict)
|
| | |
| | | /**
|
| | | * 修改字典类型
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
| | | @PreAuthorize(hasPermi = "system:dict:edit")
|
| | | @Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
| | | @PutMapping
|
| | | public AjaxResult edit(@Validated @RequestBody SysDictType dict)
|
| | |
| | | /**
|
| | | * 删除字典类型
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
| | | @PreAuthorize(hasPermi = "system:dict:remove")
|
| | | @Log(title = "字典类型", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{dictIds}")
|
| | | public AjaxResult remove(@PathVariable Long[] dictIds)
|
| | |
| | | /**
|
| | | * 清空缓存
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
| | | @PreAuthorize(hasPermi = "system:dict:remove")
|
| | | @Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
| | | @DeleteMapping("/clearCache")
|
| | | public AjaxResult clearCache()
|
| | |
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.PathVariable;
|
| | |
| | | import com.ruoyi.common.core.web.page.TableDataInfo;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import com.ruoyi.system.domain.SysLogininfor;
|
| | | import com.ruoyi.system.service.ISysLogininforService;
|
| | |
|
| | |
| | | @Autowired
|
| | | private ISysLogininforService logininforService;
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('system:logininfor:list')")
|
| | | @PreAuthorize(hasPermi = "system:logininfor:list")
|
| | | @GetMapping("/list")
|
| | | public TableDataInfo list(SysLogininfor logininfor)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | @Log(title = "登陆日志", businessType = BusinessType.EXPORT)
|
| | | @PreAuthorize("@ss.hasPermi('system:logininfor:export')")
|
| | | @PreAuthorize(hasPermi = "system:logininfor:export")
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysLogininfor logininfor) throws IOException
|
| | | {
|
| | |
| | | util.exportExcel(response, list, "登陆日志");
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('system:logininfor:remove')")
|
| | | @PreAuthorize(hasPermi = "system:logininfor:remove")
|
| | | @Log(title = "登陆日志", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{infoIds}")
|
| | | public AjaxResult remove(@PathVariable Long[] infoIds)
|
| | |
| | | return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('system:logininfor:remove')")
|
| | | @PreAuthorize(hasPermi = "system:logininfor:remove")
|
| | | @Log(title = "登陆日志", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/clean")
|
| | | public AjaxResult clean()
|
| | |
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.validation.annotation.Validated;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | |
| | | import com.ruoyi.common.core.web.domain.AjaxResult;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.domain.LoginUser;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import com.ruoyi.common.security.utils.SecurityUtils;
|
| | | import com.ruoyi.system.domain.SysMenu;
|
| | | import com.ruoyi.system.service.ISysMenuService;
|
| | |
| | | /**
|
| | | * 获取菜单列表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:menu:list')")
|
| | | @PreAuthorize(hasPermi = "system:menu:list")
|
| | | @GetMapping("/list")
|
| | | public AjaxResult list(SysMenu menu)
|
| | | {
|
| | | LoginUser loginUser = SecurityUtils.getLoginUser();
|
| | | Long userId = loginUser.getUserId();
|
| | | Long userId = SecurityUtils.getUserId();
|
| | | List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
| | | return AjaxResult.success(menus);
|
| | | }
|
| | |
| | | /**
|
| | | * 根据菜单编号获取详细信息
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:menu:query')")
|
| | | @PreAuthorize(hasPermi = "system:menu:query")
|
| | | @GetMapping(value = "/{menuId}")
|
| | | public AjaxResult getInfo(@PathVariable Long menuId)
|
| | | {
|
| | |
| | | @GetMapping("/treeselect")
|
| | | public AjaxResult treeselect(SysMenu menu)
|
| | | {
|
| | | LoginUser loginUser = SecurityUtils.getLoginUser();
|
| | | Long userId = loginUser.getUserId();
|
| | | Long userId = SecurityUtils.getUserId();
|
| | | List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
| | | return AjaxResult.success(menuService.buildMenuTreeSelect(menus));
|
| | | }
|
| | |
| | | @GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
| | | public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
|
| | | {
|
| | | LoginUser loginUser = SecurityUtils.getLoginUser();
|
| | | Long userId = loginUser.getUserId();
|
| | | Long userId = SecurityUtils.getUserId();
|
| | | List<SysMenu> menus = menuService.selectMenuList(userId);
|
| | | AjaxResult ajax = AjaxResult.success();
|
| | | ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
| | |
| | | /**
|
| | | * 新增菜单
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:menu:add')")
|
| | | @PreAuthorize(hasPermi = "system:menu:add")
|
| | | @Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
| | | @PostMapping
|
| | | public AjaxResult add(@Validated @RequestBody SysMenu menu)
|
| | |
| | | /**
|
| | | * 修改菜单
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:menu:edit')")
|
| | | @PreAuthorize(hasPermi = "system:menu:edit")
|
| | | @Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
| | | @PutMapping
|
| | | public AjaxResult edit(@Validated @RequestBody SysMenu menu)
|
| | |
| | | /**
|
| | | * 删除菜单
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:menu:remove')")
|
| | | @PreAuthorize(hasPermi = "system:menu:remove")
|
| | | @Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{menuId}")
|
| | | public AjaxResult remove(@PathVariable("menuId") Long menuId)
|
| | |
| | | @GetMapping("getRouters")
|
| | | public AjaxResult getRouters()
|
| | | {
|
| | | Long userId = SecurityUtils.getLoginUser().getUserId();
|
| | | Long userId = SecurityUtils.getUserId();
|
| | | List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
| | | return AjaxResult.success(menuService.buildMenus(menus));
|
| | | }
|
| | |
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.validation.annotation.Validated;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | |
| | | import com.ruoyi.common.core.web.page.TableDataInfo;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import com.ruoyi.common.security.utils.SecurityUtils;
|
| | | import com.ruoyi.system.domain.SysNotice;
|
| | | import com.ruoyi.system.service.ISysNoticeService;
|
| | |
| | | /**
|
| | | * 获取通知公告列表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:notice:list')")
|
| | | @PreAuthorize(hasPermi = "system:notice:list")
|
| | | @GetMapping("/list")
|
| | | public TableDataInfo list(SysNotice notice)
|
| | | {
|
| | |
| | | /**
|
| | | * 根据通知公告编号获取详细信息
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:notice:query')")
|
| | | @PreAuthorize(hasPermi = "system:notice:query")
|
| | | @GetMapping(value = "/{noticeId}")
|
| | | public AjaxResult getInfo(@PathVariable Long noticeId)
|
| | | {
|
| | |
| | | /**
|
| | | * 新增通知公告
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:notice:add')")
|
| | | @PreAuthorize(hasPermi = "system:notice:add")
|
| | | @Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
| | | @PostMapping
|
| | | public AjaxResult add(@Validated @RequestBody SysNotice notice)
|
| | |
| | | /**
|
| | | * 修改通知公告
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:notice:edit')")
|
| | | @PreAuthorize(hasPermi = "system:notice:edit")
|
| | | @Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
| | | @PutMapping
|
| | | public AjaxResult edit(@Validated @RequestBody SysNotice notice)
|
| | |
| | | /**
|
| | | * 删除通知公告
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:notice:remove')")
|
| | | @PreAuthorize(hasPermi = "system:notice:remove")
|
| | | @Log(title = "通知公告", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{noticeIds}")
|
| | | public AjaxResult remove(@PathVariable Long[] noticeIds)
|
| | |
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.PathVariable;
|
| | |
| | | import com.ruoyi.common.core.web.page.TableDataInfo;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import com.ruoyi.system.api.domain.SysOperLog;
|
| | | import com.ruoyi.system.service.ISysOperLogService;
|
| | |
|
| | |
| | | @Autowired
|
| | | private ISysOperLogService operLogService;
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('system:operlog:list')")
|
| | | @PreAuthorize(hasPermi = "system:operlog:list")
|
| | | @GetMapping("/list")
|
| | | public TableDataInfo list(SysOperLog operLog)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | @Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
| | | @PreAuthorize("@ss.hasPermi('system:operlog:export')")
|
| | | @PreAuthorize(hasPermi = "system:operlog:export")
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysOperLog operLog) throws IOException
|
| | | {
|
| | |
| | | util.exportExcel(response, list, "操作日志");
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('system:operlog:remove')")
|
| | | @PreAuthorize(hasPermi = "system:operlog:remove")
|
| | | @DeleteMapping("/{operIds}")
|
| | | public AjaxResult remove(@PathVariable Long[] operIds)
|
| | | {
|
| | | return toAjax(operLogService.deleteOperLogByIds(operIds));
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('system:operlog:remove')")
|
| | | @PreAuthorize(hasPermi = "system:operlog:remove")
|
| | | @Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
| | | @DeleteMapping("/clean")
|
| | | public AjaxResult clean()
|
| | |
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.validation.annotation.Validated;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | |
| | | import com.ruoyi.common.core.web.page.TableDataInfo;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import com.ruoyi.common.security.utils.SecurityUtils;
|
| | | import com.ruoyi.system.domain.SysPost;
|
| | | import com.ruoyi.system.service.ISysPostService;
|
| | |
| | | /**
|
| | | * 获取岗位列表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:post:list')")
|
| | | @PreAuthorize(hasPermi = "system:post:list")
|
| | | @GetMapping("/list")
|
| | | public TableDataInfo list(SysPost post)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | @Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
| | | @PreAuthorize("@ss.hasPermi('system:post:export')")
|
| | | @PreAuthorize(hasPermi = "system:post:export")
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysPost post) throws IOException
|
| | | {
|
| | |
| | | /**
|
| | | * 根据岗位编号获取详细信息
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:post:query')")
|
| | | @PreAuthorize(hasPermi = "system:post:query")
|
| | | @GetMapping(value = "/{postId}")
|
| | | public AjaxResult getInfo(@PathVariable Long postId)
|
| | | {
|
| | |
| | | /**
|
| | | * 新增岗位
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:post:add')")
|
| | | @PreAuthorize(hasPermi = "system:post:add")
|
| | | @Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
| | | @PostMapping
|
| | | public AjaxResult add(@Validated @RequestBody SysPost post)
|
| | |
| | | /**
|
| | | * 修改岗位
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:post:edit')")
|
| | | @PreAuthorize(hasPermi = "system:post:edit")
|
| | | @Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
| | | @PutMapping
|
| | | public AjaxResult edit(@Validated @RequestBody SysPost post)
|
| | |
| | | /**
|
| | | * 删除岗位
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:post:remove')")
|
| | | @PreAuthorize(hasPermi = "system:post:remove")
|
| | | @Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{postIds}")
|
| | | public AjaxResult remove(@PathVariable Long[] postIds)
|
| | |
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.validation.annotation.Validated;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | |
| | | import com.ruoyi.common.core.web.page.TableDataInfo;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import com.ruoyi.common.security.utils.SecurityUtils;
|
| | | import com.ruoyi.system.api.domain.SysRole;
|
| | | import com.ruoyi.system.service.ISysRoleService;
|
| | |
| | | @Autowired
|
| | | private ISysRoleService roleService;
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('system:role:list')")
|
| | | @PreAuthorize(hasPermi = "system:role:list")
|
| | | @GetMapping("/list")
|
| | | public TableDataInfo list(SysRole role)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | @Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
| | | @PreAuthorize("@ss.hasPermi('system:role:export')")
|
| | | @PreAuthorize(hasPermi = "system:role:export")
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysRole role) throws IOException
|
| | | {
|
| | |
| | | /**
|
| | | * 根据角色编号获取详细信息
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:role:query')")
|
| | | @PreAuthorize(hasPermi = "system:role:query")
|
| | | @GetMapping(value = "/{roleId}")
|
| | | public AjaxResult getInfo(@PathVariable Long roleId)
|
| | | {
|
| | |
| | | /**
|
| | | * 新增角色
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:role:add')")
|
| | | @PreAuthorize(hasPermi = "system:role:add")
|
| | | @Log(title = "角色管理", businessType = BusinessType.INSERT)
|
| | | @PostMapping
|
| | | public AjaxResult add(@Validated @RequestBody SysRole role)
|
| | |
| | | /**
|
| | | * 修改保存角色
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')")
|
| | | @PreAuthorize(hasPermi = "system:role:edit")
|
| | | @Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
| | | @PutMapping
|
| | | public AjaxResult edit(@Validated @RequestBody SysRole role)
|
| | |
| | | /**
|
| | | * 修改保存数据权限
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')")
|
| | | @PreAuthorize(hasPermi = "system:role:edit")
|
| | | @Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
| | | @PutMapping("/dataScope")
|
| | | public AjaxResult dataScope(@RequestBody SysRole role)
|
| | |
| | | /**
|
| | | * 状态修改
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')")
|
| | | @PreAuthorize(hasPermi = "system:role:edit")
|
| | | @Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
| | | @PutMapping("/changeStatus")
|
| | | public AjaxResult changeStatus(@RequestBody SysRole role)
|
| | |
| | | /**
|
| | | * 删除角色
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:role:remove')")
|
| | | @PreAuthorize(hasPermi = "system:role:remove")
|
| | | @Log(title = "角色管理", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{roleIds}")
|
| | | public AjaxResult remove(@PathVariable Long[] roleIds)
|
| | |
| | | /**
|
| | | * 获取角色选择框列表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:role:query')")
|
| | | @PreAuthorize(hasPermi = "system:role:query")
|
| | | @GetMapping("/optionselect")
|
| | | public AjaxResult optionselect()
|
| | | {
|
| | |
| | | import java.util.stream.Collectors;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.validation.annotation.Validated;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | |
| | | import com.ruoyi.common.core.web.page.TableDataInfo;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import com.ruoyi.common.security.utils.SecurityUtils;
|
| | | import com.ruoyi.system.api.domain.SysRole;
|
| | | import com.ruoyi.system.api.domain.SysUser;
|
| | | import com.ruoyi.system.api.model.UserInfo;
|
| | | import com.ruoyi.system.api.model.LoginUser;
|
| | | import com.ruoyi.system.service.ISysPermissionService;
|
| | | import com.ruoyi.system.service.ISysPostService;
|
| | | import com.ruoyi.system.service.ISysRoleService;
|
| | |
| | | /**
|
| | | * 获取用户列表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:user:list')")
|
| | | @PreAuthorize(hasPermi = "system:user:list")
|
| | | @GetMapping("/list")
|
| | | public TableDataInfo list(SysUser user)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | @Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
| | | @PreAuthorize("@ss.hasPermi('system:user:export')")
|
| | | @PreAuthorize(hasPermi = "system:user:export")
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysUser user) throws IOException
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | @Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
| | | @PreAuthorize("@ss.hasPermi('system:user:import')")
|
| | | @PreAuthorize(hasPermi = "system:user:import")
|
| | | @PostMapping("/importData")
|
| | | public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
| | | {
|
| | |
| | | * 获取当前用户信息
|
| | | */
|
| | | @GetMapping("/info/{username}")
|
| | | public R<UserInfo> info(@PathVariable("username") String username)
|
| | | public R<LoginUser> info(@PathVariable("username") String username)
|
| | | {
|
| | | SysUser sysUser = userService.selectUserByUserName(username);
|
| | | if (StringUtils.isNull(sysUser))
|
| | |
| | | Set<String> roles = permissionService.getRolePermission(sysUser.getUserId());
|
| | | // 权限集合
|
| | | Set<String> permissions = permissionService.getMenuPermission(sysUser.getUserId());
|
| | | UserInfo sysUserVo = new UserInfo();
|
| | | LoginUser sysUserVo = new LoginUser();
|
| | | sysUserVo.setSysUser(sysUser);
|
| | | sysUserVo.setRoles(roles);
|
| | | sysUserVo.setPermissions(permissions);
|
| | |
| | | @GetMapping("getInfo")
|
| | | public AjaxResult getInfo()
|
| | | {
|
| | | Long userId = SecurityUtils.getLoginUser().getUserId();
|
| | | Long userId = SecurityUtils.getUserId();
|
| | | // 角色集合
|
| | | Set<String> roles = permissionService.getRolePermission(userId);
|
| | | // 权限集合
|
| | |
| | | /**
|
| | | * 根据用户编号获取详细信息
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:user:query')")
|
| | | @PreAuthorize(hasPermi = "system:user:query")
|
| | | @GetMapping(value = { "/", "/{userId}" })
|
| | | public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
|
| | | {
|
| | |
| | | /**
|
| | | * 新增用户
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:user:add')")
|
| | | @PreAuthorize(hasPermi = "system:user:add")
|
| | | @Log(title = "用户管理", businessType = BusinessType.INSERT)
|
| | | @PostMapping
|
| | | public AjaxResult add(@Validated @RequestBody SysUser user)
|
| | |
| | | /**
|
| | | * 修改用户
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:user:edit')")
|
| | | @PreAuthorize(hasPermi = "system:user:edit")
|
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
| | | @PutMapping
|
| | | public AjaxResult edit(@Validated @RequestBody SysUser user)
|
| | |
| | | /**
|
| | | * 删除用户
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:user:remove')")
|
| | | @PreAuthorize(hasPermi = "system:user:remove")
|
| | | @Log(title = "用户管理", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{userIds}")
|
| | | public AjaxResult remove(@PathVariable Long[] userIds)
|
| | |
| | | /**
|
| | | * 重置密码
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:user:edit')")
|
| | | @PreAuthorize(hasPermi = "system:user:edit")
|
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
| | | @PutMapping("/resetPwd")
|
| | | public AjaxResult resetPwd(@RequestBody SysUser user)
|
| | |
| | | /**
|
| | | * 状态修改
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('system:user:edit')")
|
| | | @PreAuthorize(hasPermi = "system:user:edit")
|
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
| | | @PutMapping("/changeStatus")
|
| | | public AjaxResult changeStatus(@RequestBody SysUser user)
|
| | |
| | |
|
| | | // 登录方法
|
| | | export function login(username, password, code, uuid) {
|
| | | const grant_type = 'password'
|
| | | return request({
|
| | | url: '/auth/oauth/token',
|
| | | url: '/auth/login',
|
| | | method: 'post',
|
| | | params: { username, password, code, uuid, client_id, client_secret, grant_type, scope }
|
| | | data: { username, password, code, uuid }
|
| | | })
|
| | | }
|
| | |
|
| | | // 刷新方法
|
| | | export function refreshToken(refresh_token) {
|
| | | const grant_type = 'refresh_token'
|
| | | export function refreshToken() {
|
| | | return request({
|
| | | url: '/auth/oauth/token',
|
| | | method: 'post',
|
| | | params: { client_id, client_secret, grant_type, scope, refresh_token }
|
| | | url: '/auth/refresh',
|
| | | method: 'post'
|
| | | })
|
| | | }
|
| | |
|
| | |
| | | // 退出方法
|
| | | export function logout() {
|
| | | return request({
|
| | | url: '/auth/token/logout',
|
| | | url: '/auth/logout',
|
| | | method: 'delete'
|
| | | })
|
| | | }
|
| | |
| | | import { login, logout, getInfo, refreshToken } from '@/api/login'
|
| | | import { getToken, getRefreshToken, setToken, setRefreshToken, setExpiresIn, removeToken } from '@/utils/auth'
|
| | | import { getToken, setToken, setExpiresIn, removeToken } from '@/utils/auth'
|
| | |
|
| | | const user = {
|
| | | state: {
|
| | | token: getToken(),
|
| | | refresh_token: getRefreshToken(),
|
| | | name: '',
|
| | | avatar: '',
|
| | | roles: [],
|
| | |
| | | },
|
| | | SET_EXPIRES_IN: (state, time) => {
|
| | | state.expires_in = time
|
| | | },
|
| | | SET_REFRESH_TOKEN: (state, token) => {
|
| | | state.refresh_token = token
|
| | | },
|
| | | SET_NAME: (state, name) => {
|
| | | state.name = name
|
| | |
| | | const uuid = userInfo.uuid
|
| | | return new Promise((resolve, reject) => {
|
| | | login(username, password, code, uuid).then(res => {
|
| | | setToken(res.access_token)
|
| | | commit('SET_TOKEN', res.access_token)
|
| | | setRefreshToken(res.refresh_token)
|
| | | commit('SET_REFRESH_TOKEN', res.refresh_token)
|
| | | setExpiresIn(res.expires_in)
|
| | | commit('SET_EXPIRES_IN', res.expires_in)
|
| | | let data = res.data
|
| | | setToken(data.access_token)
|
| | | commit('SET_TOKEN', data.access_token)
|
| | | setExpiresIn(data.expires_in)
|
| | | commit('SET_EXPIRES_IN', data.expires_in)
|
| | | resolve()
|
| | | }).catch(error => {
|
| | | reject(error)
|
| | |
| | | // 刷新token
|
| | | RefreshToken({commit, state}) {
|
| | | return new Promise((resolve, reject) => {
|
| | | refreshToken(state.refresh_token).then(res => {
|
| | | setToken(res.access_token)
|
| | | commit('SET_TOKEN', res.access_token)
|
| | | setRefreshToken(res.refresh_token)
|
| | | commit('SET_REFRESH_TOKEN', res.refresh_token)
|
| | | setExpiresIn(res.expires_in)
|
| | | commit('SET_EXPIRES_IN', res.expires_in)
|
| | | refreshToken(state.token).then(res => {
|
| | | setExpiresIn(res.data)
|
| | | commit('SET_EXPIRES_IN', res.data)
|
| | | resolve()
|
| | | }).catch(error => {
|
| | | reject(error)
|
| | |
| | |
|
| | | const TokenKey = 'Admin-Token'
|
| | |
|
| | | const RefreshTokenKey = 'Admin-Refresh-Token'
|
| | |
|
| | | const ExpiresInKey = 'Admin-Expires-In'
|
| | |
|
| | | export function getToken() {
|
| | |
| | |
|
| | | export function removeToken() {
|
| | | return Cookies.remove(TokenKey)
|
| | | }
|
| | |
|
| | | export function getRefreshToken() {
|
| | | return Cookies.get(RefreshTokenKey) || ``
|
| | | }
|
| | |
|
| | | export function setRefreshToken(token) {
|
| | | return Cookies.set(RefreshTokenKey, token)
|
| | | }
|
| | |
|
| | | export function removeRefreshToken() {
|
| | | return Cookies.remove(RefreshTokenKey)
|
| | | }
|
| | |
|
| | | export function getExpiresIn() {
|
| | |
| | | // 是否需要设置 token
|
| | | const isToken = (config.headers || {}).isToken === false
|
| | | if (getToken() && !isToken) {
|
| | | config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
| | | config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际
|
| | | }
|
| | | return config
|
| | | }, error => {
|
| | |
| | | return;
|
| | | }
|
| | | const expires_in = getExpiresIn();
|
| | | if (expires_in <= 1000 && !this.refreshLock) {
|
| | | if (expires_in <= 1200 && !this.refreshLock) {
|
| | | this.refreshLock = true
|
| | | this.$store
|
| | | .dispatch('RefreshToken')
|
| File was renamed from sql/ry_20200823.sql |
| | |
| | | insert into sys_menu values('104', '岗位管理', '1', '5', 'post', 'system/post/index', 1, 'C', '0', '0', 'system:post:list', 'post', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '岗位管理菜单');
|
| | | insert into sys_menu values('105', '字典管理', '1', '6', 'dict', 'system/dict/index', 1, 'C', '0', '0', 'system:dict:list', 'dict', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '字典管理菜单');
|
| | | insert into sys_menu values('106', '参数设置', '1', '7', 'config', 'system/config/index', 1, 'C', '0', '0', 'system:config:list', 'edit', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '参数设置菜单');
|
| | | insert into sys_menu values('107', '终端设置', '1', '8', 'client', 'system/client/index', 1, 'C', '0', '0', 'system:client:list', 'client', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '终端设置菜单');
|
| | | insert into sys_menu values('108', '通知公告', '1', '9', 'notice', 'system/notice/index', 1, 'C', '0', '0', 'system:notice:list', 'message', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '通知公告菜单');
|
| | | insert into sys_menu values('109', '日志管理', '1', '10', 'log', 'system/log/index', 1, 'M', '0', '0', '', 'log', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '日志管理菜单');
|
| | | insert into sys_menu values('110', '定时任务', '2', '1', 'job', 'monitor/job/index', 1, 'C', '0', '0', 'monitor:job:list', 'job', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '定时任务菜单');
|
| | | insert into sys_menu values('111', 'Sentinel控制台', '2', '2', 'http://localhost:8718', '', 1, 'C', '0', '0', 'monitor:sentinel:list', 'sentinel', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '流量控制菜单');
|
| | | insert into sys_menu values('112', 'Nacos控制台', '2', '3', 'http://localhost:8848/nacos', '', 1, 'C', '0', '0', 'monitor:nacos:list', 'nacos', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '服务治理菜单');
|
| | | insert into sys_menu values('113', 'Admin控制台', '2', '4', 'http://localhost:9100/login', '', 1, 'C', '0', '0', 'monitor:server:list', 'server', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '服务监控菜单');
|
| | | insert into sys_menu values('114', '表单构建', '3', '1', 'build', 'tool/build/index', 1 ,'C', '0', '0', 'tool:build:list', 'build', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '表单构建菜单');
|
| | | insert into sys_menu values('115', '代码生成', '3', '2', 'gen', 'tool/gen/index', 1, 'C', '0', '0', 'tool:gen:list', 'code', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '代码生成菜单');
|
| | | insert into sys_menu values('116', '系统接口', '3', '3', 'http://localhost:8080/swagger-ui.html', '', 1, 'C', '0', '0', 'tool:swagger:list', 'swagger', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '系统接口菜单');
|
| | | insert into sys_menu values('107', '通知公告', '1', '9', 'notice', 'system/notice/index', 1, 'C', '0', '0', 'system:notice:list', 'message', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '通知公告菜单');
|
| | | insert into sys_menu values('108', '日志管理', '1', '10', 'log', 'system/log/index', 1, 'M', '0', '0', '', 'log', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '日志管理菜单');
|
| | | insert into sys_menu values('109', '定时任务', '2', '1', 'job', 'monitor/job/index', 1, 'C', '0', '0', 'monitor:job:list', 'job', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '定时任务菜单');
|
| | | insert into sys_menu values('110', 'Sentinel控制台', '2', '2', 'http://localhost:8718', '', 1, 'C', '0', '0', 'monitor:sentinel:list', 'sentinel', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '流量控制菜单');
|
| | | insert into sys_menu values('111', 'Nacos控制台', '2', '3', 'http://localhost:8848/nacos', '', 1, 'C', '0', '0', 'monitor:nacos:list', 'nacos', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '服务治理菜单');
|
| | | insert into sys_menu values('112', 'Admin控制台', '2', '4', 'http://localhost:9100/login', '', 1, 'C', '0', '0', 'monitor:server:list', 'server', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '服务监控菜单');
|
| | | insert into sys_menu values('113', '表单构建', '3', '1', 'build', 'tool/build/index', 1 ,'C', '0', '0', 'tool:build:list', 'build', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '表单构建菜单');
|
| | | insert into sys_menu values('114', '代码生成', '3', '2', 'gen', 'tool/gen/index', 1, 'C', '0', '0', 'tool:gen:list', 'code', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '代码生成菜单');
|
| | | insert into sys_menu values('115', '系统接口', '3', '3', 'http://localhost:8080/swagger-ui.html', '', 1, 'C', '0', '0', 'tool:swagger:list', 'swagger', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '系统接口菜单');
|
| | | -- 三级菜单
|
| | | insert into sys_menu values('500', '操作日志', '109', '1', 'operlog', 'system/operlog/index', 1, 'C', '0', '0', 'system:operlog:list', 'form', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '操作日志菜单');
|
| | | insert into sys_menu values('501', '登录日志', '109', '2', 'logininfor', 'system/logininfor/index', 1, 'C', '0', '0', 'system:logininfor:list', 'logininfor', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '登录日志菜单');
|
| | | insert into sys_menu values('500', '操作日志', '108', '1', 'operlog', 'system/operlog/index', 1, 'C', '0', '0', 'system:operlog:list', 'form', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '操作日志菜单');
|
| | | insert into sys_menu values('501', '登录日志', '108', '2', 'logininfor', 'system/logininfor/index', 1, 'C', '0', '0', 'system:logininfor:list', 'logininfor', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '登录日志菜单');
|
| | | -- 用户管理按钮
|
| | | insert into sys_menu values('1001', '用户查询', '100', '1', '', '', 1, 'F', '0', '0', 'system:user:query', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1002', '用户新增', '100', '2', '', '', 1, 'F', '0', '0', 'system:user:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | |
| | | insert into sys_menu values('1033', '参数修改', '106', '3', '#', '', 1, 'F', '0', '0', 'system:config:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1034', '参数删除', '106', '4', '#', '', 1, 'F', '0', '0', 'system:config:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1035', '参数导出', '106', '5', '#', '', 1, 'F', '0', '0', 'system:config:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | -- 终端设置按钮
|
| | | insert into sys_menu values('1036', '终端查询', '107', '1', '#', '', 1, 'F', '0', '0', 'system:client:query', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1037', '终端新增', '107', '2', '#', '', 1, 'F', '0', '0', 'system:client:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1038', '终端修改', '107', '3', '#', '', 1, 'F', '0', '0', 'system:client:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1039', '终端删除', '107', '4', '#', '', 1, 'F', '0', '0', 'system:client:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1040', '终端导出', '107', '5', '#', '', 1, 'F', '0', '0', 'system:client:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | -- 通知公告按钮
|
| | | insert into sys_menu values('1041', '公告查询', '108', '1', '#', '', 1, 'F', '0', '0', 'system:notice:query', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1042', '公告新增', '108', '2', '#', '', 1, 'F', '0', '0', 'system:notice:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1043', '公告修改', '108', '3', '#', '', 1, 'F', '0', '0', 'system:notice:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1044', '公告删除', '108', '4', '#', '', 1, 'F', '0', '0', 'system:notice:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | \-- 通知公告按钮
|
| | | insert into sys_menu values('1041', '公告查询', '107', '1', '#', '', 1, 'F', '0', '0', 'system:notice:query', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1042', '公告新增', '107', '2', '#', '', 1, 'F', '0', '0', 'system:notice:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1043', '公告修改', '107', '3', '#', '', 1, 'F', '0', '0', 'system:notice:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1044', '公告删除', '107', '4', '#', '', 1, 'F', '0', '0', 'system:notice:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | -- 操作日志按钮
|
| | | insert into sys_menu values('1045', '操作查询', '500', '1', '#', '', 1, 'F', '0', '0', 'system:operlog:query', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1046', '操作删除', '500', '2', '#', '', 1, 'F', '0', '0', 'system:operlog:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | |
| | | insert into sys_menu values('1049', '登录删除', '501', '2', '#', '', 1, 'F', '0', '0', 'system:logininfor:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1050', '日志导出', '501', '3', '#', '', 1, 'F', '0', '0', 'system:logininfor:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | -- 定时任务按钮
|
| | | insert into sys_menu values('1051', '任务查询', '110', '1', '#', '', 1, 'F', '0', '0', 'monitor:job:query', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1052', '任务新增', '110', '2', '#', '', 1, 'F', '0', '0', 'monitor:job:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1053', '任务修改', '110', '3', '#', '', 1, 'F', '0', '0', 'monitor:job:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1054', '任务删除', '110', '4', '#', '', 1, 'F', '0', '0', 'monitor:job:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1055', '状态修改', '110', '5', '#', '', 1, 'F', '0', '0', 'monitor:job:changeStatus', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1056', '任务导出', '110', '7', '#', '', 1, 'F', '0', '0', 'monitor:job:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1051', '任务查询', '109', '1', '#', '', 1, 'F', '0', '0', 'monitor:job:query', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1052', '任务新增', '109', '2', '#', '', 1, 'F', '0', '0', 'monitor:job:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1053', '任务修改', '109', '3', '#', '', 1, 'F', '0', '0', 'monitor:job:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1054', '任务删除', '109', '4', '#', '', 1, 'F', '0', '0', 'monitor:job:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1055', '状态修改', '109', '5', '#', '', 1, 'F', '0', '0', 'monitor:job:changeStatus', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1056', '任务导出', '109', '7', '#', '', 1, 'F', '0', '0', 'monitor:job:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | -- 代码生成按钮
|
| | | insert into sys_menu values('1057', '生成查询', '115', '1', '#', '', 1, 'F', '0', '0', 'tool:gen:query', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1058', '生成修改', '115', '2', '#', '', 1, 'F', '0', '0', 'tool:gen:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1059', '生成删除', '115', '3', '#', '', 1, 'F', '0', '0', 'tool:gen:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1060', '导入代码', '115', '2', '#', '', 1, 'F', '0', '0', 'tool:gen:import', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1061', '预览代码', '115', '4', '#', '', 1, 'F', '0', '0', 'tool:gen:preview', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1062', '生成代码', '115', '5', '#', '', 1, 'F', '0', '0', 'tool:gen:code', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1057', '生成查询', '114', '1', '#', '', 1, 'F', '0', '0', 'tool:gen:query', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1058', '生成修改', '114', '2', '#', '', 1, 'F', '0', '0', 'tool:gen:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1059', '生成删除', '114', '3', '#', '', 1, 'F', '0', '0', 'tool:gen:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1060', '导入代码', '114', '2', '#', '', 1, 'F', '0', '0', 'tool:gen:import', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1061', '预览代码', '114', '4', '#', '', 1, 'F', '0', '0', 'tool:gen:preview', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | | insert into sys_menu values('1062', '生成代码', '114', '5', '#', '', 1, 'F', '0', '0', 'tool:gen:code', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
|
| | |
|
| | |
|
| | | -- ----------------------------
|
| | |
| | | update_time datetime comment '更新时间',
|
| | | primary key (column_id)
|
| | | ) engine=innodb auto_increment=1 comment = '代码生成业务表字段';
|
| | |
|
| | |
|
| | | -- ----------------------------
|
| | | -- 20、终端配置表
|
| | | -- ----------------------------
|
| | | drop table if exists sys_oauth_client_details;
|
| | | create table sys_oauth_client_details (
|
| | | client_id varchar(255) not null comment '终端编号',
|
| | | resource_ids varchar(255) default null comment '资源ID标识',
|
| | | client_secret varchar(255) not null comment '终端安全码',
|
| | | scope varchar(255) not null comment '终端授权范围',
|
| | | authorized_grant_types varchar(255) not null comment '终端授权类型',
|
| | | web_server_redirect_uri varchar(255) default null comment '服务器回调地址',
|
| | | authorities varchar(255) default null comment '访问资源所需权限',
|
| | | access_token_validity int(11) default null comment '设定终端的access_token的有效时间值(秒)',
|
| | | refresh_token_validity int(11) default null comment '设定终端的refresh_token的有效时间值(秒)',
|
| | | additional_information varchar(4096) default null comment '附加信息',
|
| | | autoapprove tinyint(4) default null comment '是否登录时跳过授权',
|
| | | origin_secret varchar(255) not null comment '终端明文安全码',
|
| | | primary key (client_id)
|
| | | ) engine=innodb auto_increment=1 comment = '终端配置表';
|
| | |
|
| | | -- ----------------------------
|
| | | -- 初始化-终端配置表数据
|
| | | -- ----------------------------
|
| | | insert into sys_oauth_client_details values ('web', '', '$2a$10$y2hKeELx.z3Sbz.kjQ4wmuiIsv5ZSbUQ1ov4BwFH6ccirP8Knp1uq', 'server', 'password,refresh_token', '', NULL, 3600, 7200, NULL, NULL, '123456');
|
| | | insert into sys_oauth_client_details values ('ruoyi', '', '$2a$10$y2hKeELx.z3Sbz.kjQ4wmuiIsv5ZSbUQ1ov4BwFH6ccirP8Knp1uq', 'server', 'password,client_credentials,refresh_token', '', NULL, 3600, 7200, NULL, NULL, '123456'); |
| File was renamed from sql/ry_config_20200618.sql |
| | |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info';
|
| | |
|
| | | insert into config_info(id, data_id, group_id, content, md5, gmt_create, gmt_modified, src_user, src_ip, app_name, tenant_id, c_desc, c_use, effect, type, c_schema) values
|
| | | (1,'application-dev.yml','DEFAULT_GROUP','#请求处理的超时时间\nribbon:\n ReadTimeout: 10000\n ConnectTimeout: 10000\n\n# feign 配置\nfeign:\n sentinel:\n enabled: true\n okhttp:\n enabled: true\n httpclient:\n enabled: false\n client:\n config:\n default:\n connectTimeout: 10000\n readTimeout: 10000\n compression:\n request:\n enabled: true\n response:\n enabled: true\n\n# 暴露监控端点\nmanagement:\n endpoints:\n web:\n exposure:\n include: \'*\'\n\n# 认证配置\nsecurity:\n oauth2:\n client:\n client-id: ruoyi\n client-secret: 123456\n scope: server\n resource:\n loadBalanced: true\n token-info-uri: http://ruoyi-auth/oauth/check_token\n ignore:\n urls:\n - /v2/api-docs\n - /actuator/**\n - /user/info/*\n - /operlog\n - /logininfor\n','bf6cdf98474bf18c7ff697afbdf18e50','2019-11-29 16:31:20','2020-06-09 18:22:21',NULL,'0:0:0:0:0:0:0:1','','','通用配置','null','null','yaml','null'),
|
| | | (2,'ruoyi-gateway-dev.yml','DEFAULT_GROUP','spring:\r\n redis:\r\n host: localhost\r\n port: 6379\r\n password: \r\n cloud:\r\n gateway:\r\n discovery:\r\n locator:\r\n lowerCaseServiceId: true\r\n enabled: true\r\n routes:\r\n # 认证中心\r\n - id: ruoyi-auth\r\n uri: lb://ruoyi-auth\r\n predicates:\r\n - Path=/auth/**\r\n filters:\r\n # 验证码处理\r\n - ValidateCodeFilter\r\n - StripPrefix=1\r\n # 代码生成\r\n - id: ruoyi-gen\r\n uri: lb://ruoyi-gen\r\n predicates:\r\n - Path=/code/**\r\n filters:\r\n - StripPrefix=1\r\n # 定时任务\r\n - id: ruoyi-job\r\n uri: lb://ruoyi-job\r\n predicates:\r\n - Path=/schedule/**\r\n filters:\r\n - StripPrefix=1\r\n # 系统模块\r\n # 系统模块\r\n - id: ruoyi-system\r\n uri: lb://ruoyi-system\r\n predicates:\r\n - Path=/system/**\r\n filters:\r\n - name: BlackListUrlFilter\r\n args:\r\n blacklistUrl:\r\n - /user/info/*\r\n - StripPrefix=1\r\n','ce9cfad3603fe40fb14a37da1dd56516','2020-05-14 14:17:55','2020-06-18 17:32:07',NULL,'0:0:0:0:0:0:0:1','','','网关模块','null','null','yaml','null'),
|
| | | (1,'application-dev.yml','DEFAULT_GROUP','spring:\n main:\n allow-bean-definition-overriding: true\n\n#请求处理的超时时间\nribbon:\n ReadTimeout: 10000\n ConnectTimeout: 10000\n\n# feign 配置\nfeign:\n sentinel:\n enabled: true\n okhttp:\n enabled: true\n httpclient:\n enabled: false\n client:\n config:\n default:\n connectTimeout: 10000\n readTimeout: 10000\n compression:\n request:\n enabled: true\n response:\n enabled: true\n\n# 暴露监控端点\nmanagement:\n endpoints:\n web:\n exposure:\n include: \'*\'\n','57470c6d167154919418fa150863b7fb','2019-11-29 16:31:20','2020-09-01 09:14:30',NULL,'0:0:0:0:0:0:0:1','','','通用配置','null','null','yaml','null'),
|
| | | (2,'ruoyi-gateway-dev.yml','DEFAULT_GROUP','spring:\r\n redis:\r\n host: localhost\r\n port: 6379\r\n password: \r\n cloud:\r\n gateway:\r\n discovery:\r\n locator:\r\n lowerCaseServiceId: true\r\n enabled: true\r\n routes:\r\n # 认证中心\r\n - id: ruoyi-auth\r\n uri: lb://ruoyi-auth\r\n predicates:\r\n - Path=/auth/**\r\n filters:\r\n # 验证码处理\r\n - CacheRequestFilter\r\n - ValidateCodeFilter\r\n - StripPrefix=1\r\n # 代码生成\r\n - id: ruoyi-gen\r\n uri: lb://ruoyi-gen\r\n predicates:\r\n - Path=/code/**\r\n filters:\r\n - StripPrefix=1\r\n # 定时任务\r\n - id: ruoyi-job\r\n uri: lb://ruoyi-job\r\n predicates:\r\n - Path=/schedule/**\r\n filters:\r\n - StripPrefix=1\r\n # 系统模块\r\n # 系统模块\r\n - id: ruoyi-system\r\n uri: lb://ruoyi-system\r\n predicates:\r\n - Path=/system/**\r\n filters:\r\n - name: BlackListUrlFilter\r\n args:\r\n blacklistUrl:\r\n - /user/info/*\r\n - StripPrefix=1\r\n','1c11e0d5e5e4f983f378088740102540','2020-05-14 14:17:55','2020-08-31 20:30:38',NULL,'0:0:0:0:0:0:0:1','','','网关模块','null','null','yaml','null'),
|
| | | (3,'ruoyi-auth-dev.yml','DEFAULT_GROUP','spring: \r\n datasource:\r\n driver-class-name: com.mysql.cj.jdbc.Driver\r\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\r\n username: root\r\n password: password\r\n redis:\r\n host: localhost\r\n port: 6379\r\n password: \r\n','868c15010a7a15c027d4c90a48aabb3e','2020-05-14 13:20:49','2020-06-09 16:30:50',NULL,'0:0:0:0:0:0:0:1','','','认证中心','null','null','yaml','null'),
|
| | | (4,'ruoyi-monitor-dev.yml','DEFAULT_GROUP','# Spring\r\nspring: \r\n security:\r\n user:\r\n name: ruoyi\r\n password: 123456\r\n boot:\r\n admin:\r\n ui:\r\n title: 若依服务状态监控\r\n','8e49d78998a7780d780305aeefe4fb1b','2020-05-19 15:14:01','2020-05-19 18:50:44',NULL,'0:0:0:0:0:0:0:1','','','监控中心','null','null','yaml','null'),
|
| | | (5,'ruoyi-system-dev.yml','DEFAULT_GROUP','# Spring\r\nspring: \r\n redis:\r\n host: localhost\r\n port: 6379\r\n password: \r\n datasource:\r\n driver-class-name: com.mysql.cj.jdbc.Driver\r\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\r\n username: root\r\n password: password\r\n\r\n# Mybatis配置\r\nmybatis:\r\n # 搜索指定包别名\r\n typeAliasesPackage: com.ruoyi.system\r\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\r\n mapperLocations: classpath:mapper/**/*.xml\r\n\r\n# swagger 配置\r\nswagger:\r\n title: 系统模块接口文档\r\n license: Powered By ruoyi\r\n licenseUrl: https://ruoyi.vip\r\n authorization:\r\n name: RuoYi OAuth\r\n auth-regex: ^.*$\r\n authorization-scope-list:\r\n - scope: server\r\n description: 客户端授权范围\r\n token-url-list:\r\n - http://localhost:8080/auth/oauth/token\r\n','06f95c879d284ec8031cc44805e62b50','2020-05-14 13:37:04','2020-06-04 17:14:14',NULL,'0:0:0:0:0:0:0:1','','','系统模块','null','null','yaml','null'),
|
| | | (5,'ruoyi-system-dev.yml','DEFAULT_GROUP','# Spring\r\nspring: \r\n redis:\r\n host: localhost\r\n port: 6379\r\n password: \r\n datasource:\r\n driver-class-name: com.mysql.cj.jdbc.Driver\r\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\r\n username: root\r\n password: password\r\n\r\n# Mybatis配置\r\nmybatis:\r\n # 搜索指定包别名\r\n typeAliasesPackage: com.ruoyi.system\r\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\r\n mapperLocations: classpath:mapper/**/*.xml\r\n\r\n# swagger 配置\r\nswagger:\r\n title: 系统模块接口文档\r\n license: Powered By ruoyi\r\n licenseUrl: https://ruoyi.vip\r\n authorization:\r\n name: RuoYi OAuth\r\n auth-regex: ^.*$\r\n authorization-scope-list:\r\n - scope: server\r\n description: 客户端授权范围\r\n token-url-list:\r\n - http://localhost:8080/auth/oauth/token\r\n','06f95c879d284ec8031cc44805e62b50','2020-05-14 13:37:04','2020-07-02 20:03:46',NULL,'0:0:0:0:0:0:0:1','','','系统模块','null','null','yaml','null'),
|
| | | (6,'ruoyi-gen-dev.yml','DEFAULT_GROUP','# Spring\r\nspring: \r\n datasource:\r\n driver-class-name: com.mysql.cj.jdbc.Driver\r\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\r\n username: root\r\n password: password\r\n\r\n# Mybatis配置\r\nmybatis:\r\n # 搜索指定包别名\r\n typeAliasesPackage: com.ruoyi.gen.domain\r\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\r\n mapperLocations: classpath:mapper/**/*.xml\r\n\r\n# swagger 配置\r\nswagger:\r\n title: 代码生成接口文档\r\n license: Powered By ruoyi\r\n licenseUrl: https://ruoyi.vip\r\n authorization:\r\n name: RuoYi OAuth\r\n auth-regex: ^.*$\r\n authorization-scope-list:\r\n - scope: server\r\n description: 客户端授权范围\r\n token-url-list:\r\n - http://localhost:8080/auth/oauth/token\r\n\r\n# 代码生成\r\ngen: \r\n # 作者\r\n author: ruoyi\r\n # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool\r\n packageName: com.ruoyi.system\r\n # 自动去除表前缀,默认是false\r\n autoRemovePre: false\r\n # 表前缀(生成类名不会包含表前缀,多个用逗号分隔)\r\n tablePrefix: sys_\r\n','aa7e94e2abbdeb408bd8981391ab82f8','2020-05-14 13:54:50','2020-05-19 18:51:11',NULL,'0:0:0:0:0:0:0:1','','','代码生成','null','null','yaml','null'),
|
| | | (7,'ruoyi-job-dev.yml','DEFAULT_GROUP','# Spring\r\nspring: \r\n datasource:\r\n driver-class-name: com.mysql.cj.jdbc.Driver\r\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\r\n username: root\r\n password: password\r\n\r\n# Mybatis配置\r\nmybatis:\r\n # 搜索指定包别名\r\n typeAliasesPackage: com.ruoyi.job.domain\r\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\r\n mapperLocations: classpath:mapper/**/*.xml\r\n\r\n# swagger 配置\r\nswagger:\r\n title: 定时任务接口文档\r\n license: Powered By ruoyi\r\n licenseUrl: https://ruoyi.vip\r\n authorization:\r\n name: RuoYi OAuth\r\n auth-regex: ^.*$\r\n authorization-scope-list:\r\n - scope: server\r\n description: 客户端授权范围\r\n token-url-list:\r\n - http://localhost:8080/auth/oauth/token\r\n','2904b375372b13f52baed5be2e497b21','2020-05-14 13:58:46','2020-05-19 18:49:56',NULL,'0:0:0:0:0:0:0:1','','','定时任务','null','null','yaml','null'),
|
| | | (8,'sentinel-ruoyi-gateway','DEFAULT_GROUP','[\r\n {\r\n \"resource\": \"ruoyi-auth\",\r\n \"count\": 500,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"ruoyi-system\",\r\n \"count\": 1000,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"ruoyi-gen\",\r\n \"count\": 200,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n },\r\n {\r\n \"resource\": \"ruoyi-job\",\r\n \"count\": 300,\r\n \"grade\": 1,\r\n \"limitApp\": \"default\",\r\n \"strategy\": 0,\r\n \"controlBehavior\": 0\r\n }\r\n]','9f3a3069261598f74220bc47958ec252','2020-06-09 12:14:01','2020-06-10 11:44:19',NULL,'0:0:0:0:0:0:0:1','','','null','null','null','json','null');
|