胡轶钦 6 years ago
parent
commit
305c17221d
1 changed files with 11 additions and 4 deletions
  1. 11
    4
      controllers/calendar/calendar.go

+ 11
- 4
controllers/calendar/calendar.go View File

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