yanxuan_special.go 35 KB

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