yanxuan_special.go 36 KB

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