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
fcb33421
Commit
fcb33421
authored
Nov 17, 2021
by
李健华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
小程序注册接口添加租户
parent
52cb1d0e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
2 deletions
+82
-2
PasswordFreeAccessValidateAdvisor.java
.../xyqb/aspect/limit/PasswordFreeAccessValidateAdvisor.java
+1
-1
AppletParamEntry.java
...quantgroup/xyqb/entity/middleoffice/AppletParamEntry.java
+4
-0
AppletServiceImpl.java
...b/service/middleoffice/applet/impl/AppletServiceImpl.java
+3
-0
IOauthLoginInfoService.java
.../quantgroup/xyqb/service/user/IOauthLoginInfoService.java
+3
-0
OauthLoginInfoServiceImpl.java
...oup/xyqb/service/user/impl/OauthLoginInfoServiceImpl.java
+71
-1
No files found.
src/main/java/cn/quantgroup/xyqb/aspect/limit/PasswordFreeAccessValidateAdvisor.java
View file @
fcb33421
...
@@ -101,7 +101,7 @@ public class PasswordFreeAccessValidateAdvisor {
...
@@ -101,7 +101,7 @@ public class PasswordFreeAccessValidateAdvisor {
// 如果头部没有tenantId参数
// 如果头部没有tenantId参数
if
(
StringUtils
.
isBlank
(
tenantId
))
{
if
(
StringUtils
.
isBlank
(
tenantId
))
{
// 如果 token Session tenantId 不是默认羊小咩, 那么拒绝登陆
// 如果 token Session tenantId 不是默认羊小咩, 那么拒绝登陆
if
(!
loginProperties
.
getTenantId
().
toString
().
equals
(
TenantUtil
.
TENANT_DEFAULT
))
{
if
(!
loginProperties
.
getTenantId
().
equals
(
TenantUtil
.
TENANT_DEFAULT
))
{
log
.
info
(
"非法请求 - 错误租户, token={}, phoneNo={}, userId={}, clientIp={}, tenantId={}, loginTenantId={}"
,
token
,
phoneNo
,
userId
,
clientIp
,
tenantId
,
loginProperties
.
getTenantId
().
toString
());
log
.
info
(
"非法请求 - 错误租户, token={}, phoneNo={}, userId={}, clientIp={}, tenantId={}, loginTenantId={}"
,
token
,
phoneNo
,
userId
,
clientIp
,
tenantId
,
loginProperties
.
getTenantId
().
toString
());
return
false
;
return
false
;
}
}
...
...
src/main/java/cn/quantgroup/xyqb/entity/middleoffice/AppletParamEntry.java
View file @
fcb33421
...
@@ -76,4 +76,8 @@ public class AppletParamEntry {
...
@@ -76,4 +76,8 @@ public class AppletParamEntry {
*/
*/
private
String
utmSource
;
private
String
utmSource
;
/**
* 租户ID
*/
private
Integer
tenantId
;
}
}
src/main/java/cn/quantgroup/xyqb/service/middleoffice/applet/impl/AppletServiceImpl.java
View file @
fcb33421
...
@@ -74,6 +74,9 @@ public class AppletServiceImpl implements IAppletService {
...
@@ -74,6 +74,9 @@ public class AppletServiceImpl implements IAppletService {
//如果不存在就去注册一下
//如果不存在就去注册一下
if
(
null
==
user
)
{
if
(
null
==
user
)
{
user
=
iUserRegisterService
.
register
(
appletParamEntry
.
getChannelId
(),
appletParamEntry
.
getMobile
());
user
=
iUserRegisterService
.
register
(
appletParamEntry
.
getChannelId
(),
appletParamEntry
.
getMobile
());
if
(
appletParamEntry
.
getTenantId
()
!=
null
)
{
iOauthLoginInfoService
.
addRegisterInfo
(
user
,
appletParamEntry
);
}
}
}
wechatUserInfo
.
setUserId
(
user
.
getId
());
wechatUserInfo
.
setUserId
(
user
.
getId
());
}
}
...
...
src/main/java/cn/quantgroup/xyqb/service/user/IOauthLoginInfoService.java
View file @
fcb33421
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.middleoffice.AppletParamEntry
;
/**
/**
* Created by Li Jianhua on 2017/1/3.
* Created by Li Jianhua on 2017/1/3.
*/
*/
public
interface
IOauthLoginInfoService
{
public
interface
IOauthLoginInfoService
{
void
addLoginInfo
(
User
user
,
Integer
tenantId
);
void
addLoginInfo
(
User
user
,
Integer
tenantId
);
void
addRegisterInfo
(
User
user
,
AppletParamEntry
appletParamEntry
);
}
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/OauthLoginInfoServiceImpl.java
View file @
fcb33421
package
cn
.
quantgroup
.
xyqb
.
service
.
user
.
impl
;
package
cn
.
quantgroup
.
xyqb
.
service
.
user
.
impl
;
import
cn.quantgroup.xyqb.entity.*
;
import
cn.quantgroup.xyqb.entity.*
;
import
cn.quantgroup.xyqb.entity.middleoffice.AppletParamEntry
;
import
cn.quantgroup.xyqb.repository.ICustomerInfoRepository
;
import
cn.quantgroup.xyqb.repository.ICustomerInfoRepository
;
import
cn.quantgroup.xyqb.repository.ICustomerLoginRepository
;
import
cn.quantgroup.xyqb.repository.ICustomerLoginRepository
;
import
cn.quantgroup.xyqb.repository.IOauthClientDetailsRepository
;
import
cn.quantgroup.xyqb.repository.IOauthClientDetailsRepository
;
...
@@ -40,7 +41,6 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService {
...
@@ -40,7 +41,6 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService {
@Override
@Override
@Transactional
(
propagation
=
Propagation
.
REQUIRES_NEW
)
@Transactional
(
propagation
=
Propagation
.
REQUIRES_NEW
)
public
void
addLoginInfo
(
User
user
,
Integer
tenantId
)
{
public
void
addLoginInfo
(
User
user
,
Integer
tenantId
)
{
System
.
out
.
println
(
atomicSequencer
.
nextId
());
OauthClientDetailsEntity
oauthClientDetailsEntity
=
oauthClientDetailsRepository
.
findFirstByClientId
(
tenantId
);
OauthClientDetailsEntity
oauthClientDetailsEntity
=
oauthClientDetailsRepository
.
findFirstByClientId
(
tenantId
);
if
(
oauthClientDetailsEntity
!=
null
)
{
if
(
oauthClientDetailsEntity
!=
null
)
{
String
institutionId
=
oauthClientDetailsEntity
.
getInstitutionId
();
String
institutionId
=
oauthClientDetailsEntity
.
getInstitutionId
();
...
@@ -99,4 +99,74 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService {
...
@@ -99,4 +99,74 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService {
}
}
}
}
@Override
@Transactional
(
propagation
=
Propagation
.
REQUIRES_NEW
)
public
void
addRegisterInfo
(
User
user
,
AppletParamEntry
appletParamEntry
)
{
OauthClientDetailsEntity
oauthClientDetailsEntity
=
oauthClientDetailsRepository
.
findFirstByClientId
(
appletParamEntry
.
getTenantId
());
if
(
oauthClientDetailsEntity
!=
null
)
{
String
institutionId
=
oauthClientDetailsEntity
.
getInstitutionId
();
String
productId
=
oauthClientDetailsEntity
.
getProductId
();
String
phoneNo
=
user
.
getPhoneNo
();
Long
userId
=
user
.
getId
();
ProductLoginEntity
productLoginEntity
=
productLoginRepository
.
findFirstByInstitutionIdAndProductIdAndPhoneNo
(
institutionId
,
productId
,
phoneNo
);
long
uuid
=
0L
;
// 如果找不到该用户就创建
if
(
""
.
equals
(
productLoginEntity
)
||
productLoginEntity
==
null
)
{
// 添加用户到产品登录表
long
customerId
=
atomicSequencer
.
nextId
();
long
id
=
atomicSequencer
.
nextId
();
String
customerName
=
customerId
+
""
;
uuid
=
RandomSequencer
.
randomUUID
(
customerId
);
ProductLoginEntity
entity
=
new
ProductLoginEntity
();
Integer
partitionKey
=
atomicSequencer
.
partitionKey
(
customerId
);
productLoginEntity
=
EntityBuilder
.
productLogin
(
productId
,
institutionId
,
phoneNo
,
customerId
,
customerName
,
partitionKey
,
id
);
productLoginEntity
.
setExtensionAccountId
(
userId
);
productLoginRepository
.
save
(
productLoginEntity
);
// 根据customerId 获取uuid
CustomerLoginEntity
customerLoginEntity
=
customerLoginRepository
.
findFirstByCustomerId
(
productLoginEntity
.
getCustomerId
());
if
(
null
!=
customerLoginEntity
)
{
uuid
=
customerLoginEntity
.
getUuid
();
}
// 添加用户到登录表
CustomerLoginEntity
customerLogin
=
new
CustomerLoginEntity
();
customerLogin
.
setId
(
atomicSequencer
.
nextId
());
customerLogin
.
setInstitutionId
(
institutionId
);
customerLogin
.
setProductId
(
productId
);
customerLogin
.
setCustomerId
(
customerId
);
customerLogin
.
setUuid
(
uuid
);
customerLogin
.
setPartitionKey
(
partitionKey
);
customerLogin
.
setCreatedDate
(
new
Date
());
customerLogin
.
setModifiedDate
(
new
Date
());
customerLogin
.
setCreatedBy
(
""
);
customerLogin
.
setModifiedBy
(
""
);
customerLoginRepository
.
save
(
customerLogin
);
// 添加用户信息表
CustomerInfoEntity
customerInfo
=
new
CustomerInfoEntity
();
customerInfo
.
setId
(
atomicSequencer
.
nextId
());
customerInfo
.
setCustomerId
(
customerId
);
customerInfo
.
setInstitutionId
(
institutionId
);
customerInfo
.
setAvatarUrl
(
appletParamEntry
.
getAvatarUrl
());
customerInfo
.
setNickName
(
appletParamEntry
.
getNickName
());
customerInfo
.
setCity
(
appletParamEntry
.
getCity
());
customerInfo
.
setCountry
(
appletParamEntry
.
getCountry
());
customerInfo
.
setProvince
(
appletParamEntry
.
getProvince
());
customerInfo
.
setLanguage
(
appletParamEntry
.
getLanguage
());
customerInfo
.
setSourceOpenId
(
appletParamEntry
.
getOpenId
());
customerInfo
.
setSex
(
cn
.
quantgroup
.
xyqb
.
model
.
Gender
.
class
.
getEnumConstants
()[
appletParamEntry
.
getGender
()]);
customerInfo
.
setUnionId
(
appletParamEntry
.
getUnionId
());
customerInfo
.
setUtmSource
(
appletParamEntry
.
getUtmSource
());
customerInfo
.
setProductId
(
productId
);
customerInfo
.
setPartitionKey
(
partitionKey
);
customerInfo
.
setCreatedDate
(
new
Date
());
customerInfo
.
setModifiedDate
(
new
Date
());
customerInfo
.
setCreatedBy
(
""
);
customerInfo
.
setModifiedBy
(
""
);
customerInfoRepository
.
save
(
customerInfo
);
}
}
}
}
}
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