1、修复bug

2、创建模型字段问题
This commit is contained in:
2017-06-24 17:02:06 +08:00
parent 832929b0eb
commit 4bc35ad3f9
9 changed files with 39 additions and 108 deletions

View File

@@ -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');

View File

@@ -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());
}
}

View File

@@ -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'),

View File

@@ -56,7 +56,7 @@
<div class="col-lg-10 boards" id="attribute_group_sort">
{volist name="fields" id="field"}
<div class="board panel panel-info">
<div class="panel-heading">{$key}</div>
<div class="panel-heading">{$field_group[$key]}</div>
<div class="panel-body">
<div class="board-list" data-group="{$key}">
{foreach name="field" item="item" key="k"}

View File

@@ -1,15 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\api\controller;
use api\BaseAuth;
class AccessToken extends BaseAuth {
}

View File

@@ -1,26 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
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;
}

View File

@@ -1,37 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
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');
}
}

View File

@@ -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-<id>"] = "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-<id>"] = "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";

View File

@@ -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;
});