Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
ef7cc114
Commit
ef7cc114
authored
May 28, 2020
by
董建华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户中心增加小程序登录接口
parent
4d71199d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
19 deletions
+28
-19
AppletController.java
...n/quantgroup/xyqb/controller/applet/AppletController.java
+13
-3
UserController.java
...n/quantgroup/xyqb/controller/external/UserController.java
+1
-1
AppletParamEntry.java
...main/java/cn/quantgroup/xyqb/entity/AppletParamEntry.java
+3
-1
AppletServiceImpl.java
...uantgroup/xyqb/service/applet/impl/AppletServiceImpl.java
+11
-14
No files found.
src/main/java/cn/quantgroup/xyqb/controller/applet/AppletController.java
View file @
ef7cc114
...
...
@@ -2,7 +2,10 @@ package cn.quantgroup.xyqb.controller.applet;
import
cn.quantgroup.xyqb.entity.AppletParamEntry
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.service.applet.IAppletService
;
import
com.google.common.collect.ImmutableMap
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
...
@@ -20,14 +23,21 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping
(
"/middle_office/applet"
)
public
class
AppletController
{
private
final
IAppletService
iAppletService
;
@Autowired
AppletController
(
IAppletService
iAppletService
){
this
.
iAppletService
=
iAppletService
;
}
/**
*
* @return
*/
@PostMapping
(
"/relevance"
)
public
JsonResult
relevance
(
@Validated
@RequestBody
AppletParamEntry
appletParamEntry
){
return
JsonResult
.
buildSuccessResult
(
);
public
JsonResult
relevance
(
@Validated
@RequestBody
AppletParamEntry
appletParamEntry
)
{
Long
userId
=
iAppletService
.
relevance
(
appletParamEntry
);
return
JsonResult
.
buildSuccessResult
Generic
(
ImmutableMap
.
of
(
"userId"
,
userId
)
);
}
}
src/main/java/cn/quantgroup/xyqb/controller/external/UserController.java
View file @
ef7cc114
...
...
@@ -152,7 +152,7 @@ public class UserController implements IBaseController {
@RequestParam
(
required
=
false
)
String
dimension
,
@RequestParam
(
name
=
"click_id"
,
required
=
false
)
String
clickId
,
HttpServletRequest
request
)
{
log
.
info
(
"login/fastV1 -> channelId:{},appChennel:{},createdFrom:{},key:{},btRegisterChannelId:{},dimension:{},clickId:{}"
,
channelId
,
appChannel
,
createdFrom
,
key
,
btRegisterChannelId
,
dimension
,
clickId
);
log
.
info
(
"login/fastV1 -> channelId:{},
Z
appChennel:{},createdFrom:{},key:{},btRegisterChannelId:{},dimension:{},clickId:{}"
,
channelId
,
appChannel
,
createdFrom
,
key
,
btRegisterChannelId
,
dimension
,
clickId
);
return
loginFast
(
channelId
,
appChannel
,
createdFrom
,
key
,
btRegisterChannelId
,
dimension
,
clickId
,
request
);
}
...
...
src/main/java/cn/quantgroup/xyqb/entity/AppletParamEntry.java
View file @
ef7cc114
package
cn
.
quantgroup
.
xyqb
.
entity
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
@@ -36,7 +37,7 @@ public class AppletParamEntry {
* 手机号
*/
@NotNull
(
message
=
"04:mobile 不能为空"
)
@Pattern
(
regexp
=
"/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\\d{8}$/"
,
message
=
"手机号格式不对"
)
@Pattern
(
regexp
=
ValidationUtil
.
phoneRegExp
,
message
=
"手机号格式不对"
)
private
String
mobile
;
/**
* 用户全局唯一标识
...
...
@@ -70,4 +71,5 @@ public class AppletParamEntry {
* 语言
*/
private
String
language
;
}
src/main/java/cn/quantgroup/xyqb/service/applet/impl/AppletServiceImpl.java
View file @
ef7cc114
...
...
@@ -43,12 +43,9 @@ public class AppletServiceImpl implements IAppletService {
public
Long
relevance
(
AppletParamEntry
appletParamEntry
)
{
WechatUserInfo
wechatUserInfo
=
iWeChatUserRepository
.
findByOpenIdAndAppName
(
appletParamEntry
.
getOpenId
(),
appletParamEntry
.
getAppName
());
//这个接口先不考虑更换手机号的情况只要有userid就直接返回
if
(
null
!=
wechatUserInfo
&&
null
!=
wechatUserInfo
.
getUserId
())
{
return
wechatUserInfo
.
getUserId
();
}
//这个接口先不考虑更换手机号的情况
wechatUserInfo
=
new
WechatUserInfo
(
);
wechatUserInfo
=
(
wechatUserInfo
==
null
?
new
WechatUserInfo
()
:
wechatUserInfo
);
wechatUserInfo
.
setNickName
(
appletParamEntry
.
getNickName
());
wechatUserInfo
.
setCity
(
appletParamEntry
.
getCity
());
wechatUserInfo
.
setCountry
(
appletParamEntry
.
getCountry
());
...
...
@@ -59,18 +56,18 @@ public class AppletServiceImpl implements IAppletService {
wechatUserInfo
.
setOpenId
(
appletParamEntry
.
getOpenId
());
wechatUserInfo
.
setSex
(
appletParamEntry
.
getGender
());
wechatUserInfo
.
setUnionId
(
appletParamEntry
.
getUnionId
());
wechatUserInfo
.
setPhoneNo
(
appletParamEntry
.
getMobile
());
User
user
=
userService
.
findByPhoneInDb
(
appletParamEntry
.
getMobile
());
//如果不存在就去注册一下
if
(
null
==
user
)
{
user
=
iUserRegisterService
.
register
(
appletParamEntry
.
getChannelId
(),
appletParamEntry
.
getMobile
());
if
(
null
==
wechatUserInfo
.
getUserId
())
{
//只要存在userid 就说明已经在用户表里了 不考虑小程序这边换手机号了
User
user
=
userService
.
findByPhoneInDb
(
appletParamEntry
.
getMobile
());
//如果不存在就去注册一下
if
(
null
==
user
)
{
user
=
iUserRegisterService
.
register
(
appletParamEntry
.
getChannelId
(),
appletParamEntry
.
getMobile
());
}
wechatUserInfo
.
setUserId
(
user
.
getId
());
}
//如果存在就更新在微信表里
Long
id
=
user
.
getId
();
wechatUserInfo
.
setUserId
(
id
);
wechatUserInfo
.
setPhoneNo
(
user
.
getPhoneNo
());
iWeChatUserRepository
.
save
(
wechatUserInfo
);
return
id
;
return
wechatUserInfo
.
getUserId
()
;
}
}
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