AutoEmailContentController.php
2.0 KB
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
<?php
/**
* @remark :
* @name :AutoEmailContentController.php
* @author :lyh
* @method :post
* @time :2024/12/30 14:09
*/
namespace App\Http\Controllers\Bside\Subscribe;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Models\Project\AutoEmail;
use App\Models\Subscribe\Smtp;
/**
* @remark :项目设置自动回复邮件内容
* @name :AutoEmailContentController
* @author :lyh
* @method :post
* @time :2024/12/30 14:09
*/
class AutoEmailContentController extends BaseController
{
/**
* @remark :获取
* @name :getInfo
* @author :lyh
* @method :post
* @time :2024/12/30 14:10
*/
public function getContent(){
$autoEmailModel = new AutoEmail();
$lists = $autoEmailModel->list(['project_id'=>$this->user['project_id']]);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :保存详情
* @name :saveContent
* @author :lyh
* @method :post
* @time :2024/12/30 14:11
*/
public function saveContent(){
$this->request->validate([
'content' => ['required'],
], [
'content.required' => '内容不能为空',
]);
$smtpModel = new Smtp();
$smtpInfo = $smtpModel->read(['project_id' => $this->user['project_id']]);
if($smtpInfo === false){
$this->fail('请先设置SMTP',Code::USER_ERROR);
}
$autoEmailModel = new AutoEmail();
$info = $autoEmailModel->read(['project_id'=>$this->user['project_id']]);
if($info === false){
//执行新增
$data = ['project_id'=>$this->user['project_id'],['title'=>$this->param['title'],'content'=>$this->param['content']];
$id = $autoEmailModel->addReturnId($data);
}else{
$id = $info['id'];
$autoEmailModel->edit(['title'=>$this->param['title'],'content'=>$this->param['content']],['project_id'=>$this->user['project_id']]);
}
$this->response('success',Code::SUCCESS,['id'=>$id]);
}
}