蛋蛋星球 后台端
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.

hdl_basic.go 4.1 KiB

2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
1 day ago
2 weeks ago
2 weeks ago
1 day ago
2 weeks ago
1 day ago
2 weeks ago
1 day ago
2 weeks ago
1 day ago
2 weeks ago
1 day ago
2 weeks ago
1 day ago
2 weeks ago
2 weeks ago
1 day ago
2 weeks ago
1 day ago
2 weeks ago
1 day ago
2 weeks ago
1 day ago
2 weeks ago
1 day ago
2 weeks ago
1 day ago
2 weeks ago
1 day ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
1 day ago
2 weeks ago
2 weeks ago
2 weeks ago
1 day ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
1 day ago
2 weeks ago
1 day ago
2 weeks ago
2 weeks ago
1 day ago
2 weeks ago
1 day ago
2 weeks ago
1 day ago
2 weeks ago
1 day ago
2 weeks ago
2 weeks ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. enum2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum"
  9. "github.com/gin-gonic/gin"
  10. )
  11. // GetBasic
  12. // @Summary 设置中心-对象存储-对象存储设置(获取)
  13. // @Tags 对象存储
  14. // @Description 对象存储设置(获取)
  15. // @Accept json
  16. // @Produce json
  17. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  18. // @Success 200 {object} md.GetBasicResp "设置列表"
  19. // @Failure 400 {object} md.Response "具体错误"
  20. // @Router /api/settCenter/oss/aliYun/getBasic [get]
  21. func GetBasic(c *gin.Context) {
  22. redisConn := cache.GetPool().Get()
  23. sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn)
  24. sysCfg, err := sysCfgDb.SysCfgGetAll()
  25. if err != nil {
  26. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  27. return
  28. }
  29. cfgMap := make(map[string]string, len(*sysCfg))
  30. for _, cfg := range *sysCfg {
  31. cfgMap[cfg.Key] = cfg.Val
  32. }
  33. endpoint, ok := cfgMap[enum2.AliyunOssEndpoint]
  34. if !ok {
  35. sysCfgDb.SysCfgInsert(enum2.AliyunOssEndpoint, "", enum2.AliyunOss(enum2.AliyunOssEndpoint).String())
  36. endpoint = ""
  37. }
  38. bucketName, ok := cfgMap[enum2.AliyunOssBucketName]
  39. if !ok {
  40. sysCfgDb.SysCfgInsert(enum2.AliyunOssBucketName, "", enum2.AliyunOss(enum2.AliyunOssBucketName).String())
  41. bucketName = ""
  42. }
  43. bucketScheme, ok := cfgMap[enum2.AliyunOssBucketScheme]
  44. if !ok {
  45. sysCfgDb.SysCfgInsert(enum2.AliyunOssBucketScheme, "", enum2.AliyunOss(enum2.AliyunOssBucketScheme).String())
  46. bucketScheme = ""
  47. }
  48. accessKeyID, ok := cfgMap[enum2.AliyunOssAccessKeyID]
  49. if !ok {
  50. sysCfgDb.SysCfgInsert(enum2.AliyunOssAccessKeyID, "", enum2.AliyunOss(enum2.AliyunOssAccessKeyID).String())
  51. accessKeyID = ""
  52. }
  53. accessKeySecret, ok := cfgMap[enum2.AliyunOssAccessKeySecret]
  54. if !ok {
  55. sysCfgDb.SysCfgInsert(enum2.AliyunOssAccessKeySecret, "", enum2.AliyunOss(enum2.AliyunOssAccessKeySecret).String())
  56. accessKeySecret = ""
  57. }
  58. domain, ok := cfgMap[enum2.AliyunOssDomain]
  59. if !ok {
  60. sysCfgDb.SysCfgInsert(enum2.AliyunOssDomain, "", enum2.AliyunOss(enum2.AliyunOssDomain).String())
  61. domain = ""
  62. }
  63. options, ok := cfgMap[enum2.AliyunOptions]
  64. if !ok {
  65. sysCfgDb.SysCfgInsert(enum2.AliyunOptions, "", enum2.AliyunOss(enum2.AliyunOptions).String())
  66. }
  67. resp := md.GetBasicResp{
  68. OssEndpoint: endpoint,
  69. OssBucketName: bucketName,
  70. OssBucketScheme: bucketScheme,
  71. OssAccessKeyId: accessKeyID,
  72. OssAccessKeySecret: accessKeySecret,
  73. OssObjectDomain: domain,
  74. OssOption: options,
  75. }
  76. e.OutSuc(c, resp, nil)
  77. }
  78. // SetBasic
  79. // @Summary 设置中心-对象存储-对象存储设置(更新)
  80. // @Tags 对象存储
  81. // @Description 对象存储设置(更新)
  82. // @Accept json
  83. // @Produce json
  84. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  85. // @param req body md.SetBasicReq true "上传需要修改的信息"
  86. // @Success 200 {string} "success"
  87. // @Failure 400 {object} md.Response "具体错误"
  88. // @Router /api/settCenter/oss/aliYun/setBasic [post]
  89. func SetBasic(c *gin.Context) {
  90. var req *md.SetBasicReq
  91. if err1 := c.ShouldBindJSON(&req); err1 != nil {
  92. e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
  93. return
  94. }
  95. redisConn := cache.GetPool().Get()
  96. cfgDb := implement.NewSysCfgDb(db.Db, redisConn)
  97. if req.OssAccessKeyId != "" {
  98. cfgDb.SysCfgUpdate(enum2.AliyunOssAccessKeyID, req.OssAccessKeyId)
  99. }
  100. if req.OssAccessKeySecret != "" {
  101. cfgDb.SysCfgUpdate(enum2.AliyunOssAccessKeySecret, req.OssAccessKeySecret)
  102. }
  103. if req.OssBucketScheme != "" {
  104. cfgDb.SysCfgUpdate(enum2.AliyunOssBucketScheme, req.OssBucketScheme)
  105. }
  106. if req.OssObjectDomain != "" {
  107. cfgDb.SysCfgUpdate(enum2.AliyunOssDomain, req.OssObjectDomain)
  108. }
  109. if req.OssBucketName != "" {
  110. cfgDb.SysCfgUpdate(enum2.AliyunOssBucketName, req.OssBucketName)
  111. }
  112. if req.OssEndpoint != "" {
  113. cfgDb.SysCfgUpdate(enum2.AliyunOssEndpoint, req.OssEndpoint)
  114. }
  115. if req.OssOption != "" {
  116. cfgDb.SysCfgUpdate(enum2.AliyunOptions, req.OssEndpoint)
  117. }
  118. e.OutSuc(c, "success", nil)
  119. }