AdminStatusController.php
4.7 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <bronet@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;
use app\portal\model\ConditionModel;
use app\portal\model\VehicleModel;
use cmf\controller\AdminBaseController;
use app\portal\model\PortalPostModel;
use app\portal\service\PostService;
use app\portal\model\PortalCategoryModel;
use think\Db;
use app\admin\model\ThemeModel;
use think\Loader;
// over
class AdminStatusController extends AdminBaseController
{
/**
* 商品状态设置
* @adminMenu(
* 'name' => '商品状态设置',
* 'parent' => 'portal/AdminCommodityCate/default',
* 'display'=> true,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '商品状态设置',
* 'param' => ''
* )
*/
public function index()
{
$data = $this->request->param();
$return = $this->adminIndex($data);
$where_vehicle = $return['where_arr'];
$where_vehicle['status'] = array('neq',9);
$list = Db::name('Condition')
->where($where_vehicle)
->order('score desc,create_time desc')
->paginate(10,false,['query'=>$return['page_arr']]);
$page = $list->render();
$this->assign('page', $page);
$this->assign('list', $list);
return $this->fetch();
}
/**
* 添加商品状态
* @adminMenu(
* 'name' => '添加商品状态',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> false,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '添加商品状态',
* 'param' => ''
* )
*/
public function add()
{
if ($this->request->isPost()) {
$model = new ConditionModel();
$data = $this->request->param();
if(empty($data['content'])){
$this->error('商品状态不能为空');
}
$res_save = $model->save($data);
if($res_save){
$this->success('添加成功',url('index'));
}else{
$this->error('添加失败');
}
}else{
return $this->fetch();
}
}
/**
* 编辑商品状态
* @adminMenu(
* 'name' => '编辑商品状态',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '编辑商品状态',
* 'param' => ''
* )
*/
public function edit()
{
$id = $this->request->param('id', 0, 'intval');
$where_vehicle['id'] = $id;
$post = Db::name('Condition')->where($where_vehicle)->find();
if($post){
$post['content'] = htmlspecialchars_decode($post['content']);
}
$this->assign('post', $post);
return $this->fetch();
}
/**
* 编辑商品状态提交
* @adminMenu(
* 'name' => '编辑商品状态提交',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> false,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '编辑商品状态提交',
* 'param' => ''
* )
*/
public function editPost()
{
if ($this->request->isPost()) {
$data = $this->request->param();
$model = new ConditionModel();
if(empty($data['content'])){
$this->error('商品状态不能为空');
}
$res_save = $model->isUpdate(true)->save($data);
if($res_save){
$this->success('添加成功',url('index'));
}else{
$this->error('添加失败');
}
}
}
/**
* 商品状态删除
* @adminMenu(
* 'name' => '商品状态删除',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> false,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '商品状态删除',
* 'param' => ''
* )
*/
public function delete()
{
$model = new ConditionModel();
$this->adminDel($model);
}
}