package com.fh.controller.system.fhsms; import java.io.PrintWriter; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Resource; import org.springframework.beans.propertyeditors.CustomDateEditor; import org.springframework.stereotype.Controller; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; import com.fh.controller.base.BaseController; import com.fh.entity.Page; import com.fh.util.AppUtil; import com.fh.util.DateUtil; import com.fh.util.PageData; import com.fh.util.Jurisdiction; import com.fh.service.system.fhsms.FhsmsManager; /** * 创建时间:2016-01-17 */ @Controller @RequestMapping(value="/fhsms") public class FhsmsController extends BaseController { String menuUrl = "fhsms/list.do"; //菜单地址(权限用) @Resource(name="fhsmsService") private FhsmsManager fhsmsService; /**发送站内信 * @param * @throws Exception */ @RequestMapping(value="/save") @ResponseBody public Object save() throws Exception{ logBefore(logger, Jurisdiction.getUsername()+"发送站内信"); //if(!Jurisdiction.buttonJurisdiction(menuUrl, "add")){return null;} //校验权限(站内信用独立的按钮权限,在此就不必校验新增权限) PageData pd = new PageData(); pd = this.getPageData(); Map map = new HashMap(); List pdList = new ArrayList(); String msg = "ok"; //发送状态 int count = 0; //统计发送成功条数 int zcount = 0; //理论条数 String USERNAME = pd.getString("USERNAME"); //对方用户名 if(null != USERNAME && !"".equals(USERNAME)){ USERNAME = USERNAME.replaceAll(";", ";"); USERNAME = USERNAME.replaceAll(" ", ""); String[] arrUSERNAME = USERNAME.split(";"); zcount = arrUSERNAME.length; try { pd.put("STATUS", "2"); //状态 for(int i=0;i varList = fhsmsService.list(page); //列出Fhsms列表 mv.setViewName("system/fhsms/fhsms_list"); mv.addObject("varList", varList); mv.addObject("pd", pd); mv.addObject("QX",Jurisdiction.getHC()); //按钮权限 return mv; } /**去发站内信界面 * @param * @throws Exception */ @RequestMapping(value="/goAdd") public ModelAndView goAdd()throws Exception{ ModelAndView mv = this.getModelAndView(); PageData pd = new PageData(); pd = this.getPageData(); mv.setViewName("system/fhsms/fhsms_edit"); mv.addObject("msg", "save"); mv.addObject("pd", pd); return mv; } /**去查看页面 * @param * @throws Exception */ @RequestMapping(value="/goView") public ModelAndView goView()throws Exception{ ModelAndView mv = this.getModelAndView(); PageData pd = new PageData(); pd = this.getPageData(); if("1".equals(pd.getString("TYPE")) && "2".equals(pd.getString("STATUS"))){ //在收信箱里面查看未读的站内信时去数据库改变未读状态为已读 fhsmsService.edit(pd); } pd = fhsmsService.findById(pd); //根据ID读取 mv.setViewName("system/fhsms/fhsms_view"); mv.addObject("pd", pd); return mv; } /**批量删除 * @param * @throws Exception */ @RequestMapping(value="/deleteAll") @ResponseBody public Object deleteAll() throws Exception{ logBefore(logger, Jurisdiction.getUsername()+"批量删除Fhsms"); if(!Jurisdiction.buttonJurisdiction(menuUrl, "del")){return null;} //校验权限 PageData pd = new PageData(); Map map = new HashMap(); pd = this.getPageData(); List pdList = new ArrayList(); String DATA_IDS = pd.getString("DATA_IDS"); if(null != DATA_IDS && !"".equals(DATA_IDS)){ String ArrayDATA_IDS[] = DATA_IDS.split(","); fhsmsService.deleteAll(ArrayDATA_IDS); pd.put("msg", "ok"); }else{ pd.put("msg", "no"); } pdList.add(pd); map.put("list", pdList); return AppUtil.returnObject(pd, map); } @InitBinder public void initBinder(WebDataBinder binder){ DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); binder.registerCustomEditor(Date.class, new CustomDateEditor(format,true)); } }