123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431 |
- import 'aIDiagnosis.m.dart';
- import 'package:fis_jsonrpc/utils.dart';
- import 'package:fis_common/json_convert.dart';
- class AuthenticationRequest extends TokenRequest{
- String? fileName;
- AuthenticationRequest({
- this.fileName,
- String? token,
- }) : super(
- token: token,
- );
- factory AuthenticationRequest.fromJson(Map<String, dynamic> map) {
- return AuthenticationRequest(
- fileName: map['FileName'],
- token: map['Token'],
- );
- }
- Map<String, dynamic> toJson() {
- final map = super.toJson();
- if(fileName != null)
- map['FileName'] = fileName;
- return map;
- }
- }
- enum AccountType {
- Admin,
- User,
- US,
- USBox,
- ThirdParty,
- }
- enum Platform {
- Windows,
- Android,
- Ios,
- }
- enum LoginSource {
- PC,
- Mobile,
- Pad,
- Web,
- }
- class TokenDTO {
- int version;
- String? code;
- AccountType accountType;
- String? accountName;
- Platform platform;
- LoginSource loginSource;
- String? clientId;
- String? loginServer;
- DateTime? createTime;
- DateTime? expiration;
- int ipValue;
- bool isOnline;
- TokenDTO({
- this.version = 0,
- this.code,
- this.accountType = AccountType.Admin,
- this.accountName,
- this.platform = Platform.Windows,
- this.loginSource = LoginSource.PC,
- this.clientId,
- this.loginServer,
- this.createTime,
- this.expiration,
- this.ipValue = 0,
- this.isOnline = false,
- });
- factory TokenDTO.fromJson(Map<String, dynamic> map) {
- return TokenDTO(
- version: map['Version'],
- code: map['Code'],
- accountType: AccountType.values.firstWhere((e) => e.index == map['AccountType']),
- accountName: map['AccountName'],
- platform: Platform.values.firstWhere((e) => e.index == map['Platform']),
- loginSource: LoginSource.values.firstWhere((e) => e.index == map['LoginSource']),
- clientId: map['ClientId'],
- loginServer: map['LoginServer'],
- createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null,
- expiration: map['Expiration'] != null ? DateTime.parse(map['Expiration']) : null,
- ipValue: map['IpValue'],
- isOnline: map['IsOnline'],
- );
- }
- Map<String, dynamic> toJson() {
- final map = Map<String, dynamic>();
- map['Version'] = version;
- if(code != null)
- map['Code'] = code;
- map['AccountType'] = accountType.index;
- if(accountName != null)
- map['AccountName'] = accountName;
- map['Platform'] = platform.index;
- map['LoginSource'] = loginSource.index;
- if(clientId != null)
- map['ClientId'] = clientId;
- if(loginServer != null)
- map['LoginServer'] = loginServer;
- if(createTime != null)
- map['CreateTime'] = JsonRpcUtils.dateFormat(createTime!);
- if(expiration != null)
- map['Expiration'] = JsonRpcUtils.dateFormat(expiration!);
- map['IpValue'] = ipValue;
- map['IsOnline'] = isOnline;
- return map;
- }
- }
- class ApplyTokenRequest {
- AccountType accountType;
- Platform platform;
- LoginSource loginSource;
- String? clientId;
- String? loginServer;
- int ipValue;
- ApplyTokenRequest({
- this.accountType = AccountType.Admin,
- this.platform = Platform.Windows,
- this.loginSource = LoginSource.PC,
- this.clientId,
- this.loginServer,
- this.ipValue = 0,
- });
- factory ApplyTokenRequest.fromJson(Map<String, dynamic> map) {
- return ApplyTokenRequest(
- accountType: AccountType.values.firstWhere((e) => e.index == map['AccountType']),
- platform: Platform.values.firstWhere((e) => e.index == map['Platform']),
- loginSource: LoginSource.values.firstWhere((e) => e.index == map['LoginSource']),
- clientId: map['ClientId'],
- loginServer: map['LoginServer'],
- ipValue: map['IpValue'],
- );
- }
- Map<String, dynamic> toJson() {
- final map = Map<String, dynamic>();
- map['AccountType'] = accountType.index;
- map['Platform'] = platform.index;
- map['LoginSource'] = loginSource.index;
- if(clientId != null)
- map['ClientId'] = clientId;
- if(loginServer != null)
- map['LoginServer'] = loginServer;
- map['IpValue'] = ipValue;
- return map;
- }
- }
- enum CustomerRpcCode {
- Ok,
- TokenNotExist,
- TokenExpired,
- InvalidTokenVersion,
- IPInBlacklist,
- }
- class ValidateTokenResult {
- CustomerRpcCode code;
- TokenDTO? token;
- ValidateTokenResult({
- this.code = CustomerRpcCode.Ok,
- this.token,
- });
- factory ValidateTokenResult.fromJson(Map<String, dynamic> map) {
- return ValidateTokenResult(
- code: CustomerRpcCode.values.firstWhere((e) => e.index == map['Code']),
- token: map['Token'] != null ? TokenDTO.fromJson(map['Token']) : null,
- );
- }
- Map<String, dynamic> toJson() {
- final map = Map<String, dynamic>();
- map['Code'] = code.index;
- if(token != null)
- map['Token'] = token;
- return map;
- }
- }
- class ValidateTokenRequest {
- String? token;
- ValidateTokenRequest({
- this.token,
- });
- factory ValidateTokenRequest.fromJson(Map<String, dynamic> map) {
- return ValidateTokenRequest(
- token: map['Token'],
- );
- }
- Map<String, dynamic> toJson() {
- final map = Map<String, dynamic>();
- if(token != null)
- map['Token'] = token;
- return map;
- }
- }
- class IList<T> {
- TokenDTO? item;
- IList({
- this.item,
- });
- factory IList.fromJson(Map<String, dynamic> map) {
- return IList(
- item: map['Item'] != null ? TokenDTO.fromJson(map['Item']) : null,
- );
- }
- Map<String, dynamic> toJson() {
- final map = Map<String, dynamic>();
- if(item != null)
- map['Item'] = item;
- return map;
- }
- }
- class GetTokensWithClientIdRequest extends BaseRequest{
- String? clientId;
- AccountType accountType;
- GetTokensWithClientIdRequest({
- this.clientId,
- this.accountType = AccountType.Admin,
- }) : super(
- );
- factory GetTokensWithClientIdRequest.fromJson(Map<String, dynamic> map) {
- return GetTokensWithClientIdRequest(
- clientId: map['ClientId'],
- accountType: AccountType.values.firstWhere((e) => e.index == map['AccountType']),
- );
- }
- Map<String, dynamic> toJson() {
- final map = super.toJson();
- if(clientId != null)
- map['ClientId'] = clientId;
- map['AccountType'] = accountType.index;
- return map;
- }
- }
- class GetTokenWithClientIdsRequest extends BaseRequest{
- List<String>? clientIds;
- GetTokenWithClientIdsRequest({
- this.clientIds,
- }) : super(
- );
- factory GetTokenWithClientIdsRequest.fromJson(Map<String, dynamic> map) {
- return GetTokenWithClientIdsRequest(
- clientIds: map['ClientIds'] != null ? map['ClientIds'].cast<String>().toList() : null,
- );
- }
- Map<String, dynamic> toJson() {
- final map = super.toJson();
- if(clientIds != null)
- map['ClientIds'] = clientIds;
- return map;
- }
- }
- class GetTokenWithValuesRequest extends BaseRequest{
- List<String>? tokenValues;
- GetTokenWithValuesRequest({
- this.tokenValues,
- }) : super(
- );
- factory GetTokenWithValuesRequest.fromJson(Map<String, dynamic> map) {
- return GetTokenWithValuesRequest(
- tokenValues: map['TokenValues'] != null ? map['TokenValues'].cast<String>().toList() : null,
- );
- }
- Map<String, dynamic> toJson() {
- final map = super.toJson();
- if(tokenValues != null)
- map['TokenValues'] = tokenValues;
- return map;
- }
- }
- class SetOnlineStateRequest extends TokenRequest{
- bool isOnline;
- SetOnlineStateRequest({
- this.isOnline = false,
- String? token,
- }) : super(
- token: token,
- );
- factory SetOnlineStateRequest.fromJson(Map<String, dynamic> map) {
- return SetOnlineStateRequest(
- isOnline: map['IsOnline'],
- token: map['Token'],
- );
- }
- Map<String, dynamic> toJson() {
- final map = super.toJson();
- map['IsOnline'] = isOnline;
- return map;
- }
- }
- class PageResult<T> {
- int pageIndex;
- int pageSize;
- int totalCount;
- List<T>? pageData;
- PageResult({
- this.pageIndex = 0,
- this.pageSize = 0,
- this.totalCount = 0,
- this.pageData,
- });
- factory PageResult.fromJson(Map<String, dynamic> map) {
- List<T> pageDataList = [];
- if (map['PageData'] != null) {
- pageDataList.addAll(
- (map['PageData'] as List).map((e) => FJsonConvert.fromJson<T>(e)!));
- }
- return PageResult(
- pageIndex: map['PageIndex'],
- pageSize: map['PageSize'],
- totalCount: map['TotalCount'],
- pageData: pageDataList,
- );
- }
- Map<String, dynamic> toJson() {
- final map = Map<String, dynamic>();
- map['PageIndex'] = pageIndex;
- map['PageSize'] = pageSize;
- map['TotalCount'] = totalCount;
- if(pageData != null)
- map['PageData'] = pageData;
- return map;
- }
- }
- class PageRequest extends TokenRequest{
- int pageIndex;
- int pageSize;
- PageRequest({
- this.pageIndex = 0,
- this.pageSize = 0,
- String? token,
- }) : super(
- token: token,
- );
- factory PageRequest.fromJson(Map<String, dynamic> map) {
- return PageRequest(
- pageIndex: map['PageIndex'],
- pageSize: map['PageSize'],
- token: map['Token'],
- );
- }
- Map<String, dynamic> toJson() {
- final map = super.toJson();
- map['PageIndex'] = pageIndex;
- map['PageSize'] = pageSize;
- return map;
- }
- }
- class GetPagedTokensRequest extends PageRequest{
- String? keyword;
- GetPagedTokensRequest({
- this.keyword,
- int pageIndex = 0,
- int pageSize = 0,
- String? token,
- }) : super(
- pageIndex: pageIndex,
- pageSize: pageSize,
- token: token,
- );
- factory GetPagedTokensRequest.fromJson(Map<String, dynamic> map) {
- return GetPagedTokensRequest(
- keyword: map['Keyword'],
- pageIndex: map['PageIndex'],
- pageSize: map['PageSize'],
- token: map['Token'],
- );
- }
- Map<String, dynamic> toJson() {
- final map = super.toJson();
- if(keyword != null)
- map['Keyword'] = keyword;
- return map;
- }
- }
|