notesserivce.java

来自「java带进度条上传尽量不要让站长把时间都花费在为您修正说明上」· Java 代码 · 共 252 行

JAVA
252
字号
package com.jmwl.biz;

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

import com.jmwl.common.BlogException;
import com.jmwl.dao.NotesDAO;
import com.jmwl.dto.NoteDTO;
import com.jmwl.dto.Note_updateDTO;
import com.jmwl.vo.NoteVO;
import com.jmwl.vo.NotelistVO;

public class NotesSerivce extends BasicService {

	public boolean addNotes(String notename,int userid) throws BlogException{
		NotesDAO notesdao = new NotesDAO();
		this.getConn(); //开启数据库连接,让conn有连接
		notesdao.setConn(conn); //把有连接的conn传给notesdao
		boolean b = notesdao.addNotes(notename, userid);
		this.closeConn();
		return b;
	}
	/**
	 * 添加一篇日志
	 * @param info
	 * @return
	 * @throws BlogException
	 */
	public boolean addnote(NoteDTO info) throws BlogException
	{
		NotesDAO db = new NotesDAO();
		this.getConn(); 
		db.setConn(conn); 
		boolean b=db.addnote(info);
		this.closeConn();
		return b;
	}
	/**
	 * 删除一篇日志
	 * @param id
	 * @return
	 * @throws BlogException
	 */
	public boolean delete_note(int id) throws BlogException
	{
		NotesDAO db = new NotesDAO();
		this.getConn(); 
		db.setConn(conn); 
		boolean b=db.delete_note(id);
		this.closeConn();
		return b;
	}
	/**
	 * 修改一篇日志
	 * @param info
	 * @return
	 * @throws BlogException
	 */
	public boolean update_note(Note_updateDTO info) throws BlogException
	{
		NotesDAO db = new NotesDAO();
		this.getConn(); 
		db.setConn(conn); 
		boolean b=db.update_note(info);
		this.closeConn();
		return b;
	}
	/**
	 * 得到一篇日志
	 * @param id
	 * @return
	 * @throws BlogException
	 */
	public NoteVO getnote(int id) throws BlogException
	{
		NoteVO info=new NoteVO();
		NotesDAO db = new NotesDAO();
		this.getConn(); 
		db.setConn(conn); 
		info=db.getnote(id);
		this.closeConn();
		return info;
	}
	/**
	 * 得到日志列表
	 * @return
	 * @throws BlogException
	 */
	public List<NoteVO> get_all_note(int id,int currpage) throws BlogException
	{
		NotesDAO db = new NotesDAO();
		this.getConn(); 
		db.setConn(conn); 
		List<NoteVO> list=new ArrayList();
		list=db.get_all_note(id,currpage);
		this.closeConn();
		return list;
	}
	/**
	 * 得到一个指定类型的日志列表
	 * @param id
	 * @return
	 * @throws BlogException
	 */
	public List<NoteVO> get_type_note(int id,int bid,int currpage) throws BlogException
	{
		NotesDAO db = new NotesDAO();
		this.getConn(); 
		db.setConn(conn); 
		List<NoteVO> list=new ArrayList();
		list=db.get_type_note(id,bid,currpage);
		this.closeConn();
		return list;
	}
	/**
	 * 得到所有日志的数量
	 * @return
	 * @throws BlogException 
	 */
	public int getn(int id) throws BlogException
	{
		int n=0;
		NotesDAO db = new NotesDAO();
		this.getConn(); 
		db.setConn(conn); 
		n=db.getcount(id);
		this.closeConn();
		return n;
	}
	/**
	 * 得到所有日志的页数
	 * @param id
	 * @return
	 * @throws BlogException
	 */
	public int getcountpage(int id) throws BlogException
	{
		int n=0;
		NotesDAO db = new NotesDAO();
		this.getConn(); 
		db.setConn(conn); 
		n=db.getcountpage(id);
		this.closeConn();
		return n;
	}
	/**
	 * 得到一个指定类型的日志数量
	 * @param uid
	 * @param tid
	 * @return
	 * @throws BlogException
	 */
	public int get_note_sl(int uid,int tid) throws BlogException
	{
		int n=0;
		NotesDAO db = new NotesDAO();
		this.getConn(); 
		db.setConn(conn); 
		n=db.get_note_sl(uid, tid);
		this.closeConn();
		return n;
	}
	/**
	 * 得到指定类型日志的页数
	 * @param uid
	 * @param tid
	 * @return
	 * @throws BlogException
	 */
	public int getonepage(int uid,int tid) throws BlogException
	{
		int n=0;
		NotesDAO db = new NotesDAO();
		this.getConn(); 
		db.setConn(conn); 
		n=db.getonepage(uid, tid);
		this.closeConn();
		return n;
	}
	/**
	 * 增加一次查看次数
	 * @param id
	 * @return
	 * @throws BlogException
	 */
	public boolean see_cs(int id) throws BlogException
	{
		NotesDAO db = new NotesDAO();
		this.getConn(); 
		db.setConn(conn); 
		boolean b=db.add_see_cs(id);
		this.closeConn();
		return b;
	}
	/**
	 * 得到日志类型列表
	 * @return
	 * @throws BlogException
	 */
	public List<NotelistVO> get_list() throws BlogException
	{
		List<NotelistVO> list=new ArrayList();
		NotesDAO db = new NotesDAO();
		this.getConn(); 
		db.setConn(conn); 
		list=db.get_list();
		this.closeConn();
		return list;
	}
	/**
	 * 给回复用户加分
	 * @param id
	 * @return
	 * @throws BlogException
	 */
	public boolean add_hf_jf(int id) throws BlogException
	{
		NotesDAO db = new NotesDAO();
		this.getConn(); 
		db.setConn(conn);
		boolean b=db.add_hf_jf(id);
		this.closeConn();
		return b;
	}
	/**
	 * 给写日志用户加分
	 * @param id
	 * @return
	 * @throws BlogException
	 */
	public boolean add_note_jf(int id) throws BlogException
	{
		NotesDAO db = new NotesDAO();
		this.getConn(); 
		db.setConn(conn);
		boolean b=db.add_note_jf(id);
		this.closeConn();
		return b;
	}
	public static void main(String []args) throws BlogException
	{
		NotesSerivce db=new NotesSerivce();
		List<NoteVO> list=db.get_type_note(1, 1, 1);
		for(NoteVO info:list)
		{
			System.out.println(info.getId()+"---"+info.getTitle());
		}
		
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?