import { Body, Controller, Get, Inject, Post, Provide } from '@midwayjs/core';
import { DesktopOpConfigService } from '../../service/desktop_op_config.js';
import { DesktopOpConfigEntity } from '../../entity/desktop_op_config.js';

/** desktop_op 全局配置管理接口（id=1 单行模式） */
@Provide()
@Controller('/admin/desktop_op/config')
export class DesktopOpConfigAdminController {
  @Inject()
  service!: DesktopOpConfigService;

  /**
   * 读取当前配置
   * GET /admin/desktop_op/config/info
   */
  @Get('/info')
  async info() {
    return { code: 1000, data: await this.service.info() };
  }

  /**
   * 更新配置（更新后自动 reload SafetyGuard）
   * POST /admin/desktop_op/config/update
   */
  @Post('/update')
  async update(@Body() body: Partial<DesktopOpConfigEntity>) {
    return { code: 1000, data: await this.service.update(body) };
  }
}
