aa
This commit is contained in:
@@ -119,7 +119,7 @@ func DelPrinter(appID int, printNos []string) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdatePrinter(appID int, printNo, name, sim, sound string, volume int) (err error) {
|
func UpdatePrinter(appID int, printNo string, name, sim, sound *string, volume *int) (err error) {
|
||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
fields []string
|
fields []string
|
||||||
@@ -128,20 +128,20 @@ func UpdatePrinter(appID int, printNo, name, sim, sound string, volume int) (err
|
|||||||
if printers, _ := dao.GetPrinters(db, appID, printNo); len(printers) == 0 {
|
if printers, _ := dao.GetPrinters(db, appID, printNo); len(printers) == 0 {
|
||||||
return fmt.Errorf("该应用下未找到该打印机!print_no : %v", printNo)
|
return fmt.Errorf("该应用下未找到该打印机!print_no : %v", printNo)
|
||||||
} else {
|
} else {
|
||||||
if printers[0].Name != name {
|
if printers[0].Name != *name {
|
||||||
printers[0].Name = name
|
printers[0].Name = *name
|
||||||
fields = append(fields, "name")
|
fields = append(fields, "name")
|
||||||
}
|
}
|
||||||
if printers[0].SIM != sim {
|
if printers[0].SIM != *sim {
|
||||||
printers[0].SIM = sim
|
printers[0].SIM = *sim
|
||||||
fields = append(fields, "sim")
|
fields = append(fields, "sim")
|
||||||
}
|
}
|
||||||
if printers[0].Sound != sound {
|
if printers[0].Sound != *sound {
|
||||||
printers[0].Sound = sound
|
printers[0].Sound = *sound
|
||||||
fields = append(fields, "sound")
|
fields = append(fields, "sound")
|
||||||
}
|
}
|
||||||
if printers[0].Volume != volume {
|
if printers[0].Volume != *volume {
|
||||||
printers[0].Volume = volume
|
printers[0].Volume = *volume
|
||||||
fields = append(fields, "volume")
|
fields = append(fields, "volume")
|
||||||
}
|
}
|
||||||
if _, err = dao.UpdateEntity(db, printers[0], fields...); err != nil {
|
if _, err = dao.UpdateEntity(db, printers[0], fields...); err != nil {
|
||||||
|
|||||||
@@ -247,29 +247,38 @@ func (c *ApiController) DelPrinter(dataMap map[string]interface{}) (data, errCod
|
|||||||
//修改打印机信息
|
//修改打印机信息
|
||||||
func (c *ApiController) UpdatePrinter(dataMap map[string]interface{}) (data, errCode string, err error) {
|
func (c *ApiController) UpdatePrinter(dataMap map[string]interface{}) (data, errCode string, err error) {
|
||||||
var (
|
var (
|
||||||
printNo, name, sim, sound string
|
printNo string
|
||||||
appID, volume int
|
name, sim, sound *string
|
||||||
ok bool
|
volume *int
|
||||||
|
appID int
|
||||||
)
|
)
|
||||||
globals.SugarLogger.Debugf("Begin API UpdatePrinter data: [%v]", utils.Format4Output(dataMap, false))
|
globals.SugarLogger.Debugf("Begin API UpdatePrinter data: [%v]", utils.Format4Output(dataMap, false))
|
||||||
if _, ok = dataMap[keyPrintNo].(string); !ok {
|
if _, ok := dataMap[keyPrintNo].(string); !ok {
|
||||||
return buildParamErrCodeAndErr(keyPrintNo)
|
return buildParamErrCodeAndErr(keyPrintNo)
|
||||||
} else {
|
} else {
|
||||||
if printNo = dataMap[keyPrintNo].(string); printNo == "" {
|
if printNo = dataMap[keyPrintNo].(string); printNo == "" {
|
||||||
return buildParamErrCodeAndErr(keyPrintNo)
|
return buildParamErrCodeAndErr(keyPrintNo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if name, ok = dataMap[keyName].(string); !ok {
|
if nameStr, ok := dataMap[keyName].(string); !ok {
|
||||||
name = ""
|
name = nil
|
||||||
|
} else {
|
||||||
|
name = &nameStr
|
||||||
}
|
}
|
||||||
if sim, ok = dataMap["sim"].(string); !ok {
|
if simStr, ok := dataMap["sim"].(string); !ok {
|
||||||
sim = ""
|
sim = nil
|
||||||
|
} else {
|
||||||
|
sim = &simStr
|
||||||
}
|
}
|
||||||
if sound, ok = dataMap["sound"].(string); !ok {
|
if soundStr, ok := dataMap["sound"].(string); !ok {
|
||||||
sound = ""
|
sound = nil
|
||||||
|
} else {
|
||||||
|
sound = &soundStr
|
||||||
}
|
}
|
||||||
if volume, ok = dataMap["volume"].(int); !ok {
|
if volumeInt, ok := dataMap["volume"].(int); !ok {
|
||||||
volume = 0
|
volume = nil
|
||||||
|
} else {
|
||||||
|
volume = &volumeInt
|
||||||
}
|
}
|
||||||
appID = utils.Str2Int(dataMap[keyAppID].(string))
|
appID = utils.Str2Int(dataMap[keyAppID].(string))
|
||||||
if err = cms.UpdatePrinter(appID, printNo, name, sim, sound, volume); err != nil {
|
if err = cms.UpdatePrinter(appID, printNo, name, sim, sound, volume); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user