TemplateController.php
1.5 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
<?php
namespace App\Http\Controllers\Bside;
use App\Models\Template\ATemplate;
use App\Models\Template\BSetting;
/**
* 模板
* @author:dc
* @time 2023/5/9 14:00
* Class TemplateController
* @package App\Http\Controllers\Bside
*/
class TemplateController extends BaseController
{
/**
* 模板列表
* @return \Illuminate\Http\JsonResponse
* @author:dc
* @time 2023/5/9 14:20
*/
public function index(){
$limit = intval($this->param['limit']??20);
$data = ATemplate::_bAll($limit)->toArray();
return $this->success($data);
}
/**
* 当前使用的模板
* @author:dc
* @time 2023/5/9 15:19
*/
public function info(){
// 保存更新
if($this->isPost()){
$template_id = intval($this->param['template_id']??0);
if($template_id && ATemplate::_bFind($template_id)){
BSetting::_save($this->user['project_id'],$template_id);
}else{
return $this->response('无法使用不存在的模板','B_TEMPLATE_NOTFOUND');
}
}
$conf = BSetting::_get($this->user['project_id']);
$data = ATemplate::_bFind($conf['template_id']);
return $this->success([
'template_id' => $data['id']??0,
'name' => $data['name']??'',
'thumb' => $data['thumb']??'',
'time' => $conf['time']
]);
}
}