platform.go 1.3 KB
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, &param); 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, &param); 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
}