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 16 #ifndef OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_OS_ACCOUNT_DATABSE_OPERATOR_H 17 #define OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_OS_ACCOUNT_DATABSE_OPERATOR_H 18 19 #include <memory> 20 #include "account_data_storage.h" 21 #include "ios_account_control.h" 22 23 namespace OHOS { 24 namespace AccountSA { 25 class OsAccountDatabaseOperator { 26 public: 27 OsAccountDatabaseOperator(); 28 virtual ~OsAccountDatabaseOperator(); 29 30 // update infos to database 31 void UpdateOsAccountIDListInDatabase(const Json &accountListJson); 32 void UpdateOsAccountInDatabase(const OsAccountInfo &osAccountInfo); 33 void InsertOsAccountIntoDataBase(const OsAccountInfo &osAccountInfo); 34 void DelOsAccountFromDatabase(const int id); 35 36 ErrCode GetCreatedOsAccountNumFromDatabase(const std::string &storeID, int &createdOsAccountNum); 37 ErrCode GetSerialNumberFromDatabase(const std::string &storeID, int64_t &serialNumber); 38 ErrCode GetMaxAllowCreateIdFromDatabase(const std::string &storeID, int &id); 39 ErrCode GetOsAccountFromDatabase(const std::string &storeID, const int id, OsAccountInfo &osAccountInfo); 40 ErrCode GetOsAccountListFromDatabase(const std::string &storeID, std::vector<OsAccountInfo> &osAccountList); 41 ErrCode GetAccountListFromStoreID(const std::string &storeID, Json &accountListJson); 42 43 private: 44 ErrCode SaveAccountListToDatabase(const Json &accountListJson); 45 bool InnerInit(); 46 47 private: 48 std::shared_ptr<AccountDataStorage> accountDataStorage_ = nullptr; 49 }; 50 } // namespace AccountSA 51 } // namespace OHOS 52 53 #endif // OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_OS_ACCOUNT_CONTROL_DATABSE_MANAGER_H