package cn.pluss.platform.controller.merchantRegistLog;

import cn.pluss.platform.controller.BaseNoModelController;
import cn.pluss.platform.entity.MerchantRegistLog;
import cn.pluss.platform.merchantRegistLog.MerchantRegistLogService;
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("merchantRegistLog")
public class MerchantRegistLogController  extends BaseNoModelController {

	  private Integer PAGE_SIZE=12;

    @Autowired
	  private MerchantRegistLogService merchantRegistLogService;

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

    /**
    *分页查询
    */
    @RequestMapping(value = "/queryMerchantRegistLogByPage", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> queryMerchantRegistLogByPage(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<MerchantRegistLog> merchantRegistLogList=merchantRegistLogService.queryMerchantRegistLogPage(map);
    	Integer count=merchantRegistLogService.queryMerchantRegistLogPageCount(map);
        Map<String,Object> result=new HashMap<String,Object>();
        result.put("merchantRegistLogList", merchantRegistLogList);
        result.put("count", count);
        result.put("pageCount",StringUtil.getPageCount(count,PAGE_SIZE));
        result.put("currPage", currPage);
    	  return result;
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryMerchantRegistLogDetails", method = RequestMethod.GET)
    public String queryMerchantRegistLogDetails(HttpServletRequest request,Integer id,Integer pageIndex){
   
   	  if(id!=null&&id!=0) {
   		 MerchantRegistLog merchantRegistLog=new MerchantRegistLog();
   		 merchantRegistLog.setId(id);
           merchantRegistLog=merchantRegistLogService.queryMerchantRegistLog(merchantRegistLog);
          request.setAttribute("merchantRegistLog", merchantRegistLog);
   		request.setAttribute("pageIndex", pageIndex);
       	}
        return "merchantRegistLog/merchantRegistLogDetails";
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryMerchantRegistLogBaseInfo", method = RequestMethod.GET)
    public String queryMerchantRegistLogBaseInfo(HttpServletRequest request,Integer id,Integer pageIndex){
   
   	  if(id!=null&&id!=0) {
   		MerchantRegistLog merchantRegistLog=new MerchantRegistLog();
   		merchantRegistLog.setId(id);
        merchantRegistLog=merchantRegistLogService.queryMerchantRegistLog(merchantRegistLog);
          request.setAttribute("merchantRegistLog", merchantRegistLog);
   		request.setAttribute("pageIndex", pageIndex);
       	}
        return "merchantRegistLog/merchantRegistLogBaseInfo";
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryMerchantRegistLogExtendsInfo", method = RequestMethod.GET)
    public String queryMerchantRegistLogExtendsInfo(){
   
        return "merchantRegistLog/merchantRegistLogExtendsInfo";
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryMerchantRegistLogFunctionsInfo", method = RequestMethod.GET)
    public String queryMerchantRegistLogFunctionsInfo(){
   
        return "merchantRegistLog/merchantRegistLogFunctionsInfo";
    }
    /**
    *保存对象
    *@throws IOException
    */
    @RequestMapping(value = "/saveMerchantRegistLog", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> saveMerchantRegistLog(MerchantRegistLog merchantRegistLog){
   
       if(merchantRegistLog.getId()!=null&&merchantRegistLog.getId()!=0){
    		merchantRegistLogService.updateMerchantRegistLog(merchantRegistLog);
    	 }else{  
      	merchantRegistLogService.saveMerchantRegistLog(merchantRegistLog);
    	 }  
		Map<String,Object> result=new HashMap<String,Object>();
    	result.put("resultCode", "1");
    	result.put("resultMessage", "保存成功!");
    	return result;
    }
    /**
    *修改对象
    *@throws IOException
    */
    @RequestMapping(value = "/updateMerchantRegistLog", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> updateMerchantRegistLog(Integer id){
   
   	MerchantRegistLog merchantRegistLog=new MerchantRegistLog();
   	merchantRegistLog.setId(id);
      merchantRegistLogService.updateMerchantRegistLog(merchantRegistLog);
   	Map<String,Object> result=new HashMap<String,Object>();
    	result.put("resultCode", "1");
    	result.put("resultMessage", "保存成功!");
    	return result;
    }
    /**
    *删除对象
    *@throws IOException
    */
    @RequestMapping(value = "/deleteMerchantRegistLog", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> deleteMerchantRegistLog(Integer id){
   	MerchantRegistLog merchantRegistLog=new MerchantRegistLog();
   	merchantRegistLog.setId(id);
		merchantRegistLogService.deleteMerchantRegistLog(merchantRegistLog);
		Map<String,Object> result=new HashMap<String,Object>();
    	result.put("resultCode", "1");
    	result.put("resultMessage", "保存成功!");
    	return result;
    }

}


