Changeset 0.28.0.7 (#179)

This commit is contained in:
2026-03-12 19:34:48 +00:00
parent 1a5eb707ba
commit f3f5afd14c
11 changed files with 1189 additions and 89 deletions

View File

@@ -51,7 +51,7 @@ func (h *PersonaGroupHandler) List(c *gin.Context) {
for rows.Next() {
var g models.PersonaGroup
if err := rows.Scan(&g.ID, &g.Name, &g.Description, &g.OwnerID,
&g.Scope, &g.TeamID, &g.CreatedAt, &g.UpdatedAt); err != nil {
&g.Scope, &g.TeamID, database.ST(&g.CreatedAt), database.ST(&g.UpdatedAt)); err != nil {
continue
}
groups = append(groups, g)
@@ -62,7 +62,7 @@ func (h *PersonaGroupHandler) List(c *gin.Context) {
groups[i].Members = h.loadMembers(c, groups[i].ID)
}
c.JSON(http.StatusOK, gin.H{"groups": groups})
c.JSON(http.StatusOK, gin.H{"data": groups})
}
// ── Get ─────────────────────────────────────────
@@ -76,7 +76,7 @@ func (h *PersonaGroupHandler) Get(c *gin.Context) {
SELECT id, name, description, owner_id, scope, team_id, created_at, updated_at
FROM persona_groups WHERE id = $1 AND owner_id = $2
`), id, userID).Scan(&g.ID, &g.Name, &g.Description, &g.OwnerID,
&g.Scope, &g.TeamID, &g.CreatedAt, &g.UpdatedAt)
&g.Scope, &g.TeamID, database.ST(&g.CreatedAt), database.ST(&g.UpdatedAt))
if err == sql.ErrNoRows {
c.JSON(http.StatusNotFound, gin.H{"error": "group not found"})
return
@@ -87,6 +87,9 @@ func (h *PersonaGroupHandler) Get(c *gin.Context) {
}
g.Members = h.loadMembers(c, g.ID)
if g.Members == nil {
g.Members = []models.PersonaGroupMember{}
}
c.JSON(http.StatusOK, g)
}
@@ -119,7 +122,7 @@ func (h *PersonaGroupHandler) Create(c *gin.Context) {
SELECT id, name, description, owner_id, scope, team_id, created_at, updated_at
FROM persona_groups WHERE id = ?
`, id).Scan(&g.ID, &g.Name, &g.Description, &g.OwnerID,
&g.Scope, &g.TeamID, &g.CreatedAt, &g.UpdatedAt)
&g.Scope, &g.TeamID, database.ST(&g.CreatedAt), database.ST(&g.UpdatedAt))
} else {
err := database.DB.QueryRowContext(c.Request.Context(), `
INSERT INTO persona_groups (name, description, owner_id, scope)
@@ -127,7 +130,7 @@ func (h *PersonaGroupHandler) Create(c *gin.Context) {
RETURNING id, name, description, owner_id, scope, team_id, created_at, updated_at
`, strings.TrimSpace(req.Name), req.Description, userID).Scan(
&g.ID, &g.Name, &g.Description, &g.OwnerID,
&g.Scope, &g.TeamID, &g.CreatedAt, &g.UpdatedAt)
&g.Scope, &g.TeamID, database.ST(&g.CreatedAt), database.ST(&g.UpdatedAt))
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to create group"})
return