91 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			91 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Code generated by sqlc. DO NOT EDIT.
 | |
| // versions:
 | |
| //   sqlc v1.28.0
 | |
| // source: project_file.sql
 | |
| 
 | |
| package db
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| )
 | |
| 
 | |
| const createProjectFile = `-- name: CreateProjectFile :one
 | |
| INSERT INTO project_files (id, name, path, project_id, created_user_id)
 | |
| VALUES($1, $2, $3, $4, $5)
 | |
| RETURNING id, name, path, project_id, sort, created_at, created_user_id
 | |
| `
 | |
| 
 | |
| type CreateProjectFileParams struct {
 | |
| 	ID            int64  `json:"id"`
 | |
| 	Name          string `json:"name"`
 | |
| 	Path          string `json:"path"`
 | |
| 	ProjectID     int64  `json:"project_id"`
 | |
| 	CreatedUserID int32  `json:"created_user_id"`
 | |
| }
 | |
| 
 | |
| func (q *Queries) CreateProjectFile(ctx context.Context, arg *CreateProjectFileParams) (*ProjectFile, error) {
 | |
| 	row := q.db.QueryRow(ctx, createProjectFile,
 | |
| 		arg.ID,
 | |
| 		arg.Name,
 | |
| 		arg.Path,
 | |
| 		arg.ProjectID,
 | |
| 		arg.CreatedUserID,
 | |
| 	)
 | |
| 	var i ProjectFile
 | |
| 	err := row.Scan(
 | |
| 		&i.ID,
 | |
| 		&i.Name,
 | |
| 		&i.Path,
 | |
| 		&i.ProjectID,
 | |
| 		&i.Sort,
 | |
| 		&i.CreatedAt,
 | |
| 		&i.CreatedUserID,
 | |
| 	)
 | |
| 	return &i, err
 | |
| }
 | |
| 
 | |
| const deleteProjectFile = `-- name: DeleteProjectFile :exec
 | |
| DELETE FROM project_files
 | |
| WHERE project_id = $1
 | |
| `
 | |
| 
 | |
| func (q *Queries) DeleteProjectFile(ctx context.Context, projectID int64) error {
 | |
| 	_, err := q.db.Exec(ctx, deleteProjectFile, projectID)
 | |
| 	return err
 | |
| }
 | |
| 
 | |
| const listProjectFiles = `-- name: ListProjectFiles :many
 | |
| SELECT id, name, path, project_id, sort, created_at, created_user_id 
 | |
| FROM project_files
 | |
| WHERE project_id = $1
 | |
| ORDER BY id
 | |
| `
 | |
| 
 | |
| func (q *Queries) ListProjectFiles(ctx context.Context, projectID int64) ([]*ProjectFile, error) {
 | |
| 	rows, err := q.db.Query(ctx, listProjectFiles, projectID)
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	defer rows.Close()
 | |
| 	items := []*ProjectFile{}
 | |
| 	for rows.Next() {
 | |
| 		var i ProjectFile
 | |
| 		if err := rows.Scan(
 | |
| 			&i.ID,
 | |
| 			&i.Name,
 | |
| 			&i.Path,
 | |
| 			&i.ProjectID,
 | |
| 			&i.Sort,
 | |
| 			&i.CreatedAt,
 | |
| 			&i.CreatedUserID,
 | |
| 		); err != nil {
 | |
| 			return nil, err
 | |
| 		}
 | |
| 		items = append(items, &i)
 | |
| 	}
 | |
| 	if err := rows.Err(); err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	return items, nil
 | |
| }
 |