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.SatisfiedDissatisfiedRegion;
import cn.com.countrygarden.bi.main.service.ck.SatisfiedDissatisfiedRegionService;
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("SatisfiedDissatisfiedRegionController")
@RequestMapping("/api/satisfiedDissatisfiedRegion")
public class SatisfiedDissatisfiedRegionController extends BaseController {
    @Autowired
    private SatisfiedDissatisfiedRegionService satisfiedDissatisfiedRegionService;

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

    @GetMapping(value = "/detailed", produces = "application/json;charset=utf-8")
    public Result detailed(
            @RequestParam(value = "id") Long id,
            @RequestParam(value = "line") String line,
            HttpServletRequest request) {
        return satisfiedDissatisfiedRegionService.detailed(id,line,getAccessToken(request));
    }

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

    @PutMapping(value = "/edit")
    public Result edit(SatisfiedDissatisfiedRegion satisfiedDissatisfiedRegion, HttpServletRequest request){
        return  satisfiedDissatisfiedRegionService.edit(satisfiedDissatisfiedRegion,getAccessToken(request));
    }

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