mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-09 08:02:48 +08:00
traits层次调整去掉 think目录 用户自定义的traits可以放到模块目录下面区分
This commit is contained in:
@@ -1,17 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用法:
|
* 用法:
|
||||||
* T('think/controller/ajax');
|
* T('controller/ajax');
|
||||||
* class index
|
* class index
|
||||||
* {
|
* {
|
||||||
* use \traits\think\controller\ajax;
|
* use \traits\controller\ajax;
|
||||||
* public function index(){
|
* public function index(){
|
||||||
* $this->result();
|
* $this->result();
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
namespace traits\think\controller;
|
namespace traits\controller;
|
||||||
use think\Config;
|
|
||||||
|
|
||||||
trait Ajax
|
trait Ajax
|
||||||
{
|
{
|
||||||
@@ -1,17 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用法:
|
* 用法:
|
||||||
* T('think/controller/view');
|
* T('controller/view');
|
||||||
* class index
|
* class index
|
||||||
* {
|
* {
|
||||||
* use \traits\think\controller\view;
|
* use \traits\controller\view;
|
||||||
* public function index(){
|
* public function index(){
|
||||||
* $this->assign();
|
* $this->assign();
|
||||||
* $this->show();
|
* $this->show();
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
namespace traits\think\controller;
|
namespace traits\controller;
|
||||||
|
|
||||||
use think\Config;
|
use think\Config;
|
||||||
|
|
||||||
trait View
|
trait View
|
||||||
@@ -26,7 +28,7 @@ trait View
|
|||||||
public function initView()
|
public function initView()
|
||||||
{
|
{
|
||||||
// 模板引擎参数
|
// 模板引擎参数
|
||||||
if(is_null($this->view)){
|
if (is_null($this->view)) {
|
||||||
$this->view = new \think\View(Config::get()); // 只能这样写,不然view会冲突
|
$this->view = new \think\View(Config::get()); // 只能这样写,不然view会冲突
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
// | Author: liu21st <liu21st@gmail.com>
|
// | Author: liu21st <liu21st@gmail.com>
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
namespace traits\think\model;
|
namespace traits\model;
|
||||||
|
|
||||||
use think\Lang;
|
use think\Lang;
|
||||||
use think\Loader;
|
use think\Loader;
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
// | Author: liu21st <liu21st@gmail.com>
|
// | Author: liu21st <liu21st@gmail.com>
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
namespace traits\think\model;
|
namespace traits\model;
|
||||||
|
|
||||||
define('EXISTS_VALIDATE', 0);
|
define('EXISTS_VALIDATE', 0);
|
||||||
define('MUST_VALIDATE', 1);
|
define('MUST_VALIDATE', 1);
|
||||||
@@ -62,8 +62,8 @@ trait Auto
|
|||||||
$fields = explode(',', $fields);
|
$fields = explode(',', $fields);
|
||||||
}
|
}
|
||||||
// 判断令牌验证字段
|
// 判断令牌验证字段
|
||||||
if (C('TOKEN_ON')) {
|
if (Config::get('token_on')) {
|
||||||
$fields[] = C('TOKEN_NAME');
|
$fields[] = Config::get('token_name');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($data as $key => $val) {
|
foreach ($data as $key => $val) {
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
// | Author: liu21st <liu21st@gmail.com>
|
// | Author: liu21st <liu21st@gmail.com>
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
namespace traits\think\model;
|
namespace traits\model;
|
||||||
|
|
||||||
trait Query
|
trait Query
|
||||||
{
|
{
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
// | Author: liu21st <liu21st@gmail.com>
|
// | Author: liu21st <liu21st@gmail.com>
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
namespace traits\think\model;
|
namespace traits\model;
|
||||||
|
|
||||||
define('HAS_ONE', 1);
|
define('HAS_ONE', 1);
|
||||||
define('BELONGS_TO', 2);
|
define('BELONGS_TO', 2);
|
||||||
@@ -288,7 +288,7 @@ trait Relation
|
|||||||
$pk = $model->getPk();
|
$pk = $model->getPk();
|
||||||
foreach ($mappingData as $vo) {
|
foreach ($mappingData as $vo) {
|
||||||
if (isset($vo[$pk])) {
|
if (isset($vo[$pk])) {
|
||||||
// 更新数据
|
// 更新数据
|
||||||
$mappingCondition = "$pk ={$vo[$pk]}";
|
$mappingCondition = "$pk ={$vo[$pk]}";
|
||||||
$result = $model->where($mappingCondition)->save($vo);
|
$result = $model->where($mappingCondition)->save($vo);
|
||||||
} else {
|
} else {
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
// | Author: liu21st <liu21st@gmail.com>
|
// | Author: liu21st <liu21st@gmail.com>
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
namespace traits\think\model;
|
namespace traits\model;
|
||||||
|
|
||||||
trait View
|
trait View
|
||||||
{
|
{
|
||||||
@@ -92,7 +92,7 @@ trait View
|
|||||||
private function _checkFields($name, $fields)
|
private function _checkFields($name, $fields)
|
||||||
{
|
{
|
||||||
if (false !== $pos = array_search('*', $fields)) {
|
if (false !== $pos = array_search('*', $fields)) {
|
||||||
// 定义所有字段
|
// 定义所有字段
|
||||||
$fields = array_merge($fields, M($name)->getDbFields());
|
$fields = array_merge($fields, M($name)->getDbFields());
|
||||||
unset($fields[$pos]);
|
unset($fields[$pos]);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user