diff --git a/application/admin/controller/Group.php b/application/admin/controller/Group.php index 5c9d5e58..d094d3cf 100644 --- a/application/admin/controller/Group.php +++ b/application/admin/controller/Group.php @@ -176,7 +176,7 @@ class Group extends Admin { //模块 $model = db('model')->field('id,title,name') - ->where(array('status' => array('gt', 0), 'extend' => array('gt', 0))) + ->where(array('status' => array('gt', 0))) ->select(); //扩展权限 $extend_auth = db('AuthExtend')->where(array('group_id' => $id, 'type' => 2))->column('extend_id'); diff --git a/application/admin/controller/Model.php b/application/admin/controller/Model.php index 7fe0ce72..36f1223f 100644 --- a/application/admin/controller/Model.php +++ b/application/admin/controller/Model.php @@ -52,10 +52,10 @@ class Model extends Admin { //记录行为 action_log('add_model', 'model', $result, session('auth_user.uid')); $this->success('创建成功!', url('admin/model/index')); - }else{ + } else { return $this->error($this->model->getError() ? $this->model->getError() : '模型标识为保留名称!'); } - }else{ + } else { $this->setMeta('新增模型'); return $this->fetch(); } @@ -67,15 +67,15 @@ class Model extends Admin { */ public function edit(\think\Request $request) { if (IS_POST) { - $result = $this->model->validate('Model.edit')->save($request->post(), array('id'=>$request->post('id'))); + $result = $this->model->validate('Model.edit')->save($request->post(), array('id' => $request->post('id'))); if (false !== $result) { //记录行为 action_log('update_model', 'model', $request->post('id'), session('auth_user.uid')); $this->success('更新成功!', url('admin/model/index')); - }else{ + } else { return $this->error($this->model->getError()); } - }else{ + } else { $info = $this->model->where('id', $request->param('id'))->find(); $field_group = parse_config_attr($info['attribute_group']); @@ -87,14 +87,15 @@ class Model extends Admin { $list[$field['group_id']][] = $field; } foreach ($field_group as $key => $value) { - $fields[$value] = isset($list[$key]) ? $list[$key] : array(); + $fields[$key] = isset($list[$key]) ? $list[$key] : array(); } - }else{ + } else { $fields = array(); } $data = array( - 'info' => $info, - 'fields' => $fields + 'info' => $info, + 'field_group' => $field_group, + 'fields' => $fields, ); $this->assign($data); $this->setMeta('编辑模型'); @@ -148,7 +149,7 @@ class Model extends Admin { $result = $this->model->where($map)->update($data); if (false !== $result) { return $this->success('状态设置成功!'); - }else{ + } else { return $this->error($this->model->getError()); } } diff --git a/application/admin/fields.php b/application/admin/fields.php index 2ad08806..0a3b8e3e 100644 --- a/application/admin/fields.php +++ b/application/admin/fields.php @@ -5,6 +5,7 @@ return array( 'uid' => array('name' => 'uid', 'title' => '用户UID', 'type' => 'num', 'length' => 11, 'extra' => '', 'remark' => '用户UID', 'is_show' => 0, 'is_must' => 1, 'value'=>'0'), 'cover_id' => array('name' => 'cover_id', 'title' => '内容封面', 'type' => 'image', 'length' => 10, 'extra' => '', 'remark' => '内容封面', 'is_show' => 1, 'is_must' => 0, 'value'=>''), 'description' => array('name' => 'description', 'title' => '内容描述', 'type' => 'textarea', 'length' => '', 'extra' => '', 'remark' => '内容描述', 'is_show' => 1, 'is_must' => 0, 'value'=>''), + 'content' => array('name' => 'content', 'title' => '内容', 'type' => 'editor', 'length' => '', 'extra' => '', 'remark' => '内容', 'is_show' => 1, 'is_must' => 0, 'value'=>''), 'status' => array('name' => 'status', 'title' => '数据状态', 'type' => 'select', 'length' => 2, 'extra' => "-1:删除\r\n0:禁用\r\n1:正常\r\n2:待审核\r\n3:草稿", 'remark' => '数据状态', 'is_show' => 1, 'is_must' => 1, 'value'=>'1'), 'is_top' => array('name' => 'is_top', 'title' => '是否置顶', 'type' => 'bool', 'length' => 2, 'extra' => '', 'remark' => '是否置顶', 'is_show' => 0, 'is_must' => 1, 'value'=>'0'), 'view' => array('name' => 'view', 'title' => '浏览数量', 'type' => 'num', 'length' => 11, 'extra' => '', 'remark' => '浏览数量', 'is_show' => 0, 'is_must' => 1, 'value'=>'0'), diff --git a/application/admin/view/model/edit.html b/application/admin/view/model/edit.html index dafd7bbd..2da957e1 100644 --- a/application/admin/view/model/edit.html +++ b/application/admin/view/model/edit.html @@ -56,7 +56,7 @@
{volist name="fields" id="field"}
-
{$key}
+
{$field_group[$key]}
{foreach name="field" item="item" key="k"} diff --git a/application/api/controller/AccessToken.php b/application/api/controller/AccessToken.php deleted file mode 100644 index 875e5915..00000000 --- a/application/api/controller/AccessToken.php +++ /dev/null @@ -1,15 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace app\api\controller; -use api\BaseAuth; - -class AccessToken extends BaseAuth { - -} \ No newline at end of file diff --git a/application/api/controller/Base.php b/application/api/controller/Base.php deleted file mode 100644 index a9941d04..00000000 --- a/application/api/controller/Base.php +++ /dev/null @@ -1,26 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace app\api\controller; -use api\BaseRest; - -class Base extends BaseRest { - - // 允许访问的请求类型 - protected $restMethodList = 'get|post|put|delete|patch|head|options'; - //业务错误码的映射表 - public $errMap = [ - 0 => 'success', //没有错误 - 1001 => '参数错误', - 9999 => '自定义错误', //让程序给出的自定义错误 - ]; - - //是否开启权限认证 - public $apiAuth = true; -} \ No newline at end of file diff --git a/application/api/controller/Index.php b/application/api/controller/Index.php deleted file mode 100644 index 1a2c5ca3..00000000 --- a/application/api/controller/Index.php +++ /dev/null @@ -1,37 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace app\api\controller; - -use think\Request; - -class Index extends Base { - - public $apiAuth = true; - // 允许访问的请求类型 - protected $restMethodList = 'get|post|'; - - /** - * get的响应 - * @param Request $request - * @return mixed - */ - public function getResponse(Request $request) { - return $this->sendError(1001, 'THIS IS GET', 400); - } - - /** - * post的响应 - * @param Request $request - * @return mixed - */ - public function postResponse(Request $request) { - return $this->sendSuccess('THIS IS POST'); - } -} diff --git a/application/common/behavior/InitHook.php b/application/common/behavior/InitHook.php index 80f1f021..a7caed55 100644 --- a/application/common/behavior/InitHook.php +++ b/application/common/behavior/InitHook.php @@ -53,19 +53,19 @@ class InitHook { } $list = db('Model')->column('id,name', 'id'); foreach ($list as $key => $value) { - $route["admin/" . $value['name'] . "/index"] = "admin/content/index?model_id=" . $value['id']; - $route["admin/" . $value['name'] . "/add"] = "admin/content/add?model_id=" . $value['id']; - $route["admin/" . $value['name'] . "/edit"] = "admin/content/edit?model_id=" . $value['id']; - $route["admin/" . $value['name'] . "/del"] = "admin/content/del?model_id=" . $value['id']; - $route["admin/" . $value['name'] . "/status"] = "admin/content/status?model_id=" . $value['id']; - $route[$value['name'] . "/index"] = "index/content/index?model=" . $value['name']; - $route[$value['name'] . "/list/:id"] = "index/content/lists?model=" . $value['name']; - $route[$value['name'] . "/detail-"] = "index/content/detail?model_id=" . $value['id']; - $route["user/" . $value['name'] . "/index"] = "user/content/index?model_id=" . $value['id']; - $route["user/" . $value['name'] . "/add"] = "user/content/add?model_id=" . $value['id']; - $route["user/" . $value['name'] . "/edit"] = "user/content/edit?model_id=" . $value['id']; - $route["user/" . $value['name'] . "/del"] = "user/content/del?model_id=" . $value['id']; - $route["user/" . $value['name'] . "/status"] = "user/content/status?model_id=" . $value['id']; + $route["admin/" . $value . "/index"] = "admin/content/index?model_id=" . $key; + $route["admin/" . $value . "/add"] = "admin/content/add?model_id=" . $key; + $route["admin/" . $value . "/edit"] = "admin/content/edit?model_id=" . $key; + $route["admin/" . $value . "/del"] = "admin/content/del?model_id=" . $key; + $route["admin/" . $value . "/status"] = "admin/content/status?model_id=" . $key; + $route[$value . "/index"] = "index/content/index?model=" . $value; + $route[$value . "/list/:id"] = "index/content/lists?model=" . $value; + $route[$value . "/detail-"] = "index/content/detail?model_id=" . $key; + $route["user/" . $value . "/index"] = "user/content/index?model_id=" . $key; + $route["user/" . $value . "/add"] = "user/content/add?model_id=" . $key; + $route["user/" . $value . "/edit"] = "user/content/edit?model_id=" . $key; + $route["user/" . $value . "/del"] = "user/content/del?model_id=" . $key; + $route["user/" . $value . "/status"] = "user/content/status?model_id=" . $key; } $route["list/:id"] = "index/content/category"; diff --git a/application/common/model/Model.php b/application/common/model/Model.php index c4d89461..c4d1df7b 100644 --- a/application/common/model/Model.php +++ b/application/common/model/Model.php @@ -38,14 +38,21 @@ class Model extends Base { }); self::afterInsert(function($event){ $data = $event->toArray(); - if ($data['is_doc']) { - $fields = include(APP_PATH.'admin/fields.php'); - if (!empty($fields)) { - foreach ($fields as $key => $value) { + + $fields = include(APP_PATH.'admin/fields.php'); + if (!empty($fields)) { + foreach ($fields as $key => $value) { + if ($data['is_doc']) { $fields[$key]['model_id'] = $data['id']; + }else{ + if (in_array($key, array('uid', 'status', 'view', 'create_time', 'update_time'))) { + $fields[$key]['model_id'] = $data['id']; + }else{ + unset($fields[$key]); + } } - model('Attribute')->saveAll($fields); } + model('Attribute')->saveAll($fields); } return true; });