WebSettingTextLogic.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
<?php
namespace App\Http\Logic\Bside\Setting;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\WebSetting\WebSetting;
use App\Models\WebSetting\WebSettingText;
use Illuminate\Support\Facades\DB;
class WebSettingTextLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new WebSettingText();
$this->param = $this->requestAll;
}
/**
* @name :(查询设置详情)setting_read
* @author :lyh
* @method :post
* @time :2023/5/8 15:56
*/
public function setting_read(){
$web_setting = new WebSetting();
$setting_info = $web_setting->read(['project_id'=>$this->user['project_id']],['anchor_setting','anchor_is_enable','anchor_num']);
return $setting_info;
}
/**
* @name :(描文本详情)setting_text_lists
* @author :lyh
* @method :post
* @time :2023/5/8 14:18
*/
public function setting_text_lists(){
$lists['data'] = $this->model->list(['project_id'=>$this->user['project_id']],'created_at',['key_words','url']);
$lists['anchor_info'] = $this->setting_read();
$anchor_text = $this->model->anchor_text;
$lists['anchor_text'] = $anchor_text;
return $this->success($lists);
}
/**
* @name :(设置描文本)setting_text_save
* @author :lyh
* @method :post
* @time :2023/5/8 14:39
*/
public function setting_text_save(){
$web_setting = new WebSetting();
if(count($this->param['data']) > $this->param['anchor_num']){
$this->fail('超过最大设置限制');
}
DB::beginTransaction();
try {
//更新描文本设置
$data = [
'anchor_setting'=>$this->param['anchor_setting'],
'anchor_is_enable'=>$this->param['anchor_is_enable'],
'anchor_num'=>$this->param['anchor_num']
];
$web_setting->edit($data,['project_id'=>$this->user['project_id']]);
$this->model->del(['project_id'=>$this->user['project_id']]);
foreach ($this->param['data'] as $k => $v){
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$v['project_id'] = $this->user['project_id'];
$this->param['data'][$k] = $v;
}
$this->model->insert($this->param['data']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('更新失败');
}
$this->success();
}
}