package com.zhongshu.card.server.core.controller.projectAbout;

import com.github.microservice.auth.security.annotations.ResourceAuth;
import com.github.microservice.auth.security.type.AuthType;
import com.github.microservice.net.ResultContent;
import com.zhongshu.card.client.model.base.UserIdAndOidModel;
import com.zhongshu.card.client.model.projectAbout.OrgUserFaceModel;
import com.zhongshu.card.client.model.projectAbout.OrgUserFaceParam;
import com.zhongshu.card.server.core.service.projectAbout.OrgUserFaceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 项目人员人脸管理
 *
 * @author TRX
 * @date 2024/7/26
 */
@RestController
@RequestMapping("/orgUserFace")
@Tag(name = "项目-用户人脸设置")
public class OrgUserFaceController {

    @Autowired
    private OrgUserFaceService orgUserFaceService;

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "保存人脸信息", description = "保存人脸信息")
    @RequestMapping(value = "saveFace", method = {RequestMethod.POST})
    public ResultContent saveFace(@RequestBody @Valid OrgUserFaceParam param) {
        return orgUserFaceService.saveFace(param);
    }

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "得到用户人脸信息", description = "得到用户人脸信息")
    @RequestMapping(value = "getUserFace", method = {RequestMethod.POST})
    public ResultContent<OrgUserFaceModel> getUserFace(@RequestBody @Valid UserIdAndOidModel param) {
        return orgUserFaceService.getUserFaceModel(param.getUserId(), param.getProjectOid());
    }

}
