43 lines
795 B
Go
43 lines
795 B
Go
package erp
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"git.u8t.cn/open/goutil"
|
|
"github.com/tidwall/gjson"
|
|
)
|
|
|
|
type StaffScore struct {
|
|
Erp
|
|
}
|
|
|
|
type StaffScoreCreate struct {
|
|
Username string `json:"username"`
|
|
Month string `json:"month"`
|
|
Day string `json:"day"`
|
|
Score string `json:"score"`
|
|
Comment string `json:"comment"`
|
|
}
|
|
|
|
func NewStaffScore(baseUrl, token string) *StaffScore {
|
|
return &StaffScore{
|
|
Erp: Erp{
|
|
baseUrl: baseUrl,
|
|
token: token,
|
|
},
|
|
}
|
|
}
|
|
|
|
func (e *StaffScore) Create(req *StaffScoreCreate) error {
|
|
reqUrl := e.GetBaseUrl() + "/ext/staff/score"
|
|
body, err := goutil.HttpPost(reqUrl, e.GetHeader(), []byte(goutil.EncodeJSON(req)))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
g := gjson.ParseBytes(body)
|
|
if g.Get("code").Int() != 0 {
|
|
return errors.New(string(body))
|
|
}
|
|
return nil
|
|
}
|