getnewsaction.java
来自「基于JAVA的学生就业信息网 实现对信息浏览 检索 审核 修改和删除」· Java 代码 · 共 134 行
JAVA
134 行
/*
* Created on 2005-7-2
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.ug.sztz.webview.structs.actions;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.ug.sztz.domain.assistant.DateProcessor;
import org.ug.sztz.domain.assistant.SchoolFactory;
import org.ug.sztz.domain.oa.DanWeiInfo;
import org.ug.sztz.domain.oa.NewsEntity;
import org.ug.sztz.domain.oa.Sort;
import org.ug.sztz.domain.oa.ZPHInfo;
/**
* @author 桂训龙
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class GetNewsAction extends BaseAction{
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
List sortlist=sortDao.getSortList();//栏目列表
int jysortid=0;
for(int i=0;i<sortlist.size();i++){
Sort sort=(Sort)sortlist.get(i);
if((sort.getSortname()).trim().equals("就业新闻")) {
jysortid=sort.getId();
break;
}
}
HashMap map=new HashMap();
map.put("sort",String.valueOf(jysortid));
map.put("newsstatus","1");
map.put("newsdate","newsdate");
List jynewslist=this.newsDao.getNewsListByFatherSort(map,0,4);//取得新业新闻列表
for(int i=0;i<jynewslist.size();i++){
NewsEntity news=(NewsEntity)jynewslist.get(i);
news.setNewsdate(news.getNewsdate().substring(0,10));
}
map.put("type","8");
List gglist=this.newsDao.getNewsListByType(map,0,4);//取得公告列表
map.put("dwstatus","1");
List dwlist=this.dwxxDao.getDanWeiInfoList(map,0,4);
for(int i=0;i<dwlist.size();i++){
DanWeiInfo dw=(DanWeiInfo)dwlist.get(i);
dw.setDwdate(dw.getDwdate().substring(0,10));
}
map.put("zphstatus","1");
List zphlist=this.zphxxDao.getZPHInfoList(map,0,4);
for(int i=0;i<zphlist.size();i++){
ZPHInfo zph=(ZPHInfo)zphlist.get(i);
Date nowdate=new Date();
SimpleDateFormat dateformat=new SimpleDateFormat("yyyy-MM-dd");
dateformat.setLenient(false);
String sdate=zph.getZphdate();
Date zphdate=dateformat.parse(sdate);
if(nowdate.after(zphdate)) {//如果招聘会已过
zph.setZphbz("@");//用单位名称作标记表示招聘会时间已过
}
zph.setZphfbdate(zph.getZphfbdate().substring(0,10));
}
request.setAttribute("sortlist",sortlist);
request.setAttribute("jynewslist",jynewslist);
request.setAttribute("gglist",gglist);
request.setAttribute("dwlist",dwlist);
request.setAttribute("zphlist",zphlist);
//以下是取得新闻action部分
String id=request.getParameter("id");
NewsEntity shownews=this.newsDao.getNewsById(id);
request.setAttribute("news",shownews);
Sort sort=this.sortDao.getSortById(String.valueOf(shownews.getSort()));
request.setAttribute("sort",sort);
HashMap map2=new HashMap();
map2.put("newstatus","1");
map2.put("newsdj","newsdj");
List rmnews=null;
if(sort!=null){
map2.put("sort",String.valueOf(sort.getId()));
rmnews=this.newsDao.getNewsListBySort(map2,0,5);
}else{
map2.put("type",String.valueOf(shownews.getType()));
rmnews=this.newsDao.getNewsListByType(map2,0,5);
int type=shownews.getType();
sort=new Sort();
sort.setId(250);
switch(type){
case 2:sort.setSortname("首要新闻");break;
case 3:sort.setSortname("基层就业专题");break;
case 4:sort.setSortname("往届毕业生专题");break;
case 5:sort.setSortname("企业风彩");break;
case 6:sort.setSortname("区域就业");break;
case 7:sort.setSortname("视频服务");break;
default:sort.setSortname("公告区");break;
}
request.setAttribute("sort",sort);
}
this.newsDao.updateNewsDJ(String.valueOf(id));
request.setAttribute("rmnews",rmnews);
return mapping.findForward("success");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?