yanxuan_special.go 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_cygx/models"
  6. "hongze/hongze_cygx/services"
  7. "hongze/hongze_cygx/utils"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. type YanxuanSpecialController struct {
  13. BaseAuthController
  14. }
  15. // @Title 专栏列表
  16. // @Description 专栏列表
  17. // @Param UserId query int true "用户ID"
  18. // @Param PageSize query int true "每页数据条数"
  19. // @Param CurrentIndex query int true "当前页页码,从1开始"
  20. // @Param Status query int false "研选专栏装态"
  21. // @Success 200 {object} models.SpecialListResp
  22. // @router /list [get]
  23. func (this *YanxuanSpecialController) List() {
  24. br := new(models.BaseResponse).Init()
  25. defer func() {
  26. this.Data["json"] = br
  27. this.ServeJSON()
  28. }()
  29. sysUser := this.User
  30. if sysUser == nil {
  31. br.Msg = "请登录"
  32. br.ErrMsg = "请登录,SysUser Is Empty"
  33. br.Ret = 408
  34. return
  35. }
  36. userId, _ := this.GetInt("UserId", 0)
  37. pageSize, _ := this.GetInt("PageSize")
  38. currentIndex, _ := this.GetInt("CurrentIndex")
  39. status, _ := this.GetInt("Status")
  40. var startSize int
  41. if pageSize <= 0 {
  42. pageSize = utils.PageSize20
  43. }
  44. if currentIndex <= 0 {
  45. currentIndex = 1
  46. }
  47. startSize = utils.StartIndex(currentIndex, pageSize)
  48. resp := new(models.SpecialListResp)
  49. var condition string
  50. var pars []interface{}
  51. if userId > 0 {
  52. condition += ` AND a.user_id = ? `
  53. pars = append(pars, userId)
  54. }
  55. if status == 2 {
  56. condition += ` AND a.status = 2 `
  57. } else {
  58. condition += ` AND a.status = 3 `
  59. }
  60. total, err := models.GetCygxYanxuanSpecialCount(condition, pars)
  61. if err != nil {
  62. br.Msg = "获取失败"
  63. br.ErrMsg = "获取失败, Err:" + err.Error()
  64. return
  65. }
  66. list, err := models.GetYanxuanSpecialList(sysUser.UserId, condition, pars, startSize, pageSize)
  67. if err != nil {
  68. br.Msg = "获取失败"
  69. br.ErrMsg = "获取失败, Err:" + err.Error()
  70. return
  71. }
  72. for _, v := range list {
  73. hasImg, err := utils.ArticleHasImgUrl(v.Content)
  74. if err != nil {
  75. return
  76. }
  77. if hasImg {
  78. v.ContentHasImg = 1
  79. }
  80. v.Content = utils.ArticleRemoveImgUrl(v.Content)
  81. //v.Content, err = utils.ExtractText(v.Content)
  82. //if err != nil {
  83. // return
  84. //}
  85. //v.Content, _ = services.GetReportContentTextSubNew(v.Content)
  86. v.Content = services.AnnotationHtml(v.Content)
  87. if v.DocUrl != "" {
  88. var docs []models.Doc
  89. err := json.Unmarshal([]byte(v.DocUrl), &docs)
  90. if err != nil {
  91. br.Msg = "参数解析异常!"
  92. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  93. return
  94. }
  95. v.Docs = docs
  96. }
  97. if v.MyCollectNum > 0 {
  98. v.IsCollect = 1
  99. }
  100. if v.CompanyTags != "" {
  101. v.Tags += v.CompanyTags
  102. }
  103. if v.IndustryTags != "" {
  104. if v.Tags != "" {
  105. v.Tags += ","
  106. }
  107. v.Tags += v.IndustryTags
  108. }
  109. }
  110. isAuthor, isImproveInformation := services.GetYanxuanSpecialAuthorInfo(sysUser) //用户是否没开通研选专栏以及,专栏信息是否完善
  111. resp.IsAuthor = isAuthor
  112. resp.IsImproveInformation = isImproveInformation
  113. resp.List = list
  114. page := paging.GetPaging(currentIndex, pageSize, total)
  115. resp.Paging = page
  116. br.Data = resp
  117. br.Ret = 200
  118. br.Success = true
  119. br.Msg = "获取成功"
  120. }
  121. // @Title 专栏详情
  122. // @Description 专栏详情
  123. // @Param IsSendWx query int false "是否是通过微信模版进来的 1是,其它否"
  124. // @Param Id query int true "详情ID"
  125. // @Success 200 {object} models.AddEnglishReportResp
  126. // @router /detail [get]
  127. func (this *YanxuanSpecialController) Detail() {
  128. br := new(models.BaseResponse).Init()
  129. defer func() {
  130. this.Data["json"] = br
  131. this.ServeJSON()
  132. }()
  133. sysUser := this.User
  134. if sysUser == nil {
  135. br.Msg = "请登录"
  136. br.ErrMsg = "请登录,SysUser Is Empty"
  137. br.Ret = 408
  138. return
  139. }
  140. specialId, _ := this.GetInt("Id", 0)
  141. isSendWx, _ := this.GetInt("IsSendWx", 0)
  142. if specialId <= 0 {
  143. br.Msg = "参数错误"
  144. br.ErrMsg = "参数错误"
  145. return
  146. }
  147. item, tmpErr := models.GetYanxuanSpecialById(specialId, sysUser.UserId)
  148. if tmpErr != nil {
  149. br.Msg = "获取失败"
  150. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  151. return
  152. }
  153. if item.MyCollectNum > 0 {
  154. item.IsCollect = 1
  155. }
  156. var resp models.CygxYanxuanSpecialResp
  157. resp.HasPermission = 1
  158. resp.CygxYanxuanSpecialItem = *item
  159. if item.DocUrl != "" {
  160. var docs []models.Doc
  161. err := json.Unmarshal([]byte(item.DocUrl), &docs)
  162. if err != nil {
  163. br.Msg = "参数解析异常!"
  164. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  165. return
  166. }
  167. resp.Docs = docs
  168. }
  169. if item.CompanyTags != "" {
  170. resp.Tags += item.CompanyTags
  171. resp.CompanyTags = append(resp.CompanyTags, item.CompanyTags)
  172. }
  173. if item.IndustryTags != "" {
  174. if resp.Tags != "" {
  175. resp.Tags += ","
  176. }
  177. resp.Tags += item.IndustryTags
  178. resp.IndustryTags = strings.Split(item.IndustryTags, ",")
  179. }
  180. //如果状态未审核通过,而且查看的不是本人,不是审核人员,就无法查看详情
  181. var configCode string
  182. configCode = utils.TPL_MSG_WANG_FANG_WANG_YANG
  183. cnf, err := models.GetConfigByCode(configCode)
  184. if err != nil {
  185. br.Msg = "获取失败"
  186. br.ErrMsg = "获取失败, Err:" + err.Error()
  187. return
  188. }
  189. if isSendWx == 1 && strings.Contains(cnf.ConfigValue, sysUser.Mobile) {
  190. resp.IsShowExamine = true
  191. resp.ExamineStatus = item.Status
  192. }
  193. resp.ExamineStatus = item.Status
  194. if item.UserId != sysUser.UserId && item.Status != 3 && !strings.Contains(cnf.ConfigValue, sysUser.Mobile) {
  195. resp.CygxYanxuanSpecialItem = *new(models.CygxYanxuanSpecialItem) // 如果内容不可见,就把内容置空
  196. //resp.HasPermission = 2
  197. }
  198. //如果是用户本人写的专栏,那么就不做校验
  199. //if item.UserId == sysUser.UserId || sysUser.UserId == 0 {
  200. // resp.HasPermission = 1
  201. //} else {
  202. // hasPermission, err := services.GetUserRaiPermissionYanXuanInfo(sysUser)
  203. // if err != nil {
  204. // br.Msg = "获取失败"
  205. // br.ErrMsg = "获取失败, Err:" + err.Error()
  206. // return
  207. // }
  208. // resp.HasPermission = hasPermission
  209. //}
  210. //如果在web端有样式或者上传了文件,小程序就禁止编辑修改内容
  211. hasStyle, err := utils.ArticleHasStyle(item.Content)
  212. if err != nil {
  213. return
  214. }
  215. hasImg, err := utils.ArticleHasImgUrl(item.Content)
  216. if err != nil {
  217. return
  218. }
  219. if hasStyle || strings.Contains(item.DocUrl, "http") || hasImg {
  220. resp.ContentHasStyle = true
  221. }
  222. if resp.HasPermission != 1 || sysUser.UserId == 0 {
  223. resp.Content = services.AnnotationHtml(resp.Content)
  224. }
  225. br.Data = resp
  226. br.Ret = 200
  227. br.Success = true
  228. br.Msg = "获取成功"
  229. }
  230. // @Title 新增保存专栏作者详情
  231. // @Description 新增保存专栏作者详情
  232. // @Param request body help_doc.AddHelpDocReq true "type json string"
  233. // @Success 200 {object} models.AddEnglishReportResp
  234. // @router /author/save [post]
  235. func (this *YanxuanSpecialController) AuthorSave() {
  236. br := new(models.BaseResponse).Init()
  237. defer func() {
  238. this.Data["json"] = br
  239. this.ServeJSON()
  240. }()
  241. sysUser := this.User
  242. if sysUser == nil {
  243. br.Msg = "请登录"
  244. br.ErrMsg = "请登录,SysUser Is Empty"
  245. br.Ret = 408
  246. return
  247. }
  248. var req models.SaveCygxYanxuanSpecialAuthorReq
  249. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  250. if err != nil {
  251. br.Msg = "参数解析异常!"
  252. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  253. return
  254. }
  255. if req.UserId <= 0 {
  256. br.Msg = "用户id有误"
  257. return
  258. }
  259. if req.SpecialName == "" {
  260. br.Msg = "请输入专栏名称"
  261. return
  262. }
  263. if req.NickName == "" {
  264. br.Msg = "请输入昵称"
  265. return
  266. }
  267. item := models.CygxYanxuanSpecialAuthor{
  268. UserId: req.UserId,
  269. SpecialName: req.SpecialName,
  270. Introduction: req.Introduction,
  271. Label: req.Label,
  272. NickName: req.NickName,
  273. CreateTime: time.Now(),
  274. ModifyTime: time.Now(),
  275. BgImg: "",
  276. Status: 1,
  277. }
  278. //if req.Id == 0{
  279. // _, err = models.AddCygxYanxuanSpecialAuthor(&item)
  280. // if err != nil {
  281. // br.Msg = "新增失败"
  282. // br.ErrMsg = "新增失败,Err:" + err.Error()
  283. // return
  284. // }
  285. //} else {
  286. // err = models.UpdateYanxuanSpecialAuthor(&item)
  287. // if err != nil {
  288. // br.Msg = "保存失败"
  289. // br.ErrMsg = "保存失败,Err:" + err.Error()
  290. // return
  291. // }
  292. //}
  293. err = models.UpdateYanxuanSpecialAuthor(&item)
  294. if err != nil {
  295. br.Msg = "保存失败"
  296. br.ErrMsg = "保存失败,Err:" + err.Error()
  297. return
  298. }
  299. br.Ret = 200
  300. br.Success = true
  301. br.Msg = "保存成功"
  302. }
  303. // @Title 新增保存专栏
  304. // @Description 新增保存专栏
  305. // @Param request body help_doc.AddHelpDocReq true "type json string"
  306. // @Success 200 {object} models.AddEnglishReportResp
  307. // @router /save [post]
  308. func (this *YanxuanSpecialController) Save() {
  309. br := new(models.BaseResponse).Init()
  310. defer func() {
  311. this.Data["json"] = br
  312. this.ServeJSON()
  313. }()
  314. sysUser := this.User
  315. if sysUser == nil {
  316. br.Msg = "请登录"
  317. br.ErrMsg = "请登录,SysUser Is Empty"
  318. br.Ret = 408
  319. return
  320. }
  321. var req models.CygxYanxuanSpecialReq
  322. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  323. if err != nil {
  324. br.Msg = "参数解析异常!"
  325. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  326. return
  327. }
  328. if req.Content == "" && req.DoType == 2 {
  329. br.Msg = "请输入内容"
  330. return
  331. }
  332. if req.CompanyTags == "" && req.IndustryTags == "" && req.DoType == 2 {
  333. br.Msg = "请至少输入一个标签"
  334. return
  335. }
  336. isApprovalPersonnel := req.IsApprovalPersonnel
  337. item := models.CygxYanxuanSpecial{
  338. Id: req.Id,
  339. UserId: sysUser.UserId,
  340. CreateTime: time.Now(),
  341. ModifyTime: time.Now(),
  342. PublishTime: time.Now(),
  343. Content: req.Content,
  344. ImgUrl: req.ImgUrl,
  345. DocUrl: req.DocUrl,
  346. Title: req.Title,
  347. Type: req.Type,
  348. CompanyTags: req.CompanyTags,
  349. IndustryTags: req.IndustryTags,
  350. }
  351. if req.DoType == 1 {
  352. item.Status = 1
  353. } else {
  354. item.Status = 2
  355. }
  356. var authorUserId int
  357. // 如果是审批人员操作的那么就是修改内容,加审批通过
  358. if isApprovalPersonnel {
  359. item.Status = 3
  360. //校验是否属于审核人员
  361. if !services.CheckYxSpecialIsApprovalPersonnel(sysUser.Mobile) {
  362. br.Msg = "操作失败"
  363. br.ErrMsg = "操作失败,该账号不属于审核人员:" + sysUser.Mobile
  364. return
  365. }
  366. specialItem, err := models.GetYanxuanSpecialItemById(req.Id)
  367. if err != nil {
  368. br.Msg = "保存失败"
  369. br.ErrMsg = "保存失败,Err:" + err.Error()
  370. return
  371. }
  372. item.UserId = specialItem.UserId // 专栏userid还是原有userId
  373. authorUserId = specialItem.UserId
  374. item.AdminName = sysUser.RealName //审核人员姓名
  375. }
  376. specialId := 0
  377. if req.Id == 0 {
  378. id, err := models.AddCygxYanxuanSpecial(&item)
  379. if err != nil {
  380. br.Msg = "新增失败"
  381. br.ErrMsg = "新增失败,Err:" + err.Error()
  382. return
  383. }
  384. specialId = int(id)
  385. } else {
  386. err = models.UpdateYanxuanSpecial(&item)
  387. if err != nil {
  388. br.Msg = "保存失败"
  389. br.ErrMsg = "保存失败,Err:" + err.Error()
  390. return
  391. }
  392. specialId = req.Id
  393. }
  394. if isApprovalPersonnel {
  395. go services.UpdateYanxuanSpecialResourceData(specialId) // 写入首页最新 cygx_resource_data 表
  396. go services.EsAddYanxuanSpecial(specialId) // 写入es 综合搜索
  397. go services.SendWxMsgSpecialFollow(req.Id) //研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
  398. go services.SendWxMsgSpecialAuthor(req.Id, 2) //研选专栏审核完成时,给提交人发送模板消息
  399. go services.UdpateYanxuanSpecialauthorArticleNum(authorUserId) // 更新作者发布文章的数量
  400. } else {
  401. if req.DoType == 2 {
  402. go services.SendReviewTemplateMsgAdmin(specialId)
  403. go services.UpdateYanxuanSpecialResourceData(specialId) // 写入首页最新 cygx_resource_data 表
  404. go services.EsAddYanxuanSpecial(specialId) // 写入es 综合搜索
  405. }
  406. }
  407. br.Ret = 200
  408. br.Success = true
  409. br.Msg = "保存成功"
  410. }
  411. // @Title 专栏作者详情
  412. // @Description 专栏作者详情
  413. // @Param request body help_doc.AddHelpDocReq true "type json string"
  414. // @Success 200 {object} models.AddEnglishReportResp
  415. // @router /author/detail [get]
  416. func (this *YanxuanSpecialController) AuthorDetail() {
  417. br := new(models.BaseResponse).Init()
  418. defer func() {
  419. this.Data["json"] = br
  420. this.ServeJSON()
  421. }()
  422. sysUser := this.User
  423. if sysUser == nil {
  424. br.Msg = "请登录"
  425. br.ErrMsg = "请登录,SysUser Is Empty"
  426. br.Ret = 408
  427. return
  428. }
  429. userId, _ := this.GetInt("UserId", 0)
  430. if userId == 0 {
  431. userId = sysUser.UserId
  432. }
  433. item, tmpErr := models.GetYanxuanSpecialAuthor(userId, sysUser.UserId, "")
  434. if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
  435. br.Msg = "获取失败"
  436. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  437. return
  438. }
  439. br.Data = item
  440. br.Ret = 200
  441. br.Success = true
  442. br.Msg = "获取成功"
  443. }
  444. // @Title 审批研选专栏
  445. // @Description 审批研选专栏
  446. // @Param request body help_doc.AddHelpDocReq true "type json string"
  447. // @Success 200 {object} models.AddEnglishReportResp
  448. // @router /enable [post]
  449. func (this *YanxuanSpecialController) Enable() {
  450. br := new(models.BaseResponse).Init()
  451. defer func() {
  452. this.Data["json"] = br
  453. this.ServeJSON()
  454. }()
  455. user := this.User
  456. if user == nil {
  457. br.Msg = "请登录"
  458. br.ErrMsg = "请登录,SysUser Is Empty"
  459. br.Ret = 408
  460. return
  461. }
  462. var req models.EnableCygxYanxuanSpecialReq
  463. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  464. if err != nil {
  465. br.Msg = "参数解析异常!"
  466. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  467. return
  468. }
  469. if req.Id <= 0 {
  470. br.Msg = "文章id错误"
  471. return
  472. }
  473. if req.Status <= 0 {
  474. br.Msg = "参数错误"
  475. return
  476. }
  477. status := 0
  478. if req.Status == 1 {
  479. status = 3
  480. } else {
  481. status = 4
  482. }
  483. detail, err := models.GetYanxuanSpecialItemById(req.Id)
  484. if err != nil {
  485. br.Msg = "审批失败"
  486. br.ErrMsg = "审批失败, Err:" + err.Error()
  487. return
  488. }
  489. if tmpErr := models.EnableYanxuanSpecial(req.Id, status, req.Reason, user.RealName); tmpErr != nil {
  490. br.Msg = "审批失败"
  491. br.ErrMsg = "审批失败, Err:" + tmpErr.Error()
  492. return
  493. }
  494. if req.Status == 1 {
  495. go services.SendWxMsgSpecialFollow(req.Id)
  496. }
  497. go services.SendWxMsgSpecialAuthor(req.Id, req.Status)
  498. go services.UpdateYanxuanSpecialResourceData(req.Id) // 写入首页最新 cygx_resource_data 表
  499. go services.EsAddYanxuanSpecial(req.Id) // 写入es 综合搜索
  500. go services.AddAddCygxYanxuanSpecialApprovalLog(user, req.Id, req.Status, req.Reason) // 添加审核记录日志
  501. go services.UdpateYanxuanSpecialauthorArticleNum(detail.UserId) // 更新作者发布文章的数量
  502. br.Msg = "审批成功"
  503. br.Ret = 200
  504. br.Success = true
  505. }
  506. // @Title 研选专栏收藏
  507. // @Description 研选专栏收藏
  508. // @Param request body help_doc.AddHelpDocReq true "type json string"
  509. // @Success 200 {object} models.AddEnglishReportResp
  510. // @router /collect [post]
  511. func (this *YanxuanSpecialController) Collect() {
  512. br := new(models.BaseResponse).Init()
  513. defer func() {
  514. this.Data["json"] = br
  515. this.ServeJSON()
  516. }()
  517. user := this.User
  518. if user == nil {
  519. br.Msg = "请登录"
  520. br.ErrMsg = "请登录,SysUser Is Empty"
  521. br.Ret = 408
  522. return
  523. }
  524. var req models.CollectCygxYanxuanSpecialReq
  525. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  526. if err != nil {
  527. br.Msg = "参数解析异常!"
  528. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  529. return
  530. }
  531. if req.Id <= 0 {
  532. br.Msg = "文章id错误"
  533. return
  534. }
  535. if req.Status <= 0 {
  536. br.Msg = "参数错误"
  537. return
  538. }
  539. var sellerName string
  540. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  541. if err != nil {
  542. br.Msg = "查询栏目详情失败!"
  543. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  544. return
  545. }
  546. sellerName = sellerItemQy.RealName
  547. if req.Status == 1 {
  548. item := models.CygxYanxuanSpecialCollect{
  549. UserId: user.UserId,
  550. Mobile: user.Mobile,
  551. Email: user.Email,
  552. CompanyId: user.CompanyId,
  553. CompanyName: user.CompanyName,
  554. RealName: user.RealName,
  555. SellerName: sellerName,
  556. CreateTime: time.Now(),
  557. ModifyTime: time.Now(),
  558. RegisterPlatform: utils.REGISTER_PLATFORM,
  559. YanxuanSpecialId: req.Id,
  560. }
  561. _, err = models.AddCygxYanxuanSpecialCollect(&item)
  562. if err != nil {
  563. br.Msg = "新增失败"
  564. br.ErrMsg = "新增失败,Err:" + err.Error()
  565. return
  566. }
  567. br.Msg = "收藏成功"
  568. } else {
  569. err = models.DelCygxYanxuanSpecialCollect(user.UserId, req.Id)
  570. if err != nil {
  571. br.Msg = "删除失败"
  572. br.ErrMsg = "删除失败,Err:" + err.Error()
  573. return
  574. }
  575. br.Msg = "取消收藏成功"
  576. }
  577. go services.UdpateYanxuanSpecialCollect(req.Id)
  578. br.Ret = 200
  579. br.Success = true
  580. }
  581. // @Title 专栏内容中心
  582. // @Description 专栏内容中心
  583. // @Param request body help_doc.AddHelpDocReq true "type json string"
  584. // @Success 200 {object} models.AddEnglishReportResp
  585. // @router /center [get]
  586. func (this *YanxuanSpecialController) Center() {
  587. br := new(models.BaseResponse).Init()
  588. defer func() {
  589. this.Data["json"] = br
  590. this.ServeJSON()
  591. }()
  592. sysUser := this.User
  593. if sysUser == nil {
  594. br.Msg = "请登录"
  595. br.ErrMsg = "请登录,SysUser Is Empty"
  596. br.Ret = 408
  597. return
  598. }
  599. // 1:未发布,2:审核中 3:已发布 4:驳回
  600. status, _ := this.GetInt("Status", 0)
  601. if status <= 0 {
  602. br.Msg = "参数错误"
  603. br.ErrMsg = "参数错误"
  604. return
  605. }
  606. var condition string
  607. var pars []interface{}
  608. condition += ` AND a.user_id = ? `
  609. pars = append(pars, sysUser.UserId)
  610. condition += ` AND a.status = ? `
  611. pars = append(pars, status)
  612. list, tmpErr := models.GetYanxuanSpecialList(sysUser.UserId, condition, pars, 0, 0)
  613. if tmpErr != nil {
  614. br.Msg = "获取失败"
  615. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  616. return
  617. }
  618. for _, v := range list {
  619. //如果在web端有样式或者上传了文件,小程序就禁止编辑修改内容
  620. hasStyle, err := utils.ArticleHasStyle(v.Content)
  621. if err != nil {
  622. return
  623. }
  624. hasImg, err := utils.ArticleHasImgUrl(v.Content)
  625. if err != nil {
  626. return
  627. }
  628. if hasStyle || strings.Contains(v.DocUrl, "http") || hasImg {
  629. v.ContentHasStyle = true
  630. }
  631. }
  632. br.Data = list
  633. br.Ret = 200
  634. br.Success = true
  635. br.Msg = "获取成功"
  636. }
  637. // @Title 专栏点击记录
  638. // @Description 专栏点击记录
  639. // @Param request body models.AddCygxYanxuanSpecialRecordReq true "type json string"
  640. // @router /record [post]
  641. func (this *YanxuanSpecialController) Record() {
  642. br := new(models.BaseResponse).Init()
  643. defer func() {
  644. this.Data["json"] = br
  645. this.ServeJSON()
  646. }()
  647. user := this.User
  648. if user == nil {
  649. br.Msg = "请重新登录"
  650. br.Ret = 408
  651. return
  652. }
  653. var req models.AddCygxYanxuanSpecialRecordReq
  654. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  655. if err != nil {
  656. br.Msg = "参数解析异常!"
  657. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  658. return
  659. }
  660. specialId := req.SpecialId
  661. stopTime := req.StopTime
  662. if req.SpecialId <= 0 {
  663. br.Msg = "文章不存在"
  664. br.ErrMsg = "文章不存在,文章ID错误"
  665. return
  666. }
  667. err = services.AddSpecialRecord(this.User, specialId, stopTime)
  668. if err != nil {
  669. br.Msg = "记录失败"
  670. br.ErrMsg = "记录失败,Err:" + err.Error()
  671. return
  672. }
  673. br.Ret = 200
  674. br.Success = true
  675. br.Msg = "记录成功"
  676. }
  677. // @Title 研选专栏关注
  678. // @Description 研选专栏关注
  679. // @Param request body help_doc.AddHelpDocReq true "type json string"
  680. // @Success 200 {object} models.AddEnglishReportResp
  681. // @router /follow [post]
  682. func (this *YanxuanSpecialController) Follow() {
  683. br := new(models.BaseResponse).Init()
  684. defer func() {
  685. this.Data["json"] = br
  686. this.ServeJSON()
  687. }()
  688. user := this.User
  689. if user == nil {
  690. br.Msg = "请登录"
  691. br.ErrMsg = "请登录,SysUser Is Empty"
  692. br.Ret = 408
  693. return
  694. }
  695. var req models.FollowCygxYanxuanSpecialReq
  696. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  697. if err != nil {
  698. br.Msg = "参数解析异常!"
  699. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  700. return
  701. }
  702. if req.FollowUserId <= 0 {
  703. br.Msg = "被关注的用户id"
  704. return
  705. }
  706. if req.Status <= 0 {
  707. br.Msg = "参数错误"
  708. return
  709. }
  710. var sellerName string
  711. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  712. if err != nil {
  713. br.Msg = "查询栏目详情失败!"
  714. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  715. return
  716. }
  717. sellerName = sellerItemQy.RealName
  718. if req.Status == 1 {
  719. item := models.CygxYanxuanSpecialFollow{
  720. UserId: user.UserId,
  721. FollowUserId: req.FollowUserId,
  722. Mobile: user.Mobile,
  723. Email: user.Email,
  724. CompanyId: user.CompanyId,
  725. CompanyName: user.CompanyName,
  726. RealName: user.RealName,
  727. SellerName: sellerName,
  728. CreateTime: time.Now(),
  729. ModifyTime: time.Now(),
  730. RegisterPlatform: utils.REGISTER_PLATFORM,
  731. YanxuanSpecialId: req.SpecialId,
  732. }
  733. err = models.AddCygxYanxuanSpecialFollow(&item)
  734. if err != nil {
  735. br.Msg = "新增失败"
  736. br.ErrMsg = "新增失败,Err:" + err.Error()
  737. return
  738. }
  739. br.Msg = "关注成功"
  740. } else {
  741. err = models.DelCygxYanxuanSpecialFollow(user.UserId, req.FollowUserId)
  742. if err != nil {
  743. br.Msg = "删除失败"
  744. br.ErrMsg = "删除失败,Err:" + err.Error()
  745. return
  746. }
  747. br.Msg = "取消关注成功"
  748. }
  749. go services.UdpateYanxuanSpecialFansNum(req.FollowUserId)
  750. br.Ret = 200
  751. br.Success = true
  752. }
  753. // @Title 行业标签搜索
  754. // @Description 行业标签搜索
  755. // @Param request body help_doc.AddHelpDocReq true "type json string"
  756. // @Success 200 {object} models.AddEnglishReportResp
  757. // @router /industrySearch [get]
  758. func (this *YanxuanSpecialController) IndustrySearch() {
  759. br := new(models.BaseResponse).Init()
  760. defer func() {
  761. this.Data["json"] = br
  762. this.ServeJSON()
  763. }()
  764. sysUser := this.User
  765. if sysUser == nil {
  766. br.Msg = "请登录"
  767. br.ErrMsg = "请登录,SysUser Is Empty"
  768. br.Ret = 408
  769. return
  770. }
  771. keyword := this.GetString("Keyword")
  772. list, tmpErr := models.GetYanxuanSpecialIndustry(keyword)
  773. if tmpErr != nil {
  774. br.Msg = "获取失败"
  775. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  776. return
  777. }
  778. br.Data = list
  779. br.Ret = 200
  780. br.Success = true
  781. br.Msg = "获取成功"
  782. }
  783. // @Title 公司标签搜索
  784. // @Description 公司标签搜索
  785. // @Param request body help_doc.AddHelpDocReq true "type json string"
  786. // @Success 200 {object} models.AddEnglishReportResp
  787. // @router /companySearch [get]
  788. func (this *YanxuanSpecialController) CompanySearch() {
  789. br := new(models.BaseResponse).Init()
  790. defer func() {
  791. this.Data["json"] = br
  792. this.ServeJSON()
  793. }()
  794. sysUser := this.User
  795. if sysUser == nil {
  796. br.Msg = "请登录"
  797. br.ErrMsg = "请登录,SysUser Is Empty"
  798. br.Ret = 408
  799. return
  800. }
  801. keyword := this.GetString("Keyword")
  802. if keyword == "" {
  803. br.Ret = 200
  804. return
  805. }
  806. list, tmpErr := models.GetYanxuanSpecialCompany(keyword)
  807. if tmpErr != nil {
  808. br.Msg = "获取失败"
  809. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  810. return
  811. }
  812. br.Data = list
  813. br.Ret = 200
  814. br.Success = true
  815. br.Msg = "获取成功"
  816. }
  817. // @Title 专栏取消发布
  818. // @Description 专栏取消发布
  819. // @Param request body help_doc.AddHelpDocReq true "type json string"
  820. // @Success 200 {object} models.AddEnglishReportResp
  821. // @router /cancel [post]
  822. func (this *YanxuanSpecialController) Cancel() {
  823. br := new(models.BaseResponse).Init()
  824. defer func() {
  825. this.Data["json"] = br
  826. this.ServeJSON()
  827. }()
  828. sysUser := this.User
  829. if sysUser == nil {
  830. br.Msg = "请登录"
  831. br.ErrMsg = "请登录,SysUser Is Empty"
  832. br.Ret = 408
  833. return
  834. }
  835. var req models.CancelPublishCygxYanxuanSpecialReq
  836. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  837. if err != nil {
  838. br.Msg = "参数解析异常!"
  839. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  840. return
  841. }
  842. if req.Id <= 0 {
  843. br.Msg = "文章id错误"
  844. return
  845. }
  846. specialItem, err := models.GetYanxuanSpecialItemById(req.Id)
  847. if err != nil {
  848. br.Msg = "专栏取消发布失败"
  849. br.ErrMsg = "专栏取消发布失败,Err:" + err.Error()
  850. return
  851. }
  852. if tmpErr := models.CancelPublishYanxuanSpecial(req.Id); tmpErr != nil {
  853. br.Msg = "取消发布失败"
  854. br.ErrMsg = "取消发布失败, Err:" + tmpErr.Error()
  855. return
  856. }
  857. go services.UpdateYanxuanSpecialResourceData(req.Id) // 写入首页最新 cygx_resource_data 表
  858. go services.EsAddYanxuanSpecial(req.Id) // 写入es 综合搜索
  859. go services.UdpateYanxuanSpecialauthorArticleNum(specialItem.UserId) // 更新作者发布文章的数量
  860. br.Msg = "取消发布成功"
  861. br.Ret = 200
  862. br.Success = true
  863. }
  864. // @Title 作者列表
  865. // @Description 作者列表
  866. // @Param PageSize query int true "每页数据条数"
  867. // @Param CurrentIndex query int true "当前页页码,从1开始"
  868. // @Success 200 {object} models.AddEnglishReportResp
  869. // @router /author/list [get]
  870. func (this *YanxuanSpecialController) AuthorList() {
  871. br := new(models.BaseResponse).Init()
  872. defer func() {
  873. this.Data["json"] = br
  874. this.ServeJSON()
  875. }()
  876. sysUser := this.User
  877. if sysUser == nil {
  878. br.Msg = "请登录"
  879. br.ErrMsg = "请登录,SysUser Is Empty"
  880. br.Ret = 408
  881. return
  882. }
  883. pageSize, _ := this.GetInt("PageSize")
  884. currentIndex, _ := this.GetInt("CurrentIndex")
  885. var startSize int
  886. if pageSize <= 0 {
  887. pageSize = utils.PageSize20
  888. }
  889. if currentIndex <= 0 {
  890. currentIndex = 1
  891. }
  892. startSize = utils.StartIndex(currentIndex, pageSize)
  893. var condition string
  894. var pars []interface{}
  895. condition += ` AND a.nick_name <> '' `
  896. total, err := models.GetCygxYanxuanSpecialAuthorCount(condition, pars)
  897. if err != nil {
  898. br.Msg = "获取失败"
  899. br.ErrMsg = "获取失败,Err:" + err.Error()
  900. return
  901. }
  902. condition += ` ORDER BY latest_publish_time DESC`
  903. list, tmpErr := models.GetYanxuanSpecialAuthorList(condition, pars, startSize, pageSize)
  904. if tmpErr != nil {
  905. br.Msg = "获取失败"
  906. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  907. return
  908. }
  909. var userIds []int
  910. for _, v := range list {
  911. v.LatestPublishDate = v.LatestPublishTime.Format(utils.FormatDate) + "更新"
  912. userIds = append(userIds, v.UserId)
  913. }
  914. bestNew := services.GetBestNewYanxuanSpecialByUserId(userIds)
  915. for _, v := range list {
  916. v.YanxuanSpecialCenter = bestNew[v.UserId]
  917. }
  918. resp := new(models.SpecialAuthorListResp)
  919. isAuthor, _ := services.GetYanxuanSpecialAuthorInfo(sysUser) //用户是否没开通研选专栏以及,专栏信息是否完善
  920. resp.IsAuthor = isAuthor
  921. page := paging.GetPaging(currentIndex, pageSize, total)
  922. resp.List = list
  923. resp.Paging = page
  924. br.Data = resp
  925. br.Ret = 200
  926. br.Success = true
  927. br.Msg = "获取成功"
  928. }
  929. // @Title 更新作者头像
  930. // @Description 更新作者头像
  931. // @Param request body help_doc.AddHelpDocReq true "type json string"
  932. // @Success 200 {object} models.AddEnglishReportResp
  933. // @router /author/head_img [post]
  934. func (this *YanxuanSpecialController) AuthorHeadImg() {
  935. br := new(models.BaseResponse).Init()
  936. defer func() {
  937. this.Data["json"] = br
  938. this.ServeJSON()
  939. }()
  940. sysUser := this.User
  941. if sysUser == nil {
  942. br.Msg = "请登录"
  943. br.ErrMsg = "请登录,SysUser Is Empty"
  944. br.Ret = 408
  945. return
  946. }
  947. var req models.SaveCygxYanxuanSpecialAuthoHeadImgrReq
  948. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  949. if err != nil {
  950. br.Msg = "参数解析异常!"
  951. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  952. return
  953. }
  954. if req.UserId <= 0 {
  955. br.Msg = "用户id有误"
  956. return
  957. }
  958. if req.HeadImg == "" {
  959. br.Msg = "头像图片错误"
  960. return
  961. }
  962. item := models.CygxYanxuanSpecialAuthor{
  963. UserId: req.UserId,
  964. HeadImg: req.HeadImg,
  965. }
  966. err = models.UpdateYanxuanSpecialAuthorHeadImg(&item)
  967. if err != nil {
  968. br.Msg = "保存失败"
  969. br.ErrMsg = "保存失败,Err:" + err.Error()
  970. return
  971. }
  972. br.Ret = 200
  973. br.Success = true
  974. br.Msg = "保存成功"
  975. }
  976. // @Title 删除专栏
  977. // @Description 删除专栏
  978. // @Param request body help_doc.AddHelpDocReq true "type json string"
  979. // @Success 200 {object} models.AddEnglishReportResp
  980. // @router /del [post]
  981. func (this *YanxuanSpecialController) Delete() {
  982. br := new(models.BaseResponse).Init()
  983. defer func() {
  984. this.Data["json"] = br
  985. this.ServeJSON()
  986. }()
  987. sysUser := this.User
  988. if sysUser == nil {
  989. br.Msg = "请登录"
  990. br.ErrMsg = "请登录,SysUser Is Empty"
  991. br.Ret = 408
  992. return
  993. }
  994. var req models.EnableCygxYanxuanSpecialReq
  995. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  996. if err != nil {
  997. br.Msg = "参数解析异常!"
  998. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  999. return
  1000. }
  1001. if req.Id <= 0 {
  1002. br.Msg = "文章id错误"
  1003. return
  1004. }
  1005. if tmpErr := models.DelYanxuanSpecial(req.Id); tmpErr != nil {
  1006. br.Msg = "删除失败"
  1007. br.ErrMsg = "删除失败, Err:" + tmpErr.Error()
  1008. return
  1009. }
  1010. br.Msg = "删除成功"
  1011. br.Ret = 200
  1012. br.Success = true
  1013. }
  1014. // @Title 专栏文章敏感词检测
  1015. // @Description 专栏文章敏感词检测
  1016. // @Param request body help_doc.AddHelpDocReq true "type json string"
  1017. // @Success 200 {object} models.AddEnglishReportResp
  1018. // @router /check [post]
  1019. func (this *YanxuanSpecialController) Check() {
  1020. br := new(models.BaseResponse).Init()
  1021. defer func() {
  1022. this.Data["json"] = br
  1023. this.ServeJSON()
  1024. }()
  1025. sysUser := this.User
  1026. if sysUser == nil {
  1027. br.Msg = "请登录"
  1028. br.ErrMsg = "请登录,SysUser Is Empty"
  1029. br.Ret = 408
  1030. return
  1031. }
  1032. var req models.CygxYanxuanSpecialCheckReq
  1033. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1034. if err != nil {
  1035. br.Msg = "参数解析异常!"
  1036. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1037. return
  1038. }
  1039. if req.Content == "" {
  1040. br.Ret = 200
  1041. br.Success = true
  1042. br.Msg = "校验成功"
  1043. }
  1044. itemToken, err := services.WxGetToken()
  1045. if err != nil {
  1046. br.Msg = "GetWxAccessToken Err:" + err.Error()
  1047. return
  1048. }
  1049. if itemToken.AccessToken == "" {
  1050. br.Msg = "accessToken is empty"
  1051. return
  1052. }
  1053. suggest := models.WxCheckContent(itemToken.AccessToken, sysUser.OpenId, req.Content)
  1054. if suggest == "risky" {
  1055. br.Msg = "文章内容含有违法违规内容"
  1056. br.ErrMsg = "文章内容含有违法违规内容"
  1057. return
  1058. }
  1059. if len(req.ImgUrl) > 0 {
  1060. //for _, imgUrl := range req.ImgUrl {
  1061. // imgBody, err := http.Get(imgUrl)
  1062. // if err != nil {
  1063. // br.Msg = "图片链接有误"
  1064. // br.ErrMsg = "图片链接有误"
  1065. // return
  1066. // }
  1067. // rnStr := utils.GetRandStringNoSpecialChar(5)
  1068. // savePath := time.Now().Format(utils.FormatDateTimeUnSpace) + rnStr + ".jpg"
  1069. // err = file.SaveFile(imgBody, savePath)
  1070. // if err != nil {
  1071. // br.Msg = "保存图片错误"
  1072. // br.ErrMsg = "保存图片错误"
  1073. // return
  1074. // }
  1075. // res, err := weapp.IMGSecCheck(itemToken.AccessToken, savePath)
  1076. // if err != nil {
  1077. // // 处理一般错误信息
  1078. // br.Msg = "图片内容含有违法违规内容"
  1079. // br.ErrMsg = "图片内容含有违法违规内容"
  1080. // return
  1081. // }
  1082. // if err := res.GetResponseError(); err != nil {
  1083. // // 处理微信返回错误信息
  1084. // return
  1085. // }
  1086. // err = os.RemoveAll(savePath)
  1087. // if err != nil {
  1088. // return
  1089. // }
  1090. //}
  1091. }
  1092. br.Ret = 200
  1093. br.Success = true
  1094. br.Msg = "校验成功"
  1095. }
  1096. // @Title 上传文章阅读时间
  1097. // @Description 上传文章阅读时间接口
  1098. // @Param request body models.AddStopTimeRep true "type json string"
  1099. // @Success 200 {object} models.ArticleDetailResp
  1100. // @router /addStopTimedel [post]
  1101. func (this *YanxuanSpecialController) AddStopTime() {
  1102. br := new(models.BaseResponse).Init()
  1103. defer func() {
  1104. this.Data["json"] = br
  1105. this.ServeJSON()
  1106. }()
  1107. user := this.User
  1108. if user == nil {
  1109. br.Msg = "请登录"
  1110. br.ErrMsg = "请登录,用户信息为空"
  1111. br.Ret = 408
  1112. return
  1113. }
  1114. var req models.AddStopTimeRep
  1115. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1116. if err != nil {
  1117. br.Msg = "参数解析异常!"
  1118. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1119. return
  1120. }
  1121. uid := user.UserId
  1122. articleId := req.ArticleId
  1123. stopTime := req.StopTime
  1124. outType := req.OutType
  1125. source := req.Source
  1126. if articleId <= 0 {
  1127. br.Msg = "参数错误"
  1128. br.ErrMsg = "参数错误"
  1129. return
  1130. }
  1131. if stopTime == 0 {
  1132. stopTime = 1
  1133. }
  1134. if outType != 2 {
  1135. outType = 1
  1136. }
  1137. if source != "PC" {
  1138. source = "MOBILE"
  1139. }
  1140. detail := new(models.ArticleDetail)
  1141. hasPermission := 0
  1142. hasFree := 0
  1143. //判断是否已经申请过
  1144. applyCount, err := models.GetApplyRecordCount(uid)
  1145. if err != nil && err.Error() != utils.ErrNoRow() {
  1146. br.Msg = "获取信息失败"
  1147. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1148. return
  1149. }
  1150. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  1151. if user.CompanyId > 1 {
  1152. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1153. if err != nil {
  1154. br.Msg = "获取信息失败"
  1155. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1156. return
  1157. }
  1158. detail, err = models.GetArticleDetailById(articleId)
  1159. if err != nil {
  1160. br.Msg = "获取信息失败"
  1161. br.ErrMsg = "获取文章信息失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1162. return
  1163. }
  1164. if companyPermission == "" {
  1165. if applyCount > 0 {
  1166. hasPermission = 5
  1167. } else {
  1168. hasPermission = 2
  1169. }
  1170. hasFree = 2
  1171. goto Loop
  1172. } else {
  1173. hasFree = 1
  1174. var articlePermissionPermissionName string
  1175. if detail.CategoryId > 0 {
  1176. articlePermission, err := models.GetArticlePermission(detail.CategoryId)
  1177. if err != nil {
  1178. br.Msg = "获取信息失败"
  1179. br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1180. return
  1181. }
  1182. if articlePermission == nil {
  1183. br.Msg = "获取信息失败"
  1184. br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1185. return
  1186. }
  1187. articlePermissionPermissionName = articlePermission.PermissionName
  1188. } else {
  1189. articlePermissionPermissionName = detail.CategoryName
  1190. }
  1191. var hasPersion bool
  1192. slice := strings.Split(articlePermissionPermissionName, ",")
  1193. for _, v := range slice {
  1194. if strings.Contains(companyPermission, v) {
  1195. hasPersion = true
  1196. }
  1197. }
  1198. if hasPersion {
  1199. go services.ArticleHistoryStopTime(articleId, stopTime, outType, user)
  1200. } else { //无该行业权限
  1201. hasPermission = 3
  1202. }
  1203. }
  1204. } else { //潜在客户
  1205. if applyCount > 0 {
  1206. hasPermission = 5
  1207. } else {
  1208. hasPermission = 4
  1209. }
  1210. }
  1211. Loop:
  1212. resp := new(models.ArticleDetailAddStopTimeRep)
  1213. resp.HasPermission = hasPermission
  1214. resp.HasFree = hasFree
  1215. br.Ret = 200
  1216. br.Success = true
  1217. br.Msg = "操作成功"
  1218. br.Data = resp
  1219. }