package cn.com.countrygarden.bi.main.controller.wcx;

import cn.com.countrygarden.bi.main.controller.BaseController;
import cn.com.countrygarden.bi.main.core.Response;
import cn.com.countrygarden.bi.main.core.Result;
import cn.com.countrygarden.bi.main.dto.wcx.BdTypeDo;
import cn.com.countrygarden.bi.main.model.PageData;
import cn.com.countrygarden.bi.main.model.wcx.WcxUserAdmDto;
import cn.com.countrygarden.bi.main.service.wcx.WcxUserDtoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController("WcxUserDtoController")
@RequestMapping("/api/wcx/WcxUserDto")
public class WcxUserDtoController extends BaseController {

    @Autowired
    private WcxUserDtoService wcxUserDtoService;

    @GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Result list(WcxUserAdmDto wcxUserAdmDto){
        PageData pageData=wcxUserDtoService.queryPageList(wcxUserAdmDto,getAccessToken());
        return Response.response(pageData);
    }

    @GetMapping(value = "/findRoleregionfour", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Result findRoleregionfour(@RequestParam(name = "id",required = false) String id) {
        List<BdTypeDo> result = wcxUserDtoService.findRoleregionfour(getAccessToken());
        return Response.response(result);
    }

    @GetMapping(value = "/getPojDate",  produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Result getPojDate(HttpServletRequest request,
                             @RequestParam(value = "organCode",required = true) String organCode) {

        return Response.response(wcxUserDtoService.getPojDate(getAccessToken(request),organCode));
    }

    @PostMapping(value = "/addUser")
    public Result addUser(WcxUserAdmDto wcxUserAdmDto,HttpServletRequest request){
        return Response.response(wcxUserDtoService.addUser(wcxUserAdmDto,getAccessToken(request)));
    }

    @PostMapping(value = "/addInvalid")
    public Result addInvalid(WcxUserAdmDto wcxUserAdmDto,HttpServletRequest request){
        return Response.response(wcxUserDtoService.addInvalid(wcxUserAdmDto,getAccessToken(request)));
    }

    @GetMapping(value = "/getReading",  produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Result getReading(HttpServletRequest request,
                             WcxUserAdmDto wcxUserAdmDto) {
        PageData pageData=wcxUserDtoService.getReading(getAccessToken(request),wcxUserAdmDto);
        return Response.response(pageData);
    }

    @GetMapping(value = "/allpoj",  produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public void allpoj(HttpServletRequest request) {
       wcxUserDtoService.allpoj();
       System.out.println("执行完毕");
    }

}
