初始化项目:添加后端代码、ThinkPHP框架、前端资源
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model\app\pc;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class Page extends Model
|
||||
{
|
||||
|
||||
|
||||
// 表名
|
||||
protected $name = 'app_pc_page';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'status_text'
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function getStatusList()
|
||||
{
|
||||
return ['0' => __('Status 0'), '1' => __('Status 1')];
|
||||
}
|
||||
|
||||
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
|
||||
$list = $this->getStatusList();
|
||||
return isset($list[$value]) ? $list[$value] : '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 转换数据结构
|
||||
* @param $params
|
||||
* @param $type
|
||||
* @return mixed
|
||||
*/
|
||||
public function paramsStructure($params,$type = 'encode')
|
||||
{
|
||||
if($type=='encode'){
|
||||
if(isset($params['page'])){
|
||||
$params['page'] = json_encode($params['page']);
|
||||
}
|
||||
if(isset($params['components'])){
|
||||
$params['components'] = json_encode($params['components']);
|
||||
}
|
||||
}else{
|
||||
if(isset($params['page'])){
|
||||
$params['page'] = json_decode($params['page'],true);
|
||||
}
|
||||
|
||||
if(isset($params['components'])){
|
||||
$params['components'] = json_decode($params['components'],true);
|
||||
}
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user