切换导航条
此项目
正在载入...
登录
周海龙
/
mail-serve
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
邓超
about a month ago
提交
19ad418980fc975e8aca76d2fdbe3f7dacbae298
1 个父辈
8f611a8f
es
显示空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
16 行增加
和
36 行删除
event/SyncMailToEs.php
lib/DbQuery.php
event/SyncMailToEs.php
查看文件 @
19ad418
...
...
@@ -45,7 +45,7 @@ class SyncMailToEs {
public
$es
;
public
function
handler
(){
$this
->
es
=
new
Es
(
'hg_ai_emails'
);
//
$this->es = new Es('hg_ai_emails');
if
(
in_array
(
$this
->
table
,[
'lists'
,
'lists_auto'
,
'lists_hot'
])){
if
(
$this
->
type
==
'create'
){
...
...
@@ -70,16 +70,18 @@ class SyncMailToEs {
return
;
}
else
if
(
$this
->
table
==
'lists'
){
$id
=
$this
->
data
[
'email_id'
]
.
'_'
.
$this
->
data
[
'folder_id'
]
.
'_'
.
$this
->
data
[
'uid'
];
if
(
empty
(
$this
->
data
[
'is_auto'
])){
$this
->
data
[
'is_auto'
]
=
0
;
}
$this
->
es
->
save
(
$id
,
$this
->
getData
(
$this
->
data
));
redis
()
->
rPush
(
'sync_to_es'
,
$this
->
data
[
'id'
]);
// $id = $this->data['email_id'].'_'.$this->data['folder_id'].'_'.$this->data['uid'];
// if(empty($this->data['is_auto'])){
// $this->data['is_auto'] = 0;
// }
// $this->es->save($id,$this->getData($this->data));
}
else
if
(
$this
->
table
==
'lists_auto'
){
$data
=
db
()
->
first
(
listsSql
::
first
(
'`id` = '
.
$this
->
data
[
'list_id'
]));
$id
=
$data
[
'email_id'
]
.
'_'
.
$data
[
'folder_id'
]
.
'_'
.
$data
[
'uid'
];
$this
->
es
->
save
(
$id
,
$this
->
getData
(
$data
));
redis
()
->
rPush
(
'sync_to_es'
,
$this
->
data
[
'list_id'
]);
// $data = db()->first(listsSql::first('`id` = '.$this->data['list_id']));
// $id = $data['email_id'].'_'.$data['folder_id'].'_'.$data['uid'];
// $this->es->save($id,$this->getData($data));
}
}
...
...
@@ -95,39 +97,17 @@ class SyncMailToEs {
// }
if
(
$this
->
table
==
'lists'
){
// 更新es
$lists
=
db
()
->
all
(
listsSql
::
all
(
$this
->
where
));
$lists
=
db
()
->
all
(
listsSql
::
all
(
$this
->
where
,
'`id`'
));
foreach
(
$lists
as
$list
){
$id
=
$list
[
'email_id'
]
.
'_'
.
$list
[
'folder_id'
]
.
'_'
.
$list
[
'uid'
];
$this
->
es
->
save
(
$id
,
$this
->
getData
(
$list
));
redis
()
->
rPush
(
'sync_to_es'
,
$list
[
'id'
]);
// $id = $list['email_id'].'_'.$list['folder_id'].'_'.$list['uid'];
// $this->es->save($id,$this->getData($list));
}
}
}
public
function
getData
(
$data
){
if
(
!
empty
(
$data
[
'id'
])){
$data
[
'uuid'
]
=
$data
[
'id'
];
unset
(
$data
[
'id'
]);
}
if
(
!
empty
(
$data
[
'from'
])){
$data
[
'from'
]
=
[
'email'
=>
$data
[
'from'
],
'name'
=>
$data
[
'from_name'
]
??
''
];
unset
(
$data
[
'from_name'
]);
}
unset
(
$data
[
'date'
]);
if
(
!
empty
(
$data
[
'created_at'
])){
$data
[
'created_at'
]
=
date
(
'Y-m-d\TH:i:s'
,
strtotime
(
$data
[
'created_at'
]));
}
if
(
!
empty
(
$data
[
'updated_at'
])){
$data
[
'updated_at'
]
=
date
(
'Y-m-d\TH:i:s'
,
strtotime
(
$data
[
'updated_at'
]));
}
$data
[
'references'
]
=
empty
(
$data
[
'references'
])
?
''
:
$data
[
'references'
];
return
$data
;
}
...
...
lib/DbQuery.php
查看文件 @
19ad418
...
...
@@ -218,7 +218,7 @@ trait DbQuery {
$query
=
$this
->
query
([
$sql
,
$data
]);
if
(
$query
){
$data
[
'
uu
id'
]
=
$this
->
getClient
()
->
lastInsertId
();
$data
[
'id'
]
=
$this
->
getClient
()
->
lastInsertId
();
// es 同步数据
\Event\Event
::
call
(
'\Event\SyncMailToEs'
,
'create'
,
$table
,
$data
);
return
true
;
...
...
请
注册
或
登录
后发表评论