yanxuan_special.go 21 KB

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