duration
This commit is contained in:
parent
db48d126c4
commit
f8233d6746
|
@ -4,6 +4,7 @@ import (
|
||||||
"enterprise/common/model"
|
"enterprise/common/model"
|
||||||
"github.com/smbrave/goutil"
|
"github.com/smbrave/goutil"
|
||||||
"github.com/spf13/cast"
|
"github.com/spf13/cast"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BaseRequest struct {
|
type BaseRequest struct {
|
||||||
|
@ -41,6 +42,7 @@ type Checkin struct {
|
||||||
Rawdata string `json:"rawdata"`
|
Rawdata string `json:"rawdata"`
|
||||||
StartTime string `json:"start_time"`
|
StartTime string `json:"start_time"`
|
||||||
EndTime string `json:"end_time"`
|
EndTime string `json:"end_time"`
|
||||||
|
Duration string `json:"duration"`
|
||||||
CreateTime string `json:"create_time"`
|
CreateTime string `json:"create_time"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +54,9 @@ func (c *Checkin) From(m *model.Checkin) {
|
||||||
c.StartTime = goutil.TimeToDateTime(m.StartTime)
|
c.StartTime = goutil.TimeToDateTime(m.StartTime)
|
||||||
c.EndTime = goutil.TimeToDateTime(m.EndTime)
|
c.EndTime = goutil.TimeToDateTime(m.EndTime)
|
||||||
c.CreateTime = goutil.TimeToDateTime(m.CreateTime)
|
c.CreateTime = goutil.TimeToDateTime(m.CreateTime)
|
||||||
|
if m.EndTime > 0 && m.StartTime > 0 && m.EndTime > m.StartTime {
|
||||||
|
c.Duration = (time.Duration(m.EndTime-m.StartTime) * time.Second).String()
|
||||||
|
}
|
||||||
c.Exception = m.Exception
|
c.Exception = m.Exception
|
||||||
c.Rawdata = m.Rawdata
|
c.Rawdata = m.Rawdata
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,10 @@ func (s *Staff) Login(ctx *gin.Context) {
|
||||||
ctx.JSON(http.StatusOK, session.NewRsp(data))
|
ctx.JSON(http.StatusOK, session.NewRsp(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Staff) Suggest(ctx *gin.Context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Staff) List(ctx *gin.Context) {
|
func (s *Staff) List(ctx *gin.Context) {
|
||||||
sess := ctx.Keys[session.ContextSession].(*session.AdminSession)
|
sess := ctx.Keys[session.ContextSession].(*session.AdminSession)
|
||||||
var req api.StaffListReq
|
var req api.StaffListReq
|
||||||
|
|
|
@ -27,6 +27,7 @@ func initRoutge(engine *gin.Engine) {
|
||||||
group.GET("/staff/salary", controller.NewStaff().Salary)
|
group.GET("/staff/salary", controller.NewStaff().Salary)
|
||||||
group.GET("/staff/sync/salary", controller.NewStaff().SyncStaffSalary)
|
group.GET("/staff/sync/salary", controller.NewStaff().SyncStaffSalary)
|
||||||
noTokenGroup.POST("/staff/login", controller.NewStaff().Login)
|
noTokenGroup.POST("/staff/login", controller.NewStaff().Login)
|
||||||
|
apiGroup.GET("/staff/suggest", controller.NewStaff().Suggest)
|
||||||
apiGroup.POST("/staff", controller.NewStaff().Create)
|
apiGroup.POST("/staff", controller.NewStaff().Create)
|
||||||
apiGroup.PUT("/staff", controller.NewStaff().Update)
|
apiGroup.PUT("/staff", controller.NewStaff().Update)
|
||||||
apiGroup.DELETE("/staff", controller.NewStaff().Delete)
|
apiGroup.DELETE("/staff", controller.NewStaff().Delete)
|
||||||
|
|
Loading…
Reference in New Issue