Skip to content

Commit

Permalink
更新tp版本,bug修复
Browse files Browse the repository at this point in the history
  • Loading branch information
gitzwt committed Apr 19, 2018
1 parent 1c3f1bd commit 13e806b
Show file tree
Hide file tree
Showing 208 changed files with 23,147 additions and 105 deletions.
2 changes: 1 addition & 1 deletion application/admin/view/index.main.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</thead>
<tbody>
<tr>
<td>ThinkApiAdmin 版本</td>
<td>{:sysconf('app_name')} 版本</td>
<td>{:sysconf('app_version')}</td>
</tr>
<tr>
Expand Down
4 changes: 2 additions & 2 deletions application/port/controller/Row.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected function _index_data_filter(&$list)
$alert = [
'type' => 'danger',
'title' => '操作安全警告(谨慎刷新接口路由)',
'content' => '新增接口后必须要刷新接口路由才能访问!请根据实际情况刷新路由!'
'content' => '新增或编辑接口后必须刷新接口路由才能正常访问!请根据实际情况刷新路由!'
];
$tags = Db::name($this->table_api_group)->column('id,name');
$handlers = Db::name($this->table_admin)->column('id,username');
Expand Down Expand Up @@ -335,7 +335,7 @@ public function refresh()
{
$apiRoutePath = ROOT_PATH . 'application/apiRoute.php';
$tplPath = ROOT_PATH . 'application/util/apiRoute.tpl';
$methodArr = ['*', 'post', 'get'];
$methodArr = ['get|post', 'post', 'get'];

$tplStr = file_get_contents($tplPath);
$listInfo = ApiList::all(['is_deleted' => 0]);
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"yuan1994/tp-mailer": "^0.2.4",
"topthink/think-worker": "^1.0",
"topthink/think-image": "^1.0",
"topthink/think-testing": "1.0.*"
"topthink/think-testing": "1.0.*",
"monolog/monolog": "^1.23"
},
"extra": {
"think-path": "thinkphp"
Expand Down
49 changes: 1 addition & 48 deletions think_api_admin.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,53 +39,6 @@ CREATE TABLE `api_app` (

insert into `api_app`(`id`,`app_id`,`app_secret`,`app_name`,`app_status`,`app_info`,`handler`,`create_at`,`update_at`,`app_api`) values (1,'69920173','SVRZKjiXaLnaIGaqCqjsCloazWRfOUdl','测试账号',1,'获取api使用的密钥','10000','2018-04-09 23:09:03','2018-04-09 23:09:03',NULL),(2,'72706061','OZswbfqtJHWTSehfGIFSydLzvxhpQWDy','生产账号',0,'应用上线用账号','10000','2018-04-09 23:09:03','2018-04-11 22:47:30',NULL),(3,'48770236','YsOHpGNNdyTirlXBvLsHlIaGHBFLcLzc','Demo',1,'我是呆萌666','10000','2018-04-11 23:19:24','2018-04-11 23:22:30',NULL);

/*Table structure for table `api_auth_group` */

DROP TABLE IF EXISTS `api_auth_group`;

CREATE TABLE `api_auth_group` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL COMMENT '组名称',
`description` varchar(50) NOT NULL COMMENT '组描述',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '组状态:为1正常,为0禁用',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='权限组';

/*Data for the table `api_auth_group` */

insert into `api_auth_group`(`id`,`name`,`description`,`status`) values (1,'user','用户信息类',1);

/*Table structure for table `api_auth_group_access` */

DROP TABLE IF EXISTS `api_auth_group_access`;

CREATE TABLE `api_auth_group_access` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`uid` mediumint(8) unsigned NOT NULL,
`groupId` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `uid` (`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 COMMENT='用户和组的对应关系';

/*Data for the table `api_auth_group_access` */

insert into `api_auth_group_access`(`id`,`uid`,`groupId`) values (1,2,'1'),(2,3,'1'),(3,4,'1'),(4,5,'1'),(5,6,'1'),(6,7,'1'),(7,8,'1'),(8,9,'1'),(9,10,'1'),(10,11,'1'),(11,12,'1');

/*Table structure for table `api_auth_rule` */

DROP TABLE IF EXISTS `api_auth_rule`;

CREATE TABLE `api_auth_rule` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`url` char(80) NOT NULL DEFAULT '' COMMENT '规则唯一标识',
`groupId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '权限所属组的ID',
`auth` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '权限数值',
`status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态:为1正常,为0禁用',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='权限细节';

/*Data for the table `api_auth_rule` */

/*Table structure for table `api_document` */

DROP TABLE IF EXISTS `api_document`;
Expand Down Expand Up @@ -197,7 +150,7 @@ CREATE TABLE `data_region` (
PRIMARY KEY (`id`),
KEY `parent_id` (`parent_id`),
KEY `region_type` (`type`)
) ENGINE=InnoDB AUTO_INCREMENT=4044 DEFAULT CHARSET=utf8mb4 COMMENT='小程序基础数据-地区表';
) ENGINE=InnoDB AUTO_INCREMENT=4044 DEFAULT CHARSET=utf8mb4 COMMENT='基础数据-地区表';

/*Data for the table `data_region` */

Expand Down
2 changes: 1 addition & 1 deletion thinkphp/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// | Author: liu21st <[email protected]>
// +----------------------------------------------------------------------

define('THINK_VERSION', '5.0.17');
define('THINK_VERSION', '5.0.18');
define('THINK_START_TIME', microtime(true));
define('THINK_START_MEM', memory_get_usage());
define('EXT', '.php');
Expand Down
36 changes: 21 additions & 15 deletions thinkphp/library/think/db/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,11 @@ protected function parseData($data, $options)
$result[$item] = 'NULL';
} elseif (is_array($val) && !empty($val)) {
switch ($val[0]) {
case 'exp':
$result[$item] = $val[1];
break;
case 'inc':
$result[$item] = $item . '+' . floatval($val[2]);
$result[$item] = $item . '+' . floatval($val[1]);
break;
case 'dec':
$result[$item] = $item . '-' . floatval($val[2]);
$result[$item] = $item . '-' . floatval($val[1]);
break;
}
} elseif (is_scalar($val)) {
Expand Down Expand Up @@ -191,7 +188,7 @@ protected function parseField($fields, $options = [])
} elseif (!is_numeric($key)) {
$array[] = $this->parseKey($key, $options) . ' AS ' . $this->parseKey($field, $options, true);
} else {
$array[] = $this->parseKey($field, $options, true);
$array[] = $this->parseKey($field, $options);
}
}
$fieldsStr = implode(',', $array);
Expand Down Expand Up @@ -391,7 +388,11 @@ protected function parseWhereItem($field, $val, $rule = '', $options = [], $bind
}
} elseif ('EXP' == $exp) {
// 表达式查询
$whereStr .= '( ' . $key . ' ' . $value . ' )';
if ($value instanceof Expression) {
$whereStr .= '( ' . $key . ' ' . $value->getValue() . ' )';
} else {
throw new Exception('where express error:' . $exp);
}
} elseif (in_array($exp, ['NOT NULL', 'NULL'])) {
// NULL 查询
$whereStr .= $key . ' IS ' . $exp;
Expand Down Expand Up @@ -509,6 +510,11 @@ protected function parseDateTime($value, $key, $options = [], $bindName = null,
}
}
$bindName = $bindName ?: $key;

if ($this->query->isBind($bindName)) {
$bindName .= '_' . str_replace('.', '_', uniqid('', true));
}

$this->query->bind($bindName, $value, $bindType);
return ':' . $bindName;
}
Expand Down Expand Up @@ -579,8 +585,8 @@ protected function parseOrder($order, $options = [])
} else {
$sort = $val;
}

$sort = in_array(strtolower($sort), ['asc', 'desc'], true) ? ' ' . $sort : '';
$sort = strtoupper($sort);
$sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : '';
$array[] = $this->parseKey($key, $options, true) . $sort;
}
}
Expand Down Expand Up @@ -668,11 +674,7 @@ protected function parseForce($index)
return '';
}

if (is_array($index)) {
$index = join(",", $index);
}

return sprintf(" FORCE INDEX ( %s ) ", $index);
return sprintf(" FORCE INDEX ( %s ) ", is_array($index) ? implode(',', $index) : $index);
}

/**
Expand Down Expand Up @@ -790,10 +792,14 @@ public function insertAll($dataSet, $options = [], $replace = false)
$values[] = 'SELECT ' . implode(',', $value);

if (!isset($insertFields)) {
$insertFields = array_map([$this, 'parseKey'], array_keys($data));
$insertFields = array_keys($data);
}
}

foreach ($insertFields as $field) {
$fields[] = $this->parseKey($query, $field, true);
}

return str_replace(
['%INSERT%', '%TABLE%', '%FIELD%', '%DATA%', '%COMMENT%'],
[
Expand Down
35 changes: 23 additions & 12 deletions thinkphp/library/think/db/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ public function setInc($field, $step = 1, $lazyTime = 0)
return true;
}
}
return $this->setField($field, ['inc', $field, $step]);
return $this->setField($field, ['inc', $step]);
}

/**
Expand Down Expand Up @@ -637,9 +637,9 @@ public function setDec($field, $step = 1, $lazyTime = 0)
$this->options = [];
return true;
}
return $this->setField($field, ['inc', $field, $step]);
return $this->setField($field, ['inc', $step]);
}
return $this->setField($field, ['dec', $field, $step]);
return $this->setField($field, ['dec', $step]);
}

/**
Expand Down Expand Up @@ -883,7 +883,7 @@ public function dec($field, $step = 1)
*/
public function exp($field, $value)
{
$this->data($field, ['exp', $value]);
$this->data($field, $this->raw($value));
return $this;
}

Expand Down Expand Up @@ -1188,7 +1188,7 @@ public function whereNotBetween($field, $condition, $logic = 'AND')
*/
public function whereExp($field, $condition, $logic = 'AND')
{
$this->parseWhereExp($logic, $field, 'exp', $condition, [], true);
$this->parseWhereExp($logic, $field, 'exp', $this->raw($condition), [], true);
return $this;
}

Expand Down Expand Up @@ -1239,7 +1239,7 @@ protected function parseWhereExp($logic, $field, $op, $condition, $param = [], $
// 记录一个字段多次查询条件
$this->options['multi'][$logic][$field][] = $where[$field];
} elseif (is_string($field) && preg_match('/[,=\>\<\'\"\(\s]/', $field)) {
$where[] = ['exp', $field];
$where[] = ['exp', $this->raw($field)];
if (is_array($op)) {
// 参数绑定
$this->bind($op);
Expand All @@ -1260,21 +1260,28 @@ protected function parseWhereExp($logic, $field, $op, $condition, $param = [], $
$where[$field] = $param;
} elseif (in_array(strtolower($op), ['null', 'notnull', 'not null'])) {
// null查询
$where[$field] = [$op, ''];
$where[$field] = [$op, ''];

$this->options['multi'][$logic][$field][] = $where[$field];
} elseif (is_null($condition)) {
// 字段相等查询
$where[$field] = ['eq', $op];
$where[$field] = ['eq', $op];

$this->options['multi'][$logic][$field][] = $where[$field];
} else {
$where[$field] = [$op, $condition, isset($param[2]) ? $param[2] : null];
if ('exp' == strtolower($op) && isset($param[2]) && is_array($param[2])) {
if ('exp' == strtolower($op)) {
$where[$field] = ['exp', $this->raw($condition)];
// 参数绑定
$this->bind($param[2]);
if (isset($param[2]) && is_array($param[2])) {
$this->bind($param[2]);
}
} else {
$where[$field] = [$op, $condition];
}
// 记录一个字段多次查询条件
$this->options['multi'][$logic][$field][] = $where[$field];
}

if (!empty($where)) {
if (!isset($this->options['where'][$logic])) {
$this->options['where'][$logic] = [];
Expand Down Expand Up @@ -1503,7 +1510,11 @@ public function order($field, $order = null)
if (!empty($this->options['via'])) {
$field = $this->options['via'] . '.' . $field;
}
$field = empty($order) ? $field : [$field => $order];
if (strpos($field, ',')) {
$field = array_map('trim', explode(',', $field));
} else {
$field = empty($order) ? $field : [$field => $order];
}
} elseif (!empty($this->options['via'])) {
foreach ($field as $key => $val) {
if (is_numeric($key)) {
Expand Down
3 changes: 2 additions & 1 deletion thinkphp/library/think/model/relation/BelongsToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace think\model\relation;

use think\Collection;
use think\Db;
use think\db\Query;
use think\Exception;
use think\Loader;
Expand Down Expand Up @@ -338,7 +339,7 @@ public function getRelationCountQuery($closure)
return $this->belongsToManyQuery($this->foreignKey, $this->localKey, [
'pivot.' . $this->localKey => [
'exp',
'=' . $this->parent->getTable() . '.' . $this->parent->getPk(),
Db::raw('=' . $this->parent->getTable() . '.' . $this->parent->getPk()),
],
])->fetchSql()->count();
}
Expand Down
9 changes: 2 additions & 7 deletions thinkphp/library/think/model/relation/HasMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function relationCount($result, $closure)
if ($closure) {
call_user_func_array($closure, [ & $this->query]);
}
$count = $this->query->where([$this->foreignKey => $result->$localKey])->count();
$count = $this->query->where($this->foreignKey, $result->$localKey)->count();
}
return $count;
}
Expand All @@ -160,12 +160,7 @@ public function getRelationCountQuery($closure)
call_user_func_array($closure, [ & $this->query]);
}
$localKey = $this->localKey ?: $this->parent->getPk();
return $this->query->where([
$this->foreignKey => [
'exp',
'=' . $this->parent->getTable() . '.' . $localKey,
],
])->fetchSql()->count();
return $this->query->whereExp($this->foreignKey, '=' . $this->parent->getTable() . '.' . $localKey)->fetchSql()->count();
}

/**
Expand Down
3 changes: 2 additions & 1 deletion thinkphp/library/think/model/relation/MorphMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace think\model\relation;

use think\Db;
use think\db\Query;
use think\Exception;
use think\Loader;
Expand Down Expand Up @@ -201,7 +202,7 @@ public function getRelationCountQuery($closure)
return $this->query->where([
$this->morphKey => [
'exp',
'=' . $this->parent->getTable() . '.' . $this->parent->getPk(),
Db::raw('=' . $this->parent->getTable() . '.' . $this->parent->getPk()),
],
$this->morphType => $this->type,
])->fetchSql()->count();
Expand Down
2 changes: 1 addition & 1 deletion vendor/composer/autoload_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
$baseDir = dirname($vendorDir);

return array(
'2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'9b552a3cc426e3287cc811caefa3cf53' => $vendorDir . '/topthink/think-helper/src/helper.php',
'2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
'841780ea2e1d6545ea3a253239d59c05' => $vendorDir . '/qiniu/php-sdk/src/Qiniu/functions.php',
'1cfd2761b63b0a29ed23657ea394cb2d' => $vendorDir . '/topthink/think-captcha/src/helper.php',
'cc56288302d9df745d97c934d6a6e5f0' => $vendorDir . '/topthink/think-queue/src/common.php',
Expand Down
2 changes: 2 additions & 0 deletions vendor/composer/autoload_psr4.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
'Symfony\\Component\\OptionsResolver\\' => array($vendorDir . '/symfony/options-resolver'),
'Symfony\\Component\\DomCrawler\\' => array($vendorDir . '/symfony/dom-crawler'),
'Qiniu\\' => array($vendorDir . '/qiniu/php-sdk/src/Qiniu'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
'Pay\\' => array($vendorDir . '/zoujingli/pay-php-sdk/src'),
'OSS\\' => array($vendorDir . '/aliyuncs/oss-sdk-php/src/OSS'),
'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
'Flc\\Dysms\\' => array($vendorDir . '/flc/dysms/src'),
'Endroid\\QrCode\\' => array($vendorDir . '/endroid/qrcode/src'),
'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
Expand Down
Loading

0 comments on commit 13e806b

Please sign in to comment.