Przeglądaj źródła

修改研报显示时间格式

kobe6258 7 miesięcy temu
rodzic
commit
27dcb8eb13
2 zmienionych plików z 10 dodań i 11 usunięć
  1. 9 9
      domian/report/report_service.go
  2. 1 2
      routers/router.go

+ 9 - 9
domian/report/report_service.go

@@ -95,7 +95,7 @@ func GetGetReportById(reportId int) (ReportDTO ReportDTO, err error) {
 		report.Author = strings.Join(names, ",")
 	}
 	//report.PublishedTime = report.PublishedTime
-	ReportDTO = convertReportDTO(report)
+	ReportDTO = convertReportDTO(report, true)
 	return
 }
 
@@ -173,7 +173,7 @@ func GetReportPageByAnalyst(pageInfo page.PageInfo, analyst string) (list []Repo
 	list = make([]ReportDTO, 0)
 	if reports != nil {
 		for _, report := range reports {
-			dto := convertReportDTO(report)
+			dto := convertReportDTO(report, false)
 			list = append(list, dto)
 		}
 	}
@@ -189,7 +189,7 @@ func GetReportPageByOrgIds(pageInfo page.PageInfo, orgIds map[string][]int) (lis
 	list = make([]ReportDTO, 0)
 	if reports != nil {
 		for _, report := range reports {
-			dto := convertReportDTO(report)
+			dto := convertReportDTO(report, false)
 			list = append(list, dto)
 		}
 	}
@@ -200,7 +200,7 @@ func GetNewReportByPublishTime(time time.Time) (reports []ReportDTO) {
 	list := reportDao.GetNewReportByPublishTime(time)
 	if list != nil {
 		for _, report := range list {
-			dto := convertReportDTO(report)
+			dto := convertReportDTO(report, false)
 			reports = append(reports, dto)
 		}
 	}
@@ -216,7 +216,7 @@ func GetReportPage(pageInfo page.PageInfo) (list []ReportDTO, err error) {
 	list = make([]ReportDTO, 0)
 	if reports != nil {
 		for _, report := range reports {
-			dto := convertReportDTO(report)
+			dto := convertReportDTO(report, false)
 			list = append(list, dto)
 		}
 	}
@@ -532,7 +532,7 @@ func GetListOrderByConditionWeekly(week bool, column string, limit int, order mo
 		return
 	}
 	for _, reportItem := range reports {
-		dto := convertReportDTO(reportItem)
+		dto := convertReportDTO(reportItem, false)
 		dtoList = append(dtoList, dto)
 	}
 	return
@@ -549,7 +549,7 @@ func GetListByCondition[T any](column string, ids []T) (dtoList []ReportDTO, err
 		return
 	}
 	for _, reportItem := range reports {
-		dto := convertReportDTO(reportItem)
+		dto := convertReportDTO(reportItem, false)
 		dtoList = append(dtoList, dto)
 	}
 	return
@@ -622,7 +622,7 @@ func convertEsReport(report reportDao.Report) ESReport {
 	}
 }
 
-func convertReportDTO(report reportDao.Report) (reportDTO ReportDTO) {
+func convertReportDTO(report reportDao.Report, fullTime bool) (reportDTO ReportDTO) {
 	reportDTO = ReportDTO{
 		ReportID:      report.ID,
 		Title:         report.Title,
@@ -634,7 +634,7 @@ func convertReportDTO(report reportDao.Report) (reportDTO ReportDTO) {
 		PublishedTime: report.PublishedTime,
 	}
 	publishDate, err := time.Parse(time.DateTime, reportDTO.PublishedTime)
-	if err == nil {
+	if err == nil && fullTime {
 		reportDTO.PublishedTime = publishDate.Format(time.DateOnly)
 	}
 	return

+ 1 - 2
routers/router.go

@@ -4,7 +4,6 @@ import (
 	"eta/eta_mini_ht_api/controllers/media"
 	"eta/eta_mini_ht_api/controllers/report"
 	"eta/eta_mini_ht_api/controllers/user"
-	"eta/eta_mini_ht_api/middleware"
 	"github.com/beego/beego/v2/server/web"
 	"github.com/beego/beego/v2/server/web/filter/cors"
 	"time"
@@ -20,7 +19,7 @@ func init() {
 		MaxAge:           12 * time.Hour,
 	}))
 	//增加授权拦截
-	web.InsertFilter("*", web.BeforeRouter, middleware.AuthMiddleware())
+	//web.InsertFilter("*", web.BeforeRouter, middleware.AuthMiddleware())
 
 	ns := web.NewNamespace("/htapi",
 		web.NSNamespace("/user",