package com.ssm.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ssm.core.utils.BeiSenUtils;
import com.ssm.core.utils.HttpClientUtil;
import com.ssm.manage.entity.BlackList;
import com.ssm.manage.entity.SmsException;
import com.ssm.manage.response.GenericResponse;
import com.ssm.manage.response.PageResponse;
import com.ssm.manage.response.ResponseCode;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("beiSenTest")
@Slf4j
public class BeiSenTestController {

    @Autowired
    private BeiSenUtils beiSenUtils;

    /**
     * 分页查询
     *
     * @return
     */
    @GetMapping
    @ApiOperation("分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", defaultValue = "1", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", defaultValue = "10", required = true)
    })
//@RequiresPermissions("system:blackList:query")
    public PageResponse<BlackList> listPage() {
        PageResponse<BlackList> pageResponse = new PageResponse<>();
        String token = beiSenUtils.getToken();
        JSONObject jsonObject = JSON.parseObject("{\n" +
                "    \"employeeInformation\":{\n" +
                "        \"name\":\"陆秀冲\",\n" +
                "        \"email\":\"2634621870@qq.com\",\n" +
                "        \"originalId\":\"282995495508082688\"\n" +
                "    },\n" +
                "    \"employmentRecord\":{\n" +
                "        \"entryDate\":\"2023-12-28\",\n" +
                "        \"probation\":0,\n" +
                "        \"employType\":1\n" +
                "    }\n" +
                "}");
        JSONObject jsonobject = new JSONObject();
        jsonobject.put("param",JSON.toJSON(jsonObject)) ;
            String s = HttpClientUtil.doPostByBeiSen("https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/Create", jsonobject, token);

        pageResponse.setCodeAndMsg(ResponseCode.OK);
        return pageResponse;
    }
    /**
     * 分页查询
     *
     * @return
     */
    @GetMapping("/getToken")
    @ApiOperation("分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", defaultValue = "1", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", defaultValue = "10", required = true)
    })
//@RequiresPermissions("system:blackList:query")
    public GenericResponse<String> getToken() {
        GenericResponse<String> pageResponse = new GenericResponse<>();
        String token = beiSenUtils.getToken();
        pageResponse.setData(token);
        pageResponse.setCodeAndMsg(ResponseCode.OK);
        return pageResponse;
    }
}
