胡轶钦 6 년 전
부모
커밋
305c17221d
1개의 변경된 파일11개의 추가작업 그리고 4개의 파일을 삭제
  1. 11
    4
      controllers/calendar/calendar.go

+ 11
- 4
controllers/calendar/calendar.go 파일 보기

@@ -3,6 +3,7 @@ package calendar
3 3
 import (
4 4
 	"encoding/json"
5 5
 	"errors"
6
+	"path/filepath"
6 7
 	"spaceofcheng/services/controllers"
7 8
 	"spaceofcheng/services/models"
8 9
 	"spaceofcheng/services/models/model"
@@ -77,14 +78,19 @@ func (c *CalendarController) DownloadImg() {
77 78
 	if err != nil {
78 79
 		c.ResponseError(err)
79 80
 	}
81
+	customerCalendar, err := c.dao.GetCalendarFrontDetailById(calendarId)
82
+	if err != nil {
83
+		c.ResponseError(err)
84
+	}
80 85
 	var files []utils.NetFile
81 86
 	var zf string
82 87
 	if imgType == "user" {
83 88
 		for i := 0; i < len(list); i++ {
84 89
 			if list[i].CustomerImg != "" {
90
+				ext := filepath.Ext(list[i].ImgName)
85 91
 				var file = utils.NetFile{
86 92
 					URI:  list[i].CustomerImg,
87
-					Name: list[i].ImgName + ".jpeg",
93
+					Name: list[i].ImgName + ext,
88 94
 				}
89 95
 				if file.URI != "" {
90 96
 					files = append(files, file)
@@ -93,13 +99,14 @@ func (c *CalendarController) DownloadImg() {
93 99
 			}
94 100
 
95 101
 		}
96
-		zf = "客户照片.zip"
102
+		zf = customerCalendar.Email + "照片.zip"
97 103
 	} else {
98 104
 		for i := 0; i < len(list); i++ {
99 105
 			if list[i].CalendarImg != "" {
106
+				ext := filepath.Ext(list[i].ImgName)
100 107
 				var file = utils.NetFile{
101 108
 					URI:  list[i].CalendarImg,
102
-					Name: list[i].ImgName + ".jpeg",
109
+					Name: list[i].ImgName + ext,
103 110
 				}
104 111
 				if file.URI != "" {
105 112
 					files = append(files, file)
@@ -107,7 +114,7 @@ func (c *CalendarController) DownloadImg() {
107 114
 			}
108 115
 
109 116
 		}
110
-		zf = "电子台历.zip"
117
+		zf = customerCalendar.Email + "台历.zip"
111 118
 	}
112 119
 	if len(files) <= 0 {
113 120
 		c.ResponseError(errors.New("图片为空"))