package cn.pluss.platform.controller.merchantMenberComsume;

import cn.pluss.platform.controller.BaseNoModelController;
import cn.pluss.platform.entity.MerchantMenberComsume;
import cn.pluss.platform.merchantMenberComsume.MerchantMenberComsumeService;
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("merchantMenberComsume")
public class MerchantMenberComsumeController  extends BaseNoModelController {

	  private Integer PAGE_SIZE=12;

    @Autowired
	  private MerchantMenberComsumeService merchantMenberComsumeService;

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

    /**
    *分页查询
    */
    @RequestMapping(value = "/queryMerchantMenberComsumeByPage", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> queryMerchantMenberComsumeByPage(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<MerchantMenberComsume> merchantMenberComsumeList=merchantMenberComsumeService.queryMerchantMenberComsumePage(map);
    	Integer count=merchantMenberComsumeService.queryMerchantMenberComsumePageCount(map);
        Map<String,Object> result=new HashMap<String,Object>();
        result.put("merchantMenberComsumeList", merchantMenberComsumeList);
        result.put("count", count);
        result.put("pageCount",StringUtil.getPageCount(count,PAGE_SIZE));
        result.put("currPage", currPage);
    	  return result;
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryMerchantMenberComsumeDetails", method = RequestMethod.GET)
    public String queryMerchantMenberComsumeDetails(HttpServletRequest request,Integer id,Integer pageIndex){
   
   	  if(id!=null&&id!=0) {
   		 MerchantMenberComsume merchantMenberComsume=new MerchantMenberComsume();
   		 merchantMenberComsume.setId(id);
           merchantMenberComsume=merchantMenberComsumeService.queryMerchantMenberComsume(merchantMenberComsume);
          request.setAttribute("merchantMenberComsume", merchantMenberComsume);
   		request.setAttribute("pageIndex", pageIndex);
       	}
        return "merchantMenberComsume/merchantMenberComsumeDetails";
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryMerchantMenberComsumeBaseInfo", method = RequestMethod.GET)
    public String queryMerchantMenberComsumeBaseInfo(HttpServletRequest request,Integer id,Integer pageIndex){
   
   	  if(id!=null&&id!=0) {
   		MerchantMenberComsume merchantMenberComsume=new MerchantMenberComsume();
   		merchantMenberComsume.setId(id);
        merchantMenberComsume=merchantMenberComsumeService.queryMerchantMenberComsume(merchantMenberComsume);
          request.setAttribute("merchantMenberComsume", merchantMenberComsume);
   		request.setAttribute("pageIndex", pageIndex);
       	}
        return "merchantMenberComsume/merchantMenberComsumeBaseInfo";
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryMerchantMenberComsumeExtendsInfo", method = RequestMethod.GET)
    public String queryMerchantMenberComsumeExtendsInfo(){
   
        return "merchantMenberComsume/merchantMenberComsumeExtendsInfo";
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryMerchantMenberComsumeFunctionsInfo", method = RequestMethod.GET)
    public String queryMerchantMenberComsumeFunctionsInfo(){
   
        return "merchantMenberComsume/merchantMenberComsumeFunctionsInfo";
    }
    /**
    *保存对象
    *@throws IOException
    */
    @RequestMapping(value = "/saveMerchantMenberComsume", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> saveMerchantMenberComsume(MerchantMenberComsume merchantMenberComsume){
   
       if(merchantMenberComsume.getId()!=null&&merchantMenberComsume.getId()!=0){
    		merchantMenberComsumeService.updateMerchantMenberComsume(merchantMenberComsume);
    	 }else{  
      	merchantMenberComsumeService.saveMerchantMenberComsume(merchantMenberComsume);
    	 }  
		Map<String,Object> result=new HashMap<String,Object>();
    	result.put("resultCode", "1");
    	result.put("resultMessage", "保存成功!");
    	return result;
    }
    /**
    *修改对象
    *@throws IOException
    */
    @RequestMapping(value = "/updateMerchantMenberComsume", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> updateMerchantMenberComsume(Integer id){
   
   	MerchantMenberComsume merchantMenberComsume=new MerchantMenberComsume();
   	merchantMenberComsume.setId(id);
      merchantMenberComsumeService.updateMerchantMenberComsume(merchantMenberComsume);
   	Map<String,Object> result=new HashMap<String,Object>();
    	result.put("resultCode", "1");
    	result.put("resultMessage", "保存成功!");
    	return result;
    }
    /**
    *删除对象
    *@throws IOException
    */
    @RequestMapping(value = "/deleteMerchantMenberComsume", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> deleteMerchantMenberComsume(Integer id){
   	MerchantMenberComsume merchantMenberComsume=new MerchantMenberComsume();
   	merchantMenberComsume.setId(id);
		merchantMenberComsumeService.deleteMerchantMenberComsume(merchantMenberComsume);
		Map<String,Object> result=new HashMap<String,Object>();
    	result.put("resultCode", "1");
    	result.put("resultMessage", "保存成功!");
    	return result;
    }

}


