👽 Change avatar and banner id to string

This commit is contained in:
LittleSheep 2024-08-18 22:08:58 +08:00
parent dd3586b241
commit 0285b82ca2
3 changed files with 11 additions and 13 deletions

12
.idea/workspace.xml generated
View File

@ -4,12 +4,10 @@
<option name="autoReloadType" value="ALL" /> <option name="autoReloadType" value="ALL" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix internal token audience update isn't fully applied"> <list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":arrow_up: Implement list user relative grpc function">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/go.mod" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/internal/models/accounts.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/accounts.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/go.sum" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/internal/server/api/avatar_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/avatar_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/grpc/auth.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/auth.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/settings.toml" beforeDir="false" afterPath="$PROJECT_DIR$/settings.toml" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -156,7 +154,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value=":zap: Optimized audit, event logging system&#10;:sparkles: Audit logs&#10;:sparkles: Admin edit user permissions" />
<MESSAGE value=":sparkles: Admin force confirm account" /> <MESSAGE value=":sparkles: Admin force confirm account" />
<MESSAGE value=":sparkles: Admin notify one user" /> <MESSAGE value=":sparkles: Admin notify one user" />
<MESSAGE value=":sparkles: Admin check users' auth factor" /> <MESSAGE value=":sparkles: Admin check users' auth factor" />
@ -181,7 +178,8 @@
<MESSAGE value=":wastebasket: Clean up code" /> <MESSAGE value=":wastebasket: Clean up code" />
<MESSAGE value=":sparkles: Use capital to deal with links" /> <MESSAGE value=":sparkles: Use capital to deal with links" />
<MESSAGE value=":bug: Fix internal token audience update isn't fully applied" /> <MESSAGE value=":bug: Fix internal token audience update isn't fully applied" />
<option name="LAST_COMMIT_MESSAGE" value=":bug: Fix internal token audience update isn't fully applied" /> <MESSAGE value=":arrow_up: Implement list user relative grpc function" />
<option name="LAST_COMMIT_MESSAGE" value=":arrow_up: Implement list user relative grpc function" />
</component> </component>
<component name="VgoProject"> <component name="VgoProject">
<settings-migrated>true</settings-migrated> <settings-migrated>true</settings-migrated>

View File

@ -15,8 +15,8 @@ type Account struct {
Name string `json:"name" gorm:"uniqueIndex"` Name string `json:"name" gorm:"uniqueIndex"`
Nick string `json:"nick"` Nick string `json:"nick"`
Description string `json:"description"` Description string `json:"description"`
Avatar *uint `json:"avatar"` Avatar *string `json:"avatar"`
Banner *uint `json:"banner"` Banner *string `json:"banner"`
ConfirmedAt *time.Time `json:"confirmed_at"` ConfirmedAt *time.Time `json:"confirmed_at"`
SuspendedAt *time.Time `json:"suspended_at"` SuspendedAt *time.Time `json:"suspended_at"`
PermNodes datatypes.JSONMap `json:"perm_nodes"` PermNodes datatypes.JSONMap `json:"perm_nodes"`
@ -38,14 +38,14 @@ type Account struct {
func (v Account) GetAvatar() *string { func (v Account) GetAvatar() *string {
if v.Avatar != nil { if v.Avatar != nil {
return lo.ToPtr(fmt.Sprintf("%s/%d", viper.GetString("content_endpoint"), *v.Avatar)) return lo.ToPtr(fmt.Sprintf("%s/%s", viper.GetString("content_endpoint"), *v.Avatar))
} }
return nil return nil
} }
func (v Account) GetBanner() *string { func (v Account) GetBanner() *string {
if v.Banner != nil { if v.Banner != nil {
return lo.ToPtr(fmt.Sprintf("%s/%d", viper.GetString("content_endpoint"), *v.Banner)) return lo.ToPtr(fmt.Sprintf("%s/%s", viper.GetString("content_endpoint"), *v.Banner))
} }
return nil return nil
} }

View File

@ -15,7 +15,7 @@ func setAvatar(c *fiber.Ctx) error {
user := c.Locals("user").(models.Account) user := c.Locals("user").(models.Account)
var data struct { var data struct {
AttachmentID uint `json:"attachment" validate:"required"` AttachmentID string `json:"attachment" validate:"required"`
} }
if err := exts.BindAndValidate(c, &data); err != nil { if err := exts.BindAndValidate(c, &data); err != nil {
@ -40,7 +40,7 @@ func setBanner(c *fiber.Ctx) error {
user := c.Locals("user").(models.Account) user := c.Locals("user").(models.Account)
var data struct { var data struct {
AttachmentID uint `json:"attachment" validate:"required"` AttachmentID string `json:"attachment" validate:"required"`
} }
if err := exts.BindAndValidate(c, &data); err != nil { if err := exts.BindAndValidate(c, &data); err != nil {