package cn.reghao.oss.console.app.controller.page;

import cn.reghao.jutil.jdk.result.Result;
import cn.reghao.jutil.jdk.result.WebResult;
import cn.reghao.oss.console.app.service.UserKeyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

/**
 * @author reghao
 * @date 2024-02-27 10:59:07
 */
@Api(tags = "用户帐号接口")
@RestController
@RequestMapping("/api/store/my/key")
public class UserKeyController {
    private final UserKeyService userKeyService;

    public UserKeyController(UserKeyService userKeyService) {
        this.userKeyService = userKeyService;
    }

    @ApiOperation(value = "创建帐号")
    @PostMapping(value = "/create", produces = MediaType.APPLICATION_JSON_VALUE)
    public String create() {
        Result result = userKeyService.create();
        return WebResult.result(result);
    }

    @ApiOperation(value = "删除帐号")
    @DeleteMapping(value = "/delete/{accessKeyId}", produces = MediaType.APPLICATION_JSON_VALUE)
    public String delete(@PathVariable("accessKeyId") String accessKeyId) {
        userKeyService.delete(accessKeyId);
        return WebResult.success();
    }
}
