Compare commits

..

No commits in common. "29b5006f1b2f67dd24d6646d7ca1876f8d4bdff4" and "f8c0e3991d1e4b7c827bc505af5a2e61a06da870" have entirely different histories.

4 changed files with 40 additions and 43 deletions

View File

@ -8,6 +8,7 @@ import (
"time" "time"
"github.com/go-sql-driver/mysql" "github.com/go-sql-driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm/clause" "gorm.io/gorm/clause"
) )
@ -34,8 +35,10 @@ func (governanceDao) List(req *governance.ListReq) (data []model.Governance, tot
func (governanceDao) Delete(req *governance.DeleteReq) (err error) { func (governanceDao) Delete(req *governance.DeleteReq) (err error) {
return db.DocDB.Delete(&model.Governance{ return db.DocDB.Delete(&model.Governance{
ID: uint(req.Id), Model: gorm.Model{
UpdatedAt: time.Now(), ID: uint(req.Id),
UpdatedAt: time.Now(),
},
}).Error }).Error
} }
@ -48,7 +51,9 @@ func (governanceDao) Edit(req *governance.EditReq) (err error) {
AttachmentName: req.AttachmentName, AttachmentName: req.AttachmentName,
Operator: req.Operator, Operator: req.Operator,
OperatorID: int(req.OperatorId), OperatorID: int(req.OperatorId),
UpdatedAt: time.Now(), Model: gorm.Model{
UpdatedAt: time.Now(),
},
}).Error }).Error
if err != nil { if err != nil {
var mysqlErr *mysql.MySQLError var mysqlErr *mysql.MySQLError

View File

@ -92,8 +92,10 @@ func (pressReleasesDao) Edit(req *pressreleases.EditReq) (err error) {
OperatorID: uint(req.OperatorId), OperatorID: uint(req.OperatorId),
Content: req.Content, Content: req.Content,
Display: int(req.Display), Display: int(req.Display),
CreatedAt: time.UnixMilli(int64(req.CreatedAt)), Model: gorm.Model{
UpdatedAt: time.Now(), CreatedAt: time.UnixMilli(int64(req.CreatedAt)),
UpdatedAt: time.Now(),
},
}).Error }).Error
if err != nil { if err != nil {
var mysqlErr *mysql.MySQLError var mysqlErr *mysql.MySQLError
@ -127,8 +129,10 @@ func (pressReleasesDao) Create(req *pressreleases.CreateReq) (err error) {
Content: req.Content, Content: req.Content,
Summary: req.Summary, Summary: req.Summary,
Display: int(req.Display), Display: int(req.Display),
CreatedAt: time.UnixMilli(int64(req.CreatedAt)), Model: gorm.Model{
UpdatedAt: time.Now(), CreatedAt: time.UnixMilli(int64(req.CreatedAt)),
UpdatedAt: time.Now(),
},
}).Error }).Error
if err != nil { if err != nil {
var mysqlErr *mysql.MySQLError var mysqlErr *mysql.MySQLError
@ -152,7 +156,9 @@ func (pressReleasesDao) Create(req *pressreleases.CreateReq) (err error) {
func (pressReleasesDao) Delete(req *pressreleases.DeleteReq) (err error) { func (pressReleasesDao) Delete(req *pressreleases.DeleteReq) (err error) {
return db.DocDB.Delete(&model.PressReleases{ return db.DocDB.Delete(&model.PressReleases{
ID: uint(req.Id), Model: gorm.Model{
ID: uint(req.Id),
},
}).Error }).Error
} }

View File

@ -1,23 +1,16 @@
package model package model
import ( import "gorm.io/gorm"
"time"
"gorm.io/gorm"
)
type Governance struct { type Governance struct {
ID uint `gorm:"primarykey"` gorm.Model
CreatedAt time.Time Title string `gorm:"type:varchar(100);uniqueIndex:governance_unique;not null"`
UpdatedAt time.Time Attachment string `gorm:"type:varchar(1024);not null;default:'';comment:附件链接"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index:idx_governance_deleted_at;uniqueIndex:governance_unique;"` AttachmentName string `gorm:"type:varchar(1024);not null;default:'';comment:附件文件名"`
Title string `gorm:"column:title;type:varchar(100);not null;uniqueIndex:governance_unique"` Sort int `gorm:"comment:排序"`
Attachment string `gorm:"type:varchar(1024);not null;default:'';comment:附件链接"` Status int `gorm:"comment:状态 1下架 2 上架"`
AttachmentName string `gorm:"type:varchar(1024);not null;default:'';comment:附件文件名"` Operator string `gorm:"type:varchar(50);comment:操作人"`
Sort int `gorm:"comment:排序"` OperatorID int `gorm:"column:operator_id;comment:操作人Id"`
Status int `gorm:"comment:状态 1下架 2 上架"`
Operator string `gorm:"type:varchar(50);comment:操作人"`
OperatorID int `gorm:"column:operator_id;comment:操作人Id"`
} }
func (*Governance) TableName() string { func (*Governance) TableName() string {

View File

@ -1,26 +1,19 @@
package model package model
import ( import "gorm.io/gorm"
"time"
"gorm.io/gorm"
)
type PressReleases struct { type PressReleases struct {
ID uint `gorm:"primarykey"` gorm.Model
CreatedAt time.Time Title string `gorm:"type:varchar(100);uniqueIndex:press_releases_unique"`
UpdatedAt time.Time Sort uint `gorm:"not null"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index:idx_governance_deleted_at;uniqueIndex:governance_unique;"` Content string `gorm:"type:longtext"`
Title string `gorm:"column:title;type:varchar(100);not null;uniqueIndex:governance_unique"` Attachment string `gorm:"type:varchar(1024)"`
Sort uint `gorm:"not null"` Display int `gorm:"comment:状态 1不展示 2 展示"`
Content string `gorm:"type:longtext"` Summary string `gorm:"type:text;comment:摘要"`
Attachment string `gorm:"type:varchar(1024)"` Status int `gorm:"comment:状态 1下架 2 上架"`
Display int `gorm:"comment:状态 1不展示 2 展示"` Operator string `gorm:"type:varchar(100)"`
Summary string `gorm:"type:text;comment:摘要"` OperatorID uint `gorm:"column:operator_id"`
Status int `gorm:"comment:状态 1下架 2 上架"` AttachmentName string `gorm:"type:varchar(1024)"`
Operator string `gorm:"type:varchar(100)"`
OperatorID uint `gorm:"column:operator_id"`
AttachmentName string `gorm:"type:varchar(1024)"`
} }
func (*PressReleases) TableName() string { func (*PressReleases) TableName() string {