yanxuan_special.go 34 KB

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