修改评论列表
This commit is contained in:
parent
36fc2d5cd4
commit
81a7a0e5fd
|
@ -11,6 +11,7 @@ import net.maku.framework.common.exception.ServerException;
|
|||
import net.maku.framework.common.utils.PageResult;
|
||||
import net.maku.framework.common.utils.Result;
|
||||
import net.maku.maku.convert.TBookCommentConvert;
|
||||
import net.maku.maku.dao.TBookCommentDao;
|
||||
import net.maku.maku.entity.TBookCommentEntity;
|
||||
import net.maku.maku.entity.TUserEntity;
|
||||
import net.maku.maku.service.TBookCommentService;
|
||||
|
@ -41,6 +42,7 @@ import java.util.List;
|
|||
public class TBookCommentController {
|
||||
private final TBookCommentService tBookCommentService;
|
||||
private final RedisCache redisCache;
|
||||
private final TBookCommentDao tBookCommentDao;
|
||||
|
||||
@PostMapping("/manout")
|
||||
@Operation(summary = "评论")
|
||||
|
@ -112,11 +114,17 @@ public class TBookCommentController {
|
|||
|
||||
return Result.ok();
|
||||
}
|
||||
@GetMapping("/list/{bookId}")
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "查看评论列表")
|
||||
public Result<List<TBookCommentEntity>> list(@PathVariable Integer bookId){
|
||||
|
||||
return Result.ok(tBookCommentService.getByBookId(bookId));
|
||||
public List<TBookCommentEntity> list(HttpServletRequest request){
|
||||
String token = request.getHeader("token");
|
||||
TUserEntity entity = (TUserEntity) redisCache.get(token);
|
||||
if(ObjectUtils.isNull(entity)){
|
||||
throw new ServerException(ErrorCode.REFRESH_TOKEN_INVALID);
|
||||
}
|
||||
TUserEntity tUserEntity = (TUserEntity) redisCache.get(token);
|
||||
Integer userId=tUserEntity.getId();
|
||||
return tBookCommentDao.findAll(Long.valueOf(userId));
|
||||
}
|
||||
|
||||
}
|
|
@ -4,6 +4,8 @@ import net.maku.framework.mybatis.dao.BaseDao;
|
|||
import net.maku.maku.entity.TBookCommentEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
@ -12,5 +14,5 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
*/
|
||||
@Mapper
|
||||
public interface TBookCommentDao extends BaseDao<TBookCommentEntity> {
|
||||
|
||||
List<TBookCommentEntity> findAll(Long bookId);
|
||||
}
|
|
@ -8,9 +8,22 @@
|
|||
<result property="userId" column="user_id"/>
|
||||
<result property="bookId" column="book_id"/>
|
||||
<result property="comment" column="comment"/>
|
||||
<result property="parentId" column="parent_id"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
<select id="findAll" parameterType="map" resultType="map">
|
||||
SELECT
|
||||
tb.book_name,
|
||||
tu.username,
|
||||
tb.book_cover,
|
||||
tc.comment
|
||||
FROM
|
||||
t_book_comment tc
|
||||
LEFT JOIN t_book tb ON tc.book_id = tb.id
|
||||
LEFT JOIN t_user tu ON tc.user_id = tu.id
|
||||
|
||||
WHERE
|
||||
tc.user_id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user