feat(backend,docker,docs): implement Go/Gin/SQLite REST API server, Docker containerization, and architecture specifications
- Implement standalone Go backend API server using Gin and pure-Go SQLite (modernc.org/sqlite) - Add 11-table schema DDL migrations (000001_init.up.sql) based on DATA_TABLE.md - Add seed data ingestion tool (cmd/seed) and static TypeScript content exporter (cmd/export-content) - Add configuration loader (internal/config) supporting environment variables and .env files (HOST, PORT, DB_PATH, GIN_MODE, CORS_ALLOW_ORIGINS, AUTO_MIGRATE) - Add lightweight multi-stage Dockerfile and docker-compose.yml with persistent SQLite volume - Add comprehensive architecture specification (ARCHITECTURE.md) and REST API interface specification (API_INTERFACE.md) - Harmonize frontend publications page to consume isHighlight flag from database-synced content
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"git.godopu.com/lab/landing_page/backend/internal/httpx"
|
||||
"git.godopu.com/lab/landing_page/backend/internal/repository"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type HomeHandler struct {
|
||||
repo *repository.HomeRepository
|
||||
}
|
||||
|
||||
func NewHomeHandler(repo *repository.HomeRepository) *HomeHandler {
|
||||
return &HomeHandler{repo: repo}
|
||||
}
|
||||
|
||||
func (h *HomeHandler) GetResearchProjects(c *gin.Context) {
|
||||
projects, err := h.repo.GetResearchProjects(c.Request.Context())
|
||||
if err != nil {
|
||||
httpx.InternalServerError(c, "Failed to retrieve research projects: "+err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OK(c, projects)
|
||||
}
|
||||
|
||||
func (h *HomeHandler) GetResearchAreas(c *gin.Context) {
|
||||
areas, err := h.repo.GetResearchAreas(c.Request.Context())
|
||||
if err != nil {
|
||||
httpx.InternalServerError(c, "Failed to retrieve research areas: "+err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OK(c, areas)
|
||||
}
|
||||
|
||||
func (h *HomeHandler) GetStatsSummary(c *gin.Context) {
|
||||
stats, err := h.repo.GetStatsSummary(c.Request.Context())
|
||||
if err != nil {
|
||||
httpx.InternalServerError(c, "Failed to retrieve statistics summary: "+err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OK(c, stats)
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"git.godopu.com/lab/landing_page/backend/internal/httpx"
|
||||
"git.godopu.com/lab/landing_page/backend/internal/repository"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type LecturesHandler struct {
|
||||
repo *repository.LecturesRepository
|
||||
}
|
||||
|
||||
func NewLecturesHandler(repo *repository.LecturesRepository) *LecturesHandler {
|
||||
return &LecturesHandler{repo: repo}
|
||||
}
|
||||
|
||||
func (h *LecturesHandler) GetSemesters(c *gin.Context) {
|
||||
semesters, err := h.repo.GetSemestersWithCourses(c.Request.Context())
|
||||
if err != nil {
|
||||
httpx.InternalServerError(c, "Failed to retrieve semesters: "+err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OK(c, semesters)
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"git.godopu.com/lab/landing_page/backend/internal/httpx"
|
||||
"git.godopu.com/lab/landing_page/backend/internal/repository"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type MembersHandler struct {
|
||||
repo *repository.MembersRepository
|
||||
}
|
||||
|
||||
func NewMembersHandler(repo *repository.MembersRepository) *MembersHandler {
|
||||
return &MembersHandler{repo: repo}
|
||||
}
|
||||
|
||||
func (h *MembersHandler) GetMembers(c *gin.Context) {
|
||||
members, err := h.repo.GetMembers(c.Request.Context())
|
||||
if err != nil {
|
||||
httpx.InternalServerError(c, "Failed to retrieve members: "+err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OK(c, members)
|
||||
}
|
||||
|
||||
func (h *MembersHandler) GetAlumni(c *gin.Context) {
|
||||
alumni, err := h.repo.GetAlumni(c.Request.Context())
|
||||
if err != nil {
|
||||
httpx.InternalServerError(c, "Failed to retrieve alumni: "+err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OK(c, alumni)
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"git.godopu.com/lab/landing_page/backend/internal/httpx"
|
||||
"git.godopu.com/lab/landing_page/backend/internal/repository"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type PublicationsHandler struct {
|
||||
repo *repository.PublicationsRepository
|
||||
}
|
||||
|
||||
func NewPublicationsHandler(repo *repository.PublicationsRepository) *PublicationsHandler {
|
||||
return &PublicationsHandler{repo: repo}
|
||||
}
|
||||
|
||||
func (h *PublicationsHandler) GetPublications(c *gin.Context) {
|
||||
category := c.Query("category")
|
||||
if category != "" && category != "intl-journal-conf" && category != "domestic-journal-conf" {
|
||||
httpx.BadRequest(c, "Invalid category parameter: must be 'intl-journal-conf' or 'domestic-journal-conf'")
|
||||
return
|
||||
}
|
||||
|
||||
pubs, err := h.repo.GetPublications(c.Request.Context(), category)
|
||||
if err != nil {
|
||||
httpx.InternalServerError(c, "Failed to retrieve publications: "+err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OK(c, pubs)
|
||||
}
|
||||
|
||||
func (h *PublicationsHandler) GetHighlights(c *gin.Context) {
|
||||
highlights, err := h.repo.GetHighlights(c.Request.Context())
|
||||
if err != nil {
|
||||
httpx.InternalServerError(c, "Failed to retrieve highlights: "+err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OK(c, highlights)
|
||||
}
|
||||
|
||||
func (h *PublicationsHandler) GetPatents(c *gin.Context) {
|
||||
patents, err := h.repo.GetPatents(c.Request.Context())
|
||||
if err != nil {
|
||||
httpx.InternalServerError(c, "Failed to retrieve patents: "+err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OK(c, patents)
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"git.godopu.com/lab/landing_page/backend/internal/httpx"
|
||||
"git.godopu.com/lab/landing_page/backend/internal/repository"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type StandardizationHandler struct {
|
||||
repo *repository.StandardizationRepository
|
||||
}
|
||||
|
||||
func NewStandardizationHandler(repo *repository.StandardizationRepository) *StandardizationHandler {
|
||||
return &StandardizationHandler{repo: repo}
|
||||
}
|
||||
|
||||
func (h *StandardizationHandler) GetStandardsBodies(c *gin.Context) {
|
||||
bodies, err := h.repo.GetStandardsBodiesWithProjects(c.Request.Context())
|
||||
if err != nil {
|
||||
httpx.InternalServerError(c, "Failed to retrieve standards bodies: "+err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OK(c, bodies)
|
||||
}
|
||||
Reference in New Issue
Block a user