UPDATE: Submission module
All checks were successful
Build and Release / release (push) Successful in 1m14s
All checks were successful
Build and Release / release (push) Successful in 1m14s
This commit is contained in:
@@ -8,8 +8,10 @@ import (
|
||||
type EntityEntity struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Slug string `json:"slug"`
|
||||
Description string `json:"description"`
|
||||
ThumbnailUrl string `json:"thumbnail_url"`
|
||||
ProjectID string `json:"project_id"`
|
||||
Status *int16 `json:"status"`
|
||||
IsDeleted bool `json:"is_deleted"`
|
||||
CreatedAt *time.Time `json:"created_at"`
|
||||
UpdatedAt *time.Time `json:"updated_at"`
|
||||
@@ -22,8 +24,10 @@ func (e *EntityEntity) ToResponse() *response.EntityResponse {
|
||||
return &response.EntityResponse{
|
||||
ID: e.ID,
|
||||
Name: e.Name,
|
||||
Slug: e.Slug,
|
||||
Description: e.Description,
|
||||
ThumbnailUrl: e.ThumbnailUrl,
|
||||
ProjectID: e.ProjectID,
|
||||
Status: e.Status,
|
||||
IsDeleted: e.IsDeleted,
|
||||
CreatedAt: e.CreatedAt,
|
||||
UpdatedAt: e.UpdatedAt,
|
||||
|
||||
@@ -15,6 +15,7 @@ type GeometryEntity struct {
|
||||
TimeStart int32 `json:"time_start"`
|
||||
TimeEnd int32 `json:"time_end"`
|
||||
Bbox *response.Bbox `json:"bbox"`
|
||||
ProjectID string `json:"project_id"`
|
||||
IsDeleted bool `json:"is_deleted"`
|
||||
CreatedAt *time.Time `json:"created_at"`
|
||||
UpdatedAt *time.Time `json:"updated_at"`
|
||||
@@ -32,6 +33,7 @@ func (g *GeometryEntity) ToResponse() *response.GeometryResponse {
|
||||
TimeStart: g.TimeStart,
|
||||
TimeEnd: g.TimeEnd,
|
||||
Bbox: g.Bbox,
|
||||
ProjectID: g.ProjectID,
|
||||
IsDeleted: g.IsDeleted,
|
||||
CreatedAt: g.CreatedAt,
|
||||
UpdatedAt: g.UpdatedAt,
|
||||
|
||||
@@ -19,6 +19,11 @@ type MemberSimple struct {
|
||||
AvatarUrl string `json:"avatar_url"`
|
||||
}
|
||||
|
||||
type SubmissionSimple struct {
|
||||
ID string `json:"id"`
|
||||
Status constants.StatusType `json:"status"`
|
||||
}
|
||||
|
||||
type ProjectEntity struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
@@ -32,7 +37,7 @@ type ProjectEntity struct {
|
||||
UpdatedAt *time.Time `json:"updated_at"`
|
||||
User *UserSimpleEntity `json:"user"`
|
||||
Commits []CommitSimple `json:"commits"`
|
||||
SubmissionIds []string `json:"submission_ids"`
|
||||
Submissions []SubmissionSimple `json:"submissions"`
|
||||
Members []MemberSimple `json:"members"`
|
||||
}
|
||||
|
||||
@@ -60,6 +65,14 @@ func (p *ProjectEntity) ParseMembers(data []byte) error {
|
||||
return json.Unmarshal(data, &p.Members)
|
||||
}
|
||||
|
||||
func (p *ProjectEntity) ParseSubmissions(data []byte) error {
|
||||
if len(data) == 0 || string(data) == "null" || string(data) == "[]" {
|
||||
p.Submissions = []SubmissionSimple{}
|
||||
return nil
|
||||
}
|
||||
return json.Unmarshal(data, &p.Submissions)
|
||||
}
|
||||
|
||||
func (p *ProjectEntity) ToResponse() *response.ProjectResponse {
|
||||
if p == nil {
|
||||
return nil
|
||||
@@ -77,6 +90,14 @@ func (p *ProjectEntity) ToResponse() *response.ProjectResponse {
|
||||
})
|
||||
}
|
||||
|
||||
submissions := make([]response.SubmissionSimpleResponse, 0, len(p.Submissions))
|
||||
for _, s := range p.Submissions {
|
||||
submissions = append(submissions, response.SubmissionSimpleResponse{
|
||||
ID: s.ID,
|
||||
Status: s.Status.String(),
|
||||
})
|
||||
}
|
||||
|
||||
members := make([]response.MemberSimpleResponse, 0, len(p.Members))
|
||||
for _, m := range p.Members {
|
||||
members = append(members, response.MemberSimpleResponse{
|
||||
@@ -100,7 +121,7 @@ func (p *ProjectEntity) ToResponse() *response.ProjectResponse {
|
||||
UpdatedAt: p.UpdatedAt,
|
||||
User: userResponse,
|
||||
Commits: commits,
|
||||
SubmissionIds: p.SubmissionIds,
|
||||
Submissions: submissions,
|
||||
Members: members,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"history-api/internal/dtos/response"
|
||||
"time"
|
||||
)
|
||||
|
||||
type WikiEntity struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
IsDeleted bool `json:"is_deleted"`
|
||||
CreatedAt *time.Time `json:"created_at"`
|
||||
UpdatedAt *time.Time `json:"updated_at"`
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Content json.RawMessage `json:"content"`
|
||||
ProjectID string `json:"project_id"`
|
||||
IsDeleted bool `json:"is_deleted"`
|
||||
CreatedAt *time.Time `json:"created_at"`
|
||||
UpdatedAt *time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (w *WikiEntity) ToResponse() *response.WikiResponse {
|
||||
@@ -22,6 +24,7 @@ func (w *WikiEntity) ToResponse() *response.WikiResponse {
|
||||
ID: w.ID,
|
||||
Title: w.Title,
|
||||
Content: w.Content,
|
||||
ProjectID: w.ProjectID,
|
||||
IsDeleted: w.IsDeleted,
|
||||
CreatedAt: w.CreatedAt,
|
||||
UpdatedAt: w.UpdatedAt,
|
||||
|
||||
Reference in New Issue
Block a user