created tracker api endpoint and created UI interface for trackers
This commit is contained in:
44
server/internal/dto/tracker.go
Normal file
44
server/internal/dto/tracker.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package dto
|
||||
|
||||
import "smoop-api/internal/models"
|
||||
|
||||
type TrackerDto struct {
|
||||
GUID string `json:"guid"`
|
||||
Name string `json:"name"`
|
||||
Users []UserDto `json:"users,omitempty"`
|
||||
}
|
||||
|
||||
type TrackerListDto struct {
|
||||
Trackers []TrackerDto `json:"trackers"`
|
||||
Offset int `json:"offset"`
|
||||
Limit int `json:"limit"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
|
||||
type CreateTrackerDto struct {
|
||||
GUID string `json:"guid" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
UserIDs []uint `json:"userIds"`
|
||||
}
|
||||
|
||||
type RenameTrackerDto struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
}
|
||||
|
||||
type SetTrackerUsersDto struct {
|
||||
UserIDs []uint `json:"userIds"`
|
||||
}
|
||||
|
||||
func MapTracker(t models.Tracker) TrackerDto {
|
||||
out := TrackerDto{
|
||||
GUID: t.GUID,
|
||||
Name: t.Name,
|
||||
}
|
||||
if len(t.Users) > 0 {
|
||||
out.Users = make([]UserDto, 0, len(t.Users))
|
||||
for _, u := range t.Users {
|
||||
out.Users = append(out.Users, MapUser(u))
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
Reference in New Issue
Block a user