yanxuan_special.go 35 KB

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