parttimeuserupdatelogic.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package logic
  2. import (
  3. "context"
  4. "git.i2edu.net/i2/go-zero/core/stores/sqlx"
  5. "git.i2edu.net/i2/i2-bill-api/internal/utils"
  6. "git.i2edu.net/i2/i2-bill-api/model"
  7. "time"
  8. "git.i2edu.net/i2/i2-bill-api/internal/svc"
  9. "git.i2edu.net/i2/i2-bill-api/internal/types"
  10. "git.i2edu.net/i2/go-zero/core/logx"
  11. )
  12. type PartTimeUserUpdateLogic struct {
  13. logx.Logger
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. }
  17. func NewPartTimeUserUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) PartTimeUserUpdateLogic {
  18. return PartTimeUserUpdateLogic{
  19. Logger: logx.WithContext(ctx),
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. }
  23. }
  24. func (l *PartTimeUserUpdateLogic) PartTimeUserUpdate(req types.PartTimeUserAddRequest) (*types.Response, error) {
  25. // todo: add your logic here and delete this line
  26. userId := utils.GetUserIdByJwt(l.ctx)
  27. var bean = new(model.I2billMktPartTimeUser)
  28. err := l.svcCtx.SqlConn.QueryRow(bean, "select * from i2bill_mkt_part_time_user where user_id = ? and del_flag = 0", userId)
  29. if err != nil && err != sqlx.ErrNotFound {
  30. return &types.Response{Code: 500, Msg: err.Error(), Data: nil}, nil
  31. }
  32. if bean.Id == 0 {
  33. return &types.Response{Code: 500, Msg: "你还没有申请成为兼职人员", Data: nil}, nil
  34. }
  35. if bean.Id != 0 {
  36. if bean.CheckState == 54 {
  37. return &types.Response{Code: 500, Msg: "你的申请兼职人员的个人信息已提交,请等待审核!", Data: nil}, nil
  38. }
  39. if bean.CheckState == 57 {
  40. return &types.Response{Code: 500, Msg: "你已经是兼职人员:", Data: nil}, nil
  41. }
  42. }
  43. bean.LastUpdateTime = time.Now()
  44. bean.CheckState = 54
  45. bean.CheckDesc = ""
  46. bean.CityId = req.CityId
  47. bean.Sex = req.Sex
  48. bean.Name = req.Name
  49. bean.LastUpdateBy = userId
  50. err = model.NewI2billMktPartTimeUserModel(l.svcCtx.SqlConn).Update(*bean)
  51. if err != nil {
  52. return &types.Response{Code: 500, Msg: err.Error(), Data: nil}, nil
  53. }
  54. return &types.Response{Code: 200, Msg: "", Data: nil}, nil
  55. }