Realm avatar, banner and access policy

This commit is contained in:
LittleSheep 2024-09-11 22:31:30 +08:00
parent 582e6cdb61
commit 313f6b8d4f
4 changed files with 49 additions and 30 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="dataSourceStorageLocal" created-in="GO-242.21829.165">
<component name="dataSourceStorageLocal" created-in="GO-242.21829.220">
<data-source name="hy_passport@localhost" uuid="74bcf3ef-a2b9-435b-b9e5-f32902a33b25">
<database-info product="PostgreSQL" version="16.3 (Homebrew)" jdbc-version="4.2" driver-name="PostgreSQL JDBC Driver" driver-version="42.6.0" dbms="POSTGRES" exact-version="16.3" exact-driver-version="42.6">
<identifier-quote-string>&quot;</identifier-quote-string>

14
.idea/workspace.xml generated
View File

@ -4,9 +4,11 @@
<option name="autoReloadType" value="ALL" />
</component>
<component name="ChangeListManager">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix daily sign batch list query issue">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix daily sign random panic">
<change beforePath="$PROJECT_DIR$/.idea/dataSources.local.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources.local.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/sign.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/sign.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/realms.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/realms.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/realms_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/realms_api.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -112,8 +114,8 @@
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-gosdk-5df93f7ad4aa-df9ad98b711f-org.jetbrains.plugins.go.sharedIndexes.bundled-GO-242.21829.165" />
<option value="bundled-js-predefined-d6986cc7102b-7c0b70fcd90d-JavaScript-GO-242.21829.165" />
<option value="bundled-gosdk-5df93f7ad4aa-df9ad98b711f-org.jetbrains.plugins.go.sharedIndexes.bundled-GO-242.21829.220" />
<option value="bundled-js-predefined-d6986cc7102b-7c0b70fcd90d-JavaScript-GO-242.21829.220" />
</set>
</attachedChunks>
</component>
@ -153,7 +155,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value=":arrow_up: Implement list user relative grpc function" />
<MESSAGE value=":alien: Change avatar and banner id to string" />
<MESSAGE value=":card_file_box: Update modeling" />
<MESSAGE value=":sparkles: Bot token aka. API token" />
@ -178,7 +179,8 @@
<MESSAGE value=":bug: Fix auto maintain range missing models" />
<MESSAGE value=":bug: Fix date formatting issue on daily signing" />
<MESSAGE value=":bug: Fix daily sign batch list query issue" />
<option name="LAST_COMMIT_MESSAGE" value=":bug: Fix daily sign batch list query issue" />
<MESSAGE value=":bug: Fix daily sign random panic" />
<option name="LAST_COMMIT_MESSAGE" value=":bug: Fix daily sign random panic" />
</component>
<component name="VgoProject">
<settings-migrated>true</settings-migrated>

View File

@ -1,5 +1,7 @@
package models
import "gorm.io/datatypes"
type Realm struct {
BaseModel
@ -7,6 +9,9 @@ type Realm struct {
Name string `json:"name"`
Description string `json:"description"`
Members []RealmMember `json:"members"`
Avatar *string `json:"avatar"`
Banner *string `json:"banner"`
AccessPolicy datatypes.JSONMap `json:"access_policy"`
IsPublic bool `json:"is_public"`
IsCommunity bool `json:"is_community"`
AccountID uint `json:"account_id"`

View File

@ -60,6 +60,9 @@ func createRealm(c *fiber.Ctx) error {
Alias string `json:"alias" validate:"required,lowercase,min=4,max=32"`
Name string `json:"name" validate:"required"`
Description string `json:"description"`
Avatar *string `json:"avatar"`
Banner *string `json:"banner"`
AccessPolicy map[string]any `json:"access_policy"`
IsPublic bool `json:"is_public"`
IsCommunity bool `json:"is_community"`
}
@ -72,6 +75,9 @@ func createRealm(c *fiber.Ctx) error {
Alias: data.Alias,
Name: data.Name,
Description: data.Description,
Avatar: data.Avatar,
Banner: data.Banner,
AccessPolicy: data.AccessPolicy,
IsPublic: data.IsPublic,
IsCommunity: data.IsCommunity,
AccountID: user.ID,
@ -94,6 +100,9 @@ func editRealm(c *fiber.Ctx) error {
Alias string `json:"alias" validate:"required,lowercase,min=4,max=32"`
Name string `json:"name" validate:"required"`
Description string `json:"description"`
Avatar *string `json:"avatar"`
Banner *string `json:"banner"`
AccessPolicy map[string]any `json:"access_policy"`
IsPublic bool `json:"is_public"`
IsCommunity bool `json:"is_community"`
}
@ -113,6 +122,9 @@ func editRealm(c *fiber.Ctx) error {
realm.Alias = data.Alias
realm.Name = data.Name
realm.Description = data.Description
realm.Avatar = data.Avatar
realm.Banner = data.Banner
realm.AccessPolicy = data.AccessPolicy
realm.IsPublic = data.IsPublic
realm.IsCommunity = data.IsCommunity