|
@@ -4,19 +4,25 @@ import (
|
|
"kpt-pasture/util"
|
|
"kpt-pasture/util"
|
|
"strconv"
|
|
"strconv"
|
|
"strings"
|
|
"strings"
|
|
|
|
+ "time"
|
|
|
|
+
|
|
|
|
+ pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+const DefaultDataLatencyMinutes = 40
|
|
|
|
+
|
|
type DataNotice struct {
|
|
type DataNotice struct {
|
|
- Id int64 `json:"id"`
|
|
|
|
- PastureId int64 `json:"pastureId"`
|
|
|
|
- Title string `json:"title"`
|
|
|
|
- Content string `json:"content"`
|
|
|
|
- KnownUsers string `json:"knownUsers"`
|
|
|
|
- StartDate string `json:"startDate"`
|
|
|
|
- EndDate string `json:"endDate"`
|
|
|
|
- IsShow int32 `json:"isShow"`
|
|
|
|
- CreatedAt int64 `json:"createdAt"`
|
|
|
|
- UpdatedAt int64 `json:"updatedAt"`
|
|
|
|
|
|
+ Id int64 `json:"id"`
|
|
|
|
+ PastureId int64 `json:"pastureId"`
|
|
|
|
+ Title string `json:"title"`
|
|
|
|
+ Content string `json:"content"`
|
|
|
|
+ KnownUsers string `json:"knownUsers"`
|
|
|
|
+ NoticeKind pasturePb.NoticeType_Kind `json:"noticeKind"`
|
|
|
|
+ StartDate string `json:"startDate"`
|
|
|
|
+ EndDate string `json:"endDate"`
|
|
|
|
+ IsShow pasturePb.IsShow_Kind `json:"isShow"`
|
|
|
|
+ CreatedAt int64 `json:"createdAt"`
|
|
|
|
+ UpdatedAt int64 `json:"updatedAt"`
|
|
}
|
|
}
|
|
|
|
|
|
func (d *DataNotice) TableName() string {
|
|
func (d *DataNotice) TableName() string {
|
|
@@ -35,6 +41,20 @@ func (d *DataNotice) GetUserIds() []int64 {
|
|
return userIds
|
|
return userIds
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func NewDataNotice(pastureId int64, title, content string, noticeKind pasturePb.NoticeType_Kind) *DataNotice {
|
|
|
|
+ nowTime := time.Now().Local()
|
|
|
|
+ return &DataNotice{
|
|
|
|
+ Title: title,
|
|
|
|
+ Content: content,
|
|
|
|
+ StartDate: nowTime.Format(LayoutDate2),
|
|
|
|
+ EndDate: nowTime.Format(LayoutDate2),
|
|
|
|
+ IsShow: pasturePb.IsShow_Ok,
|
|
|
|
+ PastureId: pastureId,
|
|
|
|
+ NoticeKind: noticeKind,
|
|
|
|
+ KnownUsers: "",
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
type DataNoticeSlice []*DataNotice
|
|
type DataNoticeSlice []*DataNotice
|
|
|
|
|
|
func (d DataNoticeSlice) ToPB(currentUserId int64) []*NoticeContent {
|
|
func (d DataNoticeSlice) ToPB(currentUserId int64) []*NoticeContent {
|
|
@@ -45,9 +65,10 @@ func (d DataNoticeSlice) ToPB(currentUserId int64) []*NoticeContent {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
res = append(res, &NoticeContent{
|
|
res = append(res, &NoticeContent{
|
|
- Id: v.Id,
|
|
|
|
- Title: v.Title,
|
|
|
|
- Content: v.Content,
|
|
|
|
|
|
+ Id: v.Id,
|
|
|
|
+ Title: v.Title,
|
|
|
|
+ Content: v.Content,
|
|
|
|
+ NoticeKind: v.NoticeKind,
|
|
})
|
|
})
|
|
}
|
|
}
|
|
return res
|
|
return res
|
|
@@ -60,7 +81,8 @@ type DataNoticeResponse struct {
|
|
}
|
|
}
|
|
|
|
|
|
type NoticeContent struct {
|
|
type NoticeContent struct {
|
|
- Id int64 `json:"id"`
|
|
|
|
- Title string `json:"title"`
|
|
|
|
- Content string `json:"content"`
|
|
|
|
|
|
+ Id int64 `json:"id"`
|
|
|
|
+ Title string `json:"title"`
|
|
|
|
+ Content string `json:"content"`
|
|
|
|
+ NoticeKind pasturePb.NoticeType_Kind `json:"noticeKind"`
|
|
}
|
|
}
|