完成评论管理接口开发

pull/65/head
riverflow 1 month ago
parent 5abc63b45e
commit c0c926b2da

@ -1,8 +1,10 @@
package com.itmk.web.goods_comment.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.itmk.utils.ResultUtils;
import com.itmk.utils.ResultVo;
import com.itmk.web.goods_comment.entity.CommentParm;
import com.itmk.web.goods_comment.entity.GoodsComment;
import com.itmk.web.goods_comment.service.GoodsCommentService;
import com.itmk.web.order_detail.entity.UserOrderDetail;
@ -55,4 +57,17 @@ public class GoodsCommentController {
List<GoodsComment> list = goodsCommentService.commentList(goodsId);
return ResultUtils.success("查询成功",list);
}
//pc列表查询
@GetMapping("/pcCommentList")
public ResultVo pcCommentList(CommentParm parm){
IPage<GoodsComment> list = goodsCommentService.getList(parm);
return ResultUtils.success("查询成功",list);
}
//删除
@DeleteMapping("/{commentId}")
public ResultVo delete(@PathVariable("commentId") Long commentId){
goodsCommentService.removeById(commentId);
return ResultUtils.success("删除成功!");
}
}

@ -0,0 +1,11 @@
package com.itmk.web.goods_comment.entity;
import lombok.Data;
@Data
public class CommentParm {
private Integer currentPage; //当前页
private Integer pageSize;//每页查询的条数
}

@ -27,4 +27,8 @@ public class GoodsComment {
private String avatarUrl;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date createTime;
@TableField(exist = false)
private String goodsName;
@TableField(exist = false)
private String goodsImage;
}

@ -1,6 +1,8 @@
package com.itmk.web.goods_comment.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itmk.web.goods_comment.entity.GoodsComment;
import org.apache.ibatis.annotations.Param;
@ -9,4 +11,5 @@ import java.util.List;
public interface GoodsCommentMapper extends BaseMapper<GoodsComment> {
List<GoodsComment> commentList(@Param("goodsId") Long goodsId);
IPage<GoodsComment> getList(Page<GoodsComment> page);
}

@ -1,6 +1,8 @@
package com.itmk.web.goods_comment.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.itmk.web.goods_comment.entity.CommentParm;
import com.itmk.web.goods_comment.entity.GoodsComment;
import java.util.List;
@ -8,4 +10,5 @@ import java.util.List;
public interface GoodsCommentService extends IService<GoodsComment> {
List<GoodsComment> commentList(Long goodsId);
IPage<GoodsComment> getList(CommentParm parm);
}

@ -1,5 +1,8 @@
package com.itmk.web.goods_comment.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itmk.web.goods_comment.entity.CommentParm;
import com.itmk.web.goods_comment.entity.GoodsComment;
import com.itmk.web.goods_comment.mapper.GoodsCommentMapper;
import com.itmk.web.goods_comment.service.GoodsCommentService;
@ -14,4 +17,11 @@ public class GoodsCommentServiceImpl extends ServiceImpl<GoodsCommentMapper, Goo
public List<GoodsComment> commentList(Long goodsId) {
return this.baseMapper.commentList(goodsId);
}
@Override
public IPage<GoodsComment> getList(CommentParm parm) {
//构造分页对象
Page<GoodsComment> page = new Page<>(parm.getCurrentPage(),parm.getPageSize());
return this.baseMapper.getList(page);
}
}

@ -7,4 +7,11 @@
select w.nick_name,w.avatar_url,g.* from goods_comment as g inner join wx_user as w on g.openid = w.openid
where g.goods_id =#{goodsId}
</select>
<select id="getList" resultType="com.itmk.web.goods_comment.entity.GoodsComment">
SELECT c.*,u.avatar_url,u.nick_name,gs.goods_name,gs.goods_image
FROM goods_comment as c
inner join wx_user as u on c.openid = u.openid
inner join sys_goods as gs on gs.goods_id = c.goods_id
order by c.create_time desc
</select>
</mapper>
Loading…
Cancel
Save