platform.go
1.3 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
package controllers
import (
"encoding/json"
"fmt"
"oppmg/common/log"
"oppmg/protocol"
"oppmg/services/platform"
)
type PlatformController struct {
BaseController
}
//
func (c PlatformController) UpdateData() {
var msg *protocol.ResponseMessage
defer func() {
c.ResposeJson(msg)
}()
var param platform.CommonProtocol
if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil {
log.Error("json 解析失败 err:%s", err)
msg = protocol.BadRequestParam("1")
return
}
// m, err := platform.NewPlatformAction(param.Module)
// if err != nil {
// msg = protocol.NewReturnResponse(nil, err)
// return
// }
// err = m.DoAction(param.Action, []byte(param.Data))
msg = protocol.NewMessage("0")
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.Errmsg = e.Error()
return
}
err := platform.AdminChance(param.CompanyId, param.Phone)
if err != nil {
log.Error("总后台调用CompanyAdminChance发生错误;%s", err)
msg.Errmsg = err.Error()
}
c.Data["json"] = msg
c.ServeJSON()
return
}