sync2
This commit is contained in:
parent
93e6f387bd
commit
d4bd2853b2
|
@ -2,8 +2,10 @@ package controller
|
|||
|
||||
import (
|
||||
"enterprise/server/service"
|
||||
"enterprise/server/session"
|
||||
"enterprise/worker"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
@ -34,8 +36,10 @@ func (s *Staff) Salary(ctx *gin.Context) {
|
|||
|
||||
func (s *Staff) SyncStaffInfo(ctx *gin.Context) {
|
||||
go worker.SyncStaffInfo()
|
||||
ctx.JSON(http.StatusOK, session.NewRspOk())
|
||||
}
|
||||
|
||||
func (s *Staff) SyncStaffSalary(ctx *gin.Context) {
|
||||
go worker.SyncStaffSalary("")
|
||||
ctx.JSON(http.StatusOK, session.NewRspOk())
|
||||
}
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type BaseResponse struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type CommonResponse struct {
|
||||
BaseResponse
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
type RawResponse struct {
|
||||
BaseResponse
|
||||
Data json.RawMessage `json:"data"`
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
BaseResponse
|
||||
Data struct {
|
||||
Total int64 `json:"total"`
|
||||
TotalAmount string `json:"totalAmount,omitempty"`
|
||||
Items interface{} `json:"items"`
|
||||
} `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
var (
|
||||
rspOk *BaseResponse
|
||||
)
|
||||
|
||||
func init() {
|
||||
rspOk = new(BaseResponse)
|
||||
rspOk.Message = "OK"
|
||||
rspOk.Code = 0
|
||||
}
|
||||
|
||||
func NewRspOk() *BaseResponse {
|
||||
return rspOk
|
||||
}
|
||||
|
||||
func NewRawRsp(raw []byte) *RawResponse {
|
||||
rsp := &RawResponse{
|
||||
BaseResponse: BaseResponse{
|
||||
Code: rspOk.Code,
|
||||
Message: rspOk.Message,
|
||||
},
|
||||
}
|
||||
rsp.Data = raw
|
||||
return rsp
|
||||
}
|
||||
func NewListRsp(total int64, items interface{}) *ListResponse {
|
||||
rsp := &ListResponse{
|
||||
BaseResponse: BaseResponse{
|
||||
Code: rspOk.Code,
|
||||
Message: rspOk.Message,
|
||||
},
|
||||
}
|
||||
rsp.Data.Total = total
|
||||
rsp.Data.Items = items
|
||||
return rsp
|
||||
}
|
||||
|
||||
func NewRsp(data interface{}) *CommonResponse {
|
||||
return &CommonResponse{
|
||||
BaseResponse: BaseResponse{
|
||||
Code: rspOk.Code,
|
||||
Message: rspOk.Message,
|
||||
},
|
||||
Data: data,
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue