/**
 * 自助申请照片管理控制器
 * [2026-03-02] 纯新增：独立页面展示所有自助申请用户的办公室照片
 *
 * === 数据流 ===
 * admin-web → 本控制器 → AuthorizationProxyService → authorization-service 内部 API
 * 绕过 CDC，直接读源头数据，保证 officePhotoUrls 100% 准确
 */

import { Controller, Get, Query, Logger, HttpCode, HttpStatus } from '@nestjs/common';
import { AuthorizationProxyService, SelfApplyPhotosResponse } from '../../authorization/authorization-proxy.service';

@Controller('admin/authorization-photos')
export class AuthorizationPhotosController {
  private readonly logger = new Logger(AuthorizationPhotosController.name);

  constructor(
    private readonly authorizationProxyService: AuthorizationProxyService,
  ) {}

  /**
   * 获取自助申请照片列表
   * GET /admin/authorization-photos?page=1&limit=20&roleType=COMMUNITY
   */
  @Get()
  @HttpCode(HttpStatus.OK)
  async getSelfApplyPhotos(
    @Query('page') page?: string,
    @Query('limit') limit?: string,
    @Query('roleType') roleType?: string,
  ): Promise<SelfApplyPhotosResponse> {
    this.logger.debug(
      `[getSelfApplyPhotos] page=${page}, limit=${limit}, roleType=${roleType || 'ALL'}`,
    );

    return this.authorizationProxyService.getSelfApplyPhotos({
      page: Number(page) || 1,
      limit: Number(limit) || 20,
      roleType: roleType || undefined,
    });
  }
}
