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

📄 upfiledaoim.java

📁 一个不错的bbs论坛系统.对初学者很有帮助
💻 JAVA
字号:
package com.yhbbs.upload.dao;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.yhbbs.data.AppSqlMap;
import com.yhbbs.upload.itface.UpFile;
import com.yhbbs.upload.itface.UpFileDao;

/**
 * <p>Title:系统上传文件的相关操作实现</p>
 * <li>上传文件与数据库相关的各项操作</li>
 * <b>CopyRight: yyhweb[由由华网]</b>
 * @author stephen
 * @version YH-2.0
 */
public class UpFileDaoIm implements UpFileDao {

	private SqlMapClient sqlMapClient = null;
	
	private static UpFileDao filedao = new UpFileDaoIm();
	
	/**
	 * Constructor Method
	 */
	public UpFileDaoIm(){
		sqlMapClient = AppSqlMap.getInstance();
	}
	/**
	 * @return 取得一个系统文件操作对象
	 */
	public static UpFileDao getInstance(){
		return filedao;
	}
	
	private int getInt(Object ob){
		if(ob!=null)
			return Integer.parseInt(ob.toString());
		else
			return 0;
	}
	
	public boolean delOneFile(int id) throws SQLException {
		
		return getInt(sqlMapClient.delete("delOneFile", id))>0;
	}
	
	public boolean delArtFile(int artId) throws SQLException{
		
		return getInt(sqlMapClient.delete("delArtFile", artId))>0;
	}

	public void downAddTime(int id) throws SQLException {
		
	}
	
	public int getUserFileCount(int userId)throws SQLException {
		
		return getInt(sqlMapClient.queryForObject("getUserFileCount", userId));
	}
	
	public int getUserFileSize(int userId)throws SQLException {
		
		return getInt(sqlMapClient.queryForObject("getUserFileSize", userId));
	}
	
	public List getUserFiles(HashMap sizeMap) throws SQLException {
		
		return sqlMapClient.queryForList("getUserFiles", sizeMap);
	}

	public List getArtFiles(int artid,int userId) throws SQLException {
		HashMap<String,Integer> fMap = new HashMap<String,Integer>();
		fMap.put("artid", artid);
		fMap.put("userid", userId);
		return sqlMapClient.queryForList("getArtFile", fMap);
	}

	public int getFileMaxId() throws SQLException {
		
		return getInt(sqlMapClient.queryForObject("getFileMaxId", null));
	}
	
	public void upLoadFile(UpFile file) throws SQLException {
		sqlMapClient.insert("upLoadFile", file);
	}

	public void postArtFiles(int artid, int userid) throws SQLException {
		HashMap<String,Integer> userFile = new HashMap<String,Integer>();
		userFile.put("artId", artid);
		userFile.put("userId", userid);
		sqlMapClient.update("postArtFile", userFile);
	}
}

⌨️ 快捷键说明

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