📄 msgentity.java
字号:
package com.xuntian.material.bean.entity;
import com.xuntian.material.sql.baseinfo.ItemSQL;
import com.xuntian.material.util.DateTools;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.xuntian.material.bean.MsgBean;
import com.xuntian.material.bean.UserBean;
import com.xuntian.material.exception.ConnectPoolException;
public class MsgEntity extends BaseEntity {
private MsgBean item;
public MsgEntity(MsgBean item) {
this.item = item;
}
public MsgBean getMsgBean() {
return item;
}
public List<MsgBean> queryList(int[] itemIDs) throws ConnectPoolException,
SQLException {
List<MsgBean> list = new ArrayList<MsgBean>();
return list;
}
public List<List<String>> queryAll(String itemid)
throws ConnectPoolException {
if(Integer.parseInt(itemid)!=0){
return getDatabase().query("SELECT msg_id,msg_name,item_name,msg_date FROM info_msg a,info_item b where b.item_id=a.item_id and a.item_id="+itemid,null);
}else{
return getDatabase().query("SELECT msg_id,msg_name,item_name,msg_date FROM info_msg a,info_item b where b.item_id=a.item_id ORDER BY msg_id desc",null);
}
}
public List<List<String>> queryAll() throws ConnectPoolException{
return getDatabase().query("SELECT msg_id,msg_name,item_name,msg_date FROM view_msg_list ORDER BY msg_id DESC",null);
}
public void fill() throws ConnectPoolException, SQLException {
String itemID = item.getMsgId();
fill(itemID);
}
private void fill(String itemID) throws ConnectPoolException, SQLException {
List<String> parameterList = new ArrayList<String>();
parameterList.add(itemID);
ResultSet rs = getDatabase().executeQuery("select * from info_msg where 1=1 AND msg_id=?",
parameterList);
if (rs.next()) {
fill(rs);
}
rs.close();
}
private void fill(ResultSet rs) throws SQLException {
item.setMsgId(rs.getString("msg_id"));
item.setMsgName(rs.getString("msg_name"));
item.setMsgContent(rs.getString("msg_content"));
item.setMsgDate(rs.getString("msg_date"));
item.setItemId(rs.getString("item_id"));
}
public int save() throws ConnectPoolException {
List<String> parameterList = new ArrayList<String>();
parameterList.add(item.getMsgName());
parameterList.add(item.getMsgContent());
parameterList.add(item.getMsgDate());
parameterList.add(item.getItemId());
String itemID = item.getMsgId();
if (itemID == null || itemID.equals("")||itemID.length()<1) {
return getDatabase().executeUpdate("insert into info_msg(msg_name,msg_content,msg_date,item_id) values(?,?,?,?)",
parameterList);
} else {
parameterList.add(itemID);
return getDatabase().executeUpdate("update info_msg set msg_name=?,msg_content=?,msg_date=?,item_id=? where msg_id=?",
parameterList);
}
}
public int delete(String[] itemIDs) throws ConnectPoolException {
return getDatabase().executeUpdate(ItemSQL.getDeleteMsg(itemIDs));
}
public List<String> listitem() {
List<String> list = new ArrayList<String>();
try {
ResultSet rs=getDatabase().executeQuery("select * from info_item order by item_id",null);
while(rs.next()){
list.add("/BaseInfoMsg.do?method=list&item_id="+ rs.getString(1)+">"+rs.getString(2)+"</a> | ");
}
//System.out.println(rs.getRow());
rs.close();
} catch (ConnectPoolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -