fix(用户): 修复邮箱绑定逻辑中的错误处理
Build docker and publish / build (20.15.1) (push) Successful in 7m17s

重构邮箱绑定逻辑的错误处理流程,正确处理数据库查询错误和记录不存在的情况
优化设备查询方法,移除不必要的缓存键生成
This commit is contained in:
2025-10-29 01:38:49 -07:00
parent 02e76ebcf1
commit 1302accaf9
2 changed files with 14 additions and 9 deletions
+1 -2
View File
@@ -23,9 +23,8 @@ func (m *customUserModel) FindOneDevice(ctx context.Context, id int64) (*Device,
}
func (m *customUserModel) FindOneDeviceByIdentifier(ctx context.Context, id string) (*Device, error) {
deviceIdKey := fmt.Sprintf("%s%v", cacheUserDeviceNumberPrefix, id)
var resp Device
err := m.QueryCtx(ctx, &resp, deviceIdKey, func(conn *gorm.DB, v interface{}) error {
err := m.QueryNoCacheCtx(ctx, &resp, func(conn *gorm.DB, v interface{}) error {
return conn.Model(&Device{}).Where("`identifier` = ?", id).First(&resp).Error
})
switch {