topictypeoperimp.java
来自「jaguey,网上的一个朋友给我的」· Java 代码 · 共 110 行
JAVA
110 行
package net.javapassion.jaguey.service.imp;
import java.util.List;
import java.util.Iterator;
import net.javapassion.jaguey.core.Log;
import net.javapassion.jaguey.domain.TopicType;
import net.javapassion.jaguey.dao.TopicTypeDao;
import net.javapassion.jaguey.service.TopicTypeOper;
//版本: JagueyBBS 1.1
//功能: 论坛主题帖子类型业务逻辑实现
//作者: 赵程佳
//时间: 2006-02-13 15:15:08
public class TopicTypeOperImp implements TopicTypeOper {
private TopicTypeDao topicTypeDao;
//保存主题帖子类型
public String saveTopicType(TopicType topicType) {
try {
this.topicTypeDao.saveTopicType(topicType);
return "success";
} catch (Exception ex) {
Log.error(ex.getMessage(), ex);
return "failed";
}
}
//删除主题帖子类型
public String deleteTopicType(String topicTypeId) {
try {
TopicType topicType = this.topicTypeDao.getTopicTypeById(topicTypeId);
if (topicType != null) {
this.topicTypeDao.deleteTopicType(topicType);
return "success";
} else {
return "can't find data";
}
} catch (Exception ex) {
Log.error(ex.getMessage(), ex);
return "failed";
}
}
//获取全部主题帖子类型
public List getTopicTypes() {
try {
return this.topicTypeDao.getTopicTypes();
} catch (Exception ex) {
Log.error(ex.getMessage(), ex);
return null;
}
}
//通过编号获取主题帖子类型
public TopicType getTopicTypeById(String topicTypeId) {
try {
TopicType topicType = this.topicTypeDao.getTopicTypeById(topicTypeId);
if (topicType != null) {
return topicType;
} else {
Log.warn("Use topicTypeId can't find TopicType!");
return null;
}
} catch (Exception ex) {
Log.error(ex.getMessage(), ex);
return null;
}
}
//创建主题帖子类型编号
public String makeTopicTypeId() {
String typeId = "";
try {
List list = this.topicTypeDao.getTopicTypes();
if (list.size() == 0) {
return "01";
} else {
Iterator it = list.iterator();
int i = 1;
while (it.hasNext()) {
if (i == list.size()) {
TopicType topicType = (TopicType) it.next();
typeId = String.valueOf(Integer.parseInt(topicType.getTopicTypeId()) + 1);
if (Integer.parseInt(typeId) != 100) {
if (typeId.length() == 1) {
typeId = "0" + typeId;
}
} else {
Log.info("The typeId have already exceed to allow max quantity!");
typeId = "00";
}
} else {
i++;
continue;
}
}
return typeId;
}
} catch (Exception ex) {
Log.error(ex.getMessage(), ex);
return "";
}
}
public void setTopicTypeDao(TopicTypeDao topicTypeDao) {
this.topicTypeDao = topicTypeDao;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?