From 5f0170df9787c6f3ff17cc168b3f2e3f511453f6 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期二, 31 十月 2023 20:04:16 +0800
Subject: [PATCH] 支持职级降级的情况
---
model/user.go | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/model/user.go b/model/user.go
index 17da6c3..b67dada 100644
--- a/model/user.go
+++ b/model/user.go
@@ -26,7 +26,7 @@
MenuIds []uint `json:"menuIds" gorm:"-"` // 鑿滃崟ID鍒楄〃
AuthorityId uint `json:"authorityId" gorm:"default:888;comment:鐢ㄦ埛瑙掕壊ID"` // 鐢ㄦ埛瑙掕壊ID
Authority Authority `json:"authority" gorm:"foreignKey:AuthorityId"`
- SubUserIds string `json:"subUserIds" gorm:"sub_user_ids"` //涓嬪睘鍛樺伐鐢ㄦ埛id,鐢ㄩ�楀彿鍒嗗紑
+ SubUserIds *string `json:"subUserIds" gorm:"sub_user_ids"` //涓嬪睘鍛樺伐鐢ㄦ埛id,鐢ㄩ�楀彿鍒嗗紑
gorm.Model `json:"-"`
}
@@ -303,13 +303,13 @@
} else if old.Username != record.Username ||
old.UserType != record.UserType ||
old.NickName != record.NickName ||
- old.SubUserIds != record.SubUserIds {
+ record.SubUserIds != nil && old.SubUserIds != record.SubUserIds {
old.Username = record.Username
old.UserType = record.UserType
old.NickName = record.NickName
old.SubUserIds = record.SubUserIds
if err := db.Updates(&record).Error; err != nil {
- return fmt.Errorf("update user err: %v, record: %+v", err, record)
+ return fmt.Errorf("update user err: %v, old record: %+v", err, old)
}
}
--
Gitblit v1.8.0