package com.controller;
import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.io.PrintWriter;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import com.entity.Chuchaxinxi;
import com.server.ChuchaxinxiServer;
import com.util.PageBean;
import net.sf.json.JSONObject;
import com.util.db;
import java.sql.SQLException;
import java.sql.*;
@Controller
public class ChuchaxinxiController {
@Resource
private ChuchaxinxiServer chuchaxinxiService;
@RequestMapping("addChuchaxinxi.do")
public String addChuchaxinxi(HttpServletRequest request,Chuchaxinxi chuchaxinxi,HttpSession session) throws SQLException{
Timestamp time=new Timestamp(System.currentTimeMillis());
chuchaxinxi.setAddtime(time.toString().substring(0, 19));
chuchaxinxiService.add(chuchaxinxi);
db dbo = new db();
//kuabiaogaizhi
session.setAttribute("backxx", "添加成功");session.setAttribute("backurl", request.getHeader("Referer"));return "redirect:postback.jsp";
}
@RequestMapping("addChuchaxinxiqt.do")
public String addChuchaxinxiqt(HttpServletRequest request,Chuchaxinxi chuchaxinxi,HttpSession session) throws SQLException{
Timestamp time=new Timestamp(System.currentTimeMillis());
chuchaxinxi.setAddtime(time.toString().substring(0, 19));
chuchaxinxiService.add(chuchaxinxi);
db dbo = new db();
//kuabiaogaizhi
session.setAttribute("backxx", "添加成功");
session.setAttribute("backurl", request.getHeader("Referer"));
return "redirect:postback.jsp";
}
// 处理编辑
@RequestMapping("doUpdateChuchaxinxi.do")
public String doUpdateChuchaxinxi(int id,ModelMap map,Chuchaxinxi chuchaxinxi){
chuchaxinxi=chuchaxinxiService.getById(id);
map.put("chuchaxinxi", chuchaxinxi);
return "chuchaxinxi_updt";
}
@RequestMapping("doUpdateChuchaxinxilb.do")
public String doUpdateChuchaxinxilb(int id,ModelMap map,Chuchaxinxi chuchaxinxi){
chuchaxinxi=chuchaxinxiService.getById(id);
map.put("chuchaxinxi", chuchaxinxi);
return "chuchaxinxi_updtlb";
}
@RequestMapping("updateChuchaxinxilb.do")
public String updateChuchaxinxilb(int id,ModelMap map,Chuchaxinxi chuchaxinxi){
chuchaxinxiService.updatelb(chuchaxinxi);
return "redirect:chuchaxinxiList.do";
}
// 后台详细
@RequestMapping("chuchaxinxiDetail.do")
public String chuchaxinxiDetail(int id,ModelMap map,Chuchaxinxi chuchaxinxi){
chuchaxinxi=chuchaxinxiService.getById(id);
map.put("chuchaxinxi", chuchaxinxi);
return "chuchaxinxi_detail";
}
// 前台详细
@RequestMapping("ccxxDetail.do")
public String ccxxDetail(int id,ModelMap map,Chuchaxinxi chuchaxinxi){
chuchaxinxi=chuchaxinxiService.getById(id);
map.put("chuchaxinxi", chuchaxinxi);
return "chuchaxinxidetail";
}
//
@RequestMapping("updateChuchaxinxi.do")
public String updateChuchaxinxi(int id,ModelMap map,Chuchaxinxi chuchaxinxi,HttpServletRequest request,HttpSession session){
chuchaxinxiService.update(chuchaxinxi);
session.setAttribute("backxx", "修改成功");session.setAttribute("backurl", request.getHeader("Referer"));return "redirect:postback.jsp";
}
// 分页查询
@RequestMapping("chuchaxinxiList.do")
public String chuchaxinxiList(@RequestParam(value="page",required=false)String page,
ModelMap map,HttpSession session,Chuchaxinxi chuchaxinxi, String danhao, String biaoti, String chuchaxingzhi, String chuchariqi1,String chuchariqi2, String yujitianshu1,String yujitianshu2, String chuchadidian, String xiangmu, String hezuofang, String chuxingfangshi, String neirong, String gonghao, String xingming, String bumen, String dianhua, String shenpiyijian, String shenpiren, String CEOshenpi, String yijian, String issh){
if(page==null||page.equals("")){
page="1";
}
PageBean pageBean=new PageBean(Integer.parseInt(page), 8);
Map<String, Object> pmap=new HashMap<String,Object>();
pmap.put("pageno", pageBean.getStart());
pmap.put("pageSize", 8);
if(danhao==null||danhao.equals("")){pmap.put("danhao", null);}else{pmap.put("danhao", danhao);}
if(biaoti==null||biaoti.equals("")){pmap.put("biaoti", null);}else{pmap.put("biaoti", biaoti);}
if(chuchaxingzhi==null||chuchaxingzhi.equals("")){pmap.put("chuchaxingzhi", null);}else{pmap.put("chuchaxingzhi", chuchaxingzhi);}
if(chuchariqi1==null||chuchariqi1.equals("")){pmap.put("chuchariqi1", null);}else{pmap.put("chuchariqi1", chuchariqi1);}
if(chuchariqi2==null||chuchariqi2.equals("")){pmap.put("chuchariqi2", null);}else{pmap.put("chuchariqi2", chuchariqi2);}
if(yujitianshu1==null||yujitianshu1.equals("")){pmap.put("yujitianshu1", null);}else{pmap.put("yujitianshu1", yujitianshu1);}
if(yujitianshu2==null||yujitianshu2.equals("")){pmap.put("yujitianshu2", null);}else{pmap.put("yujitianshu2", yujitianshu2);}
if(chuchadidian==null||chuchadidian.equals("")){pmap.put("chuchadidian", null);}else{pmap.put("chuchadidian", chuchadidian);}
if(xiangmu==null||xiangmu.equals("")){pmap.put("xiangmu", null);}else{pmap.put("xiangmu", xiangmu);}
if(hezuofang==null||hezuofang.equals("")){pmap.put("hezuofang", null);}else{pmap.put("hezuofang", hezuofang);}
if(chuxingfangshi==null||chuxingfangshi.equals("")){pmap.put("chuxingfangshi", null);}else{pmap.put("chuxingfangshi", chuxingfangshi);}
if(neirong==null||neirong.equals("")){pmap.put("neirong", null);}else{pmap.put("neirong", neirong);}
if(gonghao==null||gonghao.equals("")){pmap.put("gonghao", null);}else{pmap.put("gonghao", gonghao);}
if(xingming==null||xingming.equals("")){pmap.put("xingming", null);}else{pmap.put("xingming", xingming);}
if(bumen==null||bumen.equals("")){pmap.put("bumen", null);}else{pmap.put("bumen", bumen);}
if(dianhua==null||dianhua.equals("")){pmap.put("dianhua", null);}else{pmap.put("dianhua", dianhua);}
if(shenpiyijian==null||shenpiyijian.equals("")){pmap.put("shenpiyijian", null);}else{pmap.put("shenpiyijian", shenpiyijian);}
if(shenpiren==null||shenpiren.equals("")){pmap.put("shenpiren", null);}else{pmap.put("shenpiren", shenpiren);}
if(CEOshenpi==null||CEOshenpi.equals("")){pmap.put("CEOshenpi", null);}else{pmap.put("CEOshenpi", CEOshenpi);}
if(yijian==null||yijian.equals("")){pmap.put("yijian", null);}else{pmap.put("yijian", yijian);}
int total=chuchaxinxiService.getCount(pmap);
pageBean.setTotal(total);
List<Chuchaxinxi> list=chuchaxinxiService.getByPage(pmap);
map.put("page", pageBean);
map.put("list", list);
session.setAttribute("p", 1);
return "chuchaxinxi_list";
}
@RequestMapping("chuchaxinxiList2.do")
public String chuchaxinxiList2(@RequestParam(value="page",required=false)String page,
ModelMap map,HttpSession session,Chuchaxinxi chuchaxinxi, String danhao, String biaoti, String chuchaxingzhi, String chuchariqi1,String chuchariqi2, String yujitianshu1,String yujitianshu2, String chuchadidian, String xiangmu, String hezuofang, String chuxingfangshi, String neirong, String gonghao, String xingming, String bumen, String dianhua, String shenpiyijian, String shenpiren, String CEOshenpi, String yijian, String issh,HttpServletRequest request){
/*if(session.getAttribute("user")==null){
return "login";
}*/
if(page==null||page.equals("")){
page="1";
}
PageBean pageBean=new PageBean(Integer.parseInt(page), 15);
Map<String, Object> pmap=new HashMap<String,Object>();
pmap.put("pageno", pageBean.getStart());
pmap.put("pageSize", 15);
pmap.put(