Bladeren bron

no message

zhangchuanxing 2 maanden geleden
bovenliggende
commit
e1bffb34c9

+ 145 - 0
controllers/gushou.go

@@ -0,0 +1,145 @@
+package controllers
+
+import (
+	"encoding/json"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/models/time_line"
+	"hongze/hongze_clpt/services"
+	"hongze/hongze_clpt/utils"
+	"time"
+)
+
+// 固收
+type MobileGushouController struct {
+	BaseAuthMobileController
+}
+
+// @Title 固收时间线列表
+// @Description 固收时间线列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Success 200 {object} models.GetCygxGushouTimeLineResp
+// @router /gushouTimeLine/list [get]
+func (this *MobileGushouController) GushouTimeLineList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+
+	resp := new(time_line.GetCygxGushouTimeLineResp)
+	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 art.status = 1 `
+	total, err := time_line.GetCygxGushouTimeLineCount(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	condition += "	ORDER BY art.publish_time DESC , art.time_line_id DESC "
+	list, err := time_line.GetCygxGushouTimeLineList(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	for _, v := range list {
+		v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
+		v.Resource = 1
+		v.Content = services.AnnotationHtml(v.Content)
+	}
+	if len(list) == 0 {
+		list = make([]*time_line.CygxGushouTimeLineResp, 0)
+	}
+	cf, err := models.GetConfigByCode(utils.CYGX_GUSHOU_TIME_LINE_STATUS)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	//如果不是弘则用户,并且设置了内部可见,那么数据就隐藏
+	if user.CompanyId != utils.HZ_COMPANY_ID && cf.ConfigValue != "1" {
+		list = make([]*time_line.CygxGushouTimeLineResp, 0)
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.List = list
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 固收时间线点击记录
+// @Description 固收时间线点击记录接口
+// @Param	request	body models.GushouTimeLineTimeLineIdReq true "type json string"
+// @Success Ret=200 新增成功
+// @router /gushouTimeLine/history [post]
+func (this *MobileGushouController) History() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	var req models.TacticsTimeLineTimeLineIdReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	timeLineId := req.TimeLineId
+	if timeLineId == 0 {
+		br.Msg = "时间线ID错误"
+		return
+	}
+	var sellerName string
+	sellerName, err = models.GetCompanySellerName(user.CompanyId)
+	if err != nil {
+		br.Msg = "记录失败!"
+		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+		return
+	}
+	item := time_line.CygxGushouTimeLineHistory{
+		TimeLineId:  timeLineId,
+		UserId:      user.UserId,
+		Mobile:      user.Mobile,
+		Email:       user.Email,
+		CompanyId:   user.CompanyId,
+		CompanyName: user.CompanyName,
+		RealName:    user.RealName,
+		SellerName:  sellerName,
+		CreateTime:  time.Now(),
+		ModifyTime:  time.Now(),
+	}
+	err = time_line.AddCygxGushouTimeLineHistory(&item)
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}

+ 2 - 0
models/db.go

@@ -2,6 +2,7 @@ package models
 
 import (
 	_ "github.com/go-sql-driver/mysql"
+	"hongze/hongze_clpt/models/time_line"
 	"hongze/hongze_clpt/utils"
 	"time"
 
@@ -106,6 +107,7 @@ func init() {
 		new(CygxActivityVideoHistory),
 		new(CygxTimelineLog),
 		new(CygxActivitySpecialPermissionPoints),
+		new(time_line.CygxGushouTimeLineHistory),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 82 - 0
models/time_line/gushou_time_line.go

@@ -0,0 +1,82 @@
+package time_line
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
+)
+
+type CygxGushouTimeLine struct {
+	TimeLineId  int       `orm:"column(time_line_id);pk"`
+	PublishTime time.Time `description:"发布日期"`
+	CreateTime  time.Time `description:"创建时间"`
+	ModifyTime  time.Time `description:"更新时间"`
+	Status      int       `description:"0:未发布,1:已发布"`
+	Content     string    `description:"内容"`
+	ArticleId   int       `description:"文章ID"`
+	ChartId     int       `description:"图表ID"`
+	Link        string    `description:"文章或图表链接"`
+	AdminId     int       `description:"管理员ID"`
+}
+
+type AddGushouTimeLineReq struct {
+	TimeLineId  int    `orm:"column(time_line_id);pk"`
+	PublishTime string `description:"发布日期"`
+	Content     string `description:"内容"`
+	Link        string `description:"文章或图表链接"`
+}
+type GushouTimeLineTimeLineIdReq struct {
+	TimeLineId int `description:"ID"`
+}
+
+type GetCygxGushouTimeLineResp struct {
+	Status int                `description:"0:内部可见,1:全部可见"`
+	Paging *paging.PagingItem `description:"分页数据"`
+	List   []*CygxGushouTimeLineResp
+}
+
+type CygxGushouTimeLineResp struct {
+	TimeLineId  int    `description:"ID"`
+	PublishTime string `description:"发布日期"`
+	Status      int    `description:"0:未发布,1:已发布"`
+	Content     string `description:"内容"`
+	ArticleId   int    `description:"文章ID"`
+	ChartId     int    `description:"图表ID"`
+	Link        string `description:"文章或图表链接"`
+	Resource    int    `description:"来源类型,1:文章、2:产品内测、3:晨报点评"`
+}
+
+// 获取数量
+func GetCygxGushouTimeLineCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_gushou_time_line as art WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 列表
+func GetCygxGushouTimeLineList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxGushouTimeLineResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_gushou_time_line as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+type GetCygxGushouTimeLineDetailResp struct {
+	Detail *CygxGushouTimeLineResp
+}
+
+// 通过ID获取详情
+func GetCygxGushouTimeLineDetail(timeLineId int) (item *CygxGushouTimeLineResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_gushou_time_line  WHERE time_line_id=? `
+	err = o.Raw(sql, timeLineId).QueryRow(&item)
+	return
+}

+ 38 - 0
models/time_line/gushou_time_line_history.go

@@ -0,0 +1,38 @@
+package time_line
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxGushouTimeLineHistory struct {
+	Id          int `orm:"column(id);pk"`
+	TimeLineId  int
+	UserId      int
+	CreateTime  time.Time
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	ModifyTime  time.Time `description:"修改时间"`
+	RealName    string    `description:"用户实际名称"`
+	SellerName  string    `description:"所属销售"`
+}
+
+// 列表
+func GetCygxGushouTimeLineHistoryList(condition string, pars []interface{}) (items []*CygxGushouTimeLineHistory, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_gushou_time_line_history as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+// 添加
+func AddCygxGushouTimeLineHistory(item *CygxGushouTimeLineHistory) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}

+ 18 - 0
routers/commentsRouter.go

@@ -520,6 +520,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileGushouController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileGushouController"],
+        beego.ControllerComments{
+            Method: "History",
+            Router: `/gushouTimeLine/history`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileGushouController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileGushouController"],
+        beego.ControllerComments{
+            Method: "GushouTimeLineList",
+            Router: `/gushouTimeLine/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileHomeController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileHomeController"],
         beego.ControllerComments{
             Method: "List",

+ 5 - 0
routers/router.go

@@ -133,6 +133,11 @@ func init() {
 				&controllers.MobileTacticsController{},
 			),
 		),
+		web.NSNamespace("/gushou",
+			web.NSInclude(
+				&controllers.MobileGushouController{},
+			),
+		),
 		web.NSNamespace("/banner",
 			web.NSInclude(
 				&controllers.BannerController{},

+ 1 - 0
utils/constants.go

@@ -107,6 +107,7 @@ const (
 	GU_SHOU_ID_CHART                 int    = 53     // chart_permission 表 固收ID
 	HONG_GUAN_NAME                   string = "宏观"
 	CYGX_TACTICS_TIME_LINE_STATUS    string = "cygx_tactics_time_line_status" // 策略时间线是否对外开放
+	CYGX_GUSHOU_TIME_LINE_STATUS     string = "cygx_gushou_time_line_status"  // 固收时间线是否对外开放
 	TIME_LINE_ID                     int    = 99999                           // 策略时间线的值
 	TIME_LINE_NAME                   string = "时间线"                           // 策略时间线的名称
 	ACTEGORY_ID_AI_QY                int    = 61                              // AI前沿自定义ID