package cn.com.countrygarden.bi.main.controller.ck.satisfaction;


import cn.com.countrygarden.bi.main.controller.BaseController;
import cn.com.countrygarden.bi.main.core.Result;
import cn.com.countrygarden.bi.main.model.ck.satisfaction.SatisfiedRegion;
import cn.com.countrygarden.bi.main.service.ck.SatisfiedRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * <p>
 *   满意度-区域模块接口
 * </p>
 *
 * @author
 * @date 2021-08-06
 * @version V1.0
 */
@RestController("SatisfiedRegionController")
@RequestMapping("/api/satisfiedRegion")
public class SatisfiedRegionController extends BaseController {
    @Autowired
    private SatisfiedRegionService satisfiedRegionService;


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

    @PostMapping(value = "/getrevenue")
    public Result getrevenue(HttpServletRequest request) throws IOException {
        return satisfiedRegionService.getrevenue(getAccessToken(request),request);
    }

    @PutMapping(value = "/edit")
    public Result edit(SatisfiedRegion satisfiedRegion, HttpServletRequest request){
        return  satisfiedRegionService.edit(satisfiedRegion,getAccessToken(request));
    }

    @PutMapping(value="/del")
    public Result del(@RequestParam(value = "id", required = true)String id){
        return  satisfiedRegionService.del(id,getAccessToken());
    }

}