package cn.com.countrygarden.bi.main.controller.manager.cache;
import cn.com.countrygarden.bi.main.controller.BaseController;
import cn.com.countrygarden.bi.main.core.Result;
import cn.com.countrygarden.bi.main.model.manager.map.ManagerMapCache;
import cn.com.countrygarden.bi.main.service.manager.map.ManagerMapCacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;

/**
 * 管家地图数据缓存-业务逻辑层实现
 *
 * @author 李森林
 * @email www.justintoforest@gamail.com
 * @url 
 * @date 2018-11-19
 */
@RestController("ManagerMapCacheController")
@RequestMapping("/api/managerMapCache")
public class ManagerMapCacheController extends BaseController{
    @Autowired
    private ManagerMapCacheService managerMapCacheService;


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

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

    @PostMapping(value = "/add")
    public Result add(ManagerMapCache managerMapCache,
                      HttpServletRequest request){
        return  managerMapCacheService.add(managerMapCache,getAccessToken(request));
    }

    @PutMapping(value = "/edit")
    public Result edit(ManagerMapCache managerMapCache, HttpServletRequest request){
        return  managerMapCacheService.edit(managerMapCache,getAccessToken(request));
    }

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


}