This commit is contained in:
Your Name
2026-07-22 10:18:59 +08:00
parent 2530ddada6
commit 0fb03d0bca
618 changed files with 19445 additions and 3 deletions
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace app\model;
use think\Model;
class AiModel extends Model
{
protected $name = 'ai_models';
protected $autoWriteTimestamp = true;
protected $createTime = 'created_at';
protected $updateTime = 'updated_at';
protected $type = [
'extra_config' => 'json',
];
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace app\model;
use think\Model;
class Conversation extends Model
{
protected $name = 'conversations';
protected $autoWriteTimestamp = true;
protected $createTime = 'created_at';
protected $updateTime = 'updated_at';
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
public function aiModel()
{
return $this->belongsTo(AiModel::class, 'model_id');
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace app\model;
use think\Model;
class Department extends Model
{
protected $name = 'departments';
protected $autoWriteTimestamp = true;
protected $createTime = 'created_at';
protected $updateTime = 'updated_at';
public function parent()
{
return $this->belongsTo(self::class, 'parent_id');
}
public function children()
{
return $this->hasMany(self::class, 'parent_id');
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace app\model;
use think\Model;
class MembershipLevel extends Model
{
protected $name = 'membership_levels';
protected $autoWriteTimestamp = true;
protected $createTime = 'created_at';
protected $updateTime = 'updated_at';
protected $type = [
'permissions' => 'json',
'allowed_models' => 'json',
];
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace app\model;
use think\Model;
class Message extends Model
{
protected $name = 'messages';
protected $autoWriteTimestamp = 'created_at';
protected $createTime = 'created_at';
protected $updateTime = false;
protected $type = [
'attachments' => 'json',
];
}
+58
View File
@@ -0,0 +1,58 @@
<?php
namespace app\model;
use app\service\PermissionCatalog;
use think\Model;
class Role extends Model
{
protected $name = 'roles';
protected $autoWriteTimestamp = true;
protected $createTime = 'created_at';
protected $updateTime = 'updated_at';
public static function defaultPermissions(): array
{
return PermissionCatalog::emptyPermissions();
}
public function getPermissionsAttr($value): array
{
return PermissionCatalog::normalize(self::toPermArray($value));
}
public function setPermissionsAttr($value): string
{
return json_encode(
PermissionCatalog::normalize(self::toPermArray($value)),
JSON_UNESCAPED_UNICODE
);
}
/**
* ThinkPHP 8 会把 JSON 列转成 \think\model\type\Json,需调用 value() 取出数组。
*/
private static function toPermArray(mixed $value): array
{
if ($value === null || $value === '') {
return [];
}
if (is_array($value)) {
return $value;
}
if (is_object($value) && method_exists($value, 'value')) {
$data = $value->value();
return is_array($data) ? $data : [];
}
if (is_string($value)) {
$decoded = json_decode($value, true);
return (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) ? $decoded : [];
}
return [];
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace app\model;
use think\Model;
class SysPermission extends Model
{
protected $name = 'sys_permissions';
protected $autoWriteTimestamp = true;
protected $createTime = 'created_at';
protected $updateTime = 'updated_at';
public function children()
{
return $this->hasMany(self::class, 'parent_id')->order('sort_order')->order('id');
}
public function parent()
{
return $this->belongsTo(self::class, 'parent_id');
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace app\model;
use think\Model;
class SystemSetting extends Model
{
protected $name = 'system_settings';
protected $autoWriteTimestamp = 'updated_at';
protected $updateTime = 'updated_at';
protected $createTime = false;
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace app\model;
use think\Model;
class UploadFile extends Model
{
protected $name = 'uploads';
protected $autoWriteTimestamp = 'created_at';
protected $createTime = 'created_at';
protected $updateTime = false;
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace app\model;
use think\Model;
class User extends Model
{
protected $name = 'users';
protected $autoWriteTimestamp = true;
protected $createTime = 'created_at';
protected $updateTime = 'updated_at';
public function membership()
{
return $this->belongsTo(MembershipLevel::class, 'membership_level_id');
}
public function roleModel()
{
return $this->belongsTo(Role::class, 'role_id');
}
public function department()
{
return $this->belongsTo(Department::class, 'department_id');
}
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace app\model;
use think\Model;
class UserDailyStat extends Model
{
protected $name = 'user_daily_stats';
protected $autoWriteTimestamp = false;
}