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
bec1305d
Commit
bec1305d
authored
Sep 27, 2023
by
gaia
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/quanku_0930' into release_pre_20230927101218
parents
42b911e9
6c753f93
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
185 additions
and
201 deletions
+185
-201
ch-admin-api/src/main/java/com/wwdz/ch/admin/controller/AdminAuthController.java
...ava/com/wwdz/ch/admin/controller/AdminAuthController.java
+4
-1
ch-admin-api/src/main/java/com/wwdz/ch/admin/entity/vo/CoinVo.java
...api/src/main/java/com/wwdz/ch/admin/entity/vo/CoinVo.java
+5
-0
ch-admin-api/src/main/java/com/wwdz/ch/admin/impl/AdminAuthServiceImpl.java
...ain/java/com/wwdz/ch/admin/impl/AdminAuthServiceImpl.java
+5
-1
ch-core/src/main/java/com/wwdz/ch/core/captcha/CaptchaCodeManager.java
...ain/java/com/wwdz/ch/core/captcha/CaptchaCodeManager.java
+15
-35
ch-dao/src/main/java/com/wwdz/ch/db/impl/ItemDaoImpl.java
ch-dao/src/main/java/com/wwdz/ch/db/impl/ItemDaoImpl.java
+1
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
...c/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
+39
-45
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
...pi/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
+116
-119
No files found.
ch-admin-api/src/main/java/com/wwdz/ch/admin/controller/AdminAuthController.java
View file @
bec1305d
...
...
@@ -39,6 +39,9 @@ public class AdminAuthController {
@Autowired
private
AdminAuthService
adminAuthService
;
@Autowired
CaptchaCodeManager
captchaCodeManager
;
/*
* { username : value, password : value }
*/
...
...
@@ -56,7 +59,7 @@ public class AdminAuthController {
}
//验证码校验
String
cachedCaptcha
=
C
aptchaCodeManager
.
getCachedCaptcha
(
uuid
);
String
cachedCaptcha
=
c
aptchaCodeManager
.
getCachedCaptcha
(
uuid
);
if
(
cachedCaptcha
==
null
)
{
logger
.
error
(
"系统管理->用户登录 错误:{},"
,
AdminResponseCode
.
AUTH_CAPTCHA_EXPIRED
.
desc
());
return
AdminResponseUtil
.
fail
(
AdminResponseCode
.
AUTH_CAPTCHA_EXPIRED
);
...
...
ch-admin-api/src/main/java/com/wwdz/ch/admin/entity/vo/CoinVo.java
View file @
bec1305d
...
...
@@ -118,6 +118,11 @@ public class CoinVo implements Entity {
*/
private
String
weight
;
/**
* 原始的资源url
*/
private
String
originalSourceUrl
;
/**
* 对应的分类
*
...
...
ch-admin-api/src/main/java/com/wwdz/ch/admin/impl/AdminAuthServiceImpl.java
View file @
bec1305d
...
...
@@ -39,6 +39,9 @@ public class AdminAuthServiceImpl implements AdminAuthService {
@Autowired
private
ApplicationContext
context
;
@Autowired
CaptchaCodeManager
captchaCodeManager
;
@Override
public
Object
info
()
{
...
...
@@ -72,7 +75,8 @@ public class AdminAuthServiceImpl implements AdminAuthService {
String
verifyCode
=
VerifyCodeUtils
.
generateVerifyCode
(
4
);
// 唯一标识
String
uuid
=
UUID
.
randomUUID
().
toString
(
true
);
boolean
successful
=
CaptchaCodeManager
.
addToCache
(
uuid
,
verifyCode
,
10
);
//存储内存
//存入redis
boolean
successful
=
captchaCodeManager
.
addToCache
(
uuid
,
verifyCode
);
if
(!
successful
)
{
logger
.
error
(
"请求验证码出错:{}"
,
AdminResponseCode
.
AUTH_CAPTCHA_FREQUENCY
.
desc
());
return
AdminResponseUtil
.
fail
(
AdminResponseCode
.
AUTH_CAPTCHA_FREQUENCY
);
...
...
ch-core/src/main/java/com/wwdz/ch/core/captcha/CaptchaCodeManager.java
View file @
bec1305d
package
com.wwdz.ch.core.captcha
;
import
com.wwdz.ch.core.util.RedisUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.time.LocalDateTime
;
import
java.util.*
;
...
...
@@ -10,12 +13,17 @@ import java.util.Map.Entry;
/**
* 缓存系统中的验证码
*/
@Component
public
class
CaptchaCodeManager
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CaptchaCodeManager
.
class
);
private
static
final
Integer
DEFAULT_EXPIRE_MINUTES
=
3
;
//验证码默认存储的有效期,单位:分钟
private
static
Map
<
String
,
CaptchaItem
>
captchaCodeCache
=
new
HashMap
<>();
@Autowired
RedisUtils
redisUtils
;
/**
* 添加到缓存
*
...
...
@@ -24,30 +32,8 @@ public class CaptchaCodeManager {
* @param code
* 验证码
*/
public
static
boolean
addToCache
(
String
flagUid
,
String
code
,
Integer
expireTime
)
{
cleanExpireCacheData
();
//清理过期内存数据
// 已经发过验证码且验证码还未过期
if
(
captchaCodeCache
.
get
(
flagUid
)
!=
null
)
{
if
(
captchaCodeCache
.
get
(
flagUid
).
getExpireTime
().
isAfter
(
LocalDateTime
.
now
()))
{
return
false
;
}
else
{
// 存在但是已过期,删掉
captchaCodeCache
.
remove
(
flagUid
);
}
}
CaptchaItem
captchaItem
=
new
CaptchaItem
();
captchaItem
.
setFlagUid
(
flagUid
);
captchaItem
.
setCode
(
code
);
// 有效期为expireTime分钟
if
(
expireTime
==
null
)
{
expireTime
=
DEFAULT_EXPIRE_MINUTES
;
}
captchaItem
.
setExpireTime
(
LocalDateTime
.
now
().
plusMinutes
(
expireTime
));
captchaCodeCache
.
put
(
flagUid
,
captchaItem
);
public
boolean
addToCache
(
String
flagUid
,
String
code
)
{
redisUtils
.
set
(
flagUid
,
code
,
3
*
60
);
return
true
;
}
...
...
@@ -59,24 +45,18 @@ public class CaptchaCodeManager {
* 关联的标志码
* @return 验证码
*/
public
static
String
getCachedCaptcha
(
String
flagUid
)
{
public
String
getCachedCaptcha
(
String
flagUid
)
{
// 没有标志码记录
if
(
captchaCodeCache
.
get
(
flagUid
)
==
null
)
return
null
;
// 记录但是已经过期
if
(
captchaCodeCache
.
get
(
flagUid
).
getExpireTime
().
isBefore
(
LocalDateTime
.
now
()))
{
if
(!
redisUtils
.
hasKey
(
flagUid
))
{
return
null
;
}
cleanExpireCacheData
();
//清理过期内存数据
return
captchaCodeCache
.
get
(
flagUid
).
getCode
();
return
redisUtils
.
get
(
flagUid
).
toString
();
}
/**
* 清理过期验证码
*/
private
static
void
cleanExpireCacheData
()
{
private
void
cleanExpireCacheData
()
{
Iterator
<
Entry
<
String
,
CaptchaItem
>>
iterator
=
captchaCodeCache
.
entrySet
().
iterator
();
//map.entrySet()得到的是set集合,可以使用迭代器遍历
List
<
String
>
keys
=
new
ArrayList
<
String
>();
while
(
iterator
.
hasNext
()){
...
...
@@ -93,7 +73,7 @@ public class CaptchaCodeManager {
}
}
public
static
void
removeCacheData
(
String
flagUid
)
{
public
void
removeCacheData
(
String
flagUid
)
{
captchaCodeCache
.
remove
(
flagUid
);
}
...
...
ch-dao/src/main/java/com/wwdz/ch/db/impl/ItemDaoImpl.java
View file @
bec1305d
...
...
@@ -38,6 +38,7 @@ public class ItemDaoImpl implements ItemDao {
}
criteria
.
andIsDeletedEqualTo
(
false
);
criteria
.
andStateEqualTo
(
0
);
criteria
.
andKindEqualTo
(
1
);
criteria
.
andSourceIn
(
CHINESE_SOURCE_LIST
);
return
itemMapper
.
selectOneByExampleWithBLOBs
(
example
);
}
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
View file @
bec1305d
package
com.wwdz.ch.wx.impl
;
import
com.github.pagehelper.PageInfo
;
import
com.wwdz.ch.core.consts.ResultCode
;
import
com.wwdz.ch.core.consts.ViewPermissionEnum
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.util.MediaUtil
;
...
...
@@ -180,7 +181,7 @@ public class FavoritesServiceImpl implements FavoritesService {
try
{
Favorites
favorites
=
favoritesDao
.
info
(
dto
.
getId
());
if
(
Objects
.
isNull
(
favorites
))
{
return
Result
.
failed
(
"数据异常,记录不存在
"
);
return
Result
.
failed
(
ResultCode
.
INVALID_DATA
.
getCode
(),
"该收藏册已经被删除
"
);
}
FavoritesResponseVo
vo
=
new
FavoritesResponseVo
();
vo
.
setId
(
favorites
.
getId
());
...
...
@@ -234,56 +235,49 @@ public class FavoritesServiceImpl implements FavoritesService {
// 获取仅自己可见的藏品列表
Long
userId
=
userTokenManager
.
getUserId
(
request
.
getHeader
(
"Authorization"
));
// 是否客态
boolean
isGuest
=
!
dto
.
getUserId
().
equals
(
userId
);
List
<
Long
>
onlyOneselfItemIds
=
itemCommonService
.
getOnlyOneselfItemIds
(
request
.
getHeader
(
"Authorization"
));
// 分页查询
PageInfo
<
FavoritesItemsRelation
>
relationPage
=
favoritesItemsRelationDao
.
pageByFavoritesId
(
dto
.
getId
(),
onlyOneselfItemIds
,
dto
.
getPage
(),
dto
.
getSize
());
page
.
setHasNextPage
(
relationPage
.
isHasNextPage
());
if
(
relationPage
.
getList
().
isEmpty
())
{
return
Result
.
success
(
page
);
}
if
(
CollectionUtils
.
isNotEmpty
(
relationPage
.
getList
()))
{
List
<
AgentTranceResponseVo
>
list
=
new
ArrayList
<>();
for
(
FavoritesItemsRelation
relation
:
relationPage
.
getList
())
{
AgentTranceResponseVo
agentTranceResponseVo
=
new
AgentTranceResponseVo
();
agentTranceResponseVo
.
setAgentTraceInfo_
(
""
);
agentTranceResponseVo
.
setViewType
(
2
);
ItemResponseVo
v
o
=
new
ItemResponseVo
();
ItemResponseVo
itemResponseV
o
=
new
ItemResponseVo
();
Item
item
=
itemDao
.
findDetails
(
relation
.
getItemId
());
// 设置基本信息
vo
.
setId
(
relation
.
getItemId
());
vo
.
setName
(
item
.
getName
());
vo
.
setImages
(
item
.
getImages
());
vo
.
setDetail
(
item
.
getDetail
());
vo
.
setFavoritesId
(
dto
.
getId
());
vo
.
setIsDeleted
(
item
.
getIsDeleted
());
itemResponseVo
.
setId
(
relation
.
getItemId
());
itemResponseVo
.
setName
(
item
.
getName
());
itemResponseVo
.
setImages
(
item
.
getImages
());
itemResponseVo
.
setDetail
(
item
.
getDetail
());
itemResponseVo
.
setFavoritesId
(
dto
.
getId
());
itemResponseVo
.
setIsDeleted
(
item
.
getIsDeleted
());
itemResponseVo
.
setViewPermission
(
item
.
getViewPermission
());
// 设置价格
v
o
.
setPrice
(
getPrice
(
item
.
getPrice
()));
itemResponseV
o
.
setPrice
(
getPrice
(
item
.
getPrice
()));
// 设置是否收藏或是否是自己发布的
vo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
userId
,
relation
.
getItemId
(),
null
)
?
1
:
0
);
vo
.
setIsMine
(
0
);
if
(
Objects
.
nonNull
(
dto
.
getUserId
())
&&
dto
.
getUserId
()
!=
0L
)
{
if
(!
isGuest
)
{
vo
.
setIsMine
(
userItemsRelationDao
.
isExisted
(
dto
.
getUserId
(),
item
.
getId
())
?
1
:
0
);
}
}
itemResponseVo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
userId
,
relation
.
getItemId
(),
null
)
?
1
:
0
);
itemResponseVo
.
setIsMine
(
userItemsRelationDao
.
isExisted
(
userId
,
item
.
getId
())
?
1
:
0
);
// 设置收藏数
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
item
.
getId
());
v
o
.
setCollectCount
(
StringUtil
.
formatCount
(
count
));
itemResponseV
o
.
setCollectCount
(
StringUtil
.
formatCount
(
count
));
// 设置藏品发布用户的昵称和头像
itemCommonService
.
getNicknameAvatar
(
item
.
getId
(),
vo
);
vo
.
setViewPermission
(
item
.
getViewPermission
());
itemCommonService
.
getNicknameAvatar
(
item
.
getId
(),
itemResponseVo
);
// 设置浏览量
vo
.
setViewsNumber
(
item
.
getViewPermission
().
equals
(
ViewPermissionEnum
.
ALL
.
getCode
())
?
StringUtil
.
formatCount
(
footPrintDao
.
countByItemIds
(
vo
.
getItemUserId
(),
item
.
getId
(),
null
))
:
"0"
);
itemResponseVo
.
setViewsNumber
(
item
.
getViewPermission
().
equals
(
ViewPermissionEnum
.
ALL
.
getCode
())
?
StringUtil
.
formatCount
(
footPrintDao
.
countByItemIds
(
itemResponseVo
.
getItemUserId
(),
item
.
getId
(),
null
))
:
"0"
);
// 设置图片或视频
v
o
.
setHomePageImage
(
MediaUtil
.
getHomePageImage
(
item
.
getImages
(),
item
.
getVideos
()));
agentTranceResponseVo
.
setDetail
(
v
o
);
itemResponseV
o
.
setHomePageImage
(
MediaUtil
.
getHomePageImage
(
item
.
getImages
(),
item
.
getVideos
()));
agentTranceResponseVo
.
setDetail
(
itemResponseV
o
);
list
.
add
(
agentTranceResponseVo
);
}
page
.
setTotal
(
favoritesItemsRelationDao
.
countByFavoritesId
(
dto
.
getId
()));
page
.
setList
(
list
);
}
logger
.
info
(
"【请求结束】查看收藏册的藏品列表成功"
);
return
Result
.
success
(
page
);
}
catch
(
Exception
e
)
{
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
View file @
bec1305d
This diff is collapsed.
Click to expand it.
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