package com.yxq.action;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.actions.DispatchAction;
import org.apache.struts.util.LabelValueBean;
import com.yxq.actionform.AbleForm;
import com.yxq.actionform.BoardForm;
import com.yxq.actionform.ClassForm;
import com.yxq.actionform.UserForm;
import com.yxq.dao.OpDB;
import com.yxq.tools.Change;
public class AdminAction extends DispatchAction {
/** 置顶帖子 */
public ActionForward setTopBbs(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
HttpSession session=request.getSession();
session.setAttribute("mainPage","/pages/show/bbs/openRootShow.jsp");
String forwardPath="error";
String bbsId=request.getParameter("bbsId");
if(bbsId!=null&&!bbsId.equals("")){
Date date=new Date();
String today=Change.dateTimeChange(date);
String sql="update tb_bbs set bbs_isTop='1', bbs_toTopTime=? where bbs_id=?";
Object[] params={today,bbsId};
ActionMessages messages=new ActionMessages();
OpDB myOp=new OpDB();
int i=myOp.OpUpdate(sql, params);
if(i<=0){
System.out.println("置顶帖子出错!");
forwardPath="error";
messages.add("userOpR",new ActionMessage("luntan.bbs.top.E"));
}
else{
System.out.println("置顶帖子成功!");
forwardPath="success";
messages.add("userOpR",new ActionMessage("luntan.bbs.top.S"));
}
saveErrors(request,messages);
}
return mapping.findForward(forwardPath);
}
/** 设为精华帖子 */
public ActionForward setGoodBbs(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
String forwardPath="error";
String bbsId=request.getParameter("bbsId");
if(bbsId!=null&&!bbsId.equals("")){
Date date=new Date();
String today=Change.dateTimeChange(date);
String sql="update tb_bbs set bbs_isGood='1', bbs_toTopTime=? where bbs_id=?";
Object[] params={today,bbsId};
ActionMessages messages=new ActionMessages();
OpDB myOp=new OpDB();
int i=myOp.OpUpdate(sql, params);
if(i<=0){
System.out.println("设为精华帖子失败!");
forwardPath="error";
messages.add("userOpR",new ActionMessage("luntan.bbs.good.E"));
}
else{
System.out.println("设为精华帖子成功!");
forwardPath="success";
messages.add("userOpR",new ActionMessage("luntan.bbs.good.S"));
}
saveErrors(request,messages);
}
return mapping.findForward(forwardPath);
}
/** 删除回复帖 */
public ActionForward deleteAnswerBbs(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
String forwardPath="error";
String delbbsId=request.getParameter("delbbsAnswerId");
if(delbbsId!=null&&!delbbsId.equals("")){
String sql="delete from tb_bbsAnswer where bbsAnswer_id=?";
Object[] params={delbbsId};
ActionMessages messages=new ActionMessages();
OpDB myOp=new OpDB();
int i=myOp.OpUpdate(sql, params);
if(i<=0){
System.out.println("删除回复帖失败!");
forwardPath="error";
messages.add("userOpR",new ActionMessage("luntan.bbs.deleteAnswerR.E"));
}
else{
System.out.println("删除回复帖成功!");
forwardPath="success";
messages.add("userOpR",new ActionMessage("luntan.bbs.deleteAnswerR.S"));
}
saveErrors(request,messages);
}
return mapping.findForward(forwardPath);
}
/** 后台-列表查看论坛类别 */
public ActionForward getClassList(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
HttpSession session=request.getSession();
session.setAttribute("backMainPage","../class/classListShow.jsp");
OpDB myOp=new OpDB();
List classList=myOp.OpClassListShow();
session.setAttribute("backClassList",classList);
return mapping.findForward("success");
}
/** 后台-修改论坛类别 */
public ActionForward modifyClass(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
HttpSession session=request.getSession();
session.setAttribute("backMainPage","../class/classModify.jsp");
String forwardPath="";
String classId=request.getParameter("classId");
if(classId==null)
classId="";
OpDB myOp=new OpDB();
ClassForm classForm=(ClassForm)form;
String validate=request.getParameter("validate");
if(validate==null||validate.equals("")||!validate.equals("yes")){
forwardPath="showModifyJSP";
String sql="select * from tb_class where class_id=?";
Object[] params={classId};
ClassForm classSingle=myOp.OpClassSingleShow(sql, params);
classForm.setClassId(classSingle.getClassId());
classForm.setClassName(classSingle.getClassName());
classForm.setClassIntro(classSingle.getClassIntro());
}
else{
ActionMessages messages=new ActionMessages();
classId = classForm.getClassId();
String className=Change.HTMLChange(classForm.getClassName());
String classIntro=Change.HTMLChange(classForm.getClassIntro());
String sql="update tb_class set class_name=?,class_intro=? where class_id=?";
Object[] paramsMo={className,classIntro,classId};
int i=myOp.OpUpdate(sql, paramsMo);
if(i<=0){
System.out.println("更新论坛类别失败!");
forwardPath="error";
messages.add("adminOpR",new ActionMessage("luntan.admin.modify.class.E"));
}
else{
System.out.println("更新论坛类别成功!");
session.setAttribute("backMainPage","../class/classListShow.jsp");
forwardPath="success";
messages.add("adminOpR",new ActionMessage("luntan.admin.modify.class.S"));
}
saveErrors(request,messages);
}
return mapping.findForward(forwardPath);
}
/** 后台-添加论坛类别 */
public ActionForward addClass(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
HttpSession session=request.getSession();
session.setAttribute("backMainPage","../class/classAdd.jsp");
String validate=request.getParameter("validate");
if(validate==null||validate.equals("")||!validate.equals("yes")){
return mapping.findForward("result");
}
else{
ActionMessages messages=new ActionMessages();
ClassForm classForm=(ClassForm)form;
String className=Change.HTMLChange(classForm.getClassName());
String classIntro=Change.HTMLChange(classForm.getClassIntro());
String sql="";
Object[] params=null;
OpDB myOp=new OpDB();
sql="select * from tb_class where class_name=?";
params=new Object[1];
params[0]=className;
if(myOp.OpClassSingleShow(sql, params)!=null){
System.out.println("添加论坛类别-名称:"+className+" 的论坛已经存在!");
messages.add("adminOpR",new ActionMessage("luntan.admin.add.class.exist",className));
}
else{
sql="insert into tb_class values(?,?)";
params=new Object[2];
params[0]=className;
params[1]=classIntro;
int i=myOp.OpUpdate(sql, params);
if(i<=0){
System.out.println("添加论坛类别失败!");
messages.add("adminOpR",new ActionMessage("l
我虽横行却不霸道
- 粉丝: 97
- 资源: 1万+
最新资源
- 11-【其他】17-新员工入职培训管理流程相关表单(总部级).xlsx
- 11-【其他】02-员工培训出勤统计表.xlsx
- 11-【其他】05-新员工入职培训表.xlsx
- 10-【管理系统】02-员工培训管理系统.xlsx
- 10-【管理系统】03-员工培训管理系统.xlsx
- 10-【管理系统】02-员工培训管理系统 (2).xlsx
- 08-【考核管理】12-员工培训考核统计表.xlsx
- 08-【考核管理】09-新入职员工培训成绩考核统计表.xlsx
- 10-【管理系统】01-人力资源员工培训管理系统.xlsx
- 05-【培训签到】07-新员工培训签到表.xlsx
- 06-【培训手册】01-员工培训手册内容清单.xlsx
- 08-【考核管理】08-企业新员工培训成绩统计表.xlsx
- 05-【培训签到】01-人力资源新员工培训签到表.xlsx
- 03-【培训流程】02-新员工入职培训流程.xlsx
- 01-【培训计划】09-新员工入职培训计划表.xlsx
- 01-【培训计划】11-新员工入职培训计划表.xlsx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈