%%%------------------------------------------------------------------- %%% @author bsk %%% @copyright (C) 2018, %%% @doc %%% %%% @end %%% Created : 05. 十二月 2018 下午4:08 %%%------------------------------------------------------------------- -module(clusterInfo_esql). -author("bsk"). -compile(export_all). -include("esqltool.hrl"). create_ClusterInfoTable(Nodes, TableName) -> ok. add_ClusterInfo(CluId, CluName) -> if CluId == " " -> ID = syncTool:getUUIDString(); CluId == "" -> ID = syncTool:getUUIDString(); true -> ID = CluId end, UpdateTime = syncTool:getTimeStr(), CreateUser = node(), StrUuid = syncTool:change2Str(ID), StrCluName = syncTool:change2Str(CluName), StrCreateUser = syncTool:change2Str(CreateUser), %% StrUuid = StrCreateUser, %% StrCluName = StrCreateUser, Sql = ["INSERT OR REPLACE INTO cluster_info (cluster_id, cluster_name, update_time, create_by) VALUES ('"++ StrUuid++ "','"++ StrCluName++ "','"++ UpdateTime++ "','"++ StrCreateUser++ "');"], Ret = executeSqlLocalyAndSaveToCacheAndSendSql(Sql), %% io:format("add_ClusterInfo ~p~n", [Ret]), if Ret == {atomic, ok} -> Result = {atomic, ok}; true -> Result = {aborted, error} end, Result. update_ClusterInfo(CluId, CluName) -> UpdateTime = syncTool:getTimeStr(), StrUuid = syncTool:change2Str(CluId), StrCluName = syncTool:change2Str(CluName), Sql = ["UPDATE cluster_info SET cluster_name = '", StrCluName, "', update_time = '", UpdateTime, "' WHERE cluster_id = '", StrUuid, "';"], io:format("update_ClusterInfo Sql is ~p", [Sql]), Ret = executeSqlLocalyAndSaveToCacheAndSendSql(Sql), if Ret == {atomic, ok} -> Result = {atomic, ok}; true -> Result = {aborted, error} end, Result. del_ClusterInfo(CluId) -> StrUuid = syncTool:change2Str(CluId), Sql = ["DELETE FROM cluster_info WHERE cluster_id = '", StrUuid, "';"], executeSqlLocalyAndSaveToCacheAndSendSql(Sql). findClusterInfo(CluId) -> StrUuid = syncTool:change2Str(CluId), Sql = ["SELECT * FROM cluster_info WHERE cluster_id = '", StrUuid, "';"], selectSomeInfoWithSql(Sql).