diff --git a/controllers/api_controller.go b/controllers/api_controller.go index 1d1a37f43..55e60e2ba 100644 --- a/controllers/api_controller.go +++ b/controllers/api_controller.go @@ -123,7 +123,7 @@ func (c *ApiController) CallOpenAPI() { } goto end } else { - if app.Status != model.UserStatusNormal { + if app.Status != model.UserStatusNormal || app.DeletedAt != utils.DefaultTimeValue { errCode = model.ErrCodeGeneralFailed err = fmt.Errorf("很抱歉您的应用已失效!") goto end @@ -183,32 +183,29 @@ end: } } -//添加打印机,暂不支持批量 +//添加打印机,一次最多50条 func (c *ApiController) AddPrinter(dataMap map[string]interface{}) (data, errCode string, err error) { var ( - printNo, printKey, name string - appID int + printers []*model.Printer + //printNo, printKey, name string + printersStr string + //appID int ) globals.SugarLogger.Debugf("Begin API AddPrinter data: [%v]", utils.Format4Output(dataMap, false)) - if _, ok := dataMap[keyPrintNo].(string); !ok { - return buildParamErrCodeAndErr(keyPrintNo) + if _, ok := dataMap["prints"].(string); !ok { + return buildParamErrCodeAndErr("prints") } else { - if printNo = dataMap[keyPrintNo].(string); printNo == "" { - return buildParamErrCodeAndErr(keyPrintNo) + if printersStr = dataMap["prints"].(string); printersStr == "" { + return buildParamErrCodeAndErr("prints") } } - if _, ok := dataMap[keyPrintKey].(string); !ok { - return buildParamErrCodeAndErr(keyPrintKey) - } else { - if printKey = dataMap[keyPrintKey].(string); printKey == "" { - return buildParamErrCodeAndErr(keyPrintKey) - } - } - appID = utils.Str2Int(dataMap[keyAppID].(string)) - name = dataMap[keyName].(string) - if err = cms.AddPrinter(appID, printNo, printKey, name); err != nil { - return "", model.ErrCodeGeneralFailed, err + if err = utils.UnmarshalUseNumber([]byte(printersStr), &printers); err != nil { + return buildParamErrCodeAndErr("prints") } + //appID = utils.Str2Int(dataMap[keyAppID].(string)) + //if err = cms.AddPrinter(appID, printers); err != nil { + // return "", model.ErrCodeGeneralFailed, err + //} return "", errCode, err }