Add logo support to team creation and update functionality

- Enhanced the team creation and update processes to include an optional logo field, allowing teams to have custom logos.
- Updated the CreateTeamRequest and UpdateTeamRequest structures to accommodate the new logo field.
- Modified the GinTeamCreate and GinTeamUpdate handlers to handle logo data appropriately.
- Expanded test cases for team creation and updates to validate logo handling, ensuring comprehensive coverage for scenarios involving logos.
This commit is contained in:
Max 2025-10-27 17:46:25 +08:00
parent 7572f99ba0
commit 8ffa767dfe
3 changed files with 44 additions and 0 deletions

View file

@ -195,6 +195,19 @@ func TestTeamCreate(t *testing.T) {
201,
"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",
map[string]interface{}{
@ -285,6 +298,9 @@ func TestTeamCreate(t *testing.T) {
if description, ok := tc.body["description"]; ok {
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, "name", "Should have team name")
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, "status", "Should have status")
assert.Contains(t, team, "settings", "Should have settings")
@ -537,6 +554,18 @@ func TestTeamUpdate(t *testing.T) {
200,
"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",
"non-existent-team-id",
@ -609,6 +638,9 @@ func TestTeamUpdate(t *testing.T) {
if description, ok := tc.body["description"]; ok {
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 {
assert.Equal(t, settings, team["settings"], "Should have updated settings")
}

View file

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

View file

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