package cn.reghao.tnb.auth.app.controller;

import cn.reghao.tnb.common.web.WebResult;
import cn.reghao.tnb.auth.api.dto.AccountRegistry;
import cn.reghao.tnb.auth.api.dto.AccountRegistryStatus;
import cn.reghao.tnb.auth.api.iface.AdminAccountService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author reghao
 * @date 2025-10-22 15:38:20
 */
@Tag(name = "account 管理接口")
@RestController
@RequestMapping("/api/admin/account")
public class AdminAccountController {
    private final AdminAccountService adminAccountService;

    public AdminAccountController(AdminAccountService adminAccountService) {
        this.adminAccountService = adminAccountService;
    }

    @Operation(summary = "帐号注册", description = "N")
    @GetMapping(value = "/account_registry", produces = MediaType.APPLICATION_JSON_VALUE)
    public String getAccountRegistry() {
        AccountRegistry accountRegistry = adminAccountService.getAccountRegistry();
        return WebResult.success(accountRegistry);
    }

    @Operation(summary = "帐号注册", description = "N")
    @PostMapping(value = "/registry", produces = MediaType.APPLICATION_JSON_VALUE)
    public String setAccountRegistry(@RequestBody @Validated AccountRegistryStatus accountRegistryStatus) {
        adminAccountService.setAccountRegistry(accountRegistryStatus);
        return WebResult.success();
    }

    @Operation(summary = "帐号注册", description = "N")
    @PostMapping(value = "/code", produces = MediaType.APPLICATION_JSON_VALUE)
    public String setAccountCode(@RequestBody @Validated AccountRegistryStatus accountRegistryStatus) {
        adminAccountService.setAccountCode(accountRegistryStatus);
        return WebResult.success();
    }
}
