package com.sunyard.chsm.controller;

import com.sunyard.chsm.dto.TmkStatus;
import com.sunyard.chsm.model.R;
import com.sunyard.chsm.service.DeviceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 主密钥管理
 *
 * @author liulu
 * @since 2024/11/8
 */
@Slf4j
@RestController
@RequestMapping("/tmk")
public class TmkController {

    @Resource
    private DeviceService deviceService;

    /**
     * 查询主密钥生成状态
     *
     * @return
     */
    @GetMapping("/status")
    public R<TmkStatus> getTMKStatus() {
        TmkStatus status = deviceService.getTMKStatus();
        return R.data(status);
    }

    /**
     * 初始化主密钥
     */
    @PostMapping("/init")
    public R<Void> initTmk() {
        deviceService.initTmk();
        return R.ok();
    }


}
