yanxuan_special.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. package cygx
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "github.com/tealeg/xlsx"
  6. "hongze/hz_crm_api/controllers"
  7. "hongze/hz_crm_api/models"
  8. "hongze/hz_crm_api/models/cygx"
  9. cygxService "hongze/hz_crm_api/services/cygx"
  10. "hongze/hz_crm_api/services/elastic"
  11. "hongze/hz_crm_api/utils"
  12. "os"
  13. "path/filepath"
  14. "strconv"
  15. "strings"
  16. "time"
  17. )
  18. // YanxuanSpecialController 研选专栏
  19. type YanxuanSpecialController struct {
  20. controllers.BaseAuthController
  21. }
  22. // @Title 新增研选专栏作者
  23. // @Description 新增研选专栏作者
  24. // @Param request body help_doc.AddHelpDocReq true "type json string"
  25. // @Success 200 {object} models.AddEnglishReportResp
  26. // @router /yanxuan_special/author/add [post]
  27. func (this *YanxuanSpecialController) Add() {
  28. br := new(models.BaseResponse).Init()
  29. defer func() {
  30. this.Data["json"] = br
  31. this.ServeJSON()
  32. }()
  33. sysUser := this.SysUser
  34. if sysUser == nil {
  35. br.Msg = "请登录"
  36. br.ErrMsg = "请登录,SysUser Is Empty"
  37. br.Ret = 408
  38. return
  39. }
  40. var req cygx.AddCygxYanxuanSpecialAuthorReq
  41. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  42. if err != nil {
  43. br.Msg = "参数解析异常!"
  44. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  45. return
  46. }
  47. if req.UserId <= 0 {
  48. br.Msg = "请输入用户信息"
  49. return
  50. }
  51. if req.RealName == "" {
  52. br.Msg = "请输入真实姓名"
  53. return
  54. }
  55. if req.Mobile == "" {
  56. br.Msg = "请输入手机号"
  57. return
  58. }
  59. //获取关联公司的用户信息
  60. infoUser, err := cygx.GetUserAndCompanyNameList(req.UserId)
  61. if err != nil {
  62. br.Msg = "获取失败"
  63. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  64. return
  65. }
  66. rnd := utils.GetRandInt(1, 5)
  67. item := cygx.CygxYanxuanSpecialAuthor{
  68. UserId: req.UserId,
  69. RealName: req.RealName,
  70. Mobile: req.Mobile,
  71. CompanyName: infoUser.CompanyName,
  72. CompanyId: infoUser.CompanyId,
  73. CreateTime: time.Now(),
  74. ModifyTime: time.Now(),
  75. HeadImg: utils.CYGX_YANXUAN_SPECIAL_HEAD_IMG_URL + strconv.Itoa(rnd) + ".png",
  76. BgImg: utils.CYGX_YANXUAN_SPECIAL_BG_IMG_URL + strconv.Itoa(rnd) + "a.png",
  77. BgImgDown: utils.CYGX_YANXUAN_SPECIAL_BG_IMG_URL + strconv.Itoa(rnd) + "b.png",
  78. BgImgPc: utils.CYGX_YANXUAN_SPECIAL_BG_IMG_URL_PC + strconv.Itoa(rnd) + ".png",
  79. Status: 1,
  80. }
  81. _, err = cygx.AddCygxYanxuanSpecialAuthor(&item)
  82. if err != nil {
  83. br.Msg = "新增失败"
  84. br.ErrMsg = "新增失败,Err:" + err.Error()
  85. return
  86. }
  87. br.Ret = 200
  88. br.Success = true
  89. br.Msg = "新增成功"
  90. }
  91. // @Title 禁用/启用研选专栏作者
  92. // @Description 禁用/启用研选专栏作者
  93. // @Param request body help_doc.AddHelpDocReq true "type json string"
  94. // @Success 200 {object} models.AddEnglishReportResp
  95. // @router /yanxuan_special/author/enable [post]
  96. func (this *YanxuanSpecialController) AuthorEnable() {
  97. br := new(models.BaseResponse).Init()
  98. defer func() {
  99. this.Data["json"] = br
  100. this.ServeJSON()
  101. }()
  102. sysUser := this.SysUser
  103. if sysUser == nil {
  104. br.Msg = "请登录"
  105. br.ErrMsg = "请登录,SysUser Is Empty"
  106. br.Ret = 408
  107. return
  108. }
  109. var req cygx.EnableCygxYanxuanSpecialAuthorReq
  110. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  111. if err != nil {
  112. br.Msg = "参数解析异常!"
  113. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  114. return
  115. }
  116. if req.UserId <= 0 {
  117. br.Msg = "用户id错误"
  118. return
  119. }
  120. if req.Status <= 0 {
  121. br.Msg = "参数错误"
  122. return
  123. }
  124. if tmpErr := cygx.EnableYanxuanSpecialAuthor(req.UserId, req.Status); tmpErr != nil {
  125. br.Msg = "启用/禁用作者失败"
  126. br.ErrMsg = "启用/禁用作者失败, Err:" + tmpErr.Error()
  127. return
  128. }
  129. if req.Status == 1 {
  130. br.Msg = "启用成功"
  131. } else {
  132. br.Msg = "禁用成功"
  133. }
  134. br.Ret = 200
  135. br.Success = true
  136. }
  137. // @Title 作者列表
  138. // @Description 作者列表
  139. // @Param request body help_doc.AddHelpDocReq true "type json string"
  140. // @Param PageSize query int true "每页数据条数"
  141. // @Param CurrentIndex query int true "当前页页码,从1开始"
  142. // @Param Status query string true "状态: 1:启用 、 2:禁用 。传其他默认所有"
  143. // @Param KeyWord query string false "搜索关键词"
  144. // @Param SortParam query string false "排序字段参数,用来排序的字段, 枚举值:'CreatTime':开通时间 、 'articleNum':已发布文章 、 'pv':总Pv/Uv "
  145. // @Param SortType query string true "如何排序,是正序还是倒序,枚举值:`asc 正序`,`desc 倒叙`"
  146. // @Success 200 {object} models.AddEnglishReportResp
  147. // @router /yanxuan_special/author/list [get]
  148. func (this *YanxuanSpecialController) AuthorList() {
  149. br := new(models.BaseResponse).Init()
  150. defer func() {
  151. this.Data["json"] = br
  152. this.ServeJSON()
  153. }()
  154. sysUser := this.SysUser
  155. if sysUser == nil {
  156. br.Msg = "请登录"
  157. br.ErrMsg = "请登录,SysUser Is Empty"
  158. br.Ret = 408
  159. return
  160. }
  161. pageSize, _ := this.GetInt("PageSize")
  162. currentIndex, _ := this.GetInt("CurrentIndex")
  163. status, _ := this.GetInt("Status")
  164. keyWord := this.GetString("KeyWord")
  165. //排序参数
  166. sortParam := this.GetString("SortParam")
  167. sortType := this.GetString("SortType")
  168. var startSize int
  169. if pageSize <= 0 {
  170. pageSize = utils.PageSize20
  171. }
  172. if currentIndex <= 0 {
  173. currentIndex = 1
  174. }
  175. startSize = utils.StartIndex(currentIndex, pageSize)
  176. var condition string
  177. var pars []interface{}
  178. //作者状态处理
  179. if status == 1 || status == 2 {
  180. condition += ` AND art.status = ? `
  181. pars = append(pars, status)
  182. }
  183. //关键词搜索
  184. if keyWord != "" {
  185. keyWord = "%" + keyWord + "%"
  186. condition += ` AND art.special_name like ? `
  187. pars = append(pars, keyWord)
  188. }
  189. //排序字段以及排序方式处理
  190. var sortStr string
  191. if sortParam != "" && sortType != "" {
  192. if sortParam == "CreatTime" {
  193. if sortType == "asc" {
  194. sortStr = " ORDER BY art.create_time ASC "
  195. } else {
  196. sortStr = " ORDER BY art.create_time DESC "
  197. }
  198. }
  199. if sortParam == "ArticleNum" {
  200. if sortType == "asc" {
  201. sortStr = " ORDER BY art.article_num ASC "
  202. } else {
  203. sortStr = " ORDER BY art.article_num DESC "
  204. }
  205. }
  206. if sortParam == "pv" {
  207. if sortType == "asc" {
  208. sortStr = " ORDER BY art.pv ASC "
  209. } else {
  210. sortStr = " ORDER BY art.pv DESC "
  211. }
  212. }
  213. } else {
  214. sortStr = " ORDER BY art.create_time DESC "
  215. }
  216. total, err := cygx.GetYanxuanSpecialAuthorCount(condition, pars)
  217. if err != nil {
  218. br.Msg = "获取失败"
  219. br.ErrMsg = "获取失败,Err:" + err.Error()
  220. return
  221. }
  222. list, tmpErr := cygx.GetYanxuanSpecialAuthorList(condition+sortStr, pars, startSize, pageSize)
  223. if tmpErr != nil {
  224. br.Msg = "获取失败"
  225. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  226. return
  227. }
  228. resp := new(cygx.GetCygxYanxuanSpecialAuthorItemResp)
  229. page := paging.GetPaging(currentIndex, pageSize, total)
  230. resp.List = list
  231. resp.Paging = page
  232. br.Data = resp
  233. br.Ret = 200
  234. br.Success = true
  235. br.Msg = "获取成功"
  236. }
  237. // @Title 审核列表
  238. // @Description 审核列表
  239. // @Param PageSize query int true "每页数据条数"
  240. // @Param CurrentIndex query int true "当前页页码,从1开始"
  241. // @Param Status query string true "状态: 1:待审核 、 2:已发布 。默认待审核"
  242. // @Param Type query int true "文章类型,1:笔记、2:观点"
  243. // @Param KeyWord query string false "搜索关键词"
  244. // @Param SortParam query string false "排序字段参数,用来排序的字段, 枚举值:'CreatTime':开通时间 、 'articleNum':已发布文章 、 'pv':总Pv/Uv "
  245. // @Param SortType query string true "如何排序,是正序还是倒序,枚举值:`asc 正序`,`desc 倒叙`"
  246. // @Param StartDate query string false "开始时间 ,列如2021-03-06 "
  247. // @Param EndDate query string false "结束时间,列如2021-03-06 "
  248. // @Success 200 {object} models.AddEnglishReportResp
  249. // @router /yanxuan_special/list [get]
  250. func (this *YanxuanSpecialController) List() {
  251. br := new(models.BaseResponse).Init()
  252. defer func() {
  253. this.Data["json"] = br
  254. this.ServeJSON()
  255. }()
  256. sysUser := this.SysUser
  257. if sysUser == nil {
  258. br.Msg = "请登录"
  259. br.ErrMsg = "请登录,SysUser Is Empty"
  260. br.Ret = 408
  261. return
  262. }
  263. userId, _ := this.GetInt("UserId", 0)
  264. pageSize, _ := this.GetInt("PageSize")
  265. currentIndex, _ := this.GetInt("CurrentIndex")
  266. status, _ := this.GetInt("Status", 1)
  267. specialType, _ := this.GetInt("Type")
  268. keyWord := this.GetString("KeyWord")
  269. //排序参数
  270. sortParam := this.GetString("SortParam")
  271. sortType := this.GetString("SortType")
  272. startDate := this.GetString("StartDate")
  273. endDate := this.GetString("EndDate")
  274. var startSize int
  275. if pageSize <= 0 {
  276. pageSize = utils.PageSize20
  277. }
  278. if currentIndex <= 0 {
  279. currentIndex = 1
  280. }
  281. startSize = utils.StartIndex(currentIndex, pageSize)
  282. var condition string
  283. var pars []interface{}
  284. if userId > 0 {
  285. condition += ` AND a.user_id = ? `
  286. pars = append(pars, userId)
  287. }
  288. if status == 1 {
  289. condition += ` AND a.status = 2 `
  290. }
  291. if status == 2 {
  292. condition += ` AND a.status = 3 `
  293. }
  294. if startDate != "" {
  295. condition += ` AND a.publish_time >= ` + "'" + startDate + " 00:00:00'"
  296. }
  297. if endDate != "" {
  298. condition += ` AND a.publish_time <= ` + "'" + endDate + " 23:59:59'"
  299. }
  300. //文章类型
  301. if specialType == 1 || specialType == 2 {
  302. condition += ` AND a.type = ? `
  303. pars = append(pars, specialType)
  304. }
  305. //关键词搜索
  306. if keyWord != "" {
  307. keyWord = "%" + keyWord + "%"
  308. condition += ` AND a.title like ? `
  309. pars = append(pars, keyWord)
  310. }
  311. //排序字段以及排序方式处理
  312. var sortStr string
  313. if sortParam != "" && sortType != "" {
  314. if sortParam == "pv" {
  315. if sortType == "asc" {
  316. sortStr = " ORDER BY a.pv ASC "
  317. } else {
  318. sortStr = " ORDER BY a.pv DESC "
  319. }
  320. }
  321. } else {
  322. sortStr = " ORDER BY a.publish_time DESC "
  323. }
  324. total, err := cygx.GetGetYanxuanSpecialCount(condition, pars)
  325. if err != nil {
  326. br.Msg = "获取失败"
  327. br.ErrMsg = "获取失败,Err:" + err.Error()
  328. return
  329. }
  330. list, tmpErr := cygx.GetYanxuanSpecialList(condition+sortStr, pars, startSize, pageSize)
  331. if tmpErr != nil {
  332. br.Msg = "获取失败"
  333. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  334. return
  335. }
  336. pars = make([]interface{}, 0)
  337. listAuthor, tmpErr := cygx.GetYanxuanSpecialAuthorList("", pars, 0, 999)
  338. if tmpErr != nil {
  339. br.Msg = "获取失败"
  340. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  341. return
  342. }
  343. mapUserId := make(map[int]int)
  344. for _, v := range listAuthor {
  345. mapUserId[v.UserId] = v.Id
  346. }
  347. for _, v := range list {
  348. v.SpecialAuthorId = mapUserId[v.UserId]
  349. hasImg, err := utils.ArticleHasImgUrl(v.Content)
  350. if err != nil {
  351. return
  352. }
  353. if hasImg {
  354. v.ContentHasImg = 1
  355. }
  356. if v.DocUrl != "" {
  357. var docs []cygx.Doc
  358. err := json.Unmarshal([]byte(v.DocUrl), &docs)
  359. if err != nil {
  360. br.Msg = "参数解析异常!"
  361. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  362. return
  363. }
  364. v.Docs = docs
  365. }
  366. if v.CompanyTags != "" {
  367. v.Tags += v.CompanyTags
  368. }
  369. if v.IndustryTags != "" {
  370. if v.Tags != "" {
  371. v.Tags += ","
  372. }
  373. v.Tags += v.IndustryTags
  374. }
  375. }
  376. resp := new(cygx.GetCygxYanxuanSpeciaResplItemResp)
  377. page := paging.GetPaging(currentIndex, pageSize, total)
  378. resp.List = list
  379. resp.Paging = page
  380. br.Data = resp
  381. br.Ret = 200
  382. br.Success = true
  383. br.Msg = "获取成功"
  384. }
  385. // @Title 审批研选专栏
  386. // @Description 审批研选专栏
  387. // @Param request body help_doc.AddHelpDocReq true "type json string"
  388. // @Success 200 {object} models.AddEnglishReportResp
  389. // @router /yanxuan_special/enable [post]
  390. func (this *YanxuanSpecialController) Enable() {
  391. br := new(models.BaseResponse).Init()
  392. defer func() {
  393. this.Data["json"] = br
  394. this.ServeJSON()
  395. }()
  396. sysUser := this.SysUser
  397. if sysUser == nil {
  398. br.Msg = "请登录"
  399. br.ErrMsg = "请登录,SysUser Is Empty"
  400. br.Ret = 408
  401. return
  402. }
  403. var req cygx.EnableCygxYanxuanSpecialReq
  404. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  405. if err != nil {
  406. br.Msg = "参数解析异常!"
  407. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  408. return
  409. }
  410. if req.Id <= 0 {
  411. br.Msg = "文章id错误"
  412. return
  413. }
  414. if req.Status <= 0 {
  415. br.Msg = "参数错误"
  416. return
  417. }
  418. status := 0
  419. if req.Status == 1 {
  420. status = 3
  421. } else {
  422. status = 4
  423. }
  424. if tmpErr := cygx.EnableYanxuanSpecial(req.Id, status, req.Reason, sysUser.RealName); tmpErr != nil {
  425. br.Msg = "审批失败"
  426. br.ErrMsg = "审批失败, Err:" + tmpErr.Error()
  427. return
  428. }
  429. if req.Status == 1 {
  430. go cygxService.SendWxMsgSpecialFollow(req.Id)
  431. }
  432. go cygxService.SendWxMsgSpecialAuthor(req.Id, req.Status) // 研选专栏审核完成时,给提交人发送模板消息
  433. go cygxService.UpdateYanxuanSpecialResourceData(req.Id) // 写入首页最新 cygx_resource_data 表
  434. go elastic.EsAddYanxuanSpecial(req.Id) // 写入es 综合搜索
  435. br.Msg = "审批成功"
  436. br.Ret = 200
  437. br.Success = true
  438. }
  439. // @Title 收藏详情
  440. // @Description 收藏详情
  441. // @Param SpecialId query int true "每页数据条数"
  442. // @Success 200 {object} models.AddEnglishReportResp
  443. // @router /yanxuan_special/special_collect/list [get]
  444. func (this *YanxuanSpecialController) SpecialCollectList() {
  445. br := new(models.BaseResponse).Init()
  446. defer func() {
  447. this.Data["json"] = br
  448. this.ServeJSON()
  449. }()
  450. sysUser := this.SysUser
  451. if sysUser == nil {
  452. br.Msg = "请登录"
  453. br.ErrMsg = "请登录,SysUser Is Empty"
  454. br.Ret = 408
  455. return
  456. }
  457. specialId, _ := this.GetInt("SpecialId")
  458. var condition string
  459. var pars []interface{}
  460. condition += " AND yanxuan_special_id = ? ORDER BY art.create_time DESC "
  461. pars = append(pars, specialId)
  462. list, err := cygx.GetCygxYanxuanSpecialCollectList(condition, pars, 0, 100000)
  463. if err != nil {
  464. br.Msg = "获取失败"
  465. br.ErrMsg = "获取失败,Err:" + err.Error()
  466. return
  467. }
  468. resp := new(cygx.GetCygxYanxuanSpecialCollectResp)
  469. resp.List = list
  470. br.Data = resp
  471. br.Ret = 200
  472. br.Success = true
  473. br.Msg = "获取成功"
  474. }
  475. // @Title 下载PV
  476. // @Description 下载PV接口
  477. // @Param SpecialId query int true "每页数据条数"
  478. // @router /yanxuan_special/list_pv [get]
  479. func (this *YanxuanSpecialController) ListPv() {
  480. br := new(models.BaseResponse).Init()
  481. defer func() {
  482. this.Data["json"] = br
  483. this.ServeJSON()
  484. }()
  485. AdminUser := this.SysUser
  486. if AdminUser == nil {
  487. br.Msg = "请登录"
  488. br.ErrMsg = "请登录,用户信息为空"
  489. br.Ret = 408
  490. return
  491. }
  492. specialId, _ := this.GetInt("SpecialId")
  493. if specialId < 1 {
  494. br.Msg = "请输入专栏ID"
  495. return
  496. }
  497. var condition string
  498. var pars []interface{}
  499. condition = ` AND yanxuan_special_id = ? ORDER BY create_time DESC `
  500. pars = append(pars, specialId)
  501. list, err := cygx.GetCygxYanxuanSpecialRecordList(condition, pars)
  502. if err != nil {
  503. br.Msg = "获取失败"
  504. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  505. return
  506. }
  507. //创建excel
  508. dir, err := os.Executable()
  509. exPath := filepath.Dir(dir)
  510. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  511. xlsxFile := xlsx.NewFile()
  512. if err != nil {
  513. br.Msg = "生成文件失败"
  514. br.ErrMsg = "生成文件失败"
  515. return
  516. }
  517. style := xlsx.NewStyle()
  518. alignment := xlsx.Alignment{
  519. Horizontal: "center",
  520. Vertical: "center",
  521. WrapText: true,
  522. }
  523. style.Alignment = alignment
  524. style.ApplyAlignment = true
  525. sheet, err := xlsxFile.AddSheet("阅读明细")
  526. if err != nil {
  527. br.Msg = "新增Sheet失败"
  528. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  529. return
  530. }
  531. rowTitle := sheet.AddRow()
  532. cellA := rowTitle.AddCell()
  533. cellA.Value = "姓名"
  534. cellB := rowTitle.AddCell()
  535. cellB.Value = "公司名称"
  536. cellC := rowTitle.AddCell()
  537. cellC.Value = "所属权益销售"
  538. cellD := rowTitle.AddCell()
  539. cellD.Value = "阅读时间"
  540. cellE := rowTitle.AddCell()
  541. cellE.Value = "阅读时长"
  542. for _, item := range list {
  543. row := sheet.AddRow()
  544. cellA := row.AddCell()
  545. cellA.Value = item.RealName
  546. cellB := row.AddCell()
  547. cellB.Value = item.CompanyName
  548. cellC := row.AddCell()
  549. cellC.Value = item.SellerName
  550. cellD := row.AddCell()
  551. cellD.Value = item.CreateTime
  552. cellE := row.AddCell()
  553. cellE.Value = strconv.Itoa(item.StopTime)
  554. }
  555. err = xlsxFile.Save(downLoadnFilePath)
  556. if err != nil {
  557. br.Msg = "保存文件失败"
  558. br.ErrMsg = "保存文件失败"
  559. return
  560. }
  561. downloadFileName := time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  562. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  563. defer func() {
  564. os.Remove(downLoadnFilePath)
  565. }()
  566. br.Ret = 200
  567. br.Success = true
  568. br.Msg = "导出成功"
  569. }
  570. // @Title 审批记录
  571. // @Description 审批记录接口
  572. // @Param PageSize query int true "每页数据条数"
  573. // @Param CurrentIndex query int true "当前页页码,从1开始"
  574. // @Success 200 {object} models.CygxYanxuanSpecialApprovalLogListResp
  575. // @router /yanxuan_special/approval_log_list [get]
  576. func (this *YanxuanSpecialController) ApprovalLogList() {
  577. br := new(models.BaseResponse).Init()
  578. defer func() {
  579. this.Data["json"] = br
  580. this.ServeJSON()
  581. }()
  582. sysUser := this.SysUser
  583. if sysUser == nil {
  584. br.Msg = "请登录"
  585. br.ErrMsg = "请登录,SysUser Is Empty"
  586. br.Ret = 408
  587. return
  588. }
  589. pageSize, _ := this.GetInt("PageSize")
  590. currentIndex, _ := this.GetInt("CurrentIndex")
  591. var startSize int
  592. if pageSize <= 0 {
  593. pageSize = utils.PageSize20
  594. }
  595. if currentIndex <= 0 {
  596. currentIndex = 1
  597. }
  598. startSize = utils.StartIndex(currentIndex, pageSize)
  599. var condition string
  600. var pars []interface{}
  601. //只是查询驳回状态的数据
  602. condition += ` AND a.approval_status = 2 `
  603. total, err := cygx.GetCygxYanxuanSpecialApprovalLogCount(condition, pars)
  604. if err != nil {
  605. br.Msg = "获取失败"
  606. br.ErrMsg = "获取失败,Err:" + err.Error()
  607. return
  608. }
  609. condition += ` ORDER BY create_time DESC `
  610. list, tmpErr := cygx.GetCygxYanxuanSpecialApprovalLogList(condition, pars, startSize, pageSize)
  611. if tmpErr != nil {
  612. br.Msg = "获取失败"
  613. br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
  614. return
  615. }
  616. resp := new(cygx.CygxYanxuanSpecialApprovalLogListResp)
  617. page := paging.GetPaging(currentIndex, pageSize, total)
  618. resp.List = list
  619. resp.Paging = page
  620. br.Data = resp
  621. br.Ret = 200
  622. br.Success = true
  623. br.Msg = "获取成功"
  624. }
  625. // @Title 按钮是否展示接口
  626. // @Description 按钮是否展示接口
  627. // @Success 200 {object} models.AddEnglishReportResp
  628. // @router /yanxuan_special/show_button [get]
  629. func (this *YanxuanSpecialController) ShowButton() {
  630. br := new(models.BaseResponse).Init()
  631. defer func() {
  632. this.Data["json"] = br
  633. this.ServeJSON()
  634. }()
  635. sysUser := this.SysUser
  636. if sysUser == nil {
  637. br.Msg = "请登录"
  638. br.ErrMsg = "请登录,SysUser Is Empty"
  639. br.Ret = 408
  640. return
  641. }
  642. resp := new(cygx.CygxYanxuanSpecialShowButton)
  643. configCode := utils.TPL_MSG_NEI_RONG_ZU
  644. cnfNeiRong, err := cygx.GetConfigByCode(configCode)
  645. if err != nil {
  646. br.Msg = "获取失败"
  647. br.ErrMsg = "获取失败,Err:" + err.Error()
  648. return
  649. }
  650. //汪洋王芳手机号
  651. configCode = utils.TPL_MSG_WANG_FANG_WANG_YANG
  652. cnfWang, err := cygx.GetConfigByCode(configCode)
  653. if err != nil {
  654. br.Msg = "获取失败"
  655. br.ErrMsg = "获取失败,Err:" + err.Error()
  656. return
  657. }
  658. //作者管理栏,只有内容组、汪洋、王芳、超管可见
  659. if strings.Contains(cnfNeiRong.ConfigValue, sysUser.Mobile) || strings.Contains(cnfWang.ConfigValue, sysUser.Mobile) || sysUser.Role == utils.ROLE_TYPE_CODE_ADMIN {
  660. resp.IsShowSpecialAuthor = true
  661. }
  662. br.Data = resp
  663. br.Ret = 200
  664. br.Success = true
  665. br.Msg = "获取成功"
  666. }
  667. // @Title 作者粉丝列表
  668. // @Description 作者粉丝列表
  669. // @Param SpecialAuthorId query int true "作者ID"
  670. // @Success 200 {object} models.AddEnglishReportResp
  671. // @router /yanxuan_special/special_author_fans_list [get]
  672. func (this *YanxuanSpecialController) SpecialAuthorFansList() {
  673. br := new(models.BaseResponse).Init()
  674. defer func() {
  675. this.Data["json"] = br
  676. this.ServeJSON()
  677. }()
  678. sysUser := this.SysUser
  679. if sysUser == nil {
  680. br.Msg = "请登录"
  681. br.ErrMsg = "请登录,SysUser Is Empty"
  682. br.Ret = 408
  683. return
  684. }
  685. specialAuthorId, _ := this.GetInt("SpecialAuthorId")
  686. detail, err := cygx.GetCygxYanxuanSpecialAuthorItemById(specialAuthorId)
  687. if err != nil {
  688. br.Msg = "获取失败"
  689. br.ErrMsg = "获取失败,Err:" + err.Error()
  690. return
  691. }
  692. var condition string
  693. var pars []interface{}
  694. condition += " AND follow_user_id = ? ORDER BY a.create_time DESC "
  695. pars = append(pars, detail.UserId)
  696. list, err := cygx.GetCygxYanxuanSpecialFollowList(condition, pars, 0, 100000)
  697. if err != nil {
  698. br.Msg = "获取失败"
  699. br.ErrMsg = "获取失败,Err:" + err.Error()
  700. return
  701. }
  702. resp := new(cygx.GetCygxYanxuanSpecialFollowResp)
  703. resp.List = list
  704. br.Data = resp
  705. br.Ret = 200
  706. br.Success = true
  707. br.Msg = "获取成功"
  708. }