修改资源列表显示错误
This commit is contained in:
parent
747ccb093b
commit
4977872d98
@ -104,10 +104,11 @@ class ResourcesController extends BaseController
|
|||||||
'cate' => input('post.cate'),
|
'cate' => input('post.cate'),
|
||||||
'icon' => input('post.icon'),
|
'icon' => input('post.icon'),
|
||||||
'url' => input('post.url'),
|
'url' => input('post.url'),
|
||||||
|
'fileurl' => input('post.fileurl'),
|
||||||
'code' => input('post.code'),
|
'code' => input('post.code'),
|
||||||
'uploader' => input('post.uploader'),
|
'uploader' => input('post.uploader'),
|
||||||
'desc' => input('post.desc'),
|
'desc' => input('post.desc'),
|
||||||
'status' => input('post.status', 2),
|
'status' => input('post.status', 1),
|
||||||
'create_time' => time()
|
'create_time' => time()
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -130,6 +131,64 @@ class ResourcesController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑资源
|
||||||
|
*/
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
if (Request::isPost()) {
|
||||||
|
$data = input('post.');
|
||||||
|
$id = input('id/d', 0);
|
||||||
|
|
||||||
|
if (!$id) {
|
||||||
|
Log::record('编辑资源', 0, '参数错误', '资源管理');
|
||||||
|
return json(['code' => 1, 'msg' => '参数错误']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$updateData = [
|
||||||
|
'title' => $data['title'],
|
||||||
|
'cate' => $data['cate'],
|
||||||
|
'desc' => $data['desc'],
|
||||||
|
'uploader' => $data['uploader'],
|
||||||
|
'icon' => $data['icon'],
|
||||||
|
'fileurl' => $data['fileurl'],
|
||||||
|
'url' => $data['url'],
|
||||||
|
'code' => $data['code'],
|
||||||
|
'sort' => $data['sort'],
|
||||||
|
'update_time' => time()
|
||||||
|
];
|
||||||
|
|
||||||
|
$result = Resource::where('id', $id)
|
||||||
|
->update($updateData);
|
||||||
|
|
||||||
|
if ($result !== false) {
|
||||||
|
Log::record('编辑资源', 1, '', '资源管理');
|
||||||
|
return json(['code' => 0, 'msg' => '编辑成功']);
|
||||||
|
} else {
|
||||||
|
Log::record('编辑资源', 0, '编辑资源失败', '资源管理');
|
||||||
|
return json(['code' => 1, 'msg' => '编辑失败']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = input('id/d', 0);
|
||||||
|
if (!$id) {
|
||||||
|
Log::record('编辑资源', 0, '参数错误', '资源管理');
|
||||||
|
$this->error('参数错误');
|
||||||
|
}
|
||||||
|
|
||||||
|
$resource = Resource::where('id', $id)
|
||||||
|
->where('delete_time', null)
|
||||||
|
->find();
|
||||||
|
|
||||||
|
if (!$resource) {
|
||||||
|
Log::record('编辑资源', 0, '资源不存在', '资源管理');
|
||||||
|
$this->error('资源不存在');
|
||||||
|
}
|
||||||
|
|
||||||
|
View::assign('resource', $resource);
|
||||||
|
return View::fetch();
|
||||||
|
}
|
||||||
|
|
||||||
// 删除资源
|
// 删除资源
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
@ -309,64 +368,6 @@ class ResourcesController extends BaseController
|
|||||||
return json(['code' => 0, 'msg' => '获取成功', 'data' => $resource]);
|
return json(['code' => 0, 'msg' => '获取成功', 'data' => $resource]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 编辑资源
|
|
||||||
*/
|
|
||||||
public function edit()
|
|
||||||
{
|
|
||||||
if (Request::isPost()) {
|
|
||||||
$data = input('post.');
|
|
||||||
$id = input('id/d', 0);
|
|
||||||
|
|
||||||
if (!$id) {
|
|
||||||
Log::record('编辑资源', 0, '参数错误', '资源管理');
|
|
||||||
return json(['code' => 1, 'msg' => '参数错误']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$updateData = [
|
|
||||||
'title' => $data['title'],
|
|
||||||
'cate' => $data['cate'],
|
|
||||||
'desc' => $data['desc'],
|
|
||||||
'uploader' => $data['uploader'],
|
|
||||||
'icon' => $data['icon'],
|
|
||||||
'fileurl' => $data['fileurl'],
|
|
||||||
'url' => $data['url'],
|
|
||||||
'code' => $data['code'],
|
|
||||||
'sort' => $data['sort'],
|
|
||||||
'update_time' => time()
|
|
||||||
];
|
|
||||||
|
|
||||||
$result = Resource::where('id', $id)
|
|
||||||
->update($updateData);
|
|
||||||
|
|
||||||
if ($result !== false) {
|
|
||||||
Log::record('编辑资源', 1, '', '资源管理');
|
|
||||||
return json(['code' => 0, 'msg' => '编辑成功']);
|
|
||||||
} else {
|
|
||||||
Log::record('编辑资源', 0, '编辑资源失败', '资源管理');
|
|
||||||
return json(['code' => 1, 'msg' => '编辑失败']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$id = input('id/d', 0);
|
|
||||||
if (!$id) {
|
|
||||||
Log::record('编辑资源', 0, '参数错误', '资源管理');
|
|
||||||
$this->error('参数错误');
|
|
||||||
}
|
|
||||||
|
|
||||||
$resource = Resource::where('id', $id)
|
|
||||||
->where('delete_time', null)
|
|
||||||
->find();
|
|
||||||
|
|
||||||
if (!$resource) {
|
|
||||||
Log::record('编辑资源', 0, '资源不存在', '资源管理');
|
|
||||||
$this->error('资源不存在');
|
|
||||||
}
|
|
||||||
|
|
||||||
View::assign('resource', $resource);
|
|
||||||
return View::fetch();
|
|
||||||
}
|
|
||||||
|
|
||||||
//统计资源数量
|
//统计资源数量
|
||||||
public function counts()
|
public function counts()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -60,11 +60,7 @@
|
|||||||
{{# if(d.status == '0'){ }}
|
{{# if(d.status == '0'){ }}
|
||||||
<span style="color:red;">未审核</span>
|
<span style="color:red;">未审核</span>
|
||||||
{{# } else if(d.status == '1'){ }}
|
{{# } else if(d.status == '1'){ }}
|
||||||
<span style="color:orange;">待审核</span>
|
<span style="color:orange;">已审核</span>
|
||||||
{{# } else if(d.status == '2'){ }}
|
|
||||||
<span style="color:green;">已发布</span>
|
|
||||||
{{# } else if(d.status == '3'){ }}
|
|
||||||
<span style="color:gray;">已下架</span>
|
|
||||||
{{# } }}
|
{{# } }}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user