feat: add feature based structure

This commit is contained in:
Justin Lin
2025-08-26 19:18:35 +10:00
commit d963362711
15 changed files with 436 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package user
import (
"context"
"github.com/gin-gonic/gin"
"tutorial.sqlc.dev/app/internal/author/gen"
)
type Controller struct {
queries gen.Queries
}
func NewController(conn gen.DBTX) Controller {
return Controller{
queries: *gen.New(conn),
}
}
func (u *Controller) ListAuthors(ctx *gin.Context) {
authors, err := u.queries.ListAuthors(context.Background())
if err != nil {
ctx.AbortWithError(500, err)
}
ctx.JSON(200, authors)
}