update
continuous-integration/drone/push Build is passing Details

master
kgdxpr 4 years ago
parent 70ba7bd8f1
commit bb7014eeb2

@ -3,7 +3,10 @@
<component name="ChangeListManager">
<list default="true" id="19c8c37d-a056-451c-a29d-fb612b9a3e2f" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Business/ImRelate/ImRelateController/ImRelateController.go" beforeDir="false" afterPath="$PROJECT_DIR$/Business/ImRelate/ImRelateController/ImRelateController.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Business/ImRelate/ImRelateDao/ImRelateDao.go" beforeDir="false" afterPath="$PROJECT_DIR$/Business/ImRelate/ImRelateDao/ImRelateDao.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/go.mod" afterDir="false" />
<change beforePath="$PROJECT_DIR$/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/go.sum" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

@ -13,9 +13,10 @@ import (
//模块的路由配置
func Routers(r *gin.RouterGroup) {
rr := r.Group("/imRelate")
rr.POST("/saveChatRecord", saveChatRecord)
rr.POST("/SaveChatRecord", SaveChatRecord)
rr.POST("/GetPersonAvatar", GetPersonAvatar)
rr.GET("/GetPersonInfoList", GetPersonInfoList)
rr.POST("/SyncRongYunUser", SyncRongYunUser)
}
/**
@ -23,7 +24,7 @@ func Routers(r *gin.RouterGroup) {
2021-08-23
*/
func saveChatRecord(c *gin.Context) {
func SaveChatRecord(c *gin.Context) {
//发送方Id。
fromId := c.PostForm("fromId")
//接收方Id。
@ -149,9 +150,11 @@ func GetPersonAvatar(c *gin.Context) {
var personAvatar []map[string]string
personIds := c.PostForm("personIds")
personIdArr := strings.Split(personIds, ",")
//获取是云版还是局版
serverLocation := ImRelateDao.GetServerLocation()
for _, val := range personIdArr {
id := val + "_5"
avatar := ImRelateDao.GetPersonAvatarByUserId(id)
avatar := ImRelateDao.GetPersonAvatarByUserId(id, serverLocation)
myMap := map[string]string{val: avatar}
personAvatar = append(personAvatar, myMap)
}
@ -183,5 +186,23 @@ func GetPersonInfoList(c *gin.Context) {
jsonObj, _ := CommonUtil.JsonStringToMap(res)
c.JSON(http.StatusOK, jsonObj)
}
/**
2021-09-07
*/
func SyncRongYunUser(c *gin.Context) {
//用户ID。
personId := c.PostForm("personId")
personName := c.PostForm("personName")
identityId := c.PostForm("identityId")
_, err := ImRelateDao.RongYunGetToken(personId, identityId, personName, "")
if err != nil {
c.JSON(http.StatusOK, gin.H{"success": false, "info": "向融云同步用户失败!"})
return
}
c.JSON(http.StatusOK, gin.H{"success": true, "info": "向融云同步用户成功!"})
}

@ -11,9 +11,8 @@ import (
"errors"
"fmt"
"github.com/astaxie/beego/httplib"
"github.com/rongcloud/server-sdk-go/v3/sdk"
"github.com/xormplus/xorm"
"io/ioutil"
"net/http"
"strings"
)
@ -208,71 +207,27 @@ func GetPersonNameMsyql(personId string, identityId string) (string, error) {
}
/**
TOKEN使
2021-08-16
2021-09-08
*/
func SendRongYunMsg(sendType string, fromId string, toId string, objectName string, content string) error {
sendTypeStr := ""
toTypeStr := ""
if sendType == "p" {
sendTypeStr = "private"
toTypeStr = "toUserId"
} else {
sendTypeStr = "group"
toTypeStr = "toGroupId"
}
url := fmt.Sprintf("https://api-cn.ronghub.com/message/%s/publish.json", sendTypeStr)
method := "POST"
parameter := fmt.Sprintf("fromUserId=%s&%s=%s&objectName=%s&content=%s", fromId, toTypeStr, toId, objectName, content)
payload := strings.NewReader(parameter)
client := &http.Client{
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
return err
}
func RongYunGetToken(personId string, identityId string, personName string, avatar string) (string, error) {
//获取云平台配置文件中的融云AK和SK
configMap, configErr := CommonUtil.GetRongYunConfig()
if configErr != nil {
return configErr
return "", configErr
}
ak := configMap["app_key"]
r := CommonUtil.GetSixRandom()
ts := CommonUtil.GetTimeStamp()
sk := configMap["app_secret"]
suffix := configMap["rong_server_name"]
st := CommonUtil.SHA1(sk + r + ts)
req.Header.Add("RC-App-Key", ak)
req.Header.Add("RC-Nonce", r)
req.Header.Add("RC-Timestamp", ts)
req.Header.Add("RC-Signature", st)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
res, err := client.Do(req)
if err != nil {
return err
}
defer res.Body.Close()
rc := sdk.NewRongCloud(ak, sk)
body, err := ioutil.ReadAll(res.Body)
user, err := rc.UserRegister(personId+"_"+identityId+suffix, personName, avatar)
if err != nil {
return err
}
jsonObj, err := CommonUtil.JsonStringToMap(string(body))
if err != nil {
return err
}
if jsonObj["code"] != float64(200) {
return errors.New("发送消息失败!")
return "", err
}
return nil
return user.Token, nil
}
/**
@ -331,9 +286,9 @@ func GetPersonNameByUserId(userId string) string {
2021-08-17
*/
func GetPersonAvatarByUserId(userId string) string {
func GetPersonAvatarByUserId(userId string, serverLocation string) string {
pId, iId := GetPersonIdIdentityId(userId)
avatar := GetPersonAvatar(pId, iId, "1")
avatar := GetPersonAvatar(pId, iId, serverLocation)
return avatar
}
@ -354,13 +309,14 @@ func GetGroupNameAvatarByGroupId(groupId string) (string, string) {
2021-08-23
*/
func GetPersonNameAvatar(fromId string, toId string, sendType string) (fromName, fromAvatar, toName, toAvatar string) {
//获取是云版还是局版
serverLocation := GetServerLocation()
fromName = GetPersonNameByUserId(fromId)
fromAvatar = GetPersonAvatarByUserId(fromId)
fromAvatar = GetPersonAvatarByUserId(fromId, serverLocation)
if sendType == "p" {
toName = GetPersonNameByUserId(toId)
toAvatar = GetPersonAvatarByUserId(toId)
} else
{
toAvatar = GetPersonAvatarByUserId(toId, serverLocation)
} else {
toName, toAvatar = GetGroupNameAvatarByGroupId(toId)
}
return

@ -37,6 +37,7 @@ require (
github.com/mojocn/base64Captcha v1.3.1
github.com/olivere/elastic/v7 v7.0.27
github.com/pkg/sftp v1.13.1
github.com/rongcloud/server-sdk-go/v3 v3.2.5 // indirect
github.com/satori/go.uuid v1.2.0
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726 // indirect
github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373 // indirect

@ -99,6 +99,7 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZ
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 h1:BUAU3CGlLvorLI26FmByPp2eC2qla6E1Tw+scpcg/to=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/astaxie/beego v1.12.0/go.mod h1:fysx+LZNZKnvh4GED/xND7jWtjCR6HzydR2Hh2Im57o=
github.com/astaxie/beego v1.12.3 h1:SAQkdD2ePye+v8Gn1r4X6IKZM1wd28EyUOVQ3PDSOOQ=
github.com/astaxie/beego v1.12.3/go.mod h1:p3qIm0Ryx7zeBHLljmd7omloyca1s4yu1a8kM1FkpIA=
github.com/aws/aws-sdk-go v1.40.11 h1:iIRx5w2FbiaEKnCFcai+NSnYa9zKFe6Lzt6aLLUh61A=
@ -145,7 +146,9 @@ github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmf
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/couchbase/go-couchbase v0.0.0-20181122212707-3e9b6e1258bb/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
github.com/couchbase/go-couchbase v0.0.0-20200519150804-63f3cdb75e0d/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
github.com/couchbase/gomemcached v0.0.0-20181122193126-5125a94a666c/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
github.com/couchbase/gomemcached v0.0.0-20200526233749-ec430f949808/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
@ -249,6 +252,7 @@ github.com/go-redis/redis/v7 v7.4.1/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRf
github.com/go-redis/redis/v8 v8.0.0-beta.1/go.mod h1:o1M7JtsgfDYyv3o+gBn/jJ1LkqpnCrmil7PSppZGBak=
github.com/go-redis/redis/v8 v8.8.2 h1:O/NcHqobw7SEptA0yA6up6spZVFtwE06SXM8rgLtsP8=
github.com/go-redis/redis/v8 v8.8.2/go.mod h1:F7resOH5Kdug49Otu24RjHWwgK7u9AmtqWMnCV1iP5Y=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
@ -468,6 +472,7 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU=
github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
@ -571,6 +576,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/rongcloud/server-sdk-go/v3 v3.2.5 h1:mcHL3NakKK6cD4WdTElx9ALYiTaZA5E7psMrqhM3enU=
github.com/rongcloud/server-sdk-go/v3 v3.2.5/go.mod h1:pPC417NmaOZ1stOSidgb+WJtR2ZyCPEdQyhEpoa9mNE=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
@ -703,6 +710,7 @@ go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U=
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=

Loading…
Cancel
Save