package cn.pluss.platform.controller.wxBankCode;

import cn.pluss.platform.controller.BaseNoModelController;
import cn.pluss.platform.entity.WxBankCode;
import cn.pluss.platform.util.StringUtil;
import cn.pluss.platform.wxBankCode.WxBankCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("wxBankCode")
public class WxBankCodeController  extends BaseNoModelController {

	  private Integer PAGE_SIZE=12;

    @Autowired
	  private WxBankCodeService wxBankCodeService;

    /**
    *引导页
    * @return
    */
    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public String index() {
   
        return "wxBankCode/wxBankCodeList";
    }

    /**
    *分页查询
    */
    @RequestMapping(value = "/queryWxBankCodeByPage", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> queryWxBankCodeByPage(Integer currPage,Integer id){
   
   	if(currPage==null) {
   	   currPage=1;
       }
    	Map<String,Object> map=new HashMap<String, Object>();
    	map.put("pageSize",PAGE_SIZE);
    	map.put("offset", (currPage-1)*PAGE_SIZE);
    	map.put("id",  id);
    	List<WxBankCode> wxBankCodeList=wxBankCodeService.queryWxBankCodePage(map);
    	Integer count=wxBankCodeService.queryWxBankCodePageCount(map);
        Map<String,Object> result=new HashMap<String,Object>();
        result.put("wxBankCodeList", wxBankCodeList);
        result.put("count", count);
        result.put("pageCount",StringUtil.getPageCount(count,PAGE_SIZE));
        result.put("currPage", currPage);
    	  return result;
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryWxBankCodeDetails", method = RequestMethod.GET)
    public String queryWxBankCodeDetails(HttpServletRequest request,Integer id,Integer pageIndex){
   
   	  if(id!=null&&id!=0) {
   		 WxBankCode wxBankCode=new WxBankCode();
   		 wxBankCode.setId(id);
           wxBankCode=wxBankCodeService.queryWxBankCode(wxBankCode);
          request.setAttribute("wxBankCode", wxBankCode);
   		request.setAttribute("pageIndex", pageIndex);
       	}
        return "wxBankCode/wxBankCodeDetails";
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryWxBankCodeBaseInfo", method = RequestMethod.GET)
    public String queryWxBankCodeBaseInfo(HttpServletRequest request,Integer id,Integer pageIndex){
   
   	  if(id!=null&&id!=0) {
   		WxBankCode wxBankCode=new WxBankCode();
   		wxBankCode.setId(id);
        wxBankCode=wxBankCodeService.queryWxBankCode(wxBankCode);
          request.setAttribute("wxBankCode", wxBankCode);
   		request.setAttribute("pageIndex", pageIndex);
       	}
        return "wxBankCode/wxBankCodeBaseInfo";
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryWxBankCodeExtendsInfo", method = RequestMethod.GET)
    public String queryWxBankCodeExtendsInfo(){
   
        return "wxBankCode/wxBankCodeExtendsInfo";
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryWxBankCodeFunctionsInfo", method = RequestMethod.GET)
    public String queryWxBankCodeFunctionsInfo(){
   
        return "wxBankCode/wxBankCodeFunctionsInfo";
    }
    /**
    *保存对象
    *@throws IOException
    */
    @RequestMapping(value = "/saveWxBankCode", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> saveWxBankCode(WxBankCode wxBankCode){
   
       if(wxBankCode.getId()!=null&&wxBankCode.getId()!=0){
    		wxBankCodeService.updateWxBankCode(wxBankCode);
    	 }else{  
      	wxBankCodeService.saveWxBankCode(wxBankCode);
    	 }  
		Map<String,Object> result=new HashMap<String,Object>();
    	result.put("resultCode", "1");
    	result.put("resultMessage", "保存成功!");
    	return result;
    }
    /**
    *修改对象
    *@throws IOException
    */
    @RequestMapping(value = "/updateWxBankCode", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> updateWxBankCode(Integer id){
   
   	WxBankCode wxBankCode=new WxBankCode();
   	wxBankCode.setId(id);
      wxBankCodeService.updateWxBankCode(wxBankCode);
   	Map<String,Object> result=new HashMap<String,Object>();
    	result.put("resultCode", "1");
    	result.put("resultMessage", "保存成功!");
    	return result;
    }
    /**
    *删除对象
    *@throws IOException
    */
    @RequestMapping(value = "/deleteWxBankCode", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> deleteWxBankCode(Integer id){
   	WxBankCode wxBankCode=new WxBankCode();
   	wxBankCode.setId(id);
		wxBankCodeService.deleteWxBankCode(wxBankCode);
		Map<String,Object> result=new HashMap<String,Object>();
    	result.put("resultCode", "1");
    	result.put("resultMessage", "保存成功!");
    	return result;
    }

}


