蛋蛋星球-客户端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

hdl_basic.go 3.5 KiB

1 tydzień temu
1 tydzień temu
1 tydzień temu
1 tydzień temu
1 tydzień temu
1 tydzień temu
1 tydzień temu
1 tydzień temu
1 tydzień temu
1 tydzień temu
1 tydzień temu
1 tydzień temu
1 tydzień temu
1 tydzień temu
1 tydzień temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package aliyun
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. md "applet/app/md/setCenter/oss/aliyun"
  6. "applet/app/utils/cache"
  7. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  8. "github.com/gin-gonic/gin"
  9. )
  10. // GetBasic
  11. // @Summary 设置中心-对象存储-对象存储设置(获取)
  12. // @Tags 对象存储
  13. // @Description 对象存储设置(获取)
  14. // @Accept json
  15. // @Produce json
  16. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  17. // @Success 200 {object} md.GetBasicResp "设置列表"
  18. // @Failure 400 {object} md.Response "具体错误"
  19. // @Router /api/comm/oss/getOssUrl [get]
  20. func GetBasic(c *gin.Context) {
  21. redisConn := cache.GetPool().Get()
  22. sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn)
  23. sysCfg, err := sysCfgDb.SysCfgGetAll()
  24. if err != nil {
  25. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  26. return
  27. }
  28. cfgMap := make(map[string]string, len(*sysCfg))
  29. for _, cfg := range *sysCfg {
  30. cfgMap[cfg.Key] = cfg.Val
  31. }
  32. endpoint, ok := cfgMap["oss_endpoint"]
  33. if !ok {
  34. sysCfgDb.SysCfgInsert("oss_endpoint", "", "oss地域节点")
  35. endpoint = ""
  36. }
  37. bucketName, ok := cfgMap["oss_bucket_name"]
  38. if !ok {
  39. sysCfgDb.SysCfgInsert("oss_bucket_name", "", "oss存储桶名称")
  40. bucketName = ""
  41. }
  42. objectScheme, ok := cfgMap["oss_object_scheme"]
  43. if !ok {
  44. sysCfgDb.SysCfgInsert("oss_object_scheme", "", "oss上传方式")
  45. objectScheme = ""
  46. }
  47. accessKeyID, ok := cfgMap["oss_access_key_id"]
  48. if !ok {
  49. sysCfgDb.SysCfgInsert("oss_access_key_id", "", "oss访问秘钥id")
  50. accessKeyID = ""
  51. }
  52. accessKeySecret, ok := cfgMap["oss_access_key_secret"]
  53. if !ok {
  54. sysCfgDb.SysCfgInsert("oss_access_key_secret", "", "oss访问秘钥")
  55. accessKeySecret = ""
  56. }
  57. domain, ok := cfgMap["oss_object_domain"]
  58. if !ok {
  59. sysCfgDb.SysCfgInsert("oss_object_domain", "", "oss域名")
  60. domain = ""
  61. }
  62. resp := md.GetBasicResp{
  63. OssEndpoint: endpoint,
  64. OssBucketName: bucketName,
  65. OssObjectScheme: objectScheme,
  66. OssAccessKeyId: accessKeyID,
  67. OssAccessKeySecret: accessKeySecret,
  68. OssObjectDomain: domain,
  69. }
  70. e.OutSuc(c, resp, nil)
  71. }
  72. // SetBasic
  73. // @Summary 设置中心-对象存储-对象存储设置(更新)
  74. // @Tags 对象存储
  75. // @Description 对象存储设置(更新)
  76. // @Accept json
  77. // @Produce json
  78. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  79. // @param req body md.SetBasicReq true "上传需要修改的信息"
  80. // @Success 200 {string} "success"
  81. // @Failure 400 {object} md.Response "具体错误"
  82. // @Router /api/comm/oss/getOssUrl [get]
  83. func SetBasic(c *gin.Context) {
  84. var req *md.SetBasicReq
  85. if err1 := c.ShouldBindJSON(&req); err1 != nil {
  86. e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
  87. return
  88. }
  89. redisConn := cache.GetPool().Get()
  90. cfgDb := implement.NewSysCfgDb(db.Db, redisConn)
  91. if req.OssAccessKeyId != "" {
  92. cfgDb.SysCfgUpdate("oss_access_key_id", req.OssAccessKeyId)
  93. }
  94. if req.OssAccessKeySecret != "" {
  95. cfgDb.SysCfgUpdate("oss_access_key_secret", req.OssAccessKeySecret)
  96. }
  97. if req.OssObjectScheme != "" {
  98. cfgDb.SysCfgUpdate("oss_object_scheme", req.OssObjectScheme)
  99. }
  100. if req.OssObjectDomain != "" {
  101. cfgDb.SysCfgUpdate("oss_object_domain", req.OssObjectDomain)
  102. }
  103. if req.OssBucketName != "" {
  104. cfgDb.SysCfgUpdate("oss_bucket_name", req.OssBucketName)
  105. }
  106. if req.OssEndpoint != "" {
  107. cfgDb.SysCfgUpdate("oss_endpoint", req.OssEndpoint)
  108. }
  109. e.OutSuc(c, "success", nil)
  110. }