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.ManagerHousekeeperCache;
import cn.com.countrygarden.bi.main.service.manager.map.ManagerHousekeeperCacheService;
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("ManagerHousekeeperCacheController")
@RequestMapping("/api/managerHousekeeperCache")
public class ManagerHousekeeperCacheController extends BaseController{
    @Autowired
    private ManagerHousekeeperCacheService managerHousekeeperCacheService;


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

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

    @PostMapping(value = "/add")
    public Result add(ManagerHousekeeperCache managerHousekeeperCache,
                      HttpServletRequest request){
        return  managerHousekeeperCacheService.add(managerHousekeeperCache,getAccessToken(request));
    }

    @PutMapping(value = "/edit")
    public Result edit(ManagerHousekeeperCache managerHousekeeperCache, HttpServletRequest request){
        return  managerHousekeeperCacheService.edit(managerHousekeeperCache,getAccessToken(request));
    }

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


}