Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
596d98e0
Commit
596d98e0
authored
Dec 19, 2024
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
乾岛
parent
256e37c2
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
1747 additions
and
19 deletions
+1747
-19
ch-core/src/main/java/com/wwdz/ch/core/api/qiandao/QdWxLoginManager.java
...n/java/com/wwdz/ch/core/api/qiandao/QdWxLoginManager.java
+291
-0
ch-core/src/main/java/com/wwdz/ch/core/entity/QdUserInfo.java
...ore/src/main/java/com/wwdz/ch/core/entity/QdUserInfo.java
+68
-0
ch-dao/src/main/java/com/wwdz/ch/db/dao/qiandao/QdGiveLikeRecordDao.java
.../java/com/wwdz/ch/db/dao/qiandao/QdGiveLikeRecordDao.java
+11
-0
ch-dao/src/main/java/com/wwdz/ch/db/dao/qiandao/QdUserSignInTaskDao.java
.../java/com/wwdz/ch/db/dao/qiandao/QdUserSignInTaskDao.java
+13
-0
ch-dao/src/main/java/com/wwdz/ch/db/domain/qiandao/QdUserSignInTask.java
.../java/com/wwdz/ch/db/domain/qiandao/QdUserSignInTask.java
+11
-4
ch-dao/src/main/java/com/wwdz/ch/db/domain/qiandao/QdUserSignInTaskExample.java
...om/wwdz/ch/db/domain/qiandao/QdUserSignInTaskExample.java
+132
-0
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/qiandao/QdGiveLikeRecordRequestDto.java
...ch/db/dto/request/qiandao/QdGiveLikeRecordRequestDto.java
+45
-0
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/qiandao/QdUserSignInTaskRequestDto.java
...ch/db/dto/request/qiandao/QdUserSignInTaskRequestDto.java
+49
-0
ch-dao/src/main/java/com/wwdz/ch/db/impl/qiandao/QdGiveLikeRecordDaoImpl.java
.../com/wwdz/ch/db/impl/qiandao/QdGiveLikeRecordDaoImpl.java
+29
-0
ch-dao/src/main/java/com/wwdz/ch/db/impl/qiandao/QdUserSignInNoteDaoImpl.java
.../com/wwdz/ch/db/impl/qiandao/QdUserSignInNoteDaoImpl.java
+0
-1
ch-dao/src/main/java/com/wwdz/ch/db/impl/qiandao/QdUserSignInTaskDaoImpl.java
.../com/wwdz/ch/db/impl/qiandao/QdUserSignInTaskDaoImpl.java
+38
-0
ch-dao/src/main/java/com/wwdz/ch/db/mapper/qiandao/QdGiveLikeRecordMapper.java
...com/wwdz/ch/db/mapper/qiandao/QdGiveLikeRecordMapper.java
+3
-0
ch-dao/src/main/java/com/wwdz/ch/db/mapper/qiandao/QdUserSignInTaskMapper.java
...com/wwdz/ch/db/mapper/qiandao/QdUserSignInTaskMapper.java
+3
-0
ch-dao/src/main/resources/com/wwdz/ch/db/mapper/qiandao/QdUserSignInTaskMapper.xml
.../com/wwdz/ch/db/mapper/qiandao/QdUserSignInTaskMapper.xml
+28
-13
ch-wx-api/src/main/java/com/wwdz/ch/wx/dao/UserInfo.java
ch-wx-api/src/main/java/com/wwdz/ch/wx/dao/UserInfo.java
+2
-1
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/qiandao/QdUserServiceImpl.java
...n/java/com/wwdz/ch/wx/impl/qiandao/QdUserServiceImpl.java
+560
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/manager/QdUserTokenManager.java
.../main/java/com/wwdz/ch/wx/manager/QdUserTokenManager.java
+133
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/qiandao/QdUserService.java
...in/java/com/wwdz/ch/wx/service/qiandao/QdUserService.java
+124
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/qiandao/QdUserController.java
...ain/java/com/wwdz/ch/wx/web/qiandao/QdUserController.java
+207
-0
No files found.
ch-core/src/main/java/com/wwdz/ch/core/api/qiandao/QdWxLoginManager.java
0 → 100644
View file @
596d98e0
package
com.wwdz.ch.core.api.qiandao
;
import
cn.binarywang.wx.miniapp.api.WxMaService
;
import
cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult
;
import
cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo
;
import
com.alibaba.fastjson.JSON
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.util.OkHttpUtil
;
import
com.wwdz.ch.core.util.RedisUtils
;
import
com.wwdz.ch.db.dto.request.UserRequestDto
;
import
com.wwdz.ch.db.dto.request.qiandao.QdUserRequestDto
;
import
com.xxdxxs.utils.JsonUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.io.InputStream
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
/**
* 微信小程序服务
*/
@Service
public
class
QdWxLoginManager
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
QdWxLoginManager
.
class
);
@Value
(
"${dts.wx.app-id}"
)
private
String
APPLET_APPID
;
@Value
(
"${dts.wx.app-secret}"
)
private
String
APPLET_APP_SECRET
;
/**
* 微信小程序获取access_token地址
* 测试环境和正式环境的url不同,相互隔离不会冲突
*/
@Value
(
"${dts.wx.get-access-token-url}"
)
private
String
GET_ACCESS_TOKEN_URL
;
// 微信小程序获取用户手机号地址
private
static
final
String
GET_PHONE_URL
=
"https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=%s"
;
// 微信小程序获取小程序码地址
private
static
final
String
GET_WXACODE_URL
=
"https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=%s"
;
// 微信小程序获取短链接地址
private
static
final
String
GET_LINK_URL
=
"https://api.weixin.qq.com/wxa/genwxashortlink?access_token=%s"
;
@Autowired
private
WxMaService
wxMaService
;
@Autowired
RedisUtils
redisUtils
;
/**
* 获取微信openid
* 为了公众号发送消息,这里实际获取的是unionid,同一用户小程序和公众号unionid相同
* @param loginCode
* @return
*/
public
WxMaJscode2SessionResult
getWxOpenId
(
String
loginCode
)
{
WxMaJscode2SessionResult
result
=
null
;
try
{
logger
.
info
(
">>>>>>>>> 获取微信openid, 参数loginCode:{}"
,
loginCode
);
result
=
this
.
wxMaService
.
getUserService
().
getSessionInfo
(
loginCode
);
//实际获取的是unionid,为了和公众号订阅用户关联
logger
.
info
(
"获取WxMaJscode2SessionResult :{}"
,
result
);
logger
.
info
(
"loginCode:{},获取openId成功 unionid :{}, openid:{}"
,
loginCode
,
result
.
getUnionid
(),
result
.
getOpenid
());
}
catch
(
Exception
e
)
{
logger
.
error
(
"loginCode:{}, 获取微信登录用户的openId失败:{}"
,
loginCode
,
e
);
}
return
result
;
}
/**
* 获取手机号
*
* @param dto
* @return
*/
public
Result
<
String
>
getPhone
(
QdUserRequestDto
dto
)
{
logger
.
info
(
"----------------- 开始获取手机号 ----------------"
);
String
phone
=
""
;
if
(
dto
.
getType
()
==
1
)
{
String
accessToken
=
getAccessToken
();
if
(
com
.
xxdxxs
.
utils
.
StringUtils
.
isEmpty
(
accessToken
))
{
return
Result
.
failed
();
}
logger
.
info
(
">>>>> 请求获取手机号 的token : {}"
,
accessToken
);
String
url
=
String
.
format
(
GET_PHONE_URL
,
accessToken
);
logger
.
info
(
">>>>> 请求获取手机号的url :{}"
,
url
);
Map
<
String
,
Object
>
phoneParam
=
new
HashMap
<>();
phoneParam
.
put
(
"code"
,
dto
.
getCode
());
String
phoneResult
=
OkHttpUtil
.
builder
().
url
(
url
)
.
addParams
(
phoneParam
)
.
post
(
true
).
sync
();
logger
.
info
(
"获取手机号的结果:{}"
,
phoneResult
);
if
(!
phoneResult
.
contains
(
"phoneNumber"
))
{
logger
.
error
(
"获取手机号出错,返回结果是:"
+
phoneResult
);
return
Result
.
failed
(
"phoneFalse"
);
}
phone
=
JsonUtils
.
getValueByPath
(
phoneResult
,
"phone_info/phoneNumber"
);
}
else
{
logger
.
info
(
"开始获取sessionKey-----------------------"
);
String
sessionKey
=
""
;
try
{
WxMaJscode2SessionResult
result
=
this
.
wxMaService
.
getUserService
().
getSessionInfo
(
dto
.
getLoginCode
());
sessionKey
=
result
.
getSessionKey
();
logger
.
info
(
"获取sessionKey结果:"
+
JSON
.
toJSONString
(
result
));
}
catch
(
Exception
e
)
{
logger
.
error
(
"获取用户登录信息失败"
,
e
);
return
Result
.
failed
(
"sessionFalse"
);
}
if
(
StringUtils
.
isBlank
(
sessionKey
))
{
logger
.
info
(
"微信登录,调用官方接口失败:{}"
,
dto
.
getLoginCode
());
return
Result
.
failed
(
"sessionFalse"
);
}
logger
.
info
(
"解析手机号加密信息-----------------------"
);
try
{
WxMaPhoneNumberInfo
wxMaPhoneNumberInfo
=
this
.
wxMaService
.
getUserService
().
getPhoneNoInfo
(
sessionKey
,
dto
.
getEncryptedData
(),
dto
.
getIv
());
logger
.
info
(
"解析手机号加密信息结果:"
+
JSON
.
toJSONString
(
wxMaPhoneNumberInfo
));
phone
=
wxMaPhoneNumberInfo
.
getPhoneNumber
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"解析手机号加密信息失败"
,
e
);
return
Result
.
failed
(
"decryptFalse"
);
}
}
return
Result
.
success
(
phone
);
}
public
String
getAccessToken
()
{
//测试环境
if
(!
GET_ACCESS_TOKEN_URL
.
contains
(
"stable_token"
))
{
String
accessTokenUrl
=
String
.
format
(
GET_ACCESS_TOKEN_URL
,
APPLET_APPID
,
APPLET_APP_SECRET
);
String
res
=
OkHttpUtil
.
builder
().
url
(
accessTokenUrl
)
.
get
().
sync
();
String
token
=
JsonUtils
.
getValueByPath
(
res
,
"access_token"
);
logger
.
info
(
"测试环境获取token :{} "
,
token
);
return
token
;
}
//根据商户的appid从redis中获取商户的token
String
token
=
redisUtils
.
hasKey
(
APPLET_APPID
)?
redisUtils
.
get
(
APPLET_APPID
).
toString
()
:
null
;
if
(
com
.
xxdxxs
.
utils
.
StringUtils
.
isEmpty
(
token
))
{
token
=
refreshAccessToken
();
}
return
token
;
}
/**
* 获取调用凭证access_token
*
* @return
*/
public
String
refreshAccessToken
()
{
logger
.
info
(
"开始获取小程序access_token----------------"
);
try
{
String
accessTokenUrl
=
null
;
String
res
=
null
;
//正式环境的url中包含了"stable_token", 要使用post请求, 测试环境是get请求
if
(!
GET_ACCESS_TOKEN_URL
.
contains
(
"stable_token"
))
{
accessTokenUrl
=
String
.
format
(
GET_ACCESS_TOKEN_URL
,
APPLET_APPID
,
APPLET_APP_SECRET
);
logger
.
info
(
"取调用凭证access_token url :{}"
,
accessTokenUrl
);
res
=
OkHttpUtil
.
builder
().
url
(
accessTokenUrl
)
.
get
().
sync
();
}
else
{
accessTokenUrl
=
GET_ACCESS_TOKEN_URL
;
logger
.
info
(
"取调用凭证access_token url :{}"
,
accessTokenUrl
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"grant_type"
,
"client_credential"
);
map
.
put
(
"appid"
,
APPLET_APPID
);
map
.
put
(
"secret"
,
APPLET_APP_SECRET
);
res
=
OkHttpUtil
.
builder
().
addParams
(
map
).
url
(
accessTokenUrl
)
.
post
(
true
).
sync
();
}
logger
.
info
(
"获取小程序access_token结果:"
+
res
);
if
(!
res
.
contains
(
"access_token"
))
{
String
errorCode
=
JsonUtils
.
getValueByPath
(
res
,
"errcode"
);
String
errmsg
=
JsonUtils
.
getValueByPath
(
res
,
"errmsg"
);
logger
.
error
(
"appid : {}, 获取小程序access_token出错, errorCode : {}, errmsg : {} "
,
APPLET_APPID
,
errorCode
,
errmsg
);
return
null
;
}
String
token
=
JsonUtils
.
getValueByPath
(
res
,
"access_token"
);
String
expires_in
=
JsonUtils
.
getValueByPath
(
res
,
"expires_in"
);
redisUtils
.
set
(
APPLET_APPID
,
token
,
Long
.
valueOf
(
expires_in
)
-
10
,
TimeUnit
.
SECONDS
);
return
token
;
}
catch
(
Exception
e
)
{
logger
.
error
(
"获取小程序access_token失败"
,
e
);
return
null
;
}
}
/**
* 获取小程序码二进制流
*
* @param page
* @param scene
* @return
*/
public
InputStream
getWxacodeStream
(
String
page
,
String
scene
)
{
try
{
String
accessToken
=
getAccessToken
();
String
url
=
String
.
format
(
GET_WXACODE_URL
,
accessToken
);
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"page"
,
page
);
param
.
put
(
"scene"
,
scene
);
param
.
put
(
"check_path"
,
false
);
//透明二维码
/* param.put("auto_color", false);
LinkedHashMap<String, String> colorMap = new LinkedHashMap<>();
colorMap.put("r", "0");
colorMap.put("g", "0");
colorMap.put("b", "0");
param.put("line_color", colorMap);
param.put("is_hyaline", true);*/
InputStream
inputStream
=
OkHttpUtil
.
builder
().
url
(
url
).
addParams
(
param
).
post
(
true
).
getInputStream
();
return
inputStream
;
}
catch
(
Exception
e
)
{
logger
.
error
(
"从微信获取小程序码流失败"
,
e
);
return
null
;
}
}
/**
* 透明的小程序二维码
* @param page
* @param scene
* @return
*/
public
InputStream
getHyalineWxacodeStream
(
String
page
,
String
scene
)
{
try
{
String
accessToken
=
getAccessToken
();
String
url
=
String
.
format
(
GET_WXACODE_URL
,
accessToken
);
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"page"
,
page
);
param
.
put
(
"scene"
,
scene
);
param
.
put
(
"check_path"
,
false
);
//透明二维码
param
.
put
(
"auto_color"
,
false
);
LinkedHashMap
<
String
,
String
>
colorMap
=
new
LinkedHashMap
<>();
colorMap
.
put
(
"r"
,
"0"
);
colorMap
.
put
(
"g"
,
"0"
);
colorMap
.
put
(
"b"
,
"0"
);
param
.
put
(
"line_color"
,
colorMap
);
param
.
put
(
"is_hyaline"
,
true
);
InputStream
inputStream
=
OkHttpUtil
.
builder
().
url
(
url
).
addParams
(
param
).
post
(
true
).
getInputStream
();
return
inputStream
;
}
catch
(
Exception
e
)
{
logger
.
error
(
"从微信获取小程序码流失败"
,
e
);
return
null
;
}
}
/**
* 获取小程序短链接
*
* @param pageUrl
* @return
*/
public
String
getLink
(
String
pageUrl
)
{
try
{
String
accessToken
=
getAccessToken
();
String
url
=
String
.
format
(
GET_LINK_URL
,
accessToken
);
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"page_url"
,
pageUrl
);
String
result
=
OkHttpUtil
.
builder
().
url
(
url
).
addParams
(
param
).
post
(
true
).
sync
();
logger
.
info
(
"获取小程序链接结果:"
+
result
);
System
.
out
.
println
(
result
);
if
(!
result
.
contains
(
"link"
))
{
return
null
;
}
if
(!
StringUtils
.
equals
(
"0"
,
JsonUtils
.
getValueByPath
(
result
,
"errcode"
)))
{
return
null
;
}
return
JsonUtils
.
getValueByPath
(
result
,
"link"
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"从微信获取小程序短链接失败"
,
e
);
return
null
;
}
}
}
ch-core/src/main/java/com/wwdz/ch/core/entity/QdUserInfo.java
0 → 100644
View file @
596d98e0
package
com.wwdz.ch.core.entity
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
import
java.util.Date
;
/**
* 用户信息
*
* @author CHENBO
* @since 1.0.0
*/
@Data
public
class
QdUserInfo
implements
Entity
{
private
static
final
long
serialVersionUID
=
-
5813029516433359765L
;
private
Long
id
;
private
Long
userId
;
private
String
userName
;
private
String
nickName
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
,
timezone
=
"GMT+8"
)
private
Date
birthday
;
private
String
avatar
;
private
String
country
;
private
String
province
;
private
String
city
;
private
String
area
;
private
String
language
;
private
Integer
gender
;
private
String
phone
;
private
String
mobile
;
private
Integer
level
;
// 用户层级 0 普通用户,1 VIP1,2 VIP2, 3 VIP3
private
String
levelDesc
;
// 用户等级描述
private
Integer
status
;
//状态
private
String
registerDate
;
//注册日期
// 微信号
private
String
wechatId
;
/**
* 微信登录openid
*/
private
String
wxOpenid
;
/**
* 微信登录unionid
*/
private
String
wxUnionid
;
private
String
profile
;
private
String
background
;
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
this
.
userId
=
id
;
}
public
void
setMobile
(
String
mobile
)
{
this
.
mobile
=
mobile
;
this
.
phone
=
mobile
;
}
}
ch-dao/src/main/java/com/wwdz/ch/db/dao/qiandao/QdGiveLikeRecordDao.java
0 → 100644
View file @
596d98e0
package
com.wwdz.ch.db.dao.qiandao
;
import
com.wwdz.ch.db.domain.qiandao.QdGiveLikeRecord
;
public
interface
QdGiveLikeRecordDao
{
boolean
insert
(
QdGiveLikeRecord
qdGiveLikeRecord
);
long
countByNoteId
(
long
noteId
);
}
ch-dao/src/main/java/com/wwdz/ch/db/dao/qiandao/QdUserSignInTaskDao.java
0 → 100644
View file @
596d98e0
package
com.wwdz.ch.db.dao.qiandao
;
import
com.wwdz.ch.db.domain.qiandao.QdUserSignInTask
;
import
com.wwdz.ch.db.dto.request.qiandao.QdUserSignInTaskRequestDto
;
import
java.util.List
;
public
interface
QdUserSignInTaskDao
{
boolean
insert
(
QdUserSignInTask
qdUserSignInTask
);
List
<
QdUserSignInTask
>
findByPage
(
QdUserSignInTaskRequestDto
dto
);
}
ch-dao/src/main/java/com/wwdz/ch/db/domain/qiandao/QdUserSignInTask.java
View file @
596d98e0
...
@@ -4,16 +4,14 @@ import java.io.Serializable;
...
@@ -4,16 +4,14 @@ import java.io.Serializable;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.Date
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
import
lombok.Data
;
/**
/**
* @author shiyu
* @author shiyu
* @date 2024/12/1
8
* @date 2024/12/1
9
*/
*/
@Data
@Data
public
class
QdUserSignInTask
implements
Entity
{
public
class
QdUserSignInTask
implements
Serializable
{
private
Long
id
;
private
Long
id
;
/**
/**
...
@@ -26,6 +24,11 @@ public class QdUserSignInTask implements Entity {
...
@@ -26,6 +24,11 @@ public class QdUserSignInTask implements Entity {
*/
*/
private
Long
taskId
;
private
Long
taskId
;
/**
* 是否自己创建
*/
private
Boolean
isSelf
;
/**
/**
* 创建时间
* 创建时间
*/
*/
...
@@ -57,6 +60,7 @@ public class QdUserSignInTask implements Entity {
...
@@ -57,6 +60,7 @@ public class QdUserSignInTask implements Entity {
sb
.
append
(
", id="
).
append
(
id
);
sb
.
append
(
", id="
).
append
(
id
);
sb
.
append
(
", userId="
).
append
(
userId
);
sb
.
append
(
", userId="
).
append
(
userId
);
sb
.
append
(
", taskId="
).
append
(
taskId
);
sb
.
append
(
", taskId="
).
append
(
taskId
);
sb
.
append
(
", isSelf="
).
append
(
isSelf
);
sb
.
append
(
", createTimeTime="
).
append
(
createTimeTime
);
sb
.
append
(
", createTimeTime="
).
append
(
createTimeTime
);
sb
.
append
(
", updateTime="
).
append
(
updateTime
);
sb
.
append
(
", updateTime="
).
append
(
updateTime
);
sb
.
append
(
", isValid="
).
append
(
isValid
);
sb
.
append
(
", isValid="
).
append
(
isValid
);
...
@@ -81,6 +85,7 @@ public class QdUserSignInTask implements Entity {
...
@@ -81,6 +85,7 @@ public class QdUserSignInTask implements Entity {
return
(
this
.
getId
()
==
null
?
other
.
getId
()
==
null
:
this
.
getId
().
equals
(
other
.
getId
()))
return
(
this
.
getId
()
==
null
?
other
.
getId
()
==
null
:
this
.
getId
().
equals
(
other
.
getId
()))
&&
(
this
.
getUserId
()
==
null
?
other
.
getUserId
()
==
null
:
this
.
getUserId
().
equals
(
other
.
getUserId
()))
&&
(
this
.
getUserId
()
==
null
?
other
.
getUserId
()
==
null
:
this
.
getUserId
().
equals
(
other
.
getUserId
()))
&&
(
this
.
getTaskId
()
==
null
?
other
.
getTaskId
()
==
null
:
this
.
getTaskId
().
equals
(
other
.
getTaskId
()))
&&
(
this
.
getTaskId
()
==
null
?
other
.
getTaskId
()
==
null
:
this
.
getTaskId
().
equals
(
other
.
getTaskId
()))
&&
(
this
.
getIsSelf
()
==
null
?
other
.
getIsSelf
()
==
null
:
this
.
getIsSelf
().
equals
(
other
.
getIsSelf
()))
&&
(
this
.
getCreateTimeTime
()
==
null
?
other
.
getCreateTimeTime
()
==
null
:
this
.
getCreateTimeTime
().
equals
(
other
.
getCreateTimeTime
()))
&&
(
this
.
getCreateTimeTime
()
==
null
?
other
.
getCreateTimeTime
()
==
null
:
this
.
getCreateTimeTime
().
equals
(
other
.
getCreateTimeTime
()))
&&
(
this
.
getUpdateTime
()
==
null
?
other
.
getUpdateTime
()
==
null
:
this
.
getUpdateTime
().
equals
(
other
.
getUpdateTime
()))
&&
(
this
.
getUpdateTime
()
==
null
?
other
.
getUpdateTime
()
==
null
:
this
.
getUpdateTime
().
equals
(
other
.
getUpdateTime
()))
&&
(
this
.
getIsValid
()
==
null
?
other
.
getIsValid
()
==
null
:
this
.
getIsValid
().
equals
(
other
.
getIsValid
()))
&&
(
this
.
getIsValid
()
==
null
?
other
.
getIsValid
()
==
null
:
this
.
getIsValid
().
equals
(
other
.
getIsValid
()))
...
@@ -94,6 +99,7 @@ public class QdUserSignInTask implements Entity {
...
@@ -94,6 +99,7 @@ public class QdUserSignInTask implements Entity {
result
=
prime
*
result
+
((
getId
()
==
null
)
?
0
:
getId
().
hashCode
());
result
=
prime
*
result
+
((
getId
()
==
null
)
?
0
:
getId
().
hashCode
());
result
=
prime
*
result
+
((
getUserId
()
==
null
)
?
0
:
getUserId
().
hashCode
());
result
=
prime
*
result
+
((
getUserId
()
==
null
)
?
0
:
getUserId
().
hashCode
());
result
=
prime
*
result
+
((
getTaskId
()
==
null
)
?
0
:
getTaskId
().
hashCode
());
result
=
prime
*
result
+
((
getTaskId
()
==
null
)
?
0
:
getTaskId
().
hashCode
());
result
=
prime
*
result
+
((
getIsSelf
()
==
null
)
?
0
:
getIsSelf
().
hashCode
());
result
=
prime
*
result
+
((
getCreateTimeTime
()
==
null
)
?
0
:
getCreateTimeTime
().
hashCode
());
result
=
prime
*
result
+
((
getCreateTimeTime
()
==
null
)
?
0
:
getCreateTimeTime
().
hashCode
());
result
=
prime
*
result
+
((
getUpdateTime
()
==
null
)
?
0
:
getUpdateTime
().
hashCode
());
result
=
prime
*
result
+
((
getUpdateTime
()
==
null
)
?
0
:
getUpdateTime
().
hashCode
());
result
=
prime
*
result
+
((
getIsValid
()
==
null
)
?
0
:
getIsValid
().
hashCode
());
result
=
prime
*
result
+
((
getIsValid
()
==
null
)
?
0
:
getIsValid
().
hashCode
());
...
@@ -112,6 +118,7 @@ public class QdUserSignInTask implements Entity {
...
@@ -112,6 +118,7 @@ public class QdUserSignInTask implements Entity {
id
(
"id"
,
"id"
,
"BIGINT"
,
false
),
id
(
"id"
,
"id"
,
"BIGINT"
,
false
),
userId
(
"user_id"
,
"userId"
,
"BIGINT"
,
false
),
userId
(
"user_id"
,
"userId"
,
"BIGINT"
,
false
),
taskId
(
"task_id"
,
"taskId"
,
"BIGINT"
,
false
),
taskId
(
"task_id"
,
"taskId"
,
"BIGINT"
,
false
),
isSelf
(
"is_self"
,
"isSelf"
,
"BIT"
,
false
),
createTimeTime
(
"create_time_time"
,
"createTimeTime"
,
"TIMESTAMP"
,
false
),
createTimeTime
(
"create_time_time"
,
"createTimeTime"
,
"TIMESTAMP"
,
false
),
updateTime
(
"update_time"
,
"updateTime"
,
"TIMESTAMP"
,
false
),
updateTime
(
"update_time"
,
"updateTime"
,
"TIMESTAMP"
,
false
),
isValid
(
"is_valid"
,
"isValid"
,
"BIT"
,
false
),
isValid
(
"is_valid"
,
"isValid"
,
"BIT"
,
false
),
...
...
ch-dao/src/main/java/com/wwdz/ch/db/domain/qiandao/QdUserSignInTaskExample.java
View file @
596d98e0
...
@@ -544,6 +544,138 @@ public class QdUserSignInTaskExample {
...
@@ -544,6 +544,138 @@ public class QdUserSignInTaskExample {
return
(
Criteria
)
this
;
return
(
Criteria
)
this
;
}
}
public
Criteria
andIsSelfIsNull
()
{
addCriterion
(
"is_self is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIsSelfIsNotNull
()
{
addCriterion
(
"is_self is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIsSelfEqualTo
(
Boolean
value
)
{
addCriterion
(
"is_self ="
,
value
,
"isSelf"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_user_sign_in_task
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andIsSelfEqualToColumn
(
QdUserSignInTask
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"is_self = "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andIsSelfNotEqualTo
(
Boolean
value
)
{
addCriterion
(
"is_self <>"
,
value
,
"isSelf"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_user_sign_in_task
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andIsSelfNotEqualToColumn
(
QdUserSignInTask
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"is_self <> "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andIsSelfGreaterThan
(
Boolean
value
)
{
addCriterion
(
"is_self >"
,
value
,
"isSelf"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_user_sign_in_task
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andIsSelfGreaterThanColumn
(
QdUserSignInTask
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"is_self > "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andIsSelfGreaterThanOrEqualTo
(
Boolean
value
)
{
addCriterion
(
"is_self >="
,
value
,
"isSelf"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_user_sign_in_task
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andIsSelfGreaterThanOrEqualToColumn
(
QdUserSignInTask
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"is_self >= "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andIsSelfLessThan
(
Boolean
value
)
{
addCriterion
(
"is_self <"
,
value
,
"isSelf"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_user_sign_in_task
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andIsSelfLessThanColumn
(
QdUserSignInTask
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"is_self < "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andIsSelfLessThanOrEqualTo
(
Boolean
value
)
{
addCriterion
(
"is_self <="
,
value
,
"isSelf"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table qd_user_sign_in_task
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andIsSelfLessThanOrEqualToColumn
(
QdUserSignInTask
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"is_self <= "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andIsSelfIn
(
List
<
Boolean
>
values
)
{
addCriterion
(
"is_self in"
,
values
,
"isSelf"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIsSelfNotIn
(
List
<
Boolean
>
values
)
{
addCriterion
(
"is_self not in"
,
values
,
"isSelf"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIsSelfBetween
(
Boolean
value1
,
Boolean
value2
)
{
addCriterion
(
"is_self between"
,
value1
,
value2
,
"isSelf"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIsSelfNotBetween
(
Boolean
value1
,
Boolean
value2
)
{
addCriterion
(
"is_self not between"
,
value1
,
value2
,
"isSelf"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCreateTimeTimeIsNull
()
{
public
Criteria
andCreateTimeTimeIsNull
()
{
addCriterion
(
"create_time_time is null"
);
addCriterion
(
"create_time_time is null"
);
return
(
Criteria
)
this
;
return
(
Criteria
)
this
;
...
...
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/qiandao/QdGiveLikeRecordRequestDto.java
0 → 100644
View file @
596d98e0
package
com.wwdz.ch.db.dto.request.qiandao
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
import
java.util.Date
;
@Data
public
class
QdGiveLikeRecordRequestDto
implements
Entity
{
/**
* id
*/
private
Long
id
;
/**
* 用户id
*/
private
Long
userId
;
/**
* 笔记id
*/
private
Long
noteId
;
/**
* 笔记创建人id
*/
private
Long
noteCreatorId
;
/**
* 点赞时间
*/
private
Date
createTime
;
/**
* 更新时间
*/
private
Integer
updateTime
;
/**
* 是否有效
*/
private
Boolean
isValid
;
}
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/qiandao/QdUserSignInTaskRequestDto.java
0 → 100644
View file @
596d98e0
package
com.wwdz.ch.db.dto.request.qiandao
;
import
com.wwdz.ch.db.dto.request.BaseRequestDto
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
import
java.util.Date
;
@Data
public
class
QdUserSignInTaskRequestDto
extends
BaseRequestDto
implements
Entity
{
private
Long
id
;
/**
* 用户id
*/
private
Long
userId
;
/**
* 签到任务id
*/
private
Long
taskId
;
/**
* 创建时间
*/
private
Date
createTimeTime
;
/**
* 更新时间
*/
private
Date
updateTime
;
/**
* 是否自己创建
*/
private
Boolean
isSelf
;
/**
* 是否有效
*/
private
Boolean
isValid
;
/**
* 状态
*/
private
Integer
state
;
}
ch-dao/src/main/java/com/wwdz/ch/db/impl/qiandao/QdGiveLikeRecordDaoImpl.java
0 → 100644
View file @
596d98e0
package
com.wwdz.ch.db.impl.qiandao
;
import
com.wwdz.ch.db.dao.qiandao.QdGiveLikeRecordDao
;
import
com.wwdz.ch.db.domain.qiandao.QdGiveLikeRecord
;
import
com.wwdz.ch.db.domain.qiandao.QdGiveLikeRecordExample
;
import
com.wwdz.ch.db.mapper.qiandao.QdGiveLikeRecordMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Repository
;
@Repository
public
class
QdGiveLikeRecordDaoImpl
implements
QdGiveLikeRecordDao
{
@Autowired
QdGiveLikeRecordMapper
qdGiveLikeRecordMapper
;
@Override
public
boolean
insert
(
QdGiveLikeRecord
qdGiveLikeRecord
)
{
return
qdGiveLikeRecordMapper
.
insert
(
qdGiveLikeRecord
)
>
0
;
}
@Override
public
long
countByNoteId
(
long
noteId
)
{
QdGiveLikeRecordExample
example
=
new
QdGiveLikeRecordExample
();
QdGiveLikeRecordExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andNoteIdEqualTo
(
noteId
);
criteria
.
andIsValidEqualTo
(
true
);
return
qdGiveLikeRecordMapper
.
countByExample
(
example
);
}
}
ch-dao/src/main/java/com/wwdz/ch/db/impl/qiandao/QdUserSignInNoteDaoImpl.java
View file @
596d98e0
package
com.wwdz.ch.db.impl.qiandao
;
package
com.wwdz.ch.db.impl.qiandao
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
import
com.wwdz.ch.db.dao.qiandao.QdUserSignInDao
;
import
com.wwdz.ch.db.dao.qiandao.QdUserSignInNoteDao
;
import
com.wwdz.ch.db.dao.qiandao.QdUserSignInNoteDao
;
import
com.wwdz.ch.db.domain.qiandao.QdUserSignInNote
;
import
com.wwdz.ch.db.domain.qiandao.QdUserSignInNote
;
import
com.wwdz.ch.db.domain.qiandao.QdUserSignInNoteExample
;
import
com.wwdz.ch.db.domain.qiandao.QdUserSignInNoteExample
;
...
...
ch-dao/src/main/java/com/wwdz/ch/db/impl/qiandao/QdUserSignInTaskDaoImpl.java
0 → 100644
View file @
596d98e0
package
com.wwdz.ch.db.impl.qiandao
;
import
com.github.pagehelper.PageHelper
;
import
com.wwdz.ch.db.dao.qiandao.QdUserSignInTaskDao
;
import
com.wwdz.ch.db.domain.qiandao.QdUserSignInTask
;
import
com.wwdz.ch.db.domain.qiandao.QdUserSignInTaskExample
;
import
com.wwdz.ch.db.dto.request.qiandao.QdUserSignInTaskRequestDto
;
import
com.wwdz.ch.db.mapper.qiandao.QdUserSignInTaskMapper
;
import
com.xxdxxs.db.component.JdbcHelper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
@Repository
public
class
QdUserSignInTaskDaoImpl
implements
QdUserSignInTaskDao
{
@Autowired
QdUserSignInTaskMapper
qdUserSignInTaskMapper
;
@Override
public
boolean
insert
(
QdUserSignInTask
qdUserSignInTask
)
{
return
qdUserSignInTaskMapper
.
insert
(
qdUserSignInTask
)
>
0
;
}
@Override
public
List
<
QdUserSignInTask
>
findByPage
(
QdUserSignInTaskRequestDto
dto
)
{
QdUserSignInTaskExample
example
=
new
QdUserSignInTaskExample
();
QdUserSignInTaskExample
.
Criteria
criteria
=
example
.
createCriteria
();
JdbcHelper
.
ifPresent
(
dto
.
getUserId
(),
criteria
::
andUserIdEqualTo
);
JdbcHelper
.
ifPresent
(
dto
.
getTaskId
(),
criteria
::
andTaskIdEqualTo
);
JdbcHelper
.
ifPresent
(
dto
.
getIsSelf
(),
criteria
::
andIsSelfEqualTo
);
criteria
.
andIsValidEqualTo
(
true
);
PageHelper
.
startPage
(
dto
.
getPage
(),
dto
.
getLimit
());
example
.
setOrderByClause
(
"create_time desc"
);
return
qdUserSignInTaskMapper
.
selectByExample
(
example
);
}
}
ch-dao/src/main/java/com/wwdz/ch/db/mapper/qiandao/QdGiveLikeRecordMapper.java
View file @
596d98e0
...
@@ -3,8 +3,11 @@ package com.wwdz.ch.db.mapper.qiandao;
...
@@ -3,8 +3,11 @@ package com.wwdz.ch.db.mapper.qiandao;
import
com.wwdz.ch.db.domain.qiandao.QdGiveLikeRecord
;
import
com.wwdz.ch.db.domain.qiandao.QdGiveLikeRecord
;
import
com.wwdz.ch.db.domain.qiandao.QdGiveLikeRecordExample
;
import
com.wwdz.ch.db.domain.qiandao.QdGiveLikeRecordExample
;
import
java.util.List
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
@Mapper
public
interface
QdGiveLikeRecordMapper
{
public
interface
QdGiveLikeRecordMapper
{
long
countByExample
(
QdGiveLikeRecordExample
example
);
long
countByExample
(
QdGiveLikeRecordExample
example
);
...
...
ch-dao/src/main/java/com/wwdz/ch/db/mapper/qiandao/QdUserSignInTaskMapper.java
View file @
596d98e0
...
@@ -3,8 +3,11 @@ package com.wwdz.ch.db.mapper.qiandao;
...
@@ -3,8 +3,11 @@ package com.wwdz.ch.db.mapper.qiandao;
import
com.wwdz.ch.db.domain.qiandao.QdUserSignInTask
;
import
com.wwdz.ch.db.domain.qiandao.QdUserSignInTask
;
import
com.wwdz.ch.db.domain.qiandao.QdUserSignInTaskExample
;
import
com.wwdz.ch.db.domain.qiandao.QdUserSignInTaskExample
;
import
java.util.List
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
@Mapper
public
interface
QdUserSignInTaskMapper
{
public
interface
QdUserSignInTaskMapper
{
long
countByExample
(
QdUserSignInTaskExample
example
);
long
countByExample
(
QdUserSignInTaskExample
example
);
...
...
ch-dao/src/main/resources/com/wwdz/ch/db/mapper/qiandao/QdUserSignInTaskMapper.xml
View file @
596d98e0
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<result
column=
"user_id"
jdbcType=
"BIGINT"
property=
"userId"
/>
<result
column=
"user_id"
jdbcType=
"BIGINT"
property=
"userId"
/>
<result
column=
"task_id"
jdbcType=
"BIGINT"
property=
"taskId"
/>
<result
column=
"task_id"
jdbcType=
"BIGINT"
property=
"taskId"
/>
<result
column=
"is_self"
jdbcType=
"BIT"
property=
"isSelf"
/>
<result
column=
"create_time_time"
jdbcType=
"TIMESTAMP"
property=
"createTimeTime"
/>
<result
column=
"create_time_time"
jdbcType=
"TIMESTAMP"
property=
"createTimeTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
<result
column=
"is_valid"
jdbcType=
"BIT"
property=
"isValid"
/>
<result
column=
"is_valid"
jdbcType=
"BIT"
property=
"isValid"
/>
...
@@ -69,7 +70,7 @@
...
@@ -69,7 +70,7 @@
</where>
</where>
</sql>
</sql>
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
id, user_id, task_id, create_time_time, update_time, is_valid, `state`
id, user_id, task_id,
is_self,
create_time_time, update_time, is_valid, `state`
</sql>
</sql>
<select
id=
"selectByExample"
parameterType=
"com.wwdz.ch.db.domain.qiandao.QdUserSignInTaskExample"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByExample"
parameterType=
"com.wwdz.ch.db.domain.qiandao.QdUserSignInTaskExample"
resultMap=
"BaseResultMap"
>
select
select
...
@@ -98,13 +99,13 @@
...
@@ -98,13 +99,13 @@
distinct
distinct
</if>
</if>
<choose>
<choose>
<when
test=
"selective != null and selective.length
>
0"
>
<when
test=
"selective != null and selective.length
>
0"
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
${column.escapedColumnName}
${column.escapedColumnName}
</foreach>
</foreach>
</when>
</when>
<otherwise>
<otherwise>
id, user_id, task_id, create_time_time, update_time, is_valid, `state`
id, user_id, task_id,
is_self,
create_time_time, update_time, is_valid, `state`
</otherwise>
</otherwise>
</choose>
</choose>
from qd_user_sign_in_task
from qd_user_sign_in_task
...
@@ -129,13 +130,13 @@
...
@@ -129,13 +130,13 @@
-->
-->
select
select
<choose>
<choose>
<when
test=
"selective != null and selective.length
>
0"
>
<when
test=
"selective != null and selective.length
>
0"
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
${column.escapedColumnName}
${column.escapedColumnName}
</foreach>
</foreach>
</when>
</when>
<otherwise>
<otherwise>
id, user_id, task_id, create_time_time, update_time, is_valid, `state`
id, user_id, task_id,
is_self,
create_time_time, update_time, is_valid, `state`
</otherwise>
</otherwise>
</choose>
</choose>
from qd_user_sign_in_task
from qd_user_sign_in_task
...
@@ -155,12 +156,12 @@
...
@@ -155,12 +156,12 @@
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.Long"
>
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.Long"
>
SELECT LAST_INSERT_ID()
SELECT LAST_INSERT_ID()
</selectKey>
</selectKey>
insert into qd_user_sign_in_task (user_id, task_id,
create_time_time
,
insert into qd_user_sign_in_task (user_id, task_id,
is_self
,
update_time, is_valid, `state`
create_time_time, update_time, is_valid,
)
`state`
)
values (#{userId,jdbcType=BIGINT}, #{taskId,jdbcType=BIGINT}, #{
createTimeTime,jdbcType=TIMESTAMP
},
values (#{userId,jdbcType=BIGINT}, #{taskId,jdbcType=BIGINT}, #{
isSelf,jdbcType=BIT
},
#{
updateTime,jdbcType=TIMESTAMP}, #{isValid,jdbcType=BIT}, #{state,jdbcType=INTEGER}
#{
createTimeTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{isValid,jdbcType=BIT},
)
#{state,jdbcType=INTEGER}
)
</insert>
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.wwdz.ch.db.domain.qiandao.QdUserSignInTask"
>
<insert
id=
"insertSelective"
parameterType=
"com.wwdz.ch.db.domain.qiandao.QdUserSignInTask"
>
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.Long"
>
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.Long"
>
...
@@ -174,6 +175,9 @@
...
@@ -174,6 +175,9 @@
<if
test=
"taskId != null"
>
<if
test=
"taskId != null"
>
task_id,
task_id,
</if>
</if>
<if
test=
"isSelf != null"
>
is_self,
</if>
<if
test=
"createTimeTime != null"
>
<if
test=
"createTimeTime != null"
>
create_time_time,
create_time_time,
</if>
</if>
...
@@ -194,6 +198,9 @@
...
@@ -194,6 +198,9 @@
<if
test=
"taskId != null"
>
<if
test=
"taskId != null"
>
#{taskId,jdbcType=BIGINT},
#{taskId,jdbcType=BIGINT},
</if>
</if>
<if
test=
"isSelf != null"
>
#{isSelf,jdbcType=BIT},
</if>
<if
test=
"createTimeTime != null"
>
<if
test=
"createTimeTime != null"
>
#{createTimeTime,jdbcType=TIMESTAMP},
#{createTimeTime,jdbcType=TIMESTAMP},
</if>
</if>
...
@@ -226,6 +233,9 @@
...
@@ -226,6 +233,9 @@
<if
test=
"record.taskId != null"
>
<if
test=
"record.taskId != null"
>
task_id = #{record.taskId,jdbcType=BIGINT},
task_id = #{record.taskId,jdbcType=BIGINT},
</if>
</if>
<if
test=
"record.isSelf != null"
>
is_self = #{record.isSelf,jdbcType=BIT},
</if>
<if
test=
"record.createTimeTime != null"
>
<if
test=
"record.createTimeTime != null"
>
create_time_time = #{record.createTimeTime,jdbcType=TIMESTAMP},
create_time_time = #{record.createTimeTime,jdbcType=TIMESTAMP},
</if>
</if>
...
@@ -248,6 +258,7 @@
...
@@ -248,6 +258,7 @@
set id = #{record.id,jdbcType=BIGINT},
set id = #{record.id,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT},
task_id = #{record.taskId,jdbcType=BIGINT},
task_id = #{record.taskId,jdbcType=BIGINT},
is_self = #{record.isSelf,jdbcType=BIT},
create_time_time = #{record.createTimeTime,jdbcType=TIMESTAMP},
create_time_time = #{record.createTimeTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
is_valid = #{record.isValid,jdbcType=BIT},
is_valid = #{record.isValid,jdbcType=BIT},
...
@@ -265,6 +276,9 @@
...
@@ -265,6 +276,9 @@
<if
test=
"taskId != null"
>
<if
test=
"taskId != null"
>
task_id = #{taskId,jdbcType=BIGINT},
task_id = #{taskId,jdbcType=BIGINT},
</if>
</if>
<if
test=
"isSelf != null"
>
is_self = #{isSelf,jdbcType=BIT},
</if>
<if
test=
"createTimeTime != null"
>
<if
test=
"createTimeTime != null"
>
create_time_time = #{createTimeTime,jdbcType=TIMESTAMP},
create_time_time = #{createTimeTime,jdbcType=TIMESTAMP},
</if>
</if>
...
@@ -284,6 +298,7 @@
...
@@ -284,6 +298,7 @@
update qd_user_sign_in_task
update qd_user_sign_in_task
set user_id = #{userId,jdbcType=BIGINT},
set user_id = #{userId,jdbcType=BIGINT},
task_id = #{taskId,jdbcType=BIGINT},
task_id = #{taskId,jdbcType=BIGINT},
is_self = #{isSelf,jdbcType=BIT},
create_time_time = #{createTimeTime,jdbcType=TIMESTAMP},
create_time_time = #{createTimeTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
is_valid = #{isValid,jdbcType=BIT},
is_valid = #{isValid,jdbcType=BIT},
...
@@ -317,13 +332,13 @@
...
@@ -317,13 +332,13 @@
select
select
'true' as QUERYID,
'true' as QUERYID,
<choose>
<choose>
<when
test=
"selective != null and selective.length
>
0"
>
<when
test=
"selective != null and selective.length
>
0"
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
${column.escapedColumnName}
${column.escapedColumnName}
</foreach>
</foreach>
</when>
</when>
<otherwise>
<otherwise>
id, user_id, task_id, create_time_time, update_time, is_valid, `state`
id, user_id, task_id,
is_self,
create_time_time, update_time, is_valid, `state`
</otherwise>
</otherwise>
</choose>
</choose>
from qd_user_sign_in_task
from qd_user_sign_in_task
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/dao/UserInfo.java
View file @
596d98e0
package
com.wwdz.ch.wx.dao
;
package
com.wwdz.ch.wx.dao
;
import
com.wwdz.ch.core.consts.FollowFansEnum
;
import
com.wwdz.ch.core.consts.FollowFansEnum
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.io.Serializable
;
...
@@ -12,7 +13,7 @@ import java.io.Serializable;
...
@@ -12,7 +13,7 @@ import java.io.Serializable;
* @since 1.0.0
* @since 1.0.0
*/
*/
@Data
@Data
public
class
UserInfo
implements
Serializable
{
public
class
UserInfo
implements
Entity
{
private
static
final
long
serialVersionUID
=
-
5813029516433359765L
;
private
static
final
long
serialVersionUID
=
-
5813029516433359765L
;
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/qiandao/QdUserServiceImpl.java
0 → 100644
View file @
596d98e0
package
com.wwdz.ch.wx.impl.qiandao
;
import
cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult
;
import
com.alibaba.fastjson.JSONObject
;
import
com.wwdz.ch.core.api.qiandao.QdWxLoginManager
;
import
com.wwdz.ch.core.entity.QdUserInfo
;
import
com.wwdz.ch.core.notify.AliSmsSender
;
import
com.wwdz.ch.core.notify.NotifyService
;
import
com.wwdz.ch.core.notify.SmsResult
;
import
com.wwdz.ch.core.storage.StorageService
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.util.*
;
import
com.wwdz.ch.core.util.bcrypt.BCryptPasswordEncoder
;
import
com.wwdz.ch.db.dao.qiandao.QdUserDao
;
import
com.wwdz.ch.db.domain.qiandao.QdUser
;
import
com.wwdz.ch.db.dto.request.qiandao.QdUserRequestDto
;
import
com.wwdz.ch.wx.constant.CacheCodeConstants
;
import
com.wwdz.ch.wx.dao.UserInfo
;
import
com.wwdz.ch.wx.dao.UserToken
;
import
com.wwdz.ch.wx.manager.QdUserTokenManager
;
import
com.wwdz.ch.wx.service.qiandao.QdUserService
;
import
com.wwdz.ch.wx.util.IpUtil
;
import
com.wwdz.ch.wx.util.WxResponseCode
;
import
com.xxdxxs.utils.EntityMapper
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.imageio.ImageIO
;
import
javax.servlet.http.HttpServletRequest
;
import
java.awt.image.BufferedImage
;
import
java.io.InputStream
;
import
java.text.MessageFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.UUID
;
/**
* 用户服务类
*/
@Service
public
class
QdUserServiceImpl
implements
QdUserService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
QdUserServiceImpl
.
class
);
@Autowired
private
QdUserDao
qdUserDao
;
@Autowired
private
QdUserTokenManager
qdUserTokenManager
;
@Autowired
private
ApplicationContext
applicationContext
;
@Autowired
private
QdWxLoginManager
qdWxLoginManager
;
@Autowired
NotifyService
notifyService
;
@Autowired
private
RedisUtils
redisUtils
;
@Value
(
"${avatar-url}"
)
private
String
avatarUrl
;
@Autowired
private
AliSmsSender
aliSmsSender
;
@Autowired
CacheUtil
cacheUtil
;
@Value
(
"${spring.profiles.active}"
)
private
String
env
;
@Autowired
StorageService
storageService
;
@Override
public
Result
regCaptcha
(
QdUserRequestDto
dto
)
{
try
{
if
(!
notifyService
.
isSmsEnable
())
{
logger
.
error
(
"请求验证码出错:{}"
,
WxResponseCode
.
AUTH_CAPTCHA_UNSUPPORT
.
desc
());
return
Result
.
failed
(
WxResponseCode
.
AUTH_CAPTCHA_UNSUPPORT
.
desc
());
}
String
key
=
""
;
if
(
dto
.
getSmsType
().
equals
(
CacheCodeConstants
.
SmsTypeEnum
.
LOGIN
.
getCode
()))
{
key
=
MessageFormat
.
format
(
CacheCodeConstants
.
USER_LOGIN_SMS_KEY
,
dto
.
getMobile
());
}
else
{
key
=
MessageFormat
.
format
(
CacheCodeConstants
.
USER_UPDATE_SMS_KEY
,
dto
.
getMobile
());
}
if
(
redisUtils
.
hasKey
(
key
))
{
return
Result
.
failed
(
"验证码请求过于频繁"
);
}
String
activeProfile
=
applicationContext
.
getEnvironment
().
getActiveProfiles
()[
0
];
String
code
=
"123456"
;
if
(!
env
.
equals
(
"dev"
))
{
if
(!
RegexUtil
.
isMobileExact
(
dto
.
getMobile
()))
{
return
Result
.
failed
(
"手机号格式不正确"
);
}
code
=
CharUtil
.
getRandomNum
(
6
);
SmsResult
smsResult
=
aliSmsSender
.
sendWithTemplate
(
dto
.
getMobile
(),
code
);
if
(
smsResult
!=
null
)
{
logger
.
info
(
"*****阿里云短信发送->请求验证码,短信发送结果:{}"
,
JSONObject
.
toJSONString
(
smsResult
));
}
}
redisUtils
.
set
(
key
,
code
,
300
);
logger
.
info
(
"【请求结束】请求验证码成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"请求验证码失败"
,
e
);
return
Result
.
failed
(
"请求验证码失败"
);
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
Result
loginByMobile
(
QdUserRequestDto
dto
,
HttpServletRequest
request
)
{
try
{
String
key
=
MessageFormat
.
format
(
CacheCodeConstants
.
USER_LOGIN_SMS_KEY
,
dto
.
getMobile
());
Object
object
=
redisUtils
.
get
(
key
);
if
(
Objects
.
isNull
(
object
))
{
return
Result
.
failed
(
"验证码已过期"
);
}
if
(!
StringUtils
.
equals
(
dto
.
getSmsCode
(),
object
.
toString
()))
{
return
Result
.
failed
(
"验证码不正确"
);
}
// 进行登录
Map
<
String
,
Object
>
result
=
getLoginResult
(
dto
,
request
);
logger
.
info
(
"【请求结束】手机号登录,响应结果:{}"
,
JSONObject
.
toJSONString
(
result
));
// 清除验证码缓存
redisUtils
.
del
(
key
);
return
Result
.
success
(
result
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"手机号登录失败"
,
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
Result
.
failed
(
"手机号登录失败"
);
}
}
@Transactional
@Override
public
Result
login
(
QdUserRequestDto
dto
,
HttpServletRequest
request
)
{
try
{
String
mobile
=
""
;
// 根据小程序来源不同调用不同的处理逻辑获取手机号
try
{
WxMaJscode2SessionResult
result
=
qdWxLoginManager
.
getWxOpenId
(
dto
.
getLoginCode
());
dto
.
setWxOpenid
(
result
.
getOpenid
());
dto
.
setWxUnionid
(
result
.
getUnionid
());
Result
<
String
>
getPhoneResult
=
qdWxLoginManager
.
getPhone
(
dto
);
if
(
getPhoneResult
.
getSuccess
())
{
mobile
=
getPhoneResult
.
getData
();
}
/* if (StringUtils.equals("false", mobile)) {
return Result.failed("获取access_token失败");
}
if (StringUtils.equals("sessionFalse", mobile)) {
return Result.failed("获取sessionKey失败");
}
if (StringUtils.equals("phoneFalse", mobile)) {
return Result.failed("获取手机号失败");
}
if (StringUtils.equals("decryptFalse", mobile)) {
return Result.failed(ResultCode.FAILED.getCode(), "用户信息解密失败");
}*/
}
catch
(
Exception
e
)
{
logger
.
error
(
"获取用户信息异常"
,
e
);
return
Result
.
failed
(
"获取用户信息异常"
);
}
dto
.
setMobile
(
mobile
);
// 进行登录
Map
<
String
,
Object
>
result
=
getLoginResult
(
dto
,
request
);
logger
.
info
(
"【请求结束】快捷登录成功,响应结果:{}"
,
JSONObject
.
toJSONString
(
result
));
return
Result
.
success
(
result
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"快捷登录失败"
,
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
Result
.
failed
(
"快捷登录失败"
);
}
}
@Override
public
Result
updateProfile
(
QdUserRequestDto
dto
)
{
try
{
QdUser
user
=
qdUserDao
.
queryById
(
dto
.
getUserId
());
if
(
Objects
.
isNull
(
user
))
{
return
Result
.
failed
(
"数据异常,用户不存在"
);
}
user
.
setProfile
(
dto
.
getProfile
());
qdUserDao
.
updateById
(
user
);
// 更新用户缓存
QdUser
resultQdUser
=
qdUserDao
.
queryById
(
user
.
getId
());
String
userKey
=
MessageFormat
.
format
(
CacheCodeConstants
.
USER_INFO_KEY
,
user
.
getId
());
redisUtils
.
set
(
userKey
,
resultQdUser
,
2
*
60
*
60
);
logger
.
info
(
"【请求结束】用户修改个性签名成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"用户修改个性签名失败"
,
e
);
return
Result
.
failed
(
"修改个性签名失败"
);
}
}
@Override
public
Result
updateBackground
(
QdUserRequestDto
dto
)
{
try
{
QdUser
user
=
qdUserDao
.
queryById
(
dto
.
getUserId
());
if
(
Objects
.
isNull
(
user
))
{
return
Result
.
failed
(
"数据异常,用户不存在"
);
}
user
.
setBackground
(
dto
.
getBackground
());
qdUserDao
.
updateById
(
user
);
// 更新用户缓存
QdUser
resultQdUser
=
qdUserDao
.
queryById
(
user
.
getId
());
String
userKey
=
MessageFormat
.
format
(
CacheCodeConstants
.
USER_INFO_KEY
,
user
.
getId
());
redisUtils
.
set
(
userKey
,
resultQdUser
,
2
*
60
*
60
);
logger
.
info
(
"【请求结束】用户修改背景成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"用户修改背景失败"
,
e
);
return
Result
.
failed
(
"修改背景失败"
);
}
}
@Override
public
Result
uploadImage
(
MultipartFile
file
)
{
try
{
InputStream
targetInput
=
null
;
try
(
InputStream
inputStream
=
file
.
getInputStream
())
{
BufferedImage
image
=
ImageIO
.
read
(
inputStream
);
ImgUtil
.
ImageOrientationWithNameResult
orientationResult
=
ImgUtil
.
getImageFileNameWithWithRepaintInfo
(
file
,
image
,
null
);
if
(
orientationResult
.
getNeedRepaint
())
{
logger
.
info
(
"当前图片需要进行重绘,旋转角度:【{}】"
,
orientationResult
.
getAngel
());
targetInput
=
ImgUtil
.
repaintImage2InputStream
(
image
,
orientationResult
.
getAngel
(),
orientationResult
.
getType
());
}
else
{
targetInput
=
file
.
getInputStream
();
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"get image size failed : "
,
e
);
}
String
originalFilename
=
file
.
getOriginalFilename
();
String
url
=
storageService
.
store
(
targetInput
,
file
.
getSize
(),
file
.
getContentType
(),
originalFilename
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"url"
,
url
);
return
Result
.
success
(
map
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"图片上传七牛云失败,原因:"
+
e
.
getMessage
(),
e
);
return
Result
.
failed
(
"文件上传失败"
);
}
}
@Override
public
Result
updateNickname
(
QdUserRequestDto
dto
)
{
try
{
QdUser
user
=
qdUserDao
.
queryById
(
dto
.
getUserId
());
if
(
Objects
.
isNull
(
user
))
{
return
Result
.
failed
(
"数据异常,用户不存在"
);
}
if
(
qdUserDao
.
isExistedByNickname
(
dto
.
getUserId
(),
dto
.
getNickName
()))
{
return
Result
.
failed
(
"昵称已存在"
);
}
user
.
setNickName
(
dto
.
getNickName
());
qdUserDao
.
updateById
(
user
);
// 更新用户缓存
QdUser
resultQdUser
=
qdUserDao
.
queryById
(
user
.
getId
());
String
userKey
=
MessageFormat
.
format
(
CacheCodeConstants
.
USER_INFO_KEY
,
user
.
getId
());
redisUtils
.
set
(
userKey
,
resultQdUser
,
2
*
60
*
60
);
logger
.
info
(
"【请求结束】用户修改昵称成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"用户修改昵称失败"
,
e
);
}
return
Result
.
failed
(
"修改昵称失败"
);
}
@Override
public
Result
updateAvatar
(
QdUserRequestDto
dto
)
{
try
{
QdUser
user
=
qdUserDao
.
queryById
(
dto
.
getUserId
());
if
(
Objects
.
isNull
(
user
))
{
return
Result
.
failed
(
"数据异常,用户不存在"
);
}
user
.
setAvatar
(
dto
.
getAvatar
());
qdUserDao
.
updateById
(
user
);
// 更新用户缓存
QdUser
resultQdUser
=
qdUserDao
.
queryById
(
user
.
getId
());
String
userKey
=
MessageFormat
.
format
(
CacheCodeConstants
.
USER_INFO_KEY
,
user
.
getId
());
redisUtils
.
set
(
userKey
,
resultQdUser
,
2
*
60
*
60
);
logger
.
info
(
"【请求结束】用户修改头像成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"用户修改头像失败 {}"
,
e
);
}
return
Result
.
failed
(
"修改头像失败"
);
}
@Override
public
Result
updateQrCode
(
QdUserRequestDto
dto
)
{
try
{
QdUser
user
=
qdUserDao
.
queryById
(
dto
.
getUserId
());
if
(
Objects
.
isNull
(
user
))
{
return
Result
.
failed
(
"数据异常,用户不存在"
);
}
qdUserDao
.
updateById
(
user
);
// 更新用户缓存
QdUser
resultQdUser
=
qdUserDao
.
queryById
(
user
.
getId
());
String
userKey
=
MessageFormat
.
format
(
CacheCodeConstants
.
USER_INFO_KEY
,
user
.
getId
());
redisUtils
.
set
(
userKey
,
resultQdUser
,
2
*
60
*
60
);
logger
.
info
(
"【请求结束】用户修改微信二维码成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"用户修改微信二维码失败"
,
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
Result
.
failed
(
"用户修改微信二维码失败"
);
}
}
@Override
public
Result
updateMobile
(
QdUserRequestDto
dto
)
{
try
{
QdUser
user
=
qdUserDao
.
queryById
(
dto
.
getUserId
());
if
(
Objects
.
isNull
(
user
))
{
return
Result
.
failed
(
"数据异常,用户不存在"
);
}
if
(!
StringUtils
.
equals
(
user
.
getMobile
(),
dto
.
getBeforeMobile
()))
{
return
Result
.
failed
(
"原手机号码不正确"
);
}
String
key
=
MessageFormat
.
format
(
CacheCodeConstants
.
USER_UPDATE_SMS_KEY
,
dto
.
getAfterMobile
());
Object
object
=
redisUtils
.
get
(
key
);
if
(
Objects
.
isNull
(
object
))
{
return
Result
.
failed
(
"验证码已过期"
);
}
if
(!
StringUtils
.
equals
(
dto
.
getSmsCode
(),
object
.
toString
()))
{
return
Result
.
failed
(
"验证码不正确"
);
}
if
(
qdUserDao
.
isExistedByMobile
(
dto
.
getBeforeMobile
(),
dto
.
getAfterMobile
()))
{
return
Result
.
failed
(
"新手机号已被绑定"
);
}
user
.
setMobile
(
dto
.
getAfterMobile
());
qdUserDao
.
updateById
(
user
);
// 更新用户缓存
QdUser
resultQdUser
=
qdUserDao
.
queryById
(
user
.
getId
());
String
userKey
=
MessageFormat
.
format
(
CacheCodeConstants
.
USER_INFO_KEY
,
user
.
getId
());
redisUtils
.
set
(
userKey
,
resultQdUser
,
2
*
60
*
60
);
logger
.
info
(
"【请求结束】用户修改手机号成功"
);
// 清除验证码缓存
redisUtils
.
del
(
key
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"用户修改手机号失败"
,
e
);
}
return
Result
.
failed
(
"修改手机号失败"
);
}
@Override
public
Result
userInfo
(
HttpServletRequest
request
)
{
try
{
String
token
=
request
.
getHeader
(
"Authorization"
);
if
(
StringUtils
.
isBlank
(
token
))
{
logger
.
info
(
"获取登录用户的token失败"
);
return
Result
.
failed
(
"查询不到当前登录用户信息"
);
}
Long
userId
=
qdUserTokenManager
.
getUserId
(
token
);
if
(
Objects
.
isNull
(
userId
))
{
logger
.
info
(
"获取登录用户的userId失败"
);
return
Result
.
failed
(
"查询不到当前登录用户信息"
);
}
QdUser
user
=
null
;
String
key
=
MessageFormat
.
format
(
CacheCodeConstants
.
USER_INFO_KEY
,
userId
);
if
(
redisUtils
.
hasKey
(
key
))
{
user
=
(
QdUser
)
redisUtils
.
get
(
key
);
}
else
{
user
=
qdUserDao
.
queryById
(
userId
);
// 缓存用户信息
redisUtils
.
set
(
key
,
user
,
2
*
60
*
60
);
}
logger
.
info
(
"【请求结束】查询用户信息成功"
);
return
Result
.
success
(
user
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询用户信息失败"
,
e
);
return
Result
.
failed
(
"查询用户信息失败"
);
}
}
@Override
public
Result
queryUserInfo
(
QdUserRequestDto
dto
)
{
try
{
QdUser
user
=
qdUserDao
.
queryById
(
dto
.
getUserId
());
return
Result
.
success
(
user
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询用户信息失败"
,
e
);
}
return
Result
.
failed
(
"查询用户信息失败"
);
}
@Override
public
Result
guestUserInfo
(
QdUserRequestDto
dto
,
HttpServletRequest
request
)
{
try
{
String
token
=
request
.
getHeader
(
"Authorization"
);
if
(
StringUtils
.
isBlank
(
token
))
{
logger
.
info
(
"获取登录用户的token失败"
);
return
Result
.
failed
(
"查询不到当前登录用户信息"
);
}
Long
userId
=
qdUserTokenManager
.
getUserId
(
token
);
if
(
Objects
.
isNull
(
userId
))
{
logger
.
info
(
"获取登录用户的userId失败"
);
return
Result
.
failed
(
"查询不到当前登录用户信息"
);
}
QdUser
user
=
qdUserDao
.
queryById
(
dto
.
getUserId
());
QdUserInfo
userInfo
=
new
QdUserInfo
();
userInfo
.
setUserId
(
dto
.
getUserId
());
userInfo
.
setNickName
(
user
.
getNickName
());
userInfo
.
setAvatar
(
user
.
getAvatar
());
userInfo
.
setProfile
(
user
.
getProfile
());
userInfo
.
setBackground
(
user
.
getBackground
());
logger
.
info
(
"【请求结束】查询用户信息成功"
);
return
Result
.
success
(
userInfo
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询用户信息失败"
,
e
);
return
Result
.
failed
(
"查询用户信息失败"
);
}
}
/**
* 获取登录结果
*
* @param dto
* @param request
* @return
*/
private
Map
<
String
,
Object
>
getLoginResult
(
QdUserRequestDto
dto
,
HttpServletRequest
request
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Date
now
=
new
Date
();
// QdUser user = qdUserDao.queryByMobile(dto.getMobile());
QdUser
user
=
qdUserDao
.
queryByOpenId
(
dto
.
getWxOpenid
());
// 判断该手机号是否已经在系统内部注册过,没有则新增
if
(
Objects
.
isNull
(
user
))
{
user
=
new
QdUser
();
String
randomName
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
).
substring
(
0
,
10
);
user
.
setUserName
(
randomName
);
BCryptPasswordEncoder
bCryptPasswordEncoder
=
new
BCryptPasswordEncoder
();
user
.
setPassword
(
bCryptPasswordEncoder
.
encode
(
"Aa123456"
));
user
.
setWxOpenid
(
dto
.
getWxOpenid
());
user
.
setWxUnionid
(
dto
.
getWxUnionid
());
user
.
setProfile
(
""
);
user
.
setNickName
(
randomName
);
user
.
setBackground
(
""
);
user
.
setMobile
(
dto
.
getMobile
());
user
.
setAvatar
(
avatarUrl
);
user
.
setWxOpenid
(
dto
.
getWxOpenid
());
user
.
setWxUnionid
(
dto
.
getWxUnionid
());
user
.
setGender
(
0
);
user
.
setStatus
(
0
);
user
.
setDeleted
(
false
);
user
.
setAddTime
(
now
);
user
.
setUpdateTime
(
now
);
user
.
setLastLoginTime
(
now
);
user
.
setLastLoginIp
(
IpUtil
.
client
(
request
));
qdUserDao
.
insert
(
user
);
long
userId
=
user
.
getId
();
}
else
{
// 注册过的用户修改最后登录的时间以及绑定微信openid和支付宝user_id
if
(
org
.
springframework
.
util
.
StringUtils
.
hasLength
(
dto
.
getWxOpenid
()))
{
user
.
setWxOpenid
(
dto
.
getWxOpenid
());
}
if
(
com
.
xxdxxs
.
utils
.
StringUtils
.
hasLength
(
dto
.
getMobile
()))
{
user
.
setMobile
(
dto
.
getMobile
());
}
user
.
setLastLoginTime
(
new
Date
());
user
.
setLastLoginIp
(
IpUtil
.
client
(
request
));
if
(
qdUserDao
.
updateById
(
user
)
==
0
)
{
logger
.
error
(
"更新用户最后登录信息失败"
);
}
}
// 先登出其他
qdUserTokenManager
.
removeToken
(
user
.
getId
());
// 获取token
UserToken
userToken
=
qdUserTokenManager
.
generateToken
(
user
.
getId
(),
null
);
userToken
.
setSessionKey
(
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
));
result
.
put
(
"token"
,
userToken
.
getToken
());
result
.
put
(
"tokenExpire"
,
userToken
.
getExpireTime
().
toString
());
QdUserInfo
userInfo
=
new
QdUserInfo
();
EntityMapper
.
copyAttribute
(
user
,
userInfo
);
userInfo
.
setUserId
(
user
.
getId
());
userInfo
.
setWxOpenid
(
user
.
getWxOpenid
());
userInfo
.
setWxUnionid
(
user
.
getWxUnionid
());
userInfo
.
setPhone
(
user
.
getMobile
());
userInfo
.
setAvatar
(
user
.
getAvatar
());
userInfo
.
setProfile
(
user
.
getProfile
());
userInfo
.
setBackground
(
user
.
getBackground
());
userInfo
.
setGender
(
user
.
getGender
());
userInfo
.
setNickName
(
user
.
getNickName
());
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
registerDate
=
simpleDateFormat
.
format
(
Objects
.
isNull
(
user
.
getAddTime
())
?
new
Date
()
:
user
.
getAddTime
());
userInfo
.
setRegisterDate
(
registerDate
);
userInfo
.
setStatus
(
user
.
getStatus
());
//会员等级
userInfo
.
setLevel
(
user
.
getLevel
());
result
.
put
(
"userInfo"
,
userInfo
);
result
.
put
(
"wxOpenid"
,
user
.
getWxOpenid
());
// 缓存用户信息
String
userKey
=
MessageFormat
.
format
(
CacheCodeConstants
.
USER_INFO_KEY
,
user
.
getId
());
redisUtils
.
set
(
userKey
,
user
,
2
*
60
*
60
);
return
result
;
}
@Override
public
Result
findById
(
QdUserRequestDto
dto
)
{
try
{
QdUser
user
=
qdUserDao
.
queryById
(
dto
.
getUserId
());
if
(
user
==
null
)
{
return
Result
.
failed
(
"查询不到该用户信息"
);
}
UserInfo
userInfo
=
new
UserInfo
();
userInfo
.
setUserId
(
user
.
getId
());
EntityMapper
.
copyAttribute
(
user
,
userInfo
);
return
Result
.
success
(
userInfo
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询用户信息失败"
,
e
);
return
Result
.
failed
(
"查询用户信息失败"
);
}
}
@Override
public
Result
loginOut
(
QdUserRequestDto
dto
)
{
try
{
//退出登录
qdUserTokenManager
.
removeToken
(
dto
.
getUserId
());
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"退出登录"
,
e
);
return
Result
.
failed
(
"退出登录失败"
);
}
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/manager/QdUserTokenManager.java
0 → 100644
View file @
596d98e0
package
com.wwdz.ch.wx.manager
;
import
com.google.gson.Gson
;
import
com.wwdz.ch.core.util.CharUtil
;
import
com.wwdz.ch.wx.dao.UserToken
;
import
com.wwdz.ch.wx.util.RedisUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Objects
;
/**
* 维护用户token
*/
@Component
public
class
QdUserTokenManager
{
@Autowired
private
RedisUtil
redisUtil
;
private
Gson
gson
=
new
Gson
();
private
static
final
String
TOKEN_PREFIX
=
"qiandao:wx:token:token_prefix:"
;
private
static
final
String
TOKEN_ID_PREFIX
=
"qiandao:wx:token:token_id_prefix:"
;
private
static
Map
<
String
,
UserToken
>
tokenMap
=
new
HashMap
<>();
private
static
Map
<
Long
,
UserToken
>
idMap
=
new
HashMap
<>();
private
static
long
SURVIVAL_TIME
=
86400
*
7
*
365
;
public
Long
getUserId
(
String
token
)
{
String
key
=
TOKEN_PREFIX
+
token
;
Object
tokenObj
=
redisUtil
.
get
(
key
);
if
(
null
==
tokenObj
)
{
return
null
;
}
UserToken
userToken
=
gson
.
fromJson
(
tokenObj
.
toString
(),
UserToken
.
class
);
if
(
userToken
.
getExpireTime
().
isBefore
(
LocalDateTime
.
now
()))
{
redisUtil
.
del
(
key
);
String
idKey
=
TOKEN_ID_PREFIX
+
userToken
.
getUserId
();
redisUtil
.
del
(
idKey
);
return
null
;
}
return
userToken
.
getUserId
();
}
public
boolean
checkLogin
(
String
token
)
{
String
key
=
TOKEN_PREFIX
+
token
;
Object
tokenObj
=
redisUtil
.
get
(
key
);
if
(
Objects
.
isNull
(
tokenObj
))
{
return
false
;
}
UserToken
userToken
=
gson
.
fromJson
(
tokenObj
.
toString
(),
UserToken
.
class
);
if
(
userToken
.
getExpireTime
().
isBefore
(
LocalDateTime
.
now
()))
{
redisUtil
.
del
(
key
);
String
idKey
=
TOKEN_ID_PREFIX
+
userToken
.
getUserId
();
redisUtil
.
del
(
idKey
);
return
false
;
}
String
idKey
=
TOKEN_ID_PREFIX
+
userToken
.
getUserId
();
Object
idObj
=
redisUtil
.
get
(
idKey
);
if
(
Objects
.
isNull
(
idObj
))
{
return
false
;
}
UserToken
idUserToken
=
gson
.
fromJson
(
idObj
.
toString
(),
UserToken
.
class
);
String
idToken
=
idUserToken
.
getToken
();
return
StringUtils
.
equals
(
token
,
idToken
);
}
public
UserToken
generateToken
(
Long
id
,
String
token
)
{
UserToken
userToken
=
null
;
// userToken = idMap.get(id);
// if(userToken != null) {
// tokenMap.remove(userToken.getToken());
// idMap.remove(id);
// }
String
key
=
TOKEN_PREFIX
+
token
;
while
(
null
!=
redisUtil
.
get
(
key
))
{
token
=
CharUtil
.
getRandomString
(
32
);
key
=
TOKEN_PREFIX
+
token
;
}
LocalDateTime
update
=
LocalDateTime
.
now
();
LocalDateTime
expire
=
update
.
plusDays
(
7
);
userToken
=
new
UserToken
();
userToken
.
setToken
(
token
);
userToken
.
setUpdateTime
(
update
);
userToken
.
setExpireTime
(
expire
);
userToken
.
setUserId
(
id
);
String
data
=
gson
.
toJson
(
userToken
);
redisUtil
.
set
(
key
,
data
,
SURVIVAL_TIME
);
String
idKey
=
TOKEN_ID_PREFIX
+
id
;
redisUtil
.
set
(
idKey
,
data
,
SURVIVAL_TIME
);
return
userToken
;
}
public
String
getSessionKey
(
Long
userId
)
{
String
idKey
=
TOKEN_ID_PREFIX
+
userId
;
Object
data
=
redisUtil
.
get
(
idKey
);
if
(
null
==
data
)
{
return
null
;
}
UserToken
userToken
=
gson
.
fromJson
(
data
.
toString
(),
UserToken
.
class
);
if
(
userToken
.
getExpireTime
().
isBefore
(
LocalDateTime
.
now
()))
{
tokenMap
.
remove
(
userToken
.
getToken
());
idMap
.
remove
(
userId
);
return
null
;
}
return
userToken
.
getSessionKey
();
}
public
void
removeToken
(
Long
userId
)
{
String
idKey
=
TOKEN_ID_PREFIX
+
userId
;
Object
data
=
redisUtil
.
get
(
idKey
);
if
(
null
!=
data
)
{
UserToken
userToken
=
gson
.
fromJson
(
data
.
toString
(),
UserToken
.
class
);
String
token
=
userToken
.
getToken
();
String
key
=
TOKEN_PREFIX
+
token
;
redisUtil
.
del
(
key
);
redisUtil
.
del
(
idKey
);
}
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/qiandao/QdUserService.java
0 → 100644
View file @
596d98e0
package
com.wwdz.ch.wx.service.qiandao
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.db.dto.request.qiandao.QdUserRequestDto
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
public
interface
QdUserService
{
/**
* 发送手机验证码
*
* @param dto
* @return
*/
Result
regCaptcha
(
QdUserRequestDto
dto
);
/**
* 手机号登录
*
* @param dto
* @param request
* @return
*/
Result
loginByMobile
(
QdUserRequestDto
dto
,
HttpServletRequest
request
);
/**
* 快捷登录
*
* @param dto
* @param request
* @return
*/
Result
login
(
QdUserRequestDto
dto
,
HttpServletRequest
request
);
/**
* 修改个性签名
*
* @param dto
* @return
*/
Result
updateProfile
(
QdUserRequestDto
dto
);
/**
* 修改背景图片
*
* @param dto
* @return
*/
Result
updateBackground
(
QdUserRequestDto
dto
);
/**
* 修改昵称
*
* @param dto
* @return
*/
Result
updateNickname
(
QdUserRequestDto
dto
);
/**
* 上传图片
*
* @param file
* @return
*/
Result
uploadImage
(
MultipartFile
file
);
/**
* 修改头像
*
* @param dto
* @return
*/
Result
updateAvatar
(
QdUserRequestDto
dto
);
Result
updateQrCode
(
QdUserRequestDto
dto
);
/**
* 修改手机号
*
* @param dto
* @return
*/
Result
updateMobile
(
QdUserRequestDto
dto
);
/**
* 查询用户信息
*
* @param request
* @return
*/
Result
userInfo
(
HttpServletRequest
request
);
/**
* 查询用户信息
*
* @param dto
* @return
*/
Result
queryUserInfo
(
QdUserRequestDto
dto
);
/**
* 查询用户信息
*
* @param dto
* @param request
* @return
*/
Result
guestUserInfo
(
QdUserRequestDto
dto
,
HttpServletRequest
request
);
Result
findById
(
QdUserRequestDto
dto
);
/**
* 退出登录
* @param dto
* @return
*/
Result
loginOut
(
QdUserRequestDto
dto
);
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/qiandao/QdUserController.java
0 → 100644
View file @
596d98e0
package
com.wwdz.ch.wx.web.qiandao
;
import
com.alibaba.fastjson.JSON
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.db.dto.request.qiandao.QdUserRequestDto
;
import
com.wwdz.ch.wx.constant.CacheCodeConstants
;
import
com.wwdz.ch.wx.service.qiandao.QdUserService
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Objects
;
/**
* 用户服务
*/
@RestController
@RequestMapping
(
"/wx/qdUser"
)
@Validated
public
class
QdUserController
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
QdUserController
.
class
);
@Autowired
private
QdUserService
qdUserService
;
@ApiOperation
(
value
=
"快捷登录"
)
@PostMapping
(
"/login"
)
public
Result
login
(
@RequestBody
QdUserRequestDto
dto
,
HttpServletRequest
request
)
{
logger
.
info
(
"【请求开始】快捷登录,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
if
(
StringUtils
.
isBlank
(
dto
.
getLoginCode
()))
{
return
Result
.
failed
(
"授权码不能为空"
);
}
if
(
Objects
.
isNull
(
dto
.
getType
()))
{
return
Result
.
failed
(
"版本类型不能为空"
);
}
if
(
dto
.
getType
()
==
2
)
{
if
(
StringUtils
.
isBlank
(
dto
.
getEncryptedData
())
||
StringUtils
.
isBlank
(
dto
.
getIv
()))
{
return
Result
.
failed
(
"encryptedData或iv不能为空"
);
}
}
return
qdUserService
.
login
(
dto
,
request
);
}
@ApiOperation
(
value
=
"登录手机验证码"
)
@PostMapping
(
"/loginRegCaptcha"
)
public
Object
registerCaptcha
(
@RequestBody
QdUserRequestDto
dto
)
{
logger
.
info
(
"【请求开始】请求登录手机验证码,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
if
(
StringUtils
.
isBlank
(
dto
.
getMobile
()))
{
return
Result
.
failed
(
"手机号不能为空"
);
}
dto
.
setSmsType
(
CacheCodeConstants
.
SmsTypeEnum
.
LOGIN
.
getCode
());
return
qdUserService
.
regCaptcha
(
dto
);
}
@ApiOperation
(
value
=
"手机验证码登录"
)
@PostMapping
(
"/loginByMobile"
)
public
Result
loginByMobile
(
@RequestBody
QdUserRequestDto
dto
,
HttpServletRequest
request
)
{
logger
.
info
(
"【请求开始】手机号登录,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
if
(
StringUtils
.
isBlank
(
dto
.
getMobile
()))
{
return
Result
.
failed
(
"手机号不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getSmsCode
()))
{
return
Result
.
failed
(
"验证码不能为空"
);
}
return
qdUserService
.
loginByMobile
(
dto
,
request
);
}
@ApiOperation
(
value
=
"修改个性签名"
)
@PostMapping
(
"/updateProfile"
)
public
Result
updateProfile
(
@RequestBody
QdUserRequestDto
dto
)
{
logger
.
info
(
"【请求开始】修改个性签名,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
if
(
Objects
.
isNull
(
dto
.
getUserId
())
||
dto
.
getUserId
().
equals
(
0L
))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getProfile
()))
{
dto
.
setProfile
(
""
);
}
else
{
if
(
dto
.
getProfile
().
length
()
>
100
)
{
return
Result
.
failed
(
"个人简介应在100字以内"
);
}
}
return
qdUserService
.
updateProfile
(
dto
);
}
@ApiOperation
(
value
=
"修改背景"
)
@PostMapping
(
"/updateBackground"
)
public
Result
updateBackground
(
@RequestBody
QdUserRequestDto
dto
)
{
logger
.
info
(
"【请求开始】修改背景,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
if
(
Objects
.
isNull
(
dto
.
getUserId
())
||
dto
.
getUserId
().
equals
(
0L
))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getBackground
()))
{
dto
.
setBackground
(
""
);
}
return
qdUserService
.
updateBackground
(
dto
);
}
@ApiOperation
(
value
=
"修改昵称"
)
@PostMapping
(
"/updateNickname"
)
public
Result
updateNickname
(
@RequestBody
QdUserRequestDto
dto
)
{
logger
.
info
(
"【请求开始】修改昵称,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
if
(
Objects
.
isNull
(
dto
.
getUserId
())
||
dto
.
getUserId
().
equals
(
0L
))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getNickName
()))
{
return
Result
.
failed
(
"昵称不能为空"
);
}
return
qdUserService
.
updateNickname
(
dto
);
}
@ApiOperation
(
"图片上传"
)
@PostMapping
(
value
=
"/uploadImage"
)
public
Result
uploadImage
(
@RequestParam
(
"image"
)
MultipartFile
file
)
{
if
(
Objects
.
isNull
(
file
)
||
file
.
isEmpty
())
{
return
Result
.
failed
(
"请上传图片"
);
}
return
qdUserService
.
uploadImage
(
file
);
}
@ApiOperation
(
value
=
"修改头像"
)
@PostMapping
(
"/updateAvatar"
)
public
Result
updateAvatar
(
@RequestBody
QdUserRequestDto
dto
)
{
logger
.
info
(
"【请求开始】修改头像,请求参数:{}"
,
JSON
.
toJSONString
(
true
));
if
(
Objects
.
isNull
(
dto
.
getUserId
())
||
dto
.
getUserId
().
equals
(
0L
))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getAvatar
()))
{
return
Result
.
failed
(
"请上传头像"
);
}
return
qdUserService
.
updateAvatar
(
dto
);
}
@ApiOperation
(
value
=
"修改手机验证码"
)
@PostMapping
(
"/updateRegCaptcha"
)
public
Object
updateRegCaptcha
(
@RequestBody
QdUserRequestDto
dto
)
{
logger
.
info
(
"【请求开始】请求修改手机验证码,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
if
(
StringUtils
.
isBlank
(
dto
.
getMobile
()))
{
return
Result
.
failed
(
"手机号不能为空"
);
}
dto
.
setSmsType
(
CacheCodeConstants
.
SmsTypeEnum
.
UPDATE
.
getCode
());
return
qdUserService
.
regCaptcha
(
dto
);
}
@ApiOperation
(
value
=
"修改手机号"
)
@PostMapping
(
"/updateMobile"
)
public
Result
updateMobile
(
@RequestBody
QdUserRequestDto
dto
)
{
logger
.
info
(
"【请求开始】修改手机号,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
if
(
Objects
.
isNull
(
dto
.
getUserId
())
||
dto
.
getUserId
().
equals
(
0L
))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getBeforeMobile
()))
{
return
Result
.
failed
(
"原手机号不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getAfterMobile
()))
{
return
Result
.
failed
(
"新绑定手机号不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getSmsCode
()))
{
return
Result
.
failed
(
"验证码不能为空"
);
}
return
qdUserService
.
updateMobile
(
dto
);
}
@ApiOperation
(
value
=
"用户信息"
)
@PostMapping
(
"/userInfo"
)
public
Result
userInfo
(
HttpServletRequest
request
)
{
logger
.
info
(
"【请求开始】查询用户信息"
);
return
qdUserService
.
userInfo
(
request
);
}
@ApiOperation
(
value
=
"用户信息(客态)"
)
@PostMapping
(
"/guest/userInfo"
)
public
Result
guestUserInfo
(
@RequestBody
QdUserRequestDto
dto
,
HttpServletRequest
request
)
{
logger
.
info
(
"【请求开始】查询用户信息(客态),请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
return
qdUserService
.
guestUserInfo
(
dto
,
request
);
}
@ApiOperation
(
value
=
"根据用户id查询用户信息"
)
@PostMapping
(
"/findById"
)
public
Result
findById
(
@RequestBody
QdUserRequestDto
dto
)
{
logger
.
info
(
"【请求开始】根据用户id查询用户信息,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
return
qdUserService
.
findById
(
dto
);
}
@ApiOperation
(
value
=
"退出登录"
)
@PostMapping
(
"/loginOut"
)
public
Result
loginOut
(
@RequestBody
QdUserRequestDto
dto
)
{
logger
.
info
(
"【请求开始】退出登录,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
return
qdUserService
.
loginOut
(
dto
);
}
}
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