account.go 720 B

1234567891011121314151617181920212223242526272829303132333435
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "net/url"
  6. "strconv"
  7. "go-common/library/log"
  8. "github.com/pkg/errors"
  9. )
  10. const (
  11. _wasFormal = -659
  12. )
  13. // BeFormal become a full member
  14. func (d *Dao) BeFormal(c context.Context, mid int64, ip string) (err error) {
  15. params := url.Values{}
  16. params.Set("mid", strconv.FormatInt(mid, 10))
  17. var res struct {
  18. Code int `json:"code"`
  19. }
  20. if err = d.xclient.Post(c, d.beFormal, ip, params, &res); err != nil {
  21. err = errors.Wrapf(err, "beFormal url(%s)", d.beFormal+"?"+params.Encode())
  22. return
  23. }
  24. if res.Code != 0 && res.Code != _wasFormal {
  25. err = errors.WithStack(fmt.Errorf("beFormal(%d) failed(%v)", mid, res.Code))
  26. return
  27. }
  28. log.Info("beFormal suc(%d) ", mid)
  29. return
  30. }