yanxuan_special.go 34 KB

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