unify
This commit is contained in:
parent
4f189f6e2f
commit
9228429d63
|
|
@ -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
|
||||
}
|
||||
Loading…
Reference in New Issue