123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package error_code
- import (
- "context"
- "gd_management/apis"
- "gd_management/common.in/utils"
- "gd_management/errors"
- "fmt"
- "github.com/astaxie/beego/orm"
- "go.uber.org/zap"
- )
- func addErrorCode(req *apis.ManagementAddErrorReq) (int64, error) {
- dbstruct := &apis.TGdErrorCode{
- Code: req.Code,
- Msg: req.Msg,
- }
- o := orm.NewOrm()
- id, err := o.Insert(dbstruct)
- if err != nil {
- fmt.Printf("database err:%v\n", err)
- return 0, errors.DataBaseError
- }
- return int64(id), nil
- }
- func ManagementAddError(ctx context.Context, req *apis.ManagementAddErrorReq, reply *apis.ManagementAddErrorReply) (err error) {
- id, err := addErrorCode(req)
- if err != nil {
- l.Error("func",
- zap.String("call", "ManagementAddError"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- }
- reply.Id = id
- l.Debug(utils.MarshalJsonString(req, reply))
- return
- }
|