Skip to content

Commit

Permalink
simple authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
sunzhengjie committed Oct 28, 2017
1 parent 57df7f5 commit fdab233
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import esform.dao.ControlDao;
import esform.domain.Control;
import esform.response.Response;
import esform.util.Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
Expand All @@ -30,6 +31,7 @@ public class ControlResource {
@ResponseBody
public Response add(@RequestBody OperateControlRequest request) {
Control domain = request.getDomain();
Util.trace(domain,true);
controlDao.add(domain);
return Response.ok();
}
Expand Down
30 changes: 30 additions & 0 deletions server/web/src/main/java/esform/util/Util.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package esform.util;

import esform.domain.BaseDomain;
import esform.domain.User;
import esform.filter.OauthFilter;

import java.util.Date;

/**
* Created by
*
* @name:孙证杰
* @email:[email protected] on 2017/10/28.
*/
public class Util {

public static void trace(BaseDomain domain, boolean isCreate){
User user = OauthFilter.getUser();
if(null == user){
throw new RuntimeException("not authorized");
}
Date now = new Date();
if(isCreate){
domain.setCreateBy(user.getUserName());
domain.setCreateDt(now);
}
domain.setUpdateBy(user.getUserName());
domain.setUpdateDt(now);
}
}
2 changes: 1 addition & 1 deletion ui/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
assetsPublicPath: '/',
proxyTable: {
'/esview': {
target: 'http://47.94.2.0:8080',
target: 'http://localhost:8080',
changeOrigin: true,
pathRewrite: {
'^/esview': '/esview'
Expand Down
4 changes: 4 additions & 0 deletions ui/src/resource/auth_resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function register() {
if(res.data.code === 10000){
this.$router.push('./')
store.commit('userModule/changePage','manage')
}else {
this.$Message.error(res.data.msg)
}
})
}
Expand All @@ -22,6 +24,8 @@ function login() {
if(res.data.code === 10000){
this.$router.push('/')
store.commit('userModule/changePage','manage')
}else {
this.$Message.error(res.data.msg)
}
})
}
Expand Down
5 changes: 4 additions & 1 deletion ui/src/store/user_module.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Vue from 'vue'
export default {
namespaced: true,
state: {
me: 1,
me: {},
page: "manage", //test
controlClazzes: []
},
Expand All @@ -12,6 +12,9 @@ export default {
controlClazzes: ({controlClazzes}) => controlClazzes
},
mutations: {
setMe(state,me){
state.me = me
},
changePage(state, page){
state.page = page
},
Expand Down
166 changes: 83 additions & 83 deletions ui/src/view/esview/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,93 @@ export default{
}
},
mounted() {
let accessToken = getCookie("access_token");
if(!accessToken) store.commit('userModule/changePage', 'login')
this.getControlClazzes()
let res = {
"code": 10000,
"msg": "ok",
"data": [
{
"id": 1,
"name": "esview",
"title": "esview",
"url": "/esview",
"orderNo": 1,
"mtype": 0,
"hasPermisson": 1,
"subMenuList": [
{
"id": 2,
"name": "s",
"title": "Assemble",
"url": "/esview/assemble",
"orderNo": 1,
"mtype": 0,
"icon": 'wrench',
"hasPermisson": 1,
"subMenuList": [
{
"id": 3,
"name": "ManageApp",
"title": "ManageApp",
"url": "/esview/assemble/manage_app",
"orderNo": 1,
"mtype": 1,
"hasPermisson": 1,
"subMenuList": null
},
{
"id": 4,
"name": "AssemblePage",
"title": "AssemblePage",
"url": "/esview/assemble/assemble_page",
"orderNo": 2,
"mtype": -1,
"hasPermisson": 1,
"subMenuList": null
}
]
},
{
"id": 74842,
"name": "develop",
"title": "Develop",
"url": "/esview/develop",
"orderNo": 1,
"mtype": 0,
"icon": 'upload',
"hasPermisson": 1,
"subMenuList": [
{
"id": 74840,
"name": "index",
"title": "ManageControl",
"url": "/esview/develop/index",
"orderNo": 1,
"mtype": 1,
"hasPermisson": 1,
"subMenuList": null
},
{
"id": 74796,
"name": "add_control",
"title": "OperateControl",
"url": "/esview/develop/operate_control",
"orderNo": 1,
"mtype": -1,
"hasPermisson": 1,
"subMenuList": null
}
]
}
]
}
]
}
this.totalMenu = res.data;
this.routes = getPages(this.totalMenu);
initRouter(this.routes);
Expand All @@ -209,88 +290,7 @@ export default{
}
}
this.userInfo = res.data;
store.commit('userModule/setMe',this.userInfo)
}
}
let res = {
"code": 10000,
"msg": "ok",
"data": [
{
"id": 1,
"name": "esview",
"title": "esview",
"url": "/esview",
"orderNo": 1,
"mtype": 0,
"hasPermisson": 1,
"subMenuList": [
{
"id": 2,
"name": "s",
"title": "Assemble",
"url": "/esview/assemble",
"orderNo": 1,
"mtype": 0,
"icon": 'wrench',
"hasPermisson": 1,
"subMenuList": [
{
"id": 3,
"name": "ManageApp",
"title": "ManageApp",
"url": "/esview/assemble/manage_app",
"orderNo": 1,
"mtype": 1,
"hasPermisson": 1,
"subMenuList": null
},
{
"id": 4,
"name": "AssemblePage",
"title": "AssemblePage",
"url": "/esview/assemble/assemble_page",
"orderNo": 2,
"mtype": -1,
"hasPermisson": 1,
"subMenuList": null
}
]
},
{
"id": 74842,
"name": "develop",
"title": "Develop",
"url": "/esview/develop",
"orderNo": 1,
"mtype": 0,
"icon": 'upload',
"hasPermisson": 1,
"subMenuList": [
{
"id": 74840,
"name": "index",
"title": "ManageControl",
"url": "/esview/develop/index",
"orderNo": 1,
"mtype": 1,
"hasPermisson": 1,
"subMenuList": null
},
{
"id": 74796,
"name": "add_control",
"title": "OperateControl",
"url": "/esview/develop/operate_control",
"orderNo": 1,
"mtype": -1,
"hasPermisson": 1,
"subMenuList": null
}
]
}
]
}
]
}
</script>
Loading

0 comments on commit fdab233

Please sign in to comment.