Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
promotion-service
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
promotion
promotion-service
Commits
6886ea2c
提交
6886ea2c
authored
5月 24, 2024
作者:
李秋林
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
controller层返回值手动添加R封闭
上级
96b60d06
隐藏空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
111 行增加
和
118 行删除
+111
-118
WangxiaoluPromotionServiceApplication.java
...aolu/promotion/WangxiaoluPromotionServiceApplication.java
+1
-0
ControllerResponseAdvice.java
...wangxiaolu/promotion/advice/ControllerResponseAdvice.java
+45
-0
ControllerLogAspect.java
...angxiaolu/promotion/config/aspet/ControllerLogAspect.java
+0
-79
TemporaryActivityClockQueryController.java
...vity/temporary/TemporaryActivityClockQueryController.java
+9
-5
TemporaryActivityCoreController.java
...r/activity/temporary/TemporaryActivityCoreController.java
+8
-5
TemporaryActivityQueryController.java
.../activity/temporary/TemporaryActivityQueryController.java
+7
-6
PromotionLoginController.java
...u/promotion/controller/user/PromotionLoginController.java
+3
-1
QinCeClienteleDataQueryController.java
...on/controller/user/QinCeClienteleDataQueryController.java
+3
-2
QinCeDataTaskController.java
...lu/promotion/controller/user/QinCeDataTaskController.java
+7
-3
UserSendSms.java
...com/wangxiaolu/promotion/controller/user/UserSendSms.java
+3
-1
WeChatUserCoreController.java
...promotion/controller/wechat/WeChatUserCoreController.java
+3
-2
WeChatUserQueryController.java
...romotion/controller/wechat/WeChatUserQueryController.java
+7
-5
WeChatUserQueryService.java
...aolu/promotion/service/wechat/WeChatUserQueryService.java
+1
-1
WeChatUserQueryServiceImpl.java
...otion/service/wechat/impl/WeChatUserQueryServiceImpl.java
+9
-4
TemporaryActivityCoreControllerTest.java
...tivity/temporary/TemporaryActivityCoreControllerTest.java
+3
-2
WeChatUserQueryControllerTest.java
...tion/controller/wechat/WeChatUserQueryControllerTest.java
+2
-2
没有找到文件。
src/main/java/com/wangxiaolu/promotion/WangxiaoluPromotionServiceApplication.java
浏览文件 @
6886ea2c
...
...
@@ -16,4 +16,5 @@ public class WangxiaoluPromotionServiceApplication {
SpringApplication
.
run
(
WangxiaoluPromotionServiceApplication
.
class
,
args
);
}
}
src/main/java/com/wangxiaolu/promotion/advice/ControllerResponseAdvice.java
0 → 100644
浏览文件 @
6886ea2c
package
com
.
wangxiaolu
.
promotion
.
advice
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.wangxiaolu.promotion.exception.APIException
;
import
com.wangxiaolu.promotion.result.basedata.R
;
import
com.wangxiaolu.promotion.result.basedata.RCode
;
import
org.springframework.core.MethodParameter
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.http.server.ServerHttpRequest
;
import
org.springframework.http.server.ServerHttpResponse
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice
;
/**
* @author : liqiulin
* @date : 2024-03-28 17
* @describe : todo 自动封装
*/
@RestControllerAdvice
public
class
ControllerResponseAdvice
implements
ResponseBodyAdvice
<
Object
>
{
@Override
public
boolean
supports
(
MethodParameter
methodParameter
,
Class
<?
extends
HttpMessageConverter
<?>>
aClass
)
{
// response是R类型或者注释了NotControllerResponseAdvice都不进行包装
return
!
methodParameter
.
getParameterType
().
isAssignableFrom
(
R
.
class
);
}
@Override
public
Object
beforeBodyWrite
(
Object
data
,
MethodParameter
methodParameter
,
MediaType
mediaType
,
Class
<?
extends
HttpMessageConverter
<?>>
aClass
,
ServerHttpRequest
serverHttpRequest
,
ServerHttpResponse
serverHttpResponse
)
{
// String类型不能直接包装
if
(
methodParameter
.
getGenericParameterType
().
equals
(
String
.
class
))
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
try
{
// 将数据包装在ResultVo里后转换为json串进行返回
return
objectMapper
.
writeValueAsString
(
new
R
(
data
));
}
catch
(
JsonProcessingException
e
)
{
throw
new
APIException
(
RCode
.
RESPONSE_PACK_ERROR
,
e
.
getMessage
());
}
}
// 包装成R返回
return
new
R
(
data
);
}
}
src/main/java/com/wangxiaolu/promotion/config/aspet/ControllerLogAspect.java
deleted
100644 → 0
浏览文件 @
96b60d06
package
com
.
wangxiaolu
.
promotion
.
config
.
aspet
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.support.spring.PropertyPreFilters
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.Signature
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Before
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.ServletResponse
;
import
javax.servlet.http.HttpServletRequest
;
@Slf4j
@Component
@Aspect
public
class
ControllerLogAspect
{
/**
* 对controller包中的所有类中的所有public类进行增强
*/
@Pointcut
(
"execution(public * com.wangxiaolu.promotion.controller..*.*(..))"
)
private
void
pointcut
(){}
@Before
(
"pointcut()"
)
public
void
before
(
JoinPoint
joinPoint
){
/**
* 此次请求
*/
ServletRequestAttributes
sra
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
HttpServletRequest
request
=
sra
.
getRequest
();
// Signature signature = joinPoint.getSignature();
// String name = signature.getName();
log
.
info
(
"------------- 开始 -------------"
);
log
.
info
(
"请求地址:{}:{}"
,
request
.
getMethod
(),
request
.
getRequestURL
().
toString
());
// log.info("类路径:{};方法名:{}", signature.getDeclaringTypeName(), name);
Object
[]
args
=
joinPoint
.
getArgs
();
Object
[]
arguments
=
new
Object
[
args
.
length
];
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
if
(
args
[
i
]
instanceof
ServletRequest
||
args
[
i
]
instanceof
ServletResponse
||
args
[
i
]
instanceof
MultipartFile
)
{
continue
;
}
arguments
[
i
]
=
args
[
i
];
}
String
[]
excludeProperties
=
{
"password"
,
"file"
};
PropertyPreFilters
filters
=
new
PropertyPreFilters
();
PropertyPreFilters
.
MySimplePropertyPreFilter
excludeFilter
=
filters
.
addFilter
();
excludeFilter
.
addExcludes
(
excludeProperties
);
log
.
info
(
"请求参数: {}"
,
JSONObject
.
toJSONString
(
arguments
,
excludeFilter
));
}
@Around
(
"pointcut()"
)
public
Object
around
(
ProceedingJoinPoint
proceedingJoinPoint
)
throws
Throwable
{
long
millis
=
System
.
currentTimeMillis
();
Object
result
=
proceedingJoinPoint
.
proceed
();
String
[]
excludeProperties
=
{
"password"
,
"file"
};
PropertyPreFilters
filters
=
new
PropertyPreFilters
();
PropertyPreFilters
.
MySimplePropertyPreFilter
excludeFilter
=
filters
.
addFilter
();
excludeFilter
.
addExcludes
(
excludeProperties
);
log
.
info
(
"返回结果: {}"
,
JSONObject
.
toJSONString
(
result
,
excludeFilter
));
log
.
info
(
"------------- 结束 耗时:{} ms -------------"
,
System
.
currentTimeMillis
()
-
millis
);
return
result
;
}
}
src/main/java/com/wangxiaolu/promotion/controller/activity/temporary/TemporaryActivityClockQueryController.java
浏览文件 @
6886ea2c
package
com
.
wangxiaolu
.
promotion
.
controller
.
activity
.
temporary
;
import
com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryClockDto
;
import
com.wangxiaolu.promotion.result.basedata.R
;
import
com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityClockQueryService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -26,18 +27,21 @@ public class TemporaryActivityClockQueryController {
* 根据促销员id查询今日打卡信息
*/
@GetMapping
(
"/{temporary_id}"
)
public
TemporaryClockDto
findTodayTemporaryClockByTemId
(
@PathVariable
(
"temporary_id"
)
@NotNull
Integer
temporaryId
)
{
return
temporaryActivityClockQueryService
.
findTodayTemporaryClockByTemId
(
temporaryId
);
public
R
findTodayTemporaryClockByTemId
(
@PathVariable
(
"temporary_id"
)
@NotNull
Integer
temporaryId
)
{
TemporaryClockDto
clockDto
=
temporaryActivityClockQueryService
.
findTodayTemporaryClockByTemId
(
temporaryId
);
return
R
.
success
(
clockDto
);
}
/**
* 根据促销员id查询指定日期打卡信息
*
* @param temporaryId 促销员id
* @param createDate 指定日期,格式:2024-04-25
* @param createDate
指定日期,格式:2024-04-25
* @return 打卡信息
*/
@GetMapping
(
"/date"
)
public
TemporaryClockDto
findTemporaryClockByTemIdAndDate
(
Integer
temporaryId
,
String
createDate
)
{
return
temporaryActivityClockQueryService
.
findTemporaryClockByTemIdAndDate
(
temporaryId
,
createDate
);
public
R
findTemporaryClockByTemIdAndDate
(
Integer
temporaryId
,
String
createDate
)
{
TemporaryClockDto
clockDto
=
temporaryActivityClockQueryService
.
findTemporaryClockByTemIdAndDate
(
temporaryId
,
createDate
);
return
R
.
success
(
clockDto
);
}
}
src/main/java/com/wangxiaolu/promotion/controller/activity/temporary/TemporaryActivityCoreController.java
浏览文件 @
6886ea2c
package
com
.
wangxiaolu
.
promotion
.
controller
.
activity
.
temporary
;
import
com.wangxiaolu.promotion.exception.ParamException
;
import
com.wangxiaolu.promotion.result.basedata.R
;
import
com.wangxiaolu.promotion.result.basedata.RCode
;
import
com.wangxiaolu.promotion.enums.activity.ClockType
;
import
com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto
;
...
...
@@ -36,7 +37,7 @@ public class TemporaryActivityCoreController {
* 促销员当日打卡信息保存
*/
@PostMapping
(
"/today/clock"
)
public
void
clockInTodayActivity
(
@RequestBody
@Validated
TemporaryClockVo
clockVo
)
{
public
R
clockInTodayActivity
(
@RequestBody
@Validated
TemporaryClockVo
clockVo
)
{
Integer
clockType
=
clockVo
.
getClockType
();
boolean
isClockIn
=
ClockType
.
TEMPORARY_CLOCK_IN
.
equals
(
clockType
);
// 上班卡必需有店铺id
...
...
@@ -61,6 +62,7 @@ public class TemporaryActivityCoreController {
builderClockOutData
(
clockVo
,
dto
,
clockTime
);
}
tempActivityCoreService
.
clockInTodayActivity
(
dto
,
clockType
);
return
R
.
success
();
}
/**
...
...
@@ -68,7 +70,7 @@ public class TemporaryActivityCoreController {
* 返回活动生成id
*/
@PostMapping
(
"/today/reported"
)
public
Long
todayActivityDataReported
(
@RequestBody
@Validated
TemporaryActivityDataVo
activityVo
)
{
public
R
todayActivityDataReported
(
@RequestBody
@Validated
TemporaryActivityDataVo
activityVo
)
{
TemporaryActivityReportedDto
temActDto
=
new
TemporaryActivityReportedDto
();
BeanUtils
.
copyProperties
(
activityVo
,
temActDto
);
temActDto
.
setId
(
activityVo
.
getActivityReportedId
());
...
...
@@ -76,9 +78,9 @@ public class TemporaryActivityCoreController {
// 有ID则修改,无ID则新建
if
(
Objects
.
nonNull
(
activityVo
.
getActivityReportedId
()))
{
tempActivityCoreService
.
activityDataReportedUpdate
(
temActDto
);
return
activityVo
.
getActivityReportedId
(
);
return
R
.
success
(
activityVo
.
getActivityReportedId
()
);
}
return
tempActivityCoreService
.
activityDataReportedSave
(
temActDto
);
return
R
.
success
(
tempActivityCoreService
.
activityDataReportedSave
(
temActDto
)
);
}
/**
...
...
@@ -86,8 +88,9 @@ public class TemporaryActivityCoreController {
* 修改审批状态
*/
@PutMapping
(
"/reported/approve/submit/{id}"
)
public
void
activityReportedSubmit
(
@PathVariable
(
"id"
)
@NotNull
Long
id
)
{
public
R
activityReportedSubmit
(
@PathVariable
(
"id"
)
@NotNull
Long
id
)
{
tempActivityCoreService
.
activityReportedSubmit
(
id
);
return
R
.
success
();
}
...
...
src/main/java/com/wangxiaolu/promotion/controller/activity/temporary/TemporaryActivityQueryController.java
浏览文件 @
6886ea2c
...
...
@@ -2,6 +2,7 @@ package com.wangxiaolu.promotion.controller.activity.temporary;
import
com.wangxiaolu.promotion.pojo.PageInfo
;
import
com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto
;
import
com.wangxiaolu.promotion.result.basedata.R
;
import
com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityQueryService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -28,26 +29,26 @@ public class TemporaryActivityQueryController {
* @return 所有任务(分页查询)
*/
@PostMapping
(
"/all/{id}"
)
public
PageInfo
findtemporaryIdActivityDataList
(
@PathVariable
(
"id"
)
@NotNull
Integer
temporaryId
,
@RequestBody
PageInfo
pageInfo
)
{
public
R
findtemporaryIdActivityDataList
(
@PathVariable
(
"id"
)
@NotNull
Integer
temporaryId
,
@RequestBody
PageInfo
pageInfo
)
{
temporaryActivityQueryService
.
findtemporaryIdActivityDataList
(
temporaryId
,
pageInfo
);
return
pageInfo
;
return
R
.
success
(
pageInfo
)
;
}
/**
* 根据促销员id查询今日任务
*/
@GetMapping
(
"/today/{id}"
)
public
TemporaryActivityReportedDto
findTemporaryTodayActivityData
(
@PathVariable
(
"id"
)
@NotNull
Integer
temporaryId
)
{
public
R
findTemporaryTodayActivityData
(
@PathVariable
(
"id"
)
@NotNull
Integer
temporaryId
)
{
TemporaryActivityReportedDto
dto
=
temporaryActivityQueryService
.
findtemporaryIdTodayActivityData
(
temporaryId
);
return
dto
;
return
R
.
success
(
dto
)
;
}
/**
* 根据任务id查询
*/
@GetMapping
(
"/{id}"
)
public
TemporaryActivityReportedDto
findTemporaryActivityById
(
@PathVariable
(
"id"
)
@NotNull
Long
activityId
)
{
public
R
findTemporaryActivityById
(
@PathVariable
(
"id"
)
@NotNull
Long
activityId
)
{
TemporaryActivityReportedDto
dto
=
temporaryActivityQueryService
.
findTemporaryActivityById
(
activityId
);
return
dto
;
return
R
.
success
(
dto
)
;
}
}
src/main/java/com/wangxiaolu/promotion/controller/user/PromotionLoginController.java
浏览文件 @
6886ea2c
package
com
.
wangxiaolu
.
promotion
.
controller
.
user
;
import
com.wangxiaolu.promotion.pojo.user.vo.UserLoginParam
;
import
com.wangxiaolu.promotion.result.basedata.R
;
import
com.wangxiaolu.promotion.service.user.PromotionService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
...
...
@@ -23,7 +24,8 @@ public class PromotionLoginController {
PromotionService
promotionService
;
@PostMapping
(
"/login"
)
public
void
login
(
@Validated
@RequestBody
UserLoginParam
userLoginParam
){
public
R
login
(
@Validated
@RequestBody
UserLoginParam
userLoginParam
){
promotionService
.
login
(
userLoginParam
);
return
R
.
success
();
}
}
src/main/java/com/wangxiaolu/promotion/controller/user/QinCeClienteleDataQueryController.java
浏览文件 @
6886ea2c
...
...
@@ -2,6 +2,7 @@ package com.wangxiaolu.promotion.controller.user;
import
com.wangxiaolu.promotion.pojo.user.dto.QinCeClienteleStoreDto
;
import
com.wangxiaolu.promotion.pojo.user.vo.ClienteleStoreQueryVo
;
import
com.wangxiaolu.promotion.result.basedata.R
;
import
com.wangxiaolu.promotion.service.user.QinCeClienteleDataQueryService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -28,8 +29,8 @@ public class QinCeClienteleDataQueryController {
* 模糊查询门店名称
*/
@PostMapping
(
"/store/list"
)
public
List
<
QinCeClienteleStoreDto
>
getStoreList
(
@RequestBody
ClienteleStoreQueryVo
storeQueryVo
)
{
return
qinCeClienteleDataQueryService
.
getStoreList
(
storeQueryVo
);
public
R
getStoreList
(
@RequestBody
ClienteleStoreQueryVo
storeQueryVo
)
{
return
R
.
success
(
qinCeClienteleDataQueryService
.
getStoreList
(
storeQueryVo
)
);
}
...
...
src/main/java/com/wangxiaolu/promotion/controller/user/QinCeDataTaskController.java
浏览文件 @
6886ea2c
package
com
.
wangxiaolu
.
promotion
.
controller
.
user
;
import
com.wangxiaolu.promotion.result.basedata.R
;
import
com.wangxiaolu.promotion.service.user.QinCeDataTaskService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -22,24 +23,27 @@ public class QinCeDataTaskController {
* 同步组织架构/部门数据
*/
@GetMapping
(
"/department"
)
public
void
departmentTask
(){
public
R
departmentTask
(){
qinCeDataTaskService
.
departmentSyncTask
();
return
R
.
success
();
}
/**
* 同步员工数据
*/
@GetMapping
(
"/employee"
)
public
void
employeeTask
(){
public
R
employeeTask
(){
qinCeDataTaskService
.
employeeSyncTask
();
return
R
.
success
();
}
/**
* 同步[终端数据]
*/
@GetMapping
(
"/shops"
)
public
void
shopDetailAllTask
(){
public
R
shopDetailAllTask
(){
qinCeDataTaskService
.
shopDetailAllTask
();
return
R
.
success
();
}
...
...
src/main/java/com/wangxiaolu/promotion/controller/user/UserSendSms.java
浏览文件 @
6886ea2c
package
com
.
wangxiaolu
.
promotion
.
controller
.
user
;
import
com.wangxiaolu.promotion.exception.ParamException
;
import
com.wangxiaolu.promotion.result.basedata.R
;
import
com.wangxiaolu.promotion.result.basedata.RCode
;
import
com.wangxiaolu.promotion.service.user.TencentCoreService
;
import
com.wangxiaolu.promotion.common.util.DataUtils
;
...
...
@@ -28,12 +29,13 @@ public class UserSendSms {
* 腾讯云短信
*/
@PostMapping
(
"/send/ver_code"
)
public
void
sendSms
(
@RequestBody
Map
<
String
,
String
>
phoneInfo
)
{
public
R
sendSms
(
@RequestBody
Map
<
String
,
String
>
phoneInfo
)
{
String
phone
=
phoneInfo
.
get
(
"phone"
);
if
(
StringUtils
.
isEmpty
(
phone
)
||
!
DataUtils
.
phonePattern
(
phone
))
{
throw
new
ParamException
(
RCode
.
PHONE_PARAM_ERROR
,
null
);
}
tencentCoreService
.
sendSmsPhoneVerCode
(
phone
);
return
R
.
success
();
}
...
...
src/main/java/com/wangxiaolu/promotion/controller/wechat/WeChatUserCoreController.java
浏览文件 @
6886ea2c
...
...
@@ -6,6 +6,7 @@ import com.wangxiaolu.promotion.common.redis.service.RedisCache;
import
com.wangxiaolu.promotion.exception.ParamException
;
import
com.wangxiaolu.promotion.pojo.user.dto.WxTemporaryInfoDto
;
import
com.wangxiaolu.promotion.pojo.user.vo.WxTemporaryEnrollVo
;
import
com.wangxiaolu.promotion.result.basedata.R
;
import
com.wangxiaolu.promotion.result.basedata.RCode
;
import
com.wangxiaolu.promotion.service.wechat.WeChatUserCoreService
;
import
com.wangxiaolu.promotion.common.util.DataUtils
;
...
...
@@ -38,7 +39,7 @@ public class WeChatUserCoreController {
* 促销员注册信息
*/
@PostMapping
(
"/temporary/enroll"
)
public
boolean
enrollUserInfo
(
@RequestBody
@Validated
WxTemporaryEnrollVo
wxTemporaryEnrollVo
)
{
public
R
enrollUserInfo
(
@RequestBody
@Validated
WxTemporaryEnrollVo
wxTemporaryEnrollVo
)
{
log
.
info
(
"微信-促销员注册:{}"
,
JSONObject
.
toJSONString
(
wxTemporaryEnrollVo
));
// 人员信息校验
boolean
isIden
=
DataUtils
.
idenCardPattern
(
wxTemporaryEnrollVo
.
getIdenNumber
());
...
...
@@ -59,7 +60,7 @@ public class WeChatUserCoreController {
WxTemporaryInfoDto
temporaryDto
=
new
WxTemporaryInfoDto
();
BeanUtils
.
copyProperties
(
wxTemporaryEnrollVo
,
temporaryDto
);
return
weChatUserCoreService
.
saveWxUserInfoTemporary
(
temporaryDto
);
return
R
.
success
(
weChatUserCoreService
.
saveWxUserInfoTemporary
(
temporaryDto
)
);
}
}
src/main/java/com/wangxiaolu/promotion/controller/wechat/WeChatUserQueryController.java
浏览文件 @
6886ea2c
package
com
.
wangxiaolu
.
promotion
.
controller
.
wechat
;
import
com.wangxiaolu.promotion.common.util.DataUtils
;
import
com.wangxiaolu.promotion.exception.ParamException
;
import
com.wangxiaolu.promotion.pojo.user.dto.WxTemporaryInfoDto
;
import
com.wangxiaolu.promotion.pojo.user.vo.WxTemporaryLoginVo
;
import
com.wangxiaolu.promotion.result.basedata.R
;
import
com.wangxiaolu.promotion.result.basedata.RCode
;
import
com.wangxiaolu.promotion.service.wechat.WeChatUserQueryService
;
import
com.wangxiaolu.promotion.common.util.DataUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -32,12 +33,13 @@ public class WeChatUserQueryController {
* @return 非null则登录成功
*/
@PostMapping
(
"/temporary/login/phone_openid"
)
public
boolean
temporaryLoginByPhoneAndOpenId
(
@RequestBody
WxTemporaryLoginVo
wxTemporaryLoginVo
)
{
public
R
temporaryLoginByPhoneAndOpenId
(
@RequestBody
WxTemporaryLoginVo
wxTemporaryLoginVo
)
{
phontAndOpenIdVerify
(
wxTemporaryLoginVo
);
if
(!
DataUtils
.
phonePattern
(
wxTemporaryLoginVo
.
getPhone
()))
{
throw
new
ParamException
(
RCode
.
PHONE_PARAM_ERROR
,
null
);
}
return
weChatUserQueryService
.
loginTemporaryByOpenIdAndPhone
(
wxTemporaryLoginVo
.
getOpenId
(),
wxTemporaryLoginVo
.
getPhone
());
String
s
=
weChatUserQueryService
.
loginTemporaryByOpenIdAndPhone
(
wxTemporaryLoginVo
.
getOpenId
(),
wxTemporaryLoginVo
.
getPhone
());
return
R
.
success
(
s
);
}
...
...
@@ -45,13 +47,13 @@ public class WeChatUserQueryController {
* 促销员信息查询
*/
@PostMapping
(
"/temporary/phone_openid"
)
public
WxTemporaryInfoDto
getTemporaryInfoByOpenIdAndPhone
(
@RequestBody
WxTemporaryLoginVo
wxTemporaryLoginVo
)
{
public
R
getTemporaryInfoByOpenIdAndPhone
(
@RequestBody
WxTemporaryLoginVo
wxTemporaryLoginVo
)
{
phontAndOpenIdVerify
(
wxTemporaryLoginVo
);
WxTemporaryInfoDto
temporaryInfoDto
=
weChatUserQueryService
.
getTemporaryInfoByOpenIdAndPhone
(
wxTemporaryLoginVo
.
getOpenId
(),
wxTemporaryLoginVo
.
getPhone
());
if
(
Objects
.
isNull
(
temporaryInfoDto
))
{
throw
new
ParamException
(
RCode
.
LOGIN_PARAM_ERROR
,
null
);
}
return
temporaryInfoDto
;
return
R
.
success
(
temporaryInfoDto
)
;
}
private
void
phontAndOpenIdVerify
(
WxTemporaryLoginVo
wxTemporaryLoginVo
)
{
...
...
src/main/java/com/wangxiaolu/promotion/service/wechat/WeChatUserQueryService.java
浏览文件 @
6886ea2c
...
...
@@ -9,7 +9,7 @@ import com.wangxiaolu.promotion.pojo.user.dto.WxTemporaryInfoDto;
*/
public
interface
WeChatUserQueryService
{
boolean
loginTemporaryByOpenIdAndPhone
(
String
openId
,
String
phone
);
String
loginTemporaryByOpenIdAndPhone
(
String
openId
,
String
phone
);
WxTemporaryInfoDto
getTemporaryInfoByOpenIdAndPhone
(
String
openId
,
String
phone
);
}
src/main/java/com/wangxiaolu/promotion/service/wechat/impl/WeChatUserQueryServiceImpl.java
浏览文件 @
6886ea2c
package
com
.
wangxiaolu
.
promotion
.
service
.
wechat
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.wangxiaolu.promotion.common.redis.RedisKeys
;
import
com.wangxiaolu.promotion.common.redis.service.RedisCache
;
import
com.wangxiaolu.promotion.domain.user.dao.TemporaryInfoDao
;
import
com.wangxiaolu.promotion.pojo.user.dto.WxTemporaryInfoDto
;
...
...
@@ -11,6 +12,8 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Objects
;
/**
...
...
@@ -33,18 +36,20 @@ public class WeChatUserQueryServiceImpl implements WeChatUserQueryService {
* 根据openId、手机号登录
*/
@Override
public
boolean
loginTemporaryByOpenIdAndPhone
(
String
openId
,
String
phone
)
{
public
String
loginTemporaryByOpenIdAndPhone
(
String
openId
,
String
phone
)
{
WxTemporaryInfoDto
temDto
=
temporaryInfoDao
.
getUnimportantData
(
openId
,
phone
);
boolean
exist
=
!
Objects
.
isNull
(
temDto
);
String
temporaryToken
=
""
;
if
(
exist
)
{
log
.
info
(
"微信-促销员{}登录成功(openId、手机号),openId:{},phone:{}"
,
temDto
.
getName
(),
openId
,
phone
);
log
.
info
(
JSONObject
.
toJSONString
(
temDto
));
// 生成一个token
temporaryToken
=
jwtUtils
.
getTemporaryToken
(
openId
,
phone
);
redisCache
.
addToJsonToDays
(
RedisKeys
.
UserKeys
.
TEMPORARY_TOKEN
.
getKey
()+
temporaryToken
,
temDto
,
1
);
}
else
{
log
.
info
(
"微信-促销员登录失败,当前信息未注册(openId、手机号),openId:{},phone:{}"
,
openId
,
phone
);
}
return
exist
;
return
temporaryToken
;
}
@Override
...
...
src/test/java/com/wangxiaolu/promotion/controller/activity/temporary/TemporaryActivityCoreControllerTest.java
浏览文件 @
6886ea2c
...
...
@@ -25,7 +25,7 @@ class TemporaryActivityCoreControllerTest {
void
todayActivityDataReported
()
{
TemporaryActivityDataVo
activityVo
=
new
TemporaryActivityDataVo
();
Long
aLong
=
temporaryActivityCoreController
.
todayActivityDataReported
(
activityVo
);
System
.
out
.
println
(
" 促销员活动上报成功,生成id:"
+
aLong
);
//
Long aLong = temporaryActivityCoreController.todayActivityDataReported(activityVo);
//
System.out.println(" 促销员活动上报成功,生成id:" + aLong);
}
}
\ No newline at end of file
src/test/java/com/wangxiaolu/promotion/controller/wechat/WeChatUserQueryControllerTest.java
浏览文件 @
6886ea2c
...
...
@@ -25,8 +25,8 @@ class WeChatUserQueryControllerTest {
@Test
void
temporaryLoginByPhoneAndOpenId
()
{
WxTemporaryLoginVo
loginVO
=
new
WxTemporaryLoginVo
().
setOpenId
(
"oCMt-66hnlY9-bQcZAAZKX0p3s6I"
).
setPhone
(
"15701654502"
);
boolean
b
=
weChatUserQueryController
.
temporaryLoginByPhoneAndOpenId
(
loginVO
);
System
.
out
.
println
(
"temporaryLoginByPhoneAndOpenId 登录结果:"
+
b
);
//
boolean b = weChatUserQueryController.temporaryLoginByPhoneAndOpenId(loginVO);
//
System.out.println("temporaryLoginByPhoneAndOpenId 登录结果:" + b);
}
@Test
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论