初始化项目:添加后端代码、ThinkPHP框架、前端资源
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model\app\msgpush;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class Config extends Model
|
||||
{
|
||||
|
||||
protected $configName = 'msg_push_option';
|
||||
|
||||
|
||||
/**
|
||||
* 获取场景配置
|
||||
* @param $senceName
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function getSenceConfig($senceName){
|
||||
|
||||
$config = \app\common\model\app\Config::getConfig($this->configName);
|
||||
|
||||
if(isset($config[$senceName])){
|
||||
$config[$senceName]['status'] = intval($config[$senceName]['status']);
|
||||
return $config[$senceName];
|
||||
}
|
||||
return [
|
||||
'status'=>0,
|
||||
'template_id'=>'',
|
||||
'config'=>[]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function getSenceList(){
|
||||
$options = config('message_push_options');
|
||||
|
||||
$list = [];
|
||||
|
||||
foreach ($options as $index => $item){
|
||||
$list[$index] = $item['name'];
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model\app\msgpush;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class Log extends Model
|
||||
{
|
||||
|
||||
|
||||
// 表名
|
||||
protected $name = 'app_msg_push_log';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = false;
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'status_text',
|
||||
'msg_type_text',
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function getStatusList()
|
||||
{
|
||||
return ['1' => __('Status 1'), '0' => __('Status 0'), '2' => __('Status 2')];
|
||||
}
|
||||
|
||||
public function getMsgTypeList()
|
||||
{
|
||||
$options = config('message_push_options');
|
||||
|
||||
$list = [];
|
||||
|
||||
foreach ($options as $index => $item){
|
||||
$list[$index] = $item['name'];
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
|
||||
$list = $this->getStatusList();
|
||||
return isset($list[$value]) ? $list[$value] : '';
|
||||
}
|
||||
|
||||
|
||||
public function getMsgTypeTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ? $value : (isset($data['msg_type']) ? $data['msg_type'] : '');
|
||||
|
||||
$list = $this->getMsgTypeList();
|
||||
return isset($list[$value]) ? $list[$value] : '';
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user