Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
Z
zion
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
zhengfg
zion
Commits
208869a4
提交
208869a4
authored
1月 03, 2020
作者:
zgy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
评论点赞,商品评分计算
上级
4483bd96
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
86 行增加
和
9 行删除
+86
-9
ShopifyController.java
...diaoyun/zion/chinafrica/controller/ShopifyController.java
+12
-0
TbCfItemCommentDao.java
...a/com/diaoyun/zion/chinafrica/dao/TbCfItemCommentDao.java
+4
-1
TbCfItemCommentEntityExtends.java
.../zion/chinafrica/entity/TbCfItemCommentEntityExtends.java
+1
-1
ShopifyService.java
...a/com/diaoyun/zion/chinafrica/service/ShopifyService.java
+1
-0
TbCfItemCommentService.java
...aoyun/zion/chinafrica/service/TbCfItemCommentService.java
+2
-0
ShopifyServiceImpl.java
...oyun/zion/chinafrica/service/impl/ShopifyServiceImpl.java
+2
-0
TbCfItemCommentServiceImpl.java
...n/chinafrica/service/impl/TbCfItemCommentServiceImpl.java
+25
-2
TbCfStationItemServiceImpl.java
...n/chinafrica/service/impl/TbCfStationItemServiceImpl.java
+19
-1
TbCfItemCommentDao.xml
src/main/resources/mapper/TbCfItemCommentDao.xml
+20
-4
没有找到文件。
src/main/java/com/diaoyun/zion/chinafrica/controller/ShopifyController.java
浏览文件 @
208869a4
...
...
@@ -190,4 +190,16 @@ public class ShopifyController {
public
Result
searchProducts
(
@ApiParam
(
"商品标题"
)
@RequestParam
(
"title"
)
String
title
)
{
return
shopifyService
.
searchProductByTitle
(
title
);
}
/**
* 点赞(评论)
*
* @param commentId
* @return
*/
@ApiOperation
(
"点赞"
)
@GetMapping
(
"/giveLike/{commentId}"
)
public
Result
giveLike
(
@ApiParam
(
"评论ID"
)
@PathVariable
String
commentId
)
{
return
tbCfItemCommentService
.
giveLike
(
commentId
);
}
}
src/main/java/com/diaoyun/zion/chinafrica/dao/TbCfItemCommentDao.java
浏览文件 @
208869a4
...
...
@@ -15,6 +15,9 @@ import java.util.List;
*/
public
interface
TbCfItemCommentDao
extends
BaseDao
<
TbCfItemCommentEntity
>
{
public
TbCfItemCommentEntityExtends
queryLastComment
(
String
itemId
);
TbCfItemCommentEntity
queryLastComment
(
String
itemId
);
List
<
TbCfItemCommentEntity
>
querycomments
(
String
itemId
);
List
<
TbCfItemCommentEntity
>
queryScore
(
String
itemId
);
}
src/main/java/com/diaoyun/zion/chinafrica/entity/TbCfItemCommentEntityExtends.java
浏览文件 @
208869a4
...
...
@@ -7,7 +7,7 @@ import java.util.Date;
* @Date: 2019/11/18
* @Description: 商品评论(默认显示最新条信息)
*/
public
class
TbCfItemCommentEntityExtends
{
public
class
TbCfItemCommentEntityExtends
{
/**
* 商品评论ID
*/
...
...
src/main/java/com/diaoyun/zion/chinafrica/service/ShopifyService.java
浏览文件 @
208869a4
...
...
@@ -20,4 +20,5 @@ public interface ShopifyService {
Result
queryAllProducts
(
String
product_id
);
Result
searchProductByTitle
(
String
title
);
}
src/main/java/com/diaoyun/zion/chinafrica/service/TbCfItemCommentService.java
浏览文件 @
208869a4
...
...
@@ -84,5 +84,7 @@ public interface TbCfItemCommentService {
Result
delComment
(
String
commentId
);
Result
giveLike
(
String
commentId
);
}
src/main/java/com/diaoyun/zion/chinafrica/service/impl/ShopifyServiceImpl.java
浏览文件 @
208869a4
...
...
@@ -232,4 +232,6 @@ public class ShopifyServiceImpl implements ShopifyService {
}
}
src/main/java/com/diaoyun/zion/chinafrica/service/impl/TbCfItemCommentServiceImpl.java
浏览文件 @
208869a4
...
...
@@ -14,7 +14,9 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -78,9 +80,15 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService {
public
Result
queryLastComment
(
String
itemId
)
{
Result
result
=
new
Result
();
try
{
TbCfItemCommentEntityExtends
lastComment
=
tbCfItemCommentDao
.
queryLastComment
(
itemId
);
TbCfItemCommentEntity
lastComment
=
tbCfItemCommentDao
.
queryLastComment
(
itemId
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
if
(
lastComment
!=
null
)
{
result
.
setData
(
lastComment
).
setMessage
(
"success"
);
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
();
map
.
put
(
"score"
,
score
);
map
.
put
(
"lastComment"
,
lastComment
);
result
.
setData
(
map
).
setMessage
(
"success"
);
logger
.
info
(
"query comment success,the itemId is:"
+
itemId
);
}
else
{
result
.
setCode
(
ResultCodeEnum
.
QUERY_ERROR
.
getCode
()).
setMessage
(
"comment is null"
);
...
...
@@ -169,5 +177,20 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService {
return
result
;
}
@Override
public
Result
giveLike
(
String
commentId
)
{
Result
result
=
new
Result
();
try
{
TbCfItemCommentEntity
comment
=
tbCfItemCommentDao
.
queryObject
(
commentId
);
Long
likeNum
=
comment
.
getLikeNum
();
comment
.
setLikeNum
(++
likeNum
);
tbCfItemCommentDao
.
update
(
comment
);
result
.
setMessage
(
ResultCodeEnum
.
SUCCESS
.
getDesc
());
}
catch
(
Exception
e
)
{
result
.
setCode
(
ResultCodeEnum
.
SERVICE_ERROR
.
getCode
()).
setMessage
(
e
.
getMessage
());
logger
.
error
(
e
.
getMessage
());
}
return
result
;
}
}
src/main/java/com/diaoyun/zion/chinafrica/service/impl/TbCfStationItemServiceImpl.java
浏览文件 @
208869a4
...
...
@@ -51,6 +51,9 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
@Resource
private
RedisCache
<
Object
>
redisCache
;
@Autowired
private
TbCfItemCommentDao
tbCfItemCommentDao
;
@Override
public
TbCfStationItemEntity
queryObject
(
String
itemId
)
{
return
tbCfStationItemDao
.
queryObject
(
itemId
);
...
...
@@ -156,6 +159,21 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
itemOption
.
setOptionList
(
optionList
);
itemOptionList
.
add
(
itemOption
);
}
//商品评论
List
<
TbCfItemCommentEntity
>
itemCommentList
=
tbCfItemCommentDao
.
queryScore
(
itemId
);
double
totalScore
=
0
;
double
score
=
5
;
double
total
=
0
;
if
(
itemCommentList
!=
null
&&
itemCommentList
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
itemCommentList
.
size
();
i
++)
{
total
=
itemCommentList
.
get
(
i
).
getItemScore
()
+
itemCommentList
.
get
(
i
).
getLogisticsScore
()
+
itemCommentList
.
get
(
i
).
getServiceScore
()
+
itemCommentList
.
get
(
i
).
getPriceScore
();
totalScore
+=
total
;
}
int
num
=
4
*
itemCommentList
.
size
();
BigDecimal
to
=
new
BigDecimal
(
totalScore
);
BigDecimal
count
=
new
BigDecimal
(
num
);
score
=
to
.
divide
(
count
,
1
,
BigDecimal
.
ROUND_UP
).
doubleValue
();
}
//商品sku
List
<
BigDecimal
>
priceList
=
new
ArrayList
<>();
...
...
@@ -190,6 +208,7 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
map
.
put
(
"itemDesc"
,
itemDesc
);
map
.
put
(
"itemDetail"
,
skuInfoList
);
// map.put("categoryList", categoryList);
map
.
put
(
"score"
,
score
);
map
.
put
(
"optionList"
,
itemOptionList
);
// map.put("priceRange", priceRange);
result
.
setData
(
map
).
setMessage
(
ResultCodeEnum
.
SUCCESS
.
getDesc
());
...
...
@@ -349,5 +368,4 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
}
}
src/main/resources/mapper/TbCfItemCommentDao.xml
浏览文件 @
208869a4
...
...
@@ -49,11 +49,9 @@
AND c.del_flag = 0
ORDER BY c.create_time DESC
</select>
<select
id=
"queryLastComment"
resultType=
"com.diaoyun.zion.chinafrica.entity.TbCfItemCommentEntity
Extends
"
>
<select
id=
"queryLastComment"
resultType=
"com.diaoyun.zion.chinafrica.entity.TbCfItemCommentEntity"
>
SELECT
c.id,
c.create_time,
c.item_review,
c.*,
u.nick username,
m.count count
FROM
...
...
@@ -68,6 +66,24 @@
c.create_time DESC
LIMIT 1
</select>
<select
id=
"queryScore"
resultType=
"com.diaoyun.zion.chinafrica.entity.TbCfItemCommentEntity"
>
select
`id`,
`user_id`,
`order_id`,
`item_id`,
`item_score`,
`service_score`,
`logistics_score`,
`price_score`,
`item_review`,
`like_num`,
`del_flag`,
`create_time`,
`update_time`
from tb_cf_item_comment
WHERE item_id=#{itemId}
</select>
<select
id=
"queryList"
resultType=
"com.diaoyun.zion.chinafrica.entity.TbCfItemCommentEntity"
>
select
`id`,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论