package cn.com.countrygarden.bi.main.controller.districtReport;
import cn.com.countrygarden.bi.main.controller.BaseController;
import cn.com.countrygarden.bi.main.core.Result;
import cn.com.countrygarden.bi.main.model.districtReport.RdDistrictProjectMp;
import cn.com.countrygarden.bi.main.service.districtReport.RdDistrictProjectMpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * 片区erp项目对应-控制层实现
 *
 * @author 吕伟峰
 * @email www.justintoforest@gamail.com
 * @url 
 * @date 2019-08-14
 */
@RestController("RdDistrictProjectMpController")
@RequestMapping("/api/rdDistrictProjectMp")
public class RdDistrictProjectMpController extends BaseController{
    @Autowired
    private RdDistrictProjectMpService rdDistrictProjectMpService;


    @GetMapping(value = "/list", produces = "application/json;charset=utf-8")
    public Result list(RdDistrictProjectMp rdDistrictProjectMp,
                       @RequestParam(value = "size", required = false, defaultValue = "10") int size,
                       @RequestParam(value = "page", required = false, defaultValue = "1") int page,
                       HttpServletRequest request){
        return  rdDistrictProjectMpService.queryPageList(rdDistrictProjectMp,page,size);
    }

    @GetMapping(value = "/one", produces = "application/json;charset=utf-8")
    public Result queryById(@RequestParam(value = "id", required = true)Integer id,
                            HttpServletRequest request){
        return  rdDistrictProjectMpService.queryById(id);
    }

    @GetMapping(value = "/checkMp", produces = "application/json;charset=utf-8")
    public Result checkMp(@RequestParam(value = "regionCode", required = false)String regionCode,HttpServletRequest request){

        return  rdDistrictProjectMpService.checkMp(regionCode,getAccessToken());
    }

    @PostMapping(value = "/add")
    public Result add(RdDistrictProjectMp rdDistrictProjectMp,
                      HttpServletRequest request){
        return  rdDistrictProjectMpService.add(rdDistrictProjectMp,getAccessToken(request));
    }

    @PutMapping(value = "/edit")
    public Result edit(RdDistrictProjectMp rdDistrictProjectMp, HttpServletRequest request){
        return  rdDistrictProjectMpService.edit(rdDistrictProjectMp,getAccessToken(request));
    }

    @DeleteMapping(value="/del")
    public Result del(@RequestParam(value = "id", required = true)Integer id,@RequestParam(value = "updateName", required = true)String updateName){
        return  rdDistrictProjectMpService.del(id,getAccessToken(),updateName);
    }


}