get_erp_active_logic.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package logic
  2. import (
  3. "context"
  4. "git.i2edu.net/i2/i2-bill-erp/utils"
  5. "git.i2edu.net/i2/i2-bill-erp/internal/svc"
  6. "git.i2edu.net/i2/i2-bill-erp/transform"
  7. "git.i2edu.net/i2/go-zero/core/logx"
  8. )
  9. type GetErpActiveLogic struct {
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. logx.Logger
  13. }
  14. func NewGetErpActiveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetErpActiveLogic {
  15. return &GetErpActiveLogic{
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. Logger: logx.WithContext(ctx),
  19. }
  20. }
  21. func (l *GetErpActiveLogic) GetErpActive(in *transform.GetErpActiveReq) (*transform.GetErpActiveRes, error) {
  22. // todo: add your logic here and delete this line
  23. type Active struct {
  24. MaName string `json:"ma_name"`
  25. ActiveId int64 `json:"active_id"`
  26. }
  27. //acts := new([]*Active)
  28. actives := new([]*transform.Active)
  29. var parmas = make(map[string]interface{})
  30. parmas["school_id"] = in.SchId
  31. //sql := `
  32. // select
  33. // act.id active_id,act.ma_name
  34. // from
  35. // mkt_activity act
  36. // left join
  37. // mkt_activities_school act_sch
  38. // on
  39. // act.id = act_sch.ma_id
  40. // where
  41. // act.del_flag = 0
  42. // and act_sch.school_id = ? `
  43. result, err := utils.AllSearch(l.svcCtx.DB, "mkt_activity", "all", "mkt_activity", parmas)
  44. //err := l.svcCtx.DB.SQL(sql, in.SchId).Find(acts)
  45. if err != nil {
  46. logx.Error(err.Error())
  47. return nil, err
  48. }
  49. for _, act := range result {
  50. active := new(transform.Active)
  51. active.MaName = act["ma_name"].(string)
  52. active.ActiveId = act["active_id"].(int64)
  53. *actives = append(*actives, active)
  54. }
  55. return &transform.GetErpActiveRes{Active: *actives}, nil
  56. }