package com.njcn.msgpush.module.push.controller.admin.credential;

import com.njcn.msgpush.framework.common.pojo.CommonResult;
import com.njcn.msgpush.module.push.dal.dataobject.credential.dto.CredentialReqDTO;
import com.njcn.msgpush.module.push.dal.dataobject.credential.dto.CredentialRespDTO;
import com.njcn.msgpush.module.push.service.credential.ICredentialService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.security.PermitAll;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统凭证 API 接口
 *
 * @author msgpush
 */
@Tag(name = "系统凭证管理")
@RestController
@RequestMapping("/push/credential")
public class CredentialController {

    @Autowired
    private ICredentialService credentialService;

    @PermitAll
    @PostMapping("/generate")
    @Operation(summary = "生成系统凭证")
    public CommonResult<CredentialRespDTO> generateCredential(@Valid @RequestBody CredentialReqDTO reqDTO) {
        CredentialRespDTO respDTO = credentialService.generateCredential(reqDTO);
        return CommonResult.success(respDTO);
    }
}