编程思路如下
先建立实体类Comment,代码:略
DAO层代码
@Mapper
public interface CommentMapper {
List<Comment> selectCommentsByEntity(int entityType, int entityId, int offset, int limit);
int selectCountByEntity(int entityType, int entityId);
}
配置对应的comment-mapper.xml文件
业务层代码如下
@Service
public class CommentService implements CommunityConstant {
@Autowired(required = false)
private CommentMapper commentMapper;
public List<Comment> findCommentsByEntity(int entityType, int entityId, int offset, int limit){
return commentMapper.selectCommentsByEntity(entityType, entityId, offset, limit);
}
public int findCommentCount(int entityType, int entityId)