yanxuan_special.go 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_web_mfyx/models"
  6. "hongze/hongze_web_mfyx/services"
  7. "hongze/hongze_web_mfyx/utils"
  8. "path"
  9. "strconv"
  10. "strings"
  11. "time"
  12. )
  13. type YanxuanSpecialController struct {
  14. BaseAuthController
  15. }
  16. type YanxuanSpecialNoLoginController struct {
  17. BaseAuthMobileController
  18. }
  19. // @Title 专栏列表
  20. // @Description 专栏列表
  21. // @Param SpecialColumnId query int true "作者专栏ID"
  22. // @Param PageSize query int true "每页数据条数"
  23. // @Param CurrentIndex query int true "当前页页码,从1开始"
  24. // @Success 200 {object} models.AddEnglishReportResp
  25. // @router /list [get]
  26. func (this *YanxuanSpecialNoLoginController) List() {
  27. br := new(models.BaseResponse).Init()
  28. defer func() {
  29. this.Data["json"] = br
  30. this.ServeJSON()
  31. }()
  32. sysUser := this.User
  33. if sysUser == nil {
  34. br.Msg = "请登录"
  35. br.ErrMsg = "请登录,SysUser Is Empty"
  36. br.Ret = 408
  37. return
  38. }
  39. specialColumnId, _ := this.GetInt("SpecialColumnId", 0)
  40. pageSize, _ := this.GetInt("PageSize")
  41. currentIndex, _ := this.GetInt("CurrentIndex")
  42. var startSize int
  43. if pageSize <= 0 {
  44. pageSize = utils.PageSize20
  45. }
  46. if currentIndex <= 0 {
  47. currentIndex = 1
  48. }
  49. startSize = utils.StartIndex(currentIndex, pageSize)
  50. resp := new(models.SpecialListResp)
  51. var condition string
  52. var pars []interface{}
  53. if specialColumnId > 0 {
  54. authorItem, err := models.GetYanxuanSpecialAuthorById(specialColumnId)
  55. if err != nil {
  56. br.Msg = "查询栏目详情失败!"
  57. br.ErrMsg = "查询栏目详情失败,Err:" + err.Error()
  58. return
  59. }
  60. condition += ` AND a.user_id = ? `
  61. pars = append(pars, authorItem.UserId)
  62. }
  63. condition += ` AND a.status = 3 `
  64. total, err := models.GetCygxYanxuanSpecialCount(condition, pars)
  65. if err != nil {
  66. br.Msg = "获取失败"
  67. br.ErrMsg = "获取失败, Err:" + err.Error()
  68. return
  69. }
  70. list, err := models.GetYanxuanSpecialList(sysUser.UserId, condition, pars, startSize, pageSize)
  71. if err != nil {
  72. br.Msg = "获取失败"
  73. br.ErrMsg = "获取失败, Err:" + err.Error()
  74. return
  75. }
  76. var yanxuanSpecialIds []int
  77. for _, v := range list {
  78. yanxuanSpecialIds = append(yanxuanSpecialIds, v.Id)
  79. }
  80. yanxuanSpecialPv := services.GetYanxuanSpecialRecordByYanxuanSpecialId(yanxuanSpecialIds)
  81. for _, v := range list {
  82. hasImg, err := utils.ArticleHasImgUrl(v.Content)
  83. if err != nil {
  84. return
  85. }
  86. if hasImg {
  87. v.ContentHasImg = 1
  88. }
  89. v.ImgUrl = strings.TrimRight(v.ImgUrl, ",")
  90. //去除图片标签
  91. v.Content = utils.ArticleRemoveImgUrl(v.Content)
  92. //v.Content, err = utils.ExtractText(v.Content)
  93. if v.DocUrl != "" {
  94. var docs []models.Doc
  95. err := json.Unmarshal([]byte(v.DocUrl), &docs)
  96. if err != nil {
  97. br.Msg = "参数解析异常!"
  98. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  99. return
  100. }
  101. v.Docs = docs
  102. }
  103. if v.MyCollectNum > 0 {
  104. v.IsCollect = 1
  105. }
  106. if v.ImgUrl != "" {
  107. imgList := strings.Split(v.ImgUrl, ",")
  108. for _, s := range imgList {
  109. v.ImgUrlList = append(v.ImgUrlList, s)
  110. }
  111. } else {
  112. v.ImgUrlList = []string{}
  113. }
  114. if v.CompanyTags != "" {
  115. tagList := strings.Split(v.CompanyTags, ",")
  116. for _, s := range tagList {
  117. v.TagList = append(v.TagList, s)
  118. }
  119. }
  120. if v.IndustryTags != "" {
  121. tagList := strings.Split(v.IndustryTags, ",")
  122. for _, s := range tagList {
  123. v.TagList = append(v.TagList, s)
  124. }
  125. }
  126. if len(v.TagList) == 0 {
  127. v.TagList = []string{}
  128. }
  129. v.Pv = yanxuanSpecialPv[v.Id]
  130. }
  131. specialAuthorCheck := services.GetYanxuanSpecialAuthorInfo(sysUser) //用户是否没开通研选专栏以及,专栏信息是否完善
  132. resp.IsAuthor = specialAuthorCheck.IsAuthor
  133. resp.IsImproveInformation = specialAuthorCheck.IsImproveInformation
  134. resp.List = list
  135. page := paging.GetPaging(currentIndex, pageSize, total)
  136. resp.Paging = page
  137. br.Data = resp
  138. br.Ret = 200
  139. br.Success = true
  140. br.Msg = "获取成功"
  141. }
  142. // @Title 专栏详情
  143. // @Description 专栏详情
  144. // @Param request body help_doc.AddHelpDocReq true "type json string"
  145. // @Param InviteShareCode query string false "销售账号邀请码"
  146. // @Success 200 {object} models.AddEnglishReportResp
  147. // @router /detail [get]
  148. func (this *YanxuanSpecialNoLoginController) Detail() {
  149. br := new(models.BaseResponse).Init()
  150. defer func() {
  151. this.Data["json"] = br
  152. this.ServeJSON()
  153. }()
  154. sysUser := this.User
  155. if sysUser == nil {
  156. br.Msg = "请登录"
  157. br.ErrMsg = "请登录,SysUser Is Empty"
  158. br.Ret = 408
  159. return
  160. }
  161. specialId, _ := this.GetInt("Id", 0)
  162. inviteShareCode := this.GetString("InviteShareCode")
  163. if specialId <= 0 {
  164. br.Msg = "参数错误"
  165. br.ErrMsg = "参数错误"
  166. return
  167. }
  168. item, tmpErr := models.GetYanxuanSpecialById(specialId, sysUser.UserId)
  169. if tmpErr != nil {
  170. br.Msg = "获取失败"
  171. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  172. return
  173. }
  174. //记录分享来源
  175. if inviteShareCode != "" {
  176. go services.AddCygxUserAdminShareHistory(sysUser, utils.CYGX_OBJ_YANXUANSPECIAL, item.Title, inviteShareCode, specialId)
  177. }
  178. if item.MyCollectNum > 0 {
  179. item.IsCollect = 1
  180. }
  181. var resp models.CygxYanxuanSpecialResp
  182. resp.HasPermission = 1
  183. resp.CygxYanxuanSpecialItem = *item
  184. if item.DocUrl != "" {
  185. var docs []models.Doc
  186. err := json.Unmarshal([]byte(item.DocUrl), &docs)
  187. if err != nil {
  188. br.Msg = "参数解析异常!"
  189. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  190. return
  191. }
  192. resp.Docs = docs
  193. }
  194. if item.ImgUrl != "" {
  195. imgList := strings.Split(item.ImgUrl, ",")
  196. for _, s := range imgList {
  197. resp.ImgUrlList = append(resp.ImgUrlList, s)
  198. }
  199. } else {
  200. resp.ImgUrlList = []string{}
  201. }
  202. if item.CompanyTags != "" {
  203. cTagList := strings.Split(item.CompanyTags, ",")
  204. for _, s := range cTagList {
  205. resp.CompanyTags = append(resp.CompanyTags, s)
  206. }
  207. } else {
  208. resp.CompanyTags = []string{}
  209. }
  210. if item.IndustryTags != "" {
  211. iTagList := strings.Split(item.IndustryTags, ",")
  212. for _, s := range iTagList {
  213. resp.IndustryTags = append(resp.IndustryTags, s)
  214. }
  215. } else {
  216. resp.IndustryTags = []string{}
  217. }
  218. var configCode string
  219. //如果是研选的就推送给汪洋跟王芳,否则就推送给王芳
  220. configCode = utils.TPL_MSG_YAN_XUAN_SPECIAL_APPROVAL
  221. cnf, err := models.GetConfigByCode(configCode)
  222. if err != nil {
  223. br.Msg = "获取失败"
  224. br.ErrMsg = "获取失败, Err:" + err.Error()
  225. return
  226. }
  227. if item.UserId != sysUser.UserId && item.Status != 3 && !strings.Contains(cnf.ConfigValue, sysUser.Mobile) {
  228. resp.CygxYanxuanSpecialItem = *new(models.CygxYanxuanSpecialItem) // 如果内容不可见,就把内容置空
  229. resp.CygxYanxuanSpecialItem.Status = item.Status
  230. //resp.HasPermission = 2
  231. }
  232. //如果是用户本人写的专栏,那么就不做校验
  233. //if item.UserId == sysUser.UserId || sysUser.UserId == 0 {
  234. // resp.HasPermission = 1
  235. //} else {
  236. // hasPermission, err := services.GetUserRaiPermissionYanXuanInfo(sysUser)
  237. // if err != nil {
  238. // br.Msg = "获取失败"
  239. // br.ErrMsg = "获取失败, Err:" + err.Error()
  240. // return
  241. // }
  242. // resp.HasPermission = hasPermission
  243. //}
  244. //判断是否属于审核人员
  245. mobileSlice := strings.Split(cnf.ConfigValue, ",")
  246. for _, v := range mobileSlice {
  247. if v == sysUser.Mobile {
  248. resp.IsApprovalAdmin = true
  249. }
  250. }
  251. fllowNum, err := models.GetCygxYanxuanSpecialFollowCountByUser(sysUser.UserId, item.UserId)
  252. if err != nil {
  253. br.Msg = "获取失败"
  254. br.ErrMsg = "获取是否关注作者失败, Err:" + err.Error()
  255. return
  256. }
  257. if fllowNum == 1 {
  258. resp.IsFollowAuthor = true
  259. }
  260. //
  261. //if resp.HasPermission != 1 || sysUser.UserId == 0 {
  262. // resp.Content = utils.InterceptHtmlLength(resp.Content, 240)
  263. //}
  264. //resp.ShareImg = utils.YANXUAN_SPECIAL_SHARE_IMG
  265. resp.ShareImg = resp.HeadImg
  266. br.Data = resp
  267. br.Ret = 200
  268. br.Success = true
  269. br.Msg = "获取成功"
  270. }
  271. // @Title 新增保存专栏作者详情
  272. // @Description 新增保存专栏作者详情
  273. // @Param request body help_doc.AddHelpDocReq true "type json string"
  274. // @Success 200 {object} models.AddEnglishReportResp
  275. // @router /author/save [post]
  276. func (this *YanxuanSpecialController) AuthorSave() {
  277. br := new(models.BaseResponse).Init()
  278. defer func() {
  279. this.Data["json"] = br
  280. this.ServeJSON()
  281. }()
  282. sysUser := this.User
  283. if sysUser == nil {
  284. br.Msg = "请登录"
  285. br.ErrMsg = "请登录,SysUser Is Empty"
  286. br.Ret = 408
  287. return
  288. }
  289. var req models.SaveCygxYanxuanSpecialAuthorReq
  290. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  291. if err != nil {
  292. br.Msg = "参数解析异常!"
  293. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  294. return
  295. }
  296. if req.SpecialColumnId <= 0 {
  297. br.Msg = "栏目id有误"
  298. return
  299. }
  300. if req.SpecialName == "" {
  301. br.Msg = "请输入专栏名称"
  302. return
  303. }
  304. if req.NickName == "" {
  305. br.Msg = "请输入昵称"
  306. return
  307. }
  308. item := models.CygxYanxuanSpecialAuthor{
  309. Id: req.SpecialColumnId,
  310. UserId: sysUser.UserId,
  311. SpecialName: req.SpecialName,
  312. Introduction: req.Introduction,
  313. Label: req.Label,
  314. NickName: req.NickName,
  315. CreateTime: time.Now(),
  316. ModifyTime: time.Now(),
  317. BgImg: "",
  318. Status: 1,
  319. }
  320. //if req.Id == 0{
  321. // _, err = models.AddCygxYanxuanSpecialAuthor(&item)
  322. // if err != nil {
  323. // br.Msg = "新增失败"
  324. // br.ErrMsg = "新增失败,Err:" + err.Error()
  325. // return
  326. // }
  327. //} else {
  328. // err = models.UpdateYanxuanSpecialAuthor(&item)
  329. // if err != nil {
  330. // br.Msg = "保存失败"
  331. // br.ErrMsg = "保存失败,Err:" + err.Error()
  332. // return
  333. // }
  334. //}
  335. err = models.UpdateYanxuanSpecialAuthor(&item)
  336. if err != nil {
  337. br.Msg = "保存失败"
  338. br.ErrMsg = "保存失败,Err:" + err.Error()
  339. return
  340. }
  341. br.Ret = 200
  342. br.Success = true
  343. br.Msg = "保存成功"
  344. }
  345. // @Title 新增保存专栏
  346. // @Description 新增保存专栏
  347. // @Param request body help_doc.AddHelpDocReq true "type json string"
  348. // @Success 200 {object} models.AddEnglishReportResp
  349. // @router /save [post]
  350. func (this *YanxuanSpecialController) Save() {
  351. br := new(models.BaseResponse).Init()
  352. defer func() {
  353. this.Data["json"] = br
  354. this.ServeJSON()
  355. }()
  356. sysUser := this.User
  357. if sysUser == nil {
  358. br.Msg = "请登录"
  359. br.ErrMsg = "请登录,SysUser Is Empty"
  360. br.Ret = 408
  361. return
  362. }
  363. var req models.CygxYanxuanSpecialReq
  364. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  365. if err != nil {
  366. br.Msg = "参数解析异常!"
  367. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  368. return
  369. }
  370. if req.Content == "" && req.DoType == 2 {
  371. br.Msg = "请输入内容"
  372. return
  373. }
  374. if len(req.CompanyTags) == 0 && len(req.IndustryTags) == 0 && req.DoType == 2 {
  375. br.Msg = "请至少输入一个标签"
  376. return
  377. }
  378. if len(req.Docs) > 0 {
  379. for i, doc := range req.Docs {
  380. extMap := services.GetCloudDiskResourceFileTypeExtMap()
  381. ext := path.Ext(doc.DocName)
  382. req.Docs[i].DocIcon = extMap[ext]
  383. }
  384. }
  385. docUrl, err := json.Marshal(req.Docs)
  386. if err != nil {
  387. return
  388. }
  389. imgUrls := strings.Join(req.ImgUrl, ",")
  390. cTags := strings.Join(req.CompanyTags, ",")
  391. iTags := strings.Join(req.IndustryTags, ",")
  392. isApprovalPersonnel := req.IsApprovalPersonnel
  393. item := models.CygxYanxuanSpecial{
  394. Id: req.Id,
  395. UserId: sysUser.UserId,
  396. CreateTime: time.Now(),
  397. ModifyTime: time.Now(),
  398. PublishTime: time.Now(),
  399. Content: req.Content,
  400. CompanyTags: cTags,
  401. IndustryTags: iTags,
  402. ImgUrl: imgUrls,
  403. DocUrl: string(docUrl),
  404. Title: req.Title,
  405. Type: req.Type,
  406. }
  407. if req.DoType == 1 {
  408. item.Status = 1
  409. br.Msg = "保存成功"
  410. } else {
  411. item.Status = 2
  412. br.Msg = "已提交审核"
  413. }
  414. var authorUserId int
  415. // 如果是审批人员操作的那么就是修改内容,加审批通过
  416. if isApprovalPersonnel {
  417. item.Status = 3
  418. //校验是否属于审核人员
  419. if !services.CheckYxSpecialIsApprovalPersonnel(sysUser.Mobile) {
  420. br.Msg = "操作失败"
  421. br.ErrMsg = "操作失败,该账号不属于审核人员:" + sysUser.Mobile
  422. return
  423. }
  424. specialItem, err := models.GetYanxuanSpecialItemById(req.Id)
  425. if err != nil {
  426. br.Msg = "保存失败"
  427. br.ErrMsg = "保存失败,Err:" + err.Error()
  428. return
  429. }
  430. item.UserId = specialItem.UserId // 专栏userid还是原有userId
  431. authorUserId = specialItem.UserId
  432. item.AdminName = sysUser.RealName //审核人员姓名
  433. br.Msg = "审批成功"
  434. }
  435. specialId := 0
  436. if req.Id == 0 {
  437. id, err := models.AddCygxYanxuanSpecial(&item)
  438. if err != nil {
  439. br.Msg = "新增失败"
  440. br.ErrMsg = "新增失败,Err:" + err.Error()
  441. return
  442. }
  443. specialId = int(id)
  444. } else {
  445. detail, tmpErr := models.GetYanxuanSpecialById(req.Id, sysUser.UserId)
  446. if tmpErr != nil {
  447. br.Msg = "获取失败"
  448. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  449. return
  450. }
  451. if detail.Status == 2 && !isApprovalPersonnel {
  452. br.Msg = "请勿重复提交"
  453. br.ErrMsg = "保存失败,专栏内容正在审核"
  454. return
  455. }
  456. err = models.UpdateYanxuanSpecial(&item)
  457. if err != nil {
  458. br.Msg = "保存失败"
  459. br.ErrMsg = "保存失败,Err:" + err.Error()
  460. return
  461. }
  462. specialId = req.Id
  463. }
  464. if isApprovalPersonnel {
  465. go services.UpdateYanxuanSpecialResourceData(specialId) // 写入首页最新 cygx_resource_data 表
  466. go services.EsAddYanxuanSpecial(specialId) // 写入es 综合搜索
  467. go services.SendWxMsgSpecialFollow(req.Id) //研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
  468. go services.SendWxMsgSpecialAuthor(req.Id, 1) //研选专栏审核完成时,给提交人发送模板消息
  469. go services.UdpateYanxuanSpecialauthorArticleNum(authorUserId) // 更新作者发布文章的数量
  470. go services.SendWxCategoryMsgSpecialAuthor(req.Id, 1) //研选专栏审核完成时,给提交人发送类目模板消息
  471. go services.SendWxCategoryMsgSpecialFollow(req.Id) // 研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
  472. } else {
  473. if req.DoType == 2 {
  474. go services.SendReviewTemplateMsgAdmin(specialId)
  475. go services.SendReviewCategoryTemplateMsgAdmin(specialId)
  476. go services.UpdateYanxuanSpecialResourceData(specialId) // 写入首页最新 cygx_resource_data 表
  477. go services.EsAddYanxuanSpecial(specialId) // 写入es 综合搜索
  478. }
  479. }
  480. br.Ret = 200
  481. br.Success = true
  482. br.Data = specialId
  483. }
  484. // @Title 专栏作者详情
  485. // @Description 专栏作者详情
  486. // @Param request body help_doc.AddHelpDocReq true "type json string"
  487. // @Success 200 {object} models.AddEnglishReportResp
  488. // @router /author/detail [get]
  489. func (this *YanxuanSpecialNoLoginController) AuthorDetail() {
  490. br := new(models.BaseResponse).Init()
  491. defer func() {
  492. this.Data["json"] = br
  493. this.ServeJSON()
  494. }()
  495. sysUser := this.User
  496. if sysUser == nil {
  497. br.Msg = "请登录"
  498. br.ErrMsg = "请登录,SysUser Is Empty"
  499. br.Ret = 408
  500. return
  501. }
  502. specialColumnId, _ := this.GetInt("SpecialColumnId", 0)
  503. item, tmpErr := models.GetYanxuanSpecialAuthorBySpecialColumnId(specialColumnId, sysUser.UserId)
  504. if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
  505. br.Msg = "获取失败"
  506. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  507. return
  508. }
  509. if item.IsFollow > 0 {
  510. item.IsFollow = 1
  511. }
  512. br.Data = item
  513. br.Ret = 200
  514. br.Success = true
  515. br.Msg = "获取成功"
  516. }
  517. // @Title 审批研选专栏
  518. // @Description 审批研选专栏
  519. // @Param request body help_doc.AddHelpDocReq true "type json string"
  520. // @Success 200 {object} models.AddEnglishReportResp
  521. // @router /enable [post]
  522. func (this *YanxuanSpecialController) Enable() {
  523. br := new(models.BaseResponse).Init()
  524. defer func() {
  525. this.Data["json"] = br
  526. this.ServeJSON()
  527. }()
  528. user := this.User
  529. if user == nil {
  530. br.Msg = "请登录"
  531. br.ErrMsg = "请登录,SysUser Is Empty"
  532. br.Ret = 408
  533. return
  534. }
  535. var req models.EnableCygxYanxuanSpecialReq
  536. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  537. if err != nil {
  538. br.Msg = "参数解析异常!"
  539. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  540. return
  541. }
  542. if req.Id <= 0 {
  543. br.Msg = "文章id错误"
  544. return
  545. }
  546. if req.Status <= 0 {
  547. br.Msg = "参数错误"
  548. return
  549. }
  550. status := 0
  551. if req.Status == 1 {
  552. status = 3
  553. } else {
  554. status = 4
  555. }
  556. detail, err := models.GetYanxuanSpecialItemById(req.Id)
  557. if err != nil {
  558. br.Msg = "审批失败"
  559. br.ErrMsg = "审批失败, Err:" + err.Error()
  560. return
  561. }
  562. if tmpErr := models.EnableYanxuanSpecial(req.Id, status, req.Reason, user.RealName); tmpErr != nil {
  563. br.Msg = "审批失败"
  564. br.ErrMsg = "审批失败, Err:" + tmpErr.Error()
  565. return
  566. }
  567. if req.Status == 1 {
  568. go services.SendWxMsgSpecialFollow(req.Id)
  569. go services.SendWxCategoryMsgSpecialAuthor(req.Id, 1) //研选专栏审核完成时,给提交人发送类目模板消息
  570. go services.SendWxCategoryMsgSpecialFollow(req.Id) // 研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
  571. } else {
  572. go services.SendWxCategoryMsgSpecialAuthor(req.Id, 2)
  573. }
  574. go services.SendWxMsgSpecialAuthor(req.Id, req.Status)
  575. go services.UpdateYanxuanSpecialResourceData(req.Id) // 写入首页最新 cygx_resource_data 表
  576. go services.EsAddYanxuanSpecial(req.Id) // 写入es 综合搜索
  577. go services.AddAddCygxYanxuanSpecialApprovalLog(user, req.Id, req.Status, req.Reason) // 写入es 综合搜索
  578. go services.UdpateYanxuanSpecialauthorArticleNum(detail.UserId) // 更新作者发布文章的数量
  579. br.Msg = "审批成功"
  580. br.Ret = 200
  581. br.Success = true
  582. }
  583. // @Title 研选专栏收藏
  584. // @Description 研选专栏收藏
  585. // @Param request body help_doc.AddHelpDocReq true "type json string"
  586. // @Success 200 {object} models.AddEnglishReportResp
  587. // @router /collect [post]
  588. func (this *YanxuanSpecialController) Collect() {
  589. br := new(models.BaseResponse).Init()
  590. defer func() {
  591. this.Data["json"] = br
  592. this.ServeJSON()
  593. }()
  594. user := this.User
  595. if user == nil {
  596. br.Msg = "请登录"
  597. br.ErrMsg = "请登录,SysUser Is Empty"
  598. br.Ret = 408
  599. return
  600. }
  601. var req models.CollectCygxYanxuanSpecialReq
  602. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  603. if err != nil {
  604. br.Msg = "参数解析异常!"
  605. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  606. return
  607. }
  608. if req.Id <= 0 {
  609. br.Msg = "文章id错误"
  610. return
  611. }
  612. if req.Status <= 0 {
  613. br.Msg = "参数错误"
  614. return
  615. }
  616. var sellerName string
  617. if req.Status == 1 {
  618. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  619. if err != nil && err.Error() != utils.ErrNoRow() {
  620. br.Msg = "查询栏目详情失败!"
  621. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  622. return
  623. }
  624. if sellerItemQy != nil {
  625. sellerName = sellerItemQy.RealName
  626. }
  627. item := models.CygxYanxuanSpecialCollect{
  628. UserId: user.UserId,
  629. Mobile: user.Mobile,
  630. Email: user.Email,
  631. CompanyId: user.CompanyId,
  632. CompanyName: user.CompanyName,
  633. RealName: user.RealName,
  634. SellerName: sellerName,
  635. CreateTime: time.Now(),
  636. ModifyTime: time.Now(),
  637. RegisterPlatform: utils.REGISTER_PLATFORM,
  638. YanxuanSpecialId: req.Id,
  639. }
  640. _, err = models.AddCygxYanxuanSpecialCollect(&item)
  641. if err != nil {
  642. br.Msg = "新增失败"
  643. br.ErrMsg = "新增失败,Err:" + err.Error()
  644. return
  645. }
  646. br.Msg = "收藏成功"
  647. } else {
  648. err = models.DelCygxYanxuanSpecialCollect(user.UserId, req.Id)
  649. if err != nil {
  650. br.Msg = "取消收藏失败"
  651. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  652. return
  653. }
  654. br.Msg = "取消收藏成功"
  655. }
  656. go services.UdpateYanxuanSpecialCollect(req.Id)
  657. br.Ret = 200
  658. br.Success = true
  659. }
  660. // @Title 专栏内容中心
  661. // @Description 专栏内容中心
  662. // @Param request body help_doc.AddHelpDocReq true "type json string"
  663. // @Success 200 {object} models.AddEnglishReportResp
  664. // @router /center [get]
  665. func (this *YanxuanSpecialController) Center() {
  666. br := new(models.BaseResponse).Init()
  667. defer func() {
  668. this.Data["json"] = br
  669. this.ServeJSON()
  670. }()
  671. sysUser := this.User
  672. if sysUser == nil {
  673. br.Msg = "请登录"
  674. br.ErrMsg = "请登录,SysUser Is Empty"
  675. br.Ret = 408
  676. return
  677. }
  678. // 1:未发布,2:审核中 3:已发布 4:驳回
  679. status, _ := this.GetInt("Status", 0)
  680. if status <= 0 {
  681. br.Msg = "参数错误"
  682. br.ErrMsg = "参数错误"
  683. return
  684. }
  685. var condition string
  686. var pars []interface{}
  687. condition += ` AND a.user_id = ? `
  688. pars = append(pars, sysUser.UserId)
  689. condition += ` AND a.status = ? `
  690. pars = append(pars, status)
  691. list, tmpErr := models.GetYanxuanSpecialList(sysUser.UserId, condition, pars, 0, 0)
  692. if tmpErr != nil {
  693. br.Msg = "获取失败"
  694. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  695. return
  696. }
  697. br.Data = list
  698. br.Ret = 200
  699. br.Success = true
  700. br.Msg = "获取成功"
  701. }
  702. // @Title 专栏点击记录
  703. // @Description 专栏点击记录
  704. // @Param request body models.AddCygxReportSelectionSubjectHistoryReq true "type json string"
  705. // @router /record [post]
  706. func (this *YanxuanSpecialController) Record() {
  707. br := new(models.BaseResponse).Init()
  708. defer func() {
  709. this.Data["json"] = br
  710. this.ServeJSON()
  711. }()
  712. user := this.User
  713. if user == nil {
  714. br.Msg = "请重新登录"
  715. br.Ret = 408
  716. return
  717. }
  718. var req models.AddCygxYanxuanSpecialRecordReq
  719. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  720. if err != nil {
  721. br.Msg = "参数解析异常!"
  722. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  723. return
  724. }
  725. if req.SpecialId <= 0 {
  726. br.Msg = "文章不存在"
  727. br.ErrMsg = "文章不存在,文章ID错误"
  728. return
  729. }
  730. specialId := req.SpecialId
  731. stopTime := req.StopTime
  732. if req.SpecialId <= 0 {
  733. br.Msg = "文章不存在"
  734. br.ErrMsg = "文章不存在,文章ID错误"
  735. return
  736. }
  737. err = services.AddSpecialRecord(this.User, specialId, stopTime)
  738. if err != nil {
  739. br.Msg = "记录失败"
  740. br.ErrMsg = "记录失败,Err:" + err.Error()
  741. return
  742. }
  743. br.Ret = 200
  744. br.Success = true
  745. br.Msg = "记录成功"
  746. }
  747. // @Title 研选专栏关注
  748. // @Description 研选专栏关注
  749. // @Param request body help_doc.AddHelpDocReq true "type json string"
  750. // @Success 200 {object} models.AddEnglishReportResp
  751. // @router /follow [post]
  752. func (this *YanxuanSpecialController) Follow() {
  753. br := new(models.BaseResponse).Init()
  754. defer func() {
  755. this.Data["json"] = br
  756. this.ServeJSON()
  757. }()
  758. user := this.User
  759. if user == nil {
  760. br.Msg = "请登录"
  761. br.ErrMsg = "请登录,SysUser Is Empty"
  762. br.Ret = 408
  763. return
  764. }
  765. var req models.FollowCygxYanxuanSpecialReq
  766. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  767. if err != nil {
  768. br.Msg = "参数解析异常!"
  769. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  770. return
  771. }
  772. if req.FollowSpecialColumnId <= 0 {
  773. br.Msg = "被关注的专栏栏目id错误"
  774. return
  775. }
  776. if req.Status <= 0 {
  777. br.Msg = "参数错误"
  778. return
  779. }
  780. var sellerName string
  781. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  782. if err != nil && err.Error() != utils.ErrNoRow() {
  783. br.Msg = "查询栏目详情失败!"
  784. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  785. return
  786. }
  787. if sellerItemQy != nil {
  788. sellerName = sellerItemQy.RealName
  789. }
  790. authorItem, err := models.GetYanxuanSpecialAuthorById(req.FollowSpecialColumnId)
  791. if err != nil {
  792. br.Msg = "查询栏目详情失败!"
  793. br.ErrMsg = "查询栏目详情失败,Err:" + err.Error()
  794. return
  795. }
  796. if req.Status == 1 {
  797. followCount, err := models.GetCygxYanxuanSpecialFollowCountByUser(user.UserId, authorItem.UserId)
  798. if err != nil {
  799. br.Msg = "获取失败"
  800. br.ErrMsg = "获取失败, Err:" + err.Error()
  801. return
  802. }
  803. if followCount == 0 {
  804. item := models.CygxYanxuanSpecialFollow{
  805. UserId: user.UserId,
  806. FollowUserId: authorItem.UserId,
  807. Mobile: user.Mobile,
  808. Email: user.Email,
  809. CompanyId: user.CompanyId,
  810. CompanyName: user.CompanyName,
  811. RealName: user.RealName,
  812. SellerName: sellerName,
  813. CreateTime: time.Now(),
  814. ModifyTime: time.Now(),
  815. RegisterPlatform: utils.REGISTER_PLATFORM,
  816. YanxuanSpecialId: req.SpecialId,
  817. }
  818. err = models.AddCygxYanxuanSpecialFollow(&item)
  819. if err != nil {
  820. br.Msg = "新增失败"
  821. br.ErrMsg = "新增失败,Err:" + err.Error()
  822. return
  823. }
  824. }
  825. br.Msg = "关注成功"
  826. } else {
  827. err = models.DelCygxYanxuanSpecialFollow(user.UserId, authorItem.UserId)
  828. if err != nil {
  829. br.Msg = "删除失败"
  830. br.ErrMsg = "删除失败,Err:" + err.Error()
  831. return
  832. }
  833. br.Msg = "取消关注成功"
  834. }
  835. go services.UdpateYanxuanSpecialFansNum(authorItem.UserId)
  836. br.Ret = 200
  837. br.Success = true
  838. }
  839. // @Title 行业标签搜索
  840. // @Description 行业标签搜索
  841. // @Param request body help_doc.AddHelpDocReq true "type json string"
  842. // @Success 200 {object} models.AddEnglishReportResp
  843. // @router /industrySearch [get]
  844. func (this *YanxuanSpecialController) IndustrySearch() {
  845. br := new(models.BaseResponse).Init()
  846. defer func() {
  847. this.Data["json"] = br
  848. this.ServeJSON()
  849. }()
  850. sysUser := this.User
  851. if sysUser == nil {
  852. br.Msg = "请登录"
  853. br.ErrMsg = "请登录,SysUser Is Empty"
  854. br.Ret = 408
  855. return
  856. }
  857. keyword := this.GetString("Keyword")
  858. list, tmpErr := models.GetYanxuanSpecialIndustry(keyword)
  859. if tmpErr != nil {
  860. br.Msg = "获取失败"
  861. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  862. return
  863. }
  864. br.Data = list
  865. br.Ret = 200
  866. br.Success = true
  867. br.Msg = "获取成功"
  868. }
  869. // @Title 公司标签搜索
  870. // @Description 公司标签搜索
  871. // @Param request body help_doc.AddHelpDocReq true "type json string"
  872. // @Success 200 {object} models.AddEnglishReportResp
  873. // @router /companySearch [get]
  874. func (this *YanxuanSpecialController) CompanySearch() {
  875. br := new(models.BaseResponse).Init()
  876. defer func() {
  877. this.Data["json"] = br
  878. this.ServeJSON()
  879. }()
  880. sysUser := this.User
  881. if sysUser == nil {
  882. br.Msg = "请登录"
  883. br.ErrMsg = "请登录,SysUser Is Empty"
  884. br.Ret = 408
  885. return
  886. }
  887. keyword := this.GetString("Keyword")
  888. if keyword == "" {
  889. br.Ret = 200
  890. return
  891. }
  892. list, tmpErr := models.GetYanxuanSpecialCompany(keyword)
  893. if tmpErr != nil {
  894. br.Msg = "获取失败"
  895. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  896. return
  897. }
  898. br.Data = list
  899. br.Ret = 200
  900. br.Success = true
  901. br.Msg = "获取成功"
  902. }
  903. // @Title 专栏取消发布
  904. // @Description 专栏取消发布
  905. // @Param request body help_doc.AddHelpDocReq true "type json string"
  906. // @Success 200 {object} models.AddEnglishReportResp
  907. // @router /cancel [post]
  908. func (this *YanxuanSpecialController) Cancel() {
  909. br := new(models.BaseResponse).Init()
  910. defer func() {
  911. this.Data["json"] = br
  912. this.ServeJSON()
  913. }()
  914. sysUser := this.User
  915. if sysUser == nil {
  916. br.Msg = "请登录"
  917. br.ErrMsg = "请登录,SysUser Is Empty"
  918. br.Ret = 408
  919. return
  920. }
  921. var req models.CancelPublishCygxYanxuanSpecialReq
  922. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  923. if err != nil {
  924. br.Msg = "参数解析异常!"
  925. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  926. return
  927. }
  928. if req.Id <= 0 {
  929. br.Msg = "文章id错误"
  930. return
  931. }
  932. specialItem, err := models.GetYanxuanSpecialItemById(req.Id)
  933. if err != nil {
  934. br.Msg = "专栏取消发布失败"
  935. br.ErrMsg = "专栏取消发布失败,Err:" + err.Error()
  936. return
  937. }
  938. if tmpErr := models.CancelPublishYanxuanSpecial(req.Id); tmpErr != nil {
  939. br.Msg = "取消发布失败"
  940. br.ErrMsg = "取消发布失败, Err:" + tmpErr.Error()
  941. return
  942. }
  943. go services.UpdateYanxuanSpecialResourceData(req.Id) // 写入首页最新 cygx_resource_data 表
  944. go services.EsAddYanxuanSpecial(req.Id) // 写入es 综合搜索
  945. go services.UdpateYanxuanSpecialauthorArticleNum(specialItem.UserId) // 更新作者发布文章的数量
  946. br.Msg = "取消发布成功"
  947. br.Ret = 200
  948. br.Success = true
  949. }
  950. // @Title 作者列表
  951. // @Description 作者列表
  952. // @Param PageSize query int true "每页数据条数"
  953. // @Param CurrentIndex query int true "当前页页码,从1开始"
  954. // @Success 200 {object} models.AddEnglishReportResp
  955. // @router /author/list [get]
  956. func (this *YanxuanSpecialNoLoginController) AuthorList() {
  957. br := new(models.BaseResponse).Init()
  958. defer func() {
  959. this.Data["json"] = br
  960. this.ServeJSON()
  961. }()
  962. sysUser := this.User
  963. if sysUser == nil {
  964. br.Msg = "请登录"
  965. br.ErrMsg = "请登录,SysUser Is Empty"
  966. br.Ret = 408
  967. return
  968. }
  969. pageSize, _ := this.GetInt("PageSize")
  970. currentIndex, _ := this.GetInt("CurrentIndex")
  971. var startSize int
  972. if pageSize <= 0 {
  973. pageSize = utils.PageSize20
  974. }
  975. if currentIndex <= 0 {
  976. currentIndex = 1
  977. }
  978. startSize = utils.StartIndex(currentIndex, pageSize)
  979. resp := new(models.SpecialAuthorListResp)
  980. specialAuthorCheck := services.GetYanxuanSpecialAuthorInfo(sysUser) //用户是否没开通研选专栏以及,专栏信息是否完善
  981. resp.IsAuthor = specialAuthorCheck.IsAuthor
  982. resp.IsImproveInformation = specialAuthorCheck.IsImproveInformation
  983. resp.SpecialColumnId = specialAuthorCheck.SpecialColumnId
  984. resp.HeadImg = specialAuthorCheck.HeadImg
  985. var condition string
  986. var conditionUserSort string
  987. var pars []interface{}
  988. condition += ` AND a.nick_name <> '' `
  989. conditionUserSort += ` ( IF ( a.user_id = ` + strconv.Itoa(sysUser.UserId) + `, 1 = 1, user_id = 1 ) ) AS user_sort , ` // 用户本人如果开通了专栏,就放在最前面
  990. total, err := models.GetCygxYanxuanSpecialAuthorCount(condition, pars)
  991. if err != nil {
  992. br.Msg = "获取失败"
  993. br.ErrMsg = "获取失败,Err:" + err.Error()
  994. return
  995. }
  996. condition += ` ORDER BY user_sort DESC, latest_publish_time DESC`
  997. list, tmpErr := models.GetYanxuanSpecialAuthorList(conditionUserSort, condition, pars, startSize, pageSize)
  998. if tmpErr != nil {
  999. br.Msg = "获取失败"
  1000. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  1001. return
  1002. }
  1003. //var userIds []int
  1004. for _, v := range list {
  1005. v.LatestPublishDate = v.LatestPublishTime.Format(utils.FormatDate) + "更新"
  1006. //userIds = append(userIds, v.UserId)
  1007. }
  1008. page := paging.GetPaging(currentIndex, pageSize, total)
  1009. resp.List = list
  1010. resp.Paging = page
  1011. br.Data = resp
  1012. br.Ret = 200
  1013. br.Success = true
  1014. br.Msg = "获取成功"
  1015. }
  1016. // @Title 更新作者头像
  1017. // @Description 更新作者头像
  1018. // @Param request body help_doc.AddHelpDocReq true "type json string"
  1019. // @Success 200 {object} models.AddEnglishReportResp
  1020. // @router /author/head_img [post]
  1021. func (this *YanxuanSpecialController) AuthorHeadImg() {
  1022. br := new(models.BaseResponse).Init()
  1023. defer func() {
  1024. this.Data["json"] = br
  1025. this.ServeJSON()
  1026. }()
  1027. sysUser := this.User
  1028. if sysUser == nil {
  1029. br.Msg = "请登录"
  1030. br.ErrMsg = "请登录,SysUser Is Empty"
  1031. br.Ret = 408
  1032. return
  1033. }
  1034. var req models.SaveCygxYanxuanSpecialAuthoHeadImgrReq
  1035. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1036. if err != nil {
  1037. br.Msg = "参数解析异常!"
  1038. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1039. return
  1040. }
  1041. if req.SpecialColumnId <= 0 {
  1042. br.Msg = "专栏栏目id错误"
  1043. return
  1044. }
  1045. if req.HeadImg == "" {
  1046. br.Msg = "头像图片错误"
  1047. return
  1048. }
  1049. item := models.CygxYanxuanSpecialAuthor{
  1050. Id: req.SpecialColumnId,
  1051. HeadImg: req.HeadImg,
  1052. }
  1053. err = models.UpdateYanxuanSpecialAuthorHeadImg(&item)
  1054. if err != nil {
  1055. br.Msg = "保存失败"
  1056. br.ErrMsg = "保存失败,Err:" + err.Error()
  1057. return
  1058. }
  1059. br.Ret = 200
  1060. br.Success = true
  1061. br.Msg = "保存成功"
  1062. }
  1063. // @Title 删除专栏
  1064. // @Description 删除专栏
  1065. // @Param request body help_doc.AddHelpDocReq true "type json string"
  1066. // @Success 200 {object} models.AddEnglishReportResp
  1067. // @router /del [post]
  1068. func (this *YanxuanSpecialController) Delete() {
  1069. br := new(models.BaseResponse).Init()
  1070. defer func() {
  1071. this.Data["json"] = br
  1072. this.ServeJSON()
  1073. }()
  1074. sysUser := this.User
  1075. if sysUser == nil {
  1076. br.Msg = "请登录"
  1077. br.ErrMsg = "请登录,SysUser Is Empty"
  1078. br.Ret = 408
  1079. return
  1080. }
  1081. var req models.DelCygxYanxuanSpecialReq
  1082. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1083. if err != nil {
  1084. br.Msg = "参数解析异常!"
  1085. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1086. return
  1087. }
  1088. if req.Id <= 0 {
  1089. br.Msg = "文章id错误"
  1090. return
  1091. }
  1092. if tmpErr := models.DelYanxuanSpecial(req.Id); tmpErr != nil {
  1093. br.Msg = "删除失败"
  1094. br.ErrMsg = "删除失败, Err:" + tmpErr.Error()
  1095. return
  1096. }
  1097. br.Msg = "删除成功"
  1098. br.Ret = 200
  1099. br.Success = true
  1100. }
  1101. // @Title 专栏文章敏感词检测
  1102. // @Description 专栏文章敏感词检测
  1103. // @Param request body help_doc.AddHelpDocReq true "type json string"
  1104. // @Success 200 {object} models.AddEnglishReportResp
  1105. // @router /check [post]
  1106. func (this *YanxuanSpecialController) Check() {
  1107. br := new(models.BaseResponse).Init()
  1108. defer func() {
  1109. this.Data["json"] = br
  1110. this.ServeJSON()
  1111. }()
  1112. sysUser := this.User
  1113. if sysUser == nil {
  1114. br.Msg = "请登录"
  1115. br.ErrMsg = "请登录,SysUser Is Empty"
  1116. br.Ret = 408
  1117. return
  1118. }
  1119. var req models.CygxYanxuanSpecialCheckReq
  1120. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1121. if err != nil {
  1122. br.Msg = "参数解析异常!"
  1123. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1124. return
  1125. }
  1126. if req.Content == "" {
  1127. br.Ret = 200
  1128. br.Success = true
  1129. br.Msg = "校验成功"
  1130. }
  1131. itemToken, err := services.WxGetToken()
  1132. if err != nil {
  1133. br.Msg = "GetWxAccessToken Err:" + err.Error()
  1134. return
  1135. }
  1136. if itemToken.AccessToken == "" {
  1137. br.Msg = "accessToken is empty"
  1138. return
  1139. }
  1140. suggest := models.WxCheckContent(itemToken.AccessToken, sysUser.OpenId, req.Content)
  1141. if suggest == "risky" {
  1142. br.Msg = "文章内容含有违法违规内容"
  1143. br.ErrMsg = "文章内容含有违法违规内容"
  1144. return
  1145. }
  1146. if len(req.ImgUrl) > 0 {
  1147. //for _, imgUrl := range req.ImgUrl {
  1148. // imgBody, err := http.Get(imgUrl)
  1149. // if err != nil {
  1150. // br.Msg = "图片链接有误"
  1151. // br.ErrMsg = "图片链接有误"
  1152. // return
  1153. // }
  1154. // rnStr := utils.GetRandStringNoSpecialChar(5)
  1155. // savePath := time.Now().Format(utils.FormatDateTimeUnSpace) + rnStr + ".jpg"
  1156. // err = file.SaveFile(imgBody, savePath)
  1157. // if err != nil {
  1158. // br.Msg = "保存图片错误"
  1159. // br.ErrMsg = "保存图片错误"
  1160. // return
  1161. // }
  1162. // res, err := weapp.IMGSecCheck(itemToken.AccessToken, savePath)
  1163. // if err != nil {
  1164. // // 处理一般错误信息
  1165. // br.Msg = "图片内容含有违法违规内容"
  1166. // br.ErrMsg = "图片内容含有违法违规内容"
  1167. // return
  1168. // }
  1169. // if err := res.GetResponseError(); err != nil {
  1170. // // 处理微信返回错误信息
  1171. // br.Msg = "GetResponseError Err:" + err.Error()
  1172. // return
  1173. // }
  1174. // err = os.RemoveAll(savePath)
  1175. // if err != nil {
  1176. // br.Msg = "RemoveAll Err:" + err.Error()
  1177. // return
  1178. // }
  1179. //}
  1180. }
  1181. br.Ret = 200
  1182. br.Success = true
  1183. br.Msg = "校验成功"
  1184. }