<%@page import="java.util.Calendar"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="webber.vsb.entity.Wbnews"%>
<%@page import="net.sf.json.JSONArray"%>
<%@page import="webber.gshdsb.dao.HdBaseDao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import="net.sf.json.JSONObject"%>
<%@ page import="webber.wbst.com.*"%><%@ page
import="webber.core.StringUtil"%>
<%
String wbstree = request.getParameter("wbstree");
String chineseName = StringUtil.getParameter(request, "chineseName", "");
String actionType = StringUtil.getParameter(request, "actionType", null);
String englishName = StringUtil.getParameter(request, "englishName", null);
String studentTime = StringUtil.getParameter(request, "studentTime", null);
String graduationTime = StringUtil.getParameter(request, "graduationTime", "");
String im = StringUtil.getParameter(request, "im", null);
String chineseAbstract = StringUtil.getParameter(request, "chineseAbstract", null);
String englishAbstract = StringUtil.getParameter(request, "englishAbstract", null);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
int wbnewsid = StringUtil.getParameterInt(request, "wbnewsid", 0);
int countriesName = StringUtil.getParameterInt(request, "countriesName", 0);
Date date = null;
JSONObject json = new JSONObject();
HdBaseDao dao = new HdBaseDao();
if ("save".equals(actionType))
{
JSONArray array = JSONArray.fromObject(wbstree);
for (int i = 0; i < array.size(); i++)
{
Wbnews news = new Wbnews();
news.setWbauthor(chineseName);
news.setWbtitle(englishName);
news.setWbpicurl(im);
news.setOwner(1536097831);
news.setWbdate(format.parse(studentTime));
if ( "".equals(graduationTime))
{
graduationTime= Integer.parseInt(studentTime.substring(0, 4))+2+studentTime.substring(4);
}
news.setWbenddate(format.parse(graduationTime));
news.setWbauditing(1);
news.setWbsummary(chineseAbstract);
news.setWbcontent(englishAbstract);
JSONObject job = array.getJSONObject(i);
news.setWbtreeid(Integer.parseInt(job.get("val").toString()));
dao.save(news);
json.put("info", true);
}
} else if ("edit".equals(actionType))
{
Wbnews news = (Wbnews) dao.getById(Wbnews.class, wbnewsid);
news.setWbauthor(chineseName);
news.setWbtitle(englishName);
news.setWbpicurl(im);
news.setOwner(1536097831);
news.setWbdate(format.parse(studentTime));
if ( "".equals(graduationTime))
{
graduationTime= Integer.parseInt(studentTime.substring(0, 4))+2+studentTime.substring(4);
}
news.setWbenddate(format.parse(graduationTime));
news.setWbauditing(1);
news.setWbsummary(chineseAbstract);
news.setWbcontent(englishAbstract);
news.setWbtreeid(countriesName);
dao.save(news);
json.put("info", true);
} else
{
json.put("info", false);
}
out.print(json.toString());
%>