Merge branch 'master' of http://121.40.234.130:8899/root/nl-sso-server
@@ -24,10 +24,22 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-jwt</artifactId>
|
||||
<version>${sa_token.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.83</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-dao-redis-jackson</artifactId>
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package org.nl.sso.base;
|
||||
|
||||
import cn.dev33.satoken.SaManager;
|
||||
import cn.dev33.satoken.config.SaSsoConfig;
|
||||
import cn.dev33.satoken.sso.SaSsoManager;
|
||||
import cn.dev33.satoken.sso.SaSsoProcessor;
|
||||
import cn.dev33.satoken.sso.SaSsoUtil;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.json.JSON;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import cn.hutool.jwt.JWT;
|
||||
import org.nl.sso.base.dto.UserEntry;
|
||||
import org.nl.sso.base.util.UserUtil;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -21,31 +22,38 @@ import java.util.List;
|
||||
* @author ZZQ
|
||||
* @Date 2022/11/26 10:12 上午
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "sa-token.sso")
|
||||
public class LoginInterceptor implements HandlerInterceptor {
|
||||
private String pathPatterns;
|
||||
|
||||
private List whileUrl= Arrays.asList("auth/login","/error","/logout","auth/sso/logoutCall","/auth/logout");
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
if (whileUrl.contains(request.getRequestURI())){
|
||||
return true;
|
||||
}
|
||||
String loginId = StpUtil.getLoginId(null);
|
||||
System.out.println("-- 登入请求---"+loginId);
|
||||
if (loginId ==null){
|
||||
return false;
|
||||
}else {
|
||||
UserEntry user = UserUtil.userCache.get(loginId);
|
||||
if (user ==null){
|
||||
//查询数据库
|
||||
HttpResponse execute = HttpRequest.get(SaSsoManager.getConfig().userinfoUrl + "?loginId=" + loginId).execute();
|
||||
if (200==execute.getStatus()){
|
||||
String body = execute.body();
|
||||
UserEntry info = new UserEntry();
|
||||
info.setTotalInfo(body);
|
||||
info.setUserId(Long.valueOf(loginId));
|
||||
UserUtil.setUserEntry(info);
|
||||
}
|
||||
}
|
||||
//如果需要添加token登出过期,修改过期添加redis判断:String token = SaSsoUtil.saSsoTemplate.stpLogic.isLogin
|
||||
String token = StpUtil.stpLogic.getTokenValue();
|
||||
if (!StringUtils.isEmpty(token)){
|
||||
JWT of = JWT.of(token);
|
||||
UserEntry user = of.getPayloads().get("loginInfo", UserEntry.class);
|
||||
UserUtil.setUserEntry(user);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||
UserUtil.remove();
|
||||
}
|
||||
|
||||
public String getPathPatterns() {
|
||||
return pathPatterns;
|
||||
}
|
||||
|
||||
public void setPathPatterns(String pathPatterns) {
|
||||
this.pathPatterns = pathPatterns;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +1,54 @@
|
||||
package org.nl.sso.base.dto;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2022/11/25 5:44 下午
|
||||
* String info ="{\"id\":1,\"username\":\"admin\",\"user\":{\"username\":\"admin\",\"personName\":\"管理员\",\"email\":\"201507802@qq.com\",\"phone\":\"18888888888\",\"gender\":\"男\",\"avatarName\":\"avatar-20200806032259161.png\",\"avatarPath\":\"/Users/jie/Documents/work/me/admin/eladmin/~/avatar/avatar-20200806032259161.png\",\"extuserId\":\"\",\"password\":\"f52020dca765fd3943ed40a615dc2c5c\",\"create_name\":\"\",\"update_optname\":\"admin\",\"create_time\":1669846199,\"update_time\":1669966881},\"permissions\":[\"admin\",\"user:list\",\"roles:list\",\"menu:list\",\"timing:list\",\"dept:list\",\"dict:list\",\"roles:add\",\"roles:edit\",\"roles:del\",\"monitor:list\",\"genCode:list\",\"999\",\"storage:list\"]}";
|
||||
*/
|
||||
@Data
|
||||
public class UserEntry implements Serializable {
|
||||
private Long userId;
|
||||
private String userName;
|
||||
private String totalInfo;
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
private Integer id;
|
||||
private String username;
|
||||
private User user;
|
||||
private List<String> permissions;
|
||||
private List<String> roles;
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
@Data
|
||||
public class User{
|
||||
private String username;
|
||||
/** 昵称 */
|
||||
private String personName;
|
||||
/** 性别 */
|
||||
private String gender;
|
||||
/** 手机号码 */
|
||||
private String phone;
|
||||
/** 邮箱 */
|
||||
private String email;
|
||||
/** 头像地址 */
|
||||
private String avatarName;
|
||||
/** 头像真实路径 */
|
||||
private String avatarPath;
|
||||
/** 密码 */
|
||||
private String password;
|
||||
/** 创建者 */
|
||||
private String create_by;
|
||||
/** 更新者 */
|
||||
private String update_by;
|
||||
/** 修改密码的时间 */
|
||||
private Date pwd_reset_time;
|
||||
/** 创建日期 */
|
||||
private Date create_time;
|
||||
/** 更新时间 */
|
||||
private Date update_time;
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getTotalInfo() {
|
||||
return totalInfo;
|
||||
}
|
||||
|
||||
public void setTotalInfo(String totalInfo) {
|
||||
this.totalInfo = totalInfo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,16 +18,13 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
* @Date 2022/11/24 3:55 下午
|
||||
*/
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "sa-token.sso")
|
||||
public class BaseConfig implements WebMvcConfigurer {
|
||||
|
||||
private String pathPatterns ="/**";
|
||||
private String projectName ="上海诺力欢迎你";
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// 注册 Sa-Token 拦截器,打开注解式鉴权功能
|
||||
registry.addInterceptor(new SaInterceptor()).addPathPatterns(pathPatterns);
|
||||
registry.addInterceptor(new SaInterceptor()).addPathPatterns("/**");
|
||||
registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**");
|
||||
}
|
||||
|
||||
@@ -36,23 +33,12 @@ public class BaseConfig implements WebMvcConfigurer {
|
||||
// 配置Http请求处理器
|
||||
sso.setSendHttp(url -> {
|
||||
HttpResponse execute = HttpRequest.get(url).execute();
|
||||
return execute.body();
|
||||
if (execute.getStatus() == 200){
|
||||
return execute.body();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
public String getPathPatterns() {
|
||||
return pathPatterns;
|
||||
}
|
||||
|
||||
public void setPathPatterns(String pathPatterns) {
|
||||
this.pathPatterns = pathPatterns;
|
||||
}
|
||||
|
||||
public String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package org.nl.sso.base.saconfig;
|
||||
|
||||
import cn.dev33.satoken.stp.StpInterface;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
@@ -14,11 +18,21 @@ import java.util.List;
|
||||
public final class PermissionHandler implements StpInterface {
|
||||
@Override
|
||||
public List<String> getPermissionList(Object loginId, String loginType) {
|
||||
return null;
|
||||
JSONObject json = (JSONObject) StpUtil.getExtra("loginInfo");
|
||||
JSONArray permissions = json.getJSONArray("permissions");
|
||||
if (permissions.size() > 0) {
|
||||
return permissions.toList(String.class);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRoleList(Object loginId, String loginType) {
|
||||
return null;
|
||||
JSONObject json = (JSONObject) StpUtil.getExtra("loginInfo");
|
||||
JSONArray roles = json.getJSONArray("roles");
|
||||
if (roles.size() > 0) {
|
||||
return roles.toList(String.class);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package org.nl.sso.controller;
|
||||
|
||||
import cn.dev33.satoken.sso.SaSsoManager;
|
||||
import cn.dev33.satoken.sso.SaSsoProcessor;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
|
||||
import cn.dev33.satoken.sso.SaSsoUtil;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.sso.base.util.UserUtil;
|
||||
import org.springframework.http.*;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
|
||||
/*
|
||||
@@ -20,33 +19,25 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
@RequestMapping("auth")
|
||||
public class LoginController {
|
||||
|
||||
//首页登入测试页面
|
||||
@RequestMapping("/login")
|
||||
public ModelAndView login(ModelAndView mv) {
|
||||
String authUrl = SaSsoManager.getConfig().splicingAuthUrl();
|
||||
mv.setViewName("login");
|
||||
mv.addObject("title","上海诺力欢迎你");
|
||||
mv.addObject("authUrl",authUrl+"?mode=simple&redirect=http://localhost:8080/home");
|
||||
mv.addObject("isLogin",StpUtil.isLogin());
|
||||
return mv;
|
||||
}
|
||||
//获取用户信息:包括权限角色菜单等
|
||||
@RequestMapping("/info")
|
||||
public String userInfo() {
|
||||
String totalInfo = UserUtil.getUserInfo().getTotalInfo();
|
||||
return totalInfo;
|
||||
public ResponseEntity<Object> userInfo() {
|
||||
Object body = SaSsoUtil.getUserinfo(UserUtil.getUserInfo().getId());
|
||||
if (body !=null){
|
||||
String info = (String) body;
|
||||
return ResponseEntity.ok(JSONObject.parseObject(info));
|
||||
}
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
//首页登入测试页面
|
||||
@RequestMapping("/logout")
|
||||
public ResponseEntity logout() {
|
||||
SaSsoProcessor.instance.ssoLogout();
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@RequestMapping("/sso/logoutCall")
|
||||
public void logoutCall() {
|
||||
System.out.println("-----"+"服务端回调注销");
|
||||
SaSsoProcessor.instance.ssoLogoutCall();
|
||||
}
|
||||
// @RequestMapping("/sso/logoutCall")
|
||||
// public void logoutCall() {
|
||||
// System.out.println("-----"+"服务端回调注销用,");
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
/*! layer mobile-v2.0.0 Web弹层组件 MIT License http://layer.layui.com/mobile By 贤心 */
|
||||
;!function(e){"use strict";var t=document,n="querySelectorAll",i="getElementsByClassName",a=function(e){return t[n](e)},s={type:0,shade:!0,shadeClose:!0,fixed:!0,anim:"scale"},l={extend:function(e){var t=JSON.parse(JSON.stringify(s));for(var n in e)t[n]=e[n];return t},timer:{},end:{}};l.touch=function(e,t){e.addEventListener("click",function(e){t.call(this,e)},!1)};var r=0,o=["layui-m-layer"],c=function(e){var t=this;t.config=l.extend(e),t.view()};c.prototype.view=function(){var e=this,n=e.config,s=t.createElement("div");e.id=s.id=o[0]+r,s.setAttribute("class",o[0]+" "+o[0]+(n.type||0)),s.setAttribute("index",r);var l=function(){var e="object"==typeof n.title;return n.title?'<h3 style="'+(e?n.title[1]:"")+'">'+(e?n.title[0]:n.title)+"</h3>":""}(),c=function(){"string"==typeof n.btn&&(n.btn=[n.btn]);var e,t=(n.btn||[]).length;return 0!==t&&n.btn?(e='<span yes type="1">'+n.btn[0]+"</span>",2===t&&(e='<span no type="0">'+n.btn[1]+"</span>"+e),'<div class="layui-m-layerbtn">'+e+"</div>"):""}();if(n.fixed||(n.top=n.hasOwnProperty("top")?n.top:100,n.style=n.style||"",n.style+=" top:"+(t.body.scrollTop+n.top)+"px"),2===n.type&&(n.content='<i></i><i class="layui-m-layerload"></i><i></i><p>'+(n.content||"")+"</p>"),n.skin&&(n.anim="up"),"msg"===n.skin&&(n.shade=!1),s.innerHTML=(n.shade?"<div "+("string"==typeof n.shade?'style="'+n.shade+'"':"")+' class="layui-m-layershade"></div>':"")+'<div class="layui-m-layermain" '+(n.fixed?"":'style="position:static;"')+'><div class="layui-m-layersection"><div class="layui-m-layerchild '+(n.skin?"layui-m-layer-"+n.skin+" ":"")+(n.className?n.className:"")+" "+(n.anim?"layui-m-anim-"+n.anim:"")+'" '+(n.style?'style="'+n.style+'"':"")+">"+l+'<div class="layui-m-layercont">'+n.content+"</div>"+c+"</div></div></div>",!n.type||2===n.type){var d=t[i](o[0]+n.type),y=d.length;y>=1&&layer.close(d[0].getAttribute("index"))}document.body.appendChild(s);var u=e.elem=a("#"+e.id)[0];n.success&&n.success(u),e.index=r++,e.action(n,u)},c.prototype.action=function(e,t){var n=this;e.time&&(l.timer[n.index]=setTimeout(function(){layer.close(n.index)},1e3*e.time));var a=function(){var t=this.getAttribute("type");0==t?(e.no&&e.no(),layer.close(n.index)):e.yes?e.yes(n.index):layer.close(n.index)};if(e.btn)for(var s=t[i]("layui-m-layerbtn")[0].children,r=s.length,o=0;o<r;o++)l.touch(s[o],a);if(e.shade&&e.shadeClose){var c=t[i]("layui-m-layershade")[0];l.touch(c,function(){layer.close(n.index,e.end)})}e.end&&(l.end[n.index]=e.end)},e.layer={v:"2.0",index:r,open:function(e){var t=new c(e||{});return t.index},close:function(e){var n=a("#"+o[0]+e)[0];n&&(n.innerHTML="",t.body.removeChild(n),clearTimeout(l.timer[e]),delete l.timer[e],"function"==typeof l.end[e]&&l.end[e](),delete l.end[e])},closeAll:function(){for(var e=t[i](o[0]),n=0,a=e.length;n<a;n++)layer.close(0|e[0].getAttribute("index"))}},"function"==typeof define?define(function(){return layer}):function(){var e=document.scripts,n=e[e.length-1],i=n.src,a=i.substring(0,i.lastIndexOf("/")+1);n.getAttribute("merge")||document.head.appendChild(function(){var e=t.createElement("link");return e.href=a+"need/layer.css?2.0",e.type="text/css",e.rel="styleSheet",e.id="layermcss",e}())}()}(window);
|
||||
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 701 B |
|
Before Width: | Height: | Size: 1.7 KiB |
@@ -1,59 +0,0 @@
|
||||
*{margin: 0; padding: 0;}
|
||||
body{font-family: Helvetica Neue,Helvetica,PingFang SC,Tahoma,Arial,sans-serif;}
|
||||
::-webkit-input-placeholder{color: #ccc;}
|
||||
|
||||
/* 视图盒子 */
|
||||
.view-box{position: relative; width: 100vw; height: 100vh; overflow: hidden;}
|
||||
/* 背景 EAEFF3 */
|
||||
.bg-1{height: 50%; background: linear-gradient(to bottom right, #0466c5, #3496F5);}
|
||||
.bg-2{height: 50%; background-color: #EAEFF3;}
|
||||
|
||||
/* 渐变背景 */
|
||||
/*.bg-1{
|
||||
background-size: 500%;
|
||||
background-image: linear-gradient(125deg,#0466c5,#3496F5,#0466c5,#3496F5,#0466c5,#2496F5);
|
||||
animation: bganimation 30s infinite;
|
||||
}
|
||||
@keyframes bganimation{
|
||||
0%{background-position: 0% 50%;}
|
||||
50%{background-position: 100% 50%;}
|
||||
100%{background-position: 0% 50%;}
|
||||
} */
|
||||
/* 背景 */
|
||||
.bg-1{background: #101C34;}
|
||||
.bg-2{background: #101C34;}
|
||||
/* .bg-1{height: 100%; background-image: url(./login-bg.png); background-size: 100% 100%;} */
|
||||
|
||||
|
||||
/* 内容盒子 */
|
||||
.content-box{position: absolute; width: 100vw; height: 100vh; top: 0px;}
|
||||
|
||||
/* 登录盒子 */
|
||||
/* .login-box{width: 400px; height: 400px; position: absolute; left: calc(50% - 200px); top: calc(50% - 200px); max-width: 90%; } */
|
||||
.login-box{width: 400px; margin: auto; max-width: 90%; height: 100%;}
|
||||
.login-box{display: flex; align-items: center; text-align: center;}
|
||||
|
||||
/* 表单 */
|
||||
.from-box{flex: 1; padding: 20px 50px; background-color: #FFF;}
|
||||
.from-box{border-radius: 1px; box-shadow: 1px 1px 20px #666;}
|
||||
.from-title{margin-top: 20px; margin-bottom: 30px; text-align: center;}
|
||||
|
||||
/* 输入框 */
|
||||
.from-item{border: 0px #000 solid; margin-bottom: 15px;}
|
||||
.s-input{width: 100%; line-height: 32px; height: 32px; text-indent: 1em; outline: 0; border: 1px #ccc solid; border-radius: 3px; transition: all 0.2s;}
|
||||
.s-input{font-size: 12px;}
|
||||
.s-input:focus{border-color: #409eff}
|
||||
|
||||
/* 登录按钮 */
|
||||
.s-btn{ text-indent: 0; cursor: pointer; background-color: #409EFF; border-color: #409EFF; color: #FFF;}
|
||||
.s-btn:hover{background-color: #50aEFF;}
|
||||
|
||||
/* 重置按钮 */
|
||||
.reset-box{text-align: left; font-size: 12px;}
|
||||
.reset-box a{text-decoration: none;}
|
||||
.reset-box a:hover{text-decoration: underline;}
|
||||
|
||||
/* loading框样式 */
|
||||
.ajax-layer-load.layui-layer-dialog{min-width: 0px !important; background-color: rgba(0,0,0,0.85);}
|
||||
.ajax-layer-load.layui-layer-dialog .layui-layer-content{padding: 10px 20px 10px 40px; color: #FFF;}
|
||||
.ajax-layer-load.layui-layer-dialog .layui-layer-content .layui-layer-ico{width: 20px; height: 20px; background-size: 20px 20px; top: 12px; }
|
||||
@@ -1,65 +0,0 @@
|
||||
// sa
|
||||
var sa = {};
|
||||
|
||||
// 打开loading
|
||||
sa.loading = function(msg) {
|
||||
layer.closeAll(); // 开始前先把所有弹窗关了
|
||||
return layer.msg(msg, {icon: 16, shade: 0.3, time: 1000 * 20, skin: 'ajax-layer-load' });
|
||||
};
|
||||
|
||||
// 隐藏loading
|
||||
sa.hideLoading = function() {
|
||||
layer.closeAll();
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------- 登录事件 -----------------------------------
|
||||
|
||||
$('.login-btn').click(function(){
|
||||
sa.loading("正在登录...");
|
||||
// 开始登录
|
||||
setTimeout(function() {
|
||||
$.ajax({
|
||||
url: "sso/doLogin",
|
||||
type: "post",
|
||||
data: {
|
||||
name: $('[name=name]').val(),
|
||||
pwd: $('[name=pwd]').val()
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(res){
|
||||
console.log('返回数据:', res);
|
||||
sa.hideLoading();
|
||||
if(res.code == 200) {
|
||||
layer.msg('登录成功', {anim: 0, icon: 6 });
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
}, 800)
|
||||
} else {
|
||||
layer.msg(res.msg, {anim: 6, icon: 2 });
|
||||
}
|
||||
},
|
||||
error: function(xhr, type, errorThrown){
|
||||
sa.hideLoading();
|
||||
if(xhr.status == 0){
|
||||
return layer.alert('无法连接到服务器,请检查网络');
|
||||
}
|
||||
return layer.alert("异常:" + JSON.stringify(xhr));
|
||||
}
|
||||
});
|
||||
}, 400);
|
||||
});
|
||||
|
||||
// 绑定回车事件
|
||||
$('[name=name],[name=pwd]').bind('keypress', function(event){
|
||||
if(event.keyCode == "13") {
|
||||
$('.login-btn').click();
|
||||
}
|
||||
});
|
||||
|
||||
// 输入框获取焦点
|
||||
$("[name=name]").focus();
|
||||
|
||||
// 打印信息
|
||||
var str = "This page is provided by Sa-Token, Please refer to: " + "https://sa-token.cc/";
|
||||
console.log(str);
|
||||
@@ -1,17 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title th:text="${title}"></title>
|
||||
<base th:href="@{/}" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<link rel="stylesheet" href="./sa-res/login.css">
|
||||
</head>
|
||||
<body>
|
||||
<a th:text="${title}"></a>
|
||||
<a th:href="${authUrl}">登入</a>
|
||||
<a th:text="${isLogin}">当前登入状态:</a>
|
||||
|
||||
</body>
|
||||
</script>
|
||||
</html>
|
||||
@@ -32,6 +32,7 @@ public class CorsFilter implements Filter {
|
||||
response.setHeader("Access-Control-Max-Age", "3600");
|
||||
// 允许的header参数
|
||||
response.setHeader("Access-Control-Allow-Headers", "x-requested-with,satoken");
|
||||
response.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
|
||||
// 如果是预检请求,直接返回
|
||||
if (OPTIONS.equals(request.getMethod())) {
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.nl.modules.system.service.RoleService;
|
||||
import org.nl.modules.system.service.UserService;
|
||||
import org.nl.modules.system.service.dto.UserDto;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -130,7 +131,6 @@ public class AuthorizationController {
|
||||
put("token", "Bearer " + StpUtil.getTokenValue());
|
||||
put("user", user);
|
||||
}};
|
||||
|
||||
// 保存在线信息
|
||||
// onlineUserService.save(userDto, StpUtil.getTokenValue(), request);
|
||||
return ResponseEntity.ok(authInfo);
|
||||
@@ -154,6 +154,17 @@ public class AuthorizationController {
|
||||
return ResponseEntity.ok(jsonObject);
|
||||
}
|
||||
|
||||
@ApiOperation("获取指定用户信息")
|
||||
@GetMapping(value = "/userInfo")
|
||||
public ResponseEntity<Object> getUserInfo(Long loginId) {
|
||||
if (loginId != null){
|
||||
WQLObject userTab = WQLObject.getWQLObject("sys_user");
|
||||
JSONObject user = userTab.query("user_id = '" + loginId + "'").uniqueResult(0);
|
||||
return ResponseEntity.ok(user);
|
||||
}
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@ApiOperation("获取验证码")
|
||||
@GetMapping(value = "/code")
|
||||
public ResponseEntity<Object> getCode() {
|
||||
|
||||
@@ -7,14 +7,12 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.modules.system.domain.Role;
|
||||
import org.nl.modules.system.domain.vo.RoleVo;
|
||||
import org.nl.modules.system.service.RoleService;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -22,8 +20,8 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-03
|
||||
* @author ludj
|
||||
* @date 2022-12-05
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@@ -33,22 +31,6 @@ public class RoleController {
|
||||
|
||||
private final RoleService roleService;
|
||||
|
||||
private static final String ENTITY_NAME = "role";
|
||||
|
||||
@ApiOperation("获取单个role")
|
||||
@GetMapping(value = "/{id}")
|
||||
@SaCheckPermission("roles:list")
|
||||
public ResponseEntity<Object> query(@PathVariable Long id) {
|
||||
return new ResponseEntity<>(roleService.findById(id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("获取单个role")
|
||||
@GetMapping(value = "/all")
|
||||
// @SaCheckPermission("roles:list")
|
||||
public ResponseEntity<Object> query() {
|
||||
List<RoleVo> roles = roleService.findRoles(null, RoleVo.class);
|
||||
return new ResponseEntity<>(roles, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询角色")
|
||||
@GetMapping
|
||||
@@ -61,28 +43,27 @@ public class RoleController {
|
||||
@Log("新增角色")
|
||||
@ApiOperation("新增角色")
|
||||
@PostMapping
|
||||
@SaCheckPermission("roles:add")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody Role resources) {
|
||||
// roleService.create(resources);
|
||||
// @SaCheckPermission("roles:add")
|
||||
public ResponseEntity<Object> create(@RequestBody JSONObject param) {
|
||||
roleService.create(param);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
/* @Log("修改角色")
|
||||
@ApiOperation("修改角色")
|
||||
@PutMapping
|
||||
@SaCheckPermission("roles:edit")
|
||||
public ResponseEntity<Object> update(@Validated(Role.Update.class) @RequestBody Role resources) {
|
||||
getLevels(resources.getLevel());
|
||||
roleService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
*/
|
||||
@Log("修改角色")
|
||||
@ApiOperation("修改角色")
|
||||
@PutMapping
|
||||
// @SaCheckPermission("roles:edit")
|
||||
public ResponseEntity<Object> update(@RequestBody JSONObject param) {
|
||||
roleService.update(param);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("修改角色菜单")
|
||||
@ApiOperation("修改角色菜单")
|
||||
@PutMapping(value = "/menu")
|
||||
// @SaCheckPermission("roles:edit")
|
||||
public ResponseEntity<Object> updateMenu(@RequestBody JSONObject form) {
|
||||
String role_id = form.getString("id");
|
||||
String role_id = form.getString("role_id");
|
||||
JSONArray menus = form.getJSONArray("menus");
|
||||
WQLObject rmTab = WQLObject.getWQLObject("sys_roles_menus");
|
||||
rmTab.delete("role_id = " + role_id + "");
|
||||
|
||||
@@ -44,15 +44,6 @@ public interface RoleService {
|
||||
*/
|
||||
JSONObject queryAll(Map whereJson, Pageable page);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
<T> List<T> findRoles(Long id, Class<T>target);
|
||||
|
||||
RoleDto findById(Long id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param form /
|
||||
@@ -61,9 +52,9 @@ public interface RoleService {
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
* @param form /
|
||||
*/
|
||||
void update(Role resources);
|
||||
void update(JSONObject form);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
@@ -71,46 +62,6 @@ public interface RoleService {
|
||||
*/
|
||||
void delete(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询
|
||||
* @param id 用户ID
|
||||
* @return /
|
||||
*/
|
||||
List<RoleSmallDto> findByUsersId(Long id);
|
||||
|
||||
/**
|
||||
* 根据角色查询角色级别
|
||||
* @param roles /
|
||||
* @return /
|
||||
*/
|
||||
Integer findByRoles(Set<Role> roles);
|
||||
|
||||
/**
|
||||
* 修改绑定的菜单
|
||||
* @param resources /
|
||||
* @param roleDTO /
|
||||
*/
|
||||
void updateMenu(Role resources, RoleDto roleDTO);
|
||||
|
||||
/**
|
||||
* 解绑菜单
|
||||
* @param id /
|
||||
*/
|
||||
void untiedMenu(Long id);
|
||||
/**
|
||||
* 查询全部
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<RoleDto> queryAll(RoleQueryCriteria criteria);
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户权限信息
|
||||
* @param user 用户信息
|
||||
* @return 权限信息
|
||||
*/
|
||||
// List<String> mapToGrantedAuthorities(UserDto user);
|
||||
|
||||
/**
|
||||
* 通过id获取用户的权限
|
||||
@@ -119,6 +70,4 @@ public interface RoleService {
|
||||
*/
|
||||
List<String> getPermissionList(JSONObject userDto);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.Map;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "codeDetail")
|
||||
public class CodeDetailServiceImpl implements CodeDetailService {
|
||||
@Override
|
||||
public JSONObject queryAll(Map form, Pageable pageable) {
|
||||
|
||||
@@ -15,21 +15,19 @@
|
||||
*/
|
||||
package org.nl.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.common.utils.enums.DataScopeEnum;
|
||||
import org.nl.modules.system.domain.Dept;
|
||||
import org.nl.modules.system.domain.User;
|
||||
import org.nl.modules.system.service.DataService;
|
||||
import org.nl.modules.system.service.DeptService;
|
||||
import org.nl.modules.system.service.RoleService;
|
||||
import org.nl.modules.system.service.dto.RoleSmallDto;
|
||||
import org.nl.modules.system.service.dto.UserDto;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
@@ -39,7 +37,6 @@ import java.util.*;
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "data")
|
||||
public class DataServiceImpl implements DataService {
|
||||
|
||||
private final RoleService roleService;
|
||||
@@ -51,7 +48,6 @@ public class DataServiceImpl implements DataService {
|
||||
* @return /
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(key = "'user:' + #p0.id")
|
||||
public List<Long> getDeptIds(User user) {
|
||||
// 用于存储部门id
|
||||
Set<Long> deptIds = new HashSet<>();
|
||||
|
||||
@@ -57,7 +57,6 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "dept")
|
||||
public class DeptServiceImpl implements DeptService {
|
||||
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -41,18 +40,17 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-04-10
|
||||
*/
|
||||
* @author Zheng Jie
|
||||
* @date 2019-04-10
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "dict")
|
||||
public class DictDetailServiceImpl implements DictDetailService {
|
||||
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(DictDetailQueryCriteria criteria, Pageable pageable) {
|
||||
public Map<String, Object> queryAll(DictDetailQueryCriteria criteria, Pageable pageable) {
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("flag", "2");
|
||||
map.put("code", criteria.getCode());
|
||||
@@ -67,7 +65,7 @@ public class DictDetailServiceImpl implements DictDetailService {
|
||||
// 校验是否已经有标签
|
||||
JSONObject object = wo.query("label = '" + resources.getLabel() + "' " +
|
||||
"AND code = '" + resources.getDictCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(object)) throw new BadRequestException("标签["+ resources.getLabel() + "]已存在");
|
||||
if (ObjectUtil.isNotEmpty(object)) throw new BadRequestException("标签[" + resources.getLabel() + "]已存在");
|
||||
JSONObject dictObj = wo.query("code = '" + resources.getDictCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(dictObj.getString("label"))) {
|
||||
// 空就赋值
|
||||
@@ -116,7 +114,6 @@ public class DictDetailServiceImpl implements DictDetailService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'name:' + #p0")
|
||||
public List<DictDto> getDictByName(String name) {
|
||||
List<DictDto> dictDtos = this.findByDictName(name);
|
||||
return dictDtos;
|
||||
@@ -143,9 +140,10 @@ public class DictDetailServiceImpl implements DictDetailService {
|
||||
dictTab.delete(json);
|
||||
}
|
||||
|
||||
public void delCaches(DictDto dict){
|
||||
public void delCaches(DictDto dict) {
|
||||
redisUtils.del("dict::name:" + dict.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictDto findById(Long dict_id) {
|
||||
WQLObject wo = WQLObject.getWQLObject("sys_dict");
|
||||
|
||||
@@ -48,7 +48,6 @@ import java.util.*;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
//@CacheConfig(cacheNames = "dict")
|
||||
public class DictServiceImpl implements DictService {
|
||||
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
@@ -29,7 +29,6 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "menu")
|
||||
public class MenuServiceImpl implements MenuService {
|
||||
|
||||
|
||||
@@ -101,7 +100,6 @@ public class MenuServiceImpl implements MenuService {
|
||||
|
||||
|
||||
@Override
|
||||
// @Cacheable(key = "'id:' + #p0")
|
||||
public MenuDto findById(String id) {
|
||||
WQLObject menuTab = WQLObject.getWQLObject("sys_menu");
|
||||
JSONObject json = menuTab.query("menu_id = '" + id + "'").uniqueResult(0);
|
||||
@@ -115,7 +113,6 @@ public class MenuServiceImpl implements MenuService {
|
||||
* @return /
|
||||
*/
|
||||
@Override
|
||||
// @Cacheable(key = "'user:' + #p0")
|
||||
public List<MenuDto> findByUser(String currentUserId) {
|
||||
JSONArray arr = WQL.getWO("QSYS_MENU01").addParam("flag", "4").addParam("user_id", String.valueOf(currentUserId)).process().getResultJSONArray(0);
|
||||
List<MenuDto> list = new ArrayList<>();
|
||||
|
||||
@@ -15,46 +15,37 @@
|
||||
*/
|
||||
package org.nl.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.common.utils.CacheKey;
|
||||
import org.nl.modules.common.utils.RedisUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.system.domain.Role;
|
||||
import org.nl.modules.system.domain.User;
|
||||
import org.nl.modules.system.service.RoleService;
|
||||
import org.nl.modules.system.service.dto.RoleDto;
|
||||
import org.nl.modules.system.service.dto.RoleQueryCriteria;
|
||||
import org.nl.modules.system.service.dto.RoleSmallDto;
|
||||
import org.nl.modules.tools.MapOf;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.ResultBean;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.util.IdUtil;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-03
|
||||
* @author ludj
|
||||
* @date 2022-12-05
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "role")
|
||||
public class RoleServiceImpl implements RoleService {
|
||||
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
@Override
|
||||
public JSONObject queryAll(Map whereJson, Pageable page) {
|
||||
WQLObject wo = WQLObject.getWQLObject("sys_role");
|
||||
@@ -71,35 +62,19 @@ public class RoleServiceImpl implements RoleService {
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleDto> queryAll(RoleQueryCriteria criteria) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'id:' + #p0")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public <T> List<T> findRoles(Long id,Class<T> target) {
|
||||
String sql = "is_used = '1' and is_delete = '0' ";
|
||||
if (id != null){
|
||||
sql=sql+"role_id = '"+id+"'";
|
||||
}
|
||||
JSONArray array = WQLObject.getWQLObject("sys_role").query(sql).getResultJSONArray(0);
|
||||
return array.toJavaList(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleDto findById(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(JSONObject form) {
|
||||
//角色表【sys_role】
|
||||
//判断角色名字是否存在
|
||||
String name = form.getString("name");
|
||||
if (StrUtil.isEmpty(name)) throw new BadRequestException("角色名字不能为空!");
|
||||
WQLObject roleTab = WQLObject.getWQLObject("sys_role");
|
||||
|
||||
//判断角色名字是否存在
|
||||
JSONObject json = roleTab.query("name = '" + name + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) throw new BadRequestException("角色【" + name + "】已存在!");
|
||||
|
||||
|
||||
String role_id = IdUtil.getStringId();
|
||||
form.put("role_id", role_id);
|
||||
form.put("create_id", SecurityUtils.getCurrentUserId());
|
||||
@@ -109,24 +84,26 @@ public class RoleServiceImpl implements RoleService {
|
||||
form.put("update_name", SecurityUtils.getCurrentNickName());
|
||||
form.put("update_time", DateUtil.now());
|
||||
roleTab.insert(form);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(Role resources) {
|
||||
public void update(JSONObject form) {
|
||||
WQLObject roleTab = WQLObject.getWQLObject("sys_role");
|
||||
//判断角色名字是否存在
|
||||
String name = form.getString("name");
|
||||
if (StrUtil.isEmpty(name)) throw new BadRequestException("角色名字不能为空!");
|
||||
|
||||
}
|
||||
JSONObject json = roleTab.query("name = '" + name + "' and role_id <> '" + form.getString("role_id") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) throw new BadRequestException("角色【" + name + "】已存在!");
|
||||
|
||||
@Override
|
||||
public void updateMenu(Role resources, RoleDto roleDTO) {
|
||||
String now = DateUtil.now();
|
||||
form.put("update_id", StpUtil.getLoginIdAsLong());
|
||||
form.put("update_time", now);
|
||||
form.put("update_optname", SecurityUtils.getCurrentNickName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void untiedMenu(Long menuId) {
|
||||
|
||||
roleTab.update(form);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -141,21 +118,6 @@ public class RoleServiceImpl implements RoleService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleSmallDto> findByUsersId(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer findByRoles(Set<Role> roles) {
|
||||
Set<RoleDto> roleDtos = new HashSet<>();
|
||||
for (Role role : roles) {
|
||||
roleDtos.add(findById(role.getId()));
|
||||
}
|
||||
return Collections.min(roleDtos.stream().map(RoleDto::getLevel).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
// @Cacheable(key = "'auth:' + #p0.id")
|
||||
public List<String> getPermissionList(JSONObject userDto) {
|
||||
List<String> permission = new LinkedList<>();
|
||||
// 查看是否为管理员
|
||||
@@ -171,21 +133,4 @@ public class RoleServiceImpl implements RoleService {
|
||||
return permission;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
*
|
||||
* @param id /
|
||||
*/
|
||||
public void delCaches(Long id, List<User> users) {
|
||||
// users = CollectionUtil.isEmpty(users) ? userRepository.findByRoleId(id) : users;
|
||||
if (CollectionUtil.isNotEmpty(users)) {
|
||||
// users.forEach(item -> userCacheClean.cleanUserCache(item.getUsername()));
|
||||
Set<Long> userIds = users.stream().map(User::getId).collect(Collectors.toSet());
|
||||
redisUtils.delByKeys(CacheKey.DATA_USER, userIds);
|
||||
redisUtils.delByKeys(CacheKey.MENU_USER, userIds);
|
||||
redisUtils.delByKeys(CacheKey.ROLE_AUTH, userIds);
|
||||
}
|
||||
redisUtils.del(CacheKey.ROLE_ID + id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,21 +22,22 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.modules.common.config.FileProperties;
|
||||
import org.nl.modules.common.exception.EntityExistException;
|
||||
import org.nl.modules.common.exception.EntityNotFoundException;
|
||||
import org.nl.modules.common.utils.*;
|
||||
import org.nl.modules.common.utils.CacheKey;
|
||||
import org.nl.modules.common.utils.FileUtil;
|
||||
import org.nl.modules.common.utils.RedisUtils;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.utils.dto.CurrentUser;
|
||||
import org.nl.modules.security.service.OnlineUserService;
|
||||
import org.nl.modules.system.domain.User;
|
||||
import org.nl.modules.system.service.DeptService;
|
||||
import org.nl.modules.system.service.UserRelateService;
|
||||
import org.nl.modules.system.service.UserService;
|
||||
|
||||
import org.nl.modules.system.service.dto.UserQueryCriteria;
|
||||
import org.nl.modules.tools.MapOf;
|
||||
import org.nl.modules.wql.WQL;
|
||||
@@ -44,17 +45,13 @@ import org.nl.modules.wql.core.bean.ResultBean;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -64,7 +61,6 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "user")
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
private final FileProperties properties;
|
||||
@@ -124,7 +120,6 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'id:' + #p0")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public User findById(long id) {
|
||||
JSONObject result = WQLObject.getWQLObject("sys_user").query("user_id = '" + id + "'").uniqueResult(0);
|
||||
@@ -228,7 +223,6 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'username:' + #p0")
|
||||
public User findByName(String userName) {
|
||||
JSONObject result = WQLObject.getWQLObject("sys_user").query("userName = '" + userName + "'").uniqueResult(0);
|
||||
if (result == null) {
|
||||
|
||||
@@ -4,6 +4,8 @@ import cn.hutool.db.Db;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.wql.WQLCore;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.jdbc.datasource.DataSourceUtils;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
@@ -78,8 +80,8 @@ public class DBPoolSpring {
|
||||
Connection conn = null;
|
||||
try {
|
||||
DataSource dataSource = SpringContextHolder.getBean(name);
|
||||
conn=Db.use(dataSource).getConnection();
|
||||
// conn = DataSourceUtils.getConnection(dataSource);
|
||||
// conn=Db.use(dataSource).getConnection();
|
||||
conn = DataSourceUtils.getConnection(dataSource);
|
||||
} catch (Exception e) {
|
||||
log.error("不能获得Spring连接池中的数据库连接:" + e.toString());
|
||||
}
|
||||
@@ -120,9 +122,10 @@ public class DBPoolSpring {
|
||||
// conn.close();
|
||||
// }
|
||||
DataSource dataSource = (DataSource) SpringContextHolder.getBean(name);
|
||||
// DataSourceUtils.releaseConnection(conn, dataSource);
|
||||
DataSourceUtils.releaseConnection(conn, dataSource);
|
||||
|
||||
Db.use(dataSource).closeConnection(conn);
|
||||
|
||||
/* Db.use(dataSource).closeConnection(conn);*/
|
||||
// } catch (SQLException e) {
|
||||
// log.error("数据库连接关闭:"+e.toString() );
|
||||
// }
|
||||
|
||||
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 3.2 KiB |
BIN
nladmin-ui/src/assets/images/logo1.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
nladmin-ui/src/assets/logo/logo.63028018.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
@@ -11,7 +11,8 @@ const baseURLStr = window.g.prod.VUE_APP_BASE_API
|
||||
// 创建axios实例
|
||||
const service = axios.create({
|
||||
baseURL: process.env.NODE_ENV === 'production' ? baseURLStr : '/', // api 的 base_url
|
||||
timeout: Config.timeout // 请求超时时间
|
||||
timeout: Config.timeout, // 请求超时时间
|
||||
withCredentials: true
|
||||
})
|
||||
|
||||
// request拦截器
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="login" :style="'background-image:url('+ Background +');'">
|
||||
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" label-position="left" label-width="0px" class="login-form">
|
||||
<h3 class="title">
|
||||
{{title}}</h3>
|
||||
{{ title }}</h3>
|
||||
<el-form-item prop="username">
|
||||
<el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="账号">
|
||||
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
|
||||
@@ -133,8 +133,13 @@ export default {
|
||||
Cookies.remove('rememberMe')
|
||||
}
|
||||
this.$store.dispatch('Login', user).then(() => {
|
||||
debugger
|
||||
this.loading = false
|
||||
this.$router.push({ path: this.redirect || '/' })
|
||||
window.location.href = this.redirect
|
||||
// if (this.redirect === 'http://localhost:8013/dashboard'){
|
||||
// window.location.href = this.redirect
|
||||
// }
|
||||
// this.$router.push({ path: this.redirect || '/' })
|
||||
}).catch(() => {
|
||||
this.loading = false
|
||||
this.getCode()
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="permission" label="权限标识" :min-width="flexWidth('permission',crud.data,'权限标识')" />
|
||||
<el-table-column prop="component" label="组件路径" :min-width="flexWidth('component',crud.data,'组件路径')" />
|
||||
<el-table-column prop="component" label="组件路径" min-width="120" />
|
||||
<el-table-column prop="i_frame" label="外链" :formatter="crud.formatIsOrNot" :min-width="flexWidth('i_frame',crud.data,'外链')" />
|
||||
|
||||
<el-table-column prop="cache" label="缓存" :formatter="crud.formatIsOrNot" :min-width="flexWidth('cache',crud.data,'缓存')" />
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
class="filter-item"
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
<rrOperation />
|
||||
<rrOperation/>
|
||||
</div>
|
||||
<crudOperation :permission="permission" />
|
||||
<crudOperation :permission="permission"/>
|
||||
</div>
|
||||
<!-- 表单渲染 -->
|
||||
<el-dialog
|
||||
@@ -28,10 +28,10 @@
|
||||
>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="mini" label-width="80px">
|
||||
<el-form-item label="角色名称" prop="name">
|
||||
<el-input v-model="form.name" style="width: 380px;" />
|
||||
<el-input v-model="form.name" style="width: 380px;"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="description">
|
||||
<el-input v-model="form.description" style="width: 380px;" rows="2" type="textarea" />
|
||||
<el-input v-model="form.description" style="width: 380px;" rows="2" type="textarea"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
@@ -55,9 +55,9 @@
|
||||
@selection-change="crud.selectionChangeHandler"
|
||||
@current-change="handleCurrentChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="name" label="名称" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column show-overflow-tooltip prop="description" label="描述" />
|
||||
<el-table-column type="selection" width="55"/>
|
||||
<el-table-column prop="name" label="名称" min-width="100" show-overflow-tooltip/>
|
||||
<el-table-column show-overflow-tooltip prop="description" label="描述"/>
|
||||
<el-table-column show-overflow-tooltip width="135px" prop="createTime" label="创建日期">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||
@@ -79,7 +79,7 @@
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
<pagination/>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<!-- 菜单授权 -->
|
||||
@@ -130,14 +130,13 @@ import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import DateRangePicker from '@/components/DateRangePicker'
|
||||
|
||||
const defaultForm = { id: null, name: null, description: null }
|
||||
const defaultForm = { role_id: null, name: null, description: null }
|
||||
export default {
|
||||
name: 'Role',
|
||||
components: { pagination, crudOperation, rrOperation, udOperation, DateRangePicker, crudMenu },
|
||||
components: { pagination, crudOperation, rrOperation, udOperation, crudMenu },
|
||||
cruds() {
|
||||
return CRUD({ title: '角色', url: 'api/roles', crudMethod: { ...crudRoles }})
|
||||
return CRUD({ idField: 'role_id', title: '角色', url: 'api/roles', crudMethod: { ...crudRoles } })
|
||||
},
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
data() {
|
||||
@@ -238,7 +237,7 @@ export default {
|
||||
// 保存菜单
|
||||
saveMenu() {
|
||||
this.menuLoading = true
|
||||
const role = { id: this.currentId, menus: [] }
|
||||
const role = { role_id: this.currentId, menus: [] }
|
||||
// 得到已选中的 key 值
|
||||
this.menuIds.forEach(function(menu_id) {
|
||||
const menu = { menu_id: menu_id }
|
||||
|
||||