1
0

first commit

This commit is contained in:
2020-08-06 14:58:51 +08:00
commit 17096657dc
780 changed files with 92857 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class Advert extends _Init
{
/**
* 模型初始化【事件注册】
*/
protected static function init()
{
self::beforeUpdate(function ($data) {
$data->update_time = time();
});
self::beforeInsert(function ($data) {
$data->create_time = time();
$data->update_time = 0;
$data->status = 1;
});
}
public function detail()
{
return $this->hasMany('AdvertDetail')->where('status', '>=', 0);
}
}

View File

@@ -0,0 +1,34 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class AdvertDetail extends _Init
{
/**
* 模型初始化【事件注册】
*/
protected static function init()
{
self::beforeUpdate(function ($data) {
$data->update_time = time();
});
self::beforeInsert(function ($data) {
$data->create_time = time();
$data->update_time = 0;
$data->click = 0;
$data->status = 1;
});
}
public function getCoverAttr($value, $data)
{
return Storage::where('id', $data['storage_id'])->value('path') ?: '';
}
}

View File

@@ -0,0 +1,58 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class Article extends _Init
{
/**
* 模型初始化【事件注册】
*/
protected static function init()
{
self::beforeInsert(function ($data) {
$data->status = 1;
});
}
/**
* 获取封面地址
* @param [type] $value 封面id
* @param [type] $data 文章数据
* @return [type] 图片地址
*/
public function getCoverAttr($value, $data)
{
return Storage::where('id', $data['storage_id'])->find();
}
/**
* 获取封面地址
* @param [type] $value 封面id
* @param [type] $data 文章数据
* @return [type] 图片地址
*/
public function getCreateTimeAttr($value, $data)
{
return date('Y-m-d', $value);
}
/**
* 获取关联的分类
* @return [type] [description]
*/
public function category()
{
return $this->hasOne('Category', 'id', 'category_id');
}
public function user()
{
return $this->belongsTo('MemberInfo', 'uid', 'uid');
}
}

View File

@@ -0,0 +1,20 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class ArticleModel extends _Init
{
protected static function init()
{
self::beforeInsert(function ($data) {
$data->status = 1;
$data->sort = $data['sort'] ?: 0;
});
}
}

View File

@@ -0,0 +1,20 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class Auth extends _Init
{
/**
* 获取用户数量
*/
protected function getUserCountAttr()
{
return $this->hasMany('AuthUser')->count();
}
}

View File

@@ -0,0 +1,35 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class AuthUser extends _Init
{
/**
* 关闭更新时间写入
*/
protected $updateTime = false;
/**
* 关联用户模型
* @return [type] [description]
*/
public function user()
{
return $this->hasOne('Member', 'id', 'uid');
}
/**
* 关联分组
* @return [type] [description]
*/
public function auth()
{
return $this->belongsTo('Auth');
}
}

View File

@@ -0,0 +1,33 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
use think\Config;
class Category extends _Init
{
/**
* 获取封面地址
* @param [type] $value 封面id
* @param [type] $data 文章数据
* @return [type] 图片地址
*/
public function getCoverAttr($value, $data)
{
return Storage::where('id', $data['storage_id'])->value('path');
}
public function getModelAttr($value, $data)
{
$list = config::get('category_model');
$name = $list[$data['model']];
return $name ?? '没有';
}
}

View File

@@ -0,0 +1,13 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class City extends _Init
{
}

View File

@@ -0,0 +1,96 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
use think\Cache;
class Config extends _Init
{
/**
* 模型初始化【事件注册】
*/
protected static function init()
{
self::afterWrite(function () {
Cache::clear();
});
}
/**
* 获取器
*/
protected function getTypeTextAttr($value, $data)
{
return Config::getValue($data['type'], 'config_type_list');
}
protected function getGroupTextAttr($value, $data)
{
return Config::getValue($data['group'], 'config_group_list');
}
/**
* 配置列表,优化输出
*/
protected function getValueTextAttr($value, $data)
{
return preg_replace('/\r\n/', "<br/>", $data['value']);
}
/**
* 格式化枚举类型的配置
*/
protected function getExtraArrayAttr($value, $data)
{
$array = preg_split('/[\r\n]+/', trim($data['extra'], "\r\n"));
$enum = [];
if (strpos($data['extra'], ':')) {
foreach ($array as $val) {
list($k, $v) = explode(':', $val, 2);
$enum[$k] = $v;
}
} else {
$enum = $array;
}
return $enum;
}
/**
* 获取配置内容
* @param string $key
* @param string $type
* @return string
*/
public static function getValue($key, $type = null)
{
if ($key == -1) {
return '<span style="color:#D2322D;">已删除</span>';
}
if (!is_null($type) && is_string($type)) {
$res = \think\Config::get($type);
$res = isset($res[$key]) ? $res[$key] : '';
} elseif (!is_null($type) && is_array($type)) {
$res = isset($type[$key]) ? $type[$key] : '';
} else {
switch ($key) {
case 0:$res = '<span style="color:#E48600;">禁用</span>';
break;
case 1:$res = '<span style="color:#229F24;">正常</span>';
break;
case 2:$res = '<span style="color:#39B3D7;">待审核</span>';
break;
case 3:$res = '<span style="color:#E48600;">被驳回</span>';
break;
default:$res = '';
break;
}
}
return $res;
}
}

View File

@@ -0,0 +1,42 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class Content extends _Init
{
/**
* 模型初始化【事件注册】
*/
protected static function init()
{
self::beforeInsert(function ($data) {
$data->status = 1;
});
}
/**
* 获取封面地址
* @param [type] $value 封面id
* @param [type] $data 文章数据
* @return [type] 图片地址
*/
public function getCoverAttr($value, $data)
{
return Storage::where('id', $data['storage_id'])->value('path');
}
/**
* 获取关联的分类
* @return [type] [description]
*/
public function category()
{
return $this->hasOne('Category', 'id', 'category_id');
}
}

View File

@@ -0,0 +1,44 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class Direct extends _Init
{
/**
* 模型初始化【事件注册】
*/
protected static function init()
{
self::beforeInsert(function ($data) {
$data->status = 1;
});
}
/**
* 获取封面地址
* @param [type] $value 封面id
* @param [type] $data 文章数据
* @return [type] 图片地址
*/
public function getCoverAttr($value, $data)
{
return Storage::where('id', $data['storage_id'])->value('path');
}
/**
* 获取音/视频地址
* @param [type] $value 封面id
* @param [type] $data 文章数据
* @return [type] 图片地址
*/
public function getExtPathAttr($value, $data)
{
return Storage::where('id', $data['ext_id'])->value('path');
}
}

View File

@@ -0,0 +1,38 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class Experience extends _Init
{
/**
* 模型初始化【事件注册】
*/
protected static function init()
{
self::beforeInsert(function ($data) {
$data->status = 1;
});
}
public function user()
{
return $this->belongsTo('MemberInfo', 'uid', 'uid');
}
public function comment()
{
return $this->hasMany('Experience', 'pid', 'id')->order('id asc');
}
public function getCountAttr($value, $data)
{
$res = ExperienceTags::where(['experience_id' => $data['id'], 'uid' => UID])->count();
return $res;
}
}

View File

@@ -0,0 +1,15 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class ExperienceTags extends _Init
{
protected $updateTime = false;
}

View File

@@ -0,0 +1,36 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
use think\Config;
class Help extends _Init
{
/**
* 模型初始化【事件注册】
*/
protected static function init()
{
self::beforeInsert(function ($data) {
$data->status = 1;
});
}
public function getCategoryAttr($value, $data)
{
$list = Config::get('help_type');
return empty($list[$data['category']]) ? '没这个分类' : $list[$data['category']];
}
public function getCreateTimeAttr($value, $data)
{
return date('Y-m-d', $value);
}
}

View File

@@ -0,0 +1,59 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class Logs extends _Init
{
/**
* 关闭更新时间写入
*/
protected $updateTime = false;
/**
* 转换datas数据
* @param [type] $value 数据内容
*/
protected function setDatasAttr($value)
{
return !empty($value) ? json_encode($value, JSON_UNESCAPED_UNICODE) : '';
}
/**
* 获取昵称
*/
protected function getUidTextAttr($value, $data)
{
return MemberInfo::where('uid', $data['uid'])->value('nickname');
}
/**
* 格式化datas数据
* @param [type] $value datas数据
* @param [type] $data 数据集合
*/
protected function getDatasTextAttr($value, $data)
{
$content = $data['datas'];
if (!empty($content)) {
$content = json_decode($content);
$string = '';
if (is_object($content) && !empty($content)) {
foreach ($content as $key => $value) {
$string .= $key . ' : ' . json_encode($value, JSON_UNESCAPED_UNICODE) . '<br/>';
}
} else {
$string = $content;
}
return $string;
} else {
return '';
}
}
}

View File

@@ -0,0 +1,68 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
use think\Config as Conf;
use think\Request;
use tools\Crypt;
class Member extends _Init
{
protected $readonly = [''];
/**
* 模型初始化【事件注册】
*/
protected static function init()
{
self::beforeInsert(function ($data) {
$data->reg_ip = Request::instance()->ip();
});
}
/**
* 格式化 最后登录时间
* @param [type] $value 最后登录时间 时间戳
*/
protected function getLastTimeAttr($value)
{
return date(Conf::get('database.datetime_format'), $value);
}
/**
* 加密密码
* @param [type] $value [description]
*/
protected function setPasswordAttr($value)
{
return Crypt::uMd5($value);
}
/**
* 用户资料
*/
protected function info()
{
return $this->hasOne('MemberInfo', 'uid', 'id');
}
/**
* 关联 AuthUser 表
* @return [type] [description]
*/
public function authUser()
{
return $this->hasOne('AuthUser', 'uid', 'id');
}
public function getJuniorAttr($value, $data)
{
return MemberList::where('uid', $data['id'])->count();
}
}

View File

@@ -0,0 +1,96 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class MemberInfo extends _Init
{
protected $createTime = false;
protected $readonly = ['image'];
/**
* 获取头像地址
* @param [type] $value [description]
* @param [type] $data [description]
* @return [type] [description]
*/
protected function getAvatarAttr($value, $data)
{
$avatar = $data['headimgurl'];
if (!empty($avatar) && strpos($avatar, 'wx.qlogo.cn')) {
return rtrim($avatar, '0') . '132';
} elseif (empty($avatar)) {
return '/static/system/images/avatar.jpg';
} else {
return $avatar;
}
}
/**
* 获取头像地址
* @param [type] $value [description]
* @param [type] $data [description]
* @return [type] [description]
*/
protected function getQrcodeAttr($value, $data)
{
$path = Storage::where('id', $data['qrcode'])->value('path');
return $path ?? '';
}
/**
* 判断用户是否为 未过期的VIP会员
* @param [type] $value [description]
* @param [type] $data [description]
* @return [type] [description]
*/
protected function getIsVipAttr($value, $data)
{
if ($data['vip_time'] > time() && $data["is_vip"] == 1) {
return 1;
} else {
return 0;
}
}
protected function getVipTextAttr($value, $data)
{
if ($data['vip_time'] > time() && $data["is_vip"] == 1) {
return 'VIP会员';
} else {
return '普通会员';
}
}
protected function getVipTimeAttr($value, $data)
{
if ($value < time()) {
return '永久';
} else {
return date('Y-m-d', $value);
}
}
protected function getVipEndTimeAttr($value, $data)
{
return $data['vip_time'];
}
protected function getIndexTplAttr($value, $data)
{
if ($this->is_vip) {
return $value;
} else {
return 1;
}
}
protected function getMessageCountAttr($value, $data)
{
return Message::where('to_uid', $data['uid'])->count();
}
}

View File

@@ -0,0 +1,14 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class MemberList extends _Init
{
}

View File

@@ -0,0 +1,34 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class Menu extends _Init
{
protected function getUrlTextAttr($value, $data)
{
if ($data['url']) {
return url($data['url']);
} else {
return '';
}
}
/**
* 修改器
*/
protected function setAuthAttr($value, $data)
{
return parent::parseStatus($value);
}
protected function setHideAttr($value, $data)
{
return parent::parseStatus($value);
}
}

View File

@@ -0,0 +1,22 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
/**
*留言
*/
class Message extends _Init
{
protected $updateTime = false;
public function user()
{
return $this->belongsTo('MemberInfo', 'from_uid', 'uid');
}
}

View File

@@ -0,0 +1,21 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class Province extends _Init
{
/**
* 模型初始化【事件注册】
*/
protected static function init()
{
self::beforeInsert(function ($data) {
});
}
}

View File

@@ -0,0 +1,39 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class Score extends _Init
{
/**
* 关闭更新时间写入
*/
protected $updateTime = false;
public function user()
{
return $this->belongsTo('MemberInfo', 'uid', 'uid');
}
public function getScoreAttr($value, $data)
{
return floatval($value);
}
public function getRulesAttr($value, $data)
{
$map = ['model' => $data['rule_id']];
return ScoreRules::where($map)->find();
}
public function getAddtimeAttr($value, $data)
{
return date('Y-m-d', $data['create_time']);
}
}

View File

@@ -0,0 +1,28 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class ScoreRules extends _Init
{
/**
* 模型初始化【事件注册】
*/
protected static function init()
{
self::beforeInsert(function ($data) {
$data->status = 1;
});
}
public function getCreateTimeAttr($value, $data)
{
return date('Y-m-d', $value);
}
}

View File

@@ -0,0 +1,27 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class Sms extends _Init
{
public function getStatusAttr($value)
{
switch ($value) {
case '0':
return '<span style="color:red">未使用</span>';
break;
case '1':
return '<span style="color:green">已使用</span>';
break;
default:
break;
}
}
}

View File

@@ -0,0 +1,17 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class Storage extends _Init
{
/**
* 关闭更新时间写入
*/
protected $updateTime = false;
}

View File

@@ -0,0 +1,17 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class Suggest extends _Init
{
public function info()
{
return $this->belongsTo('MemberInfo', 'uid', 'uid');
}
}

View File

@@ -0,0 +1,14 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class Template extends _Init
{
}

View File

@@ -0,0 +1,53 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
use tools\Str;
class VipOrder extends _Init
{
/**
* 模型初始化【事件注册】
*/
protected static function init()
{
self::beforeInsert(function ($data) {
$data->orderid = Str::orderid('VIP');
});
}
public function getStatusAttr($value)
{
switch ($value) {
case '0':
return '<span style="color:red">未支付</span>';
break;
case '20':
return '<span style="color:green">已支付</span>';
break;
default:
break;
}
}
public function getModelAttr($value, $data)
{
if ($data['model'] == 'weixin') {
return '微信支付';
} else if ($data['model'] == 'score') {
return '积分兑换';
} else {
return '未知';
}
}
public function user()
{
return $this->belongsTo('MemberInfo', 'uid', 'uid');
}
}

View File

@@ -0,0 +1,30 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
use think\Model;
class _Init extends Model
{
protected function setStatusAttr($value)
{
return self::parseStatus($value);
}
protected function parseStatus($status)
{
if (is_numeric($status)) {
return $status;
} elseif ($status == 'true' || $status == 'on') {
return 1;
} elseif ($status == 'false' || $status == 'off') {
return 0;
}
}
}