修复(#49): 修复清空备注时数据丢失 — RefererId 改为指针类型
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
+14
-14
@@ -3264,20 +3264,20 @@ type UpdateUserAuthMethodRequest struct {
|
||||
}
|
||||
|
||||
type UpdateUserBasiceInfoRequest struct {
|
||||
UserId int64 `json:"user_id" validate:"required"`
|
||||
Password string `json:"password"`
|
||||
Avatar string `json:"avatar"`
|
||||
Balance int64 `json:"balance"`
|
||||
Commission int64 `json:"commission"`
|
||||
ReferralPercentage uint8 `json:"referral_percentage"`
|
||||
OnlyFirstPurchase *bool `json:"only_first_purchase"`
|
||||
GiftAmount int64 `json:"gift_amount"`
|
||||
Telegram int64 `json:"telegram"`
|
||||
ReferCode string `json:"refer_code"`
|
||||
RefererId int64 `json:"referer_id"`
|
||||
Enable *bool `json:"enable"`
|
||||
IsAdmin *bool `json:"is_admin"`
|
||||
Remark string `json:"remark"`
|
||||
UserId int64 `json:"user_id" validate:"required"`
|
||||
Password string `json:"password"`
|
||||
Avatar string `json:"avatar"`
|
||||
Balance *int64 `json:"balance"`
|
||||
Commission *int64 `json:"commission"`
|
||||
ReferralPercentage uint8 `json:"referral_percentage"`
|
||||
OnlyFirstPurchase *bool `json:"only_first_purchase"`
|
||||
GiftAmount *int64 `json:"gift_amount"`
|
||||
Telegram int64 `json:"telegram"`
|
||||
ReferCode string `json:"refer_code"`
|
||||
RefererId *int64 `json:"referer_id"`
|
||||
Enable *bool `json:"enable"`
|
||||
IsAdmin *bool `json:"is_admin"`
|
||||
Remark *string `json:"remark"`
|
||||
}
|
||||
|
||||
type UpdateUserNotifyRequest struct {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUpdateUserBasicInfoRequestRemarkPresence(t *testing.T) {
|
||||
var omitted UpdateUserBasiceInfoRequest
|
||||
if err := json.Unmarshal([]byte(`{"user_id":1}`), &omitted); err != nil {
|
||||
t.Fatalf("unmarshal omitted remark: %v", err)
|
||||
}
|
||||
if omitted.Remark != nil {
|
||||
t.Fatalf("omitted remark = %q, want nil", *omitted.Remark)
|
||||
}
|
||||
|
||||
var cleared UpdateUserBasiceInfoRequest
|
||||
if err := json.Unmarshal([]byte(`{"user_id":1,"remark":""}`), &cleared); err != nil {
|
||||
t.Fatalf("unmarshal empty remark: %v", err)
|
||||
}
|
||||
if cleared.Remark == nil {
|
||||
t.Fatal("empty remark was decoded as nil, want explicit empty string")
|
||||
}
|
||||
if *cleared.Remark != "" {
|
||||
t.Fatalf("empty remark = %q, want empty string", *cleared.Remark)
|
||||
}
|
||||
|
||||
var updated UpdateUserBasiceInfoRequest
|
||||
if err := json.Unmarshal([]byte(`{"user_id":1,"remark":"new note"}`), &updated); err != nil {
|
||||
t.Fatalf("unmarshal non-empty remark: %v", err)
|
||||
}
|
||||
if updated.Remark == nil || *updated.Remark != "new note" {
|
||||
t.Fatalf("non-empty remark = %#v, want %q", updated.Remark, "new note")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user