重构邮箱绑定逻辑的错误处理流程,正确处理数据库查询错误和记录不存在的情况 优化设备查询方法,移除不必要的缓存键生成
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user