📄 clubtopicimpl.java
字号:
Session session = ConnClub.getSession();
ClubTopicReItem ctri = null;
ClubContentReItem ccri = null;
try{
Transaction tran = session.beginTransaction();
ctri = new ClubTopicReItem();
ctri.setTopicID(topicID);
ctri.setTopicOrder(topicOrder);
ctri.setTopicLayer(topicLayer);
ctri.setTopicTree(topicTree);
ctri.setTopic(topic);
ctri.setUserName(userName);
ctri.setCcID(ccID);
ctri.setCcID2(ccID2);
ctri.setCcID1(ccID1);
ctri.setTopicList(topicList);
ctri.setTopicMood(topicMood);
ctri.setTopicPro(topicPro);
ctri.setTopicType(topicType);
ctri.setTopicTypeNum(topicTypeNum);
ctri.setTopicAddTime(topicAddTime);
ctri.setTopicAddip(topicAddip);
ctri.setTopicLastReUser(topicLastReUser);
ctri.setTopicLastReTime(topicLastReTime);
ctri.setTopicViewCount(topicViewCount);
ctri.setTopicReCount(topicViewCount);
ctri.setTopicLen(topicLen);
ctri.setUserID(userID);
ctri.setTopicIsPass(topicIsPass);
ctri.setTopicIsDel(topicIsDel);
session.save(ctri);
tran.commit();
this.topicReID = ctri.getTopicReID();
Transaction tran1 = session.beginTransaction();
ClubInfoEdit cie = new ClubInfoEdit();
cie.updateLastReID(this.topicReID);
ccri = new ClubContentReItem();
ccri.setTopicID(topicID);
ccri.setTopicReID(this.topicReID);
ccri.setContent(content);
ccri.setContentCopyRight(contentCopyRight);
ccri.setContentEmail(contentEmail);
ccri.setContentImg(contentImg);
ccri.setContentUrl(contentUrl);
ccri.setContentUserPen(contentUserPen);
session.save(ccri);
tran1.commit();
}catch(HibernateException e){
ctri = null;
e.printStackTrace();
}
return ctri;
}
/**
* 主题表的浏览次数累加
* @param id
* @return
* 2005-11-7 21:00:31 Made In GamVan
* @see com.gamvan.club.dao.ClubTopicDAO#topicReUpdateVcount(int)
*/
public boolean topicUpdateVcount(int id) {
bea = true;
Session session = ConnClub.getSession();
StringBuffer hql = new StringBuffer();
Transaction tran = session.beginTransaction();
try{
hql.append("update ClubTopicItem set ");
hql.append(" topicViewCount=topicViewCount+1");
hql.append(" where topicID=?");
Query query = session.createQuery(hql.toString())
.setInteger(0, id);
query.executeUpdate();
tran.commit();
bea = true;
}catch(Exception e){
bea = false;
e.printStackTrace();
}
return bea;
}
/**
* 回复表的浏览次数累加
* @param id
* @return
* 2005-11-7 21:00:31 Made In GamVan
* @see com.gamvan.club.dao.ClubTopicDAO#topicReUpdateVcount(int)
*/
public boolean topicReUpdateVcount(int id) {
bea = false;
Session session = ConnClub.getSession();
StringBuffer hql = new StringBuffer();
Transaction tran = session.beginTransaction();
try{
hql.append("update ClubTopicReItem set ");
hql.append(" topicViewCount=topicViewCount+1");
hql.append(" where topicReID=?");
Query query = session.createQuery(hql.toString())
.setInteger(0, id)
;
query.executeUpdate();
tran.commit();
bea = true;
}catch(Exception e){
e.printStackTrace();
}
return bea;
}
/**
* 主题表的回复次数累加
* @param id
* @return
* 2005-11-7 20:59:44 Made In GamVan
* @see com.gamvan.club.dao.ClubTopicDAO#topicUpdateRcount(int)
*/
public boolean topicUpdateRcount(int id) {
bea = true;
Session session = ConnClub.getSession();
StringBuffer hql = new StringBuffer();
Transaction tran = session.beginTransaction();
try{
hql.append("update ClubTopicItem set ");
hql.append(" topicReCount=topicReCount+1");
hql.append(" where topicID=?");
Query query = session.createQuery(hql.toString())
.setInteger(0, id)
;
query.executeUpdate();
tran.commit();
}catch(Exception e){
bea = false;
e.printStackTrace();
}
return bea;
}
/**
* 回复表主题的回复次数累加
* @param id
* @return
* 2005-11-7 20:59:13 Made In GamVan
* @see com.gamvan.club.dao.ClubTopicDAO#topicReUpdateRcount(int)
*/
public boolean topicReUpdateRcount(int id) {
bea = false;
Session session = ConnClub.getSession();
StringBuffer hql = new StringBuffer();
Transaction tran = session.beginTransaction();
try{
hql.append("update ClubTopicReItem set ");
hql.append(" topicReCount=topicReCount+1");
hql.append(" where topicReID=?");
Query query = session.createQuery(hql.toString())
.setInteger(0, id);
query.executeUpdate();
session.flush();
tran.commit();
bea = true;
}catch(Exception e){
e.printStackTrace();
}
return bea;
}
/**
* 主题表的主题
* @param id
* @return
* 2005-11-7 20:59:02 Made In GamVan
* @see com.gamvan.club.dao.ClubTopicDAO#topicInfo(int)
*/
public ClubTopicItem topicInfo(int id) {
ClubTopicItem cti = null;
Session session = ConnClub.getSession();
try{
String hql = "from ClubTopicItem where topicID=?";
Query query = session.createQuery(hql);
query.setInteger(0, id);
cti = (ClubTopicItem)query.uniqueResult();
}catch(HibernateException e){
cti = null;
e.printStackTrace();
}
return cti;
}
/**
* 回复表的主题
* @param id
* @return
* 2005-11-7 20:58:40 Made In GamVan
* @see com.gamvan.club.dao.ClubTopicDAO#topicReInfo(int)
*/
public ClubTopicReItem topicReInfo(int id) {
ClubTopicReItem ctri = null;
Session session = ConnClub.getSession();
try{
String hql = "from ClubTopicReItem where topicReID=?";
Query query = session.createQuery(hql);
query.setInteger(0, id);
ctri = (ClubTopicReItem)query.uniqueResult();
}catch(HibernateException e){
ctri = null;
e.printStackTrace();
}
return ctri;
}
/**
* 依据reid是否为0判断回复的是主题还是回复从而更新回复主题表内的相关回复的排序
* 如果reid为0则回复内容为主题 给以主题是id相关回复的topicOrder字段累加1
* 否则只给topicOrder字段大于order的相关回复的 topicOrder字段累加1
* @param id 所回复的帖子的主题ID号 <主键>
* @param reid 所回复的回复帖子的ID号 <主键>
* @param order
* 2005-11-7 20:57:30 Made In GamVan
* @see com.gamvan.club.dao.ClubTopicDAO#topicReUpdateOrder(int, int, int)
*/
public void topicReUpdateOrder(int id, int reid, int order) {
Session session = ConnClub.getSession();
Transaction tran = session.beginTransaction();
StringBuffer hql = new StringBuffer();
try{
hql.append("update ClubTopicReItem set topicOrder=topicOrder+1 ");
if(reid==0){
hql.append(" where topicID="+ id +" ");
}else{
hql.append(" where topicID="+ id +" and topicOrder > "+ order +"");
}
Query query = session.createQuery(hql.toString()) ;
query.executeUpdate();
session.flush();
tran.commit();
}catch(Exception e){
}
}
/**
* 更新帖子类型 目前主要用于结贴
* @param id
* @param type
* 2005-11-13 22:18:04 Made In GamVan
* @see com.gamvan.club.dao.ClubTopicDAO#topicTypeUpdate(int, short)
*/
public void topicTypeUpdate(int id, short type) {
Session session = ConnClub.getSession();
Transaction tran = session.beginTransaction();
StringBuffer hql = new StringBuffer();
try{
hql.append("update ClubTopicItem ");
hql.append(" set topicType=? ");
hql.append(" where topicID=?");
Query query = session.createQuery(hql.toString());
query.setShort(0, type);
query.setInteger(1, id);
query.executeUpdate();
session.flush();
tran.commit();
}catch(Exception e){
logger.error(e.toString());
e.printStackTrace();
}
}
/**
* 移动帖子
* @param tid 帖子
* @param moveccid 目标版面ID
* @param ccid1 版面ID
* @param ccid2 版面ID
* @param byuser 操作人员
* @param movetime 移动时间
* @param savelink 判断送是否在原来的版面保留链接
* 2005-12-1 1:36:42 Made In GamVan
* @see com.gamvan.club.dao.ClubTopicDAO#topicMove(int, int, int, int, java.lang.String, java.lang.String, java.lang.String)
*/
public void topicMove(int tid, int moveccid
, int ccid1, int ccid2
, String byuser, String movetime
, String savelink )
{
Session session = ConnClub.getSession();
Transaction tran = session.beginTransaction();
StringBuffer hql = new StringBuffer("");
try{
hql.append("update ClubTopicItem set ccID=?, ccID2=?");
hql.append(", ccID1=?");
if(savelink.equals("1")){
hql.append(", moveCCID=ccID");
}else{
hql.append(", moveCCID=0");
}
hql.append(", moveUser=?");
hql.append(", moveTime=?");
hql.append(" where topicID=?");
Query query = session.createQuery(hql.toString());
query.setInteger(0, moveccid);
query.setInteger(1, ccid2);
query.setInteger(2, ccid1);
query.setString(3, byuser);
query.setString(4, movetime);
query.setInteger(5, tid);
query.executeUpdate();
tran.commit();
}catch(HibernateException e){
logger.error(e.toString());
e.printStackTrace();
}
}
/**
* 对主题表单独字段进行更新
* @param tid
* @param field 字段名
* @param num
* 2005-12-1 1:56:14 Made In GamVan
* @see com.gamvan.club.dao.ClubTopicDAO#topicFieldUpdate(int, java.lang.String, int)
*/
public void topicFieldUpdate(String where, String field, int num) {
Session session = ConnClub.getSession();
Transaction tran = session.beginTransaction();
StringBuffer hql = new StringBuffer("");
try{
hql.append("update ClubTopicItem set ");
hql.append(field);
hql.append("=? ");
hql.append(where);
Query query = session.createQuery(hql.toString())
.setInteger(0, num);
query.executeUpdate();
tran.commit();
}catch(HibernateException e){
logger.error(e.toString());
}
}
/**
* 对回复表单独字段进行更新
* @param reid
* @param field 字段名
* @param num
* 2005-12-1 1:56:46 Made In GamVan
* @see com.gamvan.club.dao.ClubTopicDAO#topicFieldUpdate_re(int, java.lang.String, int)
*/
public void topicFieldUpdate_re(String where, String field, int num) {
Session session = ConnClub.getSession();
Transaction tran = session.beginTransaction();
StringBuffer hql = new StringBuffer("");
try{
hql.append("update ClubTopicReItem set ");
hql.append(field);
hql.append("=?");
hql.append(where);
Query query = session.createQuery(hql.toString())
.setInteger(0, num);
query.executeUpdate();
tran.commit();
}catch(HibernateException e){
logger.error(e.toString());
}
}
/**
* 逻辑删除主题
* @param id
* @param isdel
* 2005-12-12 4:41:57 Made In GamVan
* @see com.gamvan.club.dao.ClubTopicDAO#topicIsDelUpdate(int, byte)
*/
public void topicIsDelUpdate(int id, byte isdel){
Session session = ConnClub.getSession();
Transaction tran = session.beginTransaction();
StringBuffer hql = new StringBuffer("");
try{
hql.append("update ClubTopicItem set topicIsDel=? ");
hql.append(" where topicID=?");
Query query = session.createQuery(hql.toString())
.setByte(0, isdel)
.setInteger(1, id);
query.executeUpdate();
tran.commit();
}catch(HibernateException e){
e.printStackTrace();
}
}
/**
* 逻辑删除主题
* @param id
* @param isdel
* 2005-12-12 4:41:57 Made In GamVan
* @see com.gamvan.club.dao.ClubTopicDAO#topicIsDelUpdate(int, byte)
*/
public void topicIsDelUpdate_re(int reid, byte isdel){
Session session = ConnClub.getSession();
Transaction tran = session.beginTransaction();
StringBuffer hql = new StringBuffer("");
try{
hql.append("update ClubTopicReItem set topicIsDel=? ");
hql.append(" where topicReID=?");
Query query = session.createQuery(hql.toString())
.setByte(0, isdel)
.setInteger(1, reid);
query.executeUpdate();
tran.commit();
}catch(HibernateException e){
e.printStackTrace();
}
}
/* test
public static void main(String args[]){
ConnClub.init();
ClubTopicImpl ctim = new ClubTopicImpl();
ctim.topicID_reID(8282);
ClubInfo ci = new ClubInfo();
int lastReID = ci.getLastReID();
System.out.println(lastReID);
ConnClub.closeSession2();
}
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -