【Java开源代码栏目提醒】:网学会员为广大网友收集整理了,AttachmentManager.java,希望对大家有所帮助!
package com.example.gw.attachment;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.List;
public class AttachmentManager implements IAttachmentManager{
private IAttachmentDao attachmentDao;
public void setAttachmentDao(IAttachmentDao attachmentDao){
this.attachmentDao = attachmentDao;
}
public IAttachmentDao getAttachmentDao(){
return attachmentDao;
}
public void saveAttachment(Attachment attachment){
attachmentDao.saveOrUpdate(attachment);
}
public Attachment getAttachment(String fileId){
return (Attachment)attachmentDao.findById(Attachment.class,new Integer(fileId));
}
public void deleteAttachmentById(String fileId){
attachmentDao.delete(getAttachment(fileId));
}
public void deleteAttachment(Attachment attachment){
attachmentDao.delete(attachment);
}
public List getAttachmentsBySendDocId(String sendDocId){
String where = " from Attachment where itemId="+sendDocId;
return attachmentDao.find(where);
}
public static void main(String args[]){
ApplicationContext app = new ClassPathXmlApplicationContext("/applicationContext.
xml");
IAttachmentManager attachmentManager = (IAttachmentManager)app.getBean("attachmentManager");
Attachment attachment = new Attachment();
attachmentManager.saveAttachment(attachment);
}
public List getAttachmentList(String sendDocId,String status){
String where = " from Attachment where itemId="+sendDocId+" and status='"+status+"'";
return attachmentDao.find(where);
}
}