Ver Fonte

按钮是否展示,三种报告列表

xingzai há 3 anos atrás
pai
commit
f03ced4d42
3 ficheiros alterados com 235 adições e 0 exclusões
  1. 112 0
      controllers/report.go
  2. 15 0
      models/report.go
  3. 108 0
      models/report_selection.go

+ 112 - 0
controllers/report.go

@@ -1109,3 +1109,115 @@ func (this *ReportController) ReportListNew() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 是否展示绝密内参
+// @Description 获取是否展示绝密内参接口
+// @Param	request	body models.IsShow true "type json string"
+// @Success 200
+// @router /isShow [get]
+func (this *ReportController) IsShow() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	var resp models.IsShow
+	mobile := user.Mobile
+	if mobile == "" {
+		br.Ret = 200
+		br.Success = true
+		br.Data = resp
+		return
+	}
+	total, _ := models.GetUserIsAdminCount(mobile)
+	if total > 0 {
+		resp.IsShow = true
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}
+
+// @Title 报告精选、本周研究汇总、上周纪要汇总列表
+// @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   ReportType   string   query     true       "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
+// @Success 200 {object} models.CygxReportSelectionListPublicRep
+// @router /reportList/byType [get]
+func (this *ReportController) ReportListByType() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	//uid := user.UserId
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	reportType := this.GetString("ReportType")
+	var condition string
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+	var pars []interface{}
+	var total int
+	resp := new(models.CygxReportSelectionListPublicRep)
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	var tbdb string
+	if reportType == "1" {
+		tbdb = "cygx_report_selection"
+	} else if reportType == "2" {
+		tbdb = "cygx_research_summary"
+	} else if reportType == "3" {
+		tbdb = "cygx_minutes_summary"
+	} else {
+		br.Msg = "请选择报告类型"
+		return
+	}
+	fmt.Println(tbdb)
+	condition = ` AND publish_status = 1`
+	total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
+		return
+	}
+	page = paging.GetPaging(currentIndex, pageSize, total)
+	list, err := models.GetReportSelectionListPublic(condition, tbdb, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	for k, v := range list {
+		if reportType == "1" {
+			list[k].Abstract = v.UpdateDescription
+		}
+		list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
+	}
+
+	resp.List = list
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 15 - 0
models/report.go

@@ -210,3 +210,18 @@ func GetWhichDepartmentCount(condition string) (count int, err error) {
 	err = o.Raw(sql).QueryRow(&count)
 	return
 }
+
+type IsShow struct {
+	IsShow bool `description:"是否展示"`
+}
+
+//获取用户是否有查看权限
+func GetUserIsAdminCount(mobile string) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) count  FROM admin 
+			WHERE
+ 			mobile = ?
+			AND (group_id IN (11, 13, 14, 15, 16, 17) OR department_id = 3 )`
+	err = o.Raw(sql, mobile).QueryRow(&count)
+	return
+}

+ 108 - 0
models/report_selection.go

@@ -0,0 +1,108 @@
+package models
+
+import (
+	"fmt"
+	"rdluck_tools/orm"
+	"rdluck_tools/paging"
+	"time"
+)
+
+type CygxReportSelection struct {
+	ArticleId          int       `orm:"column(article_id);pk"description:"报告id"`
+	AddType            string    `description:"更新方式 1重新编辑  ,2 继承往期"`
+	Title              string    `description:"标题"`
+	Department         string    `description:"作者"`
+	PublishStatus      int       `description:"发布状态,1已发布,0未发布"`
+	PublishDate        time.Time `description:"发布时间"`
+	CreateTime         time.Time `description:"创建时间"`
+	LastUpdatedTime    time.Time `description:"最后一次更新时间"`
+	Periods            string    `description:"期数"`
+	HavePublish        int       `description:"是否发布过,1是,0否"`
+	InheritPeriods     string    `description:"继承期数"`
+	ProductDescription string    `description:"产品说明"`
+	UpdateDescription  string    `description:"更新说明"`
+	FocusOn            string    `description:"近期重点关注方向"`
+}
+
+type CygxReportSelectionRep struct {
+	ArticleId         int    `orm:"column(article_id);pk"description:"报告id"`
+	Title             string `description:"标题"`
+	Department        string `description:"作者"`
+	PublishDate       string `description:"发布时间"`
+	CreateTime        string `description:"创建时间"`
+	Abstract          string `description:"摘要/更新说明"`
+	UpdateDescription string `description:"更新说明"`
+	IsRed             bool   `description:"是否标记红点"`
+}
+
+type CygxReportSelectionListPublicRep struct {
+	Paging *paging.PagingItem `description:"分页数据"`
+	List   []*CygxReportSelectionRep
+}
+
+type AddCygxReportSelection struct {
+	ArticleId          int    `description:"报告Id ,传0时新增,大于0时修改"`
+	AddType            string `description:"更新方式 1重新编辑  ,2 继承往期"`
+	InheritPeriods     string `description:"继承期数"`
+	Title              string `description:"标题"`
+	Department         string `description:"作者"`
+	PublishDate        string `description:"发布时间"`
+	ProductDescription string `description:"产品说明"`
+	UpdateDescription  string `description:"更新说明"`
+	FocusOn            string `description:"近期重点关注方向"`
+	DoType             int    `description:"操作方式,1发布,0保存"`
+}
+
+type DetailCygxReportSelectionRep struct {
+	ArticleId          int    `description:"报告Id ,传0时新增,大于0时修改"`
+	AddType            string `description:"更新方式 1重新编辑  ,2 继承往期"`
+	Title              string `description:"标题"`
+	Department         string `description:"作者"`
+	PublishStatus      int    `description:"发布状态,1已发布,0未发布"`
+	PublishDate        string `description:"发布时间"`
+	CreateTime         string `description:"创建时间"`
+	LastUpdatedTime    string `description:"最后一次更新时间"`
+	Periods            string `description:"期数"`
+	HavePublish        int    `description:"是否发布过,1是,0否"`
+	InheritPeriods     string `description:"继承期数"`
+	InheritPeriodsName string `description:"继承期数名称"`
+	ProductDescription string `description:"产品说明"`
+	UpdateDescription  string `description:"更新说明"`
+	FocusOn            string `description:"近期重点关注方向"`
+}
+
+type ReportSelectionId struct {
+	ArticleId int `description:"报告I"`
+}
+
+//获取数量
+func GetCygxReportSelectionPublic(condition, tbdb string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM ` + tbdb + ` as art WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+//通过纪要ID获取活动详情
+func GetCygxReportSelectionInfoById(articleId int) (item *CygxReportSelectionRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_selection  WHERE article_id=?`
+	err = o.Raw(sql, articleId).QueryRow(&item)
+	return
+}
+
+//列表
+func GetReportSelectionListPublic(condition, tbdb string, pars []interface{}, startSize, pageSize int) (items []*CygxReportSelectionRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM  ` + tbdb + ` as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` ORDER BY  art.publish_date  DESC  LIMIT ?,?`
+	fmt.Println(sql)
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}