123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- package model
- import (
- "fmt"
- "time"
- pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
- )
- type Calendar struct {
- Id int64 `json:"id"`
- Name string `json:"name"`
- CalendarType pasturePb.CalendarType_Kind `json:"calendarType"`
- Count int32 `json:"count"`
- ShowDay string `json:"showDay"`
- IsShow pasturePb.IsShow_Kind `json:"isShow"`
- Backup string `json:"backup"`
- CreatedAt int64 `json:"createdAt"`
- UpdatedAt int64 `json:"updatedAt"`
- }
- func (w *Calendar) TableName() string {
- return "calendar"
- }
- func NewCalendar(name string, calendarType pasturePb.CalendarType_Kind, count int32) *Calendar {
- return &Calendar{
- Name: name,
- Count: count,
- CalendarType: calendarType,
- ShowDay: time.Now().Format(LayoutDate2),
- IsShow: pasturePb.IsShow_Ok,
- }
- }
- var CalendarTypeColorMap = map[pasturePb.CalendarType_Kind]string{
- pasturePb.CalendarType_Immunisation: "#85c1e9",
- pasturePb.CalendarType_PG: "#48C9B0",
- pasturePb.CalendarType_RnGH: "#d35400",
- pasturePb.CalendarType_Pregnancy_Check: "#8E44AD",
- pasturePb.CalendarType_WorkOrder: "#5d6d7e",
- pasturePb.CalendarType_Treatment: "#c0392b",
- }
- type CalendarSlice []*Calendar
- func (c CalendarSlice) ToPB() []*pasturePb.Calendar {
- res := make([]*pasturePb.Calendar, len(c))
- for i, v := range c {
- res[i] = &pasturePb.Calendar{
- Id: int32(v.Id),
- Title: fmt.Sprintf("%s - %d", v.Name, v.Count),
- GroupId: v.CalendarType,
- Count: v.Count,
- Start: v.ShowDay,
- Color: CalendarTypeColorMap[v.CalendarType],
- ExtendedProps: v.Backup,
- }
- }
- return res
- }
- type CalendarResponse struct {
- Code int32 `json:"code"`
- Message string `json:"message"`
- Data *CalendarData `json:"data"`
- }
- type CalendarData struct {
- Total int32 `json:"total"`
- Page int32 `json:"page"`
- PageSize int32 `json:"pageSize"`
- Header interface{} `json:"header"`
- List interface{} `json:"data"`
- }
|