get_mk_ids_logic.go 975 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package logic
  2. import (
  3. "context"
  4. "fmt"
  5. "git.i2edu.net/i2/i2-bill-erp/internal/svc"
  6. "git.i2edu.net/i2/i2-bill-erp/model"
  7. "git.i2edu.net/i2/i2-bill-erp/transform"
  8. "git.i2edu.net/i2/go-zero/core/logx"
  9. )
  10. type GetMkIdsLogic struct {
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. logx.Logger
  14. }
  15. func NewGetMkIdsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMkIdsLogic {
  16. return &GetMkIdsLogic{
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. Logger: logx.WithContext(ctx),
  20. }
  21. }
  22. func (l *GetMkIdsLogic) GetMkIds(in *transform.CityMkReq) (*transform.CityMkRes, error) {
  23. var users []model.SysUser
  24. err := l.svcCtx.SqlConn.QueryRowsPartial(&users, fmt.Sprintf("select id, mobile from sys_user where mobile in (%v) and del_flag!=1", in.Phones))
  25. if err != nil {
  26. return nil, err
  27. }
  28. tc := transform.CityMkRes{}
  29. for i := range users {
  30. if tc.MapList == nil {
  31. tc.MapList = map[string]string{}
  32. }
  33. tc.MapList[users[i].Mobile] = users[i].Id
  34. }
  35. return &tc, nil
  36. }