1
This commit is contained in:
@@ -12,7 +12,10 @@ func (a *API) AddPrinter(sn, key, name string) error {
|
||||
Key: key,
|
||||
Name: name,
|
||||
}}
|
||||
resp := a.HttpPostJson("addPrinter", params)
|
||||
resp, err := a.HttpPostJson("addPrinter", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
@@ -33,11 +36,14 @@ func (a *API) AddPrinter(sn, key, name string) error {
|
||||
|
||||
//修改打印机信息
|
||||
func (a *API) EditPrinter(sn, name string) (string, error) {
|
||||
resp := a.HttpPostJson("editPrinter", []EditPrinterReq{{
|
||||
resp, err := a.HttpPostJson("editPrinter", []EditPrinterReq{{
|
||||
Sn: sn,
|
||||
Name: name,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return "", errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
@@ -58,7 +64,10 @@ func (a *API) EditPrinter(sn, name string) (string, error) {
|
||||
|
||||
//删除打印机
|
||||
func (a *API) DelPrinter(snList []string) error {
|
||||
resp := a.HttpPostJson("delPrinter", snList)
|
||||
resp, err := a.HttpPostJson("delPrinter", snList)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
@@ -79,10 +88,13 @@ func (a *API) DelPrinter(snList []string) error {
|
||||
|
||||
//设置打印机浓度
|
||||
func (a *API) SetDensity(sn string, density int) error {
|
||||
resp := a.HttpPostJson("setDensity", SetDensityReq{
|
||||
resp, err := a.HttpPostJson("setDensity", SetDensityReq{
|
||||
Sn: sn,
|
||||
Density: density,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
@@ -94,10 +106,13 @@ func (a *API) SetDensity(sn string, density int) error {
|
||||
|
||||
//设置音量
|
||||
func (a *API) SetVolume(sn string, volume int) error {
|
||||
resp := a.HttpPostJson("setVolume", SetVolumeReq{
|
||||
resp, err := a.HttpPostJson("setVolume", SetVolumeReq{
|
||||
Sn: sn,
|
||||
Volume: volume,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
@@ -109,7 +124,10 @@ func (a *API) SetVolume(sn string, volume int) error {
|
||||
|
||||
//查询打印机状态
|
||||
func (a *API) GetDeviceStatus(sn string) (float64, float64, error) {
|
||||
resp := a.HttpPostJson("getDeviceStatus", GetDeviceStatusReq{Sn: sn})
|
||||
resp, err := a.HttpPostJson("getDeviceStatus", GetDeviceStatusReq{Sn: sn})
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return 0, 0, errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
@@ -122,7 +140,10 @@ func (a *API) GetDeviceStatus(sn string) (float64, float64, error) {
|
||||
|
||||
//清空设备待打印队列
|
||||
func (a *API) CleanWaitingQueue(sn string) error {
|
||||
resp := a.HttpPostJson("cleanWaitingQueue", sn)
|
||||
resp, err := a.HttpPostJson("cleanWaitingQueue", sn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
@@ -134,7 +155,7 @@ func (a *API) CleanWaitingQueue(sn string) error {
|
||||
|
||||
//打印小票
|
||||
func (a *API) Print(sn, content, voice string) (string, error) {
|
||||
resp := a.HttpPostJson("print", PrintReq{
|
||||
resp, err := a.HttpPostJson("print", PrintReq{
|
||||
Sn: sn,
|
||||
Content: content,
|
||||
Voice: voice,
|
||||
@@ -142,7 +163,9 @@ func (a *API) Print(sn, content, voice string) (string, error) {
|
||||
VoicePlayInterval: 3,
|
||||
Copies: 1,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return "", errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user