新增创建医生创建im账号
This commit is contained in:
parent
82353bbd35
commit
7c56b936a4
@ -784,6 +784,11 @@ func (r *UserDoctorService) AddUserDoctor(userId string, a requests.AddUserDocto
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 创建im账户
|
// 创建im账户
|
||||||
|
res, err = tencentIm.CreateAccount(strconv.FormatInt(userDoctor.UserId, 10), a.CardName, a.Avatar)
|
||||||
|
if err != nil || res != true {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
return true, nil
|
return true, nil
|
||||||
|
|||||||
37
extend/tencentIm/account.go
Normal file
37
extend/tencentIm/account.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Package tencentIm 账号
|
||||||
|
package tencentIm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"hospital-admin-api/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CreateAccount 创建账号
|
||||||
|
func CreateAccount(userId, nickName, avatar string) (bool, error) {
|
||||||
|
// 构建请求数据
|
||||||
|
requestData := make(map[string]interface{})
|
||||||
|
requestData["UserID"] = userId
|
||||||
|
requestData["Nick"] = nickName
|
||||||
|
requestData["FaceUrl"] = avatar
|
||||||
|
|
||||||
|
// 将请求数据转换为 JSON
|
||||||
|
requestBody, err := json.Marshal(requestData)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.New("创建im账户失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建请求 URL
|
||||||
|
res, result := getRequestUrlParams("administrator")
|
||||||
|
if res != true {
|
||||||
|
return false, errors.New(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
url := config.C.Im.ImBaseUrl + "v4/im_open_login_svc/account_import?" + result
|
||||||
|
_, err = postRequest(url, requestBody)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.New(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user