package org.jeecg.modules.api.controller2;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.apiService.AuthenticationService;
import org.jeecg.modules.employAhthenticationCompany.entity.EmployAhthenticationCompany;
import org.jeecg.modules.employAuthenticationPerson.entity.EmployAuthenticationPerson;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags="实名认证相关接口")
@RestController
@RequestMapping("/employ/authentication")
@Slf4j
public class AuthenticationController {
    /******************************************************************************************************************/
    //实名认证信息
    @Resource
    private AuthenticationService authenticationService;
    /******************************************************************************************************************/

    //我的服务-个人实名认证
    @ApiOperation(value="我的服务-个人实名认证", notes="我的服务-个人实名认证")
    @RequestMapping(value = "/addAuthenticationPerson", method = {RequestMethod.POST})
    public Result<?> addAuthenticationPerson(@RequestHeader("X-Access-Token") String token, EmployAuthenticationPerson employAuthenticationPerson){
        //业务处理
        return authenticationService.addAuthenticationPerson(token, employAuthenticationPerson);
    }

    //lzx:我的服务-查询实名认证信息
    @ApiOperation(value="我的服务-查询个人实名认证信息", notes="我的服务-查询个人实名认证信息")
    @RequestMapping(value = "/getAuthenticationPerson", method = {RequestMethod.GET})
    public Result<?> getAuthenticationPerson(@RequestHeader("X-Access-Token") String token){
        //业务处理
        return authenticationService.getAuthenticationPerson(token);
    }













    //我的服务-企业实名认证
    @ApiOperation(value="我的服务-企业实名认证", notes="我的服务-企业实名认证")
    @RequestMapping(value = "/addAuthenticationCompany", method = {RequestMethod.POST})
    public Result<?> addAuthenticationCompany(@RequestHeader("X-Access-Token") String token, EmployAhthenticationCompany employAhthenticationCompany){
        String message = null;
        //参数校验
        if(null == employAhthenticationCompany.getBusinessLicense()){
            message = "营业执照未上传，请上传营业执照";
        }else if(null == employAhthenticationCompany.getCompanyName()){
            message = "企业名称为空，请填写企业名称";
        }else if(null == employAhthenticationCompany.getLegalPerson()){
            message = "法定代表人姓名为空，请填写法定代表人姓名";
        }else if(null == employAhthenticationCompany.getCompanyAddress()){
            message = "企业地址为空，请填写企业地址";
        }
        //参数输入有误，返回错误信息
        if(null != message){
            return Result.OK(message);
        }

        //业务处理
        return authenticationService.addAuthenticationCompany(token, employAhthenticationCompany);
    }

    @ApiOperation(value="我的服务-查询企业实名认证信息", notes="我的服务-查询企业实名认证信息")
    @RequestMapping(value = "/getAuthenticationCompany", method = {RequestMethod.GET})
    public Result<?> getAuthenticationCompany(@RequestHeader("X-Access-Token") String token){
        //业务处理
        return authenticationService.getAuthenticationCompany(token);
    }


}
