ziwen 1 年之前
父節點
當前提交
9bff515879
共有 3 個文件被更改,包括 13 次插入2 次删除
  1. 2 1
      controllers/resource.go
  2. 4 1
      controllers/yanxuan_special.go
  3. 7 0
      models/resource.go

+ 2 - 1
controllers/resource.go

@@ -204,9 +204,10 @@ func (this *ResourceController) FileUpload() {
 		br.ErrMsg = "资源上传失败,Err:" + err.Error()
 		return
 	}
-	resp := new(models.ResourceResp)
+	resp := new(models.FileResourceResp)
 	resp.Id = newId
 	resp.ResourceUrl = resourceUrl
+	resp.ResourceName = h.Filename
 
 	br.Msg = "上传成功"
 	br.Ret = 200

+ 4 - 1
controllers/yanxuan_special.go

@@ -361,8 +361,9 @@ func (this *YanxuanSpecialController) Save() {
 		item.Status = 2
 	}
 
+	var newId int64
 	if req.Id == 0 {
-		_, err = models.AddCygxYanxuanSpecial(&item)
+		newId, err = models.AddCygxYanxuanSpecial(&item)
 		if err != nil {
 			br.Msg = "新增失败"
 			br.ErrMsg = "新增失败,Err:" + err.Error()
@@ -375,11 +376,13 @@ func (this *YanxuanSpecialController) Save() {
 			br.ErrMsg = "保存失败,Err:" + err.Error()
 			return
 		}
+		newId = int64(req.Id)
 	}
 
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "保存成功"
+	br.Data = newId
 }
 
 // @Title 专栏作者详情

+ 7 - 0
models/resource.go

@@ -30,3 +30,10 @@ func GetResourceById(id string) (item *Resource, err error) {
 	err = o.Raw(sql, id).QueryRow(&item)
 	return
 }
+
+type FileResourceResp struct {
+	Id           int64  `orm:"column(id);" description:"用户id"`
+	ResourceUrl  string `description:"资源地址"`
+	ResourceName string `description:"资源名称"`
+	PlaySeconds  uint32 `description:"播放时长,单位秒"`
+}