rptin
This commit is contained in:
@@ -188,7 +188,7 @@ func (c *ApiController) AddPrinter(dataMap map[string]interface{}) (data, errCod
|
||||
var (
|
||||
printers []*model.Printer
|
||||
printersStr string
|
||||
//appID int
|
||||
appID int
|
||||
)
|
||||
globals.SugarLogger.Debugf("Begin API AddPrinter data: [%v]", utils.Format4Output(dataMap, false))
|
||||
if _, ok := dataMap["prints"].(string); !ok {
|
||||
@@ -201,34 +201,43 @@ func (c *ApiController) AddPrinter(dataMap map[string]interface{}) (data, errCod
|
||||
if err = utils.UnmarshalUseNumber([]byte(printersStr), &printers); err != nil {
|
||||
return buildParamErrCodeAndErr("prints")
|
||||
}
|
||||
//for _, v := range printers {
|
||||
// if v.PrintNo {
|
||||
//
|
||||
// }
|
||||
//}
|
||||
//appID = utils.Str2Int(dataMap[keyAppID].(string))
|
||||
//if err = cms.AddPrinter(appID, printers); err != nil {
|
||||
// return "", model.ErrCodeGeneralFailed, err
|
||||
//}
|
||||
return "", errCode, err
|
||||
}
|
||||
|
||||
//删除打印机绑定,暂不支持批量
|
||||
func (c *ApiController) DelPrinter(dataMap map[string]interface{}) (data, errCode string, err error) {
|
||||
var (
|
||||
printNo string
|
||||
appID int
|
||||
)
|
||||
globals.SugarLogger.Debugf("Begin API DelPrinter data: [%v]", utils.Format4Output(dataMap, false))
|
||||
if _, ok := dataMap[keyPrintNo].(string); !ok {
|
||||
return buildParamErrCodeAndErr(keyPrintNo)
|
||||
} else {
|
||||
if printNo = dataMap[keyPrintNo].(string); printNo == "" {
|
||||
return buildParamErrCodeAndErr(keyPrintNo)
|
||||
for _, v := range printers {
|
||||
if v.PrintNo == "" {
|
||||
return buildParamErrCodeAndErr("prints")
|
||||
}
|
||||
}
|
||||
appID = utils.Str2Int(dataMap[keyAppID].(string))
|
||||
if err = cms.DelPrinter(appID, printNo); err != nil {
|
||||
if err = cms.AddPrinter(appID, printers); err != nil {
|
||||
return "", model.ErrCodeGeneralFailed, err
|
||||
}
|
||||
return "", errCode, err
|
||||
}
|
||||
|
||||
//删除打印机绑定
|
||||
func (c *ApiController) DelPrinter(dataMap map[string]interface{}) (data, errCode string, err error) {
|
||||
var (
|
||||
printNos []string
|
||||
printNosStr string
|
||||
appID int
|
||||
)
|
||||
globals.SugarLogger.Debugf("Begin API DelPrinter data: [%v]", utils.Format4Output(dataMap, false))
|
||||
if _, ok := dataMap["print_nos"].(string); !ok {
|
||||
return buildParamErrCodeAndErr("print_nos")
|
||||
} else {
|
||||
if printNosStr = dataMap["print_nos"].(string); printNosStr == "" {
|
||||
return buildParamErrCodeAndErr("print_nos")
|
||||
}
|
||||
}
|
||||
if err = utils.UnmarshalUseNumber([]byte(printNosStr), &printNos); err != nil {
|
||||
return buildParamErrCodeAndErr("print_nos")
|
||||
}
|
||||
for _, v := range printNos {
|
||||
if v == "" {
|
||||
return buildParamErrCodeAndErr("print_nos")
|
||||
}
|
||||
}
|
||||
appID = utils.Str2Int(dataMap[keyAppID].(string))
|
||||
if err = cms.DelPrinter(appID, printNos); err != nil {
|
||||
return "", model.ErrCodeGeneralFailed, err
|
||||
}
|
||||
return "", errCode, err
|
||||
|
||||
Reference in New Issue
Block a user