Custom css SAS & layout playground

This commit is contained in:
Sas Andy
2024-04-25 16:56:20 +07:00
parent 34be7a29a1
commit da95e5b89f
13 changed files with 5213 additions and 7 deletions

View File

@@ -0,0 +1,80 @@
package services
import (
"time"
"github.com/emarifer/go-templ-project-structure/db"
)
func NewServicesXsample(u Xsample, uStore db.XsampleStore) *ServicesXsample {
return &ServicesXsample{
Xsample: u,
XsampleStore: uStore,
}
}
type Xsample struct {
ID int `json:"id"`
Xsamplename string `json:"Xsamplename"`
Email string `json:"email"`
CreatedAt time.Time `json:"created_at,omitempty"`
}
type ServicesXsample struct {
Xsample Xsample
XsampleStore db.XsampleStore
}
func (su *ServicesXsample) GetAllXsamples() ([]Xsample, error) {
query := `SELECT id, Xsamplename, email, created_at FROM Xsamples ORDER BY created_at DESC`
rows, err := su.XsampleStore.Db.Query(query)
if err != nil {
return []Xsample{}, err
}
// We close the resource
defer rows.Close()
Xsamples := []Xsample{}
for rows.Next() {
rows.Scan(
&su.Xsample.ID,
&su.Xsample.Xsamplename,
&su.Xsample.Email,
&su.Xsample.CreatedAt,
)
Xsamples = append(Xsamples, su.Xsample)
}
return Xsamples, nil
}
func (su *ServicesXsample) GetXsampleById(id int) (Xsample, error) {
query := `SELECT id, Xsamplename, email, created_at FROM Xsamples
WHERE id = ?`
stmt, err := su.XsampleStore.Db.Prepare(query)
if err != nil {
return Xsample{}, err
}
defer stmt.Close()
su.Xsample.ID = id
err = stmt.QueryRow(
su.Xsample.ID,
).Scan(
&su.Xsample.ID,
&su.Xsample.Xsamplename,
&su.Xsample.Email,
&su.Xsample.CreatedAt,
)
if err != nil {
return Xsample{}, err
}
return su.Xsample, nil
}