📄 infodb.java
字号:
package com.redmoon.forum.plugin.info;
import java.sql.*;
import java.util.*;
import cn.js.fan.base.ObjectDb;
import cn.js.fan.db.Conn;
import cn.js.fan.db.PrimaryKey;
import cn.js.fan.util.*;
import cn.js.fan.web.SkinUtil;
/**
*
* <p>Title: </p>
*
* <p>Description:存放情人路贴子的属性,msgRootId,state等 </p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class InfoDb extends ObjectDb {
public InfoDb() {
super();
}
public InfoDb(long id) {
this.id = id;
init();
load();
}
public boolean del() throws ErrMsgException {
int rowcount = 0;
Conn conn = null;
try {
conn = new Conn(connname);
PreparedStatement ps = conn.prepareStatement(this.QUERY_DEL);
ps.setLong(1, id);
rowcount = conn.executePreUpdate();
} catch (SQLException e) {
logger.error("del:" + e.getMessage());
} finally {
if (conn != null) {
conn.close();
conn = null;
}
}
if (rowcount > 0) {
InfoCache cc = new InfoCache(this);
primaryKey.setValue(new Long(id));
cc.refreshDel(primaryKey);
// 删除其附带的所有的InfoWorthDb
// 删除其所有订单
}
return rowcount>0? true:false;
}
public ObjectDb getObjectRaw(PrimaryKey pk) {
return new InfoDb(pk.getLongValue());
}
public boolean create() throws ErrMsgException, ResKeyException {
int rowcount = 0;
Conn conn = null;
try {
conn = new Conn(connname);
PreparedStatement ps = conn.prepareStatement(this.QUERY_CREATE);
ps.setLong(1, id);
ps.setString(2, typeCode);
ps.setString(3, userName);
ps.setString(4, "" + System.currentTimeMillis());
rowcount = conn.executePreUpdate();
} catch (SQLException e) {
logger.error("create:" + e.getMessage());
throw new ResKeyException(new SkinUtil(), SkinUtil.ERR_DB);
} finally {
if (conn != null) {
conn.close();
conn = null;
}
}
return rowcount>0? true:false;
}
public boolean save() {
int rowcount = 0;
Conn conn = null;
try {
conn = new Conn(connname);
PreparedStatement ps = conn.prepareStatement(this.QUERY_SAVE);
ps.setString(1, typeCode);
ps.setLong(2, id);
rowcount = conn.executePreUpdate();
// logger.info("save:rowcount=" + rowcount);
} catch (SQLException e) {
logger.error("save:" + e.getMessage());
} finally {
InfoCache uc = new InfoCache(this);
primaryKey.setValue(new Long(this.id));
uc.refreshSave(primaryKey);
if (conn != null) {
conn.close();
conn = null;
}
}
return rowcount>0? true:false;
}
private long id;
private String typeCode;
public InfoDb getInfoDb(long id) {
return (InfoDb)getObjectDb(new Long(id));
}
public void load() {
ResultSet rs = null;
Conn conn = new Conn(connname);
try {
PreparedStatement ps = conn.prepareStatement(this.QUERY_LOAD);
ps.setLong(1, id);
primaryKey.setValue(new Long(id));
rs = conn.executePreQuery();
if (rs.next()) {
typeCode = rs.getString(1);
userName = rs.getString(2);
addDate = DateUtil.parse(rs.getString(3));
loaded = true;
}
} catch (SQLException e) {
logger.error("load:" + e.getMessage());
}
finally {
if (conn!=null) {
conn.close();
conn = null;
}
}
}
public Vector list(int start, int end, String userName) {
String sql = "select id from " + this.tableName + " where userName=" + StrUtil.sqlstr(userName) + " order by addDate desc";
return list(sql, start, end);
}
public void setId(long id) {
this.id = id;
}
public long getId() {
return id;
}
public void setTypeCode(String typeCode) {
this.typeCode = typeCode;
}
public String getTypeCode() {
return typeCode;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserName() {
return userName;
}
public String getTypeName() {
InfoConfig ic = new InfoConfig();
return ic.getTypeName(typeCode);
}
public java.util.Date getAddDate() {
return this.addDate;
}
private String userName;
private java.util.Date addDate;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -