diff --git a/go.mod b/go.mod index 599271d..4c83ff9 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,6 @@ require ( github.com/mattn/go-isatty v0.0.19 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/stretchr/testify v1.8.4 // indirect github.com/syndtr/goleveldb v1.0.0 // indirect go.uber.org/atomic v1.6.0 // indirect go.uber.org/multierr v1.5.0 // indirect diff --git a/src/dao/user_tag_dao.go b/src/dao/user_tag_dao.go index cf79464..9646785 100644 --- a/src/dao/user_tag_dao.go +++ b/src/dao/user_tag_dao.go @@ -11,4 +11,5 @@ type UserTagDao interface { UserTagAllByAscByPage(page, limit int) (*[]model.UserTag, int64, error) UserTagUpdate(id interface{}, userTag *model.UserTag, forceColumns ...string) (int64, error) UserTagDeleteBySession(session *xorm.Session, tagID interface{}) (int64, error) + UserTagInsert(userTag *model.UserTag) (int, error) } diff --git a/src/implement/user_tag_implement.go b/src/implement/user_tag_implement.go index 5a5aeb3..d2c7a47 100644 --- a/src/implement/user_tag_implement.go +++ b/src/implement/user_tag_implement.go @@ -57,3 +57,11 @@ func (u UserTagDb) UserTagDeleteBySession(session *xorm.Session, tagID interface return session.Where("id = ?", tagID).Delete(model.UserTag{}) } } + +func (u UserTagDb) UserTagInsert(userTag *model.UserTag) (int, error) { + _, err := u.Db.InsertOne(userTag) + if err != nil { + return 0, zhios_order_relate_logx.Error(err) + } + return userTag.Id, nil +} diff --git a/src/model/user_tag.go b/src/model/user_tag.go index c656652..0ed2f85 100644 --- a/src/model/user_tag.go +++ b/src/model/user_tag.go @@ -1,14 +1,10 @@ package model -import ( - "time" -) - type UserTag struct { - Id int `json:"id" xorm:"not null pk autoincr INT(11)"` - TagName string `json:"tag_name" xorm:"not null default '' comment('tag名') index VARCHAR(16)"` - Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(80)"` - IsPunish int `json:"is_punish" xorm:"not null default 0 comment('是否为处罚标签(0:否 1:是)') TINYINT(1)"` - CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` - UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + TagName string `json:"tag_name" xorm:"not null default '' comment('tag名') index VARCHAR(16)"` + Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(80)"` + IsPunish int `json:"is_punish" xorm:"not null default 0 comment('是否为处罚标签(0:否 1:是)') TINYINT(1)"` + CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` }