import 'package:flyinsono/managers/interfaces/entry.dart';
import 'package:fis_i18n/i18n.dart';
import 'package:fis_jsonrpc/rpc.dart';
import 'package:flyinsono/rpc.dart';
import 'base_manager.dart';

class EntryManager extends BaseManager implements IEntryManager {
  ///获取词条库分页
  @override
  Future<List<ThesaurusDTO>> getThesaurusPage({String keyword = ''}) async {
    final getThesaurusPage = await rpc.report.getThesaurusPageAsync(
      GetThesaurusPageRequest(
        token: token,
        pageIndex: 1,
        pageSize: 100,
        thesaurusName: keyword,
        languageCode: i18nBook.locale.toCodeString('-'),
      ),
    );
    return getThesaurusPage.pageData ?? <ThesaurusDTO>[];
  }

  @override
  Future<List<ThesaurusItemDTO>> getThesaurusItems({
    String? thesaurusCode,
    String? keyword,
  }) async {
    return await rpc.report.getThesaurusItemsAsync(GetThesaurusItemsRequest(
      thesaurusCode: thesaurusCode,
      keyword: keyword,
      token: token,
    ));
  }
}
