|
@@ -43,10 +43,6 @@ func (this *AnalystController) UploadImage() {
|
|
}
|
|
}
|
|
defer f.Close()
|
|
defer f.Close()
|
|
ext := path.Ext(h.Filename)
|
|
ext := path.Ext(h.Filename)
|
|
- //if ext != ".pdf" {
|
|
|
|
- // br.Msg = "文件格式不正确"
|
|
|
|
- // return
|
|
|
|
- //}
|
|
|
|
size, err := strconv.Atoi(utils.UPLOAD_IMG_SIZE)
|
|
size, err := strconv.Atoi(utils.UPLOAD_IMG_SIZE)
|
|
if err != nil {
|
|
if err != nil {
|
|
size = 15
|
|
size = 15
|
|
@@ -55,8 +51,8 @@ func (this *AnalystController) UploadImage() {
|
|
br.Msg = fmt.Sprintf("头像文件大小不能超过%dK", size)
|
|
br.Msg = fmt.Sprintf("头像文件大小不能超过%dK", size)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- dateDir := time.Now().Format("20060102")
|
|
|
|
- uploadDir := utils.STATIC_DIR + "ht/" + dateDir
|
|
|
|
|
|
+ dateDir := time.Now().Format(time.DateOnly)
|
|
|
|
+ uploadDir := utils.STATIC_DIR + "ht/analyst/" + dateDir
|
|
err = os.MkdirAll(uploadDir, utils.DIR_MOD)
|
|
err = os.MkdirAll(uploadDir, utils.DIR_MOD)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "存储目录创建失败"
|
|
br.Msg = "存储目录创建失败"
|
|
@@ -72,33 +68,47 @@ func (this *AnalystController) UploadImage() {
|
|
br.ErrMsg = "头像上传失败,Err:" + err.Error()
|
|
br.ErrMsg = "头像上传失败,Err:" + err.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- pdfUploadDir := utils.RESOURCE_DIR + "analyst/"
|
|
|
|
- savePdfToOssPath := pdfUploadDir + time.Now().Format("200601/20060102/")
|
|
|
|
|
|
+ thumbnailPath, err := utils.ImageResize(fpath, 1200)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "头像上传失败"
|
|
|
|
+ br.ErrMsg = "头像上传失败,Err:" + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ ossUploadDir := utils.RESOURCE_DIR + "analyst/"
|
|
|
|
+ saveOssPath := ossUploadDir + time.Now().Format("200601/20060102/")
|
|
imgName := utils.GetRandStringNoSpecialChar(28)
|
|
imgName := utils.GetRandStringNoSpecialChar(28)
|
|
- savePdfToOssPath += imgName
|
|
|
|
-
|
|
|
|
|
|
+ saveOssPath += imgName
|
|
defer func() {
|
|
defer func() {
|
|
_ = os.Remove(fpath)
|
|
_ = os.Remove(fpath)
|
|
|
|
+ _ = os.Remove(thumbnailPath)
|
|
}()
|
|
}()
|
|
-
|
|
|
|
ossClient := services.NewOssClient()
|
|
ossClient := services.NewOssClient()
|
|
if ossClient == nil {
|
|
if ossClient == nil {
|
|
br.Msg = "头像上传失败"
|
|
br.Msg = "头像上传失败"
|
|
br.ErrMsg = "初始化OSS服务失败"
|
|
br.ErrMsg = "初始化OSS服务失败"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- imgUrl, err := ossClient.UploadFile("", fpath, savePdfToOssPath)
|
|
|
|
|
|
+ //新增上传缩略图
|
|
|
|
+
|
|
|
|
+ thumbnailUrl, err := ossClient.UploadFile("", thumbnailPath, saveOssPath+"_thumbnail")
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "头像上传失败"
|
|
|
|
+ br.ErrMsg = "头像上传失败,Err:" + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ imgUrl, err := ossClient.UploadFile("", fpath, saveOssPath)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "头像上传失败"
|
|
br.Msg = "头像上传失败"
|
|
br.ErrMsg = "头像上传失败,Err:" + err.Error()
|
|
br.ErrMsg = "头像上传失败,Err:" + err.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
-
|
|
|
|
base := path.Base(h.Filename)
|
|
base := path.Base(h.Filename)
|
|
- resp := new(response.ReportPdfUploadResp)
|
|
|
|
- resp.Url = imgUrl
|
|
|
|
- resp.FileName = base
|
|
|
|
-
|
|
|
|
|
|
+ thumbnailBase := path.Base(h.Filename + "_thumbnail")
|
|
|
|
+ resp := new(response.HeadImageUploadResp)
|
|
|
|
+ resp.Url = thumbnailUrl
|
|
|
|
+ resp.OriginUrl = imgUrl
|
|
|
|
+ resp.FileName = thumbnailBase
|
|
|
|
+ resp.OriginFileName = base
|
|
br.Data = resp
|
|
br.Data = resp
|
|
br.Msg = "上传成功"
|
|
br.Msg = "上传成功"
|
|
br.Ret = 200
|
|
br.Ret = 200
|
|
@@ -118,7 +128,6 @@ func (this *AnalystController) GetAnalystByName(AnalystName string) {
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
}()
|
|
}()
|
|
analyst, err := models.GetAnalystByName(AnalystName)
|
|
analyst, err := models.GetAnalystByName(AnalystName)
|
|
-
|
|
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "获取失败"
|
|
br.Msg = "获取失败"
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
@@ -241,6 +250,7 @@ func (this *AnalystController) Edit() {
|
|
}
|
|
}
|
|
analyst.Introduction = req.Introduction
|
|
analyst.Introduction = req.Introduction
|
|
analyst.Position = req.Position
|
|
analyst.Position = req.Position
|
|
|
|
+ analyst.HeadOriginImgUrl = req.HeadOriginImgUrl
|
|
analyst.ProfessionalCertificate = req.ProfessionalCertificate
|
|
analyst.ProfessionalCertificate = req.ProfessionalCertificate
|
|
analyst.InvestmentCertificate = req.InvestmentCertificate
|
|
analyst.InvestmentCertificate = req.InvestmentCertificate
|
|
analyst.UpdatedTime = time.Now()
|
|
analyst.UpdatedTime = time.Now()
|