yanxuan_special.go 34 KB

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