mirror of
https://github.com/yanislav-igonin/micrach
synced 2024-12-21 22:02:34 +03:00
fix: parent id get for html template
This commit is contained in:
parent
f4c2f9262e
commit
736be1f461
@ -320,7 +320,7 @@ func UpdateThread(c *gin.Context) {
|
||||
}
|
||||
post := Repositories.Post{
|
||||
IsParent: false,
|
||||
ParentID: threadID,
|
||||
ParentID: &threadID,
|
||||
Title: "",
|
||||
Text: text,
|
||||
IsSage: isSage,
|
||||
|
@ -115,7 +115,8 @@ func (r *PostsRepository) GetThreadByPostID(ID int) ([]Post, error) {
|
||||
text,
|
||||
is_sage,
|
||||
created_at,
|
||||
is_parent
|
||||
is_parent,
|
||||
parent_id
|
||||
FROM posts
|
||||
WHERE
|
||||
(id = $1 AND is_parent = true AND is_deleted != true)
|
||||
@ -142,6 +143,7 @@ func (r *PostsRepository) GetThreadByPostID(ID int) ([]Post, error) {
|
||||
&post.IsSage,
|
||||
&post.CreatedAt,
|
||||
&post.IsParent,
|
||||
&post.ParentID,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -47,7 +47,7 @@ func getPost(id int, pid *int) Post {
|
||||
return Post{
|
||||
ID: id,
|
||||
IsParent: isParent,
|
||||
ParentID: parentID,
|
||||
ParentID: &parentID,
|
||||
IsDeleted: false,
|
||||
Title: randSeq(rand.Intn(100)),
|
||||
Text: randSeq(rand.Intn(100)),
|
||||
|
@ -9,7 +9,7 @@ import "time"
|
||||
type Post struct {
|
||||
ID int `json:"id"`
|
||||
IsParent bool `json:"-"`
|
||||
ParentID int `json:"parentId"`
|
||||
ParentID *int `json:"parentId"`
|
||||
IsDeleted bool `json:"-"`
|
||||
Title string `json:"title"`
|
||||
Text string `json:"text"`
|
||||
@ -23,7 +23,7 @@ func (p Post) GetThreadID() int {
|
||||
if p.IsParent {
|
||||
return p.ID
|
||||
}
|
||||
return p.ParentID
|
||||
return *p.ParentID
|
||||
}
|
||||
|
||||
type File struct {
|
||||
|
@ -75,11 +75,11 @@ func ValidatePost(title, text string, files []*multipart.FileHeader) string {
|
||||
return Repositories.InvalidTextOrFilesErrorMessage
|
||||
}
|
||||
|
||||
if len(title) > 100 {
|
||||
if len([]rune(title)) > 100 {
|
||||
return Repositories.InvalidTitleLengthErrorMessage
|
||||
}
|
||||
|
||||
if len(text) > 1000 {
|
||||
if len([]rune(text)) > 1000 {
|
||||
return Repositories.InvalidTextLengthErrorMessage
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user