📄 clubtopiclistimpl.java
字号:
StringBuffer hql = new StringBuffer();
hql.append("select count(*) from ClubTopicReItem");
hql.append(" where (topicIsDel=? and topicIsPass=?)");
if(tid>0){
hql.append(" and topicID=");
hql.append(tid);
}
if(!userName.equals("")){
hql.append(" and userName=?");
}
if(searchKey!=null&&!searchKey.equals("")){
searchKey = searchKey.trim();
StringTokenizer st = new StringTokenizer(searchKey, " ");
for(int c=0;st.hasMoreTokens();c++){
if(c==0){
hql.append(" and (topic like ? ");
}else{
hql.append(" or topic like ? ");
}
st.nextToken();
}
hql.append(")");
}
Query query = session.createQuery(hql.toString());
query.setByte(0, topicIsDel);
query.setBoolean(1, topicIsPass);
if(searchKey!=null&&!searchKey.equals("")){
if(!userName.equals("")){
query.setString(2, userName);
StringTokenizer st = new StringTokenizer(searchKey, " ");
for(int c=2;st.hasMoreTokens();c++){
query.setString(c+1, "%"+ st.nextToken() +"%");
}
}else{
StringTokenizer st = new StringTokenizer(searchKey, " ");
for(int c=1;st.hasMoreTokens();c++){
query.setString(c+1, "%"+ st.nextToken() +"%");
}
}
}else{
if(!userName.equals("")){
query.setString(2, userName);
}
}
Iterator it = query.iterate();
Integer results = null;
while(it.hasNext()){
results = (Integer) it.next();
i = results.intValue();
}
}catch(HibernateException e){
}
return i;
}
public void setSearchKey(String searchKey) {
this.searchKey = searchKey;
}
public List topicImportList
(int page, int pageNum, int order, int ccid, int tpro)
{
/* 计算从第几条记录开始读取数据 */
if(page<1)page=1;
int startRow = pageNum * page - pageNum;
int endRow = pageNum;
Session session = ConnClub.getSession();
List list = null;
StringBuffer hql = new StringBuffer();
try{
hql.append("from ClubTopicItem where topicIsDel=0 and topicIsPass=?");
if(ccid>0){
hql.append(" and (ccID="+ ccid +" or ccID2="+ ccid +" or ccID1=" + ccid + ")");
}
if(tpro==1){ //最新精品
hql.append(" and topicPro=1 ");
}
else if(tpro==2){ //推荐话题
hql.append(" and topicOrder>0 ");
}
if(order==1){
hql.append(" order by topicReCount desc, topicViewCount desc");
}
else if(order==2){
hql.append(" order by topicReID desc");
}
else{
hql.append(" order by topicID desc");
}
Query query = session.createQuery(hql.toString());
query.setBoolean(0, true);
query.setFirstResult(startRow);
query.setMaxResults(endRow);
list = query.list();
}catch(Exception e){
}
return list;
}
public List topicAllList(int page, int pageNum, Boolean ispass, String hqlappend)
{
List list = null;
if(page<1){page=1;}
/* 计算从第几条记录开始读取数据 */
int startRow = pageNum * page - pageNum;
int endRow = pageNum;
Session session = ConnClub.getSession();
StringBuffer hql = new StringBuffer();
try{
hql.append("from ClubTopicItem ");
hql.append(" where topicIsDel=");
hql.append(topicIsDel);
if(ccID>0){
hql.append(" and (ccID=");
hql.append(ccID);
hql.append(" or ccID2=");
hql.append(ccID);
hql.append(" or ccID1=");
hql.append(ccID);
hql.append(") ");
}
if(ispass!=null){
hql.append(" and topicIsPass=? ");
}
hql.append(hqlappend);
Query query = session.createQuery(hql.toString());
if(ispass!=null){
query.setBoolean(0, ispass.booleanValue());
}
query.setFirstResult(startRow);
query.setMaxResults(endRow);
list = query.list();
}catch(HibernateException e){
list = null;
}
return list;
}
public int topicAllCount(Boolean ispass, String hqlappend)
{
int i = 0;
Session session = ConnClub.getSession();
StringBuffer hql = new StringBuffer();
try{
hql.append("select count(*) from ClubTopicItem");
hql.append(" where topicIsDel=");
hql.append(topicIsDel);
if(ccID>0){
hql.append(" and (ccID=");
hql.append(ccID);
hql.append(" or ccID2=");
hql.append(ccID);
hql.append(" or ccID1=");
hql.append(ccID);
hql.append(") ");
}
if(ispass!=null){
hql.append(" and topicIsPass=? ");
}
hql.append(hqlappend);
Query query = session.createQuery(hql.toString());
if(ispass!=null){
query.setBoolean(0, ispass.booleanValue());
}
Iterator it = query.iterate();
Integer results = null;
while(it.hasNext()){
results = (Integer) it.next();
i = results.intValue();
}
}catch(HibernateException e){
i = 0;
}
return i;
}
public List topicReAllList(int page, int pageNum, Boolean ispass, String hqlappend)
{
List list = null;
if(page<1){page=1;}
/* 计算从第几条记录开始读取数据 */
int startRow = pageNum * page - pageNum;
int endRow = pageNum;
Session session = ConnClub.getSession();
StringBuffer hql = new StringBuffer();
try{
hql.append("from ClubTopicReItem ");
hql.append(" where topicIsDel=");
hql.append(topicIsDel);
if(ccID>0){
hql.append(" and (ccID=");
hql.append(ccID);
hql.append(" or ccID2=");
hql.append(ccID);
hql.append(" or ccID1=");
hql.append(ccID);
hql.append(") ");
}
if(ispass!=null){
hql.append(" and topicIsPass=?");
}
hql.append(hqlappend);
Query query = session.createQuery(hql.toString());
if(ispass!=null){
query.setBoolean(0, ispass.booleanValue());
}
query.setFirstResult(startRow);
query.setMaxResults(endRow);
list = query.list();
}catch(HibernateException e){
list = null;
}
return list;
}
public int topicReAllCount(Boolean ispass, String hqlappend)
{
int i = 0;
Session session = ConnClub.getSession();
StringBuffer hql = new StringBuffer();
try{
hql.append("select count(*) from ClubTopicReItem");
hql.append(" where topicIsDel=");
hql.append(topicIsDel);
if(ccID>0){
hql.append(" and (ccID=");
hql.append(ccID);
hql.append(" or ccID2=");
hql.append(ccID);
hql.append(" or ccID1=");
hql.append(ccID);
hql.append(") ");
}
if(ispass!=null){
hql.append(" and topicIsPass=?");
}
hql.append(hqlappend);
Query query = session.createQuery(hql.toString());
if(ispass!=null){
query.setBoolean(0, ispass.booleanValue());
}
Iterator it = query.iterate();
Integer results = null;
while(it.hasNext()){
results = (Integer) it.next();
i = results.intValue();
}
}catch(HibernateException e){
i = 0;
}
return i;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -