WebSettingLogic.php
2.6 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
72
73
74
75
76
77
78
79
80
81
82
83
<?php
namespace App\Http\Logic\Bside\Setting;
use App\Helper\Common as CommonHelper;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\UpdateNotify;
use App\Models\WebSetting\WebSetting;
class WebSettingLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new WebSetting();
$this->param = $this->requestAll;
}
/**
* @name :(获取首页设置)setting_read
* @author :lyh
* @method :post
* @time :2023/4/28 15:14
*/
public function setting_read(){
$info = CommonHelper::get_user_cache($this->model->getTable(),$this->user['project_id']);
if(empty($info)){
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->fail('当前数据不存在');
}
CommonHelper::set_user_cache($info,$this->model->getTable(),$this->user['project_id']);
}
return $this->success($info);
}
/**
* @name :(添加或编辑)setting_save
* @author :lyh
* @method :post
* @time :2023/4/28 15:18
*/
public function setting_save(){
//查看数据是否存在
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->param['project_id'] = $this->user['project_id'];
$rs = $this->model->add($this->param);
}else{
$rs = $this->model->edit($this->param,['project_id'=>$this->user['project_id']]);
}
if($rs === false){
$this->fail('error');
}
CommonHelper::del_user_cache($this->model->getTable(),$this->user['project_id']);
return $this->success();
}
/**
* @remark :通知c端
* @name :sendNotifyMessage
* @author :lyh
* @method :post
* @time :2023/8/1 9:36
*/
public function sendNotifyMessage(){
//获取当前项目所有未处理的更新并更换为1:处理中 2:处理完成
$updateNotifyModel = new UpdateNotify();
$list = $updateNotifyModel->list(['project_id'=>$this->user['project_id'],'status'=>1]);
if(!empty($list)){
return $this->success($list);
}
$updateNotifyModel->edit(['status'=>1],['project_id'=>$this->user['project_id'],'status'=>0]);
$urlStr = $this->user['domain'].'api/updateHtmlNotify?project_id='.$this->user['project_id'];
$res = http_get($urlStr);
var_dump(
$res
);
die();
return $this->success();
}
}