micrach/repositories/structs.go
Yanislav Igonin fbe39f45a3
Feature - Components refactor (#10)
* feat: header component

* feat: captcha component

* feat: rename all html files

* feat: update github link

* feat: all templates in subfolders

* feat: separate thread card

* feat: separate pagination

* feat: update pagination

* feat: separate post

* lint
2022-01-31 19:56:21 +03:00

81 lines
1.8 KiB
Go

package repositories
import "time"
// DB Structs
// DB Structs
// DB Structs
type Post struct {
ID int `json:"id"`
IsParent bool `json:"-"`
ParentID int `json:"parentId"`
IsDeleted bool `json:"-"`
Title string `json:"title"`
Text string `json:"text"`
IsSage bool `json:"isSage"`
Files []File `json:"files"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"-"`
}
func (p *Post) getThreadID() int {
if p.IsParent {
return p.ID
}
return p.ParentID
}
type File struct {
ID int `json:"-"`
PostID int `json:"-"`
CreatedAt time.Time `json:"-"`
Name string `json:"name"`
Ext string `json:"-"`
Size int `json:"size"`
}
// HTML Templates Structs
// HTML Templates Structs
// HTML Templates Structs
// post-form.html
type HtmlFormData struct {
FirstPostID int
CaptchaID string
IsCaptchaActive bool
}
// index.html
type HtmlPaginationData struct {
PagesCount int
Page int
}
// thread.html
type GetThreadHtmlData struct {
Thread []Post
FormData HtmlFormData
}
// index.html
type GetThreadsHtmlData struct {
Threads []Post `json:"threads"`
Pagination HtmlPaginationData
FormData HtmlFormData
}
// 400.html
type BadRequestHtmlData struct {
Message string
}
const InvalidCaptchaErrorMessage = "INVALID CAPTCHA"
const InvalidTextOrFilesErrorMessage = "TEXT OR FILES SHOULD NOT BE EMPTY"
const InvalidTitleLengthErrorMessage = "TITLE SHOULD NOT EXCEED 100 CHARS"
const InvalidTextLengthErrorMessage = "TEXT SHOULD NOT EXCEED 1000 CHARS"
const InvalidFilesLengthErrorMessage = "MAXIMUM 4 FILES CAN BE UPLOADED"
const InvalidFileSizeErrorMessage = "FILE SIZE EXCIDED (3MB PER FILE)"
const InvalidFileExtErrorMessage = "AVALIABLE FILE EXT: PNG, JPG"
const ThreadIsArchivedErrorMessage = "THREAD IS ARCHIVED"