yanxuan_special.go 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263
  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.SendReviewCategoryTemplateMsgAdmin(specialId)
  476. go services.UpdateYanxuanSpecialResourceData(specialId) // 写入首页最新 cygx_resource_data 表
  477. go services.EsAddYanxuanSpecial(specialId) // 写入es 综合搜索
  478. }
  479. }
  480. br.Ret = 200
  481. br.Success = true
  482. br.Data = specialId
  483. }
  484. // @Title 专栏作者详情
  485. // @Description 专栏作者详情
  486. // @Param request body help_doc.AddHelpDocReq true "type json string"
  487. // @Success 200 {object} models.AddEnglishReportResp
  488. // @router /author/detail [get]
  489. func (this *YanxuanSpecialNoLoginController) AuthorDetail() {
  490. br := new(models.BaseResponse).Init()
  491. defer func() {
  492. this.Data["json"] = br
  493. this.ServeJSON()
  494. }()
  495. sysUser := this.User
  496. if sysUser == nil {
  497. br.Msg = "请登录"
  498. br.ErrMsg = "请登录,SysUser Is Empty"
  499. br.Ret = 408
  500. return
  501. }
  502. specialColumnId, _ := this.GetInt("SpecialColumnId", 0)
  503. item, tmpErr := models.GetYanxuanSpecialAuthorBySpecialColumnId(specialColumnId, sysUser.UserId)
  504. if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
  505. br.Msg = "获取失败"
  506. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  507. return
  508. }
  509. br.Data = item
  510. br.Ret = 200
  511. br.Success = true
  512. br.Msg = "获取成功"
  513. }
  514. // @Title 审批研选专栏
  515. // @Description 审批研选专栏
  516. // @Param request body help_doc.AddHelpDocReq true "type json string"
  517. // @Success 200 {object} models.AddEnglishReportResp
  518. // @router /enable [post]
  519. func (this *YanxuanSpecialController) Enable() {
  520. br := new(models.BaseResponse).Init()
  521. defer func() {
  522. this.Data["json"] = br
  523. this.ServeJSON()
  524. }()
  525. user := this.User
  526. if user == nil {
  527. br.Msg = "请登录"
  528. br.ErrMsg = "请登录,SysUser Is Empty"
  529. br.Ret = 408
  530. return
  531. }
  532. var req models.EnableCygxYanxuanSpecialReq
  533. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  534. if err != nil {
  535. br.Msg = "参数解析异常!"
  536. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  537. return
  538. }
  539. if req.Id <= 0 {
  540. br.Msg = "文章id错误"
  541. return
  542. }
  543. if req.Status <= 0 {
  544. br.Msg = "参数错误"
  545. return
  546. }
  547. status := 0
  548. if req.Status == 1 {
  549. status = 3
  550. } else {
  551. status = 4
  552. }
  553. detail, err := models.GetYanxuanSpecialItemById(req.Id)
  554. if err != nil {
  555. br.Msg = "审批失败"
  556. br.ErrMsg = "审批失败, Err:" + err.Error()
  557. return
  558. }
  559. if tmpErr := models.EnableYanxuanSpecial(req.Id, status, req.Reason, user.RealName); tmpErr != nil {
  560. br.Msg = "审批失败"
  561. br.ErrMsg = "审批失败, Err:" + tmpErr.Error()
  562. return
  563. }
  564. if req.Status == 1 {
  565. go services.SendWxMsgSpecialFollow(req.Id)
  566. go services.SendWxCategoryMsgSpecialAuthor(req.Id, 1) //研选专栏审核完成时,给提交人发送类目模板消息
  567. go services.SendWxCategoryMsgSpecialFollow(req.Id) // 研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
  568. } else {
  569. go services.SendWxCategoryMsgSpecialAuthor(req.Id, 2)
  570. }
  571. go services.SendWxMsgSpecialAuthor(req.Id, req.Status)
  572. go services.UpdateYanxuanSpecialResourceData(req.Id) // 写入首页最新 cygx_resource_data 表
  573. go services.EsAddYanxuanSpecial(req.Id) // 写入es 综合搜索
  574. go services.AddAddCygxYanxuanSpecialApprovalLog(user, req.Id, req.Status, req.Reason) // 写入es 综合搜索
  575. go services.UdpateYanxuanSpecialauthorArticleNum(detail.UserId) // 更新作者发布文章的数量
  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. item := models.CygxYanxuanSpecialFollow{
  795. UserId: user.UserId,
  796. FollowUserId: authorItem.UserId,
  797. Mobile: user.Mobile,
  798. Email: user.Email,
  799. CompanyId: user.CompanyId,
  800. CompanyName: user.CompanyName,
  801. RealName: user.RealName,
  802. SellerName: sellerName,
  803. CreateTime: time.Now(),
  804. ModifyTime: time.Now(),
  805. RegisterPlatform: utils.REGISTER_PLATFORM,
  806. YanxuanSpecialId: req.SpecialId,
  807. }
  808. err = models.AddCygxYanxuanSpecialFollow(&item)
  809. if err != nil {
  810. br.Msg = "新增失败"
  811. br.ErrMsg = "新增失败,Err:" + err.Error()
  812. return
  813. }
  814. br.Msg = "关注成功"
  815. } else {
  816. err = models.DelCygxYanxuanSpecialFollow(user.UserId, authorItem.UserId)
  817. if err != nil {
  818. br.Msg = "删除失败"
  819. br.ErrMsg = "删除失败,Err:" + err.Error()
  820. return
  821. }
  822. br.Msg = "取消关注成功"
  823. }
  824. go services.UdpateYanxuanSpecialFansNum(authorItem.UserId)
  825. br.Ret = 200
  826. br.Success = true
  827. }
  828. // @Title 行业标签搜索
  829. // @Description 行业标签搜索
  830. // @Param request body help_doc.AddHelpDocReq true "type json string"
  831. // @Success 200 {object} models.AddEnglishReportResp
  832. // @router /industrySearch [get]
  833. func (this *YanxuanSpecialController) IndustrySearch() {
  834. br := new(models.BaseResponse).Init()
  835. defer func() {
  836. this.Data["json"] = br
  837. this.ServeJSON()
  838. }()
  839. sysUser := this.User
  840. if sysUser == nil {
  841. br.Msg = "请登录"
  842. br.ErrMsg = "请登录,SysUser Is Empty"
  843. br.Ret = 408
  844. return
  845. }
  846. keyword := this.GetString("Keyword")
  847. list, tmpErr := models.GetYanxuanSpecialIndustry(keyword)
  848. if tmpErr != nil {
  849. br.Msg = "获取失败"
  850. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  851. return
  852. }
  853. br.Data = list
  854. br.Ret = 200
  855. br.Success = true
  856. br.Msg = "获取成功"
  857. }
  858. // @Title 公司标签搜索
  859. // @Description 公司标签搜索
  860. // @Param request body help_doc.AddHelpDocReq true "type json string"
  861. // @Success 200 {object} models.AddEnglishReportResp
  862. // @router /companySearch [get]
  863. func (this *YanxuanSpecialController) CompanySearch() {
  864. br := new(models.BaseResponse).Init()
  865. defer func() {
  866. this.Data["json"] = br
  867. this.ServeJSON()
  868. }()
  869. sysUser := this.User
  870. if sysUser == nil {
  871. br.Msg = "请登录"
  872. br.ErrMsg = "请登录,SysUser Is Empty"
  873. br.Ret = 408
  874. return
  875. }
  876. keyword := this.GetString("Keyword")
  877. if keyword == "" {
  878. br.Ret = 200
  879. return
  880. }
  881. list, tmpErr := models.GetYanxuanSpecialCompany(keyword)
  882. if tmpErr != nil {
  883. br.Msg = "获取失败"
  884. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  885. return
  886. }
  887. br.Data = list
  888. br.Ret = 200
  889. br.Success = true
  890. br.Msg = "获取成功"
  891. }
  892. // @Title 专栏取消发布
  893. // @Description 专栏取消发布
  894. // @Param request body help_doc.AddHelpDocReq true "type json string"
  895. // @Success 200 {object} models.AddEnglishReportResp
  896. // @router /cancel [post]
  897. func (this *YanxuanSpecialController) Cancel() {
  898. br := new(models.BaseResponse).Init()
  899. defer func() {
  900. this.Data["json"] = br
  901. this.ServeJSON()
  902. }()
  903. sysUser := this.User
  904. if sysUser == nil {
  905. br.Msg = "请登录"
  906. br.ErrMsg = "请登录,SysUser Is Empty"
  907. br.Ret = 408
  908. return
  909. }
  910. var req models.CancelPublishCygxYanxuanSpecialReq
  911. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  912. if err != nil {
  913. br.Msg = "参数解析异常!"
  914. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  915. return
  916. }
  917. if req.Id <= 0 {
  918. br.Msg = "文章id错误"
  919. return
  920. }
  921. specialItem, err := models.GetYanxuanSpecialItemById(req.Id)
  922. if err != nil {
  923. br.Msg = "专栏取消发布失败"
  924. br.ErrMsg = "专栏取消发布失败,Err:" + err.Error()
  925. return
  926. }
  927. if tmpErr := models.CancelPublishYanxuanSpecial(req.Id); tmpErr != nil {
  928. br.Msg = "取消发布失败"
  929. br.ErrMsg = "取消发布失败, Err:" + tmpErr.Error()
  930. return
  931. }
  932. go services.UpdateYanxuanSpecialResourceData(req.Id) // 写入首页最新 cygx_resource_data 表
  933. go services.EsAddYanxuanSpecial(req.Id) // 写入es 综合搜索
  934. go services.UdpateYanxuanSpecialauthorArticleNum(specialItem.UserId) // 更新作者发布文章的数量
  935. br.Msg = "取消发布成功"
  936. br.Ret = 200
  937. br.Success = true
  938. }
  939. // @Title 作者列表
  940. // @Description 作者列表
  941. // @Param PageSize query int true "每页数据条数"
  942. // @Param CurrentIndex query int true "当前页页码,从1开始"
  943. // @Success 200 {object} models.AddEnglishReportResp
  944. // @router /author/list [get]
  945. func (this *YanxuanSpecialNoLoginController) AuthorList() {
  946. br := new(models.BaseResponse).Init()
  947. defer func() {
  948. this.Data["json"] = br
  949. this.ServeJSON()
  950. }()
  951. sysUser := this.User
  952. if sysUser == nil {
  953. br.Msg = "请登录"
  954. br.ErrMsg = "请登录,SysUser Is Empty"
  955. br.Ret = 408
  956. return
  957. }
  958. pageSize, _ := this.GetInt("PageSize")
  959. currentIndex, _ := this.GetInt("CurrentIndex")
  960. var startSize int
  961. if pageSize <= 0 {
  962. pageSize = utils.PageSize20
  963. }
  964. if currentIndex <= 0 {
  965. currentIndex = 1
  966. }
  967. startSize = utils.StartIndex(currentIndex, pageSize)
  968. resp := new(models.SpecialAuthorListResp)
  969. specialAuthorCheck := services.GetYanxuanSpecialAuthorInfo(sysUser) //用户是否没开通研选专栏以及,专栏信息是否完善
  970. resp.IsAuthor = specialAuthorCheck.IsAuthor
  971. resp.IsImproveInformation = specialAuthorCheck.IsImproveInformation
  972. resp.SpecialColumnId = specialAuthorCheck.SpecialColumnId
  973. resp.HeadImg = specialAuthorCheck.HeadImg
  974. var condition string
  975. var conditionUserSort string
  976. var pars []interface{}
  977. condition += ` AND a.nick_name <> '' `
  978. conditionUserSort += ` ( IF ( a.user_id = ` + strconv.Itoa(sysUser.UserId) + `, 1 = 1, user_id = 1 ) ) AS user_sort , ` // 用户本人如果开通了专栏,就放在最前面
  979. total, err := models.GetCygxYanxuanSpecialAuthorCount(condition, pars)
  980. if err != nil {
  981. br.Msg = "获取失败"
  982. br.ErrMsg = "获取失败,Err:" + err.Error()
  983. return
  984. }
  985. condition += ` ORDER BY user_sort DESC, latest_publish_time DESC`
  986. list, tmpErr := models.GetYanxuanSpecialAuthorList(conditionUserSort, condition, pars, startSize, pageSize)
  987. if tmpErr != nil {
  988. br.Msg = "获取失败"
  989. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  990. return
  991. }
  992. //var userIds []int
  993. for _, v := range list {
  994. v.LatestPublishDate = v.LatestPublishTime.Format(utils.FormatDate) + "更新"
  995. //userIds = append(userIds, v.UserId)
  996. }
  997. page := paging.GetPaging(currentIndex, pageSize, total)
  998. resp.List = list
  999. resp.Paging = page
  1000. br.Data = resp
  1001. br.Ret = 200
  1002. br.Success = true
  1003. br.Msg = "获取成功"
  1004. }
  1005. // @Title 更新作者头像
  1006. // @Description 更新作者头像
  1007. // @Param request body help_doc.AddHelpDocReq true "type json string"
  1008. // @Success 200 {object} models.AddEnglishReportResp
  1009. // @router /author/head_img [post]
  1010. func (this *YanxuanSpecialController) AuthorHeadImg() {
  1011. br := new(models.BaseResponse).Init()
  1012. defer func() {
  1013. this.Data["json"] = br
  1014. this.ServeJSON()
  1015. }()
  1016. sysUser := this.User
  1017. if sysUser == nil {
  1018. br.Msg = "请登录"
  1019. br.ErrMsg = "请登录,SysUser Is Empty"
  1020. br.Ret = 408
  1021. return
  1022. }
  1023. var req models.SaveCygxYanxuanSpecialAuthoHeadImgrReq
  1024. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1025. if err != nil {
  1026. br.Msg = "参数解析异常!"
  1027. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1028. return
  1029. }
  1030. if req.SpecialColumnId <= 0 {
  1031. br.Msg = "专栏栏目id错误"
  1032. return
  1033. }
  1034. if req.HeadImg == "" {
  1035. br.Msg = "头像图片错误"
  1036. return
  1037. }
  1038. item := models.CygxYanxuanSpecialAuthor{
  1039. Id: req.SpecialColumnId,
  1040. HeadImg: req.HeadImg,
  1041. }
  1042. err = models.UpdateYanxuanSpecialAuthorHeadImg(&item)
  1043. if err != nil {
  1044. br.Msg = "保存失败"
  1045. br.ErrMsg = "保存失败,Err:" + err.Error()
  1046. return
  1047. }
  1048. br.Ret = 200
  1049. br.Success = true
  1050. br.Msg = "保存成功"
  1051. }
  1052. // @Title 删除专栏
  1053. // @Description 删除专栏
  1054. // @Param request body help_doc.AddHelpDocReq true "type json string"
  1055. // @Success 200 {object} models.AddEnglishReportResp
  1056. // @router /del [post]
  1057. func (this *YanxuanSpecialController) Delete() {
  1058. br := new(models.BaseResponse).Init()
  1059. defer func() {
  1060. this.Data["json"] = br
  1061. this.ServeJSON()
  1062. }()
  1063. sysUser := this.User
  1064. if sysUser == nil {
  1065. br.Msg = "请登录"
  1066. br.ErrMsg = "请登录,SysUser Is Empty"
  1067. br.Ret = 408
  1068. return
  1069. }
  1070. var req models.DelCygxYanxuanSpecialReq
  1071. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1072. if err != nil {
  1073. br.Msg = "参数解析异常!"
  1074. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1075. return
  1076. }
  1077. if req.Id <= 0 {
  1078. br.Msg = "文章id错误"
  1079. return
  1080. }
  1081. if tmpErr := models.DelYanxuanSpecial(req.Id); tmpErr != nil {
  1082. br.Msg = "删除失败"
  1083. br.ErrMsg = "删除失败, Err:" + tmpErr.Error()
  1084. return
  1085. }
  1086. br.Msg = "删除成功"
  1087. br.Ret = 200
  1088. br.Success = true
  1089. }
  1090. // @Title 专栏文章敏感词检测
  1091. // @Description 专栏文章敏感词检测
  1092. // @Param request body help_doc.AddHelpDocReq true "type json string"
  1093. // @Success 200 {object} models.AddEnglishReportResp
  1094. // @router /check [post]
  1095. func (this *YanxuanSpecialController) Check() {
  1096. br := new(models.BaseResponse).Init()
  1097. defer func() {
  1098. this.Data["json"] = br
  1099. this.ServeJSON()
  1100. }()
  1101. sysUser := this.User
  1102. if sysUser == nil {
  1103. br.Msg = "请登录"
  1104. br.ErrMsg = "请登录,SysUser Is Empty"
  1105. br.Ret = 408
  1106. return
  1107. }
  1108. var req models.CygxYanxuanSpecialCheckReq
  1109. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1110. if err != nil {
  1111. br.Msg = "参数解析异常!"
  1112. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1113. return
  1114. }
  1115. if req.Content == "" {
  1116. br.Ret = 200
  1117. br.Success = true
  1118. br.Msg = "校验成功"
  1119. }
  1120. itemToken, err := services.WxGetToken()
  1121. if err != nil {
  1122. br.Msg = "GetWxAccessToken Err:" + err.Error()
  1123. return
  1124. }
  1125. if itemToken.AccessToken == "" {
  1126. br.Msg = "accessToken is empty"
  1127. return
  1128. }
  1129. suggest := models.WxCheckContent(itemToken.AccessToken, sysUser.OpenId, req.Content)
  1130. if suggest == "risky" {
  1131. br.Msg = "文章内容含有违法违规内容"
  1132. br.ErrMsg = "文章内容含有违法违规内容"
  1133. return
  1134. }
  1135. if len(req.ImgUrl) > 0 {
  1136. //for _, imgUrl := range req.ImgUrl {
  1137. // imgBody, err := http.Get(imgUrl)
  1138. // if err != nil {
  1139. // br.Msg = "图片链接有误"
  1140. // br.ErrMsg = "图片链接有误"
  1141. // return
  1142. // }
  1143. // rnStr := utils.GetRandStringNoSpecialChar(5)
  1144. // savePath := time.Now().Format(utils.FormatDateTimeUnSpace) + rnStr + ".jpg"
  1145. // err = file.SaveFile(imgBody, savePath)
  1146. // if err != nil {
  1147. // br.Msg = "保存图片错误"
  1148. // br.ErrMsg = "保存图片错误"
  1149. // return
  1150. // }
  1151. // res, err := weapp.IMGSecCheck(itemToken.AccessToken, savePath)
  1152. // if err != nil {
  1153. // // 处理一般错误信息
  1154. // br.Msg = "图片内容含有违法违规内容"
  1155. // br.ErrMsg = "图片内容含有违法违规内容"
  1156. // return
  1157. // }
  1158. // if err := res.GetResponseError(); err != nil {
  1159. // // 处理微信返回错误信息
  1160. // br.Msg = "GetResponseError Err:" + err.Error()
  1161. // return
  1162. // }
  1163. // err = os.RemoveAll(savePath)
  1164. // if err != nil {
  1165. // br.Msg = "RemoveAll Err:" + err.Error()
  1166. // return
  1167. // }
  1168. //}
  1169. }
  1170. br.Ret = 200
  1171. br.Success = true
  1172. br.Msg = "校验成功"
  1173. }