42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package controller
|
|
|
|
import (
|
|
"enterprise/common/config"
|
|
"enterprise/common/dao"
|
|
"enterprise/server/api"
|
|
"enterprise/server/service"
|
|
"enterprise/server/session"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/spf13/cast"
|
|
"net/http"
|
|
)
|
|
|
|
type StaffCheckin struct {
|
|
}
|
|
|
|
func (s *StaffCheckin) List(ctx *gin.Context) {
|
|
var req api.ListCheckin
|
|
if err := ctx.ShouldBind(&req); err != nil {
|
|
panic(config.ErrParam.New().Append(err))
|
|
}
|
|
sess := ctx.Keys[session.ContextSession].(*session.AdminSession)
|
|
total, items := new(service.Checkin).List(sess, &req)
|
|
ctx.JSON(http.StatusOK, session.NewListRsp(total, items))
|
|
}
|
|
|
|
func (s *StaffCheckin) Sync(ctx *gin.Context) {
|
|
var req api.SyncCheckin
|
|
if err := ctx.ShouldBindJSON(&req); err != nil {
|
|
panic(config.ErrParam.New().Append(err))
|
|
}
|
|
sess := ctx.Keys[session.ContextSession].(*session.AdminSession)
|
|
new(service.Checkin).Sync(sess, &req)
|
|
ctx.JSON(http.StatusOK, session.NewRspOk())
|
|
}
|
|
|
|
func (s *StaffCheckin) Delete(ctx *gin.Context) {
|
|
id := cast.ToInt64(ctx.Query("id"))
|
|
dao.NewCheckinDao().Delete(id)
|
|
ctx.JSON(http.StatusOK, session.NewRspOk())
|
|
}
|