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
af2b9ce7
Commit
af2b9ce7
authored
Mar 20, 2018
by
技术部-任文超
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '20180301-Fixed_LogException' into 20180316-UserStatistics
parents
9f290dbd
5b800aeb
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
5 deletions
+27
-5
MotanUserServiceImpl.java
.../xyqb/controller/external/motan/MotanUserServiceImpl.java
+1
-1
InnerController.java
...tgroup/xyqb/controller/external/user/InnerController.java
+1
-1
UserController.java
...ntgroup/xyqb/controller/internal/user/UserController.java
+1
-1
IWeChatUserRepository.java
.../cn/quantgroup/xyqb/repository/IWeChatUserRepository.java
+2
-0
IWechatService.java
...ava/cn/quantgroup/xyqb/service/wechat/IWechatService.java
+1
-1
WechatServiceImpl.java
...uantgroup/xyqb/service/wechat/impl/WechatServiceImpl.java
+21
-1
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/motan/MotanUserServiceImpl.java
View file @
af2b9ce7
...
@@ -470,7 +470,7 @@ public class MotanUserServiceImpl implements UserMotanService {
...
@@ -470,7 +470,7 @@ public class MotanUserServiceImpl implements UserMotanService {
if
(
userId
==
null
||
userId
<
1
)
{
if
(
userId
==
null
||
userId
<
1
)
{
return
returnErrorValue
(
"用户id不能为空"
);
return
returnErrorValue
(
"用户id不能为空"
);
}
}
WechatUserInfo
wechatUserInfo
=
wechatService
.
query
OpenId
ByUserId
(
userId
);
WechatUserInfo
wechatUserInfo
=
wechatService
.
queryByUserId
(
userId
);
if
(
wechatUserInfo
==
null
)
{
if
(
wechatUserInfo
==
null
)
{
return
returnErrorValue
(
"wechat信息为空"
);
return
returnErrorValue
(
"wechat信息为空"
);
}
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/user/InnerController.java
View file @
af2b9ce7
...
@@ -594,7 +594,7 @@ public class InnerController implements IBaseController {
...
@@ -594,7 +594,7 @@ public class InnerController implements IBaseController {
if
(
userId
==
null
)
{
if
(
userId
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
"userId不能为空"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"userId不能为空"
,
null
);
}
}
WechatUserInfo
wechatUserInfo
=
wechatService
.
query
OpenId
ByUserId
(
userId
);
WechatUserInfo
wechatUserInfo
=
wechatService
.
queryByUserId
(
userId
);
if
(
wechatUserInfo
==
null
)
{
if
(
wechatUserInfo
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/user/UserController.java
View file @
af2b9ce7
...
@@ -478,7 +478,7 @@ public class UserController implements IBaseController {
...
@@ -478,7 +478,7 @@ public class UserController implements IBaseController {
LOGGER
.
info
(
"微信关联openId,user:[{}],openId:[{}],wechatUserInfo:[{}]"
,
user
,
openId
,
userInfo
);
LOGGER
.
info
(
"微信关联openId,user:[{}],openId:[{}],wechatUserInfo:[{}]"
,
user
,
openId
,
userInfo
);
if
(
Objects
.
isNull
(
userInfo
)
&&
!
Objects
.
isNull
(
userId
))
{
if
(
Objects
.
isNull
(
userInfo
)
&&
!
Objects
.
isNull
(
userId
))
{
userInfo
=
wechatService
.
query
OpenId
ByUserId
(
userId
);
userInfo
=
wechatService
.
queryByUserId
(
userId
);
}
}
if
(
userInfo
==
null
||
StringUtils
.
isNotEmpty
(
userInfo
.
getPhoneNo
()))
{
if
(
userInfo
==
null
||
StringUtils
.
isNotEmpty
(
userInfo
.
getPhoneNo
()))
{
return
JsonResult
.
buildSuccessResult
(
null
,
null
);
return
JsonResult
.
buildSuccessResult
(
null
,
null
);
...
...
src/main/java/cn/quantgroup/xyqb/repository/IWeChatUserRepository.java
View file @
af2b9ce7
...
@@ -16,6 +16,8 @@ public interface IWeChatUserRepository extends JpaRepository<WechatUserInfo, Lon
...
@@ -16,6 +16,8 @@ public interface IWeChatUserRepository extends JpaRepository<WechatUserInfo, Lon
WechatUserInfo
findByUserId
(
Long
userId
);
WechatUserInfo
findByUserId
(
Long
userId
);
long
countByOpenId
(
String
openId
);
@Transactional
@Transactional
@Modifying
@Modifying
int
removeByUserId
(
Long
userId
);
int
removeByUserId
(
Long
userId
);
...
...
src/main/java/cn/quantgroup/xyqb/service/wechat/IWechatService.java
View file @
af2b9ce7
...
@@ -17,7 +17,7 @@ public interface IWechatService {
...
@@ -17,7 +17,7 @@ public interface IWechatService {
WechatUserInfo
saveWechatUserInfo
(
WechatUserInfo
userInfo
);
WechatUserInfo
saveWechatUserInfo
(
WechatUserInfo
userInfo
);
WechatUserInfo
query
OpenId
ByUserId
(
Long
userId
);
WechatUserInfo
queryByUserId
(
Long
userId
);
int
forbiddenUserWeChat
(
Long
userId
);
int
forbiddenUserWeChat
(
Long
userId
);
}
}
src/main/java/cn/quantgroup/xyqb/service/wechat/impl/WechatServiceImpl.java
View file @
af2b9ce7
...
@@ -5,24 +5,32 @@ import cn.quantgroup.xyqb.model.webchat.AccessTokenResponse;
...
@@ -5,24 +5,32 @@ import cn.quantgroup.xyqb.model.webchat.AccessTokenResponse;
import
cn.quantgroup.xyqb.repository.IWeChatUserRepository
;
import
cn.quantgroup.xyqb.repository.IWeChatUserRepository
;
import
cn.quantgroup.xyqb.service.http.IHttpService
;
import
cn.quantgroup.xyqb.service.http.IHttpService
;
import
cn.quantgroup.xyqb.service.wechat.IWechatService
;
import
cn.quantgroup.xyqb.service.wechat.IWechatService
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.domain.Example
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
import
java.util.Objects
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
/**
/**
* Created by Miraculous on 2017/1/19.
* Created by Miraculous on 2017/1/19.
*/
*/
@Slf4j
@Service
@Service
public
class
WechatServiceImpl
implements
IWechatService
{
public
class
WechatServiceImpl
implements
IWechatService
{
private
static
final
String
WECHAT_TOKEN_KEY_PREFIX
=
"wechat:token:"
;
private
static
final
String
WECHAT_TOKEN_KEY_PREFIX
=
"wechat:token:"
;
private
static
final
String
WECHAT_USERINFO_KEY_PREFIX
=
"wechat:userinfo:"
;
@Autowired
@Autowired
private
IHttpService
httpService
;
private
IHttpService
httpService
;
@Autowired
@Autowired
...
@@ -101,13 +109,23 @@ public class WechatServiceImpl implements IWechatService {
...
@@ -101,13 +109,23 @@ public class WechatServiceImpl implements IWechatService {
}
}
@Override
@Override
@Cacheable
(
value
=
"WechatUserInfo"
,
key
=
"'openId:' + #openId"
,
unless
=
"#result == null"
,
cacheManager
=
"cacheManager"
)
public
WechatUserInfo
findWechatUserInfoFromDb
(
String
openId
)
{
public
WechatUserInfo
findWechatUserInfoFromDb
(
String
openId
)
{
return
weChatUserRepository
.
findByOpenId
(
openId
);
return
weChatUserRepository
.
findByOpenId
(
openId
);
}
}
@Override
@Override
@CacheEvict
(
value
=
"WechatUserInfo"
,
key
=
"'openId:' + #userInfo.openId"
,
cacheManager
=
"cacheManager"
)
@Transactional
@Transactional
public
WechatUserInfo
saveWechatUserInfo
(
WechatUserInfo
userInfo
)
{
public
WechatUserInfo
saveWechatUserInfo
(
WechatUserInfo
userInfo
)
{
if
(
Objects
.
isNull
(
userInfo
)
||
Objects
.
isNull
(
userInfo
.
getOpenId
())){
return
null
;
}
long
count
=
weChatUserRepository
.
countByOpenId
(
userInfo
.
getOpenId
());
if
(
count
>
0
){
//注意,这里会抛异常(5000/total),Controller中已捕获处理
return
weChatUserRepository
.
findByOpenId
(
userInfo
.
getOpenId
());
}
if
(
null
==
userInfo
.
getPhoneNo
())
{
if
(
null
==
userInfo
.
getPhoneNo
())
{
userInfo
.
setPhoneNo
(
""
);
userInfo
.
setPhoneNo
(
""
);
}
}
...
@@ -135,12 +153,14 @@ public class WechatServiceImpl implements IWechatService {
...
@@ -135,12 +153,14 @@ public class WechatServiceImpl implements IWechatService {
}
}
@Override
@Override
public
WechatUserInfo
queryOpenIdByUserId
(
Long
userId
)
{
@Cacheable
(
value
=
"WechatUserInfo"
,
key
=
"'userId:' + #userId"
,
unless
=
"#result == null"
,
cacheManager
=
"cacheManager"
)
public
WechatUserInfo
queryByUserId
(
Long
userId
)
{
return
weChatUserRepository
.
findByUserId
(
userId
);
return
weChatUserRepository
.
findByUserId
(
userId
);
}
}
@Override
@Override
@CacheEvict
(
value
=
"WechatUserInfo"
,
key
=
"'userId:' + #userId"
,
cacheManager
=
"cacheManager"
)
public
int
forbiddenUserWeChat
(
Long
userId
)
{
public
int
forbiddenUserWeChat
(
Long
userId
)
{
return
weChatUserRepository
.
removeByUserId
(
userId
);
return
weChatUserRepository
.
removeByUserId
(
userId
);
}
}
...
...
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