From a2bb97992ca940c54e146f858580a59eb4fad952 Mon Sep 17 00:00:00 2001 From: haoyanbin <605649647@qq.com> Date: Tue, 18 Jan 2022 17:11:27 +0800 Subject: [PATCH] Time --- app/operate/models/org_season.go | 29 ++++++++--------- app/operate/service/dto/org_ad.go | 45 ++++++++++++++------------- app/operate/service/dto/org_season.go | 9 +++--- common/utils/common.go | 5 +++ 4 files changed, 48 insertions(+), 40 deletions(-) diff --git a/app/operate/models/org_season.go b/app/operate/models/org_season.go index a764cd9..543f1f0 100755 --- a/app/operate/models/org_season.go +++ b/app/operate/models/org_season.go @@ -1,27 +1,28 @@ package models import ( - // "gorm.io/gorm" + // "gorm.io/gorm" "go-admin/common/models" + "time" ) type OrgSeason struct { - models.Model - - LeagueId string `json:"leagueId" gorm:"type:bigint(20);comment:org_league表id"` - DivisionId string `json:"divisionId" gorm:"type:bigint(20);comment:org_division表id"` - SeasonName string `json:"seasonName" gorm:"type:varchar(255);comment:èµ›å£åç§°"` - TotalRounds string `json:"totalRounds" gorm:"type:varchar(60);comment:总轮次"` - StartTime string `json:"startTime" gorm:"type:date;comment:èµ›å£å¼€å§‹æ—¶é—´"` - EndTime string `json:"endTime" gorm:"type:date;comment:èµ›å£ç»“æŸæ—¶é—´"` - Status string `json:"status" gorm:"type:tinyint(1);comment:èµ›å£å¼€å¯çŠ¶æ€ 1 是 0 å¦"` - models.ModelTime - models.ControlBy + models.Model + + LeagueId string `json:"leagueId" gorm:"type:bigint(20);comment:org_league表id"` + DivisionId string `json:"divisionId" gorm:"type:bigint(20);comment:org_division表id"` + SeasonName string `json:"seasonName" gorm:"type:varchar(255);comment:èµ›å£åç§°"` + TotalRounds string `json:"totalRounds" gorm:"type:varchar(60);comment:总轮次"` + StartTime time.Time `json:"startTime" gorm:"type:date;comment:èµ›å£å¼€å§‹æ—¶é—´"` + EndTime time.Time `json:"endTime" gorm:"type:date;comment:èµ›å£ç»“æŸæ—¶é—´"` + Status string `json:"status" gorm:"type:tinyint(1);comment:èµ›å£å¼€å¯çŠ¶æ€ 1 是 0 å¦"` + models.ModelTime + models.ControlBy } func (OrgSeason) TableName() string { - return "org_season" + return "org_season" } func (e *OrgSeason) Generate() models.ActiveRecord { @@ -31,4 +32,4 @@ func (e *OrgSeason) Generate() models.ActiveRecord { func (e *OrgSeason) GetId() interface{} { return e.Id -} \ No newline at end of file +} diff --git a/app/operate/service/dto/org_ad.go b/app/operate/service/dto/org_ad.go index 26b65ea..9d321f3 100755 --- a/app/operate/service/dto/org_ad.go +++ b/app/operate/service/dto/org_ad.go @@ -4,6 +4,7 @@ import ( "go-admin/app/operate/models" "go-admin/common/dto" common "go-admin/common/models" + "go-admin/common/utils" "time" ) @@ -37,15 +38,15 @@ func (m *OrgAdGetPageReq) GetNeedSearch() interface{} { } type OrgAdInsertReq struct { - Id int `json:"-" comment:""` // - UserId string `json:"userId" comment:"sys_user表id"` - AdName string `json:"adName" comment:"广告åç§°"` - AdType string `json:"adType" comment:"类型"` - AdImg string `json:"adImg" comment:"广告图"` - AdUrl string `json:"adUrl" comment:"链接地å€"` - Status string `json:"status" comment:"å¹¿å‘ŠçŠ¶æ€ 1 å¼€å¯ 0å…³é—"` - StartTime time.Time `json:"startTime" comment:"广告有效期 开始时间"` - EndTime time.Time `json:"endTime" comment:"广告有效期 ç»“æŸæ—¶é—´"` + Id int `json:"-" comment:""` // + UserId string `json:"userId" comment:"sys_user表id"` + AdName string `json:"adName" comment:"广告åç§°"` + AdType string `json:"adType" comment:"类型"` + AdImg string `json:"adImg" comment:"广告图"` + AdUrl string `json:"adUrl" comment:"链接地å€"` + Status string `json:"status" comment:"å¹¿å‘ŠçŠ¶æ€ 1 å¼€å¯ 0å…³é—"` + StartTime string `json:"startTime" comment:"广告有效期 开始时间"` + EndTime string `json:"endTime" comment:"广告有效期 ç»“æŸæ—¶é—´"` common.ControlBy } @@ -59,8 +60,8 @@ func (s *OrgAdInsertReq) Generate(model *models.OrgAd) { model.AdImg = s.AdImg model.AdUrl = s.AdUrl model.Status = s.Status - model.StartTime = s.StartTime - model.EndTime = s.EndTime + model.StartTime = utils.StringToTime(s.StartTime) + model.EndTime = utils.StringToTime(s.EndTime) } func (s *OrgAdInsertReq) GetId() interface{} { @@ -68,15 +69,15 @@ func (s *OrgAdInsertReq) GetId() interface{} { } type OrgAdUpdateReq struct { - Id int `uri:"id" comment:""` // - UserId string `json:"userId" comment:"sys_user表id"` - AdName string `json:"adName" comment:"广告åç§°"` - AdType string `json:"adType" comment:"类型"` - AdImg string `json:"adImg" comment:"广告图"` - AdUrl string `json:"adUrl" comment:"链接地å€"` - Status string `json:"status" comment:"å¹¿å‘ŠçŠ¶æ€ 1 å¼€å¯ 0å…³é—"` - StartTime time.Time `json:"startTime" comment:"广告有效期 开始时间"` - EndTime time.Time `json:"endTime" comment:"广告有效期 ç»“æŸæ—¶é—´"` + Id int `uri:"id" comment:""` // + UserId string `json:"userId" comment:"sys_user表id"` + AdName string `json:"adName" comment:"广告åç§°"` + AdType string `json:"adType" comment:"类型"` + AdImg string `json:"adImg" comment:"广告图"` + AdUrl string `json:"adUrl" comment:"链接地å€"` + Status string `json:"status" comment:"å¹¿å‘ŠçŠ¶æ€ 1 å¼€å¯ 0å…³é—"` + StartTime string `json:"startTime" comment:"广告有效期 开始时间"` + EndTime string `json:"endTime" comment:"广告有效期 ç»“æŸæ—¶é—´"` common.ControlBy } @@ -90,8 +91,8 @@ func (s *OrgAdUpdateReq) Generate(model *models.OrgAd) { model.AdImg = s.AdImg model.AdUrl = s.AdUrl model.Status = s.Status - model.StartTime = s.StartTime - model.EndTime = s.EndTime + model.StartTime = utils.StringToTime(s.StartTime) + model.EndTime = utils.StringToTime(s.EndTime) } func (s *OrgAdUpdateReq) GetId() interface{} { diff --git a/app/operate/service/dto/org_season.go b/app/operate/service/dto/org_season.go index 88e882d..06748bf 100755 --- a/app/operate/service/dto/org_season.go +++ b/app/operate/service/dto/org_season.go @@ -4,6 +4,7 @@ import ( "go-admin/app/operate/models" "go-admin/common/dto" common "go-admin/common/models" + "go-admin/common/utils" "time" ) @@ -72,8 +73,8 @@ func (s *OrgSeasonInsertReq) Generate(model *models.OrgSeason) { model.DivisionId = s.DivisionId model.SeasonName = s.SeasonName model.TotalRounds = s.TotalRounds - model.StartTime = s.StartTime - model.EndTime = s.EndTime + model.StartTime = utils.StringToTime(s.StartTime) + model.EndTime = utils.StringToTime(s.EndTime) model.Status = s.Status } @@ -101,8 +102,8 @@ func (s *OrgSeasonUpdateReq) Generate(model *models.OrgSeason) { model.DivisionId = s.DivisionId model.SeasonName = s.SeasonName model.TotalRounds = s.TotalRounds - model.StartTime = s.StartTime - model.EndTime = s.EndTime + model.StartTime = utils.StringToTime(s.StartTime) + model.EndTime = utils.StringToTime(s.EndTime) model.Status = s.Status } diff --git a/common/utils/common.go b/common/utils/common.go index 6070888..c2d16e2 100755 --- a/common/utils/common.go +++ b/common/utils/common.go @@ -29,6 +29,11 @@ func StringToFloat(data string) float64 { return reply } +func StringToTime(data string) time.Time { + timeData, _ := time.Parse("2006-01-02 15:04:05", data) + return timeData +} + //ä¸Šä¼ æ–‡ä»¶ func UploadFile(f multipart.File, h *multipart.FileHeader) (string, error) { -- 2.18.1