parttimeusergetlogic.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package part_time_user
  2. import (
  3. "context"
  4. "git.i2edu.net/i2/go-zero/core/stores/sqlx"
  5. "git.i2edu.net/i2/i2-bill-api/model"
  6. "git.i2edu.net/i2/i2-bill-api/internal/svc"
  7. "git.i2edu.net/i2/i2-bill-api/internal/types"
  8. "git.i2edu.net/i2/go-zero/core/logx"
  9. )
  10. type PartTimeUserGetLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewPartTimeUserGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) PartTimeUserGetLogic {
  16. return PartTimeUserGetLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *PartTimeUserGetLogic) PartTimeUserGet() (*types.Response, error) {
  23. // todo: add your logic here and delete this line
  24. userId := l.svcCtx.GetUserIdByJwt(l.ctx)
  25. partTimeUser := new(model.I2billMktPartTimeUser)
  26. err := l.svcCtx.SqlConn.QueryRow(partTimeUser, "select * from i2bill_mkt_part_time_user where user_id = ? and del_flag = 0", userId)
  27. if err == sqlx.ErrNotFound {
  28. return &types.Response{Code: 500, Msg: "你还没有申请成为兼职人员!", Data: nil}, nil
  29. }
  30. if err != nil {
  31. return &types.Response{Code: 500, Msg: err.Error(), Data: nil}, nil
  32. }
  33. return &types.Response{Code: 200, Msg: "", Data: partTimeUser}, nil
  34. }