作者 tangxuhui

更改同步数据时响应返回

@@ -14,16 +14,20 @@ type PlatformController struct { @@ -14,16 +14,20 @@ type PlatformController struct {
14 14
15 // 15 //
16 func (c PlatformController) UpdateData() { 16 func (c PlatformController) UpdateData() {
17 - defer func() {  
18 - c.Data["json"] = map[string]interface{}{ 17 + var respMsg = map[string]interface{}{
19 "code": 0, 18 "code": 0,
20 "msg": "ok", 19 "msg": "ok",
21 } 20 }
  21 + defer func() {
  22 + c.Data["json"] = respMsg
22 c.ServeJSON() 23 c.ServeJSON()
23 }() 24 }()
  25 +
24 var param platform.CommonProtocol 26 var param platform.CommonProtocol
25 if err := json.Unmarshal(c.Ctx.Input.RequestBody, &param); err != nil { 27 if err := json.Unmarshal(c.Ctx.Input.RequestBody, &param); err != nil {
26 log.Error("json 解析失败 err:%s", err) 28 log.Error("json 解析失败 err:%s", err)
  29 + respMsg["code"] = -1
  30 + respMsg["msg"] = "json 解析失败 err:" + err.Error()
27 return 31 return
28 } 32 }
29 m, err := platform.NewPlatformAction(param.Module) 33 m, err := platform.NewPlatformAction(param.Module)
@@ -34,12 +38,17 @@ func (c PlatformController) UpdateData() { @@ -34,12 +38,17 @@ func (c PlatformController) UpdateData() {
34 bt, err := json.Marshal(param.Data) 38 bt, err := json.Marshal(param.Data)
35 if err != nil { 39 if err != nil {
36 log.Error("解析param.data数据失败") 40 log.Error("解析param.data数据失败")
  41 + respMsg["code"] = -1
  42 + respMsg["msg"] = "json 解析失败 err:" + err.Error()
  43 + return
37 } 44 }
38 err = m.DoAction(param.Action, bt) 45 err = m.DoAction(param.Action, bt)
39 if err != nil { 46 if err != nil {
40 log.Error("同步数据发生错误,module=%s,action=%s,err:%s", param.Module, param.Action, err) 47 log.Error("同步数据发生错误,module=%s,action=%s,err:%s", param.Module, param.Action, err)
41 - } 48 + respMsg["code"] = -1
  49 + respMsg["msg"] = fmt.Sprintf("同步数据发生错误,module=%s,action=%s,err:%s", param.Module, param.Action, err)
42 return 50 return
  51 + }
43 } 52 }
44 53
45 func (c PlatformController) CompanyAdminChance() { 54 func (c PlatformController) CompanyAdminChance() {
@@ -159,7 +159,7 @@ func (m ModuleEmployee) DoAction(code string, jsondata []byte) error { @@ -159,7 +159,7 @@ func (m ModuleEmployee) DoAction(code string, jsondata []byte) error {
159 } 159 }
160 AddEmployeeData(data.Add) 160 AddEmployeeData(data.Add)
161 for i := range data.Edit { 161 for i := range data.Edit {
162 - UpdateEmployeeData(data.Edit[i]) 162 + _ = UpdateEmployeeData(data.Edit[i])
163 } 163 }
164 return nil 164 return nil
165 case "changePhoneAllCompany": 165 case "changePhoneAllCompany":
@@ -172,8 +172,7 @@ func (m ModuleEmployee) DoAction(code string, jsondata []byte) error { @@ -172,8 +172,7 @@ func (m ModuleEmployee) DoAction(code string, jsondata []byte) error {
172 if err != nil { 172 if err != nil {
173 return fmt.Errorf("数据解析失败:%s", err) 173 return fmt.Errorf("数据解析失败:%s", err)
174 } 174 }
175 - _ = EmployeeChangePhone(data)  
176 - return nil 175 + return EmployeeChangePhone(data)
177 default: 176 default:
178 return errors.New("action not found") 177 return errors.New("action not found")
179 } 178 }