yanxuan_special.go 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262
  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.GetCygxYanxuanSpecialFollowCountByUserId(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, 2) //研选专栏审核完成时,给提交人发送模板消息
  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.UpdateYanxuanSpecialResourceData(specialId) // 写入首页最新 cygx_resource_data 表
  476. go services.EsAddYanxuanSpecial(specialId) // 写入es 综合搜索
  477. }
  478. }
  479. br.Ret = 200
  480. br.Success = true
  481. br.Data = specialId
  482. }
  483. // @Title 专栏作者详情
  484. // @Description 专栏作者详情
  485. // @Param request body help_doc.AddHelpDocReq true "type json string"
  486. // @Success 200 {object} models.AddEnglishReportResp
  487. // @router /author/detail [get]
  488. func (this *YanxuanSpecialNoLoginController) AuthorDetail() {
  489. br := new(models.BaseResponse).Init()
  490. defer func() {
  491. this.Data["json"] = br
  492. this.ServeJSON()
  493. }()
  494. sysUser := this.User
  495. if sysUser == nil {
  496. br.Msg = "请登录"
  497. br.ErrMsg = "请登录,SysUser Is Empty"
  498. br.Ret = 408
  499. return
  500. }
  501. specialColumnId, _ := this.GetInt("SpecialColumnId", 0)
  502. item, tmpErr := models.GetYanxuanSpecialAuthorBySpecialColumnId(specialColumnId, sysUser.UserId)
  503. if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
  504. br.Msg = "获取失败"
  505. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  506. return
  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. br.Msg = "审批成功"
  576. br.Ret = 200
  577. br.Success = true
  578. }
  579. // @Title 研选专栏收藏
  580. // @Description 研选专栏收藏
  581. // @Param request body help_doc.AddHelpDocReq true "type json string"
  582. // @Success 200 {object} models.AddEnglishReportResp
  583. // @router /collect [post]
  584. func (this *YanxuanSpecialController) Collect() {
  585. br := new(models.BaseResponse).Init()
  586. defer func() {
  587. this.Data["json"] = br
  588. this.ServeJSON()
  589. }()
  590. user := this.User
  591. if user == nil {
  592. br.Msg = "请登录"
  593. br.ErrMsg = "请登录,SysUser Is Empty"
  594. br.Ret = 408
  595. return
  596. }
  597. var req models.CollectCygxYanxuanSpecialReq
  598. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  599. if err != nil {
  600. br.Msg = "参数解析异常!"
  601. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  602. return
  603. }
  604. if req.Id <= 0 {
  605. br.Msg = "文章id错误"
  606. return
  607. }
  608. if req.Status <= 0 {
  609. br.Msg = "参数错误"
  610. return
  611. }
  612. var sellerName string
  613. if req.Status == 1 {
  614. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  615. if err != nil && err.Error() != utils.ErrNoRow() {
  616. br.Msg = "查询栏目详情失败!"
  617. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  618. return
  619. }
  620. if sellerItemQy != nil {
  621. sellerName = sellerItemQy.RealName
  622. }
  623. item := models.CygxYanxuanSpecialCollect{
  624. UserId: user.UserId,
  625. Mobile: user.Mobile,
  626. Email: user.Email,
  627. CompanyId: user.CompanyId,
  628. CompanyName: user.CompanyName,
  629. RealName: user.RealName,
  630. SellerName: sellerName,
  631. CreateTime: time.Now(),
  632. ModifyTime: time.Now(),
  633. RegisterPlatform: utils.REGISTER_PLATFORM,
  634. YanxuanSpecialId: req.Id,
  635. }
  636. _, err = models.AddCygxYanxuanSpecialCollect(&item)
  637. if err != nil {
  638. br.Msg = "新增失败"
  639. br.ErrMsg = "新增失败,Err:" + err.Error()
  640. return
  641. }
  642. br.Msg = "收藏成功"
  643. } else {
  644. err = models.DelCygxYanxuanSpecialCollect(user.UserId, req.Id)
  645. if err != nil {
  646. br.Msg = "取消收藏失败"
  647. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  648. return
  649. }
  650. br.Msg = "取消收藏成功"
  651. }
  652. go services.UdpateYanxuanSpecialCollect(req.Id)
  653. br.Ret = 200
  654. br.Success = true
  655. }
  656. // @Title 专栏内容中心
  657. // @Description 专栏内容中心
  658. // @Param request body help_doc.AddHelpDocReq true "type json string"
  659. // @Success 200 {object} models.AddEnglishReportResp
  660. // @router /center [get]
  661. func (this *YanxuanSpecialController) Center() {
  662. br := new(models.BaseResponse).Init()
  663. defer func() {
  664. this.Data["json"] = br
  665. this.ServeJSON()
  666. }()
  667. sysUser := this.User
  668. if sysUser == nil {
  669. br.Msg = "请登录"
  670. br.ErrMsg = "请登录,SysUser Is Empty"
  671. br.Ret = 408
  672. return
  673. }
  674. // 1:未发布,2:审核中 3:已发布 4:驳回
  675. status, _ := this.GetInt("Status", 0)
  676. if status <= 0 {
  677. br.Msg = "参数错误"
  678. br.ErrMsg = "参数错误"
  679. return
  680. }
  681. var condition string
  682. var pars []interface{}
  683. condition += ` AND a.user_id = ? `
  684. pars = append(pars, sysUser.UserId)
  685. condition += ` AND a.status = ? `
  686. pars = append(pars, status)
  687. list, tmpErr := models.GetYanxuanSpecialList(sysUser.UserId, condition, pars, 0, 0)
  688. if tmpErr != nil {
  689. br.Msg = "获取失败"
  690. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  691. return
  692. }
  693. br.Data = list
  694. br.Ret = 200
  695. br.Success = true
  696. br.Msg = "获取成功"
  697. }
  698. // @Title 专栏点击记录
  699. // @Description 专栏点击记录
  700. // @Param request body models.AddCygxReportSelectionSubjectHistoryReq true "type json string"
  701. // @router /record [post]
  702. func (this *YanxuanSpecialController) Record() {
  703. br := new(models.BaseResponse).Init()
  704. defer func() {
  705. this.Data["json"] = br
  706. this.ServeJSON()
  707. }()
  708. user := this.User
  709. if user == nil {
  710. br.Msg = "请重新登录"
  711. br.Ret = 408
  712. return
  713. }
  714. var req models.AddCygxYanxuanSpecialRecordReq
  715. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  716. if err != nil {
  717. br.Msg = "参数解析异常!"
  718. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  719. return
  720. }
  721. if req.SpecialId <= 0 {
  722. br.Msg = "文章不存在"
  723. br.ErrMsg = "文章不存在,文章ID错误"
  724. return
  725. }
  726. specialId := req.SpecialId
  727. stopTime := req.StopTime
  728. if req.SpecialId <= 0 {
  729. br.Msg = "文章不存在"
  730. br.ErrMsg = "文章不存在,文章ID错误"
  731. return
  732. }
  733. err = services.AddSpecialRecord(this.User, specialId, stopTime)
  734. if err != nil {
  735. br.Msg = "记录失败"
  736. br.ErrMsg = "记录失败,Err:" + err.Error()
  737. return
  738. }
  739. br.Ret = 200
  740. br.Success = true
  741. br.Msg = "记录成功"
  742. }
  743. // @Title 研选专栏关注
  744. // @Description 研选专栏关注
  745. // @Param request body help_doc.AddHelpDocReq true "type json string"
  746. // @Success 200 {object} models.AddEnglishReportResp
  747. // @router /follow [post]
  748. func (this *YanxuanSpecialController) Follow() {
  749. br := new(models.BaseResponse).Init()
  750. defer func() {
  751. this.Data["json"] = br
  752. this.ServeJSON()
  753. }()
  754. user := this.User
  755. if user == nil {
  756. br.Msg = "请登录"
  757. br.ErrMsg = "请登录,SysUser Is Empty"
  758. br.Ret = 408
  759. return
  760. }
  761. var req models.FollowCygxYanxuanSpecialReq
  762. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  763. if err != nil {
  764. br.Msg = "参数解析异常!"
  765. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  766. return
  767. }
  768. if req.FollowSpecialColumnId <= 0 {
  769. br.Msg = "被关注的专栏栏目id错误"
  770. return
  771. }
  772. if req.Status <= 0 {
  773. br.Msg = "参数错误"
  774. return
  775. }
  776. var sellerName string
  777. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  778. if err != nil && err.Error() != utils.ErrNoRow() {
  779. br.Msg = "查询栏目详情失败!"
  780. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  781. return
  782. }
  783. if sellerItemQy != nil {
  784. sellerName = sellerItemQy.RealName
  785. }
  786. authorItem, err := models.GetYanxuanSpecialAuthorById(req.FollowSpecialColumnId)
  787. if err != nil {
  788. br.Msg = "查询栏目详情失败!"
  789. br.ErrMsg = "查询栏目详情失败,Err:" + err.Error()
  790. return
  791. }
  792. if req.Status == 1 {
  793. item := models.CygxYanxuanSpecialFollow{
  794. UserId: user.UserId,
  795. FollowUserId: authorItem.UserId,
  796. Mobile: user.Mobile,
  797. Email: user.Email,
  798. CompanyId: user.CompanyId,
  799. CompanyName: user.CompanyName,
  800. RealName: user.RealName,
  801. SellerName: sellerName,
  802. CreateTime: time.Now(),
  803. ModifyTime: time.Now(),
  804. RegisterPlatform: utils.REGISTER_PLATFORM,
  805. YanxuanSpecialId: req.SpecialId,
  806. }
  807. err = models.AddCygxYanxuanSpecialFollow(&item)
  808. if err != nil {
  809. br.Msg = "新增失败"
  810. br.ErrMsg = "新增失败,Err:" + err.Error()
  811. return
  812. }
  813. br.Msg = "关注成功"
  814. } else {
  815. err = models.DelCygxYanxuanSpecialFollow(user.UserId, authorItem.UserId)
  816. if err != nil {
  817. br.Msg = "删除失败"
  818. br.ErrMsg = "删除失败,Err:" + err.Error()
  819. return
  820. }
  821. br.Msg = "取消关注成功"
  822. }
  823. go services.UdpateYanxuanSpecialFansNum(authorItem.UserId)
  824. br.Ret = 200
  825. br.Success = true
  826. }
  827. // @Title 行业标签搜索
  828. // @Description 行业标签搜索
  829. // @Param request body help_doc.AddHelpDocReq true "type json string"
  830. // @Success 200 {object} models.AddEnglishReportResp
  831. // @router /industrySearch [get]
  832. func (this *YanxuanSpecialController) IndustrySearch() {
  833. br := new(models.BaseResponse).Init()
  834. defer func() {
  835. this.Data["json"] = br
  836. this.ServeJSON()
  837. }()
  838. sysUser := this.User
  839. if sysUser == nil {
  840. br.Msg = "请登录"
  841. br.ErrMsg = "请登录,SysUser Is Empty"
  842. br.Ret = 408
  843. return
  844. }
  845. keyword := this.GetString("Keyword")
  846. list, tmpErr := models.GetYanxuanSpecialIndustry(keyword)
  847. if tmpErr != nil {
  848. br.Msg = "获取失败"
  849. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  850. return
  851. }
  852. br.Data = list
  853. br.Ret = 200
  854. br.Success = true
  855. br.Msg = "获取成功"
  856. }
  857. // @Title 公司标签搜索
  858. // @Description 公司标签搜索
  859. // @Param request body help_doc.AddHelpDocReq true "type json string"
  860. // @Success 200 {object} models.AddEnglishReportResp
  861. // @router /companySearch [get]
  862. func (this *YanxuanSpecialController) CompanySearch() {
  863. br := new(models.BaseResponse).Init()
  864. defer func() {
  865. this.Data["json"] = br
  866. this.ServeJSON()
  867. }()
  868. sysUser := this.User
  869. if sysUser == nil {
  870. br.Msg = "请登录"
  871. br.ErrMsg = "请登录,SysUser Is Empty"
  872. br.Ret = 408
  873. return
  874. }
  875. keyword := this.GetString("Keyword")
  876. if keyword == "" {
  877. br.Ret = 200
  878. return
  879. }
  880. list, tmpErr := models.GetYanxuanSpecialCompany(keyword)
  881. if tmpErr != nil {
  882. br.Msg = "获取失败"
  883. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  884. return
  885. }
  886. br.Data = list
  887. br.Ret = 200
  888. br.Success = true
  889. br.Msg = "获取成功"
  890. }
  891. // @Title 专栏取消发布
  892. // @Description 专栏取消发布
  893. // @Param request body help_doc.AddHelpDocReq true "type json string"
  894. // @Success 200 {object} models.AddEnglishReportResp
  895. // @router /cancel [post]
  896. func (this *YanxuanSpecialController) Cancel() {
  897. br := new(models.BaseResponse).Init()
  898. defer func() {
  899. this.Data["json"] = br
  900. this.ServeJSON()
  901. }()
  902. sysUser := this.User
  903. if sysUser == nil {
  904. br.Msg = "请登录"
  905. br.ErrMsg = "请登录,SysUser Is Empty"
  906. br.Ret = 408
  907. return
  908. }
  909. var req models.CancelPublishCygxYanxuanSpecialReq
  910. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  911. if err != nil {
  912. br.Msg = "参数解析异常!"
  913. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  914. return
  915. }
  916. if req.Id <= 0 {
  917. br.Msg = "文章id错误"
  918. return
  919. }
  920. specialItem, err := models.GetYanxuanSpecialItemById(req.Id)
  921. if err != nil {
  922. br.Msg = "专栏取消发布失败"
  923. br.ErrMsg = "专栏取消发布失败,Err:" + err.Error()
  924. return
  925. }
  926. if tmpErr := models.CancelPublishYanxuanSpecial(req.Id); tmpErr != nil {
  927. br.Msg = "取消发布失败"
  928. br.ErrMsg = "取消发布失败, Err:" + tmpErr.Error()
  929. return
  930. }
  931. go services.UpdateYanxuanSpecialResourceData(req.Id) // 写入首页最新 cygx_resource_data 表
  932. go services.EsAddYanxuanSpecial(req.Id) // 写入es 综合搜索
  933. go services.UdpateYanxuanSpecialauthorArticleNum(specialItem.UserId) // 更新作者发布文章的数量
  934. br.Msg = "取消发布成功"
  935. br.Ret = 200
  936. br.Success = true
  937. }
  938. // @Title 作者列表
  939. // @Description 作者列表
  940. // @Param PageSize query int true "每页数据条数"
  941. // @Param CurrentIndex query int true "当前页页码,从1开始"
  942. // @Success 200 {object} models.AddEnglishReportResp
  943. // @router /author/list [get]
  944. func (this *YanxuanSpecialNoLoginController) AuthorList() {
  945. br := new(models.BaseResponse).Init()
  946. defer func() {
  947. this.Data["json"] = br
  948. this.ServeJSON()
  949. }()
  950. sysUser := this.User
  951. if sysUser == nil {
  952. br.Msg = "请登录"
  953. br.ErrMsg = "请登录,SysUser Is Empty"
  954. br.Ret = 408
  955. return
  956. }
  957. pageSize, _ := this.GetInt("PageSize")
  958. currentIndex, _ := this.GetInt("CurrentIndex")
  959. var startSize int
  960. if pageSize <= 0 {
  961. pageSize = utils.PageSize20
  962. }
  963. if currentIndex <= 0 {
  964. currentIndex = 1
  965. }
  966. startSize = utils.StartIndex(currentIndex, pageSize)
  967. resp := new(models.SpecialAuthorListResp)
  968. specialAuthorCheck := services.GetYanxuanSpecialAuthorInfo(sysUser) //用户是否没开通研选专栏以及,专栏信息是否完善
  969. resp.IsAuthor = specialAuthorCheck.IsAuthor
  970. resp.IsImproveInformation = specialAuthorCheck.IsImproveInformation
  971. resp.SpecialColumnId = specialAuthorCheck.SpecialColumnId
  972. resp.HeadImg = specialAuthorCheck.HeadImg
  973. var condition string
  974. var conditionUserSort string
  975. var pars []interface{}
  976. condition += ` AND a.nick_name <> '' `
  977. conditionUserSort += ` ( IF ( a.user_id = ` + strconv.Itoa(sysUser.UserId) + `, 1 = 1, user_id = 1 ) ) AS user_sort , ` // 用户本人如果开通了专栏,就放在最前面
  978. total, err := models.GetCygxYanxuanSpecialAuthorCount(condition, pars)
  979. if err != nil {
  980. br.Msg = "获取失败"
  981. br.ErrMsg = "获取失败,Err:" + err.Error()
  982. return
  983. }
  984. condition += ` ORDER BY user_sort DESC, latest_publish_time DESC`
  985. list, tmpErr := models.GetYanxuanSpecialAuthorList(conditionUserSort, condition, pars, startSize, pageSize)
  986. if tmpErr != nil {
  987. br.Msg = "获取失败"
  988. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  989. return
  990. }
  991. //var userIds []int
  992. for _, v := range list {
  993. v.LatestPublishDate = v.LatestPublishTime.Format(utils.FormatDate) + "更新"
  994. //userIds = append(userIds, v.UserId)
  995. }
  996. page := paging.GetPaging(currentIndex, pageSize, total)
  997. resp.List = list
  998. resp.Paging = page
  999. br.Data = resp
  1000. br.Ret = 200
  1001. br.Success = true
  1002. br.Msg = "获取成功"
  1003. }
  1004. // @Title 更新作者头像
  1005. // @Description 更新作者头像
  1006. // @Param request body help_doc.AddHelpDocReq true "type json string"
  1007. // @Success 200 {object} models.AddEnglishReportResp
  1008. // @router /author/head_img [post]
  1009. func (this *YanxuanSpecialController) AuthorHeadImg() {
  1010. br := new(models.BaseResponse).Init()
  1011. defer func() {
  1012. this.Data["json"] = br
  1013. this.ServeJSON()
  1014. }()
  1015. sysUser := this.User
  1016. if sysUser == nil {
  1017. br.Msg = "请登录"
  1018. br.ErrMsg = "请登录,SysUser Is Empty"
  1019. br.Ret = 408
  1020. return
  1021. }
  1022. var req models.SaveCygxYanxuanSpecialAuthoHeadImgrReq
  1023. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1024. if err != nil {
  1025. br.Msg = "参数解析异常!"
  1026. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1027. return
  1028. }
  1029. if req.SpecialColumnId <= 0 {
  1030. br.Msg = "专栏栏目id错误"
  1031. return
  1032. }
  1033. if req.HeadImg == "" {
  1034. br.Msg = "头像图片错误"
  1035. return
  1036. }
  1037. item := models.CygxYanxuanSpecialAuthor{
  1038. Id: req.SpecialColumnId,
  1039. HeadImg: req.HeadImg,
  1040. }
  1041. err = models.UpdateYanxuanSpecialAuthorHeadImg(&item)
  1042. if err != nil {
  1043. br.Msg = "保存失败"
  1044. br.ErrMsg = "保存失败,Err:" + err.Error()
  1045. return
  1046. }
  1047. br.Ret = 200
  1048. br.Success = true
  1049. br.Msg = "保存成功"
  1050. }
  1051. // @Title 删除专栏
  1052. // @Description 删除专栏
  1053. // @Param request body help_doc.AddHelpDocReq true "type json string"
  1054. // @Success 200 {object} models.AddEnglishReportResp
  1055. // @router /del [post]
  1056. func (this *YanxuanSpecialController) Delete() {
  1057. br := new(models.BaseResponse).Init()
  1058. defer func() {
  1059. this.Data["json"] = br
  1060. this.ServeJSON()
  1061. }()
  1062. sysUser := this.User
  1063. if sysUser == nil {
  1064. br.Msg = "请登录"
  1065. br.ErrMsg = "请登录,SysUser Is Empty"
  1066. br.Ret = 408
  1067. return
  1068. }
  1069. var req models.DelCygxYanxuanSpecialReq
  1070. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1071. if err != nil {
  1072. br.Msg = "参数解析异常!"
  1073. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1074. return
  1075. }
  1076. if req.Id <= 0 {
  1077. br.Msg = "文章id错误"
  1078. return
  1079. }
  1080. if tmpErr := models.DelYanxuanSpecial(req.Id); tmpErr != nil {
  1081. br.Msg = "删除失败"
  1082. br.ErrMsg = "删除失败, Err:" + tmpErr.Error()
  1083. return
  1084. }
  1085. br.Msg = "删除成功"
  1086. br.Ret = 200
  1087. br.Success = true
  1088. }
  1089. // @Title 专栏文章敏感词检测
  1090. // @Description 专栏文章敏感词检测
  1091. // @Param request body help_doc.AddHelpDocReq true "type json string"
  1092. // @Success 200 {object} models.AddEnglishReportResp
  1093. // @router /check [post]
  1094. func (this *YanxuanSpecialController) Check() {
  1095. br := new(models.BaseResponse).Init()
  1096. defer func() {
  1097. this.Data["json"] = br
  1098. this.ServeJSON()
  1099. }()
  1100. sysUser := this.User
  1101. if sysUser == nil {
  1102. br.Msg = "请登录"
  1103. br.ErrMsg = "请登录,SysUser Is Empty"
  1104. br.Ret = 408
  1105. return
  1106. }
  1107. var req models.CygxYanxuanSpecialCheckReq
  1108. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1109. if err != nil {
  1110. br.Msg = "参数解析异常!"
  1111. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1112. return
  1113. }
  1114. if req.Content == "" {
  1115. br.Ret = 200
  1116. br.Success = true
  1117. br.Msg = "校验成功"
  1118. }
  1119. itemToken, err := services.WxGetToken()
  1120. if err != nil {
  1121. br.Msg = "GetWxAccessToken Err:" + err.Error()
  1122. return
  1123. }
  1124. if itemToken.AccessToken == "" {
  1125. br.Msg = "accessToken is empty"
  1126. return
  1127. }
  1128. suggest := models.WxCheckContent(itemToken.AccessToken, sysUser.OpenId, req.Content)
  1129. if suggest == "risky" {
  1130. br.Msg = "文章内容含有违法违规内容"
  1131. br.ErrMsg = "文章内容含有违法违规内容"
  1132. return
  1133. }
  1134. if len(req.ImgUrl) > 0 {
  1135. //for _, imgUrl := range req.ImgUrl {
  1136. // imgBody, err := http.Get(imgUrl)
  1137. // if err != nil {
  1138. // br.Msg = "图片链接有误"
  1139. // br.ErrMsg = "图片链接有误"
  1140. // return
  1141. // }
  1142. // rnStr := utils.GetRandStringNoSpecialChar(5)
  1143. // savePath := time.Now().Format(utils.FormatDateTimeUnSpace) + rnStr + ".jpg"
  1144. // err = file.SaveFile(imgBody, savePath)
  1145. // if err != nil {
  1146. // br.Msg = "保存图片错误"
  1147. // br.ErrMsg = "保存图片错误"
  1148. // return
  1149. // }
  1150. // res, err := weapp.IMGSecCheck(itemToken.AccessToken, savePath)
  1151. // if err != nil {
  1152. // // 处理一般错误信息
  1153. // br.Msg = "图片内容含有违法违规内容"
  1154. // br.ErrMsg = "图片内容含有违法违规内容"
  1155. // return
  1156. // }
  1157. // if err := res.GetResponseError(); err != nil {
  1158. // // 处理微信返回错误信息
  1159. // br.Msg = "GetResponseError Err:" + err.Error()
  1160. // return
  1161. // }
  1162. // err = os.RemoveAll(savePath)
  1163. // if err != nil {
  1164. // br.Msg = "RemoveAll Err:" + err.Error()
  1165. // return
  1166. // }
  1167. //}
  1168. }
  1169. br.Ret = 200
  1170. br.Success = true
  1171. br.Msg = "校验成功"
  1172. }