package com.sunyard.chsm.controller;

import com.sunyard.chsm.auth.AuthCode;
import com.sunyard.chsm.model.R;
import com.sunyard.chsm.model.dto.KeyInfoDTO;
import com.sunyard.chsm.service.KeyInfoService;
import org.springframework.validation.annotation.Validated;
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;

import javax.annotation.Resource;

/**
 * 密钥管理类接口
 *
 * @author liulu
 * @since 2024/12/6
 */
@RestController
@RequestMapping("/key/manage")
public class KeyManageController {

    @Resource
    private KeyInfoService keyInfoService;

    /**
     * 启用密钥
     *
     * @param param 密钥id
     * @return id
     */
    @PostMapping("/enable")
    @AuthCode("12312312")
    public R<Void> enableKey(@Validated @RequestBody KeyInfoDTO.IDs param) {
        keyInfoService.enableKey(param.getIds());
        return R.ok();
    }

}
