Rename the main module to gotea.dev and the binary to gotea, and update the application name and English locale. Keep the external gitea.dev/sdk and gitea.dev/actionslib module imports unchanged. Assisted-by: OpenCode:DeepSeek-V4.1-Flash
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package project
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gotea.dev/models/db"
|
|
)
|
|
|
|
// CountColumns returns the total number of columns for a project
|
|
func CountColumns(ctx context.Context, projectID int64) (int64, error) {
|
|
return db.GetEngine(ctx).Where("project_id=?", projectID).Count(&Column{})
|
|
}
|
|
|
|
// GetColumns returns a list of columns for a project with pagination
|
|
func GetColumns(ctx context.Context, projectID int64, opts db.ListOptions) (ColumnList, error) {
|
|
columns := make([]*Column, 0, opts.PageSize)
|
|
s := db.GetEngine(ctx).Where("project_id=?", projectID).OrderBy("sorting, id")
|
|
if !opts.IsListAll() {
|
|
db.SetSessionPagination(s, &opts)
|
|
}
|
|
if err := s.Find(&columns); err != nil {
|
|
return nil, err
|
|
}
|
|
return columns, nil
|
|
}
|
|
|
|
func GetColumnsByIDs(ctx context.Context, projectID int64, columnsIDs []int64) (ColumnList, error) {
|
|
columns := make([]*Column, 0, 5)
|
|
if len(columnsIDs) == 0 {
|
|
return columns, nil
|
|
}
|
|
if err := db.GetEngine(ctx).
|
|
Where("project_id =?", projectID).
|
|
In("id", columnsIDs).
|
|
OrderBy("sorting").Find(&columns); err != nil {
|
|
return nil, err
|
|
}
|
|
return columns, nil
|
|
}
|