package cn.pluss.platform.controller.merchantRegistAuditRecord;

import cn.pluss.platform.controller.BaseNoModelController;
import cn.pluss.platform.entity.MerchantRegistAuditRecord;
import cn.pluss.platform.merchantRegistAuditRecord.MerchantRegistAuditRecordService;
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("merchantRegistAuditRecord")
public class MerchantRegistAuditRecordController  extends BaseNoModelController {

	  private Integer PAGE_SIZE=12;

    @Autowired
	  private MerchantRegistAuditRecordService merchantRegistAuditRecordService;

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

    /**
    *分页查询
    */
    @RequestMapping(value = "/queryMerchantRegistAuditRecordByPage", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> queryMerchantRegistAuditRecordByPage(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<MerchantRegistAuditRecord> merchantRegistAuditRecordList=merchantRegistAuditRecordService.queryMerchantRegistAuditRecordPage(map);
    	Integer count=merchantRegistAuditRecordService.queryMerchantRegistAuditRecordPageCount(map);
        Map<String,Object> result=new HashMap<String,Object>();
        result.put("merchantRegistAuditRecordList", merchantRegistAuditRecordList);
        result.put("count", count);
        result.put("pageCount",StringUtil.getPageCount(count,PAGE_SIZE));
        result.put("currPage", currPage);
    	  return result;
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryMerchantRegistAuditRecordDetails", method = RequestMethod.GET)
    public String queryMerchantRegistAuditRecordDetails(HttpServletRequest request,Integer id,Integer pageIndex){
   
   	  if(id!=null&&id!=0) {
   		 MerchantRegistAuditRecord merchantRegistAuditRecord=new MerchantRegistAuditRecord();
   		 merchantRegistAuditRecord.setId(id);
           merchantRegistAuditRecord=merchantRegistAuditRecordService.queryMerchantRegistAuditRecord(merchantRegistAuditRecord);
          request.setAttribute("merchantRegistAuditRecord", merchantRegistAuditRecord);
   		request.setAttribute("pageIndex", pageIndex);
       	}
        return "merchantRegistAuditRecord/merchantRegistAuditRecordDetails";
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryMerchantRegistAuditRecordBaseInfo", method = RequestMethod.GET)
    public String queryMerchantRegistAuditRecordBaseInfo(HttpServletRequest request,Integer id,Integer pageIndex){
   
   	  if(id!=null&&id!=0) {
   		MerchantRegistAuditRecord merchantRegistAuditRecord=new MerchantRegistAuditRecord();
   		merchantRegistAuditRecord.setId(id);
        merchantRegistAuditRecord=merchantRegistAuditRecordService.queryMerchantRegistAuditRecord(merchantRegistAuditRecord);
          request.setAttribute("merchantRegistAuditRecord", merchantRegistAuditRecord);
   		request.setAttribute("pageIndex", pageIndex);
       	}
        return "merchantRegistAuditRecord/merchantRegistAuditRecordBaseInfo";
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryMerchantRegistAuditRecordExtendsInfo", method = RequestMethod.GET)
    public String queryMerchantRegistAuditRecordExtendsInfo(){
   
        return "merchantRegistAuditRecord/merchantRegistAuditRecordExtendsInfo";
    }
    /**
    *查询详情
    */
     @RequestMapping(value = "/queryMerchantRegistAuditRecordFunctionsInfo", method = RequestMethod.GET)
    public String queryMerchantRegistAuditRecordFunctionsInfo(){
   
        return "merchantRegistAuditRecord/merchantRegistAuditRecordFunctionsInfo";
    }
    /**
    *保存对象
    *@throws IOException
    */
    @RequestMapping(value = "/saveMerchantRegistAuditRecord", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> saveMerchantRegistAuditRecord(MerchantRegistAuditRecord merchantRegistAuditRecord){
   
       if(merchantRegistAuditRecord.getId()!=null&&merchantRegistAuditRecord.getId()!=0){
    		merchantRegistAuditRecordService.updateMerchantRegistAuditRecord(merchantRegistAuditRecord);
    	 }else{  
      	merchantRegistAuditRecordService.saveMerchantRegistAuditRecord(merchantRegistAuditRecord);
    	 }  
		Map<String,Object> result=new HashMap<String,Object>();
    	result.put("resultCode", "1");
    	result.put("resultMessage", "保存成功!");
    	return result;
    }
    /**
    *修改对象
    *@throws IOException
    */
    @RequestMapping(value = "/updateMerchantRegistAuditRecord", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> updateMerchantRegistAuditRecord(Integer id){
   
   	MerchantRegistAuditRecord merchantRegistAuditRecord=new MerchantRegistAuditRecord();
   	merchantRegistAuditRecord.setId(id);
      merchantRegistAuditRecordService.updateMerchantRegistAuditRecord(merchantRegistAuditRecord);
   	Map<String,Object> result=new HashMap<String,Object>();
    	result.put("resultCode", "1");
    	result.put("resultMessage", "保存成功!");
    	return result;
    }
    /**
    *删除对象
    *@throws IOException
    */
    @RequestMapping(value = "/deleteMerchantRegistAuditRecord", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> deleteMerchantRegistAuditRecord(Integer id){
   	MerchantRegistAuditRecord merchantRegistAuditRecord=new MerchantRegistAuditRecord();
   	merchantRegistAuditRecord.setId(id);
		merchantRegistAuditRecordService.deleteMerchantRegistAuditRecord(merchantRegistAuditRecord);
		Map<String,Object> result=new HashMap<String,Object>();
    	result.put("resultCode", "1");
    	result.put("resultMessage", "保存成功!");
    	return result;
    }

}


