作者 tangxuhui

更改同步数据时响应返回

... ... @@ -14,16 +14,20 @@ type PlatformController struct {
//
func (c PlatformController) UpdateData() {
var respMsg = map[string]interface{}{
"code": 0,
"msg": "ok",
}
defer func() {
c.Data["json"] = map[string]interface{}{
"code": 0,
"msg": "ok",
}
c.Data["json"] = respMsg
c.ServeJSON()
}()
var param platform.CommonProtocol
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &param); err != nil {
log.Error("json 解析失败 err:%s", err)
respMsg["code"] = -1
respMsg["msg"] = "json 解析失败 err:" + err.Error()
return
}
m, err := platform.NewPlatformAction(param.Module)
... ... @@ -34,12 +38,17 @@ func (c PlatformController) UpdateData() {
bt, err := json.Marshal(param.Data)
if err != nil {
log.Error("解析param.data数据失败")
respMsg["code"] = -1
respMsg["msg"] = "json 解析失败 err:" + err.Error()
return
}
err = m.DoAction(param.Action, bt)
if err != nil {
log.Error("同步数据发生错误,module=%s,action=%s,err:%s", param.Module, param.Action, err)
respMsg["code"] = -1
respMsg["msg"] = fmt.Sprintf("同步数据发生错误,module=%s,action=%s,err:%s", param.Module, param.Action, err)
return
}
return
}
func (c PlatformController) CompanyAdminChance() {
... ...
... ... @@ -159,7 +159,7 @@ func (m ModuleEmployee) DoAction(code string, jsondata []byte) error {
}
AddEmployeeData(data.Add)
for i := range data.Edit {
UpdateEmployeeData(data.Edit[i])
_ = UpdateEmployeeData(data.Edit[i])
}
return nil
case "changePhoneAllCompany":
... ... @@ -172,8 +172,7 @@ func (m ModuleEmployee) DoAction(code string, jsondata []byte) error {
if err != nil {
return fmt.Errorf("数据解析失败:%s", err)
}
_ = EmployeeChangePhone(data)
return nil
return EmployeeChangePhone(data)
default:
return errors.New("action not found")
}
... ...