⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 messageserviceimpl.java

📁 通过网站展示学校风采、文化、优点与特色
💻 JAVA
字号:
package com.mvc.service.impl;import java.util.List;import com.mvc.common.exception.MessageServiceException;import com.mvc.common.transaction.HibernateTransaction;import com.mvc.common.util.BeanFactory;import com.mvc.dao.IMessageDao;import com.mvc.dao.bean.JinfengMemberinfo;import com.mvc.dao.bean.JinfengMessage;import com.mvc.dao.bean.JinfengStudents;import com.mvc.service.IMessageService;public class MessageServiceImpl implements IMessageService {	private IMessageDao messageDao =(IMessageDao) BeanFactory.getBean("messageDao");	//	 删除客户	public void delMemberinfo(JinfengMemberinfo memberinfo) throws MessageServiceException {		HibernateTransaction ht=new HibernateTransaction();		ht.beginTransaction();		try {			messageDao.delMemberinfo(memberinfo);			ht.commit();		} catch (Exception e) {			ht.rollback();			e.printStackTrace();			throw new MessageServiceException(e.getMessage());		}					}//删除信息	public void delMessage(JinfengMessage message) throws MessageServiceException {		HibernateTransaction ht=new HibernateTransaction();		ht.beginTransaction();		try {			messageDao.delMessage(message);			ht.commit();		} catch (Exception e) {			ht.rollback();			e.printStackTrace();			throw new MessageServiceException(e.getMessage());		}					}//删除学员	public void delStudents(JinfengStudents studnet) throws MessageServiceException {		HibernateTransaction ht=new HibernateTransaction();		ht.beginTransaction();		try {			messageDao.delStudents(studnet);			ht.commit();		} catch (Exception e) {			ht.rollback();			e.printStackTrace();			throw new MessageServiceException(e.getMessage());		}					}//根据id查找信息	public JinfengMessage findMessageById(Long id) throws MessageServiceException {		HibernateTransaction ht=new HibernateTransaction();		ht.beginTransaction();		try {			JinfengMessage messageid=messageDao.findMessageById(id);			if(messageid==null){				throw new Exception("您要查询的信息不存在!!");			}			ht.commit();			return messageid;		} catch (Exception e) {			ht.rollback();			e.printStackTrace();			throw new MessageServiceException(e.getMessage());		}	}//根据receiver(收件人)查询新信息	public List findNewMessages(String nickname) throws MessageServiceException {		HibernateTransaction ht=new HibernateTransaction();		ht.beginTransaction();		try {			List list=messageDao.findNewMessages(nickname);			if(list==null){				throw new Exception("您暂时没有新信息!!");							}			ht.commit();			return list;		} catch (Exception e) {			e.printStackTrace();			ht.rollback();			throw new MessageServiceException(e.getMessage());		}	}//	 根据receiver查询已接收到的信息	public List findReMessages(String nickname) throws MessageServiceException {		HibernateTransaction ht=new HibernateTransaction();		ht.beginTransaction();		try {			List list=messageDao.findReMessages(nickname);			if(list==null){				throw new Exception("您到现在为止收到任何人发的信息!!");			}			ht.commit();			return list;		} catch (Exception e) {			e.printStackTrace();			ht.rollback();			throw new MessageServiceException(e.getMessage());		}		}//	 根据sender(发件人)查询已发送的信息	public List findSeMessages(String nickname) throws MessageServiceException {		HibernateTransaction ht=new HibernateTransaction();		ht.beginTransaction();		try {			List list=messageDao.findSeMessages(nickname);			if(list==null){				throw new Exception("您没有给任何人发过信息");			}			ht.commit();			return list;		} catch (Exception e) {			e.printStackTrace();			ht.rollback();			throw new MessageServiceException(e.getMessage());		}	}	public int findUnreadedMessagesNumber(String nickname) throws MessageServiceException{		HibernateTransaction ht=new HibernateTransaction();		ht.beginTransaction();		try {			int number=messageDao.findUnreadedMessagesNumber(nickname);			ht.commit();			return number;		} catch (Exception e) {			e.printStackTrace();			ht.rollback();			throw new MessageServiceException(e.getMessage());		}	}	//发送信息	public String sendMessage(JinfengMessage mess) throws MessageServiceException {		HibernateTransaction ht=new HibernateTransaction();		ht.beginTransaction();		String s="";		try {			//System.out.println("aaaaaaaaaaaaa");			//System.out.println("messageDao=="+messageDao);			messageDao.saveMessage(mess);			s="发送成功!!";			ht.commit();		} catch (Exception e) {			e.printStackTrace();			ht.rollback();					}		return s;			}	/*public JinfengMessage findMessageByid(Long id) throws MessageServiceException {		HibernateTransaction ht=new HibernateTransaction();		ht.beginTransaction();		try {			JinfengMessage messageby=messageDao.findMessageById(id);			ht.commit();			return messageby;		} catch (Exception e) {			e.printStackTrace();ht.rollback();			throw new MessageServiceException(e.getMessage());		}			}*/	}

⌨️ 快捷键说明

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