| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package logic
- import (
- "context"
- "git.i2edu.net/i2/i2-bill-erp/internal/svc"
- "git.i2edu.net/i2/i2-bill-erp/transform"
- "git.i2edu.net/i2/go-zero/core/logx"
- )
- type GetErpActiveLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewGetErpActiveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetErpActiveLogic {
- return &GetErpActiveLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- func (l *GetErpActiveLogic) GetErpActive(in *transform.GetErpActiveReq) (*transform.GetErpActiveRes, error) {
- // todo: add your logic here and delete this line
- type Active struct {
- MaName string `json:"ma_name"`
- ActiveId int64 `json:"active_id"`
- }
- acts := new([]*Active)
- actives := new([]*transform.Active)
- sql := `
- select
- act.id active_id,act.ma_name
- from
- mkt_activity act
- left join
- mkt_activities_school act_sch
- on
- act.id = act_sch.ma_id
- where
- act.del_flag = 0
- and act_sch.school_id = ? `
- err := l.svcCtx.DB.SQL(sql, in.SchId).Find(acts)
- if err != nil {
- logx.Error(err.Error())
- return nil, err
- }
- for _, act := range *acts {
- active := new(transform.Active)
- active.MaName = act.MaName
- active.ActiveId = act.ActiveId
- *actives = append(*actives, active)
- }
- return &transform.GetErpActiveRes{Active: *actives}, nil
- }
|