123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- 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 GetErpSchoolLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewGetErpSchoolLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetErpSchoolLogic {
- return &GetErpSchoolLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- func (l *GetErpSchoolLogic) GetErpSchool(in *transform.Empty) (*transform.GetErpSchoolRes, error) {
- // todo: add your logic here and delete this line
- type Sch struct {
- Name string `json:"name"`
- OrganId int64 `json:"organ_id"`
- Id int64 `json:"id"`
- }
- sch := new([]*Sch)
- schools := new([]*transform.OrganSchool)
- sql := `
- SELECT
- sch.name,sch.organ_id,sch.id
- FROM
- base_organ_school sch
- `
- err := l.svcCtx.DB.SQL(sql).Find(sch)
- if err != nil {
- logx.Error(err.Error())
- return nil, err
- }
- for _, s := range *sch {
- school := new(transform.OrganSchool)
- school.Id = s.Id
- school.Name = s.Name
- school.OrganId = s.OrganId
- *schools = append(*schools, school)
- }
- return &transform.GetErpSchoolRes{School: *schools}, nil
- }
|