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{
Model: gorm.Model{
ID: uint(req.Id), ID: uint(req.Id),
UpdatedAt: time.Now(), 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),
Model: gorm.Model{
UpdatedAt: time.Now(), 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),
Model: gorm.Model{
CreatedAt: time.UnixMilli(int64(req.CreatedAt)), CreatedAt: time.UnixMilli(int64(req.CreatedAt)),
UpdatedAt: time.Now(), 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),
Model: gorm.Model{
CreatedAt: time.UnixMilli(int64(req.CreatedAt)), CreatedAt: time.UnixMilli(int64(req.CreatedAt)),
UpdatedAt: time.Now(), 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{
Model: gorm.Model{
ID: uint(req.Id), ID: uint(req.Id),
},
}).Error }).Error
} }

View File

@ -1,17 +1,10 @@
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
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index:idx_governance_deleted_at;uniqueIndex:governance_unique;"`
Title string `gorm:"column:title;type:varchar(100);not null;uniqueIndex:governance_unique"`
Attachment string `gorm:"type:varchar(1024);not null;default:'';comment:附件链接"` Attachment string `gorm:"type:varchar(1024);not null;default:'';comment:附件链接"`
AttachmentName string `gorm:"type:varchar(1024);not null;default:'';comment:附件文件名"` AttachmentName string `gorm:"type:varchar(1024);not null;default:'';comment:附件文件名"`
Sort int `gorm:"comment:排序"` Sort int `gorm:"comment:排序"`

View File

@ -1,17 +1,10 @@
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
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index:idx_governance_deleted_at;uniqueIndex:governance_unique;"`
Title string `gorm:"column:title;type:varchar(100);not null;uniqueIndex:governance_unique"`
Sort uint `gorm:"not null"` Sort uint `gorm:"not null"`
Content string `gorm:"type:longtext"` Content string `gorm:"type:longtext"`
Attachment string `gorm:"type:varchar(1024)"` Attachment string `gorm:"type:varchar(1024)"`