yanxuan_special.go 35 KB

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