|
@@ -261,32 +261,31 @@ class Action extends BaseController
|
|
|
*/
|
|
|
public function ActionAdd()
|
|
|
{
|
|
|
- $post = $this->request->filter('trim')->post();
|
|
|
- $action_name = isset($post['action_name']) ? trim($post['action_name']) : "";
|
|
|
- if ($action_name == "") {
|
|
|
- return json_show(1001, '功能名称不能为空');
|
|
|
+ $post = $this->request->post();
|
|
|
+
|
|
|
+ $pageid = isset($post['menuid']) ? intval($post['menuid']) : "";
|
|
|
+ if ($pageid == "") {
|
|
|
+ return error_show(1001, '菜单id不能为空');
|
|
|
}
|
|
|
- $action_desc = isset($post['action_desc']) ? trim($post['action_desc']) : "";
|
|
|
$code = isset($post['action_code']) ? trim($post['action_code']) : "";
|
|
|
if ($code == "") {
|
|
|
- return json_show(1001, '功能代码不能为空');
|
|
|
+ return error_show(1002, '功能code不能为空');
|
|
|
}
|
|
|
+
|
|
|
$status = isset($post['status']) ? intval($post['status']) : 1;
|
|
|
+
|
|
|
try {
|
|
|
- $action = [
|
|
|
- "action_name" => $action_name,
|
|
|
- "action_code" => $code,
|
|
|
- "action_desc" => $action_desc,
|
|
|
- "status" => $status,
|
|
|
- "is_show" => 1,
|
|
|
- "is_del" => 0,
|
|
|
- "addtime" => date("Y-m-d H:i:s"),
|
|
|
- "updatetime" => date("Y-m-d H:i:s")
|
|
|
- ];
|
|
|
- $up = Db::name("action_list")->insert($action);
|
|
|
- return $up ? json_show(0, "新建成功") : json_show(1004, "新建失败");
|
|
|
+ $where = ['menuid' => $pageid, 'action_code' => $code];
|
|
|
+ $true = Db::name("action")->field('id')->where($where)->find();
|
|
|
+
|
|
|
+ if ($true) return error_show(1003, '此功能已存在');
|
|
|
+ else {
|
|
|
+ $data = ['menuid' => $pageid, 'action_code' => $code, 'status' => $status, "updatetime" => date("Y-m-d H:i:s"), "addtime" => date("Y-m-d H:i:s")];
|
|
|
+ Db::name("action")->insert($data);
|
|
|
+ return app_show(0, "添加成功");
|
|
|
+ }
|
|
|
} catch (\Exception $e) {
|
|
|
- return json_show(1005, $e->getMessage());
|
|
|
+ return error_show(1005, $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
|