import 'package:fis_jsonrpc/rpc.dart';

import '../mock_db.dart';

class UserServiceMock extends UserService {
  UserServiceMock(String host) : super(host);

  @override
  Future<List<UserDTO>> getUserList(GetUserListRequest request) async {
    // return super.getUserInfoAsync(request);
    print(request);
    return mockDb.userList ??= _createMockUserList();
  }

  @override
  Future<bool> removeUsersFromOrganization(
      RemoveUsersFromOrganizationRequest request) async {
    print(request.userCodes);
    List<UserDTO> userList = [];
    for (var i in request.userCodes!) {
      mockDb.userList!.removeWhere((e) {
        return e.userCode == i;
      });
    }
    // mockDb.UserList ?? _createMockUserList();
    // return super.getUserInfoAsync(request);
    return true;
  }

  @override
  Future<bool> alterUserInfoAsync(AlterUserInfoRequest request) async {
    return super.alterUserInfoAsync(request);
  }

  List<UserDTO> _createMockUserList() {
    return [
      UserDTO(
        userCode: "1",
        phone: "18033388444",
        nickName: 'JACK',
        fullName: "Mock_User_JACK",
        organizationCode: "主管",
        rootOrganizationCode: "主任医师",
        lastIP: '1',
      ),
      UserDTO(
        userCode: "2",
        phone: "18045334444",
        nickName: 'TOM',
        fullName: "Mock_User_TOM",
        organizationCode: "普通员工",
        rootOrganizationCode: "主任",
        lastIP: '1',
      ),
      UserDTO(
        userCode: "3",
        phone: "18033334114",
        nickName: 'SRT',
        fullName: "Mock_User_SRT",
        organizationCode: "普通员工",
        rootOrganizationCode: "医师",
        lastIP: '2',
      ),
      UserDTO(
        userCode: "4",
        phone: "18033334114",
        nickName: 'ALL',
        fullName: "Mock_User_ALL",
        organizationCode: "主管",
        rootOrganizationCode: "医师",
        lastIP: '2',
      ),
      UserDTO(
        userCode: "5",
        phone: "18033334114",
        nickName: 'MAL',
        fullName: "Mock_User_MAL",
        organizationCode: "普通员工",
        rootOrganizationCode: "主治医师",
        lastIP: '2',
      ),
      UserDTO(
        userCode: "6",
        phone: "18033334114",
        nickName: 'TASK',
        fullName: "Mock_User_TASK",
        organizationCode: "普通员工",
        rootOrganizationCode: "医师",
        lastIP: '4',
      ),
      UserDTO(
        userCode: "7",
        phone: "18033334114",
        nickName: 'ADK',
        fullName: "Mock_User_ADK",
        organizationCode: "普通员工",
        rootOrganizationCode: "主治医师",
        lastIP: '2',
      ),
      UserDTO(
        userCode: "8",
        phone: "17355327973",
        nickName: 'DWE',
        fullName: "Mock_User_DWE",
        organizationCode: "普通员工",
        rootOrganizationCode: "主治医师",
        lastIP: '4',
      ),
      UserDTO(
        userCode: "9",
        phone: "18033334114",
        nickName: 'FBJ',
        fullName: "Mock_User_FBJ",
        organizationCode: "普通员工",
        rootOrganizationCode: "医师",
        lastIP: '4',
      ),
      UserDTO(
        userCode: "10",
        phone: "18033334114",
        nickName: 'OBI',
        fullName: "Mock_User_OBI",
        organizationCode: "普通员工",
        rootOrganizationCode: "主任医师",
        lastIP: '2',
      ),
      UserDTO(
        userCode: "11",
        phone: "18033334114",
        nickName: 'ROLE',
        fullName: "Mock_User_ROLE",
        organizationCode: "普通员工",
        rootOrganizationCode: "医师",
        lastIP: '3',
      ),
      UserDTO(
        userCode: "12",
        phone: "18033334114",
        nickName: 'BOOL',
        fullName: "Mock_User_BOOL",
        organizationCode: "主管",
        rootOrganizationCode: "医师",
        lastIP: '2',
      ),
      UserDTO(
        userCode: "13",
        phone: "18033334114",
        nickName: 'OBJ',
        fullName: "Mock_User_OBJ",
        organizationCode: "主管",
        rootOrganizationCode: "主任医师",
        lastIP: '2',
      ),
      UserDTO(
        userCode: "14",
        phone: "18033334114",
        nickName: 'LIST',
        fullName: "Mock_User_LIST",
        organizationCode: "普通员工",
        rootOrganizationCode: "主任医师",
        lastIP: '2',
      ),
      UserDTO(
        userCode: "15",
        phone: "18033334114",
        nickName: 'RETAKE',
        fullName: "Mock_User_RETAKE",
        organizationCode: "主管",
        rootOrganizationCode: "医师",
        lastIP: '2',
      ),
      UserDTO(
        userCode: "16",
        phone: "18033334114",
        nickName: 'MOVE',
        fullName: "Mock_User_MOVE",
        organizationCode: "普通员工",
        rootOrganizationCode: "主任医师",
        lastIP: '2',
      ),
      UserDTO(
        userCode: "17",
        phone: "18033334114",
        nickName: 'LIKE',
        fullName: "Mock_User_LIKE",
        organizationCode: "主管",
        rootOrganizationCode: "医师",
        lastIP: '2',
      ),
      UserDTO(
        userCode: "18",
        phone: "18033334114",
        nickName: 'UDK',
        fullName: "Mock_User_UDK",
        organizationCode: "主管",
        rootOrganizationCode: "主任医师",
        lastIP: '2',
      ),
      UserDTO(
        userCode: "19",
        phone: "18033334114",
        nickName: 'LSIY',
        fullName: "Mock_User_LSIY",
        organizationCode: "普通员工",
        rootOrganizationCode: "医师",
        lastIP: '2',
      ),
      UserDTO(
        userCode: "20",
        phone: "18033334114",
        nickName: 'DAKE',
        fullName: "Mock_User_DAKE",
        organizationCode: "普通员工",
        rootOrganizationCode: "主任医师",
        lastIP: '2',
      ),
      UserDTO(
        userCode: "21",
        phone: "18033334114",
        nickName: 'KKKKDS',
        fullName: "Mock_User_KKKKDS",
        organizationCode: "主管",
        rootOrganizationCode: "主任医师",
        lastIP: '2',
      ),
      UserDTO(
        userCode: "22",
        phone: "18033334114",
        nickName: 'ODEEIE',
        fullName: "Mock_User_ODEEIE",
        organizationCode: "主管",
        rootOrganizationCode: "医师",
        lastIP: '2',
      ),
      UserDTO(
        userCode: "23",
        phone: "18033334114",
        nickName: 'JDFER',
        fullName: "Mock_User_JDFER",
        organizationCode: "普通员工",
        rootOrganizationCode: "医师",
        lastIP: '2',
      ),
    ];
  }
}
