改名
This commit is contained in:
@@ -16,6 +16,7 @@ use Snowflake\Error\Logger;
|
|||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
|
|
||||||
defined('SAVE_FAIL') or define('SAVE_FAIL', 3227);
|
defined('SAVE_FAIL') or define('SAVE_FAIL', 3227);
|
||||||
|
defined('FIND_OR_CREATE_MESSAGE') or define('FIND_OR_CREATE_MESSAGE', 'Create a new model, but the data cannot be empty.');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Orm
|
* Class Orm
|
||||||
@@ -116,8 +117,7 @@ class ActiveRecord extends BaseActiveRecord
|
|||||||
return $select;
|
return $select;
|
||||||
}
|
}
|
||||||
if (empty($attributes)) {
|
if (empty($attributes)) {
|
||||||
$message = 'Create a new model, but the data cannot be empty.';
|
return \logger()->addError(FIND_OR_CREATE_MESSAGE, 'mysql');
|
||||||
return Snowflake::app()->logger->addError($message, 'mysql');
|
|
||||||
}
|
}
|
||||||
$select = new static();
|
$select = new static();
|
||||||
$select->attributes = $attributes;
|
$select->attributes = $attributes;
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ class {$controllerName}Controller extends Controller
|
|||||||
{
|
{
|
||||||
$model = ' . $className . '::findOne(Input()->post(\'id\', 0));
|
$model = ' . $className . '::findOne(Input()->post(\'id\', 0));
|
||||||
if (empty($model)) {
|
if (empty($model)) {
|
||||||
return JSON::to(500, \'指定数据不存在\');
|
return JSON::to(500, SELECT_IS_NULL);
|
||||||
}
|
}
|
||||||
$model->attributes = $this->loadParam();
|
$model->attributes = $this->loadParam();
|
||||||
|
|
||||||
@@ -245,7 +245,7 @@ class {$controllerName}Controller extends Controller
|
|||||||
$_key = Input()->array(\'ids\');
|
$_key = Input()->array(\'ids\');
|
||||||
$pass = Input()->string(\'password\', true, 32);
|
$pass = Input()->string(\'password\', true, 32);
|
||||||
if (empty($_key)) {
|
if (empty($_key)) {
|
||||||
return JSON::to(500, \'IDS集合不能为空\');
|
return JSON::to(500, PARAMS_IS_NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->request->identity;
|
$user = $this->request->identity;
|
||||||
@@ -255,7 +255,7 @@ class {$controllerName}Controller extends Controller
|
|||||||
|
|
||||||
$model = ' . $className . '::find()->in(\'id\', $_key);
|
$model = ' . $className . '::find()->in(\'id\', $_key);
|
||||||
if(!$model->delete()){
|
if(!$model->delete()){
|
||||||
return JSON::to(500, \'系统繁忙, 请稍后再试!\');
|
return JSON::to(500, DB_ERROR_BUSY);
|
||||||
}
|
}
|
||||||
return JSON::to(0, $model->toArray());
|
return JSON::to(0, $model->toArray());
|
||||||
}';
|
}';
|
||||||
@@ -279,7 +279,7 @@ class {$controllerName}Controller extends Controller
|
|||||||
{
|
{
|
||||||
$model = ' . $managerName . '::findOne(Input()->get(\'id\'));
|
$model = ' . $managerName . '::findOne(Input()->get(\'id\'));
|
||||||
if(empty($model)){
|
if(empty($model)){
|
||||||
return JSON::to(404, \'Data Not Exists\');
|
return JSON::to(404, SELECT_IS_NULL);
|
||||||
}
|
}
|
||||||
return JSON::to(0, $model->toArray());
|
return JSON::to(0, $model->toArray());
|
||||||
}';
|
}';
|
||||||
@@ -311,7 +311,7 @@ class {$controllerName}Controller extends Controller
|
|||||||
|
|
||||||
$model = ' . $managerName . '::findOne($_key);
|
$model = ' . $managerName . '::findOne($_key);
|
||||||
if (empty($model)) {
|
if (empty($model)) {
|
||||||
return JSON::to(500, \'指定数据不存在\');
|
return JSON::to(500, SELECT_IS_NULL);
|
||||||
}
|
}
|
||||||
if(!$model->delete()){
|
if(!$model->delete()){
|
||||||
return JSON::to(500, $model->getLastError());
|
return JSON::to(500, $model->getLastError());
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ use Snowflake\Process\Process;
|
|||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
use Swoole\WebSocket\Server;
|
use Swoole\WebSocket\Server;
|
||||||
|
|
||||||
|
|
||||||
|
defined('DB_ERROR_BUSY') or define('DB_ERROR', 'The database is busy. Please try again later.');
|
||||||
|
defined('SELECT_IS_NULL') or define('SELECT_IS_NULL', 'Query data does not exist, please check the relevant conditions.');
|
||||||
|
defined('PARAMS_IS_NULL') or define('PARAMS_IS_NULL', 'Required items cannot be empty, please add.');
|
||||||
|
|
||||||
class Snowflake
|
class Snowflake
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user