后台biz 接口与实现 CommentBiz

本文介绍了一个关于评论联表业务逻辑层接口及其实现的Java代码案例。该案例展示了如何通过联表查询来获取评论及其状态信息,并实现了分页功能。主要涉及的技术包括Java编程语言、评论表和评论状态表的联表查询。
package cn.service.biz;

import java.util.List;

import cn.entity.Comment;

/*
 * 评论联表 业务逻辑层 接口
 * */
public interface CommentBiz {
	
	//评论分页 联表(评论表,评论状态表)
	public List<Comment>  getCommentByPage(int pageIndex, int pageSize,
			int id, String userId);
}

 

package cn.service.biz.impl;

import java.util.ArrayList;
import java.util.List;

import cn.entity.Comment;
import cn.entity.CommentStatus;
import cn.entity.NeComment;
import cn.service.biz.CommentBiz;
import cn.service.dao.CommentStatusDao;
import cn.service.dao.NeCommentDao;
import cn.service.dao.impl.CommentStatusDaoImpl;
import cn.service.dao.impl.NeCommentDaoImpl;

/*
 * 评论联表 业务逻辑层 实现
 * */
public class CommentBizImpl implements CommentBiz {

	//评论分页 联表(评论表,评论状态表)
	public List<Comment> getCommentByPage(int pageIndex, int pageSize, int id,
			String userId) {
		
		//评论表
		NeCommentDao neCommentDao = new NeCommentDaoImpl();
		List<NeComment> neCommentlist = neCommentDao.getNeCommentByPage(pageIndex, pageSize, id, userId);

		//评论状态表
		CommentStatusDao commentStatusDao = new CommentStatusDaoImpl();
		List<CommentStatus> commentStatusList = commentStatusDao.commentStatusList();
		
		//开始联表
		List<Comment> list = new ArrayList<Comment>();
		Comment item = null;
		
		for(int i=0; i<neCommentlist.size();i++){
			int products_id = neCommentlist.get(i).getNe_products_id();
			String content = neCommentlist.get(i).getNe_content();
			String user_id = neCommentlist.get(i).getNe_user_id();
			String time = neCommentlist.get(i).getNe_time();
			int status_id = neCommentlist.get(i).getNe_status_id();
			String status_content =null;
			for(int j=0; j<commentStatusList.size();j++){
				if(neCommentlist.get(i).getNe_status_id()==commentStatusList.get(j).getComment_status_id()){
					status_content = commentStatusList.get(j).getComment_status_content();
					break;
				}
			}
			item = new Comment(products_id, content, user_id, time, status_id, status_content);
			list.add(item);
		}
		return list;
	}

}

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值