This commit is contained in:
jiangyong27 2023-10-07 14:21:00 +08:00
parent 93e6f387bd
commit d4bd2853b2
2 changed files with 79 additions and 0 deletions

View File

@ -2,8 +2,10 @@ package controller
import ( import (
"enterprise/server/service" "enterprise/server/service"
"enterprise/server/session"
"enterprise/worker" "enterprise/worker"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"net/http"
"strings" "strings"
"time" "time"
) )
@ -34,8 +36,10 @@ func (s *Staff) Salary(ctx *gin.Context) {
func (s *Staff) SyncStaffInfo(ctx *gin.Context) { func (s *Staff) SyncStaffInfo(ctx *gin.Context) {
go worker.SyncStaffInfo() go worker.SyncStaffInfo()
ctx.JSON(http.StatusOK, session.NewRspOk())
} }
func (s *Staff) SyncStaffSalary(ctx *gin.Context) { func (s *Staff) SyncStaffSalary(ctx *gin.Context) {
go worker.SyncStaffSalary("") go worker.SyncStaffSalary("")
ctx.JSON(http.StatusOK, session.NewRspOk())
} }

75
server/session/base.go Normal file
View File

@ -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,
}
}