Merge pull request #1245 from trheyi/main

Add logo support to team creation and update functionality
This commit is contained in:
Max 2025-10-27 18:19:24 +08:00 committed by GitHub
commit e42c669843
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 44 additions and 0 deletions

View file

@ -195,6 +195,19 @@ func TestTeamCreate(t *testing.T) {
201, 201,
"should create team with settings", "should create team with settings",
}, },
{
"create team with logo",
map[string]interface{}{
"name": "Team with Logo",
"description": "Team with custom logo",
"logo": "__yao.attachment://test-logo-123",
},
map[string]string{
"Authorization": "Bearer " + tokenInfo.AccessToken,
},
201,
"should create team with logo",
},
{ {
"create team without name", "create team without name",
map[string]interface{}{ map[string]interface{}{
@ -285,6 +298,9 @@ func TestTeamCreate(t *testing.T) {
if description, ok := tc.body["description"]; ok { if description, ok := tc.body["description"]; ok {
assert.Equal(t, description, team["description"], "Should have correct description") assert.Equal(t, description, team["description"], "Should have correct description")
} }
if logo, ok := tc.body["logo"]; ok {
assert.Equal(t, logo, team["logo"], "Should have correct logo")
}
} }
} }
@ -423,6 +439,7 @@ func TestTeamGet(t *testing.T) {
assert.Contains(t, team, "team_id", "Should have team_id") assert.Contains(t, team, "team_id", "Should have team_id")
assert.Contains(t, team, "name", "Should have team name") assert.Contains(t, team, "name", "Should have team name")
assert.Contains(t, team, "description", "Should have description") assert.Contains(t, team, "description", "Should have description")
// Logo field is optional, only present if set
assert.Contains(t, team, "owner_id", "Should have owner_id") assert.Contains(t, team, "owner_id", "Should have owner_id")
assert.Contains(t, team, "status", "Should have status") assert.Contains(t, team, "status", "Should have status")
assert.Contains(t, team, "settings", "Should have settings") assert.Contains(t, team, "settings", "Should have settings")
@ -537,6 +554,18 @@ func TestTeamUpdate(t *testing.T) {
200, 200,
"should update team settings", "should update team settings",
}, },
{
"update team logo",
getTeamID(createdTeam),
map[string]interface{}{
"logo": "__yao.attachment://updated-logo-456",
},
map[string]string{
"Authorization": "Bearer " + tokenInfo.AccessToken,
},
200,
"should update team logo",
},
{ {
"update non-existent team", "update non-existent team",
"non-existent-team-id", "non-existent-team-id",
@ -609,6 +638,9 @@ func TestTeamUpdate(t *testing.T) {
if description, ok := tc.body["description"]; ok { if description, ok := tc.body["description"]; ok {
assert.Equal(t, description, team["description"], "Should have updated description") assert.Equal(t, description, team["description"], "Should have updated description")
} }
if logo, ok := tc.body["logo"]; ok {
assert.Equal(t, logo, team["logo"], "Should have updated logo")
}
if settings, ok := tc.body["settings"]; ok { if settings, ok := tc.body["settings"]; ok {
assert.Equal(t, settings, team["settings"], "Should have updated settings") assert.Equal(t, settings, team["settings"], "Should have updated settings")
} }

View file

@ -179,6 +179,11 @@ func GinTeamCreate(c *gin.Context) {
"description": req.Description, "description": req.Description,
}) })
// Add logo if provided
if req.Logo != "" {
teamData["logo"] = req.Logo
}
// Add settings if provided // Add settings if provided
if req.Settings != nil { if req.Settings != nil {
teamData["settings"] = req.Settings teamData["settings"] = req.Settings
@ -261,6 +266,9 @@ func GinTeamUpdate(c *gin.Context) {
if req.Description != "" { if req.Description != "" {
updateData["description"] = req.Description updateData["description"] = req.Description
} }
if req.Logo != "" {
updateData["logo"] = req.Logo
}
if req.Settings != nil { if req.Settings != nil {
updateData["settings"] = req.Settings updateData["settings"] = req.Settings
} }
@ -953,6 +961,7 @@ func mapToTeamResponse(data maps.MapStr) TeamResponse {
TeamID: toString(data["team_id"]), TeamID: toString(data["team_id"]),
Name: toString(data["name"]), Name: toString(data["name"]),
Description: toString(data["description"]), Description: toString(data["description"]),
Logo: toString(data["logo"]),
OwnerID: toString(data["owner_id"]), OwnerID: toString(data["owner_id"]),
Status: toString(data["status"]), Status: toString(data["status"]),
IsVerified: toBool(data["is_verified"]), IsVerified: toBool(data["is_verified"]),

View file

@ -355,6 +355,7 @@ type TeamResponse struct {
TeamID string `json:"team_id"` TeamID string `json:"team_id"`
Name string `json:"name"` Name string `json:"name"`
Description string `json:"description,omitempty"` Description string `json:"description,omitempty"`
Logo string `json:"logo,omitempty"` // Team logo URL or file ID
OwnerID string `json:"owner_id"` OwnerID string `json:"owner_id"`
Status string `json:"status"` Status string `json:"status"`
IsVerified bool `json:"is_verified"` IsVerified bool `json:"is_verified"`
@ -375,6 +376,7 @@ type TeamDetailResponse struct {
type CreateTeamRequest struct { type CreateTeamRequest struct {
Name string `json:"name" binding:"required"` Name string `json:"name" binding:"required"`
Description string `json:"description,omitempty"` Description string `json:"description,omitempty"`
Logo string `json:"logo,omitempty"` // Team logo URL or file ID
Settings *TeamSettings `json:"settings,omitempty"` Settings *TeamSettings `json:"settings,omitempty"`
} }
@ -382,6 +384,7 @@ type CreateTeamRequest struct {
type UpdateTeamRequest struct { type UpdateTeamRequest struct {
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"` Description string `json:"description,omitempty"`
Logo string `json:"logo,omitempty"` // Team logo URL or file ID
Settings *TeamSettings `json:"settings,omitempty"` Settings *TeamSettings `json:"settings,omitempty"`
} }