package com.muzhi.dingtalk.test.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.muzhi.dingtalk.test.entity.Employee;
import com.muzhi.dingtalk.test.entity.vo.EmployeeDataVo;
import com.muzhi.dingtalk.test.entity.vo.EmployeeQuery;
import com.muzhi.dingtalk.test.service.EmployeeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(description = "钉钉花名册")
@RestController
//produces = {"application/json;charset=UTF-8"}为了解决后端返回json数据给前端显示乱码问题（中文问号？）
@RequestMapping(value = "/employeeservice/employee", produces = {"application/json;charset=UTF-8"})
public class EmployeeController {

    @Autowired
    private EmployeeService employeeService;

    //获取公司在职员工id列表（已去除",[]）
    @ApiOperation(value = "获取公司在职员工id列表（已去除\",[]）")
    @GetMapping("getEmployeeId")
    public String getEmployeeId(){

        String employeeId = employeeService.getEmployeeId();
        return employeeId;
    }

    //获取公司离职员工id列表（已去除",[]）
    @ApiOperation(value = "获取公司离职员工id列表（已去除\",[]）")
    @GetMapping("getLiZhiEmployeeId")
    public String getLiZhiEmployeeId(){

        String liZhiEmployeeId = employeeService.getLiZhiEmployeeId();
        return liZhiEmployeeId;
    }


    //获取公司在职员工id列表（未去除",[]）
    @ApiOperation(value = "获取公司在职员工id列表（未去除\",[]）")
    @GetMapping("getEmployeeIdAll")
    public List<String> getEmployeeIdAll(){

        List<String> employeeIdAll = employeeService.getEmployeeIdAll();
        return employeeIdAll;
    }

    //查询钉钉接口中的花名册信息
    @ApiOperation(value = "查询钉钉接口中的花名册信息")
    @GetMapping("getDingHuamingce")
    public String getDingHuamingce(){

        String dingHuamingce = employeeService.getDingHuamingce();
        return dingHuamingce;
    }

    //获取数据库中员工花名册employee实体类表数据并放入vo对象进行前端接口调用展示数据
    @ApiOperation(value = "获取员工花名册字段信息")
    @GetMapping("getHuamingce")
    public EmployeeDataVo getHuamingce(Integer page,Integer limit,
                                       EmployeeQuery employeeQuery){

//        @RequestBody是使用json传递数据，把json数据封装到对应的对象里面，注意：需要用Post提交方式，Get取不到值
//        (required = false)表示参数值可以为空
//        @ApiParam(name = "teacherQuery", value = "自定义讲师查询条件", required = true)
//        @RequestBody(required = false) EmployeeQuery employeeVoQuery

        EmployeeDataVo huamingce = employeeService.getHuamingce(page,limit,employeeQuery);
        return huamingce;
    }
}
