Added GetAllOffset. Post controller completed.
This commit is contained in:
parent
5b18009658
commit
41944884b4
12 changed files with 229 additions and 71 deletions
|
|
@ -3,6 +3,7 @@ package repo
|
|||
import (
|
||||
"58team_blog/internal/domain/entities"
|
||||
"58team_blog/internal/infrastructure/db"
|
||||
"strconv"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jmoiron/sqlx"
|
||||
|
|
@ -65,6 +66,15 @@ func (r *PostRepository) GetAll() ([]*entities.Post, error) {
|
|||
return entity_list, err
|
||||
}
|
||||
|
||||
func (r *PostRepository) GetAllOffset(offset int) ([]*entities.Post, error) {
|
||||
var entity_list []*entities.Post
|
||||
query := "SELECT * FROM " + entities.PostTable + " ORDER BY createdat, updatedat OFFSET " + strconv.Itoa(offset) + " LIMIT 5"
|
||||
|
||||
err := r.conn.Conn.Select(&entity_list, query)
|
||||
|
||||
return entity_list, err
|
||||
}
|
||||
|
||||
func (r *PostRepository) Update(entity *entities.Post) error {
|
||||
query := "UPDATE " + entities.PostTable + "SET title=:title, description=:description, content=:content, updatedat=:updatedat WHERE id=:id"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue