package com.community.huiju.controller;

import com.community.huiju.common.base.BaseController;
import com.community.huiju.common.base.ResponseBean;
import com.community.huiju.service.FaceServiceI;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * weiximei on 2019-05-17
 */

@RestController
@RequestMapping("/")
@Api(value = "人脸操作 API", description = "人脸操作 API")
public class TaFceController extends BaseController {

    @Autowired
    private FaceServiceI faceServiceI;

    @RequestMapping(value = "/face", method = RequestMethod.POST)
    @ApiOperation(value = "录入人脸" , notes = "录入人脸")
    @ApiImplicitParams({
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "form", name = "userId", value = "用户Id"),
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "form", name = "userVerifyId", value = "房产审核Id"),
            @ApiImplicitParam(dataTypeClass = MultipartFile.class, paramType = "form", name = "uploadFile", value = "图片"),
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "appid", value = "appid"),
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "datetime", value = "时间戳"),
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "encrypt", value = "加密方式"),
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "sign", value = "签名"),
    })
    public ResponseBean addFace(@RequestParam(value = "userId") Integer userId,
                                @RequestParam(value = "userVerifyId") Integer userVerifyId,
                                @RequestParam(value = "uploadFile") MultipartFile uploadFile) {

        ResponseBean responseBean = new ResponseBean();
        responseBean = faceServiceI.addFace(userId, userVerifyId, uploadFile);
        return responseBean;

    }


    @RequestMapping(value = "/face", method = RequestMethod.PUT)
    @ApiOperation(value = "修改人脸" , notes = "修改人脸")
    @ApiImplicitParams({
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "form", name = "userId", value = "用户Id"),
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "form", name = "userVerifyId", value = "房产审核Id"),
            @ApiImplicitParam(dataTypeClass = MultipartFile.class, paramType = "form", name = "uploadFile", value = "图片"),
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "appid", value = "appid"),
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "datetime", value = "时间戳"),
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "encrypt", value = "加密方式"),
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "sign", value = "签名"),
    })
    public ResponseBean updateFace(@RequestParam(value = "userId") Integer userId,
                                @RequestParam(value = "userVerifyId") Integer userVerifyId,
                                @RequestParam(value = "uploadFile") MultipartFile uploadFile) {

        ResponseBean responseBean = new ResponseBean();
        responseBean = faceServiceI.updateFace(userId, userVerifyId, uploadFile);
        return responseBean;

    }

    @RequestMapping(value = "/face", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除人脸" , notes = "删除人脸")
    @ApiImplicitParams({
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "form", name = "userId", value = "用户Id"),
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "form", name = "userVerifyId", value = "房产审核Id"),
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "appid", value = "appid"),
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "datetime", value = "时间戳"),
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "encrypt", value = "加密方式"),
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "sign", value = "签名"),
    })
    public ResponseBean deleteFace(@RequestParam(value = "userId") Integer userId,
                                   @RequestParam(value = "userVerifyId") Integer userVerifyId) {

        ResponseBean responseBean = new ResponseBean();
        responseBean = faceServiceI.deleteFace(userId, userVerifyId);
        return responseBean;

    }


    @RequestMapping(value = "/face", method = RequestMethod.GET)
    @ApiOperation(value = "查询人脸信息" , notes = "查询人脸信息")
    @ApiImplicitParams({
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "query", name = "userId", value = "用户Id"),
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "query", name = "userVerifyId", value = "房产审核Id"),
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "appid", value = "appid"),
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "datetime", value = "时间戳"),
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "encrypt", value = "加密方式"),
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "sign", value = "签名"),
    })
    public ResponseBean getTaFaceByUserId(@RequestParam(value = "userId") Integer userId,
                                   @RequestParam(value = "userVerifyId") Integer userVerifyId) {

        ResponseBean responseBean = new ResponseBean();
        responseBean = faceServiceI.getTaFaceByUserId(userId, userVerifyId);
        return responseBean;

    }

}
