yanxuan_special.go 35 KB

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