Browse Source

Merge branch 'cygx_10.1' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 2 years ago
parent
commit
a4997fbd0e

+ 16 - 1
controllers/chart_permission.go

@@ -198,8 +198,23 @@ func (this *ChartPermissionAuthController) StrategyDetail() {
 			list[k].IsRed = true
 		}
 	}
+	cf, err := models.GetConfigByCode(utils.CYGX_TACTICS_TIME_LINE_STATUS)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
 	resp := new(models.ReportMappingHomeResp)
-	resp.List = list
+	if cf.ConfigValue == "1" || user.CompanyId == utils.HZ_COMPANY_ID {
+		item := new(models.ReportMappingHome)
+		item.CategoryId = utils.TIME_LINE_ID
+		item.SubCategoryName = utils.TIME_LINE_NAME
+		item.MatchTypeName = utils.TIME_LINE_NAME
+		resp.List = append(resp.List, item)
+	}
+	for _, v := range list {
+		resp.List = append(resp.List, v)
+	}
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 127 - 14
controllers/tactics.go

@@ -1,6 +1,7 @@
 package controllers
 
 import (
+	"encoding/json"
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_cygx/models"
@@ -118,18 +119,6 @@ func (this *TacticsController) List() {
 		listTacticsSrt = strings.TrimRight(listTacticsSrt, ",")
 		condition = ` AND category_id IN(` + listTacticsSrt + `)`
 	} else {
-		//categoryIdSet, errCategory := models.GetdetailByCategoryIdSet(categoryId)
-		//if errCategory != nil {
-		//	br.Msg = "获取信息失败"
-		//	br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
-		//	return
-		//}
-		//if categoryIdSet != "" {
-		//	condition = ` AND category_id IN(` + categoryIdSet + `)`
-		//} else {
-		//	condition = ` AND category_id IN(` + strconv.Itoa(categoryId) + `)`
-		//}
-
 		if detail.CeLueFieldId != "" {
 			condition = ` AND ce_lue_field_id IN(` + detail.CeLueFieldId + `)`
 		} else if detail.PolymerizationId != "" {
@@ -137,7 +126,6 @@ func (this *TacticsController) List() {
 		} else {
 			condition = ` AND category_id IN(` + strconv.Itoa(categoryId) + `)`
 		}
-
 	}
 	total, err = models.GetHomeCount(condition, pars)
 	if err != nil {
@@ -145,7 +133,6 @@ func (this *TacticsController) List() {
 		br.Msg = "获取帖子总数失败,Err:" + err.Error()
 		return
 	}
-
 	page = paging.GetPaging(currentIndex, pageSize, total)
 	list, err := models.GetReportTacticsList(condition, pars, uid, startSize, pageSize)
 	if err != nil {
@@ -381,3 +368,129 @@ Loop:
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 时间线列表
+// @Description 时间线列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Success 200 {object} models.GetCygxTacticsTimeLineResp
+// @router /tacticsTimeLine/list [get]
+func (this *TacticsController) TacticsTimeLineList() {
+	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(models.GetCygxTacticsTimeLineResp)
+	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 := models.GetCygxTacticsTimeLineCount(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 := models.GetCygxTacticsTimeLineList(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)
+	}
+	if len(list) == 0 {
+		list = make([]*models.CygxTacticsTimeLineResp, 0)
+	}
+	cf, err := models.GetConfigByCode(utils.CYGX_TACTICS_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([]*models.CygxTacticsTimeLineResp, 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.TacticsTimeLineTimeLineIdReq true "type json string"
+// @Success Ret=200 新增成功
+// @router /tacticsTimeLine/history [post]
+func (this *TacticsController) 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 := models.CygxTacticsTimeLineHistory{
+		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 = models.AddCygxTacticsTimeLineHistory(&item)
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}

+ 1 - 0
models/db.go

@@ -134,6 +134,7 @@ func init() {
 		new(CygxActivitySpecialTripBill),
 		new(CygxXzsChooseCategory),
 		new(CygxReportSelectionSubjectHistory),
+		new(CygxTacticsTimeLineHistory),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 81 - 0
models/tactics_time_line.go

@@ -0,0 +1,81 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
+)
+
+type CygxTacticsTimeLine 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 AddTacticsTimeLineReq struct {
+	TimeLineId  int    `orm:"column(time_line_id);pk"`
+	PublishTime string `description:"发布日期"`
+	Content     string `description:"内容"`
+	Link        string `description:"文章或图表链接"`
+}
+type TacticsTimeLineTimeLineIdReq struct {
+	TimeLineId int `description:"ID"`
+}
+
+type GetCygxTacticsTimeLineResp struct {
+	Status int                `description:"0:内部可见,1:全部可见"`
+	Paging *paging.PagingItem `description:"分页数据"`
+	List   []*CygxTacticsTimeLineResp
+}
+
+type CygxTacticsTimeLineResp 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:"文章或图表链接"`
+}
+
+// 获取数量
+func GetCygxTacticsTimeLineCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_tactics_time_line as art WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 列表
+func GetCygxTacticsTimeLineList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxTacticsTimeLineResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_tactics_time_line as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+type GetCygxTacticsTimeLineDetailResp struct {
+	Detail *CygxTacticsTimeLineResp
+}
+
+// 通过ID获取详情
+func GetCygxTacticsTimeLineDetail(timeLineId int) (item *CygxTacticsTimeLineResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_tactics_time_line  WHERE time_line_id=? `
+	err = o.Raw(sql, timeLineId).QueryRow(&item)
+	return
+}

+ 38 - 0
models/tactics_time_line_history.go

@@ -0,0 +1,38 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxTacticsTimeLineHistory 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 GetCygxTacticsTimeLineHistoryList(condition string, pars []interface{}) (items []*CygxTacticsTimeLineHistory, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_tactics_time_line_history as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+// 添加
+func AddCygxTacticsTimeLineHistory(item *CygxTacticsTimeLineHistory) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}

+ 18 - 0
routers/commentsRouter.go

@@ -1186,6 +1186,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:TacticsController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:TacticsController"],
+        beego.ControllerComments{
+            Method: "History",
+            Router: `/tacticsTimeLine/history`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:TacticsController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:TacticsController"],
+        beego.ControllerComments{
+            Method: "TacticsTimeLineList",
+            Router: `/tacticsTimeLine/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserCommonController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserCommonController"],
         beego.ControllerComments{
             Method: "LoginPublic",

+ 6 - 3
utils/constants.go

@@ -99,9 +99,12 @@ const (
 	HONG_GUAN_NAME                   string = "宏观"
 	HONG_GUAN_ID                     int    = 1
 	GU_SHOU_NAME                     string = "固收"
-	GU_SHOU_ID                       int    = 100000   // 自定义权限类型ID ,十万起步
-	YAN_XUAN_ARTICLE_TYPE_IDS        string = "1,2,12" // 属于研选的报告类型ID
-	NO_YAN_XUAN_ARTICLE_TYPE_IDS     string = "13"     // 不属于研选的报告类型ID
+	GU_SHOU_ID                       int    = 100000                          // 自定义权限类型ID ,十万起步
+	YAN_XUAN_ARTICLE_TYPE_IDS        string = "1,2,12"                        // 属于研选的报告类型ID
+	NO_YAN_XUAN_ARTICLE_TYPE_IDS     string = "13"                            // 不属于研选的报告类型ID
+	CYGX_TACTICS_TIME_LINE_STATUS    string = "cygx_tactics_time_line_status" // 策略时间线是否对外开放
+	TIME_LINE_ID                     int    = 99999                           // 策略时间线的值
+	TIME_LINE_NAME                   string = "时间线"                           // 策略时间线的名称
 )
 
 const (