yanxuan_special.go 34 KB

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