Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gs1-office-web-sit
Overview
Overview
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
吴迪
gs1-office-web-sit
Commits
cc63386c
Commit
cc63386c
authored
Dec 17, 2021
by
唐功亮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改】 登录接口 增加手机号用户登录
parent
63b24814
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
4 deletions
+101
-4
LogLoginServiceImpl.java
...fice/modules/manage/service/impl/LogLoginServiceImpl.java
+57
-4
DESUtils.java
src/main/java/io/office/modules/manage/utils/DESUtils.java
+44
-0
No files found.
src/main/java/io/office/modules/manage/service/impl/LogLoginServiceImpl.java
View file @
cc63386c
package
io
.
office
.
modules
.
manage
.
service
.
impl
;
package
io
.
office
.
modules
.
manage
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
io.office.common.exception.RRException
;
import
io.office.common.exception.RRException
;
import
io.office.common.utils.IPUtils
;
import
io.office.common.utils.IPUtils
;
import
io.office.common.utils.R
;
import
io.office.common.utils.R
;
import
io.office.modules.manage.dao.MemberDao
;
import
io.office.modules.manage.dao.MemberDao
;
import
io.office.modules.manage.entity.MemberEntity
;
import
io.office.modules.manage.entity.MemberEntity
;
import
io.office.modules.manage.utils.DESUtils
;
import
io.office.modules.manage.utils.HttpUtlis
;
import
io.office.modules.manage.utils.MD5Util
;
import
io.office.modules.manage.utils.MD5Util
;
import
io.office.modules.sys.service.SysUserTokenService
;
import
io.office.modules.sys.service.SysUserTokenService
;
import
org.apache.commons.httpclient.HttpClient
;
import
org.apache.commons.httpclient.methods.GetMethod
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.io.IOException
;
import
java.security.SecureRandom
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
...
@@ -66,11 +73,35 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity
...
@@ -66,11 +73,35 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity
Integer
levels
=
null
;
//用户权限 空.代表普通用户 0.代表中心管理员,1.代表校验管理员 其他4位.代表分中心管理员
Integer
levels
=
null
;
//用户权限 空.代表普通用户 0.代表中心管理员,1.代表校验管理员 其他4位.代表分中心管理员
Integer
isQY
=
2
;
//是否开通企业认证 1.开通 2.未开通
Integer
isQY
=
2
;
//是否开通企业认证 1.开通 2.未开通
Integer
isXT
=
2
;
//是否是业务大厅系统成员 1.是 2.否
Integer
isXT
=
2
;
//是否是业务大厅系统成员 1.是 2.否
Integer
id
=
0
;
//用户ID
Integer
id
=
0
;
//用户ID
String
search
=
"ws2"
;
// 用户来源 manager:业务大厅手机号用户 ws2:member表用户
String
carno
=
null
;
// 条码卡号
String
phone
=
null
;
//手机号码
//判断用户是否是手机号 是手机号调用 第三方接口登录 不是继续
//判断用户是否是手机号 是手机号调用 第三方接口登录 不是继续
if
(
matchPhoneNumber
(
userName
)){
if
(
matchPhoneNumber
(
userName
)){
//
TODO tgl 调
用第三方登录接口
//用第三方登录接口
userType
=
1
;
userType
=
1
;
//对 用户名密码进行DES加密
String
phoen_M
=
DESUtils
.
byteToHexString
(
DESUtils
.
DES_CBC_Encrypt
(
userName
.
getBytes
(),
DESUtils
.
Key
.
getBytes
()));
String
passwrod_M
=
DESUtils
.
byteToHexString
(
DESUtils
.
DES_CBC_Encrypt
(
passWord
.
getBytes
(),
DESUtils
.
Key
.
getBytes
()));
String
url
=
"http://wsdt.gs1cn.org/anccoh/login?method=loginValidate&phone="
+
phoen_M
+
"&password="
+
passwrod_M
;
String
s
=
doGet
(
url
);
if
(
s
==
null
){
throw
new
RRException
(
"服务器繁忙,登录失败"
);
}
else
{
JSONObject
jsonObject
=
JSON
.
parseObject
(
s
);
String
status
=
jsonObject
.
getString
(
"status"
);
if
(!
status
.
equals
(
"1"
)){
throw
new
RRException
(
"登录失败"
+
jsonObject
.
getString
(
"msg"
));
}
else
{
//登录成功
search
=
"manager"
;
phone
=
userName
;
//TODO tgl 需要中国编码官网提供 条码卡数据 来判断是否是系统用户
}
}
}
else
{
}
else
{
//查询Member表
//查询Member表
MemberEntity
memberEntity
=
memberDao
.
selectByName
(
userName
);
MemberEntity
memberEntity
=
memberDao
.
selectByName
(
userName
);
...
@@ -85,6 +116,7 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity
...
@@ -85,6 +116,7 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity
userType
=
3
;
userType
=
3
;
}
else
{
//条码卡用户
}
else
{
//条码卡用户
userType
=
2
;
userType
=
2
;
carno
=
userName
;
}
}
//获取权限
//获取权限
levels
=
memberDao
.
selectCode_agen
(
userName
);
levels
=
memberDao
.
selectCode_agen
(
userName
);
...
@@ -103,7 +135,7 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity
...
@@ -103,7 +135,7 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity
if
(
user
==
null
){
if
(
user
==
null
){
throw
new
RRException
(
"用户不存在!"
);
throw
new
RRException
(
"用户不存在!"
);
}
}
String
phone
=
user
.
getPhone
();
phone
=
user
.
getPhone
();
String
password
=
user
.
getPass
();
String
password
=
user
.
getPass
();
String
passwordMD5
=
MD5Util
.
md5Encrypt32Upper
(
passWord
);
String
passwordMD5
=
MD5Util
.
md5Encrypt32Upper
(
passWord
);
//判断密码是否正确
//判断密码是否正确
...
@@ -112,10 +144,10 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity
...
@@ -112,10 +144,10 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity
}
}
//TODO tgl 参数不正确添加登录日志 log_login
//添加登录日志 log_login
logLoginDao
.
insert
(
new
LogLoginEntity
(
1
,
userName
,
"用户来源"
,
"条码卡号"
,
phone
,
new
Date
(),
IPUtils
.
getIpAddr
(
request
),
request
.
getRequestURL
().
toString
()));
}
}
logLoginDao
.
insert
(
new
LogLoginEntity
(
1
,
userName
,
search
,
carno
,
phone
,
new
Date
(),
IPUtils
.
getIpAddr
(
request
),
request
.
getRequestURL
().
toString
()));
JSONObject
jsonObject
=
new
JSONObject
();
JSONObject
jsonObject
=
new
JSONObject
();
...
@@ -142,4 +174,24 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity
...
@@ -142,4 +174,24 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity
}
}
return
Pattern
.
matches
(
regex
,
phoneNumber
);
return
Pattern
.
matches
(
regex
,
phoneNumber
);
}
}
private
static
String
doGet
(
String
url
)
{
HttpClient
client
=
new
HttpClient
();
GetMethod
getMethod
=
new
GetMethod
(
url
);
int
code
=
0
;
try
{
code
=
client
.
executeMethod
(
getMethod
);
if
(
code
==
200
)
{
String
res
=
getMethod
.
getResponseBodyAsString
();
return
res
;
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
}
\ No newline at end of file
src/main/java/io/office/modules/manage/utils/DESUtils.java
0 → 100644
View file @
cc63386c
package
io
.
office
.
modules
.
manage
.
utils
;
import
javax.crypto.Cipher
;
import
javax.crypto.SecretKey
;
import
javax.crypto.SecretKeyFactory
;
import
javax.crypto.spec.DESKeySpec
;
import
javax.crypto.spec.IvParameterSpec
;
public
class
DESUtils
{
public
static
final
String
Key
=
"loginkey"
;
public
static
byte
[]
DES_CBC_Encrypt
(
byte
[]
content
,
byte
[]
keyBytes
){
try
{
DESKeySpec
keySpec
=
new
DESKeySpec
(
keyBytes
);
SecretKeyFactory
keyFactory
=
SecretKeyFactory
.
getInstance
(
"DES"
);
SecretKey
key
=
keyFactory
.
generateSecret
(
keySpec
);
Cipher
cipher
=
Cipher
.
getInstance
(
"DES/CBC/PKCS5Padding"
);
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
key
,
new
IvParameterSpec
(
keySpec
.
getKey
()));
byte
[]
result
=
cipher
.
doFinal
(
content
);
return
result
;
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
System
.
out
.
println
(
"exception:"
+
e
.
toString
());
}
return
null
;
}
public
static
String
byteToHexString
(
byte
[]
bytes
)
{
StringBuffer
sb
=
new
StringBuffer
(
bytes
.
length
);
String
sTemp
;
for
(
int
i
=
0
;
i
<
bytes
.
length
;
i
++)
{
sTemp
=
Integer
.
toHexString
(
0xFF
&
bytes
[
i
]);
if
(
sTemp
.
length
()
<
2
)
sb
.
append
(
0
);
sb
.
append
(
sTemp
.
toUpperCase
());
}
return
sb
.
toString
();
}
}
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