a
554325746@qq.com
2019-12-25 603cb36a5123e46656b06a5deb8d7ac7ff81307f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
%%%-------------------------------------------------------------------
%%% @author bsk
%%% @copyright (C) 2018, <COMPANY>
%%% @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).