首页>代码>全站功能最佳UI体验最好的一套基于SpringMVC+Spring+Mybatis的商户管理系统,值得学习!>/FHSHGL/src/com/fh/controller/erp/customerimg/CustomerImgController.java
package com.fh.controller.erp.customerimg;
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.ObjectExcelView;
import com.fh.util.PageData;
import com.fh.util.Jurisdiction;
import com.fh.util.Tools;
import com.fh.service.erp.customerimg.CustomerImgManager;
/**
* 说明:客户跟踪描述
* 创建人:
* 创建时间:2017-03-04
*/
@Controller
@RequestMapping(value="/customerimg")
public class CustomerImgController extends BaseController {
String menuUrl = "customerimg/list.do"; //菜单地址(权限用)
@Resource(name="customerimgService")
private CustomerImgManager customerimgService;
/**保存
* @param
* @throws Exception
*/
@RequestMapping(value="/save")
public ModelAndView save() throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"新增CustomerImg");
if(!Jurisdiction.buttonJurisdiction(menuUrl, "add")){return null;} //校验权限
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
pd.put("CUSTOMERIMG_ID", this.get32UUID()); //主键
pd.put("CTIME", Tools.date2Str(new Date())); //记录日期
customerimgService.save(pd);
mv.addObject("msg","success");
mv.setViewName("save_result");
return mv;
}
/**删除
* @param out
* @throws Exception
*/
@RequestMapping(value="/delete")
public void delete(PrintWriter out) throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"删除CustomerImg");
if(!Jurisdiction.buttonJurisdiction(menuUrl, "del")){return;} //校验权限
PageData pd = new PageData();
pd = this.getPageData();
customerimgService.delete(pd);
out.write("success");
out.close();
}
/**修改
* @param
* @throws Exception
*/
@RequestMapping(value="/edit")
public ModelAndView edit() throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"修改CustomerImg");
if(!Jurisdiction.buttonJurisdiction(menuUrl, "edit")){return null;} //校验权限
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
customerimgService.edit(pd);
mv.addObject("msg","success");
mv.setViewName("save_result");
return mv;
}
/**列表
* @param page
* @throws Exception
*/
@RequestMapping(value="/list")
public ModelAndView list(Page page) throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"列表CustomerImg");
//if(!Jurisdiction.buttonJurisdiction(menuUrl, "cha")){return null;} //校验权限(无权查看时页面会有提示,如果不注释掉这句代码就无法进入列表页面,所以根据情况是否加入本句代码)
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
String keywords = pd.getString("keywords"); //关键词检索条件
if(null != keywords && !"".equals(keywords)){
pd.put("keywords", keywords.trim());
}
page.setPd(pd);
List<PageData> varList = customerimgService.list(page); //列出CustomerImg列表
mv.setViewName("erp/customerimg/customerimg_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("erp/customerimg/customerimg_edit");
mv.addObject("msg", "save");
mv.addObject("pd", pd);
return mv;
}
/**去修改页面
* @param
* @throws Exception
*/
@RequestMapping(value="/goEdit")
public ModelAndView goEdit()throws Exception{
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
pd = customerimgService.findById(pd); //根据ID读取
mv.setViewName("erp/customerimg/customerimg_edit");
mv.addObject("msg", "edit");
mv.addObject("pd", pd);
return mv;
}
/**查看详情
* @param
* @throws Exception
*/
@RequestMapping(value="/viewC")
public ModelAndView viewC()throws Exception{
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
pd = customerimgService.findById(pd); //根据ID读取
mv.setViewName("erp/customerimg/customerimg_view");
mv.addObject("msg", "edit");
mv.addObject("pd", pd);
return mv;
}
/**批量删除
* @param
* @throws Exception
*/
@RequestMapping(value="/deleteAll")
@ResponseBody
public Object deleteAll() throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"批量删除CustomerImg");
if(!Jurisdiction.buttonJurisdiction(menuUrl, "del")){return null;} //校验权限
PageData pd = new PageData();
Map<String,Object> map = new HashMap<String,Object>();
pd = this.getPageData();
List<PageData> pdList = new ArrayList<PageData>();
String DATA_IDS = pd.getString("DATA_IDS");
if(null != DATA_IDS && !"".equals(DATA_IDS)){
String ArrayDATA_IDS[] = DATA_IDS.split(",");
customerimgService.deleteAll(ArrayDATA_IDS);
pd.put("msg", "ok");
}else{
pd.put("msg", "no");
}
pdList.add(pd);
map.put("list", pdList);
return AppUtil.returnObject(pd, map);
}
/**导出到excel
* @param
* @throws Exception
*/
@RequestMapping(value="/excel")
public ModelAndView exportExcel() throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"导出CustomerImg到excel");
if(!Jurisdiction.buttonJurisdiction(menuUrl, "cha")){return null;}
ModelAndView mv = new ModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
Map<String,Object> dataMap = new HashMap<String,Object>();
List<String> titles = new ArrayList<String>();
titles.add("描述"); //1
titles.add("记录日期"); //2
titles.add("商户ID"); //3
dataMap.put("titles", titles);
List<PageData> varOList = customerimgService.listAll(pd);
List<PageData> varList = new ArrayList<PageData>();
for(int i=0;i<varOList.size();i++){
PageData vpd = new PageData();
vpd.put("var1", varOList.get(i).getString("CDESCRIPTION")); //1
vpd.put("var2", varOList.get(i).getString("CTIME")); //2
vpd.put("var3", varOList.get(i).getString("CUSTOMER_ID")); //3
varList.add(vpd);
}
dataMap.put("varList", varList);
ObjectExcelView erv = new ObjectExcelView();
mv = new ModelAndView(erv,dataMap);
return mv;
}
@InitBinder
public void initBinder(WebDataBinder binder){
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
binder.registerCustomEditor(Date.class, new CustomDateEditor(format,true));
}
}
最近下载更多
最近浏览更多
dddding yang LV6
9月15日
hrbylw LV9
8月9日
user100
6月10日
暂无贡献等级
chengguo123
4月2日
暂无贡献等级
天空java LV8
3月23日
哪里的完整版 LV8
3月1日
微信网友_7371218154688512 LV4
2月5日
xiaoaitx LV8
1月1日
yimaoermao LV1
2024年11月28日
TY0165 LV20
2024年6月20日

