Skip to content

Commit

Permalink
API 万能签名
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinywan committed Sep 7, 2016
1 parent d26da38 commit 2d199cd
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Backend/Home/Controller/BaseController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public function _initialize(){
/***************************************权限认证****************************************************/
$Public = in_array(MODULE_NAME,explode(',',C('NOT_AUTH_MODULE'))) || in_array(ACTION_NAME,explode(',',C('NOT_AUTH_ACTION')));
// 如果不在公共模块之中,同时开启权限验证的话,则开始认证过程
if(C('USER_AUTH_ON') && !$Public)
{
if(!Rbac::AccessDecision()) //通过accessDecision获取权限信息
{
return $this->error("您没有操作权限"); //没有获取到权限信息时需要执行的代码
}
}
// if(C('USER_AUTH_ON') && !$Public)
// {
// if(!Rbac::AccessDecision()) //通过accessDecision获取权限信息
// {
// return $this->error("您没有操作权限"); //没有获取到权限信息时需要执行的代码
// }
// }
/***************************************导航栏菜单显示****************************************************/
/*
* 思路:
Expand Down
6 changes: 6 additions & 0 deletions Backend/Home/Controller/ProductController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Home\Controller;

use Home\Controller\BaseController;
use Home\Model\ProductViewModel;

class ProductController extends BaseController
{
Expand Down Expand Up @@ -204,4 +205,9 @@ public function test()
p(word_time(time()));
}

public function viewFind(){
$Model = D('Product');
p($Model->select());
}

}
22 changes: 22 additions & 0 deletions Backend/Home/Model/ProductViewModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* Created by PhpStorm.
* User: 1
* Date: 2016/9/6
* Time: 14:11
*/

namespace Home\Model;

use Think\Model;
use Think\Model\ViewModel;

class ProductViewModel extends ViewModel
{
//$viewFields 属性表示视图模型包含的字段,每个元素定义了某个数据表或者模型的字段
public $viewFields = array(
'Blog'=>array('id','name','title'),
'Category'=>array('title'=>'category_name', '_on'=>'Blog.category_id=Category.id'),
'User'=>array('name'=>'username', '_on'=>'Blog.user_id=User.id'),
);
}

0 comments on commit 2d199cd

Please sign in to comment.