1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-22 11:41:27 +08:00

优化代码

This commit is contained in:
xiaochong0302 2020-08-26 20:02:34 +08:00
parent 9c4e10ccda
commit aa66660e47
40 changed files with 246 additions and 254 deletions

View File

@ -1,25 +1,29 @@
<div class="search-course-list">
{% for item in pager.items %}
{% set course_url = url({'for':'desktop.course.show','id':item.id}) %}
{% set teacher_url = url({'for':'desktop.teacher.show','id':item.teacher.id}) %}
<div class="search-course-card clearfix">
<div class="cover">
<a href="{{ course_url }}">
<img src="{{ item.cover }}!cover_270" alt="{{ item.title }}">
</a>
</div>
<div class="info">
<div class="title layui-elip">
<a href="{{ course_url }}">{{ item.title }}</a>
{% if pager.total_pages > 0 %}
<div class="search-course-list">
{% for item in pager.items %}
{% set course_url = url({'for':'desktop.course.show','id':item.id}) %}
{% set teacher_url = url({'for':'desktop.teacher.show','id':item.teacher.id}) %}
<div class="search-course-card clearfix">
<div class="cover">
<a href="{{ course_url }}">
<img src="{{ item.cover }}!cover_270" alt="{{ item.title }}">
</a>
</div>
<div class="summary">{{ item.summary }}</div>
<div class="meta">
<span>讲师:<a href="{{ teacher_url }}">{{ item.teacher.name }}</a></span>
<span>难度:{{ level_info(item.level) }}</span>
<span>课时:{{ item.lesson_count }}</span>
<span>学员:{{ item.user_count }}</span>
<div class="info">
<div class="title layui-elip">
<a href="{{ course_url }}">{{ item.title }}</a>
</div>
<div class="summary">{{ item.summary }}</div>
<div class="meta">
<span>讲师:<a href="{{ teacher_url }}">{{ item.teacher.name }}</a></span>
<span>难度:{{ level_info(item.level) }}</span>
<span>课时:{{ item.lesson_count }}</span>
<span>学员:{{ item.user_count }}</span>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
{% endfor %}
</div>
{% else %}
{{ partial('search/empty') }}
{% endif %}

View File

@ -0,0 +1,4 @@
<div class="search-empty">
<div class="icon"><i class="layui-icon layui-icon-face-surprised"></i></div>
<div class="text">没有找到<span class="query">{{ query }}</span>相关内容,换个关键字试试吧!</div>
</div>

View File

@ -1,24 +1,28 @@
<div class="search-group-list">
{% for item in pager.items %}
{% set group_url = url({'for':'desktop.group.show','id':item.id}) %}
{% set owner_url = url({'for':'desktop.user.show','id':item.owner.id}) %}
{% set item.about = item.about ? item.about : '这个家伙真懒,什么也没有留下!' %}
<div class="search-group-card clearfix">
<div class="avatar">
<a href="{{ group_url }}">
<img src="{{ item.avatar }}" alt="{{ item.name }}">
</a>
</div>
<div class="info">
<div class="name layui-elip">
<a href="{{ group_url }}">{{ item.name }}</a>
{% if pager.total_pages > 0 %}
<div class="search-group-list">
{% for item in pager.items %}
{% set group_url = url({'for':'desktop.group.show','id':item.id}) %}
{% set owner_url = url({'for':'desktop.user.show','id':item.owner.id}) %}
{% set item.about = item.about ? item.about : '这个家伙真懒,什么也没有留下!' %}
<div class="search-group-card clearfix">
<div class="avatar">
<a href="{{ group_url }}">
<img src="{{ item.avatar }}!avatar_160" alt="{{ item.name }}">
</a>
</div>
<div class="about layui-elip">{{ item.about }}</div>
<div class="meta">
<span>组长:<a href="{{ owner_url }}">{{ item.owner.name }}</a></span>
<span>成员:{{ item.user_count }}</span>
<div class="info">
<div class="name layui-elip">
<a href="{{ group_url }}">{{ item.name }}</a>
</div>
<div class="about layui-elip">{{ item.about }}</div>
<div class="meta">
<span>组长:<a href="{{ owner_url }}">{{ item.owner.name }}</a></span>
<span>成员:{{ item.user_count }}</span>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
{% endfor %}
</div>
{% else %}
{{ partial('search/empty') }}
{% endif %}

View File

@ -43,14 +43,7 @@
</div>
</div>
</div>
{% if pager.total_pages > 0 %}
{{ partial('partials/pager') }}
{% else %}
<div class="search-empty wrap">
<div class="icon"><i class="layui-icon layui-icon-face-surprised"></i></div>
<div class="text">没有找到<span class="query">{{ query }}</span>相关内容,换个关键字试试吧!</div>
</div>
{% endif %}
{{ partial('partials/pager') }}
</div>
<div class="layout-sidebar">
{{ partial('search/sidebar') }}

View File

@ -8,26 +8,30 @@
{% endif %}
{%- endmacro %}
<div class="search-user-list">
{% for item in pager.items %}
{% set user_url = url({'for':'desktop.user.show','id':item.id}) %}
{% set item.about = item.about ? item.about : '这个家伙真懒,什么也没有留下!' %}
<div class="search-group-card clearfix">
<div class="avatar">
<a href="{{ user_url }}">
<img src="{{ item.avatar }}" alt="{{ item.name }}">
</a>
</div>
<div class="info">
<div class="name layui-elip">
<a href="{{ user_url }}">{{ item.name }}</a>
{% if pager.total_pages > 0 %}
<div class="search-user-list">
{% for item in pager.items %}
{% set user_url = url({'for':'desktop.user.show','id':item.id}) %}
{% set item.about = item.about ? item.about : '这个家伙真懒,什么也没有留下!' %}
<div class="search-group-card clearfix">
<div class="avatar">
<a href="{{ user_url }}">
<img src="{{ item.avatar }}!avatar_160" alt="{{ item.name }}">
</a>
</div>
<div class="about layui-elip">{{ item.about }}</div>
<div class="meta">
<span>性别:{{ gender_info(item.gender) }}</span>
<span>地区:{{ item.location }}</span>
<div class="info">
<div class="name layui-elip">
<a href="{{ user_url }}">{{ item.name }}</a>
</div>
<div class="about layui-elip">{{ item.about }}</div>
<div class="meta">
<span>性别:{{ gender_info(item.gender) }}</span>
<span>地区:{{ item.location }}</span>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
{% endfor %}
</div>
{% else %}
{{ partial('search/empty') }}
{% endif %}

View File

@ -2,11 +2,11 @@
namespace App\Library\Paginator\Adapter;
use App\Library\Paginator\Query;
use Phalcon\Paginator\Adapter\QueryBuilder as BaseQueryBuilder;
use App\Library\Paginator\Query as PaginatorQuery;
use Phalcon\Paginator\Adapter\QueryBuilder as PhQueryBuilder;
use stdClass;
class QueryBuilder extends BaseQueryBuilder
class QueryBuilder extends PhQueryBuilder
{
protected $baseUrl;
@ -17,7 +17,7 @@ class QueryBuilder extends BaseQueryBuilder
{
$pager = parent::paginate();
$query = new Query();
$query = new PaginatorQuery();
$this->baseUrl = $query->getBaseUrl();
$this->params = $query->getParams();

View File

@ -2,7 +2,8 @@
namespace App\Library\Paginator\Adapter;
use App\Library\Paginator\Query;
use App\Library\Paginator\Query as PaginatorQuery;
use App\Library\Validators\Common as CommonValidator;
use Phalcon\Paginator\Adapter as PaginatorAdapter;
use Phalcon\Paginator\Exception as PaginatorException;
use stdClass;
@ -44,11 +45,11 @@ class XunSearch extends PaginatorAdapter
throw new PaginatorException('Invalid query parameter');
}
if (empty($config['page']) || $config['page'] != intval($config['page'])) {
if (isset($config['page']) && !CommonValidator::positiveNumber($config['page'])) {
throw new PaginatorException('Invalid page parameter');
}
if (empty($config['limit']) || $config['limit'] != intval($config['limit'])) {
if (isset($config['limit']) && !CommonValidator::positiveNumber($config['limit'])) {
throw new PaginatorException('Invalid limit parameter');
}
@ -60,7 +61,7 @@ class XunSearch extends PaginatorAdapter
$this->_page = $config['page'] ?? 1;
$this->_limitRows = $config['limit'] ?? 15;
$query = new Query();
$query = new PaginatorQuery();
$this->baseUrl = $query->getBaseUrl();
$this->params = $query->getParams();

View File

@ -22,7 +22,7 @@ class Common
public static function email($str)
{
return filter_var($str, FILTER_VALIDATE_EMAIL) ? true : false;
return filter_var($str, FILTER_VALIDATE_EMAIL) !== false;
}
public static function url($str)
@ -31,30 +31,40 @@ class Common
$str = 'http:' . $str;
}
return filter_var($str, FILTER_VALIDATE_URL) ? true : false;
return filter_var($str, FILTER_VALIDATE_URL) !== false;
}
public static function intNumber($str)
public static function intNumber($value)
{
return filter_var($str, FILTER_VALIDATE_INT) ? true : false;
return filter_var($value, FILTER_VALIDATE_INT) !== false;
}
public static function floatNumber($str)
public static function floatNumber($value)
{
return filter_var($str, FILTER_VALIDATE_FLOAT) === false;
}
public static function natureNumber($number)
{
if (preg_match('/^0$/', $number)) {
return true;
if (filter_var($value, FILTER_VALIDATE_FLOAT) === false) {
return false;
}
if (preg_match('/^[1-9][0-9]?/', $number)) {
return true;
if (strpos($value, '.') === false) {
return false;
}
return false;
$head = strstr($value, '.', true);
if ($head[0] == '0' && strlen($head) > 1) {
return false;
}
return true;
}
public static function positiveNumber($value)
{
if (!self::intNumber($value)) {
return false;
}
return $value > 0;
}
public static function idCard($str)

View File

@ -70,7 +70,7 @@ class Audit extends Model
{
$this->create_time = time();
if (!empty($this->req_data)) {
if (is_array($this->req_data) && !empty($this->req_data)) {
$this->req_data = kg_json_encode($this->req_data);
} else {
$this->req_data = '';

View File

@ -8,14 +8,6 @@ use Phalcon\Text;
class Carousel extends Model
{
/**
* 平台类型
*/
const PLATFORM_DESKTOP = 'desktop';
const PLATFORM_MOBILE = 'mobile';
const PLATFORM_APP = 'app';
const PLATFORM_MINI = 'mini';
/**
* 目标类型
*/
@ -58,13 +50,6 @@ class Carousel extends Model
*/
public $summary;
/**
* 平台
*
* @var string
*/
public $platform;
/**
* 目标
*
@ -79,6 +64,13 @@ class Carousel extends Model
*/
public $content;
/**
* 平台
*
* @var int
*/
public $platform;
/**
* 优先级
*
@ -133,8 +125,6 @@ class Carousel extends Model
public function beforeCreate()
{
$this->create_time = time();
if (empty($this->cover)) {
$this->cover = kg_default_cover_path();
} elseif (Text::startsWith($this->cover, 'http')) {
@ -144,23 +134,25 @@ class Carousel extends Model
if (is_array($this->style) && !empty($this->style)) {
$this->style = kg_json_encode($this->style);
}
$this->create_time = time();
}
public function beforeUpdate()
{
$this->update_time = time();
if (Text::startsWith($this->cover, 'http')) {
$this->cover = self::getCoverPath($this->cover);
}
if (is_array($this->style) && !empty($this->style)) {
$this->style = kg_json_encode($this->style);
}
if ($this->deleted == 1) {
$this->published = 0;
}
if (Text::startsWith($this->cover, 'http')) {
$this->cover = self::getCoverPath($this->cover);
}
if (!empty($this->style)) {
$this->style = kg_json_encode($this->style);
}
$this->update_time = time();
}
public function afterFetch()
@ -169,7 +161,7 @@ class Carousel extends Model
$this->cover = kg_ci_cover_img_url($this->cover);
}
if (!empty($this->style)) {
if (is_string($this->style) && !empty($this->style)) {
$this->style = json_decode($this->style, true);
}
}
@ -203,14 +195,4 @@ class Carousel extends Model
];
}
public static function platformTypes()
{
return [
self::PLATFORM_DESKTOP => 'desktop',
self::PLATFORM_MOBILE => 'mobile',
self::PLATFORM_APP => 'app',
self::PLATFORM_MINI => '小程序',
];
}
}

View File

@ -122,11 +122,11 @@ class Category extends Model
public function beforeUpdate()
{
$this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
$this->update_time = time();
}
public function afterCreate()

View File

@ -186,8 +186,6 @@ class Chapter extends Model
public function beforeCreate()
{
$this->create_time = time();
$course = Course::findFirst($this->course_id);
$this->model = $course->model;
@ -210,19 +208,21 @@ class Chapter extends Model
$this->attrs = kg_json_encode($attrs);
}
$this->create_time = time();
}
public function beforeUpdate()
{
$this->update_time = time();
if (is_array($this->attrs) && !empty($this->attrs)) {
$this->attrs = kg_json_encode($this->attrs);
}
if ($this->deleted == 1) {
$this->published = 0;
}
if (is_array($this->attrs)) {
$this->attrs = kg_json_encode($this->attrs);
}
$this->update_time = time();
}
public function afterCreate()
@ -234,7 +234,7 @@ class Chapter extends Model
public function afterFetch()
{
if (!empty($this->attrs) && is_string($this->attrs)) {
if (is_string($this->attrs) && !empty($this->attrs)) {
$this->attrs = json_decode($this->attrs, true);
}
}

View File

@ -57,9 +57,9 @@ class ChapterRead extends Model
$this->create_time = time();
/**
* text类型不能填充默认值
* text类型不能自动填充默认值
*/
if (empty($this->content)) {
if (is_null($this->content)) {
$this->content = '';
}
}

View File

@ -14,13 +14,6 @@ class ChapterUser extends Model
*/
public $id;
/**
* 计划编号
*
* @var int
*/
public $plan_id;
/**
* 课程编号
*
@ -42,6 +35,13 @@ class ChapterUser extends Model
*/
public $user_id;
/**
* 计划编号
*
* @var int
*/
public $plan_id;
/**
* 学习时长
*

View File

@ -63,20 +63,20 @@ class ChapterVod extends Model
public function beforeCreate()
{
$this->create_time = time();
if (is_array($this->file_transcode) && !empty($this->file_transcode)) {
$this->file_transcode = kg_json_encode($this->file_transcode);
}
$this->create_time = time();
}
public function beforeUpdate()
{
$this->update_time = time();
if (is_array($this->file_transcode) && !empty($this->file_transcode)) {
$this->file_transcode = kg_json_encode($this->file_transcode);
}
$this->update_time = time();
}
public function afterFetch()

View File

@ -136,11 +136,11 @@ class Consult extends Model
public function beforeUpdate()
{
$this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
$this->update_time = time();
}
}

View File

@ -256,8 +256,6 @@ class Course extends Model
public function beforeCreate()
{
$this->create_time = time();
$attrs = [];
switch ($this->model) {
@ -288,6 +286,8 @@ class Course extends Model
if (!empty($attrs)) {
$this->attrs = kg_json_encode($attrs);
}
$this->create_time = time();
}
public function beforeUpdate()
@ -301,7 +301,7 @@ class Course extends Model
$this->cover = self::getCoverPath($this->cover);
}
if (is_array($this->attrs)) {
if (is_array($this->attrs) && !empty($this->attrs)) {
$this->attrs = kg_json_encode($this->attrs);
}
@ -322,7 +322,7 @@ class Course extends Model
public function afterUpdate()
{
/**
* 课程标题和群组名称保持一致
* 群组名称和课程标题保持一致
*/
if ($this->hasUpdated('title')) {
$imGroup = ImGroup::findFirst(['course_id' => $this->id]);
@ -341,7 +341,7 @@ class Course extends Model
$this->cover = kg_ci_cover_img_url($this->cover);
}
if (!empty($this->attrs) && is_string($this->attrs)) {
if (is_string($this->attrs) && !empty($this->attrs)) {
$this->attrs = json_decode($this->attrs, true);
}
}

View File

@ -51,14 +51,14 @@ class CourseUser extends Model
/**
* 角色类型
*
* @var string
* @var int
*/
public $role_type;
/**
* 来源类型
*
* @var string
* @var int
*/
public $source_type;
@ -130,9 +130,9 @@ class CourseUser extends Model
public function beforeCreate()
{
$this->create_time = time();
$this->plan_id = (int)date('Ymd');
$this->create_time = time();
}
public function beforeUpdate()

View File

@ -144,11 +144,11 @@ class Danmu extends Model
public function beforeUpdate()
{
$this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
$this->update_time = time();
}
public static function sizeTypes()
@ -184,7 +184,6 @@ class Danmu extends Model
$types = self::positionTypes();
$keys = array_keys($types);
$index = array_rand($keys);
return $keys[$index];
@ -195,7 +194,6 @@ class Danmu extends Model
$types = self::colorTypes();
$keys = array_keys($types);
$index = array_rand($keys);
return $keys[$index];

View File

@ -90,23 +90,23 @@ class Help extends Model
public function beforeCreate()
{
$this->create_time = time();
/**
* text类型不会自动填充默认值
*/
if (is_null($this->content)) {
$this->content = '';
}
$this->create_time = time();
}
public function beforeUpdate()
{
$this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
$this->update_time = time();
}
public function afterCreate()

View File

@ -126,13 +126,13 @@ class ImGroup extends Model
public function beforeCreate()
{
$this->create_time = time();
if (empty($this->avatar)) {
$this->avatar = kg_default_avatar_path();
} elseif (Text::startsWith($this->avatar, 'http')) {
$this->avatar = self::getAvatarPath($this->avatar);
}
$this->create_time = time();
}
public function beforeUpdate()

View File

@ -102,13 +102,11 @@ class ImMessage extends Model
public function beforeCreate()
{
$this->create_time = time();
$this->chat_id = 0;
if ($this->receiver_type == self::TYPE_FRIEND) {
$this->chat_id = self::getChatId($this->sender_id, $this->receiver_id);
}
$this->create_time = time();
}
public function beforeUpdate()

View File

@ -41,7 +41,7 @@ class ImNotice extends Model
/**
* 条目类型
*
* @var string
* @var int
*/
public $item_type;
@ -106,25 +106,25 @@ class ImNotice extends Model
public function beforeCreate()
{
$this->create_time = time();
if (!empty($this->item_info)) {
$this->item_info = kg_json_encode($this->item_info);
}
$this->create_time = time();
}
public function beforeUpdate()
{
$this->update_time = time();
if (is_array($this->item_info)) {
if (is_array($this->item_info) && !empty($this->item_info)) {
$this->item_info = kg_json_encode($this->item_info);
}
$this->update_time = time();
}
public function afterFetch()
{
if (!empty($this->item_info) && is_string($this->item_info)) {
if (is_string($this->item_info) && !empty($this->item_info)) {
$this->item_info = json_decode($this->item_info, true);
}
}

View File

@ -112,22 +112,22 @@ class ImUser extends Model
public function beforeCreate()
{
$this->create_time = time();
if (empty($this->avatar)) {
$this->avatar = kg_default_avatar_path();
} elseif (Text::startsWith($this->avatar, 'http')) {
$this->avatar = self::getAvatarPath($this->avatar);
}
$this->create_time = time();
}
public function beforeUpdate()
{
$this->update_time = time();
if (Text::startsWith($this->avatar, 'http')) {
$this->avatar = self::getAvatarPath($this->avatar);
}
$this->update_time = time();
}
public function afterFetch()

View File

@ -19,13 +19,6 @@ class Learning extends Model
*/
public $request_id;
/**
* 计划编号
*
* @var int
*/
public $plan_id;
/**
* 课程编号
*
@ -47,6 +40,13 @@ class Learning extends Model
*/
public $user_id;
/**
* 计划编号
*
* @var int
*/
public $plan_id;
/**
* 持续时长
*

View File

@ -141,11 +141,11 @@ class Nav extends Model
public function beforeUpdate()
{
$this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
$this->update_time = time();
}
public static function positionTypes()

View File

@ -77,14 +77,14 @@ class Order extends Model
/**
* 条目编号
*
* @var string
* @var int
*/
public $item_id;
/**
* 条目类型
*
* @var string
* @var int
*/
public $item_type;
@ -144,24 +144,24 @@ class Order extends Model
public function beforeCreate()
{
$this->sn = date('YmdHis') . rand(1000, 9999);
$this->status = self::STATUS_PENDING;
$this->create_time = time();
$this->sn = date('YmdHis') . rand(1000, 9999);
if (is_array($this->item_info)) {
if (is_array($this->item_info) && !empty($this->item_info)) {
$this->item_info = kg_json_encode($this->item_info);
}
$this->create_time = time();
}
public function beforeUpdate()
{
$this->update_time = time();
if (is_array($this->item_info)) {
if (is_array($this->item_info) && !empty($this->item_info)) {
$this->item_info = kg_json_encode($this->item_info);
}
$this->update_time = time();
}
public function afterSave()
@ -178,7 +178,7 @@ class Order extends Model
{
$this->amount = (float)$this->amount;
if (!empty($this->item_info) && is_string($this->item_info)) {
if (is_string($this->item_info) && !empty($this->item_info)) {
$this->item_info = json_decode($this->item_info, true);
}
}
@ -198,6 +198,7 @@ class Order extends Model
{
return [
self::STATUS_PENDING => '待支付',
self::STATUS_SHIPPING => '发货中',
self::STATUS_FINISHED => '已完成',
self::STATUS_CLOSED => '已关闭',
self::STATUS_REFUNDED => '已退款',

View File

@ -22,7 +22,7 @@ class OrderStatus extends Model
/**
* 状态类型
*
* @var string
* @var int
*/
public $status;

View File

@ -102,11 +102,11 @@ class Package extends Model
public function beforeUpdate()
{
$this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
$this->update_time = time();
}
public function afterCreate()

View File

@ -76,23 +76,23 @@ class Page extends Model
public function beforeCreate()
{
$this->create_time = time();
/**
* text类型不会自动填充默认值
*/
if (is_null($this->content)) {
$this->content = '';
}
$this->create_time = time();
}
public function beforeUpdate()
{
$this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
$this->update_time = time();
}
public function afterCreate()

View File

@ -27,7 +27,7 @@ class Refund extends Model
/**
* 用户编号
*
* @var string
* @var int
*/
public $owner_id;
@ -69,7 +69,7 @@ class Refund extends Model
/**
* 状态类型
*
* @var string
* @var int
*/
public $status;
@ -132,13 +132,6 @@ class Refund extends Model
$this->sn = date('YmdHis') . rand(1000, 9999);
$this->create_time = time();
/**
* 退款周期内无条件审批状态为approved
*/
if (!$this->status) {
$this->status = self::STATUS_PENDING;
}
}
public function beforeUpdate()

View File

@ -22,7 +22,7 @@ class RefundStatus extends Model
/**
* 状态类型
*
* @var string
* @var int
*/
public $status;

View File

@ -131,20 +131,20 @@ class Review extends Model
public function beforeCreate()
{
$this->create_time = time();
$this->rating = $this->getAvgRating();
$this->create_time = time();
}
public function beforeUpdate()
{
$this->update_time = time();
$this->rating = $this->getAvgRating();
if ($this->deleted == 1) {
$this->published = 0;
}
$this->update_time = time();
}
protected function getAvgRating()

View File

@ -103,25 +103,25 @@ class Role extends Model
public function beforeCreate()
{
$this->create_time = time();
if (!empty($this->routes)) {
if (is_array($this->routes) && !empty($this->routes)) {
$this->routes = kg_json_encode($this->routes);
}
$this->create_time = time();
}
public function beforeUpdate()
{
$this->update_time = time();
if (is_array($this->routes)) {
if (is_array($this->routes) && !empty($this->routes)) {
$this->routes = kg_json_encode($this->routes);
}
$this->update_time = time();
}
public function afterFetch()
{
if (!empty($this->routes) && is_string($this->routes)) {
if (is_string($this->routes) && !empty($this->routes)) {
$this->routes = json_decode($this->routes, true);
}
}

View File

@ -64,7 +64,7 @@ class Task extends Model
/**
* 状态标识
*
* @var string
* @var int
*/
public $status;
@ -98,25 +98,25 @@ class Task extends Model
{
$this->status = self::STATUS_PENDING;
$this->create_time = time();
if (!empty($this->item_info)) {
if (is_array($this->item_info) && !empty($this->item_info)) {
$this->item_info = kg_json_encode($this->item_info);
}
$this->create_time = time();
}
public function beforeUpdate()
{
$this->update_time = time();
if (is_array($this->item_info)) {
if (is_array($this->item_info) && !empty($this->item_info)) {
$this->item_info = kg_json_encode($this->item_info);
}
$this->update_time = time();
}
public function afterFetch()
{
if (!empty($this->item_info) && is_string($this->item_info)) {
if (is_string($this->item_info) && !empty($this->item_info)) {
$this->item_info = json_decode($this->item_info, true);
}
}

View File

@ -88,11 +88,11 @@ class Topic extends Model
public function beforeUpdate()
{
$this->update_time = time();
if ($this->deleted == 1) {
$this->published = 0;
}
$this->update_time = time();
}
public function afterCreate()

View File

@ -66,7 +66,7 @@ class Trade extends Model
/**
* 平台类型
*
* @var string
* @var int
*/
public $channel;
@ -80,7 +80,7 @@ class Trade extends Model
/**
* 状态类型
*
* @var string
* @var int
*/
public $status;
@ -126,11 +126,11 @@ class Trade extends Model
public function beforeCreate()
{
$this->create_time = time();
$this->status = self::STATUS_PENDING;
$this->sn = date('YmdHis') . rand(1000, 9999);
$this->create_time = time();
}
public function beforeUpdate()

View File

@ -22,7 +22,7 @@ class TradeStatus extends Model
/**
* 状态类型
*
* @var string
* @var int
*/
public $status;

View File

@ -177,13 +177,13 @@ class User extends Model
public function beforeCreate()
{
$this->create_time = time();
if (empty($this->avatar)) {
$this->avatar = kg_default_avatar_path();
} elseif (Text::startsWith($this->avatar, 'http')) {
$this->avatar = self::getAvatarPath($this->avatar);
}
$this->create_time = time();
}
public function beforeUpdate()

View File

@ -19,7 +19,7 @@ type = string
[about]
type = body
[location]
[area]
type = string
index = self