get_city_ids_logic.go 988 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 GetCityIdsLogic struct {
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. logx.Logger
  14. }
  15. func NewGetCityIdsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCityIdsLogic {
  16. return &GetCityIdsLogic{
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. Logger: logx.WithContext(ctx),
  20. }
  21. }
  22. func (l *GetCityIdsLogic) GetCityIds(in *transform.CityIdsReq) (*transform.CityIdsRes, error) {
  23. var city []model.BaseOrgan
  24. err := l.svcCtx.SqlConn.QueryRowsPartial(&city, fmt.Sprintf("select id, name from base_organ where name in (%v) and del_flag!=1", in.Names))
  25. if err != nil {
  26. return nil, err
  27. }
  28. tc := transform.CityIdsRes{}
  29. for i := range city {
  30. if tc.MapList == nil {
  31. tc.MapList = map[string]int64{}
  32. }
  33. tc.MapList[city[i].Name.String] = city[i].Id
  34. }
  35. return &tc, nil
  36. }