1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_OS_ACCOUNT_DATABSE_OPERATOR_H 16 #define OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_OS_ACCOUNT_DATABSE_OPERATOR_H 17 #include <memory> 18 #include "account_data_storage.h" 19 #include "ios_account_control.h" 20 21 namespace OHOS { 22 namespace AccountSA { 23 class OsAccountDatabaseOperator { 24 public: 25 OsAccountDatabaseOperator(); 26 virtual ~OsAccountDatabaseOperator(); 27 void Init(); 28 29 // update infos to database 30 void UpdateOsAccountIDListInDatabase(const Json &accountListJson); 31 void UpdateOsAccountInDatabase(const OsAccountInfo &osAccountInfo); 32 void InsertOsAccountIntoDataBase(const OsAccountInfo &osAccountInfo); 33 void DelOsAccountFromDatabase(const int id); 34 35 ErrCode GetCreatedOsAccountNumFromDatabase(const std::string& storeID, int &createdOsAccountNum); 36 ErrCode GetSerialNumberFromDatabase(const std::string& storeID, int64_t &serialNumber); 37 ErrCode GetMaxAllowCreateIdFromDatabase(const std::string& storeID, int &id); 38 ErrCode GetOsAccountFromDatabase(const std::string& storeID, const int id, OsAccountInfo &osAccountInfo); 39 ErrCode GetOsAccountListFromDatabase(const std::string& storeID, std::vector<OsAccountInfo> &osAccountList); 40 41 private: 42 ErrCode GetAccountListFromStoreID(const std::string& storeID, Json &accountListJson); 43 ErrCode SaveAccountListToDatabase(const Json &accountListJson); 44 bool InnerInit(); 45 46 private: 47 std::shared_ptr<AccountDataStorage> accountDataStorage_; 48 std::string storeID_; 49 }; 50 } // namespace AccountSA 51 } // namespace OHOS 52 #endif /* OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_OS_ACCOUNT_CONTROL_DATABSE_MANAGER_H */