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.SatisfiedDissatisfiedNationwide;
import cn.com.countrygarden.bi.main.service.ck.SatisfiedDissatisfiedNationwideService;
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("SatisfiedDissatisfiedNationwideController")
@RequestMapping("/api/satisfiedDissatisfiedNationwide")
public class SatisfiedDissatisfiedNationwideController extends BaseController {
    @Autowired
    private SatisfiedDissatisfiedNationwideService satisfiedDissatisfiedNationwideService;


    @GetMapping(value = "/list", produces = "application/json;charset=utf-8")
    public Result list(SatisfiedDissatisfiedNationwide satisfiedDissatisfiedNationwide,
                       @RequestParam(value = "size", required = false, defaultValue = "10") int size,
                       @RequestParam(value = "page", required = false, defaultValue = "1") int page,
                       HttpServletRequest request) {
        return satisfiedDissatisfiedNationwideService.queryPageList(satisfiedDissatisfiedNationwide,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 satisfiedDissatisfiedNationwideService.detailed(id,line,getAccessToken(request));
    }

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

    @PutMapping(value = "/edit")
    public Result edit(SatisfiedDissatisfiedNationwide satisfiedDissatisfiedNationwide, HttpServletRequest request){
        return  satisfiedDissatisfiedNationwideService.edit(satisfiedDissatisfiedNationwide,getAccessToken(request));
    }

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

}