yanxuan_special.go 35 KB

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