Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
Z
zion
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
zhengfg
zion
Commits
01e67bc6
提交
01e67bc6
authored
1月 09, 2020
作者:
zgy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
点赞,取消点赞,查询评论添加点赞标识
上级
18cde5ad
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
95 行增加
和
23 行删除
+95
-23
KeyConstant.java
...ava/com/diaoyun/zion/chinafrica/constant/KeyConstant.java
+6
-2
ShopifyController.java
...diaoyun/zion/chinafrica/controller/ShopifyController.java
+11
-7
TbCfItemCommentEntity.java
...diaoyun/zion/chinafrica/entity/TbCfItemCommentEntity.java
+24
-0
TbCfItemCommentService.java
...aoyun/zion/chinafrica/service/TbCfItemCommentService.java
+3
-3
TbCfItemCommentServiceImpl.java
...n/chinafrica/service/impl/TbCfItemCommentServiceImpl.java
+50
-10
TbCfOrderServiceImpl.java
...un/zion/chinafrica/service/impl/TbCfOrderServiceImpl.java
+1
-1
没有找到文件。
src/main/java/com/diaoyun/zion/chinafrica/constant/KeyConstant.java
浏览文件 @
01e67bc6
...
...
@@ -43,8 +43,12 @@ public class KeyConstant {
//订单失效
public
final
static
Integer
ORDER_EXPIRE
=
0
;
//搜索
public
final
static
String
USER_SEARCH
=
"user_search"
;
public
final
static
String
USER_SEARCH
=
"user_search"
;
//搜索记录时长
public
final
static
Integer
SEARCH_EXPIRE
=
259200
;
public
final
static
Integer
SEARCH_EXPIRE
=
259200
;
//点赞
public
final
static
String
GIVE_LIKE
=
"give_like"
;
public
final
static
String
YES
=
"yes"
;
}
src/main/java/com/diaoyun/zion/chinafrica/controller/ShopifyController.java
浏览文件 @
01e67bc6
...
...
@@ -93,9 +93,10 @@ public class ShopifyController {
*/
@ApiOperation
(
value
=
"查询商品评论"
)
@GetMapping
(
"/querylastcomment"
)
public
Result
queryLastComment
(
@ApiParam
(
"商品ID"
)
@RequestParam
(
"itemId"
)
String
itemId
)
{
public
Result
queryLastComment
(
@ApiParam
(
"商品ID"
)
@RequestParam
(
"itemId"
)
String
itemId
,
@ApiParam
(
"商品ID"
)
@RequestParam
(
"userId"
)
String
userId
)
{
return
tbCfItemCommentService
.
queryLastComment
(
itemId
);
return
tbCfItemCommentService
.
queryLastComment
(
itemId
,
userId
);
}
/**
...
...
@@ -110,8 +111,9 @@ public class ShopifyController {
@GetMapping
(
"/querycomments"
)
public
Result
queryComments
(
@ApiParam
(
"商品ID"
)
@RequestParam
(
"itemId"
)
String
itemId
,
@ApiParam
(
value
=
"页数 默认1"
)
@RequestParam
(
value
=
"pageNum"
,
defaultValue
=
"1"
)
Integer
pageNum
,
@ApiParam
(
value
=
"每页大小 默认10"
)
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
pageSize
)
{
return
tbCfItemCommentService
.
querycomments
(
itemId
,
pageNum
,
pageSize
);
@ApiParam
(
value
=
"每页大小 默认10"
)
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
pageSize
,
@ApiParam
(
"商品ID"
)
@RequestParam
(
"userId"
)
String
userId
)
{
return
tbCfItemCommentService
.
querycomments
(
itemId
,
pageNum
,
pageSize
,
userId
);
}
/**
...
...
@@ -198,9 +200,11 @@ public class ShopifyController {
* @return
*/
@ApiOperation
(
"点赞"
)
@GetMapping
(
"/giveLike/{commentId}"
)
public
Result
giveLike
(
@ApiParam
(
"评论ID"
)
@PathVariable
String
commentId
)
{
return
tbCfItemCommentService
.
giveLike
(
commentId
);
@GetMapping
(
"/giveLike/{commentId}/{userId}/{itemId}"
)
public
Result
giveLike
(
@ApiParam
(
"评论ID"
)
@PathVariable
String
commentId
,
@ApiParam
(
"用户ID"
)
@PathVariable
String
userId
,
@ApiParam
(
"商品ID"
)
@PathVariable
String
itemId
)
{
return
tbCfItemCommentService
.
giveLike
(
commentId
,
userId
,
itemId
);
}
...
...
src/main/java/com/diaoyun/zion/chinafrica/entity/TbCfItemCommentEntity.java
浏览文件 @
01e67bc6
...
...
@@ -79,6 +79,16 @@ public class TbCfItemCommentEntity implements Serializable {
private
String
orderNo
;
private
String
itemName
;
private
boolean
isLike
;
public
boolean
isLike
()
{
return
isLike
;
}
public
void
setLike
(
boolean
like
)
{
isLike
=
like
;
}
public
String
getUserName
()
{
return
userName
;
}
...
...
@@ -120,6 +130,7 @@ public class TbCfItemCommentEntity implements Serializable {
public
String
getId
()
{
return
id
;
}
/**
* 设置:评论人
*/
...
...
@@ -133,6 +144,7 @@ public class TbCfItemCommentEntity implements Serializable {
public
String
getUserId
()
{
return
userId
;
}
/**
* 设置:订单ID
*/
...
...
@@ -146,6 +158,7 @@ public class TbCfItemCommentEntity implements Serializable {
public
String
getOrderId
()
{
return
orderId
;
}
/**
* 设置:商品ID
*/
...
...
@@ -159,6 +172,7 @@ public class TbCfItemCommentEntity implements Serializable {
public
String
getItemId
()
{
return
itemId
;
}
/**
* 设置:类型 0: 只有文本内容 1:带图片
*/
...
...
@@ -172,6 +186,7 @@ public class TbCfItemCommentEntity implements Serializable {
public
Integer
getType
()
{
return
type
;
}
/**
* 设置:图片或视频的url
*/
...
...
@@ -185,6 +200,7 @@ public class TbCfItemCommentEntity implements Serializable {
public
String
getUrls
()
{
return
urls
;
}
/**
* 设置:商品评分
*/
...
...
@@ -198,6 +214,7 @@ public class TbCfItemCommentEntity implements Serializable {
public
Integer
getItemScore
()
{
return
itemScore
;
}
/**
* 设置:服务评分
*/
...
...
@@ -211,6 +228,7 @@ public class TbCfItemCommentEntity implements Serializable {
public
Integer
getServiceScore
()
{
return
serviceScore
;
}
/**
* 设置:物流评分
*/
...
...
@@ -224,6 +242,7 @@ public class TbCfItemCommentEntity implements Serializable {
public
Integer
getLogisticsScore
()
{
return
logisticsScore
;
}
/**
* 设置:价格评分
*/
...
...
@@ -237,6 +256,7 @@ public class TbCfItemCommentEntity implements Serializable {
public
Integer
getPriceScore
()
{
return
priceScore
;
}
/**
* 设置:商品评论
*/
...
...
@@ -250,6 +270,7 @@ public class TbCfItemCommentEntity implements Serializable {
public
String
getItemReview
()
{
return
itemReview
;
}
/**
* 设置:点赞人数
*/
...
...
@@ -263,6 +284,7 @@ public class TbCfItemCommentEntity implements Serializable {
public
Long
getLikeNum
()
{
return
likeNum
;
}
/**
* 设置:删除标志 0:正常 1:已删除
*/
...
...
@@ -276,6 +298,7 @@ public class TbCfItemCommentEntity implements Serializable {
public
Integer
getDelFlag
()
{
return
delFlag
;
}
/**
* 设置:创建时间
*/
...
...
@@ -289,6 +312,7 @@ public class TbCfItemCommentEntity implements Serializable {
public
Date
getCreateTime
()
{
return
createTime
;
}
/**
* 设置:更新时间
*/
...
...
src/main/java/com/diaoyun/zion/chinafrica/service/TbCfItemCommentService.java
浏览文件 @
01e67bc6
...
...
@@ -76,15 +76,15 @@ public interface TbCfItemCommentService {
*/
int
deleteBatch
(
String
[]
ids
);
Result
queryLastComment
(
String
item
Id
);
Result
queryLastComment
(
String
itemId
,
String
user
Id
);
Result
querycomments
(
String
itemId
,
Integer
pageNum
,
Integer
pageSize
);
Result
querycomments
(
String
itemId
,
Integer
pageNum
,
Integer
pageSize
,
String
userId
);
Result
addComment
(
TbCfItemCommentEntity
comment
);
Result
delComment
(
String
commentId
);
Result
giveLike
(
String
commentId
);
Result
giveLike
(
String
commentId
,
String
userId
,
String
itemId
);
}
src/main/java/com/diaoyun/zion/chinafrica/service/impl/TbCfItemCommentServiceImpl.java
浏览文件 @
01e67bc6
package
com
.
diaoyun
.
zion
.
chinafrica
.
service
.
impl
;
import
com.diaoyun.zion.chinafrica.constant.KeyConstant
;
import
com.diaoyun.zion.chinafrica.dao.TbCfItemCommentDao
;
import
com.diaoyun.zion.chinafrica.entity.TbCfItemCommentEntity
;
import
com.diaoyun.zion.chinafrica.entity.TbCfItemCommentEntityExtends
;
import
com.diaoyun.zion.chinafrica.service.TbCfItemCommentService
;
import
com.diaoyun.zion.master.base.Result
;
import
com.diaoyun.zion.master.common.RedisCache
;
import
com.diaoyun.zion.master.enums.ResultCodeEnum
;
import
com.diaoyun.zion.master.util.IdUtil
;
import
com.github.pagehelper.PageInfo
;
...
...
@@ -15,11 +17,9 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
static
com
.
github
.
pagehelper
.
page
.
PageMethod
.
startPage
;
...
...
@@ -34,6 +34,8 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService {
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
TbCfItemCommentServiceImpl
.
class
);
@Autowired
private
TbCfItemCommentDao
tbCfItemCommentDao
;
@Resource
private
RedisCache
<
Object
>
redisCache
;
@Override
public
TbCfItemCommentEntity
queryObject
(
String
id
)
{
...
...
@@ -78,15 +80,21 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService {
* @return
*/
@Override
public
Result
queryLastComment
(
String
itemId
)
{
public
Result
queryLastComment
(
String
itemId
,
String
userId
)
{
Result
result
=
new
Result
();
try
{
TbCfItemCommentEntity
lastComment
=
tbCfItemCommentDao
.
queryLastComment
(
itemId
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
boolean
isLike
=
false
;
if
(
lastComment
!=
null
)
{
double
totalScore
=
lastComment
.
getItemScore
()
+
lastComment
.
getLogisticsScore
()
+
lastComment
.
getPriceScore
()
+
lastComment
.
getServiceScore
();
BigDecimal
total
=
new
BigDecimal
(
totalScore
);
double
score
=
total
.
divide
(
new
BigDecimal
(
4
),
1
,
BigDecimal
.
ROUND_UP
).
doubleValue
();
String
give_like
=
(
String
)
redisCache
.
get
(
KeyConstant
.
GIVE_LIKE
+
userId
+
itemId
);
if
(!
StringUtils
.
isBlank
(
give_like
)
&&
KeyConstant
.
YES
.
equals
(
give_like
))
{
isLike
=
true
;
}
map
.
put
(
"isLike"
,
isLike
);
map
.
put
(
"score"
,
score
);
map
.
put
(
"lastComment"
,
lastComment
);
result
.
setData
(
map
).
setMessage
(
"success"
);
...
...
@@ -111,12 +119,23 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService {
* @return
*/
@Override
public
Result
querycomments
(
String
itemId
,
Integer
pageNum
,
Integer
pageSize
)
{
public
Result
querycomments
(
String
itemId
,
Integer
pageNum
,
Integer
pageSize
,
String
userId
)
{
Result
<
PageInfo
>
result
=
new
Result
();
try
{
startPage
(
pageNum
,
pageSize
);
List
<
TbCfItemCommentEntity
>
comments
=
tbCfItemCommentDao
.
querycomments
(
itemId
);
PageInfo
<
TbCfItemCommentEntity
>
pageInfo
=
new
PageInfo
<>(
comments
);
List
<
TbCfItemCommentEntity
>
commentList
=
new
ArrayList
<>();
for
(
TbCfItemCommentEntity
comment
:
comments
)
{
TbCfItemCommentEntity
commentEntity
=
tbCfItemCommentDao
.
queryObject
(
comment
.
getId
());
commentEntity
.
setLike
(
false
);
System
.
err
.
println
(
comment
.
getUserId
());
String
give_like
=
(
String
)
redisCache
.
get
(
KeyConstant
.
GIVE_LIKE
+
comment
.
getUserId
()
+
comment
.
getItemId
());
if
(!
StringUtils
.
isBlank
(
give_like
)
&&
KeyConstant
.
YES
.
equals
(
give_like
))
{
commentEntity
.
setLike
(
true
);
}
commentList
.
add
(
commentEntity
);
}
PageInfo
<
TbCfItemCommentEntity
>
pageInfo
=
new
PageInfo
<>(
commentList
);
result
.
setData
(
pageInfo
);
}
catch
(
Exception
e
)
{
result
.
setCode
(
ResultCodeEnum
.
QUERY_ERROR
.
getCode
()).
setMessage
(
e
.
getMessage
());
...
...
@@ -133,7 +152,13 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService {
*/
public
Result
addComment
(
TbCfItemCommentEntity
comment
)
{
Result
result
=
new
Result
();
try
{
TbCfItemCommentEntity
commentEntity
=
tbCfItemCommentDao
.
queryByUser
(
comment
.
getItemId
(),
comment
.
getUserId
());
if
(
commentEntity
!=
null
)
{
result
.
setMessage
(
"Already reviewed this product!"
);
return
result
;
}
comment
.
setId
(
IdUtil
.
createIdbyUUID
());
comment
.
setDelFlag
(
0
);
comment
.
setLikeNum
(
0L
);
...
...
@@ -182,13 +207,29 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService {
return
result
;
}
/**
* 点赞
*
* @param commentId
* @param userId
* @param itemId
* @return
*/
@Override
public
Result
giveLike
(
String
commentId
)
{
public
Result
giveLike
(
String
commentId
,
String
userId
,
String
itemId
)
{
Result
result
=
new
Result
();
try
{
String
give_like
=
(
String
)
redisCache
.
get
(
KeyConstant
.
GIVE_LIKE
+
userId
+
itemId
);
TbCfItemCommentEntity
comment
=
tbCfItemCommentDao
.
queryObject
(
commentId
);
Long
likeNum
=
comment
.
getLikeNum
();
comment
.
setLikeNum
(++
likeNum
);
if
(!
StringUtils
.
isBlank
(
give_like
)
&&
KeyConstant
.
YES
.
equals
(
give_like
))
{
comment
.
setLikeNum
(--
likeNum
);
redisCache
.
delete
(
KeyConstant
.
GIVE_LIKE
+
userId
+
itemId
);
}
else
{
comment
.
setLikeNum
(++
likeNum
);
redisCache
.
set
(
KeyConstant
.
GIVE_LIKE
+
userId
+
itemId
,
KeyConstant
.
YES
);
}
tbCfItemCommentDao
.
update
(
comment
);
result
.
setMessage
(
ResultCodeEnum
.
SUCCESS
.
getDesc
());
}
catch
(
Exception
e
)
{
...
...
@@ -199,5 +240,4 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService {
}
}
src/main/java/com/diaoyun/zion/chinafrica/service/impl/TbCfOrderServiceImpl.java
浏览文件 @
01e67bc6
...
...
@@ -217,7 +217,6 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
@Override
public
Result
getUserOrderList
(
Integer
pageNum
,
Integer
pageSize
,
Integer
orderStatus
)
throws
InterruptedException
{
Result
<
PageInfo
<
TbCfOrderVo
>>
result
=
new
Result
<>();
boolean
isCommented
=
false
;
//获取用户
synchronized
(
this
)
{
String
token
=
jwtTokenProvider
.
resolveToken
(
request
);
...
...
@@ -238,6 +237,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
//返回的订单商品详情
List
<
TbCfCartItemDetailVo
>
itemDetailVoList
=
new
ArrayList
<>();
for
(
TbCfItemDetailEntity
tbCfItemDetail
:
tbCfItemDetailList
)
{
boolean
isCommented
=
false
;
//判断商品是否评论过
TbCfItemCommentEntity
comment
=
tbCfItemCommentDao
.
queryByUser
(
tbCfItemDetail
.
getItemId
(),
tbCfUserInfoVo
.
getUserId
());
if
(
comment
!=
null
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论