.
This commit is contained in:
@@ -30,15 +30,15 @@
|
|||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class="pull-right">
|
<li class="pull-right">
|
||||||
<select v-model="sysPlat" class="form-control" style="border: 0;background-color: #404a53;color: #fff;">
|
<a @click="logout()" href="javascript:;" style="padding: 6px 15px;border: 0;background-color: #404a53;color: #fff;">
|
||||||
<option v-for="item in sysPlats" :value="item" v-text="item.name"></option>
|
<i class="icon icon-user"></i> 退出
|
||||||
</select>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class="pull-right">
|
<li class="pull-right">
|
||||||
<a style="padding: 6px 15px;border: 0;background-color: #404a53;color: #fff;">
|
<select v-model="sysPlat" class="form-control" style="border: 0;background-color: #404a53;color: #fff;">
|
||||||
<i class="icon icon-user"></i> root
|
<option v-for="item in sysPlats" :value="item" v-text="item.name"></option>
|
||||||
</a>
|
</select>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -111,11 +111,14 @@
|
|||||||
{name: "关于", url: "/single/about.html"}
|
{name: "关于", url: "/single/about.html"}
|
||||||
|
|
||||||
],
|
],
|
||||||
menus: red.getData("menus", [
|
menus: red.getData("menus", {name: "MetaData", url: "/meta", nodes: [
|
||||||
{url:"/qtask/plat.html", name:"业务平台"},
|
/*{url:"/metadata/metatable/list.html", name:"TableList"},*/
|
||||||
{url:"/qtask/list.html", name:"QTask"},
|
{url:"/metadata/metatable/metaTable.html", name:"MetaTable"},
|
||||||
{url:"/qtask/debug.html", name:"QT-Debug"},
|
/*{url:"/metadata/metaLink.html", name:"MetaLink"},*/
|
||||||
]),
|
{url:"/metadata/metaService.html", name:"MetaService"},
|
||||||
|
{url:"/metadata/dataList.html", name:"数据查询"},
|
||||||
|
]
|
||||||
|
}),
|
||||||
page: red.getData("page", {url:"/qtask/list.html", name:"QTask"}),
|
page: red.getData("page", {url:"/qtask/list.html", name:"QTask"}),
|
||||||
pageId: red.getData("pageId", "QTask")
|
pageId: red.getData("pageId", "QTask")
|
||||||
},
|
},
|
||||||
@@ -143,6 +146,14 @@
|
|||||||
loadMain: function (item) {
|
loadMain: function (item) {
|
||||||
this.menus = item.nodes || [item];
|
this.menus = item.nodes || [item];
|
||||||
this.pageId = item.name;
|
this.pageId = item.name;
|
||||||
|
},
|
||||||
|
logout: function () {
|
||||||
|
red.getJSON("/user/logout",{}, function () {
|
||||||
|
red.showMsg({msg:"退出成功"});
|
||||||
|
setTimeout(() => {
|
||||||
|
location.href = "/user/login.html";
|
||||||
|
}, 2000)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
.tlist>li.active>a:hover,
|
.tlist>li.active>a:hover,
|
||||||
.tlist>li>a:hover {
|
.tlist>li>a:hover {
|
||||||
background-color: #92b0cb;
|
background-color: #92b0cb;
|
||||||
|
border-bottom: 2px solid #607d8b;
|
||||||
|
color: #fff;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<row class="meta-service">
|
<row class="meta-service">
|
||||||
|
|||||||
@@ -28,21 +28,23 @@ body {
|
|||||||
}
|
}
|
||||||
#top a {
|
#top a {
|
||||||
color: #ddd;
|
color: #ddd;
|
||||||
|
font-size: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#top .nav-tabs{
|
#top .nav-tabs{
|
||||||
border-bottom:0;
|
border-bottom:0;
|
||||||
}
|
}
|
||||||
.nav-tabs>li>a{
|
#top>.nav-tabs>li>a{
|
||||||
border: 0;
|
border: 0;
|
||||||
font-size: 15px;
|
|
||||||
}
|
}
|
||||||
|
#top>.nav-tabs>li.active>a,
|
||||||
.nav-tabs>li.active>a, .nav-tabs>li.active>a:focus, .nav-tabs>li.active>a:hover, .nav-tabs>li>a:hover {
|
#top>.nav-tabs>li.active>a:focus,
|
||||||
|
#top>.nav-tabs>li.active>a:hover,
|
||||||
|
#top>.nav-tabs>li>a:hover {
|
||||||
background-color: #404a53;
|
background-color: #404a53;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
border: 0;
|
border: 0;
|
||||||
border-bottom: 2px solid #607d8b;
|
border-bottom: 3px solid #607d8b;
|
||||||
}
|
}
|
||||||
|
|
||||||
#left {
|
#left {
|
||||||
|
|||||||
@@ -100,12 +100,12 @@
|
|||||||
doc:"sys_plat",
|
doc:"sys_plat",
|
||||||
shows: JSON.stringify(["_id", "_key", "name", "token","remark", "status"])
|
shows: JSON.stringify(["_id", "_key", "name", "token","remark", "status"])
|
||||||
};
|
};
|
||||||
red.getJSON("/meta/find", para, function (json) {
|
red.getJSON("/meta/plat_list", {}, function (json) {
|
||||||
vm.sysPlats = json.rows;
|
vm.sysPlats = json;
|
||||||
if (!vm.sysPlat) {
|
if (!vm.sysPlat) {
|
||||||
vm.sysPlat = json.rows[0];
|
vm.sysPlat = json[0];
|
||||||
}
|
}
|
||||||
red.setData("sysPlats", json.rows);
|
red.setData("sysPlats", json);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
goIndex: function () {
|
goIndex: function () {
|
||||||
|
|||||||
@@ -2,12 +2,17 @@ package net.tccn.service;
|
|||||||
|
|
||||||
import com.arangodb.ArangoDBException;
|
import com.arangodb.ArangoDBException;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import net.tccn.base.JBean;
|
||||||
import net.tccn.base.Kv;
|
import net.tccn.base.Kv;
|
||||||
import net.tccn.base.arango.ArangoSource;
|
import net.tccn.base.arango.ArangoSource;
|
||||||
|
import net.tccn.user.User;
|
||||||
|
import net.tccn.user.UserService;
|
||||||
import org.redkale.net.http.HttpRequest;
|
import org.redkale.net.http.HttpRequest;
|
||||||
import org.redkale.net.http.HttpResponse;
|
import org.redkale.net.http.HttpResponse;
|
||||||
|
import org.redkale.net.http.HttpScope;
|
||||||
import org.redkale.net.http.HttpServlet;
|
import org.redkale.net.http.HttpServlet;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -17,6 +22,9 @@ import java.util.logging.Logger;
|
|||||||
*/
|
*/
|
||||||
public class BaseServlet extends HttpServlet {
|
public class BaseServlet extends HttpServlet {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
public Logger logger = Logger.getLogger(this.getClass().getSimpleName());
|
public Logger logger = Logger.getLogger(this.getClass().getSimpleName());
|
||||||
protected static Gson gson = new Gson();
|
protected static Gson gson = new Gson();
|
||||||
|
|
||||||
@@ -31,8 +39,8 @@ public class BaseServlet extends HttpServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sessionid != null) {
|
if (sessionid != null) {
|
||||||
//User user = userService.current(sessionid);
|
User user = userService.current(sessionid);
|
||||||
//request.setCurrentUser(user);
|
request.setCurrentUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.preExecute(request, response);
|
super.preExecute(request, response);
|
||||||
@@ -40,7 +48,7 @@ public class BaseServlet extends HttpServlet {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void authenticate(HttpRequest request, HttpResponse response) throws IOException {
|
protected void authenticate(HttpRequest request, HttpResponse response) throws IOException {
|
||||||
/* fixme: 权限拦截
|
//fixme: 权限拦截
|
||||||
if (request.currentUser() == null) {
|
if (request.currentUser() == null) {
|
||||||
if ("XMLHttpRequest".equals(request.getHeader("X-Requested-With"))){
|
if ("XMLHttpRequest".equals(request.getHeader("X-Requested-With"))){
|
||||||
response.finish(JBean.by(-2, "未登陆"));
|
response.finish(JBean.by(-2, "未登陆"));
|
||||||
@@ -48,7 +56,7 @@ public class BaseServlet extends HttpServlet {
|
|||||||
response.finish(HttpScope.refer("/user/login.html"));
|
response.finish(HttpScope.refer("/user/login.html"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}*/
|
}
|
||||||
super.authenticate(request, response);
|
super.authenticate(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -199,4 +199,13 @@ public class MetadataService extends BaseService { //arango
|
|||||||
return JBean.by(0, "");
|
return JBean.by(0, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RestMapping(name = "plat_list", comment = "平台列表")
|
||||||
|
public JBean platList() {
|
||||||
|
JBean jBean = new JBean();
|
||||||
|
List<SysPlat> plats = SysPlat.dao.find();
|
||||||
|
|
||||||
|
jBean.setBody(plats);
|
||||||
|
return jBean;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
108
src/main/java/net/tccn/user/User.java
Normal file
108
src/main/java/net/tccn/user/User.java
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
package net.tccn.user;
|
||||||
|
|
||||||
|
import net.tccn.base.JBean;
|
||||||
|
import net.tccn.base.arango.Doc;
|
||||||
|
import org.redkale.convert.ConvertColumn;
|
||||||
|
import org.redkale.convert.ConvertType;
|
||||||
|
import org.redkale.convert.json.JsonConvert;
|
||||||
|
import org.redkale.util.Utility;
|
||||||
|
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: liangxianyou at 2018/11/22 17:37.
|
||||||
|
*/
|
||||||
|
@Table(name = "sys_user", catalog = "db_dev")
|
||||||
|
public class User extends Doc<User> {
|
||||||
|
public static User dao = dao(User.class);
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
private String pwd;
|
||||||
|
private Long createTime;
|
||||||
|
private Long loginTime;
|
||||||
|
private Integer status;
|
||||||
|
private String sessionid;
|
||||||
|
|
||||||
|
public User() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public User(String sessionid) {
|
||||||
|
this.sessionid = sessionid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConvertColumn(ignore = true,type = ConvertType.JSON)
|
||||||
|
public String getPwd() {
|
||||||
|
return pwd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPwd(String pwd) {
|
||||||
|
this.pwd = pwd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Long createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getLoginTime() {
|
||||||
|
return loginTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoginTime(Long loginTime) {
|
||||||
|
this.loginTime = loginTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Integer status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSessionid() {
|
||||||
|
return sessionid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSessionid(String sessionid) {
|
||||||
|
this.sessionid = sessionid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return JsonConvert.root().convertTo(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------
|
||||||
|
|
||||||
|
public static String md5IfNeed(String password){
|
||||||
|
if (password == null || password.length() == 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return Utility.md5Hex(password);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JBean checkLogin(String pwd) {
|
||||||
|
JBean jBean = JBean.by(0, "");
|
||||||
|
|
||||||
|
if (!this.pwd.equalsIgnoreCase(md5IfNeed(pwd))) {
|
||||||
|
jBean.set(-1, "密码错误");
|
||||||
|
} else if (status != 1) {
|
||||||
|
jBean.set(-1, "登陆失败,限制登陆。");
|
||||||
|
}
|
||||||
|
jBean.setBody(this);
|
||||||
|
return jBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
56
src/main/java/net/tccn/user/UserService.java
Normal file
56
src/main/java/net/tccn/user/UserService.java
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
package net.tccn.user;
|
||||||
|
|
||||||
|
import net.tccn.base.JBean;
|
||||||
|
import net.tccn.service.BaseService;
|
||||||
|
import org.redkale.net.http.RestMapping;
|
||||||
|
import org.redkale.net.http.RestService;
|
||||||
|
import org.redkale.net.http.RestSessionid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: liangxianyou at 2018/11/22 17:16.
|
||||||
|
*/
|
||||||
|
@RestService(name = "user", automapping = true, comment = "用户服务")
|
||||||
|
public class UserService extends BaseService {
|
||||||
|
|
||||||
|
@RestMapping(name = "login", auth = false, comment = "登陆验证")
|
||||||
|
public JBean login(@RestSessionid String sessionid,
|
||||||
|
String username,
|
||||||
|
String pwd) {
|
||||||
|
User bean = new User();
|
||||||
|
bean.setUsername(username);
|
||||||
|
|
||||||
|
User user = User.dao.findFirst(bean);
|
||||||
|
if (user == null) {
|
||||||
|
return JBean.by(-1, "登陆失败:账号无效");
|
||||||
|
}
|
||||||
|
|
||||||
|
JBean jBean = user.checkLogin(pwd);
|
||||||
|
if (jBean.getCode() == 0) {
|
||||||
|
cacheSource.set(30 * 60 * 2,sessionid, User.class, user);
|
||||||
|
|
||||||
|
user.setSessionid(sessionid);
|
||||||
|
user.setLoginTime(System.currentTimeMillis());
|
||||||
|
user.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
return jBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RestMapping(name = "current")
|
||||||
|
public User current(@RestSessionid String sessionid) {
|
||||||
|
return getT("user_" + sessionid, User.class, () -> User.dao.findFirst(new User(sessionid)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RestMapping(name = "logout", comment = "退出登陆")
|
||||||
|
public JBean logout(@RestSessionid String sessionid) {
|
||||||
|
User user = User.dao.findFirst(new User(sessionid));
|
||||||
|
if (user != null) {
|
||||||
|
user.setSessionid("");
|
||||||
|
user.update();
|
||||||
|
}
|
||||||
|
cacheSource.removeAsync("user_" + sessionid);
|
||||||
|
|
||||||
|
return new JBean();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -39,7 +39,7 @@ public class RunTest<T> {
|
|||||||
//System.out.println(query.getClass());
|
//System.out.println(query.getClass());
|
||||||
}
|
}
|
||||||
ParseMysql parser = new ParseMysql();
|
ParseMysql parser = new ParseMysql();
|
||||||
@Test
|
//@Test
|
||||||
public void parseFBeanTest() {
|
public void parseFBeanTest() {
|
||||||
FBean fBean = new Gson().fromJson("{name:'user_service', filters:[{col:'a.username',type:'like',value:'lxy'}], orders:[{col:a.`id`,desc: -1},{col:a.`deptName`,desc: 1}], limit:{ps:2,pn:10}}", FBean.class);
|
FBean fBean = new Gson().fromJson("{name:'user_service', filters:[{col:'a.username',type:'like',value:'lxy'}], orders:[{col:a.`id`,desc: -1},{col:a.`deptName`,desc: 1}], limit:{ps:2,pn:10}}", FBean.class);
|
||||||
|
|
||||||
@@ -96,8 +96,8 @@ public class RunTest<T> {
|
|||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
|
|
||||||
System.out.println("--------------");
|
System.out.println("--------------");
|
||||||
Date date1 = Kv.toAs("Sun Mar 17 12:11:12 CST 2019", Date.class);
|
//Date date1 = Kv.toAs("Sun Mar 17 12:11:12 CST 2019", Date.class);
|
||||||
System.out.println(date1);
|
//System.out.println(date1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user