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
73ac21f1
Commit
73ac21f1
authored
Apr 01, 2020
by
fudahua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取企业登录用户信息
parent
b83c6f11
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
57 deletions
+89
-57
InfoController.java
.../com/gic/haoban/manage/web/controller/InfoController.java
+89
-57
No files found.
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/controller/InfoController.java
View file @
73ac21f1
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.gic.haoban.common.utils.EntityUtil
;
import
com.gic.haoban.common.utils.EntityUtil
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.manage.api.dto.StaffDTO
;
import
com.gic.haoban.manage.api.dto.*
;
import
com.gic.haoban.manage.api.dto.UserLoginLogDTO
;
import
com.gic.haoban.manage.api.dto.WxEnterpriseDTO
;
import
com.gic.haoban.manage.api.dto.YwWxEnterpriseDTO
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.api.service.WxEnterpriseApiService
;
import
com.gic.haoban.manage.api.service.WxEnterpriseApiService
;
import
com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService
;
import
com.gic.haoban.manage.web.config.Config
;
import
com.gic.haoban.manage.web.config.Config
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.haoban.manage.web.interceptor.WebInterceptor
;
import
com.gic.haoban.manage.web.vo.AppStaffVo
;
import
com.gic.haoban.manage.web.vo.AppStaffVo
;
import
com.gic.haoban.manage.web.vo.InfoVo
;
import
com.gic.haoban.manage.web.vo.InfoVo
;
import
com.gic.wechat.api.dto.qywx.UserDTO
;
import
com.gic.wechat.api.dto.qywx.UserDTO
;
import
com.gic.wechat.api.service.qywx.QywxCorpApiService
;
import
com.gic.wechat.api.service.qywx.QywxCorpApiService
;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@RestController
@RestController
public
class
InfoController
extends
WebBaseController
{
public
class
InfoController
extends
WebBaseController
{
...
@@ -42,49 +35,88 @@ public class InfoController extends WebBaseController{
...
@@ -42,49 +35,88 @@ public class InfoController extends WebBaseController{
private
StaffApiService
staffApiService
;
private
StaffApiService
staffApiService
;
@Autowired
@Autowired
private
WxEnterpriseApiService
wxEnterpriseApiService
;
private
WxEnterpriseApiService
wxEnterpriseApiService
;
@Autowired
private
WxEnterpriseRelatedApiService
wxEnterpriseRelatedApiService
;
@Autowired
private
QywxUserApiService
qywxUserApiService
;
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
InfoController
.
class
);
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
InfoController
.
class
);
@Autowired
@Autowired
private
Config
config
;
private
Config
config
;
@RequestMapping
(
"get-info-by-code"
)
@RequestMapping
(
"get-info-by-code"
)
public
HaobanResponse
getInfoByCode
(
String
code
)
{
public
HaobanResponse
getInfoByCode
(
String
code
)
{
String
userDTOJson
=
qywxCorpApiService
.
getCodeSession
(
config
.
getWxSuiteid
(),
code
);
String
userDTOJson
=
qywxCorpApiService
.
getCodeSession
(
config
.
getWxSuiteid
(),
code
);
logger
.
info
(
"userDTOJson=============>{}"
,
userDTOJson
);
logger
.
info
(
"userDTOJson=============>{}"
,
userDTOJson
);
UserDTO
user
=
JSON
.
parseObject
(
userDTOJson
,
UserDTO
.
class
);
UserDTO
user
=
JSON
.
parseObject
(
userDTOJson
,
UserDTO
.
class
);
if
(
user
==
null
)
{
if
(
user
==
null
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_6
);
return
resultResponse
(
HaoBanErrCode
.
ERR_6
);
}
}
String
userId
=
user
.
getUserid
();
String
userId
=
user
.
getUserid
();
String
corpId
=
user
.
getCorpid
();
String
corpId
=
user
.
getCorpid
();
WxEnterpriseDTO
enterprise
=
wxEnterpriseApiService
.
getEnterpriseBycorpId
(
corpId
);
WxEnterpriseDTO
enterprise
=
wxEnterpriseApiService
.
getEnterpriseBycorpId
(
corpId
);
StaffDTO
loginStaff
=
null
;
StaffDTO
loginStaff
=
null
;
if
(
enterprise
!=
null
){
if
(
enterprise
!=
null
){
loginStaff
=
staffApiService
.
selectByUserIdAndEnterpriseId
(
userId
,
enterprise
.
getWxEnterpriseId
());
loginStaff
=
staffApiService
.
selectByUserIdAndEnterpriseId
(
userId
,
enterprise
.
getWxEnterpriseId
());
}
}
if
(
loginStaff
==
null
){
if
(
loginStaff
==
null
){
if
(
enterprise
!=
null
){
if
(
enterprise
!=
null
){
staffApiService
.
wxGetAdd
(
userId
,
enterprise
.
getWxEnterpriseId
());
staffApiService
.
wxGetAdd
(
userId
,
enterprise
.
getWxEnterpriseId
());
loginStaff
=
staffApiService
.
selectByUserIdAndEnterpriseId
(
userId
,
enterprise
.
getWxEnterpriseId
());
loginStaff
=
staffApiService
.
selectByUserIdAndEnterpriseId
(
userId
,
enterprise
.
getWxEnterpriseId
());
}
}
}
}
if
(
loginStaff
==
null
){
if
(
loginStaff
==
null
){
return
resultResponse
(
HaoBanErrCode
.
ERR_600001
);
return
resultResponse
(
HaoBanErrCode
.
ERR_600001
);
}
}
String
wxEnterpriseId
=
loginStaff
.
getWxEnterpriseId
();
String
wxEnterpriseId
=
loginStaff
.
getWxEnterpriseId
();
WxEnterpriseDTO
wxEnterpriseDTO
=
wxEnterpriseApiService
.
getOne
(
wxEnterpriseId
);
WxEnterpriseDTO
wxEnterpriseDTO
=
wxEnterpriseApiService
.
getOne
(
wxEnterpriseId
);
String
accesstoken
=
qywxCorpApiService
.
getCorpAccessToken
(
wxEnterpriseDTO
.
getCorpid
(),
config
.
getWxSuiteid
());
String
accesstoken
=
qywxCorpApiService
.
getCorpAccessToken
(
wxEnterpriseDTO
.
getCorpid
(),
config
.
getWxSuiteid
());
InfoVo
infoVo
=
new
InfoVo
();
InfoVo
infoVo
=
new
InfoVo
();
infoVo
.
setAccessToken
(
accesstoken
);
infoVo
.
setAccessToken
(
accesstoken
);
infoVo
.
setStaffId
(
loginStaff
.
getStaffId
());
infoVo
.
setStaffId
(
loginStaff
.
getStaffId
());
infoVo
.
setWxEnterpriseId
(
wxEnterpriseId
);
infoVo
.
setWxEnterpriseId
(
wxEnterpriseId
);
infoVo
.
setStaffName
(
loginStaff
.
getStaffName
());
infoVo
.
setStaffName
(
loginStaff
.
getStaffName
());
infoVo
.
setPhoneNumber
(
loginStaff
.
getPhoneNumber
());
infoVo
.
setPhoneNumber
(
loginStaff
.
getPhoneNumber
());
infoVo
.
setNationcode
(
loginStaff
.
getNationCode
());
infoVo
.
setNationcode
(
loginStaff
.
getNationCode
());
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
infoVo
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
infoVo
);
}
}
@RequestMapping
(
"get-user-by-member-code"
)
public
HaobanResponse
getInfoByMemberCode
(
String
code
,
String
gicEnterpriseId
)
{
EnterpriseDetailDTO
enterpriseDetailDTO
=
wxEnterpriseRelatedApiService
.
getByEnterpriseId
(
gicEnterpriseId
);
if
(
enterpriseDetailDTO
==
null
)
{
logger
.
info
(
"改企业没有关系好办:{}"
,
gicEnterpriseId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_500001
);
}
WxEnterpriseDTO
enterpriseDTO
=
wxEnterpriseApiService
.
getOne
(
enterpriseDetailDTO
.
getWxEnterpriseId
());
if
(
enterpriseDetailDTO
==
null
)
{
logger
.
info
(
"改企业不存在:{}"
,
gicEnterpriseId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_400002
);
}
String
userDTOJson
=
qywxUserApiService
.
getUserByCode
(
enterpriseDTO
.
getCorpid
(),
enterpriseDTO
.
getWxSecretKey
(),
code
);
logger
.
info
(
"会员微信登录信息=============>{}"
,
userDTOJson
);
UserDTO
user
=
JSON
.
parseObject
(
userDTOJson
,
UserDTO
.
class
);
if
(
user
==
null
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_6
);
}
String
userId
=
user
.
getUserid
();
String
corpId
=
user
.
getCorpid
();
Map
<
String
,
String
>
ret
=
new
HashMap
<>();
ret
.
put
(
"userId"
,
userId
);
ret
.
put
(
"corpId"
,
corpId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
ret
);
}
@RequestMapping
(
"save-user-login-log"
)
@RequestMapping
(
"save-user-login-log"
)
public
HaobanResponse
saveUserLoginLog
(
UserLoginLogDTO
userLoginLogDTO
)
{
public
HaobanResponse
saveUserLoginLog
(
UserLoginLogDTO
userLoginLogDTO
)
{
...
...
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