diff --git a/dsSzxy/.idea/workspace.xml b/dsSzxy/.idea/workspace.xml
index 3f4dc62e..691ef33c 100644
--- a/dsSzxy/.idea/workspace.xml
+++ b/dsSzxy/.idea/workspace.xml
@@ -5,8 +5,6 @@
-
-
@@ -113,4 +111,15 @@
+
+
+
+
+ file://$PROJECT_DIR$/Business/ImRelate/ImRelateDao/ImRelateDao.go
+ 430
+
+
+
+
+
\ No newline at end of file
diff --git a/dsSzxy/Business/ImRelate/ImRelateController/ImRelateController.go b/dsSzxy/Business/ImRelate/ImRelateController/ImRelateController.go
index 90a72562..0b80bf68 100644
--- a/dsSzxy/Business/ImRelate/ImRelateController/ImRelateController.go
+++ b/dsSzxy/Business/ImRelate/ImRelateController/ImRelateController.go
@@ -16,6 +16,7 @@ func Routers(r *gin.RouterGroup) {
rr.POST("/SaveChatRecord", SaveChatRecord)
rr.POST("/GetPersonAvatar", GetPersonAvatar)
rr.GET("/GetPersonInfoList", GetPersonInfoList)
+ rr.POST("/CreateGroup", CreateGroup)
rr.POST("/SyncRongYunUser", SyncRongYunUser)
}
@@ -206,3 +207,32 @@ func SyncRongYunUser(c *gin.Context) {
}
c.JSON(http.StatusOK, gin.H{"success": true, "info": "向融云同步用户成功!"})
}
+
+/**
+功能:保存聊天记录
+作者:吴缤
+日期:2021-08-23
+*/
+func CreateGroup(c *gin.Context) {
+ //群组名称
+ groupName := c.PostForm("group_name")
+ //人员列表
+ personList := c.PostForm("person_list")
+
+ personIdCookie, _ := c.Cookie("person_id")
+ identityIdCookie, _ := c.Cookie("identity_id")
+ tokenCookie, _ := c.Cookie("token")
+ qAccessTokenCookie, _ := c.Cookie("q_access_token")
+
+ groupId, err := ImRelateDao.SaveGroup(groupName, personIdCookie, identityIdCookie, tokenCookie, qAccessTokenCookie)
+ if err != nil {
+ c.JSON(http.StatusOK, gin.H{"success": false, "info": err.Error()})
+ return
+ }
+ err = ImRelateDao.AddGroupMember(groupId, personList, personIdCookie, identityIdCookie, tokenCookie, qAccessTokenCookie)
+ if err != nil {
+ c.JSON(http.StatusOK, gin.H{"success": false, "info": "调用云平台的增加群组成员接口失败!"})
+ return
+ }
+ c.JSON(http.StatusOK, gin.H{"success": true, "info": "成功!"})
+}
diff --git a/dsSzxy/Business/ImRelate/ImRelateDao/ImRelateDao.go b/dsSzxy/Business/ImRelate/ImRelateDao/ImRelateDao.go
index 5a19e209..3e654a09 100644
--- a/dsSzxy/Business/ImRelate/ImRelateDao/ImRelateDao.go
+++ b/dsSzxy/Business/ImRelate/ImRelateDao/ImRelateDao.go
@@ -13,6 +13,8 @@ import (
"github.com/astaxie/beego/httplib"
"github.com/rongcloud/server-sdk-go/v3/sdk"
"github.com/xormplus/xorm"
+ "net/http"
+ "strconv"
"strings"
)
@@ -45,6 +47,13 @@ type PersonList struct {
AvatarUrl string `json:"avatar_url"`
}
+//群组
+type Group struct {
+ Id int `json:"id"`
+ Success bool `json:"success"`
+ Info string `json:"info"`
+}
+
//聊天记录结构
type ChatRecordStruct struct {
SenderUserId string `json:"sender_user_id"`
@@ -375,3 +384,113 @@ func GetPersonList(bureauId string, orgId string, queryChild string, bUse string
return string(jsonBytes), nil
}
+
+/**
+功能:调用云平台的创建群组接口
+作者:吴缤
+日期:2021-09-09
+*/
+func SaveGroup(groupName string, personIdCookie string, identityIdCookie string, tokenCookie string, qAccessTokenCookie string) (string, error) {
+ req := httplib.Post(fmt.Sprintf("%s/dsideal_yy/ypt/group/saveGroup", ConfigUtil.DsidealYy))
+
+ req.Param("group_name", groupName)
+ req.Param("group_desc", "")
+ req.Param("avater_url", "OTc1MEE2RjgtMkNCRi00Q0YwLUEyNTQtRjI1MjhDNDVEM0E4LnBuZw==")
+ req.Param("parent_type", "-1")
+ req.Param("parent_id", "-1")
+ req.Param("group_type", "2")
+ req.Param("use_range", "1")
+ req.Param("plat_type", "1")
+ req.Param("plat_id", "0")
+
+ req.SetCookie(&http.Cookie{
+ Name: "person_id",
+ Value: personIdCookie,
+ Path: "/",
+ Domain: "10.10.14.199",
+ })
+ req.SetCookie(&http.Cookie{
+ Name: "identity_id",
+ Value: identityIdCookie,
+ Path: "/",
+ Domain: "10.10.14.199",
+ })
+ req.SetCookie(&http.Cookie{
+ Name: "token",
+ Value: tokenCookie,
+ Path: "/",
+ Domain: "10.10.14.199",
+ })
+ req.SetCookie(&http.Cookie{
+ Name: "q_access_token",
+ Value: qAccessTokenCookie,
+ Path: "/",
+ Domain: "10.10.14.199",
+ })
+
+ resStr, err := req.String()
+ if err != nil {
+ return "", err
+ }
+
+ var g Group
+ json.Unmarshal([]byte(resStr), &g)
+
+ if !g.Success {
+ return "", errors.New(g.Info)
+ }
+
+ return strconv.Itoa(g.Id), nil
+}
+
+/**
+功能:调用云平台的增加群组成员接口
+作者:吴缤
+日期:2021-09-09
+*/
+func AddGroupMember(groupId string, personList string, personIdCookie string, identityIdCookie string, tokenCookie string, qAccessTokenCookie string) error {
+ req := httplib.Post(fmt.Sprintf("%s/dsideal_yy/ypt/group/addMember", ConfigUtil.DsidealYy))
+
+ req.Param("groupId", groupId)
+ req.Param("pids", personList)
+ req.Param("random_num", CommonUtil.GetSixRandom())
+
+ req.SetCookie(&http.Cookie{
+ Name: "person_id",
+ Value: personIdCookie,
+ Path: "/",
+ Domain: "10.10.14.199",
+ })
+ req.SetCookie(&http.Cookie{
+ Name: "identity_id",
+ Value: identityIdCookie,
+ Path: "/",
+ Domain: "10.10.14.199",
+ })
+ req.SetCookie(&http.Cookie{
+ Name: "token",
+ Value: tokenCookie,
+ Path: "/",
+ Domain: "10.10.14.199",
+ })
+ req.SetCookie(&http.Cookie{
+ Name: "q_access_token",
+ Value: qAccessTokenCookie,
+ Path: "/",
+ Domain: "10.10.14.199",
+ })
+
+ resStr, err := req.String()
+ if err != nil {
+ return err
+ }
+
+ var g Group
+ json.Unmarshal([]byte(resStr), &g)
+
+ if !g.Success {
+ return errors.New("调用云平台的增加群组成员接口失败!")
+ }
+
+ return nil
+}