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

📄 smsmanager.java

📁 一个用jsp写的完整的论坛源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				+ " set delR=1 where incept=? and delR=0";
		JdbcWrapper jw = new JdbcWrapper();
		try {
			jw.prepareStatement(sql);
			jw.setString(1, userName);
			jw.executeUpdate();
		} catch (Exception e) {
			log.error("清空收件箱信息出错", e);
			throw new Exception("清空收件箱信息出错");
		} finally {
			jw.close();
		}
	}

	public void delOutBox(HttpServletRequest request) throws Exception {
		int ID = 0;
		try {
			ID = ParamUtil.getInt(request, "id");
		} catch (Exception e) {
			throw new Exception("请指定相关参数。");
		}
		JdbcWrapper jw = new JdbcWrapper();
		sql = "update " + BBSConst.TABLE_MESSAGE
				+ " set delS=1 where sender=? and issend=0 and id =?";
		try {
			jw.prepareStatement(sql);
			jw.setString(1, userName);
			jw.setInt(2, ID);
			jw.executeUpdate();
		} catch (Exception e) {
			log.error("删除发件箱信息出错", e);
			throw new Exception("删除发件箱信息出错");
		} finally {
			jw.close();
		}
	}

	public void allDelOutBox() throws Exception {
		sql = "update " + BBSConst.TABLE_MESSAGE
				+ " set delS=1 where sender=? and delS=0 and issend=0";
		JdbcWrapper jw = new JdbcWrapper();
		try {
			jw.prepareStatement(sql);
			jw.setString(1, userName);
			jw.executeUpdate();
		} catch (Exception e) {
			log.error("清空发件箱信息出错", e);
			throw new Exception("清空发件箱信息出错");
		} finally {
			jw.close();
		}
	}

	public void delIsSend(HttpServletRequest request) throws Exception {
		int ID = 0;
		try {
			ID = ParamUtil.getInt(request, "id");
		} catch (Exception e) {
			throw new Exception("请指定相关参数。");
		}
		JdbcWrapper jw = new JdbcWrapper();
		sql = "update " + BBSConst.TABLE_MESSAGE
				+ " set delS=1 where sender=? and issend=1 and id =" + ID;
		try {
			jw.prepareStatement(sql);
			jw.setString(1, userName);
			jw.executeUpdate();
		} catch (Exception e) {
			log.error("删除草稿箱信息出错", e);
			throw new Exception("删除草稿箱信息出错");
		} finally {
			jw.close();
		}
	}

	public void allDelIsSend() throws Exception {
		sql = "update " + BBSConst.TABLE_MESSAGE
				+ " set delS=1 where sender=? and delS=0 and issend=1";
		JdbcWrapper jw = new JdbcWrapper();
		try {
			jw.prepareStatement(sql);
			jw.setString(1, userName);
			jw.executeUpdate();
		} catch (Exception e) {
			log.error("清空草稿箱信息出错", e);
			throw new Exception("清空草稿箱信息出错");
		} finally {
			jw.close();
		}
	}

	public void delRecycle(HttpServletRequest request) throws Exception {
		int ID = 0;
		try {
			ID = ParamUtil.getInt(request, "id");
		} catch (Exception e) {
			throw new Exception("请指定相关参数。");
		}
		JdbcWrapper jw = new JdbcWrapper();
		sql = "delete from " + BBSConst.TABLE_MESSAGE
				+ " where incept=? and delR=1 and id=?";
		try {
			jw.setAutoClose(false);
			jw.prepareStatement(sql);
			jw.setString(1, userName);
			jw.setInt(2, ID);
			jw.executeUpdate();
			sql = "update " + BBSConst.TABLE_MESSAGE
					+ " set delS=2 where sender=? and delS=1 and id =?";
			jw.prepareStatement(sql);
			jw.setString(1, userName);
			jw.setInt(2, ID);
			jw.executeUpdate();
		} catch (Exception e) {
			log.error("删除回收箱信息出错", e);
			throw new Exception("删除回收箱信息出错");
		} finally {
			jw.close();
		}
	}

	public void allDelRecycle() throws Exception {
		JdbcWrapper jw = new JdbcWrapper();
		sql = "delete from " + BBSConst.TABLE_MESSAGE
				+ " where incept=? and delR=1";
		try {
			jw.setAutoClose(false);
			jw.prepareStatement(sql);
			jw.setString(1, userName);
			jw.executeUpdate();
			sql = "update " + BBSConst.TABLE_MESSAGE
					+ " set delS=2 where sender=? and delS=1";
			jw.prepareStatement(sql);
			jw.setString(1, userName);
			jw.executeUpdate();
		} catch (Exception e) {
			log.error("清空回收箱信息出错", e);
			throw new Exception("清空回收箱信息出错");
		} finally {
			jw.close();
		}
	}

	public void delete(HttpServletRequest request) throws Exception {
		int ID = 0;
		try {
			ID = ParamUtil.getInt(request, "id");
		} catch (Exception e) {
			throw new Exception("请指定相关参数。");
		}
		JdbcWrapper jw = new JdbcWrapper();

		sql = "update " + BBSConst.TABLE_MESSAGE
				+ " set delR=1 where incept=? and id=?";
		try {
			jw.setAutoClose(false);
			jw.prepareStatement(sql);
			jw.setString(1, userName);
			jw.setInt(2, ID);
			jw.executeUpdate();
			sql = "update " + BBSConst.TABLE_MESSAGE
					+ " set delS=1 where sender=? and id=" + ID;
			jw.prepareStatement(sql);
			jw.setString(1, userName);
			jw.executeUpdate();
		} catch (Exception e) {
			log.error("删除信息出错", e);
			throw new Exception("删除信息出错");
		} finally {
			jw.close();
		}
	}

	public void saveSMS(HttpServletRequest request) throws Exception {

		String touser = ParamUtil.getString(request, "touser");
		if (touser == null || touser.trim().equals("")) {
			throw new Exception("您忘记填写发送对象了吧。");
		}
		String title = ParamUtil.getString(request, "title");
		if (title == null || title.trim().equals("")) {
			throw new Exception("您还没有填写标题呀。");
		}
		String message = ParamUtil.getString(request, "message");
		if (message == null || message.trim().equals("")) {
			throw new Exception("内容是必须要填写的噢。");
		}
		JdbcWrapper jw = new JdbcWrapper();
		try {
			jw.setAutoClose(false);
			String[] users = touser.split(",");
			for (int i = 0; i < users.length; i++) {
				if (i > 4) {
					throw new Exception("最多只能发送给5个用户,您的名单5位以后的请重新发送");
				}
				sql = "select username from " + BBSConst.TABLE_USER
						+ " where username='" + users[i] + "'";
				jw.executeQuery(sql);
				if (!jw.next()) {
					throw new Exception("论坛没有这个用户,看看你的发送对象写对了嘛?");
				}
				//
				String submit = ParamUtil.getString(request, "Submit", "");
				if (submit.equals("发送")) {
					sql = "insert into "
							+ BBSConst.TABLE_MESSAGE
							+ " (incept,sender,title,content,sendtime,flag,issend) values (?,?,?,?,now(),0,1)";
				} else {
					sql = "insert into "
							+ BBSConst.TABLE_MESSAGE
							+ " (incept,sender,title,content,sendtime,flag,issend) values (?,?,?,?,now(),0,0)";
				}
				jw.prepareStatement(sql);
				jw.setString(1, users[i]);
				jw.setString(2, userName);
				jw.setString(3, title);
				jw.setString(4, message);
				jw.executeUpdate();
			}
		} catch (Exception e) {
			log.error("发送信息出错", e);
			throw e;
		} finally {
			jw.close();
		}
	}

	public void saveEdit(HttpServletRequest request) throws Exception {
		int ID = 0;
		try {
			ID = ParamUtil.getInt(request, "id");
		} catch (Exception e) {
			throw new Exception("请指定相关参数。");
		}
		String touser = ParamUtil.getString(request, "touser");
		if (touser == null || touser.trim().equals("")) {
			throw new Exception("您忘记填写发送对象了吧。");
		}
		String title = ParamUtil.getString(request, "title");
		if (title == null || title.trim().equals("")) {
			throw new Exception("您还没有填写标题呀。");
		}
		String message = ParamUtil.getString(request, "message");
		if (message == null || message.trim().equals("")) {
			throw new Exception("内容是必须要填写的噢。");
		}
		String incept = touser;
		JdbcWrapper jw = new JdbcWrapper();
		try {
			sql = "select username from " + BBSConst.TABLE_USER
					+ " where username='" + incept + "'";
			jw.executeQuery(sql);
			if (!jw.next()) {
				throw new Exception("论坛没有这个用户,看看你的发送对象写对了嘛?");
			}
			String submit = ParamUtil.getString(request, "Submit", "");

			if (submit.equals("发送")) {
				sql = "update "
						+ BBSConst.TABLE_MESSAGE
						+ " set incept=?,sender=?,title=?,content=?,sendtime=now(),flag=0,issend=1 where id="
						+ ID;
			} else {
				sql = "update "
						+ BBSConst.TABLE_MESSAGE
						+ " set incept=?,sender=?,title=?,content=?,sendtime=now(),flag=0,issend=0 where id="
						+ ID;
			}
			jw.prepareStatement(sql);
			jw.setString(1, incept);
			jw.setString(2, userName);
			jw.setString(3, title);
			jw.setString(4, message);
			jw.executeUpdate();
		} catch (Exception e) {
			log.error("发送信息出错", e);
			throw e;
		} finally {
			jw.close();
		}
	}
}

⌨️ 快捷键说明

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