Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
aserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
15所TongWeb
aserver
Commits
126e943e
Commit
126e943e
authored
Jul 15, 2020
by
Dyml
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.archser.com/common/aserver
# Conflicts: # src/main/resources/DBUpdate/DM_UpdateSQL.xml
parents
7ab9c9f3
2be259fa
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
134 additions
and
46 deletions
+134
-46
pom.xml
pom.xml
+13
-3
MainConfig.java
...in/java/com/archser/aserver/common/config/MainConfig.java
+5
-0
IndexController.java
.../java/com/archser/aserver/controller/IndexController.java
+67
-39
UserController.java
...n/java/com/archser/aserver/controller/UserController.java
+42
-2
DM_UpdateSQL.xml
src/main/resources/DBUpdate/DM_UpdateSQL.xml
+7
-2
No files found.
pom.xml
View file @
126e943e
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
</properties>
</properties>
<!-- 使用阿里 maven 库 -->
<!-- 使用阿里 maven 库 -->
<repositories>
<repositories>
<repository>
<repository>
<id>
nexus
</id>
<id>
nexus
</id>
<url>
http://nexus.archser.com:8081/repository/maven-public/
</url>
<url>
http://nexus.archser.com:8081/repository/maven-public/
</url>
...
@@ -88,7 +88,17 @@
...
@@ -88,7 +88,17 @@
</dependency>
</dependency>
<dependency>
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
<version>
2.9.0
</version>
</dependency>
<dependency>
<groupId>
de.ruedigermoeller
</groupId>
<artifactId>
fst
</artifactId>
<version>
2.50
</version>
</dependency>
<dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<groupId>
com.alibaba
</groupId>
...
@@ -123,7 +133,7 @@
...
@@ -123,7 +133,7 @@
</dependency>
</dependency>
<!-- webSocket 开始
-->
<!-- webSocket 开始
-->
<dependency>
<dependency>
<groupId>
javax.websocket
</groupId>
<groupId>
javax.websocket
</groupId>
...
@@ -144,7 +154,7 @@
...
@@ -144,7 +154,7 @@
<scope>
provided
</scope>
<scope>
provided
</scope>
</dependency>
</dependency>
<!-- webSocket 结束
-->
<!-- webSocket 结束
-->
<dependency>
<dependency>
<groupId>
org.apache.dubbo
</groupId>
<groupId>
org.apache.dubbo
</groupId>
...
...
src/main/java/com/archser/aserver/common/config/MainConfig.java
View file @
126e943e
...
@@ -29,6 +29,7 @@ import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
...
@@ -29,6 +29,7 @@ import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import
com.jfinal.plugin.activerecord.CaseInsensitiveContainerFactory
;
import
com.jfinal.plugin.activerecord.CaseInsensitiveContainerFactory
;
import
com.jfinal.plugin.activerecord.dialect.OracleDialect
;
import
com.jfinal.plugin.activerecord.dialect.OracleDialect
;
import
com.jfinal.plugin.druid.DruidPlugin
;
import
com.jfinal.plugin.druid.DruidPlugin
;
import
com.jfinal.plugin.redis.RedisPlugin
;
import
com.jfinal.render.ViewType
;
import
com.jfinal.render.ViewType
;
import
com.jfinal.server.undertow.UndertowServer
;
import
com.jfinal.server.undertow.UndertowServer
;
import
com.jfinal.server.undertow.WebBuilder
;
import
com.jfinal.server.undertow.WebBuilder
;
...
@@ -130,6 +131,10 @@ public class MainConfig extends JFinalConfig {
...
@@ -130,6 +131,10 @@ public class MainConfig extends JFinalConfig {
me
.
add
(
dbPlugin
);
me
.
add
(
dbPlugin
);
me
.
add
(
arp
);
me
.
add
(
arp
);
// 添加Redis 配置
RedisPlugin
redis
=
new
RedisPlugin
(
"redis"
,
PropKit
.
get
(
"redis.url"
),
PropKit
.
get
(
"redis.password"
));
me
.
add
(
redis
);
}
}
...
...
src/main/java/com/archser/aserver/controller/IndexController.java
View file @
126e943e
...
@@ -2,24 +2,22 @@ package com.archser.aserver.controller;
...
@@ -2,24 +2,22 @@ package com.archser.aserver.controller;
import
java.math.BigInteger
;
import
java.math.BigInteger
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Map.Entry
;
import
java.util.Optional
;
import
java.util.Optional
;
import
org.bouncycastle.crypto.InvalidCipherTextException
;
import
org.bouncycastle.crypto.InvalidCipherTextException
;
import
org.bouncycastle.crypto.params.ECPrivateKeyParameters
;
import
org.bouncycastle.crypto.params.ECPrivateKeyParameters
;
import
org.bouncycastle.pqc.math.linearalgebra.ByteUtils
;
import
org.bouncycastle.pqc.math.linearalgebra.ByteUtils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.archser.aserver.interceptor.JwtInterceptor
;
import
com.archser.aserver.interceptor.JwtInterceptor
;
import
com.archser.aserver.model.System
;
import
com.archser.aserver.model.System
;
import
com.archser.aserver.model.User
;
import
com.archser.aserver.model.User
;
import
com.archser.aserver.service.LogService
;
import
com.archser.aserver.service.LogService
;
import
com.archser.aserver.service.UserService
;
import
com.archser.aserver.service.UserService
;
import
com.archser.aserver.util.CollectionUtil
;
import
com.archser.aserver.util.HttpRequestUtil
;
import
com.archser.aserver.util.HttpRequestUtil
;
import
com.archser.aserver.util.KeysUtil
;
import
com.archser.aserver.util.KeysUtil
;
import
com.archser.aserver.util.gm.BCECUtil
;
import
com.archser.aserver.util.gm.BCECUtil
;
...
@@ -35,6 +33,7 @@ import com.jfinal.kit.StrKit;
...
@@ -35,6 +33,7 @@ import com.jfinal.kit.StrKit;
import
com.jfinal.log.Log
;
import
com.jfinal.log.Log
;
import
com.jfinal.plugin.activerecord.Db
;
import
com.jfinal.plugin.activerecord.Db
;
import
com.jfinal.plugin.activerecord.Record
;
import
com.jfinal.plugin.activerecord.Record
;
import
com.jfinal.plugin.redis.Redis
;
import
com.spbportal.sso.SsoToken
;
import
com.spbportal.sso.SsoToken
;
import
io.jsonwebtoken.JwsHeader
;
import
io.jsonwebtoken.JwsHeader
;
...
@@ -68,7 +67,6 @@ public class IndexController extends Controller {
...
@@ -68,7 +67,6 @@ public class IndexController extends Controller {
@Inject
@Inject
private
UserService
userService
;
private
UserService
userService
;
/**
/**
* 首页Action
* 首页Action
*/
*/
...
@@ -103,13 +101,12 @@ public class IndexController extends Controller {
...
@@ -103,13 +101,12 @@ public class IndexController extends Controller {
* 登录验证
* 登录验证
*/
*/
@Clear
(
JwtInterceptor
.
class
)
@Clear
(
JwtInterceptor
.
class
)
// @Before(LoginValidator.class)
// @Before(LoginValidator.class)
public
void
login
()
{
public
void
login
()
{
String
app
=
this
.
getPara
(
"app"
);
String
app
=
this
.
getPara
(
"app"
);
String
username
=
this
.
getPara
(
"username"
);
String
username
=
this
.
getPara
(
"username"
);
String
password
=
this
.
getPara
(
"password"
);
String
password
=
this
.
getPara
(
"password"
);
String
callback
=
this
.
getPara
(
"callback"
);
String
callback
=
this
.
getPara
(
"callback"
);
// 解密用户名和密码
// 解密用户名和密码
try
{
try
{
username
=
decrypt
(
username
);
username
=
decrypt
(
username
);
...
@@ -119,10 +116,7 @@ public class IndexController extends Controller {
...
@@ -119,10 +116,7 @@ public class IndexController extends Controller {
username
=
this
.
getPara
(
"username"
);
username
=
this
.
getPara
(
"username"
);
password
=
this
.
getPara
(
"password"
);
password
=
this
.
getPara
(
"password"
);
}
}
password
=
HashKit
.
sha256
(
password
);
password
=
HashKit
.
sha256
(
password
);
java
.
lang
.
System
.
out
.
println
(
"Login: "
+
username
);
User
user
=
User
.
dao
.
template
(
"getUser"
,
username
).
findFirst
();
User
user
=
User
.
dao
.
template
(
"getUser"
,
username
).
findFirst
();
if
(
user
==
null
)
{
if
(
user
==
null
)
{
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"用户名或密码不存在: "
+
username
));
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"用户名或密码不存在: "
+
username
));
...
@@ -205,21 +199,21 @@ public class IndexController extends Controller {
...
@@ -205,21 +199,21 @@ public class IndexController extends Controller {
}
}
//查询用户是否有该系统的权限
//查询用户是否有该系统的权限
// boolean homeAuth = userService.checkUserSystemPermission(user.getId(), app);
// boolean homeAuth = userService.checkUserSystemPermission(user.getId(), app);
// if (!homeAuth) {
// if (!homeAuth) {
// this.renderJson(Ret.fail("msg", "您没有权限登录" + system.getTitle() + "系统"));
// this.renderJson(Ret.fail("msg", "您没有权限登录" + system.getTitle() + "系统"));
// logService.saveAsLog("login", username, JwtInterceptor.getIpAddr(getRequest()), "登录失败,原因:您没有权限登录此系统" + app,
// logService.saveAsLog("login", username, JwtInterceptor.getIpAddr(getRequest()), "登录失败,原因:您没有权限登录此系统" + app,
// app);
// app);
// return;
// return;
// }
// }
List
<
System
>
systemList
=
userService
.
findSystemWithUserPermission
(
user
.
getId
());
List
<
System
>
systemList
=
userService
.
findSystemWithUserPermission
(
user
.
getId
());
/** 修改如果登陆用户为admin用户则直接登陆 huwenbin 2020/5/20 start
*/
/** 修改如果登陆用户为admin用户则直接登陆 huwenbin 2020/5/20 start
*/
if
(!
"admin"
.
equals
(
user
.
getUsername
()))
{
if
(!
"admin"
.
equals
(
user
.
getUsername
()))
{
if
((
systemList
==
null
||
systemList
.
isEmpty
()))
{
if
((
systemList
==
null
||
systemList
.
isEmpty
()))
{
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"您没有权限登录"
+
system
.
getTitle
()
+
"系统"
));
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"您没有权限登录"
+
system
.
getTitle
()
+
"系统"
));
logService
.
saveAsLog
(
"login"
,
username
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"登录失败,原因:您没有权限登录此系统"
+
app
,
logService
.
saveAsLog
(
"login"
,
username
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
app
);
"登录失败,原因:您没有权限登录此系统"
+
app
,
app
);
return
;
return
;
}
}
...
@@ -249,9 +243,28 @@ public class IndexController extends Controller {
...
@@ -249,9 +243,28 @@ public class IndexController extends Controller {
if
(
errorcount
!=
null
&&
errorcount
!=
0
)
{
if
(
errorcount
!=
null
&&
errorcount
!=
0
)
{
this
.
setErrZero
(
user
);
this
.
setErrZero
(
user
);
}
}
/**
* 20200706 lidecai 将用户信息保存到Redis start
*/
Map
<
Object
,
Object
>
userInfo
=
new
HashMap
<>();
Iterator
<
Entry
<
String
,
Object
>>
userIterator
=
user
.
_getAttrsEntrySet
().
iterator
();
Entry
<
String
,
Object
>
nextAttr
=
null
;
while
(
userIterator
.
hasNext
())
{
nextAttr
=
userIterator
.
next
();
userInfo
.
put
(
nextAttr
.
getKey
().
trim
().
toLowerCase
(),
nextAttr
.
getValue
());
}
try
{
Redis
.
use
().
hmset
(
username
+
"_INFO"
,
userInfo
);
// 设置过期时间
Redis
.
use
().
expire
(
username
,
60
*
60
*
24
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
this
.
renderJson
(
Ret
.
ok
(
"token"
,
jws
).
set
(
"callback"
,
callback
));
this
.
renderJson
(
Ret
.
ok
(
"token"
,
jws
).
set
(
"callback"
,
callback
));
logService
.
saveAsLog
(
"login"
,
username
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
logService
.
saveAsLog
(
"login"
,
username
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
username
+
"登录"
+
app
+
"成功"
,
app
);
username
+
"登录"
+
app
+
"成功"
,
app
);
/**
* 20200706 lidecai 将用户信息保存到Redis end
*/
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"生成登录票据失败"
,
e
);
log
.
error
(
"生成登录票据失败"
,
e
);
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"生成登录票据失败"
));
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"生成登录票据失败"
));
...
@@ -266,23 +279,25 @@ public class IndexController extends Controller {
...
@@ -266,23 +279,25 @@ public class IndexController extends Controller {
//密码错误时判断错误次数是否为5次
//密码错误时判断错误次数是否为5次
private
boolean
checkErrorCount
(
User
user
)
{
private
boolean
checkErrorCount
(
User
user
)
{
Kv
cond
=
Kv
.
by
(
"id"
,
user
.
getId
()).
set
(
"hour"
,
hour
).
set
(
"permitLoginTimes"
,
permitLoginTimes
);
Kv
cond
=
Kv
.
by
(
"id"
,
user
.
getId
()).
set
(
"hour"
,
hour
).
set
(
"permitLoginTimes"
,
permitLoginTimes
);
List
<
Record
>
currentList
=
Db
.
find
(
Db
.
getSqlPara
(
"getErrorCount"
,
cond
));
List
<
Record
>
currentList
=
Db
.
find
(
Db
.
getSqlPara
(
"getErrorCount"
,
cond
));
int
currentNum
=
0
;
int
currentNum
=
0
;
for
(
Record
record
:
currentList
)
{
for
(
Record
record
:
currentList
)
{
currentNum
=
Integer
.
parseInt
(
record
.
get
(
"flag"
).
toString
());
currentNum
=
Integer
.
parseInt
(
record
.
get
(
"flag"
).
toString
());
}
}
if
(
currentNum
>=
permitLoginTimes
)
{
if
(
currentNum
>=
permitLoginTimes
)
{
return
true
;
return
true
;
}
else
{
}
else
{
//执行+1或=1的操作
//执行+1或=1的操作
Db
.
update
(
Db
.
getSqlPara
(
"updateForErr"
,
cond
));
Db
.
update
(
Db
.
getSqlPara
(
"updateForErr"
,
cond
));
return
false
;
return
false
;
}
}
}
}
//密码正确时判断次数和锁定时间是否在指定范围内
//密码正确时判断次数和锁定时间是否在指定范围内
private
boolean
checkWhenPwdOk
(
User
user
)
{
private
boolean
checkWhenPwdOk
(
User
user
)
{
List
<
Record
>
currentList
=
Db
.
find
(
Db
.
getSqlPara
(
"checkWhenPwdOk"
,
Kv
.
by
(
"id"
,
user
.
getId
()).
set
(
"hour"
,
hour
).
set
(
"permitLoginTimes"
,
permitLoginTimes
)));
List
<
Record
>
currentList
=
Db
.
find
(
Db
.
getSqlPara
(
"checkWhenPwdOk"
,
Kv
.
by
(
"id"
,
user
.
getId
()).
set
(
"hour"
,
hour
).
set
(
"permitLoginTimes"
,
permitLoginTimes
)));
int
currentNum
=
0
;
int
currentNum
=
0
;
if
(
currentList
==
null
||
currentList
.
size
()
==
0
)
{
if
(
currentList
==
null
||
currentList
.
size
()
==
0
)
{
return
true
;
return
true
;
...
@@ -290,9 +305,9 @@ public class IndexController extends Controller {
...
@@ -290,9 +305,9 @@ public class IndexController extends Controller {
for
(
Record
record
:
currentList
)
{
for
(
Record
record
:
currentList
)
{
currentNum
=
Integer
.
parseInt
(
record
.
get
(
"flag"
).
toString
());
currentNum
=
Integer
.
parseInt
(
record
.
get
(
"flag"
).
toString
());
}
}
if
(
currentNum
>=
permitLoginTimes
)
{
if
(
currentNum
>=
permitLoginTimes
)
{
return
false
;
return
false
;
}
else
{
}
else
{
return
true
;
return
true
;
}
}
}
}
...
@@ -306,10 +321,10 @@ public class IndexController extends Controller {
...
@@ -306,10 +321,10 @@ public class IndexController extends Controller {
public
void
ssoByPortalSystem
()
{
public
void
ssoByPortalSystem
()
{
try
{
try
{
//获取app
//获取app
String
app
=
getPara
(
"app"
,
null
);
String
app
=
getPara
(
"app"
,
null
);
if
(
app
==
null
)
{
if
(
app
==
null
)
{
renderJson
(
Ret
.
fail
(
"msg"
,
"获取服务信息失败"
));
renderJson
(
Ret
.
fail
(
"msg"
,
"获取服务信息失败"
));
return
;
return
;
}
}
//获取到门户系统的Token
//获取到门户系统的Token
String
ssotoken
=
getPara
(
"ssotoken"
);
String
ssotoken
=
getPara
(
"ssotoken"
);
...
@@ -320,12 +335,12 @@ public class IndexController extends Controller {
...
@@ -320,12 +335,12 @@ public class IndexController extends Controller {
//获取用户
//获取用户
Record
user
=
userService
.
getUserInfoByPersonCode
(
personCode
);
Record
user
=
userService
.
getUserInfoByPersonCode
(
personCode
);
System
system
=
System
.
dao
.
template
(
"getSystemPrivatekey"
,
app
).
findFirst
();
System
system
=
System
.
dao
.
template
(
"getSystemPrivatekey"
,
app
).
findFirst
();
if
(
system
==
null
)
{
if
(
system
==
null
)
{
renderJson
(
Ret
.
fail
(
"msg"
,
"获取服务信息失败"
));
renderJson
(
Ret
.
fail
(
"msg"
,
"获取服务信息失败"
));
return
;
return
;
}
}
//判断用户是否存在
//判断用户是否存在
if
(
user
!=
null
&&
user
.
getStr
(
"username"
)
!=
null
)
{
if
(
user
!=
null
&&
user
.
getStr
(
"username"
)
!=
null
)
{
String
jws
=
Jwts
.
builder
()
String
jws
=
Jwts
.
builder
()
// 设置密匙ID
// 设置密匙ID
.
setHeaderParam
(
JwsHeader
.
KEY_ID
,
system
.
getKeyid
())
.
setHeaderParam
(
JwsHeader
.
KEY_ID
,
system
.
getKeyid
())
...
@@ -341,14 +356,14 @@ public class IndexController extends Controller {
...
@@ -341,14 +356,14 @@ public class IndexController extends Controller {
.
signWith
(
KeysUtil
.
privatekey
(
system
.
getPrivatekey
()),
SignatureAlgorithm
.
RS256
).
compact
();
.
signWith
(
KeysUtil
.
privatekey
(
system
.
getPrivatekey
()),
SignatureAlgorithm
.
RS256
).
compact
();
this
.
renderJson
(
Ret
.
ok
(
"token"
,
jws
));
this
.
renderJson
(
Ret
.
ok
(
"token"
,
jws
));
return
;
return
;
}
else
{
}
else
{
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"没有找到当前用户"
));
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"没有找到当前用户"
));
return
;
return
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
// TODO: handle exception
// TODO: handle exception
e
.
printStackTrace
();
e
.
printStackTrace
();
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"登录出错!"
));
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"登录出错!"
));
}
}
}
}
...
@@ -442,6 +457,19 @@ public class IndexController extends Controller {
...
@@ -442,6 +457,19 @@ public class IndexController extends Controller {
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"生成登录票据失败"
));
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"生成登录票据失败"
));
logService
.
saveAsLog
(
"login"
,
userName
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"生成登录票据失败"
,
app
);
logService
.
saveAsLog
(
"login"
,
userName
,
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"生成登录票据失败"
,
app
);
}
}
}
/**
* 退出系统,清空Redis 中的用户信息
* @Time:2020年7月6日 - 下午5:19:58
* @author:李德才
* @param:
* @return: void
* @throws
*/
public
void
loginOut
()
{
String
userName
=
getAttrForStr
(
"username"
);
Redis
.
use
().
del
(
userName
+
"_INFO"
);
renderJson
(
Ret
.
ok
());
}
}
}
}
src/main/java/com/archser/aserver/controller/UserController.java
View file @
126e943e
package
com
.
archser
.
aserver
.
controller
;
package
com
.
archser
.
aserver
.
controller
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
com.archser.aserver.model.User
;
import
com.archser.aserver.model.User
;
import
com.archser.aserver.service.UserService
;
import
com.archser.aserver.service.UserService
;
...
@@ -11,6 +17,7 @@ import com.jfinal.kit.Kv;
...
@@ -11,6 +17,7 @@ import com.jfinal.kit.Kv;
import
com.jfinal.kit.Ret
;
import
com.jfinal.kit.Ret
;
import
com.jfinal.plugin.activerecord.Db
;
import
com.jfinal.plugin.activerecord.Db
;
import
com.jfinal.plugin.activerecord.Record
;
import
com.jfinal.plugin.activerecord.Record
;
import
com.jfinal.plugin.redis.Redis
;
/**
/**
* 用户相关操作
* 用户相关操作
...
@@ -22,6 +29,9 @@ public class UserController extends Controller {
...
@@ -22,6 +29,9 @@ public class UserController extends Controller {
@Inject
@Inject
UserService
userService
;
UserService
userService
;
private
static
final
String
_INFO
=
"_INFO"
;
/**
/**
* 获取用户信息
* 获取用户信息
*/
*/
...
@@ -34,8 +44,8 @@ public class UserController extends Controller {
...
@@ -34,8 +44,8 @@ public class UserController extends Controller {
/**
/**
* 修改用户密码
* 修改用户密码
* @throws SQLException
*/
*/
@SuppressWarnings
(
"unused"
)
public
void
updatePwd
()
{
public
void
updatePwd
()
{
String
username
=
this
.
getAttr
(
"username"
);
String
username
=
this
.
getAttr
(
"username"
);
String
password
=
this
.
getPara
(
"newPwd"
);
String
password
=
this
.
getPara
(
"newPwd"
);
...
@@ -43,6 +53,12 @@ public class UserController extends Controller {
...
@@ -43,6 +53,12 @@ public class UserController extends Controller {
int
flag
=
Db
.
update
(
Db
.
getSql
(
"updatePassword"
),
password
,
username
);
int
flag
=
Db
.
update
(
Db
.
getSql
(
"updatePassword"
),
password
,
username
);
if
(
flag
==
0
)
{
if
(
flag
==
0
)
{
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"修改失败"
));
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
"修改失败"
));
return
;
}
try
{
Redis
.
use
().
hset
(
username
+
_INFO
,
"password"
,
password
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
this
.
renderJson
(
Ret
.
ok
(
"msg"
,
"修改成功"
));
this
.
renderJson
(
Ret
.
ok
(
"msg"
,
"修改成功"
));
}
}
...
@@ -58,6 +74,7 @@ public class UserController extends Controller {
...
@@ -58,6 +74,7 @@ public class UserController extends Controller {
}
}
boolean
flag
=
user
.
update
();
boolean
flag
=
user
.
update
();
if
(
flag
)
{
if
(
flag
)
{
updateUserForRedis
(
user
);
renderJson
(
Ret
.
ok
(
"msg"
,
"数据修改成功!"
));
renderJson
(
Ret
.
ok
(
"msg"
,
"数据修改成功!"
));
return
;
return
;
}
else
{
}
else
{
...
@@ -66,9 +83,32 @@ public class UserController extends Controller {
...
@@ -66,9 +83,32 @@ public class UserController extends Controller {
}
}
/**
/**
* 修改Redis中的用户信息
*@Time:2020年7月10日 - 上午8:48:48
* @author:李德才
* @param: @param user
* @return: void
* @throws
*/
public
void
updateUserForRedis
(
User
user
)
{
try
{
Iterator
<
Entry
<
String
,
Object
>>
userIterator
=
user
.
_getAttrsEntrySet
().
iterator
();
Map
<
Object
,
Object
>
userMap
=
new
HashMap
<>();
Entry
<
String
,
Object
>
userAttr
=
null
;
while
(
userIterator
.
hasNext
())
{
userAttr
=
userIterator
.
next
();
userMap
.
put
(
userAttr
.
getKey
().
toString
().
trim
().
toLowerCase
(),
userAttr
.
getValue
());
}
Redis
.
use
().
hmset
(
user
.
getUsername
()
+
_INFO
,
userMap
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
/**
* 查询角色
* 查询角色
*/
*/
@SuppressWarnings
(
"unused"
)
public
void
getRoleData
()
{
public
void
getRoleData
()
{
String
username
=
this
.
getAttr
(
"username"
);
String
username
=
this
.
getAttr
(
"username"
);
User
user
=
User
.
dao
.
template
(
"getUser"
,
username
).
findFirst
();
User
user
=
User
.
dao
.
template
(
"getUser"
,
username
).
findFirst
();
...
...
src/main/resources/DBUpdate/DM_UpdateSQL.xml
View file @
126e943e
...
@@ -764,12 +764,17 @@
...
@@ -764,12 +764,17 @@
alter table AS_CHECK_RECORD_RESULT add(DATASIGN1 VARCHAR2(200));
alter table AS_CHECK_RECORD_RESULT add(DATASIGN1 VARCHAR2(200));
</sql>
</sql>
</version>
</version>
<version
edition=
"43"
description=
"档案分类排序"
>
<version
edition=
"43"
description=
"序列"
>
<sql
creator=
"yangrifei"
createDate=
"20200715"
note=
"序列"
>
CREATE SEQUENCE "SEQ_AS_VIDEO_TRANSITION" INCREMENT BY 1 START WITH 1 MAXVALUE 9223372036854775807 MINVALUE 1;
</sql>
</version>
<version
edition=
"44"
description=
"档案分类排序"
>
<sql
creator=
"xiaoying"
createDate=
"20200703"
note=
"档案分类排序"
>
<sql
creator=
"xiaoying"
createDate=
"20200703"
note=
"档案分类排序"
>
alter table AS_TREECLASSFIC add(SERIALINDEX VARCHAR2(500));
alter table AS_TREECLASSFIC add(SERIALINDEX VARCHAR2(500));
</sql>
</sql>
</version>
</version>
<version
edition=
"4
4"
description=
"添加全宗信息表"
>
<version
edition=
"4
5"
description=
"添加全宗信息表"
>
<sql
creator=
"yangchengwu"
createDate=
"20200715"
note=
"全宗信息表"
>
<sql
creator=
"yangchengwu"
createDate=
"20200715"
note=
"全宗信息表"
>
CREATE TABLE "ARCHSER_YZ"."AS_FOND"
CREATE TABLE "ARCHSER_YZ"."AS_FOND"
(
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment