notemessoperimp.java
来自「jaguey,网上的一个朋友给我的」· Java 代码 · 共 114 行
JAVA
114 行
package net.javapassion.jaguey.service.imp;
import java.util.List;
import java.util.Date;
import java.util.Iterator;
import net.javapassion.jaguey.core.Log;
import net.javapassion.jaguey.util.DateUtil;
import net.javapassion.jaguey.domain.NoteMess;
import net.javapassion.jaguey.dao.NoteMessDao;
import net.javapassion.jaguey.service.NoteMessOper;
//版本: JagueyBBS 1.1
//功能: 论坛发布信息业务逻辑实现
//作者: 赵程佳
//时间: 2006-02-10 16:55:13
public class NoteMessOperImp implements NoteMessOper {
private NoteMessDao noteMessDao;
//保存发布信息
public String saveNoteMess(NoteMess noteMess) {
try {
this.noteMessDao.saveNoteMess(noteMess);
return "success";
} catch (Exception ex) {
Log.error(ex.getMessage(), ex);
return "failed";
}
}
//删除发布信息
public String deleteNoteMess(String mesId) {
try {
NoteMess noteMess = this.noteMessDao.getNoteMessById(mesId);
if (noteMess != null) {
this.noteMessDao.deleteNoteMess(noteMess);
return "success";
} else {
return "can't find data";
}
} catch (Exception ex) {
Log.error(ex.getMessage(), ex);
return "failed";
}
}
//获取全部发布信息
public List getNoteMesses() {
try {
return this.noteMessDao.getNoteMesses();
} catch (Exception ex) {
Log.error(ex.getMessage(), ex);
return null;
}
}
//通过编号获取发布信息
public NoteMess getNoteMessById(String mesId) {
try {
NoteMess noteMess = this.noteMessDao.getNoteMessById(mesId);
if (noteMess != null) {
return noteMess;
} else {
Log.warn("Use mesId can't find NoteMess!");
return null;
}
} catch (Exception ex) {
Log.error(ex.getMessage(), ex);
return null;
}
}
//创建发布信息编号
public String makeMessId() {
String messId = "";
try {
List list = this.noteMessDao.getNoteMessByLikeId(DateUtil.formatDate7(new Date()));
if (list.size() == 0) {
return DateUtil.formatDate7(new Date()) + "0001";
} else {
Iterator it = list.iterator();
int i = 1;
while (it.hasNext()) {
if (i == list.size()) {
NoteMess noteMess = (NoteMess) it.next();
messId = String.valueOf(Integer.parseInt(noteMess.getMesId().substring(6)) + 1);
if (Integer.parseInt(messId) != 10000) {
switch (messId.length()) {
case 1 : messId = "000" + messId; break;
case 2 : messId = "00" + messId; break;
case 3 : messId = "0" + messId; break;
}
} else {
Log.info("The messId have already exceed to allow max quantity!");
messId = "0000";
}
} else {
i++;
continue;
}
}
return DateUtil.formatDate7(new Date()) + messId;
}
} catch (Exception ex) {
Log.error(ex.getMessage(), ex);
return "";
}
}
public void setNoteMessDao(NoteMessDao noteMessDao) {
this.noteMessDao = noteMessDao;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?