|
@@ -7,6 +7,7 @@ import (
|
|
|
"eta/eta_api/models/rag"
|
|
|
"eta/eta_api/models/rag/request"
|
|
|
"eta/eta_api/models/rag/response"
|
|
|
+ "eta/eta_api/models/system"
|
|
|
"eta/eta_api/services/llm"
|
|
|
"eta/eta_api/utils"
|
|
|
"fmt"
|
|
@@ -161,15 +162,15 @@ func (c *WechatPlatformController) Add() {
|
|
|
br.Msg = `添加成功`
|
|
|
}
|
|
|
|
|
|
-// List
|
|
|
-// @Title 获取ppt列表
|
|
|
-// @Description 获取ppt列表接口
|
|
|
+// FollowList
|
|
|
+// @Title 我关注的接口
|
|
|
+// @Description 我关注的接口
|
|
|
// @Param PageSize query int true "每页数据条数"
|
|
|
// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
// @Param KeyWord query string true "搜索关键词"
|
|
|
-// @Success 200 {object} models.WechatPlatformListResp
|
|
|
-// @router /wechat_platform/list [get]
|
|
|
-func (c *WechatPlatformController) List() {
|
|
|
+// @Success 200 {object} []*rag.WechatPlatform
|
|
|
+// @router /wechat_platform/list/follow [get]
|
|
|
+func (c *WechatPlatformController) FollowList() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
defer func() {
|
|
|
c.Data["json"] = br
|
|
@@ -204,17 +205,118 @@ func (c *WechatPlatformController) List() {
|
|
|
}
|
|
|
|
|
|
obj := new(rag.WechatPlatform)
|
|
|
- total, list, err := obj.GetPageListByCondition(condition, pars, startSize, pageSize)
|
|
|
+ list, err := obj.GetListByCondition(condition, pars, startSize, 100000)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
- resp := new(response.WechatPlatformListResp)
|
|
|
- resp.Paging = page
|
|
|
- resp.List = list
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = list
|
|
|
+}
|
|
|
+
|
|
|
+// PublicList
|
|
|
+// @Title 公共列表
|
|
|
+// @Description 公共列表
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Param KeyWord query string true "搜索关键词"
|
|
|
+// @Success 200 {object} models.WechatPlatformListResp
|
|
|
+// @router /wechat_platform/list/public [get]
|
|
|
+func (c *WechatPlatformController) PublicList() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ c.Data["json"] = br
|
|
|
+ c.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ sysUser := c.SysUser
|
|
|
+ if sysUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ pageSize, _ := c.GetInt("PageSize")
|
|
|
+ currentIndex, _ := c.GetInt("CurrentIndex")
|
|
|
+ keyWord := c.GetString("KeyWord")
|
|
|
+
|
|
|
+ var startSize int
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize20
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+ startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
+
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+
|
|
|
+ condition = fmt.Sprintf(` AND b.%s = ?`, rag.WechatPlatformUserMappingColumns.SysUserID)
|
|
|
+ pars = append(pars, c.SysUser.AdminId)
|
|
|
+
|
|
|
+ if keyWord != "" {
|
|
|
+ condition = fmt.Sprintf(` AND %s = ?`, rag.WechatPlatformColumns.Nickname)
|
|
|
+ pars = append(pars, `%`+keyWord+`%`)
|
|
|
+ }
|
|
|
+
|
|
|
+ obj := new(rag.WechatPlatformUserMapping)
|
|
|
+ list, err := obj.GetListByCondition(condition, pars, startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ resp := make([]response.WechatPlatformPublicListResp, 0)
|
|
|
+
|
|
|
+ if list != nil && len(list) > 0 {
|
|
|
+ userIdList := make([]int, 0)
|
|
|
+ uerIdMap := make(map[int]bool)
|
|
|
+ userFollowIndexMap := make(map[int]int)
|
|
|
+ for _, v := range list {
|
|
|
+ if _, ok := uerIdMap[v.FollowUserId]; !ok {
|
|
|
+ userIdList = append(userIdList, v.FollowUserId)
|
|
|
+ uerIdMap[v.FollowUserId] = true
|
|
|
+ }
|
|
|
+
|
|
|
+ index, ok := userFollowIndexMap[v.FollowUserId]
|
|
|
+ if !ok {
|
|
|
+ userFollowIndexMap[v.FollowUserId] = len(resp)
|
|
|
+
|
|
|
+ resp = append(resp, response.WechatPlatformPublicListResp{
|
|
|
+ UserId: v.FollowUserId,
|
|
|
+ List: []*rag.UserFollowWechatPlatform{v},
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ resp[index].List = append(resp[index].List, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ userList, err := system.GetAdminListByIdList(userIdList)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ userNameMap := make(map[int]*system.Admin)
|
|
|
+ for _, v := range userList {
|
|
|
+ userNameMap[v.AdminId] = v
|
|
|
+ }
|
|
|
+
|
|
|
+ for k, v := range resp {
|
|
|
+ userInfo, ok := userNameMap[v.UserId]
|
|
|
+ if !ok {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ resp[k].Name = userInfo.RealName + `关注`
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "获取成功"
|