From a88944b5e156bc342a9e4cc05f98e7b70fdb63aa Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Feb 2026 16:56:51 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=88=A0=E9=99=A4=20users=20?= =?UTF-8?q?=E8=A1=A8=E4=B8=AD=E6=9C=AA=E4=BD=BF=E7=94=A8=E7=9A=84=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除 report_to(上级ID)字段 - 删除 position(职位)字段 - 更新 User 模型移除相关关联和类型转换 - 更新 BusinessTripService 移除 position 返回 Co-Authored-By: Claude Opus 4.6 --- backend/app/model/User.php | 19 ------------------ backend/app/service/BusinessTripService.php | 1 - .../014_remove_users_unused_fields.sql | 20 +++++++++++++++++++ 3 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 backend/database/migrations/014_remove_users_unused_fields.sql diff --git a/backend/app/model/User.php b/backend/app/model/User.php index f2c92a3..21961f8 100644 --- a/backend/app/model/User.php +++ b/backend/app/model/User.php @@ -14,7 +14,6 @@ class User extends Model protected $fillable = [ 'company_id', 'sn', - 'report_to', 'name', 'avatar', 'sex', @@ -25,13 +24,11 @@ class User extends Model 'user_type', 'union_id', // 飞书 UnionID - 用于跨应用识别用户 'feishu_app_id', // 最后登录的飞书应用ID - 用于快速获取默认应用 - 'position', 'sign_img', ]; protected $casts = [ 'company_id' => 'integer', - 'report_to' => 'integer', 'sex' => 'integer', 'status' => 'integer', 'user_type' => 'integer', @@ -51,22 +48,6 @@ class User extends Model return $this->belongsTo(Company::class, 'company_id'); } - /** - * 上级用户 - */ - public function parent() - { - return $this->belongsTo(User::class, 'report_to'); - } - - /** - * 下级用户 - */ - public function children() - { - return $this->hasMany(User::class, 'report_to'); - } - /** * 用户飞书应用绑定 */ diff --git a/backend/app/service/BusinessTripService.php b/backend/app/service/BusinessTripService.php index 133a7c9..84ee226 100644 --- a/backend/app/service/BusinessTripService.php +++ b/backend/app/service/BusinessTripService.php @@ -622,7 +622,6 @@ class BusinessTripService 'id' => $user->id, 'name' => $user->name, 'avatar' => $user->avatar, - 'position' => $user->position, ]; } } diff --git a/backend/database/migrations/014_remove_users_unused_fields.sql b/backend/database/migrations/014_remove_users_unused_fields.sql new file mode 100644 index 0000000..3c76faf --- /dev/null +++ b/backend/database/migrations/014_remove_users_unused_fields.sql @@ -0,0 +1,20 @@ +-- X-Server 删除 users 表中未使用的字段 + +USE xserver; + +-- ===================================== +-- 删除未使用的字段 +-- ===================================== + +-- 删除上级ID字段 +ALTER TABLE users DROP COLUMN report_to; + +-- 删除职位字段 +ALTER TABLE users DROP COLUMN position; + +-- ===================================== +-- 验证结果 +-- ===================================== + +SELECT "=== users 表结构验证 ===" as ""; +DESCRIBE users;