package com.union.ai.api.controller.face;

import com.union.ai.api.dto.*;
import com.union.ai.api.util.Config;
import com.union.ai.api.util.HttpClientUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * Author: xingxin.jing
 * Date: 2019/3/30
 * Time: 下午1:48
 */
@Slf4j
@RestController
@RequestMapping(value = "/face-api/v3/face", method = RequestMethod.POST)
public class FaceApiController {

    /**
     * 人脸检测
     * @param paramDto
     * @return
     */
    @RequestMapping("detect")
    public String detect(@RequestBody  DetectParamDto paramDto) {

        String url = Config.getInstance().getFaceApiUrl() + "detect";
        return HttpClientUtil.sendPostJSON(url, paramDto);

    }

    /**
     * 活体检测
     * @param paramDto
     * @return
     */
    @RequestMapping("liveness")
    public String liveness(@RequestBody  List<LivenessParamDto> paramDto) {

        String url = Config.getInstance().getFaceApiUrl() + "liveness";
        return HttpClientUtil.sendPostJSON(url, paramDto);

    }

    /**
     * 人脸对比
     * @param paramDto
     * @return
     */
    @RequestMapping("match")
    public String match(@RequestBody  List<MatchParamDto> paramDto) {

        String url = Config.getInstance().getFaceApiUrl() + "match";
        return HttpClientUtil.sendPostJSON(url, paramDto);

    }


    /**
     * 人脸认证
     * @param paramDto
     * @return
     */
    @RequestMapping("identify")
    public String identify(@RequestBody  IdentifyParamDto paramDto) {

        String url = Config.getInstance().getFaceApiUrl() + "identify";
        return HttpClientUtil.sendPostJSON(url, paramDto);

    }

    /**
     * 人脸注册
     * @param paramDto
     * @return
     */
    @RequestMapping("add")
    public String add(@RequestBody  AddParamDto paramDto) {

        String url = Config.getInstance().getFaceApiUrl() + "add";
        return HttpClientUtil.sendPostJSON(url, paramDto);

    }

    /**
     * 人脸更新
     * @param paramDto
     * @return
     */
    @RequestMapping("update")
    public String update(@RequestBody UpdateParamDto paramDto) {

        String url = Config.getInstance().getFaceApiUrl() + "update";
        return HttpClientUtil.sendPostJSON(url, paramDto);

    }

    /**
     * 人脸列表
     * @param paramDto
     * @return
     */
    @RequestMapping("list")
    public String list(@RequestBody  ListParamDto paramDto) {

        String url = Config.getInstance().getFaceApiUrl() + "list";
        return HttpClientUtil.sendPostJSON(url, paramDto);

    }

    /**
     * 删除人脸
     * @param paramDto
     * @return
     */
    @RequestMapping("delete")
    public String delete(@RequestBody  DeleteParamDto paramDto) {

        String url = Config.getInstance().getFaceApiUrl() + "delete";
        return HttpClientUtil.sendPostJSON(url, paramDto);

    }


}
