yanxuan_special.go 34 KB

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