This commit is contained in:
2025-12-24 16:59:05 +08:00
parent b52a51c09b
commit b68946fe79
218 changed files with 10790 additions and 3878 deletions
+17 -3
View File
@@ -75,9 +75,18 @@ class Archives extends Base
public function getCategoryOptions($type='default'){
return Category::where('status','1')->where('type',$type)->column('id,title');
}
function setCreatedAtAttr($v,$row=[]){
cp($v);
cp($row);
function setCreatedAtAttr($v){
if($v && strpos($v,'-')){
return strtotime($v);
}
return $v;
}
function setUpdatedAtAttr($v){
if($v && strpos($v,'-')){
return strtotime($v);
}
return $v;
}
@@ -86,6 +95,11 @@ class Archives extends Base
return Config('site.flagtype');
}
public function content()
{
return $this->hasOne('content', 'id', 'id');
// ->bind(['content']);//->setEagerlyType(0);
}
public function category()
{
return $this->belongsTo('Category', 'category_id', 'id');//->setEagerlyType(0);
+5
View File
@@ -11,4 +11,9 @@ use app\model\Base;
*/
class Content extends Base
{
protected function getOptions(): array{
return array_merge(parent::getOptions(),[
'autoWriteTimestamp' => false
]);
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace app\model;
use app\model\Base;
/**
* @property integer $id 主键(ID)
* @property integer $user_id 用户ID
* @property string $title 名字
* @property string $path 文件
* @property integer $size 大小
* @property string $mime_type 文件类型
* @property string $extension 扩展名
* @property integer $height 高度
* @property integer $width 宽度
* @property string $sha1 文件sha1值
* @property integer $use_count 使用次数
* @property integer $created_at 创建时间
* @property integer $updated_at 更新时间
* @property integer $deleted_at 删除时间
*/
class Files extends Base
{
protected $name = 'files';
public function user()
{
return $this->belongsTo('User', 'user_id', 'id');//->setEagerlyType(0);
}
}
+138
View File
@@ -0,0 +1,138 @@
<?php
namespace app\model;
/**
* 朋友圈动态模型
* @property integer $id 主键(ID)
* @property integer $user_id 用户ID
* @property string $body 内容
* @property string $files 图片列表(JSON)
* @property integer $like_count 点赞数
* @property integer $comment_count 评论数
* @property integer $created_at 创建时间
* @property integer $updated_at 更新时间
* @property integer $status 状态(0:隐藏 1:正常)
*/
class FriendCircle extends Base
{
protected $name = 'friend_circle';
protected function getOptions(): array
{
return array_merge(parent::getOptions(), [
'insert' => [
'status' => 1,
'like_count' => 0,
'comment_count' => 0,
],
]);
}
public static function onAfterInsert($row){
$changeData = $row->getChangedData();
if(isset($changeData['files'])) {
$files = json_decode($changeData['files'],true);
Files::whereIn('path',$files)->inc('use_count');
};
}
public static function onAfterUpdate($row){
$OrgData = $row->getOrigin();
$changeData = $row->getChangedData();
if(isset($OrgData['files'])) {
if(is_array($OrgData['files'])){
\support\Log::alert('OrgData array');
}else{
\support\Log::info('OrgData string');
$files = json_decode($OrgData['files'],true);
Files::whereIn('path',$files)->dec('use_count');
}
};
if(isset($changeData['files'])) {
if(is_array($changeData['files'])){
\support\Log::alert('changeData array');
}else{
\support\Log::info('changeData string');
$files = json_decode($changeData['files'],true);
Files::whereIn('path',$files)->inc('use_count');
}
};
}
/**
* 关联用户
*/
public function user()
{
return $this->belongsTo('\\app\\model\\User', 'user_id', 'id');
}
/**
* 关联点赞
*/
public function likes()
{
return $this->hasMany('\\app\\model\\FriendCircleLike', 'circle_id', 'id');
}
/**
* 关联评论
*/
public function comments()
{
return $this->hasMany('\\app\\model\\FriendCircleComment', 'circle_id', 'id');
}
/**
* 获取图片列表
*/
public function getFilesAttr($value)
{
if (empty($value)) {
return [];
}
if(is_array($value)){
return $value;
}
$files = json_decode($value, true);
return is_array($files) ? $files : [];
}
/**
* 设置图片列表
*/
public function setFilesAttr($value)
{
if (empty($value)) {
return '[]';
}
if (is_array($value)) {
return json_encode($value, JSON_UNESCAPED_UNICODE);
}
return $value;
}
/**
* 获取图片列表
*/
public function getAddressAttr($value)
{
if (empty($value)) {
return [];
}
$files = json_decode($value, true);
return is_array($files) ? $files : [];
}
/**
* 设置图片列表
*/
public function setAddressAttr($value)
{
if (empty($value)) {
return '{"chooseFlag":false}';
}
if (is_array($value)) {
return json_encode($value, JSON_UNESCAPED_UNICODE);
}
return $value;
}
}
+54
View File
@@ -0,0 +1,54 @@
<?php
namespace app\model;
/**
* 朋友圈评论模型
* @property integer $id 主键(ID)
* @property integer $circle_id 朋友圈动态ID
* @property integer $user_id 用户ID
* @property integer $reply_user_id 回复的用户ID(0表示直接评论)
* @property string $body 评论内容
* @property integer $created_at 创建时间
* @property integer $updated_at 更新时间
* @property integer $status 状态(0:隐藏 1:正常)
*/
class FriendCircleComment extends Base
{
protected $name = 'friend_circle_comment';
protected $autoWriteTimestamp = true;
protected function getOptions(): array
{
return array_merge(parent::getOptions(), [
'insert' => [
'status' => 1,
'reply_user_id' => 0,
],
]);
}
/**
* 关联朋友圈动态
*/
public function circle()
{
return $this->belongsTo('\\app\\model\\FriendCircle', 'circle_id', 'id');
}
/**
* 关联评论用户
*/
public function user()
{
return $this->belongsTo('\\app\\model\\User', 'user_id', 'id');
}
/**
* 关联被回复的用户
*/
public function replyUser()
{
return $this->belongsTo('\\app\\model\\User', 'reply_user_id', 'id');
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace app\model;
/**
* 朋友圈点赞模型
* @property integer $id 主键(ID)
* @property integer $circle_id 朋友圈动态ID
* @property integer $user_id 用户ID
* @property integer $created_at 创建时间
*/
class FriendCircleLike extends Base
{
protected $name = 'friend_circle_like';
protected $autoWriteTimestamp = 'int';
/**
* 关联朋友圈动态
*/
public function circle()
{
return $this->belongsTo('\\app\\model\\FriendCircle', 'circle_id', 'id');
}
/**
* 关联用户
*/
public function user()
{
return $this->belongsTo('\\app\\model\\User', 'user_id', 'id');
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace app\model;
use app\model\Base;
/**
* @property integer $id 主键(ID) - 无注释
* @property string $title 名称
* @property float $price 价格
* @property float $org_price 原价
* @property integer $duration 时长
* @property string $label 标签
* @property integer $status 0:禁用,1启用
* @property integer $created_at 创建时间
* @property integer $updated_at 更新时间
*/
class Thali extends Base
{
protected function getOptions(): array
{
// 所有的参数配置统一返回
return array_merge(parent::getOptions(),[
'append' => []
]);
}
}
+9 -4
View File
@@ -82,12 +82,12 @@ class User extends Base
public static function onAfterUpdate($row){
$changeData = $row->getChangedData();
$orgData = $row->getOrigin();
//cp($changeData);
if(isset($changeData['avatar']) || isset($changeData['nickname'])){
request()->IM->user->updateUserInfo($row->id,[
$sdata = [
'nickname' => $row->nickname,
'faceURL' => cdnurl($row->avatar)
]);
];
request()->IM->user->updateUserInfo($row->id,$sdata);
}
if(isset($changeData['status']) || $changeData['status'] == '0'){
request()->IM->user->forceLogout($row->id);
@@ -130,7 +130,12 @@ class User extends Base
{
return $this->hasMany(UserTeam::class, 'ancestor_id', 'id');
}
function setExpireAtAttr($v){
if($v && strpos($v,'-')){
return strtotime($v);
}
return $v;
}
public static function transform($from_currency,$to_currency,$user_id,$amount,\app\enum\BalanceType $type,$memo=null){
if(!in_array($from_currency,Config('site.allow_currencys'))){
+9 -3
View File
@@ -5,11 +5,17 @@ namespace app\model;
/**
* @property integer $id 主键(主键)
* @property integer $pid 上级id
* @property string $name 角色名
* @property string $rules 权限
* @property string $created_at 创建时间
* @property string $updated_at 更新时间
* @property integer $pid 上级id
* @property integer $max_send_msg_count 最大消息数量
* @property integer $max_friend_count 最大好友数量
* @property integer $max_group_join_count 最大加入的群组数量
* @property integer $max_gourp_create_count 最大创建的群组数量
* @property integer $created_at 创建时间
* @property integer $updated_at 更新时间
* @property integer $status 状态
*/
class UserRole extends Base
{
-1
View File
@@ -3,7 +3,6 @@
namespace app\model;
use app\model\Base;
use support\Model;
/**
* @property integer $id 主键(主键)
* @property string $title 标题
+69
View File
@@ -0,0 +1,69 @@
<?php
namespace app\model;
use app\model\Base;
/**
* @property integer $id 主键(ID) - 无注释
* @property integer $user_id 用户ID
* @property float $deduction_amount 提现金额
* @property float $recive_amount 到账金额
* @property float $fee 后续费
* @property string $title 姓名
* @property string $network 方式
* @property string $address 地址
* @property integer $transfer_at 转账时间
* @property string $txid 凭证
* @property string $memo 备注
* @property integer $created_at 创建时间
* @property integer $updated_at 更新时间
* @property integer $status 状态
*/
class Version extends Base
{
protected function getOptions(): array
{
// 所有的参数配置统一返回
return array_merge(parent::getOptions(),[
'append' => ['source_text']
]);
}
function getSourceTextAttr($v,$row){
if($v){
return cdnurl($v);
}
}
function getOsList(){
return [
"android"=>"Android",
"ios"=>"IOS",
"harmonry"=>"鸿蒙"
];
}
function getTypeList(){
return [
"1"=>"WGT热更新",
"0"=>"整包更新",
"2"=>"外链下载更新"
];
}
function getForceList(){
return [
"0"=>"可选更新",
"1"=>"强制更新",
];
}
function getStatusList(){
return [
'0' => '禁用',
'1' => '启用'
];
}
public function user()
{
return $this->belongsTo('User', 'user_id', 'id');//->setEagerlyType(0);
}
}