dengbiao vor 1 Monat
Ursprung
Commit
1afa0bedf9
2 geänderte Dateien mit 32 neuen und 13 gelöschten Zeilen
  1. +28
    -9
      app/hdl/comm/hdl_comm.go
  2. +4
    -4
      app/svc/im/svc_group.go

+ 28
- 9
app/hdl/comm/hdl_comm.go Datei anzeigen

@@ -110,6 +110,13 @@ func MenuList(c *gin.Context) {
return
}

type ImgReqUploadReq struct {
FileName string `json:"file_name" binding:"required" example:"文件名"`
}
type ImgReqUploadResp struct {
SignUrl string `json:"sign_url" example:"签名上传url"`
}

// GetOssUrl
// @Summary 通用请求-对象存储-上传许可链接(获取)
// @Tags 对象存储
@@ -121,6 +128,14 @@ func MenuList(c *gin.Context) {
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/comm/getOssUrl [get]
func GetOssUrl(c *gin.Context) {
var args ImgReqUploadReq
err := c.ShouldBindJSON(&args)
if err != nil {
err = svc.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
redisConn := cache.GetPool().Get()
sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn)
sysCfgs, err := sysCfgDb.SysCfgGetAll()
@@ -137,23 +152,27 @@ func GetOssUrl(c *gin.Context) {
for _, cfg := range *sysCfgs {
cfgMap[cfg.Key] = cfg.Val
}
endpoint := cfgMap[enum2.AliyunOss(enum2.AliyunOssEndpoint).String()]
bucketName := cfgMap[enum2.AliyunOss(enum2.AliyunOssBucketName).String()]
objectName := cfgMap[enum2.AliyunOss(enum2.AliyunOssBucketScheme).String()]
accessKeyID := cfgMap[enum2.AliyunOss(enum2.AliyunOssAccessKeyID).String()]
accessKeySecret := cfgMap[enum2.AliyunOss(enum2.AliyunOssAccessKeySecret).String()]
endpoint := cfgMap[enum2.AliyunOssEndpoint]
bucketName := cfgMap[enum2.AliyunOssBucketName]
ossBucketScheme := cfgMap[enum2.AliyunOssBucketScheme]
accessKeyID := cfgMap[enum2.AliyunOssAccessKeyID]
accessKeySecret := cfgMap[enum2.AliyunOssAccessKeySecret]

client, err := oss.New(endpoint, accessKeyID, accessKeySecret)
// 创建OSSClient实例。
client, err := oss.New(ossBucketScheme+"://"+endpoint, accessKeyID, accessKeySecret)
if err != nil {
e.OutErr(c, e.ERR_AES_ENCODE, err.Error())
e.OutErr(c, e.ERR, err.Error())
return
}

// 获取存储空间。
bucket, err := client.Bucket(bucketName)
if err != nil {
e.OutErr(c, e.ERR_AES_ENCODE, err.Error())
e.OutErr(c, e.ERR, err.Error())
return
}
signedURL, err := bucket.SignURL(objectName, oss.HTTPPut, 60*5)

signedURL, err := bucket.SignURL(args.FileName, oss.HTTPPut, 60*5)
if err != nil {
e.OutErr(c, e.ERR_AES_ENCODE, err.Error())
return


+ 4
- 4
app/svc/im/svc_group.go Datei anzeigen

@@ -13,8 +13,8 @@ func GroupList(req md.GroupListReq) (err error, resp md.GroupListResp) {
var groupIds []int64
if req.GroupAdmin != "" {
var user model.User
has, err := db.DbIm.Where("`phone_number`=?", req.GroupAdmin).Get(&user)
if err != nil {
has, err1 := db.DbIm.Where("`phone_number`=?", req.GroupAdmin).Get(&user)
if err1 != nil {
return
}
if !has {
@@ -67,8 +67,8 @@ func GroupList(req md.GroupListReq) (err error, resp md.GroupListResp) {
UpdateTime: v.UpdateTime,
}
var groupUser model.GroupUser
has, err := db.DbIm.Where("`group_id`=? and member_type= 1", v.Id).Get(&groupUser)
if err != nil {
has, err1 := db.DbIm.Where("`group_id`=? and member_type= 1", v.Id).Get(&groupUser)
if err1 != nil {
return
}
if has {


Laden…
Abbrechen
Speichern