Browse Source

no message

xingzai 1 year ago
parent
commit
0bacd2c445
3 changed files with 70 additions and 13 deletions
  1. 10 8
      controllers/morning_meeting.go
  2. 34 0
      models/cygx_morning_meeting_gather.go
  3. 26 5
      services/morning_meeting.go

+ 10 - 8
controllers/morning_meeting.go

@@ -30,7 +30,7 @@ func (this *MorningMeetingController) List() {
 		br.Ret = 408
 		return
 	}
-	resp := new(models.GetCygxProductInteriorResp)
+	resp := new(models.CygxMorningMeetingGatherListResp)
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
 
@@ -44,25 +44,27 @@ func (this *MorningMeetingController) List() {
 	startSize = utils.StartIndex(currentIndex, pageSize)
 	var condition string
 	var pars []interface{}
-	condition += ` AND art.status = 1 `
-	total, err := models.GetCygxProductInteriorCount(condition, pars)
+	condition += ` AND status = 1 `
+	total, err := models.GetCygxMorningMeetingGatherCount(condition, pars)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
-	condition += "	ORDER BY art.publish_time DESC , art.product_interior_id DESC "
-	list, err := models.GetCygxProductInteriorList(condition, pars, startSize, pageSize)
+	condition += "	ORDER BY publish_time DESC ,id  DESC "
+	list, err := models.GetCygxMorningMeetingGatherList(condition, pars, startSize, pageSize)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
 	for _, v := range list {
-		v.PublishTime = utils.TimeRemoveHms(v.PublishTime)
+		item := new(models.CygxMorningMeetingGatherResp)
+		item.Id = v.Id
+		item.Title = v.Title
+		resp.List = append(resp.List, item)
 	}
-	page := paging.GetPaging(currentIndex, pageSize, total)
-	resp.List = list
 	resp.Paging = page
 	br.Ret = 200
 	br.Success = true

+ 34 - 0
models/cygx_morning_meeting_gather.go

@@ -2,6 +2,7 @@ package models
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
 	"time"
 )
 
@@ -21,3 +22,36 @@ func AddCygxMorningMeetingGather(item *CygxMorningMeetingGather) (err error) {
 	_, err = o.Insert(item)
 	return
 }
+
+func GetCygxMorningMeetingGatherCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) AS count FROM cygx_morning_meeting_gather WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	err = o.Raw(sql, pars).QueryRow(&count)
+	return
+}
+
+type CygxMorningMeetingGatherResp struct {
+	Id           int    `description:"ID"`
+	Title        string `description:"标题"`
+	SubjectNames string `description:"多个标的名称"`
+}
+
+type CygxMorningMeetingGatherListResp struct {
+	Paging *paging.PagingItem `description:"分页数据"`
+	List   []*CygxMorningMeetingGatherResp
+}
+
+// 列表
+func GetCygxMorningMeetingGatherList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxMorningMeetingGather, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_morning_meeting_gather WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 26 - 5
services/morning_meeting.go

@@ -9,11 +9,15 @@ import (
 	"time"
 )
 
-func init233() {
-	init12()
+func init123() {
+
+	for i := 180; i > 0; i-- {
+		init12(i)
+	}
+
 }
 
-func init12() (err error) {
+func init12(day int) (err error) {
 	defer func() {
 		if err != nil {
 			fmt.Println(err)
@@ -21,19 +25,36 @@ func init12() (err error) {
 		}
 	}()
 	hourstr := " 10:30:00 "
-	DayTime := time.Now().AddDate(0, 0, -46)
+	DayTime := time.Now().AddDate(0, 0, -day)
 	startSize := 0
 	pageSize := 100
 	var condition string
 	var pars []interface{}
 	startDate := DayTime.AddDate(0, 0, -1).Format(utils.FormatDate) + hourstr
 	endDate := DayTime.Format(utils.FormatDate) + hourstr
-	condition += ` 	AND publish_time  BETWEEN ?   AND  ? `
+
+	condition = ` 	AND publish_time  = ? `
+	pars = append(pars, endDate)
+	total, err := models.GetCygxMorningMeetingGatherCount(condition, pars)
+	if err != nil {
+		return
+	}
+	if total > 0 {
+		return
+	}
+	fmt.Println(total)
+	pars = make([]interface{}, 0)
+	pars = make([]interface{}, 0)
+	condition = ` 	AND publish_time  BETWEEN ?   AND  ? `
 	pars = append(pars, startDate, endDate)
+
 	list, err := models.GetCygxMorningMeetingReviewsList(condition, pars, startSize, pageSize)
 	if err != nil {
 		return
 	}
+	if len(list) == 0 {
+		return
+	}
 	item := new(models.CygxMorningMeetingGather)
 	for _, v := range list {
 		item.MeetingIds += strconv.Itoa(v.Id) + ","