附近小店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 2 месеца
1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package svc
  2. import (
  3. "time"
  4. "applet/app/db"
  5. "applet/app/db/model"
  6. "applet/app/md"
  7. "applet/app/utils"
  8. "github.com/gin-gonic/gin"
  9. )
  10. func FileSave(c *gin.Context, f *md.FileCallback) error {
  11. // todo 校验时间是否超时, 目前没必要做时间校验,如果已经上传,但超时,那么会造成三方存储存在,可我方表不存在,导致冗余
  12. // 校验签名是否正确
  13. //if qiniu.Sign(f.Time) != f.Sign {
  14. // return e.NewErrCode(e.ERR_SIGN)
  15. //}
  16. newFile := &model.SysFile{
  17. ParentFid: utils.StrToInt64(f.DirId),
  18. FileType: 1,
  19. ShowName: f.FileName,
  20. SaveName: f.FileName,
  21. Uid: utils.StrToInt(f.Uid),
  22. Ext: utils.FileExt(f.FileName),
  23. Hash: f.Hash,
  24. Mime: f.Mime,
  25. Provider: f.Provider,
  26. Width: utils.StrToInt(f.Width),
  27. Height: utils.StrToInt(f.Height),
  28. Bucket: f.Bucket,
  29. FileSize: utils.StrToInt64(f.FileSize),
  30. CreateAt: int(time.Now().Unix()),
  31. }
  32. file, _ := db.FileGetByPFidAndName(db.DBs[c.GetString("mid")], f.DirId, f.FileName)
  33. if file != nil {
  34. newFile.Fid = file.Fid
  35. // 更新数据
  36. return db.FileUpdate(db.DBs[c.GetString("mid")], newFile)
  37. }
  38. return db.FileInsert(db.DBs[c.GetString("mid")], newFile)
  39. }