wechat_platform.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. package llm
  2. import (
  3. "encoding/json"
  4. "eta/eta_api/cache"
  5. "eta/eta_api/controllers"
  6. "eta/eta_api/models"
  7. "eta/eta_api/models/rag"
  8. "eta/eta_api/models/rag/request"
  9. "eta/eta_api/models/rag/response"
  10. "eta/eta_api/models/system"
  11. "eta/eta_api/services"
  12. "eta/eta_api/utils"
  13. "fmt"
  14. "github.com/rdlucklib/rdluck_tools/paging"
  15. "html"
  16. "strings"
  17. "time"
  18. )
  19. // WechatPlatformController
  20. // @Description: 微信公众号管理
  21. type WechatPlatformController struct {
  22. controllers.BaseAuthController
  23. }
  24. // TagList
  25. // @Title 获取ppt列表
  26. // @Description 获取ppt列表接口
  27. // @Param PageSize query int true "每页数据条数"
  28. // @Param CurrentIndex query int true "当前页页码,从1开始"
  29. // @Param KeyWord query string true "搜索关键词"
  30. // @Success 200 {object} models.TagListResp
  31. // @router /tag/list [get]
  32. func (c *WechatPlatformController) TagList() {
  33. br := new(models.BaseResponse).Init()
  34. defer func() {
  35. c.Data["json"] = br
  36. c.ServeJSON()
  37. }()
  38. sysUser := c.SysUser
  39. if sysUser == nil {
  40. br.Msg = "请登录"
  41. br.ErrMsg = "请登录,SysUser Is Empty"
  42. return
  43. }
  44. pageSize, _ := c.GetInt("PageSize")
  45. currentIndex, _ := c.GetInt("CurrentIndex")
  46. keyWord := c.GetString("KeyWord")
  47. var startSize int
  48. if pageSize <= 0 {
  49. pageSize = utils.PageSize20
  50. }
  51. if currentIndex <= 0 {
  52. currentIndex = 1
  53. }
  54. startSize = utils.StartIndex(currentIndex, pageSize)
  55. var condition string
  56. var pars []interface{}
  57. if keyWord != "" {
  58. condition += fmt.Sprintf(` AND %s like ?`, rag.WechatPlatformColumns.Nickname)
  59. pars = append(pars, `%`+keyWord+`%`)
  60. }
  61. obj := new(rag.Tag)
  62. total, list, err := obj.GetPageListByCondition(condition, pars, startSize, pageSize)
  63. if err != nil {
  64. br.Msg = "获取失败"
  65. br.ErrMsg = "获取失败,Err:" + err.Error()
  66. return
  67. }
  68. page := paging.GetPaging(currentIndex, pageSize, total)
  69. resp := new(response.TagListResp)
  70. resp.Paging = page
  71. resp.List = list
  72. br.Ret = 200
  73. br.Success = true
  74. br.Msg = "获取成功"
  75. br.Data = resp
  76. }
  77. // Add
  78. // @Title 新增公众号
  79. // @Description 新增公众号
  80. // @Param request body request.AddWechatPlatformReq true "type json string"
  81. // @Success 200 Ret=200 新增成功
  82. // @router /wechat_platform/add [post]
  83. func (c *WechatPlatformController) Add() {
  84. br := new(models.BaseResponse).Init()
  85. defer func() {
  86. c.Data["json"] = br
  87. c.ServeJSON()
  88. }()
  89. var req request.AddWechatPlatformReq
  90. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  91. if err != nil {
  92. br.Msg = "参数解析异常!"
  93. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  94. return
  95. }
  96. req.Name = strings.TrimSpace(req.Name)
  97. if req.Name == "" {
  98. br.Msg = "请输入公众号名称"
  99. br.IsSendEmail = false
  100. return
  101. }
  102. req.Link = strings.TrimSpace(req.Link)
  103. if req.Link == "" {
  104. br.Msg = "请输入文章链接"
  105. br.IsSendEmail = false
  106. return
  107. }
  108. // 名称校验
  109. {
  110. var condition string
  111. var pars []interface{}
  112. condition += fmt.Sprintf(` AND %s = ?`, rag.WechatPlatformColumns.Nickname)
  113. pars = append(pars, req.Name)
  114. obj := new(rag.WechatPlatform)
  115. item, err := obj.GetByCondition(condition, pars)
  116. if err != nil && !utils.IsErrNoRow(err) {
  117. br.Msg = "公众号信息获取失败"
  118. br.ErrMsg = "公众号信息获取失败,Err:" + err.Error()
  119. return
  120. }
  121. if item.WechatPlatformId > 0 {
  122. br.Msg = "公众号名称重复"
  123. br.IsSendEmail = false
  124. return
  125. }
  126. }
  127. // 链接校验
  128. {
  129. var condition string
  130. var pars []interface{}
  131. condition += fmt.Sprintf(` AND %s = ?`, rag.WechatPlatformColumns.ArticleLink)
  132. pars = append(pars, req.Link)
  133. obj := new(rag.WechatPlatform)
  134. item, err := obj.GetByCondition(condition, pars)
  135. if err != nil && !utils.IsErrNoRow(err) {
  136. br.Msg = "公众号信息获取失败"
  137. br.ErrMsg = "公众号信息获取失败,Err:" + err.Error()
  138. return
  139. }
  140. if item.WechatPlatformId > 0 {
  141. br.Msg = "公众号链接重复"
  142. br.IsSendEmail = false
  143. return
  144. }
  145. }
  146. item := &rag.WechatPlatform{
  147. WechatPlatformId: 0,
  148. FakeId: "",
  149. Nickname: req.Name,
  150. Alias: "",
  151. RoundHeadImg: "",
  152. ServiceType: 0,
  153. Signature: "",
  154. Verified: 0,
  155. ArticleLink: req.Link,
  156. Enabled: 0,
  157. SysUserId: c.SysUser.AdminId,
  158. ModifyTime: time.Now(),
  159. CreateTime: time.Now(),
  160. }
  161. err = item.Add(req.TagIdList)
  162. if err != nil {
  163. br.Msg = "添加失败"
  164. br.ErrMsg = "添加失败,Err:" + err.Error()
  165. return
  166. }
  167. // 异步新增公众号
  168. go cache.AddWechatArticleOpToCache(item.WechatPlatformId, `add`)
  169. br.Ret = 200
  170. br.Success = true
  171. br.Msg = `添加成功`
  172. }
  173. // FollowList
  174. // @Title 我关注的接口
  175. // @Description 我关注的接口
  176. // @Param PageSize query int true "每页数据条数"
  177. // @Param CurrentIndex query int true "当前页页码,从1开始"
  178. // @Param KeyWord query string true "搜索关键词"
  179. // @Success 200 {object} []*rag.WechatPlatform
  180. // @router /wechat_platform/list/follow [get]
  181. func (c *WechatPlatformController) FollowList() {
  182. br := new(models.BaseResponse).Init()
  183. defer func() {
  184. c.Data["json"] = br
  185. c.ServeJSON()
  186. }()
  187. sysUser := c.SysUser
  188. if sysUser == nil {
  189. br.Msg = "请登录"
  190. br.ErrMsg = "请登录,SysUser Is Empty"
  191. return
  192. }
  193. pageSize, _ := c.GetInt("PageSize")
  194. currentIndex, _ := c.GetInt("CurrentIndex")
  195. keyWord := c.GetString("KeyWord")
  196. var startSize int
  197. if pageSize <= 0 {
  198. pageSize = utils.PageSize20
  199. }
  200. if currentIndex <= 0 {
  201. currentIndex = 1
  202. }
  203. startSize = utils.StartIndex(currentIndex, pageSize)
  204. var condition string
  205. var pars []interface{}
  206. if keyWord != "" {
  207. condition += fmt.Sprintf(` AND %s like ?`, rag.WechatPlatformColumns.Nickname)
  208. pars = append(pars, `%`+keyWord+`%`)
  209. }
  210. condition += fmt.Sprintf(` AND b.%s = ?`, rag.WechatPlatformUserMappingColumns.SysUserID)
  211. pars = append(pars, c.SysUser.AdminId)
  212. obj := new(rag.WechatPlatformUserMapping)
  213. list, err := obj.GetListByCondition(condition, pars, startSize, pageSize)
  214. if err != nil {
  215. br.Msg = "获取失败"
  216. br.ErrMsg = "获取失败,Err:" + err.Error()
  217. return
  218. }
  219. br.Ret = 200
  220. br.Success = true
  221. br.Msg = "获取成功"
  222. br.Data = list
  223. }
  224. // PublicList
  225. // @Title 公共列表
  226. // @Description 公共列表
  227. // @Param PageSize query int true "每页数据条数"
  228. // @Param CurrentIndex query int true "当前页页码,从1开始"
  229. // @Param KeyWord query string true "搜索关键词"
  230. // @Success 200 {object} models.WechatPlatformListResp
  231. // @router /wechat_platform/list/public [get]
  232. func (c *WechatPlatformController) PublicList() {
  233. br := new(models.BaseResponse).Init()
  234. defer func() {
  235. c.Data["json"] = br
  236. c.ServeJSON()
  237. }()
  238. sysUser := c.SysUser
  239. if sysUser == nil {
  240. br.Msg = "请登录"
  241. br.ErrMsg = "请登录,SysUser Is Empty"
  242. return
  243. }
  244. pageSize, _ := c.GetInt("PageSize")
  245. currentIndex, _ := c.GetInt("CurrentIndex")
  246. keyWord := c.GetString("KeyWord")
  247. var startSize int
  248. if pageSize <= 0 {
  249. pageSize = utils.PageSize20
  250. }
  251. if currentIndex <= 0 {
  252. currentIndex = 1
  253. }
  254. startSize = utils.StartIndex(currentIndex, pageSize)
  255. var condition string
  256. var pars []interface{}
  257. if keyWord != "" {
  258. condition += fmt.Sprintf(` AND %s like ?`, rag.WechatPlatformColumns.Nickname)
  259. pars = append(pars, `%`+keyWord+`%`)
  260. }
  261. obj := new(rag.WechatPlatformUserMapping)
  262. list, err := obj.GetListByCondition(condition, pars, startSize, 100000)
  263. if err != nil {
  264. br.Msg = "获取失败"
  265. br.ErrMsg = "获取失败,Err:" + err.Error()
  266. return
  267. }
  268. resp := make([]response.WechatPlatformPublicListResp, 0)
  269. if list != nil && len(list) > 0 {
  270. userIdList := make([]int, 0)
  271. uerIdMap := make(map[int]bool)
  272. userFollowIndexMap := make(map[int]int)
  273. for _, v := range list {
  274. if _, ok := uerIdMap[v.FollowUserId]; !ok {
  275. userIdList = append(userIdList, v.FollowUserId)
  276. uerIdMap[v.FollowUserId] = true
  277. }
  278. index, ok := userFollowIndexMap[v.FollowUserId]
  279. if !ok {
  280. userFollowIndexMap[v.FollowUserId] = len(resp)
  281. resp = append(resp, response.WechatPlatformPublicListResp{
  282. UserId: v.FollowUserId,
  283. List: []*rag.UserFollowWechatPlatform{v},
  284. })
  285. } else {
  286. resp[index].List = append(resp[index].List, v)
  287. }
  288. }
  289. userList, err := system.GetAdminListByIdList(userIdList)
  290. if err != nil {
  291. br.Msg = "获取失败"
  292. br.ErrMsg = "获取失败,Err:" + err.Error()
  293. return
  294. }
  295. userNameMap := make(map[int]*system.Admin)
  296. for _, v := range userList {
  297. userNameMap[v.AdminId] = v
  298. }
  299. for k, v := range resp {
  300. userInfo, ok := userNameMap[v.UserId]
  301. if !ok {
  302. continue
  303. }
  304. resp[k].Name = userInfo.RealName + `关注`
  305. }
  306. }
  307. br.Ret = 200
  308. br.Success = true
  309. br.Msg = "获取成功"
  310. br.Data = resp
  311. }
  312. // PublicList
  313. // @Title 公共列表
  314. // @Description 公共列表
  315. // @Param PageSize query int true "每页数据条数"
  316. // @Param CurrentIndex query int true "当前页页码,从1开始"
  317. // @Param KeyWord query string true "搜索关键词"
  318. // @Success 200 {object} models.WechatPlatformListResp
  319. // @router /wechat_platform/op [post]
  320. func (c *WechatPlatformController) Op() {
  321. br := new(models.BaseResponse).Init()
  322. defer func() {
  323. c.Data["json"] = br
  324. c.ServeJSON()
  325. }()
  326. sysUser := c.SysUser
  327. if sysUser == nil {
  328. br.Msg = "请登录"
  329. br.ErrMsg = "请登录,SysUser Is Empty"
  330. return
  331. }
  332. var req request.OpWechatPlatformReq
  333. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  334. if err != nil {
  335. br.Msg = "参数解析异常!"
  336. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  337. return
  338. }
  339. if req.WechatPlatformId <= 0 {
  340. br.Msg = "参数错误"
  341. return
  342. }
  343. if req.Status < 0 || req.Status > 1 {
  344. br.Msg = "参数错误"
  345. return
  346. }
  347. obj := rag.WechatPlatform{}
  348. wechatPlatform, err := obj.GetById(req.WechatPlatformId)
  349. if err != nil {
  350. br.Msg = "修改失败"
  351. br.ErrMsg = "修改失败,Err:" + err.Error()
  352. if utils.IsErrNoRow(err) {
  353. br.Msg = "公众号不存在"
  354. br.IsSendEmail = false
  355. }
  356. return
  357. }
  358. wechatPlatform.Enabled = req.Status
  359. wechatPlatform.ModifyTime = time.Now()
  360. err = wechatPlatform.Update([]string{"enabled", `modify_time`})
  361. if err != nil {
  362. br.Msg = "修改失败"
  363. br.ErrMsg = "修改失败,Err:" + err.Error()
  364. return
  365. }
  366. // 异步处理公众号下面的文章
  367. go services.AddOrEditEsWechatPlatformId(wechatPlatform.WechatPlatformId)
  368. br.Ret = 200
  369. br.Success = true
  370. br.Msg = "修改成功"
  371. }
  372. // Refresh
  373. // @Title 公共列表
  374. // @Description 公共列表
  375. // @Success 200 {object} models.WechatPlatformListResp
  376. // @router /wechat_platform/refresh [post]
  377. func (c *WechatPlatformController) Refresh() {
  378. br := new(models.BaseResponse).Init()
  379. defer func() {
  380. c.Data["json"] = br
  381. c.ServeJSON()
  382. }()
  383. sysUser := c.SysUser
  384. if sysUser == nil {
  385. br.Msg = "请登录"
  386. br.ErrMsg = "请登录,SysUser Is Empty"
  387. return
  388. }
  389. var req request.RefreshWechatPlatformReq
  390. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  391. if err != nil {
  392. br.Msg = "参数解析异常!"
  393. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  394. return
  395. }
  396. if req.WechatPlatformId <= 0 {
  397. br.Msg = "参数错误"
  398. return
  399. }
  400. obj := rag.WechatPlatform{}
  401. wechatPlatform, err := obj.GetById(req.WechatPlatformId)
  402. if err != nil {
  403. br.Msg = "修改失败"
  404. br.ErrMsg = "修改失败,Err:" + err.Error()
  405. if utils.IsErrNoRow(err) {
  406. br.Msg = "公众号不存在"
  407. br.IsSendEmail = false
  408. }
  409. return
  410. }
  411. if wechatPlatform.FakeId != `` {
  412. br.Msg = "公众号已添加成功"
  413. br.ErrMsg = "公众号已添加成功"
  414. br.IsSendEmail = false
  415. return
  416. }
  417. go cache.AddWechatArticleOpToCache(wechatPlatform.WechatPlatformId, `add`)
  418. br.Ret = 200
  419. br.Success = true
  420. br.Msg = "刷新成功"
  421. }
  422. // ArticleList
  423. // @Title 我关注的接口
  424. // @Description 我关注的接口
  425. // @Param PageSize query int true "每页数据条数"
  426. // @Param CurrentIndex query int true "当前页页码,从1开始"
  427. // @Param WechatPlatformId query int true "微信公众号id"
  428. // @Param KeyWord query string true "搜索关键词"
  429. // @Success 200 {object} []*rag.WechatPlatform
  430. // @router /wechat_platform/article/list [get]
  431. func (c *WechatPlatformController) ArticleList() {
  432. br := new(models.BaseResponse).Init()
  433. defer func() {
  434. c.Data["json"] = br
  435. c.ServeJSON()
  436. }()
  437. sysUser := c.SysUser
  438. if sysUser == nil {
  439. br.Msg = "请登录"
  440. br.ErrMsg = "请登录,SysUser Is Empty"
  441. return
  442. }
  443. pageSize, _ := c.GetInt("PageSize")
  444. currentIndex, _ := c.GetInt("CurrentIndex")
  445. wechatPlatformId, _ := c.GetInt("WechatPlatformId")
  446. keyWord := c.GetString("KeyWord")
  447. var startSize int
  448. if pageSize <= 0 {
  449. pageSize = utils.PageSize20
  450. }
  451. if currentIndex <= 0 {
  452. currentIndex = 1
  453. }
  454. startSize = utils.StartIndex(currentIndex, pageSize)
  455. var condition string
  456. var pars []interface{}
  457. if keyWord != "" {
  458. condition += fmt.Sprintf(` AND (b.%s like ? or a.%s like ? ) `, rag.WechatPlatformColumns.Nickname, rag.WechatArticleColumns.Title)
  459. pars = append(pars, `%`+keyWord+`%`, `%`+keyWord+`%`)
  460. }
  461. if wechatPlatformId > 0 {
  462. condition += fmt.Sprintf(` AND a.%s = ?`, rag.WechatArticleColumns.WechatPlatformID)
  463. pars = append(pars, wechatPlatformId)
  464. }
  465. condition += fmt.Sprintf(` AND b.%s = ? `, rag.WechatPlatformColumns.Enabled)
  466. pars = append(pars, 1)
  467. obj := new(rag.WechatArticle)
  468. total, list, err := obj.GetPageListByPlatformCondition(condition, pars, startSize, pageSize)
  469. if err != nil {
  470. br.Msg = "获取失败"
  471. br.ErrMsg = "获取失败,Err:" + err.Error()
  472. return
  473. }
  474. viewList := make([]rag.WechatArticleView, 0)
  475. if list != nil && len(list) > 0 {
  476. viewList = obj.ArticleAndPlatformListToViewList(list)
  477. }
  478. page := paging.GetPaging(currentIndex, pageSize, total)
  479. resp := response.WechatArticleListListResp{
  480. List: viewList,
  481. Paging: page,
  482. }
  483. br.Ret = 200
  484. br.Success = true
  485. br.Msg = "获取成功"
  486. br.Data = resp
  487. }
  488. // ArticleList
  489. // @Title 我关注的接口
  490. // @Description 我关注的接口
  491. // @Param WechatArticleId query int true "文章id"
  492. // @Success 200 {object} []*rag.WechatArticle
  493. // @router /wechat_platform/article/detail [get]
  494. func (c *WechatPlatformController) ArticleDetail() {
  495. br := new(models.BaseResponse).Init()
  496. defer func() {
  497. c.Data["json"] = br
  498. c.ServeJSON()
  499. }()
  500. sysUser := c.SysUser
  501. if sysUser == nil {
  502. br.Msg = "请登录"
  503. br.ErrMsg = "请登录,SysUser Is Empty"
  504. return
  505. }
  506. wechatArticleId, _ := c.GetInt("WechatArticleId")
  507. if wechatArticleId <= 0 {
  508. br.Msg = "请选择文章"
  509. br.IsSendEmail = false
  510. return
  511. }
  512. obj := new(rag.WechatArticle)
  513. item, err := obj.GetById(wechatArticleId)
  514. if err != nil {
  515. br.Msg = "获取失败"
  516. br.ErrMsg = "获取失败,Err:" + err.Error()
  517. return
  518. }
  519. if item.IsDeleted == 1 {
  520. br.Msg = "文章已删除"
  521. br.IsSendEmail = false
  522. return
  523. }
  524. resp := item.ToView()
  525. resp.Content = html.UnescapeString(item.Content)
  526. // 获取摘要信息
  527. {
  528. abstractObj := rag.WechatArticleAbstract{}
  529. abstractItem, err := abstractObj.GetByWechatArticleId(wechatArticleId)
  530. if err != nil && !utils.IsErrNoRow(err) {
  531. br.Msg = "获取失败"
  532. br.ErrMsg = "获取失败,Err:" + err.Error()
  533. return
  534. }
  535. resp.Abstract = abstractItem.Content
  536. }
  537. br.Ret = 200
  538. br.Success = true
  539. br.Msg = "获取成功"
  540. br.Data = resp
  541. }
  542. // ArticleList
  543. // @Title 我关注的接口
  544. // @Description 我关注的接口
  545. // @Param WechatArticleId query int true "文章id"
  546. // @Success 200 {object} []*rag.WechatPlatform
  547. // @router /wechat_platform/article/del [get]
  548. func (c *WechatPlatformController) ArticleDel() {
  549. br := new(models.BaseResponse).Init()
  550. defer func() {
  551. c.Data["json"] = br
  552. c.ServeJSON()
  553. }()
  554. sysUser := c.SysUser
  555. if sysUser == nil {
  556. br.Msg = "请登录"
  557. br.ErrMsg = "请登录,SysUser Is Empty"
  558. return
  559. }
  560. wechatArticleId, _ := c.GetInt("WechatArticleId")
  561. if wechatArticleId <= 0 {
  562. br.Msg = "请选择文章"
  563. br.IsSendEmail = false
  564. return
  565. }
  566. obj := new(rag.WechatArticle)
  567. item, err := obj.GetById(wechatArticleId)
  568. if err != nil {
  569. br.Msg = "获取失败"
  570. br.ErrMsg = "获取失败,Err:" + err.Error()
  571. return
  572. }
  573. if item.IsDeleted == 1 {
  574. br.Msg = "文章已删除"
  575. br.IsSendEmail = false
  576. return
  577. }
  578. item.IsDeleted = 1
  579. err = item.Update([]string{"is_deleted"})
  580. if err != nil {
  581. br.Msg = "删除失败"
  582. br.ErrMsg = "删除失败,Err:" + err.Error()
  583. return
  584. }
  585. // 修改ES信息
  586. services.AddOrEditEsWechatArticle(item.WechatArticleId)
  587. br.Ret = 200
  588. br.Success = true
  589. br.Msg = "删除成功"
  590. }
  591. //func init() {
  592. // //obj := rag.WechatPlatform{}
  593. // //item, _ := obj.GetByID(2)
  594. // //fmt.Println(llm.BeachAddWechatPlatform(item))
  595. //
  596. // obj := rag.WechatArticle{}
  597. // //item, _ := obj.GetById(30)
  598. // list, _ := obj.GetListByCondition(``, ` `, []interface{}{}, 0, 1000)
  599. // //llm.ArticleToTmpFile(item.TextContent)
  600. // for _, item := range list {
  601. // //llm.ArticleToKnowledge(item)
  602. // llm.GenerateArticleAbstract(item)
  603. // }
  604. //}
  605. //func init() {
  606. // //obj := rag.WechatPlatform{}
  607. // //item, _ := obj.GetByID(2)
  608. // //fmt.Println(llm.BeachAddWechatPlatform(item))
  609. //
  610. // //obj := rag.WechatArticle{}
  611. // //list, _ := obj.GetListByCondition(`wechat_article_id,content`, ` `, []interface{}{}, 0, 1)
  612. // ////obj := rag.WechatPlatform{}
  613. // ////list, _ := obj.GetListByCondition(` AND wechat_platform_id !=1 `, []interface{}{}, 0, 100)
  614. // ////llm.ArticleToTmpFile(item.TextContent)
  615. // //for _, item := range list {
  616. // // //llm.ArticleToKnowledge(item)
  617. // // services.ReGenerateArticleAbstract(item)
  618. // //}
  619. //
  620. // // 重新生成摘要
  621. // {
  622. // obj := rag.WechatArticle{}
  623. // list, _ := obj.GetListByCondition(``, ` AND text_content !='' AND abstract_status = 0`, []interface{}{}, 0, 300)
  624. // for _, item := range list {
  625. // services.GenerateArticleAbstract(item)
  626. // }
  627. // }
  628. //
  629. // //// 删除摘要向量库
  630. // //{
  631. // // obj := rag.WechatArticleAbstract{}
  632. // // list, _ := obj.GetListByCondition(`vector_key,wechat_article_abstract_id`, ` AND wechat_article_id in (25,27) `, []interface{}{}, 0, 10000)
  633. // // fmt.Println(services.DelDoc(list))
  634. // //}
  635. //
  636. // fmt.Println("修复结束")
  637. //}
  638. //func init() {
  639. // // 微信文章加到es
  640. // {
  641. // obj := rag.WechatArticle{}
  642. // list, _ := obj.GetListByCondition(` wechat_article_id `, ` `, []interface{}{}, 0, 1000)
  643. // total := len(list)
  644. // for k, item := range list {
  645. // fmt.Println(k, "/", total)
  646. // services.AddOrEditEsWechatArticle(item.WechatArticleId)
  647. // }
  648. //
  649. // fmt.Println("结束了")
  650. // }
  651. //}