yanxuan_special.go 34 KB

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