123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789 |
- package cygx
- import (
- "encoding/json"
- "github.com/rdlucklib/rdluck_tools/paging"
- "github.com/tealeg/xlsx"
- "hongze/hz_crm_api/controllers"
- "hongze/hz_crm_api/models"
- "hongze/hz_crm_api/models/cygx"
- cygxService "hongze/hz_crm_api/services/cygx"
- "hongze/hz_crm_api/services/elastic"
- "hongze/hz_crm_api/utils"
- "os"
- "path/filepath"
- "strconv"
- "strings"
- "time"
- )
- // YanxuanSpecialController 研选专栏
- type YanxuanSpecialController struct {
- controllers.BaseAuthController
- }
- // @Title 新增研选专栏作者
- // @Description 新增研选专栏作者
- // @Param request body help_doc.AddHelpDocReq true "type json string"
- // @Success 200 {object} models.AddEnglishReportResp
- // @router /yanxuan_special/author/add [post]
- func (this *YanxuanSpecialController) Add() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req cygx.AddCygxYanxuanSpecialAuthorReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.UserId <= 0 {
- br.Msg = "请输入用户信息"
- return
- }
- if req.RealName == "" {
- br.Msg = "请输入真实姓名"
- return
- }
- if req.Mobile == "" {
- br.Msg = "请输入手机号"
- return
- }
- //获取关联公司的用户信息
- infoUser, err := cygx.GetUserAndCompanyNameList(req.UserId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- rnd := utils.GetRandInt(1, 5)
- item := cygx.CygxYanxuanSpecialAuthor{
- UserId: req.UserId,
- RealName: req.RealName,
- Mobile: req.Mobile,
- CompanyName: infoUser.CompanyName,
- CompanyId: infoUser.CompanyId,
- CreateTime: time.Now(),
- ModifyTime: time.Now(),
- HeadImg: utils.CYGX_YANXUAN_SPECIAL_HEAD_IMG_URL + strconv.Itoa(rnd) + ".png",
- BgImg: utils.CYGX_YANXUAN_SPECIAL_BG_IMG_URL + strconv.Itoa(rnd) + "a.png",
- BgImgDown: utils.CYGX_YANXUAN_SPECIAL_BG_IMG_URL + strconv.Itoa(rnd) + "b.png",
- BgImgPc: utils.CYGX_YANXUAN_SPECIAL_BG_IMG_URL_PC + strconv.Itoa(rnd) + ".png",
- Status: 1,
- }
- _, err = cygx.AddCygxYanxuanSpecialAuthor(&item)
- if err != nil {
- br.Msg = "新增失败"
- br.ErrMsg = "新增失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "新增成功"
- }
- // @Title 禁用/启用研选专栏作者
- // @Description 禁用/启用研选专栏作者
- // @Param request body help_doc.AddHelpDocReq true "type json string"
- // @Success 200 {object} models.AddEnglishReportResp
- // @router /yanxuan_special/author/enable [post]
- func (this *YanxuanSpecialController) AuthorEnable() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req cygx.EnableCygxYanxuanSpecialAuthorReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.UserId <= 0 {
- br.Msg = "用户id错误"
- return
- }
- if req.Status <= 0 {
- br.Msg = "参数错误"
- return
- }
- if tmpErr := cygx.EnableYanxuanSpecialAuthor(req.UserId, req.Status); tmpErr != nil {
- br.Msg = "启用/禁用作者失败"
- br.ErrMsg = "启用/禁用作者失败, Err:" + tmpErr.Error()
- return
- }
- if req.Status == 1 {
- br.Msg = "启用成功"
- } else {
- br.Msg = "禁用成功"
- }
- br.Ret = 200
- br.Success = true
- }
- // @Title 作者列表
- // @Description 作者列表
- // @Param request body help_doc.AddHelpDocReq true "type json string"
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param Status query string true "状态: 1:启用 、 2:禁用 。传其他默认所有"
- // @Param KeyWord query string false "搜索关键词"
- // @Param SortParam query string false "排序字段参数,用来排序的字段, 枚举值:'CreatTime':开通时间 、 'articleNum':已发布文章 、 'pv':总Pv/Uv "
- // @Param SortType query string true "如何排序,是正序还是倒序,枚举值:`asc 正序`,`desc 倒叙`"
- // @Success 200 {object} models.AddEnglishReportResp
- // @router /yanxuan_special/author/list [get]
- func (this *YanxuanSpecialController) AuthorList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- status, _ := this.GetInt("Status")
- keyWord := this.GetString("KeyWord")
- //排序参数
- sortParam := this.GetString("SortParam")
- sortType := this.GetString("SortType")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = utils.StartIndex(currentIndex, pageSize)
- var condition string
- var pars []interface{}
- //作者状态处理
- if status == 1 || status == 2 {
- condition += ` AND art.status = ? `
- pars = append(pars, status)
- }
- //关键词搜索
- if keyWord != "" {
- keyWord = "%" + keyWord + "%"
- condition += ` AND art.special_name like ? `
- pars = append(pars, keyWord)
- }
- //排序字段以及排序方式处理
- var sortStr string
- if sortParam != "" && sortType != "" {
- if sortParam == "CreateTime" {
- if sortType == "asc" {
- sortStr = " ORDER BY art.create_time ASC "
- } else {
- sortStr = " ORDER BY art.create_time DESC "
- }
- }
- if sortParam == "ArticleNum" {
- if sortType == "asc" {
- sortStr = " ORDER BY art.article_num ASC "
- } else {
- sortStr = " ORDER BY art.article_num DESC "
- }
- }
- if sortParam == "pv" {
- if sortType == "asc" {
- sortStr = " ORDER BY art.pv ASC "
- } else {
- sortStr = " ORDER BY art.pv DESC "
- }
- }
- if sortStr == "" {
- sortStr = " ORDER BY a.publish_time DESC " // 兼容前端老六乱传字段
- }
- } else {
- sortStr = " ORDER BY art.create_time DESC "
- }
- total, err := cygx.GetYanxuanSpecialAuthorCount(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- list, tmpErr := cygx.GetYanxuanSpecialAuthorList(condition+sortStr, pars, startSize, pageSize)
- if tmpErr != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
- return
- }
- var userIds []int
- for _, v := range list {
- userIds = append(userIds, v.UserId)
- }
- //获取专栏用户最新的一篇文章信息
- mapNewTime := cygxService.GetBestNewYanxuanSpecialByUserId(userIds)
- for _, v := range list {
- v.SpecialAuthorId = v.Id
- v.ArticlePublishTime = mapNewTime[v.UserId]
- }
- resp := new(cygx.GetCygxYanxuanSpecialAuthorItemResp)
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp.List = list
- resp.Paging = page
- br.Data = resp
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- }
- // @Title 审核列表
- // @Description 审核列表
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param Status query string true "状态: 1:待审核 、 2:已发布 。默认待审核"
- // @Param Type query int true "文章类型,1:笔记、2:观点"
- // @Param KeyWord query string false "搜索关键词"
- // @Param SortParam query string false "排序字段参数,用来排序的字段, 枚举值:'CreatTime':开通时间 、 'articleNum':已发布文章 、 'pv':总Pv/Uv "
- // @Param SortType query string true "如何排序,是正序还是倒序,枚举值:`asc 正序`,`desc 倒叙`"
- // @Param StartDate query string false "开始时间 ,列如2021-03-06 "
- // @Param EndDate query string false "结束时间,列如2021-03-06 "
- // @Success 200 {object} models.AddEnglishReportResp
- // @router /yanxuan_special/list [get]
- func (this *YanxuanSpecialController) List() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- userId, _ := this.GetInt("UserId", 0)
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- status, _ := this.GetInt("Status", 1)
- specialType, _ := this.GetInt("Type")
- keyWord := this.GetString("KeyWord")
- //排序参数
- sortParam := this.GetString("SortParam")
- sortType := this.GetString("SortType")
- startDate := this.GetString("StartDate")
- endDate := this.GetString("EndDate")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = utils.StartIndex(currentIndex, pageSize)
- var condition string
- var pars []interface{}
- if userId > 0 {
- condition += ` AND a.user_id = ? `
- pars = append(pars, userId)
- }
- if status == 1 {
- condition += ` AND a.status = 2 `
- }
- if status == 2 {
- condition += ` AND a.status = 3 `
- }
- if startDate != "" {
- condition += ` AND a.publish_time >= ` + "'" + startDate + " 00:00:00'"
- }
- if endDate != "" {
- condition += ` AND a.publish_time <= ` + "'" + endDate + " 23:59:59'"
- }
- //文章类型
- if specialType == 1 || specialType == 2 {
- condition += ` AND a.type = ? `
- pars = append(pars, specialType)
- }
- //关键词搜索
- if keyWord != "" {
- keyWord = "%" + keyWord + "%"
- condition += ` AND a.title like ? `
- pars = append(pars, keyWord)
- }
- //排序字段以及排序方式处理
- var sortStr string
- if sortParam != "" && sortType != "" {
- if sortParam == "pv" {
- if sortType == "asc" {
- sortStr = " ORDER BY a.pv ASC "
- } else {
- sortStr = " ORDER BY a.pv DESC "
- }
- }
- if sortStr == "" {
- sortStr = " ORDER BY a.publish_time DESC " // 兼容前端老六乱传字段
- }
- } else {
- sortStr = " ORDER BY a.publish_time DESC "
- }
- total, err := cygx.GetGetYanxuanSpecialCount(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- list, tmpErr := cygx.GetYanxuanSpecialList(condition+sortStr, pars, startSize, pageSize)
- if tmpErr != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
- return
- }
- pars = make([]interface{}, 0)
- listAuthor, tmpErr := cygx.GetYanxuanSpecialAuthorList("", pars, 0, 999)
- if tmpErr != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
- return
- }
- mapUserId := make(map[int]int)
- for _, v := range listAuthor {
- mapUserId[v.UserId] = v.Id
- }
- for _, v := range list {
- v.SpecialAuthorId = mapUserId[v.UserId]
- hasImg, err := utils.ArticleHasImgUrl(v.Content)
- if err != nil {
- return
- }
- if hasImg {
- v.ContentHasImg = 1
- }
- if v.DocUrl != "" {
- var docs []cygx.Doc
- err := json.Unmarshal([]byte(v.DocUrl), &docs)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- v.Docs = docs
- }
- if v.CompanyTags != "" {
- v.Tags += v.CompanyTags
- }
- if v.IndustryTags != "" {
- if v.Tags != "" {
- v.Tags += ","
- }
- v.Tags += v.IndustryTags
- }
- }
- resp := new(cygx.GetCygxYanxuanSpeciaResplItemResp)
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp.List = list
- resp.Paging = page
- br.Data = resp
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- }
- // @Title 审批研选专栏
- // @Description 审批研选专栏
- // @Param request body help_doc.AddHelpDocReq true "type json string"
- // @Success 200 {object} models.AddEnglishReportResp
- // @router /yanxuan_special/enable [post]
- func (this *YanxuanSpecialController) Enable() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req cygx.EnableCygxYanxuanSpecialReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.Id <= 0 {
- br.Msg = "文章id错误"
- return
- }
- if req.Status <= 0 {
- br.Msg = "参数错误"
- return
- }
- status := 0
- if req.Status == 1 {
- status = 3
- } else {
- status = 4
- }
- if tmpErr := cygx.EnableYanxuanSpecial(req.Id, status, req.Reason, sysUser.RealName); tmpErr != nil {
- br.Msg = "审批失败"
- br.ErrMsg = "审批失败, Err:" + tmpErr.Error()
- return
- }
- if req.Status == 1 {
- go cygxService.SendWxMsgSpecialFollow(req.Id)
- }
- go cygxService.SendWxMsgSpecialAuthor(req.Id, req.Status) // 研选专栏审核完成时,给提交人发送模板消息
- go cygxService.UpdateYanxuanSpecialResourceData(req.Id) // 写入首页最新 cygx_resource_data 表
- go elastic.EsAddYanxuanSpecial(req.Id) // 写入es 综合搜索
- br.Msg = "审批成功"
- br.Ret = 200
- br.Success = true
- }
- // @Title 收藏详情
- // @Description 收藏详情
- // @Param SpecialId query int true "每页数据条数"
- // @Success 200 {object} models.AddEnglishReportResp
- // @router /yanxuan_special/special_collect/list [get]
- func (this *YanxuanSpecialController) SpecialCollectList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- specialId, _ := this.GetInt("SpecialId")
- var condition string
- var pars []interface{}
- condition += " AND yanxuan_special_id = ? ORDER BY art.create_time DESC "
- pars = append(pars, specialId)
- list, err := cygx.GetCygxYanxuanSpecialCollectList(condition, pars, 0, 100000)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.GetCygxYanxuanSpecialCollectResp)
- resp.List = list
- br.Data = resp
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- }
- // @Title 下载PV
- // @Description 下载PV接口
- // @Param SpecialId query int true "每页数据条数"
- // @router /yanxuan_special/list_pv [get]
- func (this *YanxuanSpecialController) ListPv() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- AdminUser := this.SysUser
- if AdminUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- specialId, _ := this.GetInt("SpecialId")
- if specialId < 1 {
- br.Msg = "请输入专栏ID"
- return
- }
- var condition string
- var pars []interface{}
- condition = ` AND yanxuan_special_id = ? ORDER BY create_time DESC `
- pars = append(pars, specialId)
- list, err := cygx.GetCygxYanxuanSpecialRecordList(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- br.Msg = "生成文件失败"
- br.ErrMsg = "生成文件失败"
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- sheet, err := xlsxFile.AddSheet("阅读明细")
- if err != nil {
- br.Msg = "新增Sheet失败"
- br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
- return
- }
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "姓名"
- cellB := rowTitle.AddCell()
- cellB.Value = "公司名称"
- cellC := rowTitle.AddCell()
- cellC.Value = "所属权益销售"
- cellD := rowTitle.AddCell()
- cellD.Value = "阅读时间"
- cellE := rowTitle.AddCell()
- cellE.Value = "阅读时长"
- for _, item := range list {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.RealName
- cellB := row.AddCell()
- cellB.Value = item.CompanyName
- cellC := row.AddCell()
- cellC.Value = item.SellerName
- cellD := row.AddCell()
- cellD.Value = item.CreateTime
- cellE := row.AddCell()
- cellE.Value = strconv.Itoa(item.StopTime)
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- br.Msg = "保存文件失败"
- br.ErrMsg = "保存文件失败"
- return
- }
- downloadFileName := time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
- defer func() {
- os.Remove(downLoadnFilePath)
- }()
- br.Ret = 200
- br.Success = true
- br.Msg = "导出成功"
- }
- // @Title 审批记录
- // @Description 审批记录接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success 200 {object} models.CygxYanxuanSpecialApprovalLogListResp
- // @router /yanxuan_special/approval_log_list [get]
- func (this *YanxuanSpecialController) ApprovalLogList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = utils.StartIndex(currentIndex, pageSize)
- var condition string
- var pars []interface{}
- //只是查询驳回状态的数据
- condition += ` AND a.approval_status = 2 `
- total, err := cygx.GetCygxYanxuanSpecialApprovalLogCount(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- condition += ` ORDER BY create_time DESC `
- list, tmpErr := cygx.GetCygxYanxuanSpecialApprovalLogList(condition, pars, startSize, pageSize)
- if tmpErr != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
- return
- }
- pars = make([]interface{}, 0)
- listAuthor, tmpErr := cygx.GetYanxuanSpecialAuthorList("", pars, 0, 999)
- if tmpErr != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
- return
- }
- mapUserId := make(map[int]int)
- for _, v := range listAuthor {
- mapUserId[v.UserId] = v.Id
- }
- for _, v := range list {
- v.SpecialAuthorId = mapUserId[v.UserId]
- }
- resp := new(cygx.CygxYanxuanSpecialApprovalLogListResp)
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp.List = list
- resp.Paging = page
- br.Data = resp
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- }
- // @Title 按钮是否展示接口
- // @Description 按钮是否展示接口
- // @Success 200 {object} models.AddEnglishReportResp
- // @router /yanxuan_special/show_button [get]
- func (this *YanxuanSpecialController) ShowButton() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- resp := new(cygx.CygxYanxuanSpecialShowButton)
- configCode := utils.TPL_MSG_NEI_RONG_ZU
- cnfNeiRong, err := cygx.GetConfigByCode(configCode)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- //汪洋王芳手机号
- configCode = utils.TPL_MSG_WANG_FANG_WANG_YANG
- cnfWang, err := cygx.GetConfigByCode(configCode)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- //作者管理栏,只有内容组、汪洋、王芳、超管可见
- if strings.Contains(cnfNeiRong.ConfigValue, sysUser.Mobile) || strings.Contains(cnfWang.ConfigValue, sysUser.Mobile) || sysUser.Role == utils.ROLE_TYPE_CODE_ADMIN {
- resp.IsShowSpecialAuthor = true
- }
- br.Data = resp
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- }
- // @Title 作者粉丝列表
- // @Description 作者粉丝列表
- // @Param SpecialAuthorId query int true "作者ID"
- // @Success 200 {object} models.AddEnglishReportResp
- // @router /yanxuan_special/special_author_fans_list [get]
- func (this *YanxuanSpecialController) SpecialAuthorFansList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- specialAuthorId, _ := this.GetInt("SpecialAuthorId")
- detail, err := cygx.GetCygxYanxuanSpecialAuthorItemById(specialAuthorId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- var condition string
- var pars []interface{}
- condition += " AND follow_user_id = ? ORDER BY a.create_time DESC "
- pars = append(pars, detail.UserId)
- list, err := cygx.GetCygxYanxuanSpecialFollowList(condition, pars, 0, 100000)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.GetCygxYanxuanSpecialFollowResp)
- resp.List = list
- br.Data = resp
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- }
|