package cn.pluss.platform.controller.merchantMenberRecharge;

import cn.pluss.platform.controller.BaseNoModelController;
import cn.pluss.platform.entity.MerchantMenberRecharge;
import cn.pluss.platform.merchantMenberRecharge.MerchantMenberRechargeService;
import cn.pluss.platform.util.StringUtil;
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("merchantMenberRecharge")
public class MerchantMenberRechargeController  extends BaseNoModelController {

	  private Integer PAGE_SIZE=12;

    @Autowired
	  private MerchantMenberRechargeService merchantMenberRechargeService;

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

    /**
    *分页查询
    */
    @RequestMapping(value = "/queryMerchantMenberRechargeByPage", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> queryMerchantMenberRechargeByPage(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<MerchantMenberRecharge> merchantMenberRechargeList=merchantMenberRechargeService.queryMerchantMenberRechargePage(map);
    	Integer count=merchantMenberRechargeService.queryMerchantMenberRechargePageCount(map);
        Map<String,Object> result=new HashMap<String,Object>();
        result.put("merchantMenberRechargeList", merchantMenberRechargeList);
        result.put("count", count);
        result.put("pageCount",StringUtil.getPageCount(count,PAGE_SIZE));
        result.put("currPage", currPage);
    	  return result;
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryMerchantMenberRechargeDetails", method = RequestMethod.GET)
    public String queryMerchantMenberRechargeDetails(HttpServletRequest request,Integer id,Integer pageIndex){
   
   	  if(id!=null&&id!=0) {
   		 MerchantMenberRecharge merchantMenberRecharge=new MerchantMenberRecharge();
   		 merchantMenberRecharge.setId(id);
           merchantMenberRecharge=merchantMenberRechargeService.queryMerchantMenberRecharge(merchantMenberRecharge);
          request.setAttribute("merchantMenberRecharge", merchantMenberRecharge);
   		request.setAttribute("pageIndex", pageIndex);
       	}
        return "merchantMenberRecharge/merchantMenberRechargeDetails";
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryMerchantMenberRechargeBaseInfo", method = RequestMethod.GET)
    public String queryMerchantMenberRechargeBaseInfo(HttpServletRequest request,Integer id,Integer pageIndex){
   
   	  if(id!=null&&id!=0) {
   		MerchantMenberRecharge merchantMenberRecharge=new MerchantMenberRecharge();
   		merchantMenberRecharge.setId(id);
        merchantMenberRecharge=merchantMenberRechargeService.queryMerchantMenberRecharge(merchantMenberRecharge);
          request.setAttribute("merchantMenberRecharge", merchantMenberRecharge);
   		request.setAttribute("pageIndex", pageIndex);
       	}
        return "merchantMenberRecharge/merchantMenberRechargeBaseInfo";
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryMerchantMenberRechargeExtendsInfo", method = RequestMethod.GET)
    public String queryMerchantMenberRechargeExtendsInfo(){
   
        return "merchantMenberRecharge/merchantMenberRechargeExtendsInfo";
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryMerchantMenberRechargeFunctionsInfo", method = RequestMethod.GET)
    public String queryMerchantMenberRechargeFunctionsInfo(){
   
        return "merchantMenberRecharge/merchantMenberRechargeFunctionsInfo";
    }
    /**
    *保存对象
    *@throws IOException
    */
    @RequestMapping(value = "/saveMerchantMenberRecharge", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> saveMerchantMenberRecharge(MerchantMenberRecharge merchantMenberRecharge){
   
       if(merchantMenberRecharge.getId()!=null&&merchantMenberRecharge.getId()!=0){
    		merchantMenberRechargeService.updateMerchantMenberRecharge(merchantMenberRecharge);
    	 }else{  
      	merchantMenberRechargeService.saveMerchantMenberRecharge(merchantMenberRecharge);
    	 }  
		Map<String,Object> result=new HashMap<String,Object>();
    	result.put("resultCode", "1");
    	result.put("resultMessage", "保存成功!");
    	return result;
    }
    /**
    *修改对象
    *@throws IOException
    */
    @RequestMapping(value = "/updateMerchantMenberRecharge", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> updateMerchantMenberRecharge(Integer id){
   
   	MerchantMenberRecharge merchantMenberRecharge=new MerchantMenberRecharge();
   	merchantMenberRecharge.setId(id);
      merchantMenberRechargeService.updateMerchantMenberRecharge(merchantMenberRecharge);
   	Map<String,Object> result=new HashMap<String,Object>();
    	result.put("resultCode", "1");
    	result.put("resultMessage", "保存成功!");
    	return result;
    }
    /**
    *删除对象
    *@throws IOException
    */
    @RequestMapping(value = "/deleteMerchantMenberRecharge", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> deleteMerchantMenberRecharge(Integer id){
   	MerchantMenberRecharge merchantMenberRecharge=new MerchantMenberRecharge();
   	merchantMenberRecharge.setId(id);
		merchantMenberRechargeService.deleteMerchantMenberRecharge(merchantMenberRecharge);
		Map<String,Object> result=new HashMap<String,Object>();
    	result.put("resultCode", "1");
    	result.put("resultMessage", "保存成功!");
    	return result;
    }

}


