fix: sqlite

pull/3/head
1379 2 years ago committed by 1379Monitor
parent 9fd1a0e167
commit 446c8b84d3

@ -17,10 +17,10 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newAttachment(db *gorm.DB) attachment {
func newAttachment(db *gorm.DB, opts ...gen.DOOption) attachment {
_attachment := attachment{}
_attachment.attachmentDo.UseDB(db)
_attachment.attachmentDo.UseDB(db, opts...)
_attachment.attachmentDo.UseModel(&entity.Attachment{})
tableName := _attachment.attachmentDo.TableName()
@ -131,6 +131,11 @@ func (a *attachment) fillFieldMap() {
}
func (a attachment) clone(db *gorm.DB) attachment {
a.attachmentDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a attachment) replaceDB(db *gorm.DB) attachment {
a.attachmentDo.ReplaceDB(db)
return a
}
@ -153,6 +158,10 @@ func (a attachmentDo) WriteDB() *attachmentDo {
return a.Clauses(dbresolver.Write)
}
func (a attachmentDo) Session(config *gorm.Session) *attachmentDo {
return a.withDO(a.DO.Session(config))
}
func (a attachmentDo) Clauses(conds ...clause.Expression) *attachmentDo {
return a.withDO(a.DO.Clauses(conds...))
}

@ -17,10 +17,10 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newCategory(db *gorm.DB) category {
func newCategory(db *gorm.DB, opts ...gen.DOOption) category {
_category := category{}
_category.categoryDo.UseDB(db)
_category.categoryDo.UseDB(db, opts...)
_category.categoryDo.UseModel(&entity.Category{})
tableName := _category.categoryDo.TableName()
@ -29,13 +29,13 @@ func newCategory(db *gorm.DB) category {
_category.CreateTime = field.NewTime(tableName, "create_time")
_category.UpdateTime = field.NewTime(tableName, "update_time")
_category.Description = field.NewString(tableName, "description")
_category.Type = field.NewField(tableName, "type")
_category.Name = field.NewString(tableName, "name")
_category.ParentID = field.NewInt32(tableName, "parent_id")
_category.Password = field.NewString(tableName, "password")
_category.Slug = field.NewString(tableName, "slug")
_category.Thumbnail = field.NewString(tableName, "thumbnail")
_category.Priority = field.NewInt32(tableName, "priority")
_category.Type = field.NewField(tableName, "type")
_category.fillFieldMap()
@ -50,13 +50,13 @@ type category struct {
CreateTime field.Time
UpdateTime field.Time
Description field.String
Type field.Field
Name field.String
ParentID field.Int32
Password field.String
Slug field.String
Thumbnail field.String
Priority field.Int32
Type field.Field
fieldMap map[string]field.Expr
}
@ -77,13 +77,13 @@ func (c *category) updateTableName(table string) *category {
c.CreateTime = field.NewTime(table, "create_time")
c.UpdateTime = field.NewTime(table, "update_time")
c.Description = field.NewString(table, "description")
c.Type = field.NewField(table, "type")
c.Name = field.NewString(table, "name")
c.ParentID = field.NewInt32(table, "parent_id")
c.Password = field.NewString(table, "password")
c.Slug = field.NewString(table, "slug")
c.Thumbnail = field.NewString(table, "thumbnail")
c.Priority = field.NewInt32(table, "priority")
c.Type = field.NewField(table, "type")
c.fillFieldMap()
@ -111,16 +111,21 @@ func (c *category) fillFieldMap() {
c.fieldMap["create_time"] = c.CreateTime
c.fieldMap["update_time"] = c.UpdateTime
c.fieldMap["description"] = c.Description
c.fieldMap["type"] = c.Type
c.fieldMap["name"] = c.Name
c.fieldMap["parent_id"] = c.ParentID
c.fieldMap["password"] = c.Password
c.fieldMap["slug"] = c.Slug
c.fieldMap["thumbnail"] = c.Thumbnail
c.fieldMap["priority"] = c.Priority
c.fieldMap["type"] = c.Type
}
func (c category) clone(db *gorm.DB) category {
c.categoryDo.ReplaceConnPool(db.Statement.ConnPool)
return c
}
func (c category) replaceDB(db *gorm.DB) category {
c.categoryDo.ReplaceDB(db)
return c
}
@ -143,6 +148,10 @@ func (c categoryDo) WriteDB() *categoryDo {
return c.Clauses(dbresolver.Write)
}
func (c categoryDo) Session(config *gorm.Session) *categoryDo {
return c.withDO(c.DO.Session(config))
}
func (c categoryDo) Clauses(conds ...clause.Expression) *categoryDo {
return c.withDO(c.DO.Clauses(conds...))
}

@ -17,15 +17,15 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newComment(db *gorm.DB) comment {
func newComment(db *gorm.DB, opts ...gen.DOOption) comment {
_comment := comment{}
_comment.commentDo.UseDB(db)
_comment.commentDo.UseDB(db, opts...)
_comment.commentDo.UseModel(&entity.Comment{})
tableName := _comment.commentDo.TableName()
_comment.ALL = field.NewAsterisk(tableName)
_comment.ID = field.NewInt64(tableName, "id")
_comment.ID = field.NewInt32(tableName, "id")
_comment.Type = field.NewField(tableName, "type")
_comment.CreateTime = field.NewTime(tableName, "create_time")
_comment.UpdateTime = field.NewTime(tableName, "update_time")
@ -37,7 +37,7 @@ func newComment(db *gorm.DB) comment {
_comment.GravatarMd5 = field.NewString(tableName, "gravatar_md5")
_comment.IPAddress = field.NewString(tableName, "ip_address")
_comment.IsAdmin = field.NewBool(tableName, "is_admin")
_comment.ParentID = field.NewInt64(tableName, "parent_id")
_comment.ParentID = field.NewInt32(tableName, "parent_id")
_comment.PostID = field.NewInt32(tableName, "post_id")
_comment.Status = field.NewField(tableName, "status")
_comment.TopPriority = field.NewInt32(tableName, "top_priority")
@ -52,7 +52,7 @@ type comment struct {
commentDo commentDo
ALL field.Asterisk
ID field.Int64
ID field.Int32
Type field.Field
CreateTime field.Time
UpdateTime field.Time
@ -64,7 +64,7 @@ type comment struct {
GravatarMd5 field.String
IPAddress field.String
IsAdmin field.Bool
ParentID field.Int64
ParentID field.Int32
PostID field.Int32
Status field.Field
TopPriority field.Int32
@ -85,7 +85,7 @@ func (c comment) As(alias string) *comment {
func (c *comment) updateTableName(table string) *comment {
c.ALL = field.NewAsterisk(table)
c.ID = field.NewInt64(table, "id")
c.ID = field.NewInt32(table, "id")
c.Type = field.NewField(table, "type")
c.CreateTime = field.NewTime(table, "create_time")
c.UpdateTime = field.NewTime(table, "update_time")
@ -97,7 +97,7 @@ func (c *comment) updateTableName(table string) *comment {
c.GravatarMd5 = field.NewString(table, "gravatar_md5")
c.IPAddress = field.NewString(table, "ip_address")
c.IsAdmin = field.NewBool(table, "is_admin")
c.ParentID = field.NewInt64(table, "parent_id")
c.ParentID = field.NewInt32(table, "parent_id")
c.PostID = field.NewInt32(table, "post_id")
c.Status = field.NewField(table, "status")
c.TopPriority = field.NewInt32(table, "top_priority")
@ -145,6 +145,11 @@ func (c *comment) fillFieldMap() {
}
func (c comment) clone(db *gorm.DB) comment {
c.commentDo.ReplaceConnPool(db.Statement.ConnPool)
return c
}
func (c comment) replaceDB(db *gorm.DB) comment {
c.commentDo.ReplaceDB(db)
return c
}
@ -167,6 +172,10 @@ func (c commentDo) WriteDB() *commentDo {
return c.Clauses(dbresolver.Write)
}
func (c commentDo) Session(config *gorm.Session) *commentDo {
return c.withDO(c.DO.Session(config))
}
func (c commentDo) Clauses(conds ...clause.Expression) *commentDo {
return c.withDO(c.DO.Clauses(conds...))
}

@ -17,15 +17,15 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newCommentBlack(db *gorm.DB) commentBlack {
func newCommentBlack(db *gorm.DB, opts ...gen.DOOption) commentBlack {
_commentBlack := commentBlack{}
_commentBlack.commentBlackDo.UseDB(db)
_commentBlack.commentBlackDo.UseDB(db, opts...)
_commentBlack.commentBlackDo.UseModel(&entity.CommentBlack{})
tableName := _commentBlack.commentBlackDo.TableName()
_commentBlack.ALL = field.NewAsterisk(tableName)
_commentBlack.ID = field.NewInt64(tableName, "id")
_commentBlack.ID = field.NewInt32(tableName, "id")
_commentBlack.CreateTime = field.NewTime(tableName, "create_time")
_commentBlack.UpdateTime = field.NewTime(tableName, "update_time")
_commentBlack.BanTime = field.NewTime(tableName, "ban_time")
@ -40,7 +40,7 @@ type commentBlack struct {
commentBlackDo commentBlackDo
ALL field.Asterisk
ID field.Int64
ID field.Int32
CreateTime field.Time
UpdateTime field.Time
BanTime field.Time
@ -61,7 +61,7 @@ func (c commentBlack) As(alias string) *commentBlack {
func (c *commentBlack) updateTableName(table string) *commentBlack {
c.ALL = field.NewAsterisk(table)
c.ID = field.NewInt64(table, "id")
c.ID = field.NewInt32(table, "id")
c.CreateTime = field.NewTime(table, "create_time")
c.UpdateTime = field.NewTime(table, "update_time")
c.BanTime = field.NewTime(table, "ban_time")
@ -99,6 +99,11 @@ func (c *commentBlack) fillFieldMap() {
}
func (c commentBlack) clone(db *gorm.DB) commentBlack {
c.commentBlackDo.ReplaceConnPool(db.Statement.ConnPool)
return c
}
func (c commentBlack) replaceDB(db *gorm.DB) commentBlack {
c.commentBlackDo.ReplaceDB(db)
return c
}
@ -121,6 +126,10 @@ func (c commentBlackDo) WriteDB() *commentBlackDo {
return c.Clauses(dbresolver.Write)
}
func (c commentBlackDo) Session(config *gorm.Session) *commentBlackDo {
return c.withDO(c.DO.Session(config))
}
func (c commentBlackDo) Clauses(conds ...clause.Expression) *commentBlackDo {
return c.withDO(c.DO.Clauses(conds...))
}

@ -17,10 +17,10 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newFlywaySchemaHistory(db *gorm.DB) flywaySchemaHistory {
func newFlywaySchemaHistory(db *gorm.DB, opts ...gen.DOOption) flywaySchemaHistory {
_flywaySchemaHistory := flywaySchemaHistory{}
_flywaySchemaHistory.flywaySchemaHistoryDo.UseDB(db)
_flywaySchemaHistory.flywaySchemaHistoryDo.UseDB(db, opts...)
_flywaySchemaHistory.flywaySchemaHistoryDo.UseModel(&entity.FlywaySchemaHistory{})
tableName := _flywaySchemaHistory.flywaySchemaHistoryDo.TableName()
@ -119,6 +119,11 @@ func (f *flywaySchemaHistory) fillFieldMap() {
}
func (f flywaySchemaHistory) clone(db *gorm.DB) flywaySchemaHistory {
f.flywaySchemaHistoryDo.ReplaceConnPool(db.Statement.ConnPool)
return f
}
func (f flywaySchemaHistory) replaceDB(db *gorm.DB) flywaySchemaHistory {
f.flywaySchemaHistoryDo.ReplaceDB(db)
return f
}
@ -141,6 +146,10 @@ func (f flywaySchemaHistoryDo) WriteDB() *flywaySchemaHistoryDo {
return f.Clauses(dbresolver.Write)
}
func (f flywaySchemaHistoryDo) Session(config *gorm.Session) *flywaySchemaHistoryDo {
return f.withDO(f.DO.Session(config))
}
func (f flywaySchemaHistoryDo) Clauses(conds ...clause.Expression) *flywaySchemaHistoryDo {
return f.withDO(f.DO.Clauses(conds...))
}

@ -8,7 +8,9 @@ import (
"context"
"database/sql"
"gorm.io/gen"
"gorm.io/gorm"
"gorm.io/plugin/dbresolver"
)
var (
@ -33,8 +35,8 @@ var (
User *user
)
func SetDefault(db *gorm.DB) {
*Q = *Use(db)
func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
*Q = *Use(db, opts...)
Attachment = &Q.Attachment
Category = &Q.Category
Comment = &Q.Comment
@ -55,27 +57,27 @@ func SetDefault(db *gorm.DB) {
User = &Q.User
}
func Use(db *gorm.DB) *Query {
func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
return &Query{
db: db,
Attachment: newAttachment(db),
Category: newCategory(db),
Comment: newComment(db),
CommentBlack: newCommentBlack(db),
FlywaySchemaHistory: newFlywaySchemaHistory(db),
Journal: newJournal(db),
Link: newLink(db),
Log: newLog(db),
Menu: newMenu(db),
Meta: newMeta(db),
Option: newOption(db),
Photo: newPhoto(db),
Post: newPost(db),
PostCategory: newPostCategory(db),
PostTag: newPostTag(db),
Tag: newTag(db),
ThemeSetting: newThemeSetting(db),
User: newUser(db),
Attachment: newAttachment(db, opts...),
Category: newCategory(db, opts...),
Comment: newComment(db, opts...),
CommentBlack: newCommentBlack(db, opts...),
FlywaySchemaHistory: newFlywaySchemaHistory(db, opts...),
Journal: newJournal(db, opts...),
Link: newLink(db, opts...),
Log: newLog(db, opts...),
Menu: newMenu(db, opts...),
Meta: newMeta(db, opts...),
Option: newOption(db, opts...),
Photo: newPhoto(db, opts...),
Post: newPost(db, opts...),
PostCategory: newPostCategory(db, opts...),
PostTag: newPostTag(db, opts...),
Tag: newTag(db, opts...),
ThemeSetting: newThemeSetting(db, opts...),
User: newUser(db, opts...),
}
}
@ -128,6 +130,38 @@ func (q *Query) clone(db *gorm.DB) *Query {
}
}
func (q *Query) ReadDB() *Query {
return q.clone(q.db.Clauses(dbresolver.Read))
}
func (q *Query) WriteDB() *Query {
return q.clone(q.db.Clauses(dbresolver.Write))
}
func (q *Query) ReplaceDB(db *gorm.DB) *Query {
return &Query{
db: db,
Attachment: q.Attachment.replaceDB(db),
Category: q.Category.replaceDB(db),
Comment: q.Comment.replaceDB(db),
CommentBlack: q.CommentBlack.replaceDB(db),
FlywaySchemaHistory: q.FlywaySchemaHistory.replaceDB(db),
Journal: q.Journal.replaceDB(db),
Link: q.Link.replaceDB(db),
Log: q.Log.replaceDB(db),
Menu: q.Menu.replaceDB(db),
Meta: q.Meta.replaceDB(db),
Option: q.Option.replaceDB(db),
Photo: q.Photo.replaceDB(db),
Post: q.Post.replaceDB(db),
PostCategory: q.PostCategory.replaceDB(db),
PostTag: q.PostTag.replaceDB(db),
Tag: q.Tag.replaceDB(db),
ThemeSetting: q.ThemeSetting.replaceDB(db),
User: q.User.replaceDB(db),
}
}
type queryCtx struct {
Attachment *attachmentDo
Category *categoryDo

@ -17,10 +17,10 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newJournal(db *gorm.DB) journal {
func newJournal(db *gorm.DB, opts ...gen.DOOption) journal {
_journal := journal{}
_journal.journalDo.UseDB(db)
_journal.journalDo.UseDB(db, opts...)
_journal.journalDo.UseModel(&entity.Journal{})
tableName := _journal.journalDo.TableName()
@ -105,6 +105,11 @@ func (j *journal) fillFieldMap() {
}
func (j journal) clone(db *gorm.DB) journal {
j.journalDo.ReplaceConnPool(db.Statement.ConnPool)
return j
}
func (j journal) replaceDB(db *gorm.DB) journal {
j.journalDo.ReplaceDB(db)
return j
}
@ -127,6 +132,10 @@ func (j journalDo) WriteDB() *journalDo {
return j.Clauses(dbresolver.Write)
}
func (j journalDo) Session(config *gorm.Session) *journalDo {
return j.withDO(j.DO.Session(config))
}
func (j journalDo) Clauses(conds ...clause.Expression) *journalDo {
return j.withDO(j.DO.Clauses(conds...))
}

@ -17,10 +17,10 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newLink(db *gorm.DB) link {
func newLink(db *gorm.DB, opts ...gen.DOOption) link {
_link := link{}
_link.linkDo.UseDB(db)
_link.linkDo.UseDB(db, opts...)
_link.linkDo.UseModel(&entity.Link{})
tableName := _link.linkDo.TableName()
@ -113,6 +113,11 @@ func (l *link) fillFieldMap() {
}
func (l link) clone(db *gorm.DB) link {
l.linkDo.ReplaceConnPool(db.Statement.ConnPool)
return l
}
func (l link) replaceDB(db *gorm.DB) link {
l.linkDo.ReplaceDB(db)
return l
}
@ -135,6 +140,10 @@ func (l linkDo) WriteDB() *linkDo {
return l.Clauses(dbresolver.Write)
}
func (l linkDo) Session(config *gorm.Session) *linkDo {
return l.withDO(l.DO.Session(config))
}
func (l linkDo) Clauses(conds ...clause.Expression) *linkDo {
return l.withDO(l.DO.Clauses(conds...))
}

@ -17,10 +17,10 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newLog(db *gorm.DB) log {
func newLog(db *gorm.DB, opts ...gen.DOOption) log {
_log := log{}
_log.logDo.UseDB(db)
_log.logDo.UseDB(db, opts...)
_log.logDo.UseModel(&entity.Log{})
tableName := _log.logDo.TableName()
@ -105,6 +105,11 @@ func (l *log) fillFieldMap() {
}
func (l log) clone(db *gorm.DB) log {
l.logDo.ReplaceConnPool(db.Statement.ConnPool)
return l
}
func (l log) replaceDB(db *gorm.DB) log {
l.logDo.ReplaceDB(db)
return l
}
@ -127,6 +132,10 @@ func (l logDo) WriteDB() *logDo {
return l.Clauses(dbresolver.Write)
}
func (l logDo) Session(config *gorm.Session) *logDo {
return l.withDO(l.DO.Session(config))
}
func (l logDo) Clauses(conds ...clause.Expression) *logDo {
return l.withDO(l.DO.Clauses(conds...))
}

@ -17,10 +17,10 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newMenu(db *gorm.DB) menu {
func newMenu(db *gorm.DB, opts ...gen.DOOption) menu {
_menu := menu{}
_menu.menuDo.UseDB(db)
_menu.menuDo.UseDB(db, opts...)
_menu.menuDo.UseModel(&entity.Menu{})
tableName := _menu.menuDo.TableName()
@ -117,6 +117,11 @@ func (m *menu) fillFieldMap() {
}
func (m menu) clone(db *gorm.DB) menu {
m.menuDo.ReplaceConnPool(db.Statement.ConnPool)
return m
}
func (m menu) replaceDB(db *gorm.DB) menu {
m.menuDo.ReplaceDB(db)
return m
}
@ -139,6 +144,10 @@ func (m menuDo) WriteDB() *menuDo {
return m.Clauses(dbresolver.Write)
}
func (m menuDo) Session(config *gorm.Session) *menuDo {
return m.withDO(m.DO.Session(config))
}
func (m menuDo) Clauses(conds ...clause.Expression) *menuDo {
return m.withDO(m.DO.Clauses(conds...))
}

@ -17,15 +17,15 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newMeta(db *gorm.DB) meta {
func newMeta(db *gorm.DB, opts ...gen.DOOption) meta {
_meta := meta{}
_meta.metaDo.UseDB(db)
_meta.metaDo.UseDB(db, opts...)
_meta.metaDo.UseModel(&entity.Meta{})
tableName := _meta.metaDo.TableName()
_meta.ALL = field.NewAsterisk(tableName)
_meta.ID = field.NewInt64(tableName, "id")
_meta.ID = field.NewInt32(tableName, "id")
_meta.Type = field.NewField(tableName, "type")
_meta.CreateTime = field.NewTime(tableName, "create_time")
_meta.UpdateTime = field.NewTime(tableName, "update_time")
@ -42,7 +42,7 @@ type meta struct {
metaDo metaDo
ALL field.Asterisk
ID field.Int64
ID field.Int32
Type field.Field
CreateTime field.Time
UpdateTime field.Time
@ -65,7 +65,7 @@ func (m meta) As(alias string) *meta {
func (m *meta) updateTableName(table string) *meta {
m.ALL = field.NewAsterisk(table)
m.ID = field.NewInt64(table, "id")
m.ID = field.NewInt32(table, "id")
m.Type = field.NewField(table, "type")
m.CreateTime = field.NewTime(table, "create_time")
m.UpdateTime = field.NewTime(table, "update_time")
@ -105,6 +105,11 @@ func (m *meta) fillFieldMap() {
}
func (m meta) clone(db *gorm.DB) meta {
m.metaDo.ReplaceConnPool(db.Statement.ConnPool)
return m
}
func (m meta) replaceDB(db *gorm.DB) meta {
m.metaDo.ReplaceDB(db)
return m
}
@ -127,6 +132,10 @@ func (m metaDo) WriteDB() *metaDo {
return m.Clauses(dbresolver.Write)
}
func (m metaDo) Session(config *gorm.Session) *metaDo {
return m.withDO(m.DO.Session(config))
}
func (m metaDo) Clauses(conds ...clause.Expression) *metaDo {
return m.withDO(m.DO.Clauses(conds...))
}

@ -17,10 +17,10 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newOption(db *gorm.DB) option {
func newOption(db *gorm.DB, opts ...gen.DOOption) option {
_option := option{}
_option.optionDo.UseDB(db)
_option.optionDo.UseDB(db, opts...)
_option.optionDo.UseModel(&entity.Option{})
tableName := _option.optionDo.TableName()
@ -101,6 +101,11 @@ func (o *option) fillFieldMap() {
}
func (o option) clone(db *gorm.DB) option {
o.optionDo.ReplaceConnPool(db.Statement.ConnPool)
return o
}
func (o option) replaceDB(db *gorm.DB) option {
o.optionDo.ReplaceDB(db)
return o
}
@ -123,6 +128,10 @@ func (o optionDo) WriteDB() *optionDo {
return o.Clauses(dbresolver.Write)
}
func (o optionDo) Session(config *gorm.Session) *optionDo {
return o.withDO(o.DO.Session(config))
}
func (o optionDo) Clauses(conds ...clause.Expression) *optionDo {
return o.withDO(o.DO.Clauses(conds...))
}

@ -17,10 +17,10 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newPhoto(db *gorm.DB) photo {
func newPhoto(db *gorm.DB, opts ...gen.DOOption) photo {
_photo := photo{}
_photo.photoDo.UseDB(db)
_photo.photoDo.UseDB(db, opts...)
_photo.photoDo.UseModel(&entity.Photo{})
tableName := _photo.photoDo.TableName()
@ -121,6 +121,11 @@ func (p *photo) fillFieldMap() {
}
func (p photo) clone(db *gorm.DB) photo {
p.photoDo.ReplaceConnPool(db.Statement.ConnPool)
return p
}
func (p photo) replaceDB(db *gorm.DB) photo {
p.photoDo.ReplaceDB(db)
return p
}
@ -143,6 +148,10 @@ func (p photoDo) WriteDB() *photoDo {
return p.Clauses(dbresolver.Write)
}
func (p photoDo) Session(config *gorm.Session) *photoDo {
return p.withDO(p.DO.Session(config))
}
func (p photoDo) Clauses(conds ...clause.Expression) *photoDo {
return p.withDO(p.DO.Clauses(conds...))
}

@ -17,10 +17,10 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newPost(db *gorm.DB) post {
func newPost(db *gorm.DB, opts ...gen.DOOption) post {
_post := post{}
_post.postDo.UseDB(db)
_post.postDo.UseDB(db, opts...)
_post.postDo.UseModel(&entity.Post{})
tableName := _post.postDo.TableName()
@ -32,9 +32,11 @@ func newPost(db *gorm.DB) post {
_post.DisallowComment = field.NewBool(tableName, "disallow_comment")
_post.EditTime = field.NewTime(tableName, "edit_time")
_post.EditorType = field.NewField(tableName, "editor_type")
_post.FormatContent = field.NewString(tableName, "format_content")
_post.Likes = field.NewInt64(tableName, "likes")
_post.MetaDescription = field.NewString(tableName, "meta_description")
_post.MetaKeywords = field.NewString(tableName, "meta_keywords")
_post.OriginalContent = field.NewString(tableName, "original_content")
_post.Password = field.NewString(tableName, "password")
_post.Slug = field.NewString(tableName, "slug")
_post.Status = field.NewField(tableName, "status")
@ -45,9 +47,6 @@ func newPost(db *gorm.DB) post {
_post.TopPriority = field.NewInt32(tableName, "top_priority")
_post.Visits = field.NewInt64(tableName, "visits")
_post.WordCount = field.NewInt64(tableName, "word_count")
_post.Version = field.NewInt32(tableName, "version")
_post.FormatContent = field.NewString(tableName, "format_content")
_post.OriginalContent = field.NewString(tableName, "original_content")
_post.fillFieldMap()
@ -65,9 +64,11 @@ type post struct {
DisallowComment field.Bool
EditTime field.Time
EditorType field.Field
FormatContent field.String
Likes field.Int64
MetaDescription field.String
MetaKeywords field.String
OriginalContent field.String
Password field.String
Slug field.String
Status field.Field
@ -78,9 +79,6 @@ type post struct {
TopPriority field.Int32
Visits field.Int64
WordCount field.Int64
Version field.Int32
FormatContent field.String
OriginalContent field.String
fieldMap map[string]field.Expr
}
@ -104,9 +102,11 @@ func (p *post) updateTableName(table string) *post {
p.DisallowComment = field.NewBool(table, "disallow_comment")
p.EditTime = field.NewTime(table, "edit_time")
p.EditorType = field.NewField(table, "editor_type")
p.FormatContent = field.NewString(table, "format_content")
p.Likes = field.NewInt64(table, "likes")
p.MetaDescription = field.NewString(table, "meta_description")
p.MetaKeywords = field.NewString(table, "meta_keywords")
p.OriginalContent = field.NewString(table, "original_content")
p.Password = field.NewString(table, "password")
p.Slug = field.NewString(table, "slug")
p.Status = field.NewField(table, "status")
@ -117,9 +117,6 @@ func (p *post) updateTableName(table string) *post {
p.TopPriority = field.NewInt32(table, "top_priority")
p.Visits = field.NewInt64(table, "visits")
p.WordCount = field.NewInt64(table, "word_count")
p.Version = field.NewInt32(table, "version")
p.FormatContent = field.NewString(table, "format_content")
p.OriginalContent = field.NewString(table, "original_content")
p.fillFieldMap()
@ -142,7 +139,7 @@ func (p *post) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
}
func (p *post) fillFieldMap() {
p.fieldMap = make(map[string]field.Expr, 23)
p.fieldMap = make(map[string]field.Expr, 22)
p.fieldMap["id"] = p.ID
p.fieldMap["type"] = p.Type
p.fieldMap["create_time"] = p.CreateTime
@ -150,9 +147,11 @@ func (p *post) fillFieldMap() {
p.fieldMap["disallow_comment"] = p.DisallowComment
p.fieldMap["edit_time"] = p.EditTime
p.fieldMap["editor_type"] = p.EditorType
p.fieldMap["format_content"] = p.FormatContent
p.fieldMap["likes"] = p.Likes
p.fieldMap["meta_description"] = p.MetaDescription
p.fieldMap["meta_keywords"] = p.MetaKeywords
p.fieldMap["original_content"] = p.OriginalContent
p.fieldMap["password"] = p.Password
p.fieldMap["slug"] = p.Slug
p.fieldMap["status"] = p.Status
@ -163,12 +162,14 @@ func (p *post) fillFieldMap() {
p.fieldMap["top_priority"] = p.TopPriority
p.fieldMap["visits"] = p.Visits
p.fieldMap["word_count"] = p.WordCount
p.fieldMap["version"] = p.Version
p.fieldMap["format_content"] = p.FormatContent
p.fieldMap["original_content"] = p.OriginalContent
}
func (p post) clone(db *gorm.DB) post {
p.postDo.ReplaceConnPool(db.Statement.ConnPool)
return p
}
func (p post) replaceDB(db *gorm.DB) post {
p.postDo.ReplaceDB(db)
return p
}
@ -191,6 +192,10 @@ func (p postDo) WriteDB() *postDo {
return p.Clauses(dbresolver.Write)
}
func (p postDo) Session(config *gorm.Session) *postDo {
return p.withDO(p.DO.Session(config))
}
func (p postDo) Clauses(conds ...clause.Expression) *postDo {
return p.withDO(p.DO.Clauses(conds...))
}

@ -17,10 +17,10 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newPostCategory(db *gorm.DB) postCategory {
func newPostCategory(db *gorm.DB, opts ...gen.DOOption) postCategory {
_postCategory := postCategory{}
_postCategory.postCategoryDo.UseDB(db)
_postCategory.postCategoryDo.UseDB(db, opts...)
_postCategory.postCategoryDo.UseModel(&entity.PostCategory{})
tableName := _postCategory.postCategoryDo.TableName()
@ -99,6 +99,11 @@ func (p *postCategory) fillFieldMap() {
}
func (p postCategory) clone(db *gorm.DB) postCategory {
p.postCategoryDo.ReplaceConnPool(db.Statement.ConnPool)
return p
}
func (p postCategory) replaceDB(db *gorm.DB) postCategory {
p.postCategoryDo.ReplaceDB(db)
return p
}
@ -121,6 +126,10 @@ func (p postCategoryDo) WriteDB() *postCategoryDo {
return p.Clauses(dbresolver.Write)
}
func (p postCategoryDo) Session(config *gorm.Session) *postCategoryDo {
return p.withDO(p.DO.Session(config))
}
func (p postCategoryDo) Clauses(conds ...clause.Expression) *postCategoryDo {
return p.withDO(p.DO.Clauses(conds...))
}

@ -17,10 +17,10 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newPostTag(db *gorm.DB) postTag {
func newPostTag(db *gorm.DB, opts ...gen.DOOption) postTag {
_postTag := postTag{}
_postTag.postTagDo.UseDB(db)
_postTag.postTagDo.UseDB(db, opts...)
_postTag.postTagDo.UseModel(&entity.PostTag{})
tableName := _postTag.postTagDo.TableName()
@ -97,6 +97,11 @@ func (p *postTag) fillFieldMap() {
}
func (p postTag) clone(db *gorm.DB) postTag {
p.postTagDo.ReplaceConnPool(db.Statement.ConnPool)
return p
}
func (p postTag) replaceDB(db *gorm.DB) postTag {
p.postTagDo.ReplaceDB(db)
return p
}
@ -119,6 +124,10 @@ func (p postTagDo) WriteDB() *postTagDo {
return p.Clauses(dbresolver.Write)
}
func (p postTagDo) Session(config *gorm.Session) *postTagDo {
return p.withDO(p.DO.Session(config))
}
func (p postTagDo) Clauses(conds ...clause.Expression) *postTagDo {
return p.withDO(p.DO.Clauses(conds...))
}

@ -17,10 +17,10 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newTag(db *gorm.DB) tag {
func newTag(db *gorm.DB, opts ...gen.DOOption) tag {
_tag := tag{}
_tag.tagDo.UseDB(db)
_tag.tagDo.UseDB(db, opts...)
_tag.tagDo.UseModel(&entity.Tag{})
tableName := _tag.tagDo.TableName()
@ -105,6 +105,11 @@ func (t *tag) fillFieldMap() {
}
func (t tag) clone(db *gorm.DB) tag {
t.tagDo.ReplaceConnPool(db.Statement.ConnPool)
return t
}
func (t tag) replaceDB(db *gorm.DB) tag {
t.tagDo.ReplaceDB(db)
return t
}
@ -127,6 +132,10 @@ func (t tagDo) WriteDB() *tagDo {
return t.Clauses(dbresolver.Write)
}
func (t tagDo) Session(config *gorm.Session) *tagDo {
return t.withDO(t.DO.Session(config))
}
func (t tagDo) Clauses(conds ...clause.Expression) *tagDo {
return t.withDO(t.DO.Clauses(conds...))
}

@ -17,10 +17,10 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newThemeSetting(db *gorm.DB) themeSetting {
func newThemeSetting(db *gorm.DB, opts ...gen.DOOption) themeSetting {
_themeSetting := themeSetting{}
_themeSetting.themeSettingDo.UseDB(db)
_themeSetting.themeSettingDo.UseDB(db, opts...)
_themeSetting.themeSettingDo.UseModel(&entity.ThemeSetting{})
tableName := _themeSetting.themeSettingDo.TableName()
@ -103,6 +103,11 @@ func (t *themeSetting) fillFieldMap() {
}
func (t themeSetting) clone(db *gorm.DB) themeSetting {
t.themeSettingDo.ReplaceConnPool(db.Statement.ConnPool)
return t
}
func (t themeSetting) replaceDB(db *gorm.DB) themeSetting {
t.themeSettingDo.ReplaceDB(db)
return t
}
@ -125,6 +130,10 @@ func (t themeSettingDo) WriteDB() *themeSettingDo {
return t.Clauses(dbresolver.Write)
}
func (t themeSettingDo) Session(config *gorm.Session) *themeSettingDo {
return t.withDO(t.DO.Session(config))
}
func (t themeSettingDo) Clauses(conds ...clause.Expression) *themeSettingDo {
return t.withDO(t.DO.Clauses(conds...))
}

@ -17,10 +17,10 @@ import (
"github.com/go-sonic/sonic/model/entity"
)
func newUser(db *gorm.DB) user {
func newUser(db *gorm.DB, opts ...gen.DOOption) user {
_user := user{}
_user.userDo.UseDB(db)
_user.userDo.UseDB(db, opts...)
_user.userDo.UseModel(&entity.User{})
tableName := _user.userDo.TableName()
@ -125,6 +125,11 @@ func (u *user) fillFieldMap() {
}
func (u user) clone(db *gorm.DB) user {
u.userDo.ReplaceConnPool(db.Statement.ConnPool)
return u
}
func (u user) replaceDB(db *gorm.DB) user {
u.userDo.ReplaceDB(db)
return u
}
@ -147,6 +152,10 @@ func (u userDo) WriteDB() *userDo {
return u.Clauses(dbresolver.Write)
}
func (u userDo) Session(config *gorm.Session) *userDo {
return u.withDO(u.DO.Session(config))
}
func (u userDo) Clauses(conds ...clause.Expression) *userDo {
return u.withDO(u.DO.Clauses(conds...))
}

@ -1,7 +0,0 @@
GENERATE_DIR="./cmd/generate"
cd $GENERATE_DIR || exit
echo "Start Generating"
go run .

@ -29,7 +29,7 @@ require (
gopkg.in/yaml.v2 v2.4.0
gorm.io/driver/mysql v1.4.3
gorm.io/driver/sqlite v1.4.3
gorm.io/gen v0.3.17
gorm.io/gen v0.3.18
gorm.io/gorm v1.24.0
gorm.io/plugin/dbresolver v1.3.0
)

@ -791,6 +791,8 @@ gorm.io/driver/sqlserver v1.4.0 h1:3fjbsNkr/YqocSBW5CP16Lq6+APjRrWMzu7NbkXr9QU=
gorm.io/driver/sqlserver v1.4.0/go.mod h1:P8BSbBwkdzXURYx3pWUSEAABRQU0vxbd6xk5+53pg7g=
gorm.io/gen v0.3.17 h1:vIgdvpBnXd3c1HOc7chuWlj0cM6w6ZimGZUDada6nwI=
gorm.io/gen v0.3.17/go.mod h1:uQsfditHYOjbibLcsXkFqSIfBmRFWwucMEa2WrcqX8k=
gorm.io/gen v0.3.18 h1:2loBwVSN8+K0EC7Q2XFP7AhWPY/Pt3rRtw2ENTAB1c4=
gorm.io/gen v0.3.18/go.mod h1:uQsfditHYOjbibLcsXkFqSIfBmRFWwucMEa2WrcqX8k=
gorm.io/gorm v1.21.15/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0=
gorm.io/gorm v1.22.2/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0=
gorm.io/gorm v1.23.1/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=

@ -12,6 +12,7 @@ import (
"github.com/go-sonic/sonic/model/property"
"github.com/go-sonic/sonic/service"
"github.com/go-sonic/sonic/service/assembler"
"github.com/go-sonic/sonic/service/impl"
"github.com/go-sonic/sonic/util"
"github.com/go-sonic/sonic/util/xerr"
)
@ -83,7 +84,7 @@ func (j *JournalCommentHandler) ListJournalCommentAsTree(ctx *gin.Context) (inte
}
page := param.Page{PageSize: pageSize.(int), PageNum: int(pageNum)}
allComments, err := j.JournalCommentService.GetByContentID(ctx, journalID, &param.Sort{Fields: []string{"createTime,desc"}})
allComments, err := j.JournalCommentService.GetByContentID(ctx, journalID, consts.CommentTypeJournal, &param.Sort{Fields: []string{"createTime,desc"}})
if err != nil {
return nil, err
}
@ -129,7 +130,7 @@ func (j *JournalCommentHandler) ListJournalCommentWithParent(ctx *gin.Context) (
}
func (j *JournalCommentHandler) CreateJournalComment(ctx *gin.Context) (interface{}, error) {
var commentParam *param.Comment
var commentParam *param.AdminComment
err := ctx.ShouldBindJSON(&commentParam)
if err != nil {
if e, ok := err.(validator.ValidationErrors); ok {
@ -137,14 +138,25 @@ func (j *JournalCommentHandler) CreateJournalComment(ctx *gin.Context) (interfac
}
return nil, xerr.WithStatus(err, xerr.StatusBadRequest).WithMsg("parameter error")
}
if commentParam.AuthorURL != "" {
err = util.Validate.Var(commentParam.AuthorURL, "url")
if err != nil {
return nil, xerr.WithStatus(err, xerr.StatusBadRequest).WithMsg("url is not available")
}
user, err := impl.MustGetAuthorizedUser(ctx)
if err != nil || user == nil {
return nil, err
}
blogURL, err := j.OptionService.GetBlogBaseURL(ctx)
if err != nil {
return nil, err
}
commonParam := param.Comment{
Author: user.Username,
Email: user.Email,
AuthorURL: blogURL,
Content: commentParam.Content,
PostID: commentParam.PostID,
ParentID: commentParam.ParentID,
AllowNotification: true,
CommentType: consts.CommentTypeJournal,
}
commentParam.CommentType = consts.CommentTypeJournal
comment, err := j.JournalCommentService.CreateBy(ctx, commentParam)
comment, err := j.JournalCommentService.CreateBy(ctx, &commonParam)
if err != nil {
return nil, err
}
@ -152,7 +164,7 @@ func (j *JournalCommentHandler) CreateJournalComment(ctx *gin.Context) (interfac
}
func (j *JournalCommentHandler) UpdateJournalCommentStatus(ctx *gin.Context) (interface{}, error) {
commentID, err := util.ParamInt64(ctx, "commentID")
commentID, err := util.ParamInt32(ctx, "commentID")
if err != nil {
return nil, err
}
@ -168,7 +180,7 @@ func (j *JournalCommentHandler) UpdateJournalCommentStatus(ctx *gin.Context) (in
}
func (j *JournalCommentHandler) UpdateJournalComment(ctx *gin.Context) (interface{}, error) {
commentID, err := util.ParamInt64(ctx, "commentID")
commentID, err := util.ParamInt32(ctx, "commentID")
if err != nil {
return nil, err
}
@ -199,7 +211,7 @@ func (j *JournalCommentHandler) UpdateJournalStatusBatch(ctx *gin.Context) (inte
return nil, err
}
ids := make([]int64, 0)
ids := make([]int32, 0)
err = ctx.ShouldBindJSON(&ids)
if err != nil {
return nil, xerr.WithStatus(err, xerr.StatusBadRequest).WithMsg("post ids error")
@ -212,7 +224,7 @@ func (j *JournalCommentHandler) UpdateJournalStatusBatch(ctx *gin.Context) (inte
}
func (j *JournalCommentHandler) DeleteJournalComment(ctx *gin.Context) (interface{}, error) {
commentID, err := util.ParamInt64(ctx, "commentID")
commentID, err := util.ParamInt32(ctx, "commentID")
if err != nil {
return nil, err
}
@ -220,7 +232,7 @@ func (j *JournalCommentHandler) DeleteJournalComment(ctx *gin.Context) (interfac
}
func (j *JournalCommentHandler) DeleteJournalCommentBatch(ctx *gin.Context) (interface{}, error) {
ids := make([]int64, 0)
ids := make([]int32, 0)
err := ctx.ShouldBindJSON(&ids)
if err != nil {
return nil, xerr.WithStatus(err, xerr.StatusBadRequest).WithMsg("post ids error")

@ -12,6 +12,7 @@ import (
"github.com/go-sonic/sonic/model/property"
"github.com/go-sonic/sonic/service"
"github.com/go-sonic/sonic/service/assembler"
"github.com/go-sonic/sonic/service/impl"
"github.com/go-sonic/sonic/util"
"github.com/go-sonic/sonic/util/xerr"
)
@ -90,7 +91,7 @@ func (p *PostCommentHandler) ListPostCommentAsTree(ctx *gin.Context) (interface{
return nil, err
}
page := param.Page{PageSize: pageSize.(int), PageNum: int(pageNum)}
allComments, err := p.PostCommentService.GetByContentID(ctx, postID, &param.Sort{Fields: []string{"createTime,desc"}})
allComments, err := p.PostCommentService.GetByContentID(ctx, postID, consts.CommentTypePost, &param.Sort{Fields: []string{"createTime,desc"}})
if err != nil {
return nil, err
}
@ -135,7 +136,7 @@ func (p *PostCommentHandler) ListPostCommentWithParent(ctx *gin.Context) (interf
}
func (p *PostCommentHandler) CreatePostComment(ctx *gin.Context) (interface{}, error) {
var commentParam *param.Comment
var commentParam *param.AdminComment
err := ctx.ShouldBindJSON(&commentParam)
if err != nil {
if e, ok := err.(validator.ValidationErrors); ok {
@ -143,14 +144,25 @@ func (p *PostCommentHandler) CreatePostComment(ctx *gin.Context) (interface{}, e
}
return nil, xerr.WithStatus(err, xerr.StatusBadRequest).WithMsg("parameter error")
}
if commentParam.AuthorURL != "" {
err = util.Validate.Var(commentParam.AuthorURL, "url")
if err != nil {
return nil, xerr.WithStatus(err, xerr.StatusBadRequest).WithMsg("url is not available")
}
user, err := impl.MustGetAuthorizedUser(ctx)
if err != nil || user == nil {
return nil, err
}
commentParam.CommentType = consts.CommentTypeSheet
comment, err := p.PostCommentService.CreateBy(ctx, commentParam)
blogURL, err := p.OptionService.GetBlogBaseURL(ctx)
if err != nil {
return nil, err
}
commonParam := param.Comment{
Author: user.Username,
Email: user.Email,
AuthorURL: blogURL,
Content: commentParam.Content,
PostID: commentParam.PostID,
ParentID: commentParam.ParentID,
AllowNotification: true,
CommentType: consts.CommentTypePost,
}
comment, err := p.PostCommentService.CreateBy(ctx, &commonParam)
if err != nil {
return nil, err
}
@ -158,7 +170,7 @@ func (p *PostCommentHandler) CreatePostComment(ctx *gin.Context) (interface{}, e
}
func (p *PostCommentHandler) UpdatePostComment(ctx *gin.Context) (interface{}, error) {
commentID, err := util.ParamInt64(ctx, "commentID")
commentID, err := util.ParamInt32(ctx, "commentID")
if err != nil {
return nil, err
}
@ -197,7 +209,7 @@ func (p *PostCommentHandler) UpdatePostCommentStatus(ctx *gin.Context) (interfac
if err != nil {
return nil, err
}
return p.PostCommentService.UpdateStatus(ctx, int64(commentID), status)
return p.PostCommentService.UpdateStatus(ctx, commentID, status)
}
func (p *PostCommentHandler) UpdatePostCommentStatusBatch(ctx *gin.Context) (interface{}, error) {
@ -206,7 +218,7 @@ func (p *PostCommentHandler) UpdatePostCommentStatusBatch(ctx *gin.Context) (int
return nil, err
}
ids := make([]int64, 0)
ids := make([]int32, 0)
err = ctx.ShouldBindJSON(&ids)
if err != nil {
return nil, xerr.WithStatus(err, xerr.StatusBadRequest).WithMsg("post ids error")
@ -219,7 +231,7 @@ func (p *PostCommentHandler) UpdatePostCommentStatusBatch(ctx *gin.Context) (int
}
func (p *PostCommentHandler) DeletePostComment(ctx *gin.Context) (interface{}, error) {
commentID, err := util.ParamInt64(ctx, "commentID")
commentID, err := util.ParamInt32(ctx, "commentID")
if err != nil {
return nil, err
}
@ -227,7 +239,7 @@ func (p *PostCommentHandler) DeletePostComment(ctx *gin.Context) (interface{}, e
}
func (p *PostCommentHandler) DeletePostCommentBatch(ctx *gin.Context) (interface{}, error) {
ids := make([]int64, 0)
ids := make([]int32, 0)
err := ctx.ShouldBindJSON(&ids)
if err != nil {
return nil, xerr.WithStatus(err, xerr.StatusBadRequest).WithMsg("post ids error")

@ -16,6 +16,7 @@ import (
"github.com/go-sonic/sonic/model/vo"
"github.com/go-sonic/sonic/service"
"github.com/go-sonic/sonic/service/assembler"
"github.com/go-sonic/sonic/service/impl"
"github.com/go-sonic/sonic/util"
"github.com/go-sonic/sonic/util/xerr"
)
@ -98,7 +99,7 @@ func (s *SheetCommentHandler) ListSheetCommentAsTree(ctx *gin.Context) (interfac
}
page := param.Page{PageSize: pageSize.(int), PageNum: int(pageNum)}
allComments, err := s.SheetCommentService.GetByContentID(ctx, postID, &param.Sort{Fields: []string{"createTime,desc"}})
allComments, err := s.SheetCommentService.GetByContentID(ctx, postID, consts.CommentTypeSheet, &param.Sort{Fields: []string{"createTime,desc"}})
if err != nil {
return nil, err
}
@ -142,7 +143,7 @@ func (s *SheetCommentHandler) ListSheetCommentWithParent(ctx *gin.Context) (inte
}
func (s *SheetCommentHandler) CreateSheetComment(ctx *gin.Context) (interface{}, error) {
var commentParam *param.Comment
var commentParam *param.AdminComment
err := ctx.ShouldBindJSON(&commentParam)
if err != nil {
if e, ok := err.(validator.ValidationErrors); ok {
@ -150,14 +151,25 @@ func (s *SheetCommentHandler) CreateSheetComment(ctx *gin.Context) (interface{},
}
return nil, xerr.WithStatus(err, xerr.StatusBadRequest).WithMsg("parameter error")
}
if commentParam.AuthorURL != "" {
err = util.Validate.Var(commentParam.AuthorURL, "url")
if err != nil {
return nil, xerr.WithStatus(err, xerr.StatusBadRequest).WithMsg("url is not available")
}
user, err := impl.MustGetAuthorizedUser(ctx)
if err != nil || user == nil {
return nil, err
}
blogURL, err := s.OptionService.GetBlogBaseURL(ctx)
if err != nil {
return nil, err
}
commentParam.CommentType = consts.CommentTypeSheet
comment, err := s.BaseCommentService.CreateBy(ctx, commentParam)
commonParam := param.Comment{
Author: user.Username,
Email: user.Email,
AuthorURL: blogURL,
Content: commentParam.Content,
PostID: commentParam.PostID,
ParentID: commentParam.ParentID,
AllowNotification: true,
CommentType: consts.CommentTypeSheet,
}
comment, err := s.BaseCommentService.CreateBy(ctx, &commonParam)
if err != nil {
return nil, err
}
@ -177,7 +189,7 @@ func (s *SheetCommentHandler) UpdateSheetCommentStatus(ctx *gin.Context) (interf
if err != nil {
return nil, err
}
return s.SheetCommentService.UpdateStatus(ctx, int64(commentID), status)
return s.SheetCommentService.UpdateStatus(ctx, commentID, status)
}
func (s *SheetCommentHandler) UpdateSheetCommentStatusBatch(ctx *gin.Context) (interface{}, error) {
@ -186,7 +198,7 @@ func (s *SheetCommentHandler) UpdateSheetCommentStatusBatch(ctx *gin.Context) (i
return nil, err
}
ids := make([]int64, 0)
ids := make([]int32, 0)
err = ctx.ShouldBindJSON(&ids)
if err != nil {
return nil, xerr.WithStatus(err, xerr.StatusBadRequest).WithMsg("post ids error")
@ -203,11 +215,11 @@ func (s *SheetCommentHandler) DeleteSheetComment(ctx *gin.Context) (interface{},
if err != nil {
return nil, err
}
return nil, s.SheetCommentService.Delete(ctx, int64(commentID))
return nil, s.SheetCommentService.Delete(ctx, commentID)
}
func (s *SheetCommentHandler) DeleteSheetCommentBatch(ctx *gin.Context) (interface{}, error) {
ids := make([]int64, 0)
ids := make([]int32, 0)
err := ctx.ShouldBindJSON(&ids)
if err != nil {
return nil, xerr.WithStatus(err, xerr.StatusBadRequest).WithMsg("post ids error")

@ -68,6 +68,9 @@ func (j *JournalHandler) CreateJournal(ctx *gin.Context) (interface{}, error) {
}
return nil, xerr.WithStatus(err, xerr.StatusBadRequest).WithMsg("parameter error")
}
if journalParam.Content == "" {
journalParam.Content = journalParam.SourceContent
}
journal, err := j.JournalService.Create(ctx, &journalParam)
if err != nil {
return nil, err

@ -66,7 +66,12 @@ func (m *MenuHandler) ListMenusAsTreeByTeam(ctx *gin.Context) (interface{}, erro
if len(sort.Fields) == 0 {
sort.Fields = append(sort.Fields, "priority,asc")
}
menus, err := m.MenuService.ListAsTree(ctx, &sort)
team, err := util.MustGetQueryString(ctx, "team")
if err != nil {
return nil, err
}
menus, err := m.MenuService.ListAsTreeByTeam(ctx, team, &sort)
if err != nil {
return nil, err
}

@ -119,11 +119,11 @@ func (j *JournalHandler) ListChildren(ctx *gin.Context) (interface{}, error) {
if err != nil {
return nil, err
}
parentID, err := util.ParamInt64(ctx, "parentID")
parentID, err := util.ParamInt32(ctx, "parentID")
if err != nil {
return nil, err
}
children, err := j.JournalCommentService.GetChildren(ctx, parentID, journalID)
children, err := j.JournalCommentService.GetChildren(ctx, parentID, journalID, consts.CommentTypeJournal)
if err != nil {
return nil, err
}
@ -154,7 +154,7 @@ func (j *JournalHandler) ListCommentTree(ctx *gin.Context) (interface{}, error)
commentQuery.PageSize = pageSize
commentQuery.ParentID = util.Int32Ptr(0)
allComments, err := j.JournalCommentService.GetByContentID(ctx, journalID, commentQuery.Sort)
allComments, err := j.JournalCommentService.GetByContentID(ctx, journalID, consts.CommentTypeJournal, commentQuery.Sort)
if err != nil {
return nil, err
}

@ -77,11 +77,11 @@ func (p *PostHandler) ListChildren(ctx *gin.Context) (interface{}, error) {
if err != nil {
return nil, err
}
parentID, err := util.ParamInt64(ctx, "parentID")
parentID, err := util.ParamInt32(ctx, "parentID")
if err != nil {
return nil, err
}
children, err := p.PostCommentService.GetChildren(ctx, parentID, postID)
children, err := p.PostCommentService.GetChildren(ctx, parentID, postID, consts.CommentTypePost)
if err != nil {
return nil, err
}
@ -112,7 +112,7 @@ func (p *PostHandler) ListCommentTree(ctx *gin.Context) (interface{}, error) {
commentQuery.PageSize = pageSize
commentQuery.ParentID = util.Int32Ptr(0)
allComments, err := p.PostCommentService.GetByContentID(ctx, postID, commentQuery.Sort)
allComments, err := p.PostCommentService.GetByContentID(ctx, postID, consts.CommentTypePost, commentQuery.Sort)
if err != nil {
return nil, err
}

@ -77,11 +77,11 @@ func (j *SheetHandler) ListChildren(ctx *gin.Context) (interface{}, error) {
if err != nil {
return nil, err
}
parentID, err := util.ParamInt64(ctx, "parentID")
parentID, err := util.ParamInt32(ctx, "parentID")
if err != nil {
return nil, err
}
children, err := j.SheetCommentService.GetChildren(ctx, parentID, sheetID)
children, err := j.SheetCommentService.GetChildren(ctx, parentID, sheetID, consts.CommentTypeSheet)
if err != nil {
return nil, err
}
@ -112,7 +112,7 @@ func (p *SheetHandler) ListCommentTree(ctx *gin.Context) (interface{}, error) {
commentQuery.PageSize = pageSize
commentQuery.ParentID = util.Int32Ptr(0)
allComments, err := p.SheetCommentService.GetByContentID(ctx, sheetID, commentQuery.Sort)
allComments, err := p.SheetCommentService.GetByContentID(ctx, sheetID, consts.CommentTypeSheet, commentQuery.Sort)
if err != nil {
return nil, err
}

@ -14,5 +14,6 @@ func init() {
NewLinkHandler,
NewPhotoHandler,
NewJournalHandler,
NewSearchHandler,
)
}

@ -5,6 +5,7 @@ import (
"strings"
"github.com/go-sonic/sonic/consts"
"github.com/go-sonic/sonic/handler/content/authentication"
"github.com/go-sonic/sonic/model/entity"
"github.com/go-sonic/sonic/service"
"github.com/go-sonic/sonic/service/assembler"
@ -19,42 +20,46 @@ func NewSheetModel(optionService service.OptionService,
metaService service.MetaService,
sheetAssembler assembler.SheetAssembler,
sheetService service.SheetService,
postAuthentication *authentication.PostAuthentication,
) *SheetModel {
return &SheetModel{
OptionService: optionService,
ThemeService: themeService,
PostTagService: postTagService,
TagService: tagService,
MetaService: metaService,
SheetAssembler: sheetAssembler,
SheetService: sheetService,
OptionService: optionService,
ThemeService: themeService,
PostTagService: postTagService,
TagService: tagService,
MetaService: metaService,
SheetAssembler: sheetAssembler,
SheetService: sheetService,
PostAuthentication: postAuthentication,
}
}
type SheetModel struct {
SheetService service.SheetService
OptionService service.OptionService
ThemeService service.ThemeService
PostTagService service.PostTagService
TagService service.TagService
MetaService service.MetaService
SheetAssembler assembler.SheetAssembler
SheetService service.SheetService
OptionService service.OptionService
ThemeService service.ThemeService
PostTagService service.PostTagService
TagService service.TagService
MetaService service.MetaService
SheetAssembler assembler.SheetAssembler
PostAuthentication *authentication.PostAuthentication
}
func (s *SheetModel) Content(ctx context.Context, sheet *entity.Post, model template.Model) (string, error) {
func (s *SheetModel) Content(ctx context.Context, sheet *entity.Post, token string, model template.Model) (string, error) {
if sheet == nil {
return "", xerr.WithStatus(nil, int(xerr.StatusBadRequest)).WithMsg("查询不到文章信息")
}
if sheet.Status == consts.PostStatusRecycle || sheet.Status == consts.PostStatusDraft {
return "", xerr.WithStatus(nil, xerr.StatusNotFound).WithMsg("查询不到文章信息")
} else if sheet.Status == consts.PostStatusIntimate {
// TODO
model["slug"] = sheet.Slug
model["type"] = consts.EncryptTypePost.Name()
if exist, err := s.ThemeService.TemplateExist(ctx, "post_password.tmpl"); err == nil && exist {
return s.ThemeService.Render(ctx, "post_password")
if isAuthenticated, err := s.PostAuthentication.IsAuthenticated(ctx, token, sheet.ID); err != nil || !isAuthenticated {
model["slug"] = sheet.Slug
model["type"] = consts.EncryptTypePost.Name()
if exist, err := s.ThemeService.TemplateExist(ctx, "post_password.tmpl"); err == nil && exist {
return s.ThemeService.Render(ctx, "post_password")
}
return "common/template/post_password", nil
}
return "common/template/post_password", nil
}
sheetVO, err := s.SheetAssembler.ConvertToDetailVO(ctx, sheet)

@ -0,0 +1,90 @@
package content
import (
"html"
"github.com/gin-gonic/gin"
"github.com/go-sonic/sonic/consts"
"github.com/go-sonic/sonic/handler/binding"
"github.com/go-sonic/sonic/model/dto"
"github.com/go-sonic/sonic/model/param"
"github.com/go-sonic/sonic/model/property"
"github.com/go-sonic/sonic/service"
"github.com/go-sonic/sonic/service/assembler"
"github.com/go-sonic/sonic/template"
"github.com/go-sonic/sonic/util"
"github.com/go-sonic/sonic/util/xerr"
)
type SearchHandler struct {
PostAssembler assembler.PostAssembler
PostService service.PostService
OptionService service.OptionService
ThemeService service.ThemeService
}
func NewSearchHandler(
postAssembler assembler.PostAssembler,
postService service.PostService,
optionService service.OptionService,
themeService service.ThemeService,
) *SearchHandler {
return &SearchHandler{
PostAssembler: postAssembler,
PostService: postService,
OptionService: optionService,
ThemeService: themeService,
}
}
func (s *SearchHandler) Search(ctx *gin.Context, model template.Model) (string, error) {
return s.search(ctx, 0, model)
}
func (s *SearchHandler) PageSearch(ctx *gin.Context, model template.Model) (string, error) {
page, err := util.ParamInt32(ctx, "page")
if err != nil {
return "", err
}
return s.search(ctx, int(page)-1, model)
}
func (s *SearchHandler) search(ctx *gin.Context, pageNum int, model template.Model) (string, error) {
keyword, err := util.MustGetQueryString(ctx, "keyword")
if err != nil {
return "", err
}
sort := param.Sort{}
err = ctx.ShouldBindWith(&sort, binding.CustomFormBinding)
if err != nil {
return "", xerr.WithStatus(err, xerr.StatusBadRequest).WithMsg("Parameter error")
}
if len(sort.Fields) == 0 {
sort = s.OptionService.GetPostSort(ctx)
}
defaultPageSize := s.OptionService.GetIndexPageSize(ctx)
page := param.Page{
PageNum: pageNum,
PageSize: defaultPageSize,
}
postQuery := param.PostQuery{
Page: page,
Sort: &sort,
Keyword: &keyword,
Statuses: []*consts.PostStatus{consts.PostStatusPublished.Ptr()},
}
posts, total, err := s.PostService.Page(ctx, postQuery)
if err != nil {
return "", err
}
postVOs, err := s.PostAssembler.ConvertToListVO(ctx, posts)
if err != nil {
return "", err
}
model["is_search"] = true
model["keyword"] = html.EscapeString(keyword)
model["posts"] = dto.NewPage(postVOs, total, page)
model["meta_keywords"] = s.OptionService.GetOrByDefault(ctx, property.SeoKeywords)
model["meta_description"] = s.OptionService.GetOrByDefault(ctx, property.SeoDescription)
return s.ThemeService.Render(ctx, "search")
}

@ -36,5 +36,6 @@ func (s *SheetHandler) SheetBySlug(ctx *gin.Context, model template.Model) (stri
if err != nil {
return "", err
}
return s.SheetModel.Content(ctx, sheet, model)
token, _ := ctx.Cookie("authentication")
return s.SheetModel.Content(ctx, sheet, token, model)
}

@ -199,7 +199,7 @@ func (s *Server) RegisterRouters() {
linkRouter.GET("/teams", s.wrapHandler(s.LinkHandler.ListLinkTeams))
}
{
menuRouter := authRouter.Group("/menu")
menuRouter := authRouter.Group("/menus")
menuRouter.GET("", s.wrapHandler(s.MenuHandler.ListMenus))
menuRouter.GET("/tree_view", s.wrapHandler(s.MenuHandler.ListMenusAsTree))
menuRouter.GET("/team/tree_view", s.wrapHandler(s.MenuHandler.ListMenusAsTreeByTeam))
@ -300,6 +300,8 @@ func (s *Server) RegisterRouters() {
contentRouter.GET("/install", s.ViewHandler.Install)
contentRouter.GET("/logo", s.wrapHandler(s.ViewHandler.Logo))
contentRouter.GET("/favicon", s.wrapHandler(s.ViewHandler.Favicon))
contentRouter.GET("/search", s.wrapHTMLHandler(s.ContentSearchHandler.Search))
contentRouter.GET("/search/page/:page", s.wrapHTMLHandler(s.ContentSearchHandler.PageSearch))
err := s.registerDynamicRouters(contentRouter)
if err != nil {
s.logger.DPanic("regiterDynamicRouters err", zap.Error(err))

@ -66,6 +66,7 @@ type Server struct {
ContentLinkHandler *content.LinkHandler
ContentPhotoHandler *content.PhotoHandler
ContentJournalHandler *content.JournalHandler
ContentSearchHandler *content.SearchHandler
ContentAPIArchiveHandler *api.ArchiveHandler
ContentAPICategoryHandler *api.CategoryHandler
ContentAPIJournalHandler *api.JournalHandler
@ -118,6 +119,7 @@ type ServerParams struct {
ContentLinkHandler *content.LinkHandler
ContentPhotoHandler *content.PhotoHandler
ContentJournalHandler *content.JournalHandler
ContentSearchHandler *content.SearchHandler
ContentAPIArchiveHandler *api.ArchiveHandler
ContentAPICategoryHandler *api.CategoryHandler
ContentAPIJournalHandler *api.JournalHandler
@ -187,6 +189,7 @@ func NewServer(param ServerParams, lifecycle fx.Lifecycle) *Server {
ContentAPIPostHandler: param.ContentAPIPostHandler,
ContentAPISheetHandler: param.ContentAPISheetHandler,
ContentAPIOptionHander: param.ContentAPIOptionHander,
ContentSearchHandler: param.ContentSearchHandler,
}
lifecycle.Append(fx.Hook{
OnStop: httpServer.Shutdown,

@ -3,7 +3,7 @@ package dto
import "github.com/go-sonic/sonic/consts"
type Comment struct {
ID int64 `json:"id"`
ID int32 `json:"id"`
Author string `json:"author"`
Email string `json:"email"`
IpAddress string `json:"ipAddress"`
@ -12,7 +12,7 @@ type Comment struct {
Content string `json:"content"`
Status consts.CommentStatus `json:"status"`
UserAgent string `json:"userAgent"`
ParentID int64 `json:"parentId"`
ParentID int32 `json:"parentId"`
IsAdmin bool `json:"isAdmin"`
AllowNotification bool `json:"allowNotification"`
CreateTime int64 `json:"createTime"`

@ -8,7 +8,7 @@ type Journal struct {
Content string `json:"content"`
Likes int64 `json:"likes"`
CreateTime int64 `json:"createTime"`
JournalType consts.JournalType `json:"journalType"`
JournalType consts.JournalType `json:"type"`
}
type JournalWithComment struct {

@ -1,7 +1,7 @@
package dto
type Meta struct {
ID int64 `json:"id"`
ID int32 `json:"id"`
PostID int32 `json:"postId"`
Key string `json:"key"`
Value string `json:"value"`

@ -25,7 +25,7 @@ type Attachment struct {
Size int64 `gorm:"column:size;type:bigint;not null" json:"size"`
Suffix string `gorm:"column:suffix;type:varchar(50);not null" json:"suffix"`
ThumbPath string `gorm:"column:thumb_path;type:varchar(1023);not null" json:"thumb_path"`
Type consts.AttachmentType `gorm:"column:type;type:int;not null" json:"type"`
Type consts.AttachmentType `gorm:"column:type;type:bigint;not null" json:"type"`
Width int32 `gorm:"column:width;type:int;not null" json:"width"`
}

@ -18,13 +18,13 @@ type Category struct {
CreateTime time.Time `gorm:"column:create_time;type:datetime;not null" json:"create_time"`
UpdateTime *time.Time `gorm:"column:update_time;type:datetime" json:"update_time"`
Description string `gorm:"column:description;type:varchar(100);not null" json:"description"`
Type consts.CategoryType `gorm:"column:type;type:tinyint;not null" json:"type"`
Name string `gorm:"column:name;type:varchar(255);not null;index:category_name,priority:1" json:"name"`
ParentID int32 `gorm:"column:parent_id;type:int;not null;index:category_parent_id,priority:1" json:"parent_id"`
Password string `gorm:"column:password;type:varchar(255);not null" json:"password"`
Slug string `gorm:"column:slug;type:varchar(255);not null;uniqueIndex:uniq_category_slug,priority:1" json:"slug"`
Thumbnail string `gorm:"column:thumbnail;type:varchar(1023);not null" json:"thumbnail"`
Priority int32 `gorm:"column:priority;type:int;not null" json:"priority"`
Type consts.CategoryType `gorm:"column:type;type:int;not null" json:"type"`
}
// TableName Category's table name

@ -14,8 +14,8 @@ const TableNameComment = "comment"
// Comment mapped from table <comment>
type Comment struct {
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
Type consts.CommentType `gorm:"column:type;type:int;not null;index:comment_type_status,priority:1" json:"type"`
ID int32 `gorm:"column:id;type:int;primaryKey;autoIncrement:true" json:"id"`
Type consts.CommentType `gorm:"column:type;type:bigint;not null;index:comment_type_status,priority:1" json:"type"`
CreateTime time.Time `gorm:"column:create_time;type:datetime;not null" json:"create_time"`
UpdateTime *time.Time `gorm:"column:update_time;type:datetime" json:"update_time"`
AllowNotification bool `gorm:"column:allow_notification;type:tinyint(1);not null;default:1" json:"allow_notification"`
@ -26,9 +26,9 @@ type Comment struct {
GravatarMd5 string `gorm:"column:gravatar_md5;type:varchar(127);not null" json:"gravatar_md5"`
IPAddress string `gorm:"column:ip_address;type:varchar(127);not null" json:"ip_address"`
IsAdmin bool `gorm:"column:is_admin;type:tinyint(1);not null" json:"is_admin"`
ParentID int64 `gorm:"column:parent_id;type:bigint;not null;index:comment_parent_id,priority:1" json:"parent_id"`
ParentID int32 `gorm:"column:parent_id;type:int;not null;index:comment_parent_id,priority:1" json:"parent_id"`
PostID int32 `gorm:"column:post_id;type:int;not null;index:comment_post_id,priority:1" json:"post_id"`
Status consts.CommentStatus `gorm:"column:status;type:int;not null;index:comment_type_status,priority:2;default:1" json:"status"`
Status consts.CommentStatus `gorm:"column:status;type:bigint;not null;index:comment_type_status,priority:2;default:1" json:"status"`
TopPriority int32 `gorm:"column:top_priority;type:int;not null" json:"top_priority"`
UserAgent string `gorm:"column:user_agent;type:varchar(511);not null" json:"user_agent"`
}

@ -12,7 +12,7 @@ const TableNameCommentBlack = "comment_black"
// CommentBlack mapped from table <comment_black>
type CommentBlack struct {
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
ID int32 `gorm:"column:id;type:int;primaryKey;autoIncrement:true" json:"id"`
CreateTime time.Time `gorm:"column:create_time;type:datetime;not null" json:"create_time"`
UpdateTime *time.Time `gorm:"column:update_time;type:datetime" json:"update_time"`
BanTime time.Time `gorm:"column:ban_time;type:datetime;not null" json:"ban_time"`

@ -20,7 +20,7 @@ type Journal struct {
Content string `gorm:"column:content;type:text;not null" json:"content"`
Likes int64 `gorm:"column:likes;type:bigint;not null" json:"likes"`
SourceContent string `gorm:"column:source_content;type:longtext;not null" json:"source_content"`
Type consts.JournalType `gorm:"column:type;type:int;not null" json:"type"`
Type consts.JournalType `gorm:"column:type;type:bigint;not null" json:"type"`
}
// TableName Journal's table name

@ -20,7 +20,7 @@ type Log struct {
Content string `gorm:"column:content;type:varchar(1023);not null" json:"content"`
IPAddress string `gorm:"column:ip_address;type:varchar(127);not null" json:"ip_address"`
LogKey string `gorm:"column:log_key;type:varchar(1023);not null" json:"log_key"`
Type consts.LogType `gorm:"column:type;type:int;not null" json:"type"`
Type consts.LogType `gorm:"column:type;type:bigint;not null" json:"type"`
}
// TableName Log's table name

@ -14,8 +14,8 @@ const TableNameMeta = "meta"
// Meta mapped from table <meta>
type Meta struct {
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
Type consts.MetaType `gorm:"column:type;type:int;not null" json:"type"`
ID int32 `gorm:"column:id;type:int;primaryKey;autoIncrement:true" json:"id"`
Type consts.MetaType `gorm:"column:type;type:bigint;not null" json:"type"`
CreateTime time.Time `gorm:"column:create_time;type:datetime;not null" json:"create_time"`
UpdateTime *time.Time `gorm:"column:update_time;type:datetime" json:"update_time"`
MetaKey string `gorm:"column:meta_key;type:varchar(255);not null" json:"meta_key"`

@ -18,7 +18,7 @@ type Option struct {
CreateTime time.Time `gorm:"column:create_time;type:datetime;not null" json:"create_time"`
UpdateTime *time.Time `gorm:"column:update_time;type:datetime" json:"update_time"`
OptionKey string `gorm:"column:option_key;type:varchar(100);not null" json:"option_key"`
Type consts.OptionType `gorm:"column:type;type:int;not null" json:"type"`
Type consts.OptionType `gorm:"column:type;type:bigint;not null" json:"type"`
OptionValue string `gorm:"column:option_value;type:longtext;not null" json:"option_value"`
}

@ -15,18 +15,20 @@ const TableNamePost = "post"
// Post mapped from table <post>
type Post struct {
ID int32 `gorm:"column:id;type:int;primaryKey;autoIncrement:true" json:"id"`
Type consts.PostType `gorm:"column:type;type:int;not null;index:post_type_status,priority:1" json:"type"`
Type consts.PostType `gorm:"column:type;type:bigint;not null;index:post_type_status,priority:1" json:"type"`
CreateTime time.Time `gorm:"column:create_time;type:datetime;not null;index:post_create_time,priority:1" json:"create_time"`
UpdateTime *time.Time `gorm:"column:update_time;type:datetime" json:"update_time"`
DisallowComment bool `gorm:"column:disallow_comment;type:tinyint(1);not null" json:"disallow_comment"`
EditTime *time.Time `gorm:"column:edit_time;type:datetime" json:"edit_time"`
EditorType consts.EditorType `gorm:"column:editor_type;type:int;not null" json:"editor_type"`
EditorType consts.EditorType `gorm:"column:editor_type;type:bigint;not null" json:"editor_type"`
FormatContent string `gorm:"column:format_content;type:longtext;not null" json:"format_content"`
Likes int64 `gorm:"column:likes;type:bigint;not null" json:"likes"`
MetaDescription string `gorm:"column:meta_description;type:varchar(1023);not null" json:"meta_description"`
MetaKeywords string `gorm:"column:meta_keywords;type:varchar(511);not null" json:"meta_keywords"`
OriginalContent string `gorm:"column:original_content;type:longtext;not null" json:"original_content"`
Password string `gorm:"column:password;type:varchar(255);not null" json:"password"`
Slug string `gorm:"column:slug;type:varchar(255);not null;uniqueIndex:uniq_post_slug,priority:1" json:"slug"`
Status consts.PostStatus `gorm:"column:status;type:int;not null;index:post_type_status,priority:2;default:1" json:"status"`
Status consts.PostStatus `gorm:"column:status;type:bigint;not null;index:post_type_status,priority:2;default:1" json:"status"`
Summary string `gorm:"column:summary;type:longtext;not null" json:"summary"`
Template string `gorm:"column:template;type:varchar(255);not null" json:"template"`
Thumbnail string `gorm:"column:thumbnail;type:varchar(1023);not null" json:"thumbnail"`
@ -34,9 +36,6 @@ type Post struct {
TopPriority int32 `gorm:"column:top_priority;type:int;not null" json:"top_priority"`
Visits int64 `gorm:"column:visits;type:bigint;not null" json:"visits"`
WordCount int64 `gorm:"column:word_count;type:bigint;not null" json:"word_count"`
Version int32 `gorm:"column:version;type:int;not null;default:1" json:"version"`
FormatContent string `gorm:"column:format_content;type:longtext;not null" json:"format_content"`
OriginalContent string `gorm:"column:original_content;type:longtext;not null" json:"original_content"`
}
// TableName Post's table name

@ -22,7 +22,7 @@ type User struct {
Email string `gorm:"column:email;type:varchar(127);not null" json:"email"`
ExpireTime *time.Time `gorm:"column:expire_time;type:datetime" json:"expire_time"`
MfaKey string `gorm:"column:mfa_key;type:varchar(64);not null" json:"mfa_key"`
MfaType consts.MFAType `gorm:"column:mfa_type;type:int;not null" json:"mfa_type"`
MfaType consts.MFAType `gorm:"column:mfa_type;type:bigint;not null" json:"mfa_type"`
Nickname string `gorm:"column:nickname;type:varchar(255);not null" json:"nickname"`
Password string `gorm:"column:password;type:varchar(255);not null" json:"password"`
Username string `gorm:"column:username;type:varchar(50);not null" json:"username"`

@ -17,7 +17,18 @@ type Comment struct {
AuthorURL string `json:"authorUrl" form:"authorUrl" binding:"lte=255"`
Content string `json:"content" form:"content" binding:"gte=1,lte=1023"`
PostID int32 `json:"postId" form:"postId" binding:"gte=1"`
ParentID int64 `json:"parentId" form:"parentId" binding:"gte=0"`
ParentID int32 `json:"parentId" form:"parentId" binding:"gte=0"`
AllowNotification bool `json:"allowNotification" form:"allowNotification"`
CommentType consts.CommentType `json:"-"`
}
type AdminComment struct {
Author string `json:"author" form:"author"`
Email string `json:"email" form:"email"`
AuthorURL string `json:"authorUrl" form:"authorUrl"`
Content string `json:"content" form:"content"`
PostID int32 `json:"postId" form:"postId"`
ParentID int32 `json:"parentId" form:"parentId"`
AllowNotification bool `json:"allowNotification"`
CommentType consts.CommentType `json:"-"`
}

@ -11,6 +11,6 @@ type JournalQuery struct {
type Journal struct {
SourceContent string `json:"sourceContent" form:"sourceContent" binding:"gte=1"`
Content string `json:"content" form:"content" binding:"gte=1"`
Content string `json:"content" form:"content"`
Type consts.JournalType `json:"type" form:"type"`
}

@ -40,7 +40,7 @@ var (
}
CommentInternalPluginJs = Property{
KeyValue: "comment_internal_plugin_js",
DefaultValue: "//cdn.jsdelivr.net/npm/sonic-comment@latest/dist/sonic-comment.min.js",
DefaultValue: "//cdn.jsdelivr.net/npm/halo-comment@latest/dist/halo-comment.min.js",
Kind: reflect.String,
}
CommentGravatarSource = Property{

@ -16,6 +16,6 @@ type PostDetailVO struct {
Tags []*dto.Tag `json:"tags"`
CategoryIDs []int32 `json:"categoryIds"`
Categories []*dto.CategoryDTO `json:"categories"`
MetaIDs []int64 `json:"metaIds"`
MetaIDs []int32 `json:"metaIds"`
Metas []*dto.Meta `json:"metas"`
}

@ -4,7 +4,7 @@ import "github.com/go-sonic/sonic/model/dto"
type SheetDetail struct {
dto.PostDetail
MetaIDs []int64 `json:"metaIds"`
MetaIDs []int32 `json:"metaIds"`
Metas []*dto.Meta `json:"metas"`
}

@ -0,0 +1 @@
.list-group{min-height:20px}.list-group-item{cursor:move}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 11 KiB

@ -1 +1 @@
<!doctype html><html lang="zh-cmn-Hans"><head><meta charset="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="renderer" content="webkit"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"/><meta name="robots" content="noindex,nofollow"/><meta name="generator" content="Halo 1.5.2"/><link rel="icon" href="/favicon.ico"/><title>Halo</title><style>body {height: 100%;background-color: #f5f5f5;}#loader{position:absolute;top:0;right:0;bottom:0;left:0;margin:auto;border:solid 3px #e5e5e5;border-top-color:#333;border-radius:50%;width:30px;height:30px;animation:spin .6s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}</style><script defer="defer" src="/js/chunk-vendors.a8aac3e6.js"></script><script defer="defer" src="/js/app.8eac304f.js"></script><link href="/css/chunk-vendors.b8f03799.css" rel="stylesheet"><link href="/css/app.807e04c6.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but halo admin client doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"><div id="loader"></div></div></body></html>
<!doctype html><html lang="cmn-Hans"><head><meta charset="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="renderer" content="webkit"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"/><meta name="robots" content="noindex,nofollow"/><meta name="generator" content="Halo 1.6.0"/><link rel="icon" href="/favicon.ico"/><title>Halo</title><style>body {height: 100%;background-color: #f5f5f5;}#loader{position:absolute;top:0;right:0;bottom:0;left:0;margin:auto;border:solid 3px #e5e5e5;border-top-color:#333;border-radius:50%;width:30px;height:30px;animation:spin .6s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}</style><script defer="defer" src="/js/chunk-vendors.b06eab53.js"></script><script defer="defer" src="/js/app.b866d7e3.js"></script><link href="/css/chunk-vendors.b8f03799.css" rel="stylesheet"><link href="/css/app.487935a4.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but halo admin client doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"><div id="loader"></div></div></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1 +1 @@
"use strict";(self["webpackChunkhalo_admin"]=self["webpackChunkhalo_admin"]||[]).push([[359],{79359:function(t,e,a){a.r(e),a.d(e,{default:function(){return h}});var n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("page-view",[a("a-card",{attrs:{bodyStyle:{padding:"16px"},bordered:!1}},[a("div",{staticClass:"table-operator"},[a("a-button",{attrs:{type:"danger"},on:{click:t.handleClearActionLogs}},[t._v("清空操作日志")])],1),a("div",{staticClass:"mt-4"},[a("a-table",{attrs:{columns:t.list.columns,dataSource:t.list.data,loading:t.list.loading,pagination:!1,rowKey:function(t){return t.id},scrollToFirstRowOnChange:!0},scopedSlots:t._u([{key:"type",fn:function(e){return[t._v(" "+t._s(t._f("typeConvert")(e))+" ")]}},{key:"ipAddress",fn:function(e){return[a("div",{staticClass:"blur hover:blur-none transition-all"},[t._v(t._s(e))])]}},{key:"createTime",fn:function(e){return[a("a-tooltip",{attrs:{placement:"top"}},[a("template",{slot:"title"},[t._v(" "+t._s(t._f("moment")(e))+" ")]),t._v(" "+t._s(t._f("timeAgo")(e))+" ")],2)]}}])}),a("div",{staticClass:"page-wrapper"},[a("a-pagination",{staticClass:"pagination",attrs:{current:t.pagination.page,defaultPageSize:t.pagination.size,pageSizeOptions:["10","20","50","100"],total:t.pagination.total,showLessItems:"",showSizeChanger:""},on:{change:t.handlePageChange,showSizeChange:t.handlePageSizeChange}})],1)],1)])],1)},i=[],s=a(46519),r=(a(41479),a(70315),a(71101)),o=a(18608),l=a(84707),c=[{title:"ID",dataIndex:"id"},{title:"类型",dataIndex:"type",scopedSlots:{customRender:"type"}},{title:"关键值",dataIndex:"logKey"},{title:"内容",dataIndex:"content"},{title:"IP",dataIndex:"ipAddress",scopedSlots:{customRender:"ipAddress"}},{title:"操作时间",dataIndex:"createTime",scopedSlots:{customRender:"createTime"}}],d={name:"ActionLog",components:{PageView:r.B4},data:function(){return{list:{columns:c,data:[],total:0,loading:!1,params:{page:0,size:50}}}},computed:{pagination:function(){return{page:this.list.params.page+1,size:this.list.params.size,total:this.list.total}}},created:function(){this.handleListActionLogs()},methods:{handleListActionLogs:function(){var t=this;return(0,s.Z)(regeneratorRuntime.mark((function e(){var a;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,t.list.loading=!0,e.next=4,o.Z.log.list(t.list.params);case 4:a=e.sent,t.list.data=a.data.content,t.list.total=a.data.total,e.next=12;break;case 9:e.prev=9,e.t0=e["catch"](0),t.$log.error(e.t0);case 12:return e.prev=12,t.list.loading=!1,e.finish(12);case 15:case"end":return e.stop()}}),e,null,[[0,9,12,15]])})))()},handlePageChange:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.list.params.page=t-1,this.handleListActionLogs()},handlePageSizeChange:function(t,e){this.$log.debug("Current: ".concat(t,", PageSize: ").concat(e)),this.list.params.page=0,this.list.params.size=e,this.handleListActionLogs()},handleClearActionLogs:function(){var t=this;t.$confirm({title:"提示",maskClosable:!0,content:"是否确定要清空所有操作日志?",onOk:function(){return(0,s.Z)(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,o.Z.log.clear();case 3:e.next=8;break;case 5:e.prev=5,e.t0=e["catch"](0),t.$log.error("Failed to clear action logs.",e.t0);case 8:return e.prev=8,e.next=11,t.handleListActionLogs();case 11:return e.finish(8);case 12:case"end":return e.stop()}}),e,null,[[0,5,8,12]])})))()}})}},filters:{typeConvert:function(t){var e=l.Js[t];return e?e.text:t}}},u=d,p=a(42177),g=(0,p.Z)(u,n,i,!1,null,null,null),h=g.exports}}]);
"use strict";(self["webpackChunkhalo_admin"]=self["webpackChunkhalo_admin"]||[]).push([[163],{65163:function(t,e,a){a.r(e),a.d(e,{default:function(){return h}});var n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("page-view",[a("a-card",{attrs:{bodyStyle:{padding:"16px"},bordered:!1}},[a("div",{staticClass:"table-operator"},[a("a-button",{attrs:{type:"danger"},on:{click:t.handleClearActionLogs}},[t._v("清空操作日志")])],1),a("div",{staticClass:"mt-4"},[a("a-table",{attrs:{columns:t.list.columns,dataSource:t.list.data,loading:t.list.loading,pagination:!1,rowKey:function(t){return t.id},scrollToFirstRowOnChange:!0},scopedSlots:t._u([{key:"type",fn:function(e){return[t._v(" "+t._s(t._f("typeConvert")(e))+" ")]}},{key:"ipAddress",fn:function(e){return[a("div",{staticClass:"blur hover:blur-none transition-all"},[t._v(t._s(e))])]}},{key:"createTime",fn:function(e){return[a("a-tooltip",{attrs:{placement:"top"}},[a("template",{slot:"title"},[t._v(" "+t._s(t._f("moment")(e))+" ")]),t._v(" "+t._s(t._f("timeAgo")(e))+" ")],2)]}}])}),a("div",{staticClass:"page-wrapper"},[a("a-pagination",{staticClass:"pagination",attrs:{current:t.pagination.page,defaultPageSize:t.pagination.size,pageSizeOptions:["10","20","50","100"],total:t.pagination.total,showLessItems:"",showSizeChanger:""},on:{change:t.handlePageChange,showSizeChange:t.handlePageSizeChange}})],1)],1)])],1)},i=[],s=a(54288),r=(a(41479),a(70315),a(53298)),o=a(36591),l=a(43376),c=[{title:"ID",dataIndex:"id"},{title:"类型",dataIndex:"type",scopedSlots:{customRender:"type"}},{title:"关键值",dataIndex:"logKey"},{title:"内容",dataIndex:"content"},{title:"IP",dataIndex:"ipAddress",scopedSlots:{customRender:"ipAddress"}},{title:"操作时间",dataIndex:"createTime",scopedSlots:{customRender:"createTime"}}],d={name:"ActionLog",components:{PageView:r.B4},data:function(){return{list:{columns:c,data:[],total:0,loading:!1,params:{page:0,size:50}}}},computed:{pagination:function(){return{page:this.list.params.page+1,size:this.list.params.size,total:this.list.total}}},created:function(){this.handleListActionLogs()},methods:{handleListActionLogs:function(){var t=this;return(0,s.Z)(regeneratorRuntime.mark((function e(){var a;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,t.list.loading=!0,e.next=4,o.Z.log.list(t.list.params);case 4:a=e.sent,t.list.data=a.data.content,t.list.total=a.data.total,e.next=12;break;case 9:e.prev=9,e.t0=e["catch"](0),t.$log.error(e.t0);case 12:return e.prev=12,t.list.loading=!1,e.finish(12);case 15:case"end":return e.stop()}}),e,null,[[0,9,12,15]])})))()},handlePageChange:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.list.params.page=t-1,this.handleListActionLogs()},handlePageSizeChange:function(t,e){this.$log.debug("Current: ".concat(t,", PageSize: ").concat(e)),this.list.params.page=0,this.list.params.size=e,this.handleListActionLogs()},handleClearActionLogs:function(){var t=this;t.$confirm({title:"提示",maskClosable:!0,content:"是否确定要清空所有操作日志?",onOk:function(){return(0,s.Z)(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,o.Z.log.clear();case 3:e.next=8;break;case 5:e.prev=5,e.t0=e["catch"](0),t.$log.error("Failed to clear action logs.",e.t0);case 8:return e.prev=8,e.next=11,t.handleListActionLogs();case 11:return e.finish(8);case 12:case"end":return e.stop()}}),e,null,[[0,5,8,12]])})))()}})}},filters:{typeConvert:function(t){var e=l.Js[t];return e?e.text:t}}},u=d,p=a(70739),g=(0,p.Z)(u,n,i,!1,null,null,null),h=g.exports}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
"use strict";(self["webpackChunkhalo_admin"]=self["webpackChunkhalo_admin"]||[]).push([[336],{29336:function(e,t,n){n.r(t),n.d(t,{default:function(){return y}});var o=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("page-view",[n("a-row",[n("a-col",{attrs:{span:24}},[e.options.developer_mode?n("div",{staticClass:"card-container"},[n("a-tabs",{attrs:{type:"card"},model:{value:e.activeKey,callback:function(t){e.activeKey=t},expression:"activeKey"}},e._l(e.panes,(function(t){return n("a-tab-pane",{key:t.key},[n("span",{attrs:{slot:"tab"},slot:"tab"},[n("a-icon",{attrs:{type:t.icon}}),e._v(e._s(t.title)+" ")],1),n(t.component,{tag:"component"})],1)})),1)],1):n("a-alert",{attrs:{description:"当前没有启用开发者选项,请启用之后再访问该页面!",message:"提示",showIcon:"",type:"error"}})],1)],1)],1)},i=[],a=n(22373),r=(n(31875),n(29888),n(45107),n(98906)),c=n(53298),s={components:{PageView:c.B4},data:function(){var e=[{title:"运行环境",icon:"safety",component:function(){return n.e(355).then(n.bind(n,26355))},key:"environment"},{title:"实时日志",icon:"code",component:function(){return Promise.all([n.e(788),n.e(192),n.e(164),n.e(303)]).then(n.bind(n,57303))},key:"runtimeLogs"},{title:"系统变量",icon:"table",component:function(){return n.e(719).then(n.bind(n,99719))},key:"optionsList"},{title:"静态存储",icon:"cloud",component:function(){return Promise.all([n.e(788),n.e(773)]).then(n.bind(n,47773))},key:"staticStorage"},{title:"设置",icon:"setting",component:function(){return n.e(626).then(n.bind(n,22626))},key:"settings"}];return{activeKey:e[0].key,panes:e}},computed:(0,a.Z)({},(0,r.Se)(["options"])),beforeRouteEnter:function(e,t,n){var o=e.query.activeKey;n((function(e){o&&(e.activeKey=o)}))},watch:{activeKey:function(e){if(e){var t=this.$router.history.current.path;this.$router.push({path:t,query:{activeKey:e}}).catch((function(e){return e}))}}}},u=s,l=n(70739),p=(0,l.Z)(u,o,i,!1,null,null,null),y=p.exports}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1 +0,0 @@
"use strict";(self["webpackChunkhalo_admin"]=self["webpackChunkhalo_admin"]||[]).push([[439],{68439:function(e,t,n){n.r(t),n.d(t,{default:function(){return y}});var o=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("page-view",[n("a-row",[n("a-col",{attrs:{span:24}},[e.options.developer_mode?n("div",{staticClass:"card-container"},[n("a-tabs",{attrs:{type:"card"},model:{value:e.activeKey,callback:function(t){e.activeKey=t},expression:"activeKey"}},e._l(e.panes,(function(t){return n("a-tab-pane",{key:t.key},[n("span",{attrs:{slot:"tab"},slot:"tab"},[n("a-icon",{attrs:{type:t.icon}}),e._v(e._s(t.title)+" ")],1),n(t.component,{tag:"component"})],1)})),1)],1):n("a-alert",{attrs:{description:"当前没有启用开发者选项,请启用之后再访问该页面!",message:"提示",showIcon:"",type:"error"}})],1)],1)],1)},i=[],a=n(92164),r=(n(31875),n(29888),n(45107),n(98906)),c=n(71101),s={components:{PageView:c.B4},data:function(){var e=[{title:"运行环境",icon:"safety",component:function(){return n.e(235).then(n.bind(n,2235))},key:"environment"},{title:"实时日志",icon:"code",component:function(){return Promise.all([n.e(807),n.e(192),n.e(164),n.e(793)]).then(n.bind(n,5793))},key:"runtimeLogs"},{title:"系统变量",icon:"table",component:function(){return n.e(674).then(n.bind(n,3674))},key:"optionsList"},{title:"静态存储",icon:"cloud",component:function(){return Promise.all([n.e(807),n.e(293)]).then(n.bind(n,88293))},key:"staticStorage"},{title:"设置",icon:"setting",component:function(){return n.e(728).then(n.bind(n,55988))},key:"settings"}];return{activeKey:e[0].key,panes:e}},computed:(0,a.Z)({},(0,r.Se)(["options"])),beforeRouteEnter:function(e,t,n){var o=e.query.activeKey;n((function(e){o&&(e.activeKey=o)}))},watch:{activeKey:function(e){if(e){var t=this.$router.history.current.path;this.$router.push({path:t,query:{activeKey:e}}).catch((function(e){return e}))}}}},u=s,l=n(42177),p=(0,l.Z)(u,o,i,!1,null,null,null),y=p.exports}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1 +1 @@
"use strict";(self["webpackChunkhalo_admin"]=self["webpackChunkhalo_admin"]||[]).push([[728],{55988:function(e,r,t){t.r(r),t.d(r,{default:function(){return v}});var n=function(){var e=this,r=e.$createElement,t=e._self._c||r;return t("a-form",{attrs:{wrapperCol:e.wrapperCol,layout:"vertical"}},[t("a-form-item",{attrs:{label:"开发者选项:"}},[t("a-switch",{model:{value:e.options.developer_mode,callback:function(r){e.$set(e.options,"developer_mode",r)},expression:"options.developer_mode"}})],1),t("a-form-item",[t("ReactiveButton",{attrs:{errored:e.errored,loading:e.saving,erroredText:"保存失败",loadedText:"保存成功",text:"保存",type:"primary"},on:{callback:function(r){e.errored=!1},click:e.handleSaveOptions}})],1)],1)},a=[],o=t(46519),s=t(92164),i=(t(30535),t(85018),t(70315),t(98906)),c=t(18608),l={name:"SettingsForm",data:function(){return{options:{},wrapperCol:{xl:{span:8},lg:{span:8},sm:{span:12},xs:{span:24}},saving:!1,errored:!1}},created:function(){this.handleListOptions()},methods:(0,s.Z)((0,s.Z)({},(0,i.nv)(["refreshOptionsCache"])),{},{handleListOptions:function(){var e=this;return(0,o.Z)(regeneratorRuntime.mark((function r(){var t,n;return regeneratorRuntime.wrap((function(r){while(1)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,c.Z.option.listAsMapViewByKeys(["developer_mode"]);case 3:t=r.sent,n=t.data,e.options=n,r.next=11;break;case 8:r.prev=8,r.t0=r["catch"](0),e.$log.error(r.t0);case 11:case"end":return r.stop()}}),r,null,[[0,8]])})))()},handleSaveOptions:function(){var e=this;return(0,o.Z)(regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){while(1)switch(r.prev=r.next){case 0:return r.prev=0,e.saving=!0,r.next=4,c.Z.option.saveMapView(e.options);case 4:r.next=10;break;case 6:r.prev=6,r.t0=r["catch"](0),e.errored=!1,e.$log.error(r.t0);case 10:return r.prev=10,setTimeout((function(){e.saving=!1}),400),r.next=14,e.handleListOptions();case 14:return r.next=16,e.refreshOptionsCache();case 16:if(e.options.developer_mode){r.next=19;break}return r.next=19,e.$router.replace({name:"ToolList"});case 19:return r.finish(10);case 20:case"end":return r.stop()}}),r,null,[[0,6,10,20]])})))()}})},p=l,u=t(42177),d=(0,u.Z)(p,n,a,!1,null,null,null),v=d.exports}}]);
"use strict";(self["webpackChunkhalo_admin"]=self["webpackChunkhalo_admin"]||[]).push([[626],{22626:function(e,r,t){t.r(r),t.d(r,{default:function(){return v}});var n=function(){var e=this,r=e.$createElement,t=e._self._c||r;return t("a-form",{attrs:{wrapperCol:e.wrapperCol,layout:"vertical"}},[t("a-form-item",{attrs:{label:"开发者选项:"}},[t("a-switch",{model:{value:e.options.developer_mode,callback:function(r){e.$set(e.options,"developer_mode",r)},expression:"options.developer_mode"}})],1),t("a-form-item",[t("ReactiveButton",{attrs:{errored:e.errored,loading:e.saving,erroredText:"保存失败",loadedText:"保存成功",text:"保存",type:"primary"},on:{callback:function(r){e.errored=!1},click:e.handleSaveOptions}})],1)],1)},a=[],o=t(54288),s=t(22373),i=(t(30535),t(85018),t(70315),t(98906)),c=t(36591),l={name:"SettingsForm",data:function(){return{options:{},wrapperCol:{xl:{span:8},lg:{span:8},sm:{span:12},xs:{span:24}},saving:!1,errored:!1}},created:function(){this.handleListOptions()},methods:(0,s.Z)((0,s.Z)({},(0,i.nv)(["refreshOptionsCache"])),{},{handleListOptions:function(){var e=this;return(0,o.Z)(regeneratorRuntime.mark((function r(){var t,n;return regeneratorRuntime.wrap((function(r){while(1)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,c.Z.option.listAsMapViewByKeys(["developer_mode"]);case 3:t=r.sent,n=t.data,e.options=n,r.next=11;break;case 8:r.prev=8,r.t0=r["catch"](0),e.$log.error(r.t0);case 11:case"end":return r.stop()}}),r,null,[[0,8]])})))()},handleSaveOptions:function(){var e=this;return(0,o.Z)(regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){while(1)switch(r.prev=r.next){case 0:return r.prev=0,e.saving=!0,r.next=4,c.Z.option.saveMapView(e.options);case 4:r.next=10;break;case 6:r.prev=6,r.t0=r["catch"](0),e.errored=!1,e.$log.error(r.t0);case 10:return r.prev=10,setTimeout((function(){e.saving=!1}),400),r.next=14,e.handleListOptions();case 14:return r.next=16,e.refreshOptionsCache();case 16:if(e.options.developer_mode){r.next=19;break}return r.next=19,e.$router.replace({name:"ToolList"});case 19:return r.finish(10);case 20:case"end":return r.stop()}}),r,null,[[0,6,10,20]])})))()}})},p=l,u=t(70739),d=(0,u.Z)(p,n,a,!1,null,null,null),v=d.exports}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save