蛋蛋星球-客户端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

hdl_comm.go 3.2 KiB

il y a 1 semaine
il y a 3 jours
il y a 2 jours
il y a 1 semaine
il y a 3 jours
il y a 1 semaine
il y a 3 jours
il y a 1 semaine
il y a 1 jour
il y a 1 semaine
il y a 3 jours
il y a 2 jours
il y a 3 jours
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package comm
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/md/comm"
  6. "applet/app/svc"
  7. "applet/app/utils/cache"
  8. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  9. "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
  10. enum2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum"
  11. "github.com/aliyun/aliyun-oss-go-sdk/oss"
  12. "github.com/gin-gonic/gin"
  13. "time"
  14. )
  15. // GetOssUrl
  16. // @Summary 通用请求-对象存储-上传许可链接(获取)
  17. // @Tags 对象存储
  18. // @Description 上传许可链接(获取)
  19. // @Accept json
  20. // @Produce json
  21. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  22. // @Success 200 {string} "许可链接"
  23. // @Failure 400 {object} md.Response "具体错误"
  24. // @Router /api/settCenter/oss/aliYun/getBasic [get]
  25. func GetOssUrl(c *gin.Context) {
  26. redisConn := cache.GetPool().Get()
  27. sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn)
  28. sysCfgs, err := sysCfgDb.SysCfgGetAll()
  29. if err != nil {
  30. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  31. return
  32. }
  33. if sysCfgs == nil {
  34. e.OutErr(c, e.ERR_CFG_CACHE, nil)
  35. return
  36. }
  37. cfgMap := make(map[string]string, len(*sysCfgs))
  38. for _, cfg := range *sysCfgs {
  39. cfgMap[cfg.Key] = cfg.Val
  40. }
  41. endpoint := cfgMap[enum2.AliyunOss(enum2.AliyunOssEndpoint).String()]
  42. bucketName := cfgMap[enum2.AliyunOss(enum2.AliyunOssBucketName).String()]
  43. objectName := cfgMap[enum2.AliyunOss(enum2.AliyunOssBucketScheme).String()]
  44. accessKeyID := cfgMap[enum2.AliyunOss(enum2.AliyunOssAccessKeyID).String()]
  45. accessKeySecret := cfgMap[enum2.AliyunOss(enum2.AliyunOssAccessKeySecret).String()]
  46. client, err := oss.New(endpoint, accessKeyID, accessKeySecret)
  47. if err != nil {
  48. e.OutErr(c, e.ERR_AES_ENCODE, err.Error())
  49. return
  50. }
  51. bucket, err := client.Bucket(bucketName)
  52. if err != nil {
  53. e.OutErr(c, e.ERR_AES_ENCODE, err.Error())
  54. return
  55. }
  56. signedURL, err := bucket.SignURL(objectName, oss.HTTPPut, 60*5)
  57. if err != nil {
  58. e.OutErr(c, e.ERR_AES_ENCODE, err.Error())
  59. return
  60. }
  61. e.OutSuc(c, signedURL, nil)
  62. }
  63. // AccessRecords
  64. // @Summary 通用请求-访问记录-页面记录
  65. // @Tags 访问记录
  66. // @Description 页面记录
  67. // @Accept json
  68. // @Produce json
  69. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  70. // @Param req body comm.AccessRecordsReq true "页面标识"
  71. // @Success 200 {string} "success"
  72. // @Success 200 {string} "data exist"
  73. // @Failure 400 {object} md.Response "具体错误"
  74. func AccessRecords(c *gin.Context) {
  75. var req *comm.AccessRecordsReq
  76. if err1 := c.ShouldBindJSON(&req); err1 != nil {
  77. e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
  78. return
  79. }
  80. user := svc.GetUser(c)
  81. date := time.Now().Format("2006-01-02")
  82. recordsDb := implement.NewEggAccessRecordsDb(db.Db)
  83. exist, err := recordsDb.EggAccessRecordsExist(user.Id, date, req.Index)
  84. if err != nil {
  85. e.OutErr(c, e.ERR_DB_ORM, nil)
  86. }
  87. if exist {
  88. e.OutSuc(c, "data exist", nil)
  89. return
  90. }
  91. m := model.EggAccessRecords{
  92. Uid: user.Id,
  93. PageIndex: req.Index,
  94. Date: date,
  95. }
  96. _, err = recordsDb.EggAccessRecordsInsert(&m)
  97. if err != nil {
  98. e.OutErr(c, e.ERR_DB_ORM, nil)
  99. return
  100. }
  101. e.OutSuc(c, "success", nil)
  102. }