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
d269e486
Commit
d269e486
authored
Sep 16, 2020
by
董建华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
小程序
parent
e2efeb13
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
104 additions
and
7 deletions
+104
-7
ExceptionHandlingController.java
...antgroup/xyqb/controller/ExceptionHandlingController.java
+1
-1
AppletController.java
...xyqb/controller/middleoffice/applet/AppletController.java
+41
-4
ILoginModule.java
...roup/xyqb/controller/middleoffice/login/ILoginModule.java
+2
-0
LoginModule.java
...group/xyqb/controller/middleoffice/login/LoginModule.java
+21
-0
WechatUserInfo.java
src/main/java/cn/quantgroup/xyqb/entity/WechatUserInfo.java
+2
-0
AppletParamEntry.java
...quantgroup/xyqb/entity/middleoffice/AppletParamEntry.java
+4
-0
IAppletService.java
...roup/xyqb/service/middleoffice/applet/IAppletService.java
+2
-0
AppletServiceImpl.java
...b/service/middleoffice/applet/impl/AppletServiceImpl.java
+31
-2
No files found.
src/main/java/cn/quantgroup/xyqb/controller/ExceptionHandlingController.java
View file @
d269e486
...
@@ -152,7 +152,7 @@ public class ExceptionHandlingController implements IBaseController {
...
@@ -152,7 +152,7 @@ public class ExceptionHandlingController implements IBaseController {
return
null
;
return
null
;
}
}
@ExceptionHandler
(
DataException
.
class
)
@ExceptionHandler
(
{
DataException
.
class
,
IllegalArgumentException
.
class
}
)
@ResponseBody
@ResponseBody
@ResponseStatus
(
HttpStatus
.
OK
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
JsonResult
handleDataException
(
DataException
e
)
{
public
JsonResult
handleDataException
(
DataException
e
)
{
...
...
src/main/java/cn/quantgroup/xyqb/controller/middleoffice/applet/AppletController.java
View file @
d269e486
package
cn
.
quantgroup
.
xyqb
.
controller
.
middleoffice
.
applet
;
package
cn
.
quantgroup
.
xyqb
.
controller
.
middleoffice
.
applet
;
import
cn.quantgroup.xyqb.controller.middleoffice.common.VerifyTypeEnum
;
import
cn.quantgroup.xyqb.controller.middleoffice.login.ILoginModule
;
import
cn.quantgroup.xyqb.controller.middleoffice.login.LoginVo
;
import
cn.quantgroup.xyqb.entity.middleoffice.AppletParamEntry
;
import
cn.quantgroup.xyqb.entity.middleoffice.AppletParamEntry
;
import
cn.quantgroup.xyqb.exception.DataException
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.service.middleoffice.applet.IAppletService
;
import
cn.quantgroup.xyqb.service.middleoffice.applet.IAppletService
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.Assert
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
/**
* @author :dongjianhua
* @author :dongjianhua
* @date :Created in 2020/5/27 17:24
* @date :Created in 2020/5/27 17:24
...
@@ -23,21 +32,49 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -23,21 +32,49 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RestController
@RequestMapping
(
"/middle_office/applet"
)
@RequestMapping
(
"/middle_office/applet"
)
public
class
AppletController
{
public
class
AppletController
{
//先这么干 多了的话建表去存
private
static
final
List
<
String
>
appNames
=
Lists
.
newArrayList
(
"luckii"
,
"xyqb"
,
"wuxi"
);
private
final
IAppletService
iAppletService
;
private
final
IAppletService
iAppletService
;
private
ILoginModule
loginModule
;
@Autowired
@Autowired
AppletController
(
IAppletService
iAppletService
){
AppletController
(
IAppletService
iAppletService
,
ILoginModule
loginModule
)
{
this
.
iAppletService
=
iAppletService
;
this
.
iAppletService
=
iAppletService
;
this
.
loginModule
=
loginModule
;
}
}
/**
/**
*
* @return
* @return
*/
*/
@PostMapping
(
"/relevance"
)
@PostMapping
(
"/relevance"
)
public
JsonResult
relevance
(
@Validated
@RequestBody
AppletParamEntry
appletParamEntry
)
{
public
JsonResult
relevance
(
@Validated
@RequestBody
AppletParamEntry
appletParamEntry
)
{
if
(!
appNames
.
contains
(
appletParamEntry
.
getAppName
()))
{
throw
new
DataException
(
"appName不合法"
);
}
Long
userId
=
iAppletService
.
relevance
(
appletParamEntry
);
Long
userId
=
iAppletService
.
relevance
(
appletParamEntry
);
return
JsonResult
.
buildSuccessResultGeneric
(
ImmutableMap
.
of
(
"userId"
,
userId
));
LoginVo
loginVo
=
loginModule
.
loginByUserId
(
appletParamEntry
.
getChannelId
(),
appletParamEntry
.
getUtmSource
(),
userId
);
return
JsonResult
.
buildSuccessResultGeneric
(
ImmutableMap
.
of
(
"userId"
,
userId
,
"user"
,
loginVo
));
}
}
/**
* @return
*/
@PostMapping
(
"/login"
)
public
JsonResult
login
(
String
appName
,
String
openId
,
String
utmSource
)
{
if
(!
appNames
.
contains
(
appName
))
{
throw
new
DataException
(
"appName不合法"
);
}
LoginVo
login
=
iAppletService
.
login
(
appName
,
openId
,
utmSource
);
return
JsonResult
.
buildSuccessResultGeneric
(
login
);
}
}
}
src/main/java/cn/quantgroup/xyqb/controller/middleoffice/login/ILoginModule.java
View file @
d269e486
...
@@ -10,4 +10,6 @@ public interface ILoginModule {
...
@@ -10,4 +10,6 @@ public interface ILoginModule {
String
verify
);
String
verify
);
Boolean
modifyPwd
(
VerifyTypeEnum
type
,
String
phoneNo
,
String
password
,
String
verify
);
Boolean
modifyPwd
(
VerifyTypeEnum
type
,
String
phoneNo
,
String
password
,
String
verify
);
LoginVo
loginByUserId
(
Long
channelId
,
String
appChannel
,
Long
userId
);
}
}
src/main/java/cn/quantgroup/xyqb/controller/middleoffice/login/LoginModule.java
View file @
d269e486
...
@@ -81,5 +81,26 @@ public class LoginModule implements ILoginModule {
...
@@ -81,5 +81,26 @@ public class LoginModule implements ILoginModule {
return
true
;
return
true
;
}
}
@Override
public
LoginVo
loginByUserId
(
Long
channelId
,
String
appChannel
,
Long
userId
)
{
User
user
=
userService
.
findById
(
userId
);
if
(
null
==
user
){
throw
new
DataException
(
"未找到此用户"
);
}
LoginProperties
loginProperties
=
LoginProperties
.
builder
()
.
createdFrom
(
user
.
getRegisteredFrom
())
.
appChannel
(
appChannel
==
null
?
""
:
appChannel
)
.
channelId
(
channelId
)
.
build
();
AuthBean
session
=
sessionService
.
createSession
(
user
,
loginProperties
);
return
LoginVo
.
builder
()
.
hasPassword
(
user
.
getHasPassword
())
.
phoneNo
(
user
.
getPhoneNo
())
.
token
(
session
.
getToken
())
.
userId
(
user
.
getId
())
.
uuid
(
user
.
getUuid
())
.
build
();
}
}
}
src/main/java/cn/quantgroup/xyqb/entity/WechatUserInfo.java
View file @
d269e486
...
@@ -42,6 +42,8 @@ public class WechatUserInfo extends BaseEntity implements Serializable {
...
@@ -42,6 +42,8 @@ public class WechatUserInfo extends BaseEntity implements Serializable {
private
String
country
;
private
String
country
;
@Column
(
name
=
"head_img_url"
)
@Column
(
name
=
"head_img_url"
)
private
String
headImgUrl
;
private
String
headImgUrl
;
@Column
(
name
=
"utm_source"
)
private
String
utmSource
;
public
WechatUserInfo
convertEmoji
()
{
public
WechatUserInfo
convertEmoji
()
{
...
...
src/main/java/cn/quantgroup/xyqb/entity/middleoffice/AppletParamEntry.java
View file @
d269e486
...
@@ -71,5 +71,9 @@ public class AppletParamEntry {
...
@@ -71,5 +71,9 @@ public class AppletParamEntry {
* 语言
* 语言
*/
*/
private
String
language
;
private
String
language
;
/**
* 风控要的字段广告系列来源
*/
private
String
utmSource
;
}
}
src/main/java/cn/quantgroup/xyqb/service/middleoffice/applet/IAppletService.java
View file @
d269e486
package
cn
.
quantgroup
.
xyqb
.
service
.
middleoffice
.
applet
;
package
cn
.
quantgroup
.
xyqb
.
service
.
middleoffice
.
applet
;
import
cn.quantgroup.xyqb.controller.middleoffice.login.LoginVo
;
import
cn.quantgroup.xyqb.entity.middleoffice.AppletParamEntry
;
import
cn.quantgroup.xyqb.entity.middleoffice.AppletParamEntry
;
/**
/**
...
@@ -11,4 +12,5 @@ import cn.quantgroup.xyqb.entity.middleoffice.AppletParamEntry;
...
@@ -11,4 +12,5 @@ import cn.quantgroup.xyqb.entity.middleoffice.AppletParamEntry;
*/
*/
public
interface
IAppletService
{
public
interface
IAppletService
{
Long
relevance
(
AppletParamEntry
appletParamEntry
);
Long
relevance
(
AppletParamEntry
appletParamEntry
);
LoginVo
login
(
String
appName
,
String
openId
,
String
utmSource
);
}
}
src/main/java/cn/quantgroup/xyqb/service/middleoffice/applet/impl/AppletServiceImpl.java
View file @
d269e486
package
cn
.
quantgroup
.
xyqb
.
service
.
middleoffice
.
applet
.
impl
;
package
cn
.
quantgroup
.
xyqb
.
service
.
middleoffice
.
applet
.
impl
;
import
cn.quantgroup.xyqb.controller.middleoffice.login.ILoginModule
;
import
cn.quantgroup.xyqb.controller.middleoffice.login.LoginVo
;
import
cn.quantgroup.xyqb.entity.middleoffice.AppletParamEntry
;
import
cn.quantgroup.xyqb.entity.middleoffice.AppletParamEntry
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.WechatUserInfo
;
import
cn.quantgroup.xyqb.entity.WechatUserInfo
;
import
cn.quantgroup.xyqb.exception.DataException
;
import
cn.quantgroup.xyqb.repository.IWeChatUserRepository
;
import
cn.quantgroup.xyqb.repository.IWeChatUserRepository
;
import
cn.quantgroup.xyqb.service.middleoffice.applet.IAppletService
;
import
cn.quantgroup.xyqb.service.middleoffice.applet.IAppletService
;
import
cn.quantgroup.xyqb.service.register.IUserRegisterService
;
import
cn.quantgroup.xyqb.service.register.IUserRegisterService
;
...
@@ -29,12 +32,17 @@ public class AppletServiceImpl implements IAppletService {
...
@@ -29,12 +32,17 @@ public class AppletServiceImpl implements IAppletService {
private
final
IUserRegisterService
iUserRegisterService
;
private
final
IUserRegisterService
iUserRegisterService
;
private
final
IUserService
userService
;
private
final
IUserService
userService
;
private
ILoginModule
loginModule
;
@Autowired
@Autowired
public
AppletServiceImpl
(
IWeChatUserRepository
iWeChatUserRepository
,
IUserRegisterService
iUserRegisterService
,
IUserService
userService
)
{
public
AppletServiceImpl
(
IWeChatUserRepository
iWeChatUserRepository
,
IUserRegisterService
iUserRegisterService
,
IUserService
userService
,
ILoginModule
loginModule
)
{
this
.
iWeChatUserRepository
=
iWeChatUserRepository
;
this
.
iWeChatUserRepository
=
iWeChatUserRepository
;
this
.
iUserRegisterService
=
iUserRegisterService
;
this
.
iUserRegisterService
=
iUserRegisterService
;
this
.
userService
=
userService
;
this
.
userService
=
userService
;
this
.
loginModule
=
loginModule
;
}
}
@Override
@Override
...
@@ -56,7 +64,7 @@ public class AppletServiceImpl implements IAppletService {
...
@@ -56,7 +64,7 @@ public class AppletServiceImpl implements IAppletService {
wechatUserInfo
.
setSex
(
appletParamEntry
.
getGender
());
wechatUserInfo
.
setSex
(
appletParamEntry
.
getGender
());
wechatUserInfo
.
setUnionId
(
appletParamEntry
.
getUnionId
());
wechatUserInfo
.
setUnionId
(
appletParamEntry
.
getUnionId
());
wechatUserInfo
.
setPhoneNo
(
appletParamEntry
.
getMobile
());
wechatUserInfo
.
setPhoneNo
(
appletParamEntry
.
getMobile
());
wechatUserInfo
.
setUtmSource
(
appletParamEntry
.
getUtmSource
());
if
(
null
==
wechatUserInfo
.
getUserId
())
{
//只要存在userid 就说明已经在用户表里了 不考虑小程序这边换手机号了
if
(
null
==
wechatUserInfo
.
getUserId
())
{
//只要存在userid 就说明已经在用户表里了 不考虑小程序这边换手机号了
User
user
=
userService
.
findByPhoneInDb
(
appletParamEntry
.
getMobile
());
User
user
=
userService
.
findByPhoneInDb
(
appletParamEntry
.
getMobile
());
//如果不存在就去注册一下
//如果不存在就去注册一下
...
@@ -70,4 +78,25 @@ public class AppletServiceImpl implements IAppletService {
...
@@ -70,4 +78,25 @@ public class AppletServiceImpl implements IAppletService {
iWeChatUserRepository
.
save
(
wechatUserInfo
);
iWeChatUserRepository
.
save
(
wechatUserInfo
);
return
wechatUserInfo
.
getUserId
();
return
wechatUserInfo
.
getUserId
();
}
}
@Override
public
LoginVo
login
(
String
appName
,
String
openId
,
String
utmSource
)
{
WechatUserInfo
wechatUserInfo
=
iWeChatUserRepository
.
findByOpenIdAndAppName
(
openId
,
appName
);
if
(
null
==
wechatUserInfo
)
{
log
.
error
(
"未找到此用户,appName:{} ,openId:{}"
,
appName
,
openId
);
throw
new
DataException
(
"未找到此用户"
);
}
if
(
null
==
wechatUserInfo
.
getUserId
())
{
log
.
error
(
"用户未绑定到xyqb,appName:{} ,openId:{}"
,
appName
,
openId
);
throw
new
DataException
(
"未找到此用户绑定信息"
);
}
User
user
=
userService
.
findById
(
wechatUserInfo
.
getUserId
());
LoginVo
loginVo
=
loginModule
.
loginByUserId
(
user
.
getRegisteredFrom
(),
utmSource
==
null
?
""
:
utmSource
,
user
.
getId
());
return
loginVo
;
}
}
}
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