yanxuan_special.go 36 KB

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