mirror of
https://github.com/yanislav-igonin/micrach
synced 2024-12-22 14:22:33 +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{
|
post := Repositories.Post{
|
||||||
IsParent: false,
|
IsParent: false,
|
||||||
ParentID: threadID,
|
ParentID: &threadID,
|
||||||
Title: "",
|
Title: "",
|
||||||
Text: text,
|
Text: text,
|
||||||
IsSage: isSage,
|
IsSage: isSage,
|
||||||
|
@ -115,7 +115,8 @@ func (r *PostsRepository) GetThreadByPostID(ID int) ([]Post, error) {
|
|||||||
text,
|
text,
|
||||||
is_sage,
|
is_sage,
|
||||||
created_at,
|
created_at,
|
||||||
is_parent
|
is_parent,
|
||||||
|
parent_id
|
||||||
FROM posts
|
FROM posts
|
||||||
WHERE
|
WHERE
|
||||||
(id = $1 AND is_parent = true AND is_deleted != true)
|
(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.IsSage,
|
||||||
&post.CreatedAt,
|
&post.CreatedAt,
|
||||||
&post.IsParent,
|
&post.IsParent,
|
||||||
|
&post.ParentID,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -47,7 +47,7 @@ func getPost(id int, pid *int) Post {
|
|||||||
return Post{
|
return Post{
|
||||||
ID: id,
|
ID: id,
|
||||||
IsParent: isParent,
|
IsParent: isParent,
|
||||||
ParentID: parentID,
|
ParentID: &parentID,
|
||||||
IsDeleted: false,
|
IsDeleted: false,
|
||||||
Title: randSeq(rand.Intn(100)),
|
Title: randSeq(rand.Intn(100)),
|
||||||
Text: randSeq(rand.Intn(100)),
|
Text: randSeq(rand.Intn(100)),
|
||||||
|
@ -9,7 +9,7 @@ import "time"
|
|||||||
type Post struct {
|
type Post struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
IsParent bool `json:"-"`
|
IsParent bool `json:"-"`
|
||||||
ParentID int `json:"parentId"`
|
ParentID *int `json:"parentId"`
|
||||||
IsDeleted bool `json:"-"`
|
IsDeleted bool `json:"-"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
@ -23,7 +23,7 @@ func (p Post) GetThreadID() int {
|
|||||||
if p.IsParent {
|
if p.IsParent {
|
||||||
return p.ID
|
return p.ID
|
||||||
}
|
}
|
||||||
return p.ParentID
|
return *p.ParentID
|
||||||
}
|
}
|
||||||
|
|
||||||
type File struct {
|
type File struct {
|
||||||
|
@ -75,11 +75,11 @@ func ValidatePost(title, text string, files []*multipart.FileHeader) string {
|
|||||||
return Repositories.InvalidTextOrFilesErrorMessage
|
return Repositories.InvalidTextOrFilesErrorMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(title) > 100 {
|
if len([]rune(title)) > 100 {
|
||||||
return Repositories.InvalidTitleLengthErrorMessage
|
return Repositories.InvalidTitleLengthErrorMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(text) > 1000 {
|
if len([]rune(text)) > 1000 {
|
||||||
return Repositories.InvalidTextLengthErrorMessage
|
return Repositories.InvalidTextLengthErrorMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user