1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package controllers
-
- import (
- "XT_New/enums"
- "XT_New/service"
- "XT_New/utils"
- "time"
-
- "github.com/astaxie/beego"
- )
-
- func DialysisBoardAPIControllerRegistRouter() {
- beego.Router("/api/dialysis/board", &DialysisBoardAPIController{}, "get:BoardData")
- }
-
- type DialysisBoardAPIController struct {
- BaseAuthAPIController
- }
-
- func (c *DialysisBoardAPIController) BoardData() {
- page, _ := c.GetInt64("page", 0)
- if page <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- nowTimeUinx := time.Now()
- today := nowTimeUinx.Format("2006-01-02")
- week := nowTimeUinx.Weekday()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- todayTime, err := time.ParseInLocation(timeLayout, today, loc)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- var limit int64 = 10
- offset := (page - 1) * limit
- todayTimeStamp := todayTime.Unix()
-
- adminUserInfo := c.GetAdminUserInfo()
-
- boards, err := service.GetDialysisBoard(adminUserInfo.CurrentOrgId, todayTimeStamp, offset, limit)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "today": today,
- "week": week,
- "boards": boards,
- })
-
- }
|