refactor: Update module and import paths to match new repository structure
This commit is contained in:
parent
9213034093
commit
6f12a06a02
11 changed files with 222 additions and 763 deletions
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
const addAnnotation = `-- name: AddAnnotation :exec
|
||||
INSERT INTO annotations (user_ID, object_ID, event_ID, check_in_ID, events_object_ID, text, datetime)
|
||||
INSERT INTO annotations (user_id, object_id, event_id, check_in_id, events_object_id, text, datetime)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
`
|
||||
|
||||
|
@ -39,7 +39,7 @@ func (q *Queries) AddAnnotation(ctx context.Context, arg AddAnnotationParams) er
|
|||
}
|
||||
|
||||
const addCheckIn = `-- name: AddCheckIn :exec
|
||||
INSERT INTO check_in (user_ID, checkin_event_ID, event_ID, object_ID, checkin_state_ID, datetime)
|
||||
INSERT INTO check_in (user_id, checkin_event_id, event_id, object_id, checkin_state_id, datetime)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
`
|
||||
|
||||
|
@ -65,7 +65,7 @@ func (q *Queries) AddCheckIn(ctx context.Context, arg AddCheckInParams) error {
|
|||
}
|
||||
|
||||
const addObject = `-- name: AddObject :exec
|
||||
INSERT INTO objects (storagespace_ID, Name, Description, Serialnumber, created)
|
||||
INSERT INTO objects (storagespace_id, name, description, serialnumber, created)
|
||||
VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP)
|
||||
`
|
||||
|
||||
|
@ -87,7 +87,7 @@ func (q *Queries) AddObject(ctx context.Context, arg AddObjectParams) error {
|
|||
}
|
||||
|
||||
const addPicture = `-- name: AddPicture :exec
|
||||
INSERT INTO pictures (user_ID, storagespace_ID, object_ID, event_ID, check_in_ID, Path, Description, datetime)
|
||||
INSERT INTO pictures (user_id, storagespace_id, object_id, event_id, check_in_id, path, description, datetime)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`
|
||||
|
||||
|
@ -117,7 +117,7 @@ func (q *Queries) AddPicture(ctx context.Context, arg AddPictureParams) error {
|
|||
}
|
||||
|
||||
const addUser = `-- name: AddUser :exec
|
||||
INSERT INTO users (Username) VALUES (?)
|
||||
INSERT INTO users (username) VALUES (?)
|
||||
`
|
||||
|
||||
func (q *Queries) AddUser(ctx context.Context, username string) error {
|
||||
|
@ -126,7 +126,7 @@ func (q *Queries) AddUser(ctx context.Context, username string) error {
|
|||
}
|
||||
|
||||
const addUserSession = `-- name: AddUserSession :exec
|
||||
INSERT INTO user_sessions (user_ID, session_token, created_at, valid_until, name)
|
||||
INSERT INTO user_sessions (user_id, session_token, created_at, valid_until, name)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
`
|
||||
|
||||
|
@ -150,7 +150,7 @@ func (q *Queries) AddUserSession(ctx context.Context, arg AddUserSessionParams)
|
|||
}
|
||||
|
||||
const createEvent = `-- name: CreateEvent :exec
|
||||
INSERT INTO events (user_ID, Name, Description, Location, Start_Date, End_Date)
|
||||
INSERT INTO events (user_id, name, description, location, start_date, end_date)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
`
|
||||
|
||||
|
@ -175,6 +175,33 @@ func (q *Queries) CreateEvent(ctx context.Context, arg CreateEventParams) error
|
|||
return err
|
||||
}
|
||||
|
||||
const getAllStorageSpaces = `-- name: GetAllStorageSpaces :many
|
||||
SELECT id, parent, location FROM storagespace
|
||||
`
|
||||
|
||||
func (q *Queries) GetAllStorageSpaces(ctx context.Context) ([]Storagespace, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllStorageSpaces)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Storagespace
|
||||
for rows.Next() {
|
||||
var i Storagespace
|
||||
if err := rows.Scan(&i.ID, &i.Parent, &i.Location); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getAllUsers = `-- name: GetAllUsers :many
|
||||
SELECT id, username FROM users
|
||||
`
|
||||
|
@ -202,6 +229,33 @@ func (q *Queries) GetAllUsers(ctx context.Context) ([]User, error) {
|
|||
return items, nil
|
||||
}
|
||||
|
||||
const getChildStorageSpaces = `-- name: GetChildStorageSpaces :many
|
||||
SELECT id, parent, location FROM storagespace WHERE parent = ?
|
||||
`
|
||||
|
||||
func (q *Queries) GetChildStorageSpaces(ctx context.Context, parent sql.NullInt64) ([]Storagespace, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getChildStorageSpaces, parent)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Storagespace
|
||||
for rows.Next() {
|
||||
var i Storagespace
|
||||
if err := rows.Scan(&i.ID, &i.Parent, &i.Location); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getEventCheckIns = `-- name: GetEventCheckIns :many
|
||||
SELECT check_in_id, username, event_name, object_name, datetime, checkin_state FROM check_in_log WHERE event_name = ?
|
||||
`
|
||||
|
@ -237,9 +291,10 @@ func (q *Queries) GetEventCheckIns(ctx context.Context, eventName string) ([]Che
|
|||
}
|
||||
|
||||
const getEventObjects = `-- name: GetEventObjects :many
|
||||
SELECT objects.id, objects.storagespace_id, objects.name, objects.description, objects.serialnumber, objects.created FROM objects
|
||||
JOIN events_objects ON objects.ID = events_objects.object_ID
|
||||
WHERE events_objects.event_ID = ?
|
||||
SELECT objects.id, objects.storagespace_id, objects.name, objects.description, objects.serialnumber, objects.created
|
||||
FROM objects
|
||||
JOIN events_objects ON objects.id = events_objects.object_id
|
||||
WHERE events_objects.event_id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) GetEventObjects(ctx context.Context, eventID int64) ([]Object, error) {
|
||||
|
@ -273,7 +328,7 @@ func (q *Queries) GetEventObjects(ctx context.Context, eventID int64) ([]Object,
|
|||
}
|
||||
|
||||
const getEventPictures = `-- name: GetEventPictures :many
|
||||
SELECT id, user_id, storagespace_id, object_id, event_id, check_in_id, path, description, datetime FROM pictures WHERE event_ID = ?
|
||||
SELECT id, user_id, storagespace_id, object_id, event_id, check_in_id, path, description, datetime FROM pictures WHERE event_id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) GetEventPictures(ctx context.Context, eventID sql.NullInt64) ([]Picture, error) {
|
||||
|
@ -310,7 +365,7 @@ func (q *Queries) GetEventPictures(ctx context.Context, eventID sql.NullInt64) (
|
|||
}
|
||||
|
||||
const getObjectAnnotations = `-- name: GetObjectAnnotations :many
|
||||
SELECT id, user_id, object_id, event_id, check_in_id, events_object_id, text, datetime FROM annotations WHERE object_ID = ?
|
||||
SELECT id, user_id, object_id, event_id, check_in_id, events_object_id, text, datetime FROM annotations WHERE object_id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) GetObjectAnnotations(ctx context.Context, objectID sql.NullInt64) ([]Annotation, error) {
|
||||
|
@ -345,6 +400,41 @@ func (q *Queries) GetObjectAnnotations(ctx context.Context, objectID sql.NullInt
|
|||
return items, nil
|
||||
}
|
||||
|
||||
const getObjectsByStorageID = `-- name: GetObjectsByStorageID :many
|
||||
SELECT id, storagespace_id, name, description, serialnumber, created
|
||||
FROM objects WHERE storagespace_id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) GetObjectsByStorageID(ctx context.Context, storagespaceID int64) ([]Object, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getObjectsByStorageID, storagespaceID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Object
|
||||
for rows.Next() {
|
||||
var i Object
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.StoragespaceID,
|
||||
&i.Name,
|
||||
&i.Description,
|
||||
&i.Serialnumber,
|
||||
&i.Created,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getObjectsInStorage = `-- name: GetObjectsInStorage :many
|
||||
SELECT object_id, object_name, storage_location FROM object_storage WHERE storage_location = ?
|
||||
`
|
||||
|
@ -372,8 +462,19 @@ func (q *Queries) GetObjectsInStorage(ctx context.Context, storageLocation sql.N
|
|||
return items, nil
|
||||
}
|
||||
|
||||
const getStorageSpaceByID = `-- name: GetStorageSpaceByID :one
|
||||
SELECT id, parent, location FROM storagespace WHERE id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) GetStorageSpaceByID(ctx context.Context, id int64) (Storagespace, error) {
|
||||
row := q.db.QueryRowContext(ctx, getStorageSpaceByID, id)
|
||||
var i Storagespace
|
||||
err := row.Scan(&i.ID, &i.Parent, &i.Location)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUserByID = `-- name: GetUserByID :one
|
||||
SELECT id, username FROM users WHERE ID = ?
|
||||
SELECT id, username FROM users WHERE id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) GetUserByID(ctx context.Context, id int64) (User, error) {
|
||||
|
@ -419,7 +520,7 @@ func (q *Queries) GetUserEvents(ctx context.Context, organizer string) ([]EventD
|
|||
}
|
||||
|
||||
const getUserSessions = `-- name: GetUserSessions :many
|
||||
SELECT user_id, username, session_token, created_at, valid_until FROM user_sessions_view WHERE user_ID = ?
|
||||
SELECT user_id, username, session_token, created_at, valid_until FROM user_sessions_view WHERE user_id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) GetUserSessions(ctx context.Context, userID int64) ([]UserSessionsView, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue