ziwen 1 year ago
parent
commit
1ef8a9d4bf
2 changed files with 56 additions and 23 deletions
  1. 21 23
      controllers/yanxuan_special.go
  2. 35 0
      services/oss.go

+ 21 - 23
controllers/yanxuan_special.go

@@ -115,7 +115,20 @@ func (this *YanxuanSpecialController) Detail() {
 		item.IsCollect = 1
 	}
 
-	br.Data = item
+	var resp models.CygxYanxuanSpecialResp
+	resp.CygxYanxuanSpecialItem = *item
+	if item.DocUrl != "" {
+		var docs []models.Doc
+		err := json.Unmarshal([]byte(item.DocUrl), &docs)
+		if err != nil {
+			br.Msg = "参数解析异常!"
+			br.ErrMsg = "参数解析失败,Err:" + err.Error()
+			return
+		}
+		resp.Docs = docs
+	}
+
+	br.Data = resp
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"
@@ -847,13 +860,13 @@ func (this *YanxuanSpecialController) AuthorHeadImg() {
 	br.Msg = "保存成功"
 }
 
-// ResourceUpload 上传文件
-// @Title 上传文件
-// @Description 上传文件
-// @Param   MenuId  query  int  true  "目录ID"
-// @Param   File	query  file  true  "文件"
-// @Success 200 Ret=200 操作成功
-// @router /doc/upload [post]
+//ResourceUpload 上传文件
+//@Title 上传文件
+//@Description 上传文件
+//@Param   MenuId  query  int  true  "目录ID"
+//@Param   File	query  file  true  "文件"
+//@Success 200 Ret=200 操作成功
+//@router /doc/upload [post]
 //func (this *YanxuanSpecialController) ResourceUpload() {
 //	br := new(models.BaseResponse).Init()
 //	defer func() {
@@ -884,21 +897,6 @@ func (this *YanxuanSpecialController) AuthorHeadImg() {
 //	fileName := originName[:extIndex]
 //	ext := path.Ext(h.Filename)
 //
-//	// 重名校验
-//	existItem := new(models.CloudDiskResource)
-//	existCond := ` AND resource_name = ? AND menu_id = ? `
-//	existPars := make([]interface{}, 0)
-//	existPars = append(existPars, fileName, menuId)
-//	if e := existItem.GetItemByCondition(existCond, existPars); e != nil && e.Error() != utils.ErrNoRow() {
-//		br.Msg = "操作失败"
-//		br.ErrMsg = "获取重名文件失败, Err: " + e.Error()
-//		return
-//	}
-//	if existItem != nil && existItem.MenuId > 0 {
-//		br.Msg = fmt.Sprintf("文件名%s已存在", fileName)
-//		return
-//	}
-//
 //	uploadDir := utils.STATIC_DIR + "hongze/" + time.Now().Format("20060102")
 //	if e = os.MkdirAll(uploadDir, 766); e != nil {
 //		br.Msg = "存储目录创建失败"

+ 35 - 0
services/oss.go

@@ -138,3 +138,38 @@ func UploadFileToAliyun(filename, filepath, savePath string) error {
 	//return path,err
 	return err
 }
+
+// GetCloudDiskResourceFileTypeExtMap 常见文件类型图标
+func GetCloudDiskResourceFileTypeExtMap() map[string]string {
+	return map[string]string{
+		".doc":  "https://hzstatic.hzinsights.com/static/icon/file_type_docx.png",
+		".docx": "https://hzstatic.hzinsights.com/static/icon/file_type_docx.png",
+
+		".pdf": "https://hzstatic.hzinsights.com/static/icon/file_type_pdf.png",
+
+		".ppt":  "https://hzstatic.hzinsights.com/static/icon/file_type_ppt.png",
+		".pptx": "https://hzstatic.hzinsights.com/static/icon/file_type_ppt.png",
+
+		".xls":  "https://hzstatic.hzinsights.com/static/icon/file_type_xlsx.png",
+		".xlsx": "https://hzstatic.hzinsights.com/static/icon/file_type_xlsx.png",
+
+		".jpg":  "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+		".jpeg": "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+		".png":  "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+		".bmp":  "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+		".svg":  "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+		".gif":  "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+
+		".mp4":  "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".wmv":  "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".mov":  "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".mpeg": "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".avi":  "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".flv":  "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".rm":   "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".rmvb": "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+
+		".mp3": "https://hzstatic.hzinsights.com/static/icon/file_type_audio.png",
+		".wma": "https://hzstatic.hzinsights.com/static/icon/file_type_audio.png",
+	}
+}