This commit is contained in:
jiangyong 2026-05-10 11:17:39 +08:00
parent 4f189f6e2f
commit 9228429d63
1 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,42 @@
package enterprise
import (
"errors"
"git.u8t.cn/open/goutil"
"github.com/tidwall/gjson"
)
type StaffTarget struct {
Enterprise
}
type StaffTargetCreate struct {
Username string `json:"username"`
Month string `json:"month"`
Day string `json:"day"`
Score string `json:"score"`
Comment string `json:"comment"`
}
func NewStaffTarget(baseUrl, token string) *StaffTarget {
return &StaffTarget{
Enterprise: Enterprise{
baseUrl: baseUrl,
token: token,
},
}
}
func (e *StaffTarget) Create(req *StaffTargetCreate) error {
reqUrl := e.GetBaseUrl() + "/ext/staff/target"
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
}