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
6a1471f5
Commit
6a1471f5
authored
Apr 12, 2022
by
李健华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
注销用户多删除租户对应表
parent
9506266d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
35 additions
and
20 deletions
+35
-20
IProductLoginRepository.java
...n/quantgroup/xyqb/repository/IProductLoginRepository.java
+11
-0
IProductLoginService.java
...cn/quantgroup/xyqb/service/user/IProductLoginService.java
+2
-0
OauthLoginInfoServiceImpl.java
...oup/xyqb/service/user/impl/OauthLoginInfoServiceImpl.java
+6
-19
ProductLoginServiceImpl.java
...group/xyqb/service/user/impl/ProductLoginServiceImpl.java
+9
-0
UserServiceImpl.java
...cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
+6
-0
Md5Util.java
src/main/java/cn/quantgroup/xyqb/util/encrypt/Md5Util.java
+1
-1
xyqb-user2.2022-04-11-0.gz
xyqb-user2.2022-04-11-0.gz
+0
-0
No files found.
src/main/java/cn/quantgroup/xyqb/repository/IProductLoginRepository.java
View file @
6a1471f5
...
...
@@ -2,8 +2,12 @@ package cn.quantgroup.xyqb.repository;
import
cn.quantgroup.xyqb.entity.ProductLoginEntity
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -36,4 +40,11 @@ public interface IProductLoginRepository extends JpaRepository<ProductLoginEntit
List
<
ProductLoginEntity
>
findProductLoginsByInstitutionIdAndProductId
(
String
institutionId
,
String
productId
);
ProductLoginEntity
findFirstByInstitutionIdAndProductIdAndCustomerId
(
String
institutionId
,
String
productId
,
long
customerId
);
@Transactional
@Query
(
value
=
"delete from product_login where INSTITUTION_ID = ?1 and PRODUCT_ID = ?2 and PHONE_NO = ?3"
,
nativeQuery
=
true
)
@Modifying
void
deleteTenantAndPhoneNo
(
String
qtg
,
String
yxm
,
String
phoneNo
);
}
\ No newline at end of file
src/main/java/cn/quantgroup/xyqb/service/user/IProductLoginService.java
View file @
6a1471f5
...
...
@@ -24,4 +24,6 @@ public interface IProductLoginService {
List
<
ProductLoginEntity
>
findProductLoginsByInstitutionIdAndProductId
(
String
institutionId
,
String
productId
);
ProductLoginEntity
findSlaveByCustomerInfo
(
long
customerId
,
String
institutionId
,
String
productId
);
ProductLoginEntity
findTenantAndPhoneNo
(
String
institutionId
,
String
productId
,
String
phoneNo
);
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/OauthLoginInfoServiceImpl.java
View file @
6a1471f5
...
...
@@ -7,6 +7,7 @@ import cn.quantgroup.xyqb.repository.ICustomerLoginRepository;
import
cn.quantgroup.xyqb.repository.IOauthClientDetailsRepository
;
import
cn.quantgroup.xyqb.repository.IProductLoginRepository
;
import
cn.quantgroup.xyqb.service.user.IOauthLoginInfoService
;
import
cn.quantgroup.xyqb.service.user.IProductLoginService
;
import
cn.quantgroup.xyqb.util.AtomicSequencer
;
import
cn.quantgroup.xyqb.util.RandomSequencer
;
import
com.alibaba.fastjson.JSON
;
...
...
@@ -36,13 +37,15 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService {
@Autowired
private
ICustomerLoginRepository
customerLoginRepository
;
@Autowired
private
IProductLoginService
productLoginService
;
@Autowired
private
AtomicSequencer
atomicSequencer
;
@Override
@Transactional
(
propagation
=
Propagation
.
REQUIRES_NEW
,
rollbackFor
=
Exception
.
class
)
public
void
addLoginInfo
(
User
user
,
Integer
tenantId
)
{
log
.
info
(
"=addLoginInfo -> user={}, tenetId={}"
,
JSON
.
toJSONString
(
user
),
tenantId
);
OauthClientDetailsEntity
oauthClientDetailsEntity
=
oauthClientDetailsRepository
.
findFirstByClientId
(
tenantId
);
if
(
oauthClientDetailsEntity
!=
null
)
{
String
institutionId
=
oauthClientDetailsEntity
.
getInstitutionId
();
...
...
@@ -50,11 +53,8 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService {
String
phoneNo
=
user
.
getPhoneNo
();
Long
userId
=
user
.
getId
();
ProductLoginEntity
findProductLoginEntity
=
productLoginRepository
.
findByInstitutionIdAndProductIdAndExtensionAccountId
(
institutionId
,
productId
,
userId
);
ProductLoginEntity
findProductLoginByPhoneEntity
=
productLoginRepository
.
findFirstByInstitutionIdAndProductIdAndEncryptedPhoneNo
(
institutionId
,
productId
,
phoneNo
);
log
.
info
(
"=findProductLoginEntity -> {}"
,
JSON
.
toJSONString
(
findProductLoginEntity
));
log
.
info
(
"=findProductLoginPhoneEntity -> {}"
,
JSON
.
toJSONString
(
findProductLoginByPhoneEntity
));
ProductLoginEntity
findProductLoginByPhoneEntity
=
productLoginService
.
findTenantAndPhoneNo
(
institutionId
,
productId
,
phoneNo
);
long
uuid
=
0L
;
// 如果找不到该用户就创建
if
(
findProductLoginEntity
==
null
&&
findProductLoginByPhoneEntity
==
null
)
{
// 添加用户到产品登录表
long
customerId
=
atomicSequencer
.
nextId
();
...
...
@@ -67,9 +67,7 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService {
ProductLoginEntity
productLoginEntity
=
EntityBuilder
.
productLogin
(
productId
,
institutionId
,
phoneNo
,
customerId
,
customerName
,
partitionKey
,
id
);
productLoginEntity
.
setExtensionAccountId
(
userId
);
productLoginEntity
.
setEncryptedPhoneNo
(
phoneNo
);
log
.
info
(
"=addLoginInfo=save begin productLoginRepository={}"
,
JSON
.
toJSONString
(
productLoginEntity
));
productLoginRepository
.
save
(
productLoginEntity
);
log
.
info
(
"=addLoginInfo=save end productLoginRepository={}"
,
JSON
.
toJSONString
(
productLoginEntity
));
// 根据customerId 获取uuid
CustomerLoginEntity
customerLoginEntity
=
customerLoginRepository
.
findFirstByCustomerId
(
productLoginEntity
.
getCustomerId
());
if
(
null
!=
customerLoginEntity
)
{
...
...
@@ -88,9 +86,7 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService {
customerLogin
.
setModifiedDate
(
new
Date
());
customerLogin
.
setCreatedBy
(
""
);
customerLogin
.
setModifiedBy
(
""
);
log
.
info
(
"=addLoginInfo=save begin customerLoginRepository={}"
,
JSON
.
toJSONString
(
customerLogin
));
customerLoginRepository
.
save
(
customerLogin
);
log
.
info
(
"=addLoginInfo=save end customerLoginRepository={}"
,
JSON
.
toJSONString
(
customerLogin
));
// 添加用户信息表
CustomerInfoEntity
customerInfo
=
new
CustomerInfoEntity
();
// customerInfo.setId(atomicSequencer.nextId());
...
...
@@ -102,9 +98,7 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService {
customerInfo
.
setModifiedDate
(
new
Date
());
customerInfo
.
setCreatedBy
(
""
);
customerInfo
.
setModifiedBy
(
""
);
log
.
info
(
"=addLoginInfo=save begin customerInfoRepository={}"
,
JSON
.
toJSONString
(
customerInfo
));
customerInfoRepository
.
save
(
customerInfo
);
log
.
info
(
"=addLoginInfo=save end customerInfoRepository={}"
,
JSON
.
toJSONString
(
customerInfo
));
}
}
}
...
...
@@ -112,14 +106,13 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService {
@Override
@Transactional
(
propagation
=
Propagation
.
REQUIRES_NEW
)
public
void
addRegisterInfo
(
User
user
,
AppletParamEntry
appletParamEntry
)
{
log
.
info
(
"=addRegisterInfo= -> User={}, AppletParamEntry={}"
,
JSON
.
toJSONString
(
user
),
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
=
productLogin
Repository
.
findFirstByInstitutionIdAndProductIdAndEncrypte
dPhoneNo
(
institutionId
,
productId
,
phoneNo
);
ProductLoginEntity
productLoginEntity
=
productLogin
Service
.
findTenantAn
dPhoneNo
(
institutionId
,
productId
,
phoneNo
);
long
uuid
=
0L
;
// 如果找不到该用户就创建
if
(
""
.
equals
(
productLoginEntity
)
||
productLoginEntity
==
null
)
{
...
...
@@ -133,9 +126,7 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService {
productLoginEntity
=
EntityBuilder
.
productLogin
(
productId
,
institutionId
,
phoneNo
,
customerId
,
customerName
,
partitionKey
,
id
);
productLoginEntity
.
setExtensionAccountId
(
userId
);
productLoginEntity
.
setEncryptedPhoneNo
(
phoneNo
);
log
.
info
(
"=addRegisterInfo=save begin productLoginRepository= {}"
,
JSON
.
toJSONString
(
productLoginEntity
));
productLoginRepository
.
save
(
productLoginEntity
);
log
.
info
(
"=addRegisterInfo=save end productLoginRepository= {}"
,
JSON
.
toJSONString
(
productLoginEntity
));
// 根据customerId 获取uuid
CustomerLoginEntity
customerLoginEntity
=
customerLoginRepository
.
findFirstByCustomerId
(
productLoginEntity
.
getCustomerId
());
if
(
null
!=
customerLoginEntity
)
{
...
...
@@ -154,9 +145,7 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService {
customerLogin
.
setModifiedDate
(
new
Date
());
customerLogin
.
setCreatedBy
(
""
);
customerLogin
.
setModifiedBy
(
""
);
log
.
info
(
"=addRegisterInfo=save begin customerLoginRepository= {}"
,
JSON
.
toJSONString
(
customerLogin
));
customerLoginRepository
.
save
(
customerLogin
);
log
.
info
(
"=addRegisterInfo=save end customerLoginRepository= {}"
,
JSON
.
toJSONString
(
customerLogin
));
// 添加用户信息表
CustomerInfoEntity
customerInfo
=
new
CustomerInfoEntity
();
// customerInfo.setId(atomicSequencer.nextId());
...
...
@@ -179,9 +168,7 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService {
customerInfo
.
setModifiedDate
(
new
Date
());
customerInfo
.
setCreatedBy
(
""
);
customerInfo
.
setModifiedBy
(
""
);
log
.
info
(
"=addRegisterInfo=save begin customerInfoRepository= {}"
,
JSON
.
toJSONString
(
customerInfo
));
customerInfoRepository
.
save
(
customerInfo
);
log
.
info
(
"=addRegisterInfo=save end customerInfoRepository= {}"
,
JSON
.
toJSONString
(
customerInfo
));
}
else
{
// 如果产品登陆表有信息,查询用户信息表
CustomerInfoEntity
customerInfo
=
customerInfoRepository
.
findByCustomerId
(
productLoginEntity
.
getCustomerId
());
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/ProductLoginServiceImpl.java
View file @
6a1471f5
...
...
@@ -55,4 +55,13 @@ public class ProductLoginServiceImpl implements IProductLoginService {
public
ProductLoginEntity
findSlaveByCustomerInfo
(
long
customerId
,
String
institutionId
,
String
productId
)
{
return
productLoginRepository
.
findFirstByInstitutionIdAndProductIdAndCustomerId
(
institutionId
,
productId
,
customerId
);
}
@Override
public
ProductLoginEntity
findTenantAndPhoneNo
(
String
institutionId
,
String
productId
,
String
phoneNo
)
{
ProductLoginEntity
productLogin
=
productLoginRepository
.
findFirstByInstitutionIdAndProductIdAndEncryptedPhoneNo
(
institutionId
,
productId
,
phoneNo
);
if
(
productLogin
==
null
)
{
productLogin
=
productLoginRepository
.
findFirstByInstitutionIdAndProductIdAndPhoneNo
(
institutionId
,
productId
,
phoneNo
);
}
return
productLogin
;
}
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
View file @
6a1471f5
...
...
@@ -106,6 +106,9 @@ public class UserServiceImpl implements IUserService, IBaseController {
@Resource
private
IWeChatUserRepository
weChatUserRepository
;
@Resource
private
IProductLoginRepository
productLoginRepository
;
@Override
// @Cacheable(value = "usercache", key = "'xyqbuser' + #phone", unless = "#result == null", cacheManager = "cacheManager")
public
User
findByPhoneInDb
(
String
phone
)
{
...
...
@@ -599,5 +602,8 @@ public class UserServiceImpl implements IUserService, IBaseController {
/* 禁用微信 Or 删除?*/
// wechatService.forbiddenXyqbAndWuxiUserByUserId(user.getId());
weChatUserRepository
.
deleteByUserId
(
userId
);
/* 删除用户租户关联 羊小咩租户*/
productLoginRepository
.
deleteTenantAndPhoneNo
(
"qtg"
,
"yxm"
,
user
.
getPhoneNo
());
}
}
src/main/java/cn/quantgroup/xyqb/util/encrypt/Md5Util.java
View file @
6a1471f5
...
...
@@ -37,6 +37,6 @@ public final class Md5Util {
}
public
static
void
main
(
String
[]
args
){
System
.
out
.
println
(
Md5Util
.
build
(
"1
3718656985
"
));
System
.
out
.
println
(
Md5Util
.
build
(
"1
5010826659
"
));
}
}
xyqb-user2.2022-04-11-0.gz
0 → 100644
View file @
6a1471f5
File added
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