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

1 month ago
1 month ago
2 weeks ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 weeks ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
3 weeks ago
1 month ago
1 month ago
3 weeks ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 weeks ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
3 weeks ago
1 month ago
1 month ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. package aliyun
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. md "applet/app/md/setCenter/oss/aliyun"
  6. "applet/app/svc/sys_cfg"
  7. enum2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum"
  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/settCenter/oss/aliYun/getBasic [get]
  20. func GetBasic(c *gin.Context) {
  21. sysCfgDb := sys_cfg.NewSysCfgDb(db.Db)
  22. sysCfg, err := sysCfgDb.SysCfgGetAll()
  23. if err != nil {
  24. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  25. return
  26. }
  27. cfgMap := make(map[string]string, len(*sysCfg))
  28. for _, cfg := range *sysCfg {
  29. cfgMap[cfg.Key] = cfg.Val
  30. }
  31. endpoint, ok := cfgMap[enum2.AliyunOssEndpoint]
  32. if !ok {
  33. sysCfgDb.SysCfgInsert(enum2.AliyunOssEndpoint, "", enum2.AliyunOss(enum2.AliyunOssEndpoint).String())
  34. endpoint = ""
  35. }
  36. bucketName, ok := cfgMap[enum2.AliyunOssBucketName]
  37. if !ok {
  38. sysCfgDb.SysCfgInsert(enum2.AliyunOssBucketName, "", enum2.AliyunOss(enum2.AliyunOssBucketName).String())
  39. bucketName = ""
  40. }
  41. bucketScheme, ok := cfgMap[enum2.AliyunOssBucketScheme]
  42. if !ok {
  43. sysCfgDb.SysCfgInsert(enum2.AliyunOssBucketScheme, "", enum2.AliyunOss(enum2.AliyunOssBucketScheme).String())
  44. bucketScheme = ""
  45. }
  46. accessKeyID, ok := cfgMap[enum2.AliyunOssAccessKeyID]
  47. if !ok {
  48. sysCfgDb.SysCfgInsert(enum2.AliyunOssAccessKeyID, "", enum2.AliyunOss(enum2.AliyunOssAccessKeyID).String())
  49. accessKeyID = ""
  50. }
  51. accessKeySecret, ok := cfgMap[enum2.AliyunOssAccessKeySecret]
  52. if !ok {
  53. sysCfgDb.SysCfgInsert(enum2.AliyunOssAccessKeySecret, "", enum2.AliyunOss(enum2.AliyunOssAccessKeySecret).String())
  54. accessKeySecret = ""
  55. }
  56. domain, ok := cfgMap[enum2.AliyunOssDomain]
  57. if !ok {
  58. sysCfgDb.SysCfgInsert(enum2.AliyunOssDomain, "", enum2.AliyunOss(enum2.AliyunOssDomain).String())
  59. domain = ""
  60. }
  61. options, ok := cfgMap[enum2.AliyunOptions]
  62. if !ok {
  63. sysCfgDb.SysCfgInsert(enum2.AliyunOptions, "", enum2.AliyunOss(enum2.AliyunOptions).String())
  64. }
  65. assumeRoleARN, ok := cfgMap[enum2.AliyunOssAssumeRoleARN]
  66. if !ok {
  67. sysCfgDb.SysCfgInsert(enum2.AliyunOssAssumeRoleARN, "", enum2.AliyunOss(enum2.AliyunOssAssumeRoleARN).String())
  68. }
  69. assumeRoleAccessKeySecret, ok := cfgMap[enum2.AliyunOssAssumeRoleAccessKeySecret]
  70. if !ok {
  71. sysCfgDb.SysCfgInsert(enum2.AliyunOssAssumeRoleAccessKeySecret, "", enum2.AliyunOss(enum2.AliyunOssAssumeRoleAccessKeySecret).String())
  72. }
  73. assumeRoleAccessKeyID, ok := cfgMap[enum2.AliyunOssAssumeRoleAccessKeyID]
  74. if !ok {
  75. sysCfgDb.SysCfgInsert(enum2.AliyunOssAssumeRoleAccessKeyID, "", enum2.AliyunOss(enum2.AliyunOssAssumeRoleAccessKeyID).String())
  76. }
  77. resp := md.GetBasicResp{
  78. OssEndpoint: endpoint,
  79. OssBucketName: bucketName,
  80. OssBucketScheme: bucketScheme,
  81. OssAccessKeyId: accessKeyID,
  82. OssAccessKeySecret: accessKeySecret,
  83. OssObjectDomain: domain,
  84. OssOption: options,
  85. OssAssumeRoleAccessKeyID: assumeRoleAccessKeyID,
  86. OssAssumeRoleAccessKeySecret: assumeRoleAccessKeySecret,
  87. OssAssumeRoleARN: assumeRoleARN,
  88. }
  89. e.OutSuc(c, resp, nil)
  90. }
  91. // SetBasic
  92. // @Summary 设置中心-对象存储-对象存储设置(更新)
  93. // @Tags 对象存储
  94. // @Description 对象存储设置(更新)
  95. // @Accept json
  96. // @Produce json
  97. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  98. // @param req body md.SetBasicReq true "上传需要修改的信息"
  99. // @Success 200 {string} "success"
  100. // @Failure 400 {object} md.Response "具体错误"
  101. // @Router /api/settCenter/oss/aliYun/setBasic [post]
  102. func SetBasic(c *gin.Context) {
  103. var req *md.SetBasicReq
  104. if err1 := c.ShouldBindJSON(&req); err1 != nil {
  105. e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
  106. return
  107. }
  108. cfgDb := sys_cfg.NewSysCfgDb(db.Db)
  109. if req.OssAccessKeyId != "" {
  110. cfgDb.SysCfgUpdate(enum2.AliyunOssAccessKeyID, req.OssAccessKeyId)
  111. }
  112. if req.OssAccessKeySecret != "" {
  113. cfgDb.SysCfgUpdate(enum2.AliyunOssAccessKeySecret, req.OssAccessKeySecret)
  114. }
  115. if req.OssBucketScheme != "" {
  116. cfgDb.SysCfgUpdate(enum2.AliyunOssBucketScheme, req.OssBucketScheme)
  117. }
  118. if req.OssObjectDomain != "" {
  119. cfgDb.SysCfgUpdate(enum2.AliyunOssDomain, req.OssObjectDomain)
  120. }
  121. if req.OssBucketName != "" {
  122. cfgDb.SysCfgUpdate(enum2.AliyunOssBucketName, req.OssBucketName)
  123. }
  124. if req.OssEndpoint != "" {
  125. cfgDb.SysCfgUpdate(enum2.AliyunOssEndpoint, req.OssEndpoint)
  126. }
  127. if req.OssOption != "" {
  128. cfgDb.SysCfgUpdate(enum2.AliyunOptions, req.OssOption)
  129. }
  130. if req.OssAssumeRoleAccessKeyID != "" {
  131. cfgDb.SysCfgUpdate(enum2.AliyunOssAssumeRoleAccessKeyID, req.OssAssumeRoleAccessKeyID)
  132. }
  133. if req.OssAssumeRoleAccessKeySecret != "" {
  134. cfgDb.SysCfgUpdate(enum2.AliyunOssAssumeRoleAccessKeySecret, req.OssAssumeRoleAccessKeySecret)
  135. }
  136. if req.OssAssumeRoleARN != "" {
  137. cfgDb.SysCfgUpdate(enum2.AliyunOssAssumeRoleARN, req.OssAssumeRoleARN)
  138. }
  139. e.OutSuc(c, "success", nil)
  140. }