12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package data_api
- import (
- "context"
- "gd_management/apis"
- "gd_management/errors"
- "encoding/json"
- "fmt"
- "gd_management/common.in/jsonrpc2"
- "gd_management/common.in/utils"
- "github.com/astaxie/beego/orm"
- "go.uber.org/zap"
- )
- func DataApiGetDataCombo(ctx context.Context, req *apis.ManagementDataApiGetDataComboReq, reply *apis.ManagementDataApiGetDataComboReply) (err error) {
- // 捕获各个task中的异常并返回给调用者
- defer func() {
- if r := recover(); r != nil {
- err = fmt.Errorf("%+v", r)
- e := &jsonrpc2.Error{}
- if er := json.Unmarshal([]byte(err.Error()), e); er != nil {
- l.Error("err",
- zap.String("system_err", err.Error()),
- zap.Stack("stacktrace"))
- }
- }
- }()
- if req.ComboId <= 0 {
- l.Error("argument",
- zap.String("call", "check"),
- zap.String("fields", utils.MarshalJsonString(req)))
- return errors.ArgsError
- }
- sql := "SELECT a.`count`, a.price, a.type, a.total_day, b.query_type_name FROM t_gd_data_api_combo a LEFT JOIN t_gd_data_api_query_type b ON a.query_type_id = b.id WHERE a.id = ?"
- err = orm.NewOrm().Raw(sql, req.ComboId).QueryRow(&reply)
- if err != nil {
- if err == orm.ErrNoRows {
- return errors.ComboNotExist
- }
- l.Error("mysql",
- zap.String("sql", sql),
- zap.String("fields", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.DataBaseError
- }
- return nil
- }
|