From 927be7bd7619fe5a6cd7a548c8d777906fcdd3a6 Mon Sep 17 00:00:00 2001 From: textworld Date: Thu, 7 Dec 2023 08:38:46 +0800 Subject: [PATCH] feat: no application_password --- cmd/generate/generate.go | 2 +- dal/scrap_page.gen.go | 8 ++++---- handler/admin/scrap_page.go | 14 +++++++++++++ model/entity/attachment.gen.go | 2 +- model/entity/category.gen.go | 2 +- model/entity/comment.gen.go | 2 +- model/entity/journal.gen.go | 2 +- model/entity/link.gen.go | 2 +- model/entity/log.gen.go | 2 +- model/entity/menu.gen.go | 2 +- model/entity/meta.gen.go | 2 +- model/entity/option.gen.go | 2 +- model/entity/post.gen.go | 2 +- model/entity/scrap_page.gen.go | 12 +++++------ model/entity/tag.gen.go | 2 +- model/entity/theme_setting.gen.go | 2 +- model/entity/user.gen.go | 2 +- model/param/scrap_page.go | 14 ++++++------- scripts/table.sql | 16 +++++++++++++++ service/impl/scrap.go | 34 +++++++++++++++++++++++-------- service/scrap.go | 7 ++++++- 21 files changed, 93 insertions(+), 40 deletions(-) diff --git a/cmd/generate/generate.go b/cmd/generate/generate.go index fde6584..8a03457 100644 --- a/cmd/generate/generate.go +++ b/cmd/generate/generate.go @@ -56,7 +56,7 @@ func main() { g.GenerateModel("tag"), g.GenerateModel("theme_setting"), g.GenerateModel("user", gen.FieldType("mfa_type", "consts.MFAType")), - //g.GenerateModel("application_password"), + g.GenerateModel("application_password"), g.GenerateModel("scrap_page"), ) diff --git a/dal/scrap_page.gen.go b/dal/scrap_page.gen.go index 930583c..43d312f 100644 --- a/dal/scrap_page.gen.go +++ b/dal/scrap_page.gen.go @@ -35,7 +35,7 @@ func newScrapPage(db *gorm.DB, opts ...gen.DOOption) scrapPage { _scrapPage.Summary = field.NewString(tableName, "summary") _scrapPage.CreateAt = field.NewInt64(tableName, "create_at") _scrapPage.Domain = field.NewString(tableName, "domain") - _scrapPage.Resource = field.NewString(tableName, "resource") + _scrapPage.OutLink = field.NewString(tableName, "out_link") _scrapPage.fillFieldMap() @@ -54,7 +54,7 @@ type scrapPage struct { Summary field.String CreateAt field.Int64 Domain field.String - Resource field.String + OutLink field.String fieldMap map[string]field.Expr } @@ -79,7 +79,7 @@ func (s *scrapPage) updateTableName(table string) *scrapPage { s.Summary = field.NewString(table, "summary") s.CreateAt = field.NewInt64(table, "create_at") s.Domain = field.NewString(table, "domain") - s.Resource = field.NewString(table, "resource") + s.OutLink = field.NewString(table, "out_link") s.fillFieldMap() @@ -115,7 +115,7 @@ func (s *scrapPage) fillFieldMap() { s.fieldMap["summary"] = s.Summary s.fieldMap["create_at"] = s.CreateAt s.fieldMap["domain"] = s.Domain - s.fieldMap["resource"] = s.Resource + s.fieldMap["out_link"] = s.OutLink } func (s scrapPage) clone(db *gorm.DB) scrapPage { diff --git a/handler/admin/scrap_page.go b/handler/admin/scrap_page.go index 29687d3..add1ebf 100644 --- a/handler/admin/scrap_page.go +++ b/handler/admin/scrap_page.go @@ -3,7 +3,9 @@ package admin import ( "github.com/gin-gonic/gin" + "github.com/go-sonic/sonic/model/param" "github.com/go-sonic/sonic/service" + "github.com/go-sonic/sonic/util/xerr" ) type ScrapPageHandler struct { @@ -21,4 +23,16 @@ func (handler *ScrapPageHandler) QueryMd5List(ctx *gin.Context) (interface{}, er } func (handler *ScrapPageHandler) Create(ctx *gin.Context) (interface{}, error) { + scrapPageParam := param.ScrapPage{} + err := ctx.ShouldBindJSON(&scrapPageParam) + if err != nil { + return nil, xerr.BadParam.Wrap(err) + } + + err = handler.ScrapService.Create(ctx, &scrapPageParam) + if err != nil { + return nil, err + } + + return true, nil } diff --git a/model/entity/attachment.gen.go b/model/entity/attachment.gen.go index d102197..751473d 100644 --- a/model/entity/attachment.gen.go +++ b/model/entity/attachment.gen.go @@ -14,7 +14,7 @@ const TableNameAttachment = "attachment" // Attachment mapped from table type Attachment struct { - ID *int32 `gorm:"column:id;type:integer;primaryKey" json:"id"` + ID int32 `gorm:"column:id;type:integer;primaryKey" 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"` FileKey string `gorm:"column:file_key;type:varchar(2047);not null" json:"file_key"` diff --git a/model/entity/category.gen.go b/model/entity/category.gen.go index 2cbc2fa..6481adc 100644 --- a/model/entity/category.gen.go +++ b/model/entity/category.gen.go @@ -14,7 +14,7 @@ const TableNameCategory = "category" // Category mapped from table type Category struct { - ID *int32 `gorm:"column:id;type:integer;primaryKey" json:"id"` + ID int32 `gorm:"column:id;type:integer;primaryKey" 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"` Description string `gorm:"column:description;type:varchar(100);not null" json:"description"` diff --git a/model/entity/comment.gen.go b/model/entity/comment.gen.go index 6a5199e..527f745 100644 --- a/model/entity/comment.gen.go +++ b/model/entity/comment.gen.go @@ -14,7 +14,7 @@ const TableNameComment = "comment" // Comment mapped from table type Comment struct { - ID *int32 `gorm:"column:id;type:integer;primaryKey" json:"id"` + ID int32 `gorm:"column:id;type:integer;primaryKey" json:"id"` Type consts.CommentType `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"` diff --git a/model/entity/journal.gen.go b/model/entity/journal.gen.go index 78a666a..76388f2 100644 --- a/model/entity/journal.gen.go +++ b/model/entity/journal.gen.go @@ -14,7 +14,7 @@ const TableNameJournal = "journal" // Journal mapped from table type Journal struct { - ID *int32 `gorm:"column:id;type:integer;primaryKey" json:"id"` + ID int32 `gorm:"column:id;type:integer;primaryKey" 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"` Content string `gorm:"column:content;type:text;not null" json:"content"` diff --git a/model/entity/link.gen.go b/model/entity/link.gen.go index 4953159..3f93f03 100644 --- a/model/entity/link.gen.go +++ b/model/entity/link.gen.go @@ -12,7 +12,7 @@ const TableNameLink = "link" // Link mapped from table type Link struct { - ID *int32 `gorm:"column:id;type:integer;primaryKey" json:"id"` + ID int32 `gorm:"column:id;type:integer;primaryKey" 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"` Description string `gorm:"column:description;type:varchar(255);not null" json:"description"` diff --git a/model/entity/log.gen.go b/model/entity/log.gen.go index 22cb2c9..ac5f420 100644 --- a/model/entity/log.gen.go +++ b/model/entity/log.gen.go @@ -14,7 +14,7 @@ const TableNameLog = "log" // Log mapped from table type Log struct { - ID *int64 `gorm:"column:id;type:bigint;primaryKey" json:"id"` + ID int64 `gorm:"column:id;type:bigint;primaryKey" 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"` Content string `gorm:"column:content;type:varchar(1023);not null" json:"content"` diff --git a/model/entity/menu.gen.go b/model/entity/menu.gen.go index 29300ec..19f37af 100644 --- a/model/entity/menu.gen.go +++ b/model/entity/menu.gen.go @@ -12,7 +12,7 @@ const TableNameMenu = "menu" // Menu mapped from table type Menu struct { - ID *int32 `gorm:"column:id;type:integer;primaryKey" json:"id"` + ID int32 `gorm:"column:id;type:integer;primaryKey" 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"` Icon string `gorm:"column:icon;type:varchar(50);not null" json:"icon"` diff --git a/model/entity/meta.gen.go b/model/entity/meta.gen.go index 7515742..57dbadc 100644 --- a/model/entity/meta.gen.go +++ b/model/entity/meta.gen.go @@ -14,7 +14,7 @@ const TableNameMeta = "meta" // Meta mapped from table type Meta struct { - ID *int32 `gorm:"column:id;type:integer;primaryKey" json:"id"` + ID int32 `gorm:"column:id;type:integer;primaryKey" 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"` diff --git a/model/entity/option.gen.go b/model/entity/option.gen.go index 3a7678f..42cc6a6 100644 --- a/model/entity/option.gen.go +++ b/model/entity/option.gen.go @@ -14,7 +14,7 @@ const TableNameOption = "option" // Option mapped from table