platform.go
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package controllers
import (
"encoding/json"
"fmt"
"oppmg/common/log"
"oppmg/protocol"
"oppmg/services/platform"
)
type PlatformController struct {
BaseController
}
//
func (c PlatformController) UpdateData() {
defer func() {
c.Data["json"] = map[string]interface{}{
"code": 0,
"msg": "ok",
}
c.ServeJSON()
}()
var param platform.CommonProtocol
if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil {
log.Error("json 解析失败 err:%s", err)
return
}
m, err := platform.NewPlatformAction(param.Module)
if err != nil {
log.Error("同步数据发生错误,err%s", err)
return
}
bt, err := json.Marshal(param.Data)
if err != nil {
log.Error("解析param.data数据失败")
}
err = m.DoAction(param.Action, bt)
if err != nil {
log.Error("同步数据发生错误,module=%s,action=%s,err:%s", param.Module, param.Action, err)
}
return
}
func (c PlatformController) CompanyAdminChance() {
type Parameter struct {
CompanyId int64 `json:"company_id"`
Phone string `json:"phone"`
}
var msg = protocol.ErrWithMessage{}
var param Parameter
if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil {
e := fmt.Errorf("json 解析失败 err:%s", err)
log.Error(e.Error())
msg.Errno = "0"
msg.Errmsg = e.Error()
return
}
err := platform.AdminChance(param.CompanyId, param.Phone)
if err != nil {
log.Error("总后台调用CompanyAdminChance发生错误;%s", err)
msg.Errno = "-1"
msg.Errmsg = err.Error()
}
msg.Errno = "0"
c.Data["json"] = msg
c.ServeJSON()
return
}