Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
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
haoban3.0
haoban-manage3.0
Commits
f51a83fb
Commit
f51a83fb
authored
Feb 12, 2020
by
qwmqiuwenmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
模拟登录
parent
9c10fc03
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
336 additions
and
1 deletions
+336
-1
StaffDTO.java
...src/main/java/com/gic/haoban/manage/api/dto/StaffDTO.java
+109
-0
StaffApiService.java
...va/com/gic/haoban/manage/api/service/StaffApiService.java
+4
-0
StaffService.java
...a/com/gic/haoban/manage/service/service/StaffService.java
+4
-0
StaffApiServiceImpl.java
...oban/manage/service/service/impl/StaffApiServiceImpl.java
+14
-0
StaffServiceImpl.java
...ban/manage/service/service/out/impl/StaffServiceImpl.java
+12
-0
AuthRequestUtil.java
.../java/com/gic/haoban/manage/web/auth/AuthRequestUtil.java
+139
-0
ApplicationController.java
...c/haoban/manage/web/controller/ApplicationController.java
+18
-0
LoginController.java
...com/gic/haoban/manage/web/controller/LoginController.java
+35
-0
dubbo-haoban-manage-web.xml
...3-web/src/main/webapp/WEB-INF/dubbo-haoban-manage-web.xml
+1
-1
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/dto/StaffDTO.java
0 → 100644
View file @
f51a83fb
package
com
.
gic
.
haoban
.
manage
.
api
.
dto
;
import
java.io.Serializable
;
import
java.util.Date
;
public
class
StaffDTO
implements
Serializable
{
private
String
staffId
;
private
String
wxUserId
;
private
String
phoneNumber
;
private
String
staffName
;
private
String
nationCode
;
private
String
nickName
;
private
Integer
sex
;
private
String
postion
;
private
Integer
activeFlag
;
private
String
extendPostion
;
private
Integer
statusFlag
;
private
Date
createTime
;
private
Date
updateTime
;
private
static
final
long
serialVersionUID
=
1L
;
public
String
getStaffId
()
{
return
staffId
;
}
public
void
setStaffId
(
String
staffId
)
{
this
.
staffId
=
staffId
==
null
?
null
:
staffId
.
trim
();
}
public
String
getWxUserId
()
{
return
wxUserId
;
}
public
void
setWxUserId
(
String
wxUserId
)
{
this
.
wxUserId
=
wxUserId
==
null
?
null
:
wxUserId
.
trim
();
}
public
String
getPhoneNumber
()
{
return
phoneNumber
;
}
public
void
setPhoneNumber
(
String
phoneNumber
)
{
this
.
phoneNumber
=
phoneNumber
==
null
?
null
:
phoneNumber
.
trim
();
}
public
String
getStaffName
()
{
return
staffName
;
}
public
void
setStaffName
(
String
staffName
)
{
this
.
staffName
=
staffName
==
null
?
null
:
staffName
.
trim
();
}
public
String
getNationCode
()
{
return
nationCode
;
}
public
void
setNationCode
(
String
nationCode
)
{
this
.
nationCode
=
nationCode
==
null
?
null
:
nationCode
.
trim
();
}
public
String
getNickName
()
{
return
nickName
;
}
public
void
setNickName
(
String
nickName
)
{
this
.
nickName
=
nickName
==
null
?
null
:
nickName
.
trim
();
}
public
Integer
getSex
()
{
return
sex
;
}
public
void
setSex
(
Integer
sex
)
{
this
.
sex
=
sex
;
}
public
String
getPostion
()
{
return
postion
;
}
public
void
setPostion
(
String
postion
)
{
this
.
postion
=
postion
==
null
?
null
:
postion
.
trim
();
}
public
Integer
getActiveFlag
()
{
return
activeFlag
;
}
public
void
setActiveFlag
(
Integer
activeFlag
)
{
this
.
activeFlag
=
activeFlag
;
}
}
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/StaffApiService.java
View file @
f51a83fb
package
com
.
gic
.
haoban
.
manage
.
api
.
service
;
package
com
.
gic
.
haoban
.
manage
.
api
.
service
;
import
com.gic.haoban.manage.api.dto.StaffDTO
;
public
interface
StaffApiService
{
public
interface
StaffApiService
{
public
StaffDTO
selectById
(
String
staffId
);
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/StaffService.java
View file @
f51a83fb
package
com
.
gic
.
haoban
.
manage
.
service
.
service
;
package
com
.
gic
.
haoban
.
manage
.
service
.
service
;
import
com.gic.haoban.manage.service.entity.TabHaobanStaff
;
public
interface
StaffService
{
public
interface
StaffService
{
TabHaobanStaff
selectById
(
String
staffId
);
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/StaffApiServiceImpl.java
View file @
f51a83fb
package
com
.
gic
.
haoban
.
manage
.
service
.
service
.
impl
;
package
com
.
gic
.
haoban
.
manage
.
service
.
service
.
impl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.haoban.manage.api.dto.StaffDTO
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.service.entity.TabHaobanStaff
;
import
com.gic.haoban.manage.service.service.StaffService
;
@Service
@Service
public
class
StaffApiServiceImpl
implements
StaffApiService
{
public
class
StaffApiServiceImpl
implements
StaffApiService
{
@Autowired
StaffService
staffService
;
@Override
public
StaffDTO
selectById
(
String
staffId
)
{
TabHaobanStaff
staff
=
staffService
.
selectById
(
staffId
);
return
EntityUtil
.
changeEntityByJSON
(
StaffDTO
.
class
,
staff
);
}
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/StaffServiceImpl.java
View file @
f51a83fb
package
com
.
gic
.
haoban
.
manage
.
service
.
service
.
out
.
impl
;
package
com
.
gic
.
haoban
.
manage
.
service
.
service
.
out
.
impl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.gic.haoban.manage.service.dao.mapper.StaffMapper
;
import
com.gic.haoban.manage.service.entity.TabHaobanStaff
;
import
com.gic.haoban.manage.service.service.StaffService
;
import
com.gic.haoban.manage.service.service.StaffService
;
@Service
@Service
public
class
StaffServiceImpl
implements
StaffService
{
public
class
StaffServiceImpl
implements
StaffService
{
@Autowired
StaffMapper
mapper
;
@Override
public
TabHaobanStaff
selectById
(
String
id
)
{
return
mapper
.
selectByPrimaryKey
(
id
);
}
}
}
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/auth/AuthRequestUtil.java
0 → 100644
View file @
f51a83fb
package
com
.
gic
.
haoban
.
manage
.
web
.
auth
;
import
com.gic.redis.data.util.RedisUtil
;
import
org.apache.commons.beanutils.BeanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
java.util.Date
;
import
java.util.concurrent.TimeUnit
;
/**
* Created 2018/7/26.
*
* @author hua
*/
public
class
AuthRequestUtil
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AuthRequestUtil
.
class
);
public
static
final
String
REDIS_LOGIN_USER_TOKEN_PREFIX
=
"GIC:HAOBAN:HAOBAN_MOBILE_APP:LOGIN_USER:"
;
public
static
final
String
REDIS_FAKE_LOGIN_FLAG_PREFIX
=
"GIC:HAOBAN:HAOBAN_MOBILE_APP:FAKE_LOGIN_TOKEN:"
;
public
static
Object
getSessionUser
()
{
return
getSession
().
getAttribute
(
GlobalParams
.
LOGIN_SESSION_KEY
);
}
public
static
void
setSessionUser
(
Object
obj
)
{
getSession
().
setAttribute
(
GlobalParams
.
LOGIN_SESSION_KEY
,
obj
);
}
public
static
void
delSessionUser
()
{
getSession
().
removeAttribute
(
GlobalParams
.
LOGIN_SESSION_KEY
);
}
public
static
Object
getAppLoginUser
()
{
String
token
=
getRequest
().
getHeader
(
"token"
);
logger
.
info
(
"token1111111111="
+
token
);
if
(
StringUtils
.
isBlank
(
token
))
{
return
null
;
}
Object
cache
=
RedisUtil
.
getCache
(
token
);
return
cache
;
}
private
static
void
setLoginUserLastToken
(
String
token
,
Object
obj
)
{
try
{
String
userId
=
BeanUtils
.
getProperty
(
obj
,
"user.userId"
);
if
(
StringUtils
.
isNotBlank
(
userId
)
&&
StringUtils
.
isNotBlank
(
token
))
{
RedisUtil
.
setCache
(
REDIS_LOGIN_USER_TOKEN_PREFIX
+
userId
,
token
,
31L
,
TimeUnit
.
DAYS
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
}
}
/**
* 是否为用户最后一次登录token
*
* @param token
* @param userId
* @return
*/
public
static
boolean
isLoginUserLastToken
(
String
token
,
String
userId
)
{
Object
lastUserLoginToken
=
RedisUtil
.
getCache
(
REDIS_LOGIN_USER_TOKEN_PREFIX
+
userId
);
// 如果用户最后一次登录token不符则返回false
return
!(
lastUserLoginToken
instanceof
CharSequence
)
||
StringUtils
.
equals
(
token
,
(
CharSequence
)
lastUserLoginToken
);
}
private
static
void
setFakeLoginFlag
(
String
token
)
{
if
(
StringUtils
.
isNotBlank
(
token
))
{
RedisUtil
.
setCache
(
REDIS_FAKE_LOGIN_FLAG_PREFIX
+
token
,
new
Date
(),
30L
,
TimeUnit
.
DAYS
);
}
}
/**
* 是否为伪登录token
*
* @param token
* @return
*/
public
static
boolean
isFakeLoginToken
(
String
token
)
{
return
StringUtils
.
isNotBlank
(
token
)
&&
RedisUtil
.
getCache
(
REDIS_FAKE_LOGIN_FLAG_PREFIX
+
token
)
!=
null
;
}
public
static
void
setAppLoginUser
(
String
token
,
Object
obj
)
{
RedisUtil
.
setCache
(
token
,
obj
,
30L
,
TimeUnit
.
DAYS
);
getResponse
().
setHeader
(
"token"
,
token
);
setLoginUserLastToken
(
token
,
obj
);
}
public
static
void
setAppFakeLoginUser
(
String
token
,
Object
obj
)
{
RedisUtil
.
setCache
(
token
,
obj
,
30L
,
TimeUnit
.
DAYS
);
getResponse
().
setHeader
(
"token"
,
token
);
setFakeLoginFlag
(
token
);
}
public
static
void
delToken
()
{
String
token
=
getRequest
().
getHeader
(
"token"
);
RedisUtil
.
delCache
(
token
);
}
public
static
void
setAppLoginUser
(
Object
obj
)
{
String
token
=
getRequest
().
getHeader
(
"token"
);
RedisUtil
.
setCache
(
token
,
obj
,
30L
,
TimeUnit
.
DAYS
);
getResponse
().
setHeader
(
"token"
,
token
);
setLoginUserLastToken
(
token
,
obj
);
}
public
static
void
setAppFakeLoginUser
(
Object
obj
)
{
String
token
=
getRequest
().
getHeader
(
"token"
);
RedisUtil
.
setCache
(
token
,
obj
,
30L
,
TimeUnit
.
DAYS
);
getResponse
().
setHeader
(
"token"
,
token
);
}
public
static
HttpSession
getSession
()
{
HttpSession
session
=
null
;
try
{
session
=
getRequest
().
getSession
();
}
catch
(
Exception
e
)
{
}
return
session
;
}
public
static
HttpServletRequest
getRequest
()
{
ServletRequestAttributes
attrs
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
return
attrs
.
getRequest
();
}
public
static
HttpServletResponse
getResponse
()
{
ServletRequestAttributes
attrs
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
return
attrs
.
getResponse
();
}
}
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/ApplicationController.java
0 → 100644
View file @
f51a83fb
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.gic.haoban.common.utils.HaobanResponse
;
@RestController
public
class
ApplicationController
extends
WebBaseController
{
@RequestMapping
(
"application-list"
)
public
HaobanResponse
applicationList
()
{
return
null
;
}
}
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/LoginController.java
0 → 100644
View file @
f51a83fb
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.gic.haoban.common.utils.AuthRequestUtil
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.manage.api.dto.StaffDTO
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
@RestController
public
class
LoginController
extends
WebBaseController
{
@Autowired
StaffApiService
staffApiService
;
@RequestMapping
(
"login"
)
public
HaobanResponse
login
()
{
StaffDTO
staff
=
staffApiService
.
selectById
(
"1"
);
AuthRequestUtil
.
setSessionUser
(
staff
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
staff
);
}
@RequestMapping
(
"login-out"
)
public
HaobanResponse
loginOut
()
{
AuthRequestUtil
.
delSessionUser
();
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
}
haoban-manage3-web/src/main/webapp/WEB-INF/dubbo-haoban-manage-web.xml
View file @
f51a83fb
...
@@ -19,5 +19,5 @@
...
@@ -19,5 +19,5 @@
<!--<dubbo:registry address="zookeeper://115.159.182.172:2199" protocol="dubbo" id="remoteAdd"/>-->
<!--<dubbo:registry address="zookeeper://115.159.182.172:2199" protocol="dubbo" id="remoteAdd"/>-->
<!--<dubbo:registry address="zookeeper://localhost:2181|zookeeper://115.159.182.172:2199" protocol="dubbo"/>-->
<!--<dubbo:registry address="zookeeper://localhost:2181|zookeeper://115.159.182.172:2199" protocol="dubbo"/>-->
<dubbo:reference
interface=
"com.gic.haoban.manage.api.service.StaffApidService"
id=
"staffApiService"
/>
</beans>
</beans>
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