123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- package data
- import (
- "context"
- "sikey/w303a/http/internal/biz"
- "sikey/w303a/http/internal/data/ent/child"
- )
- var _ biz.ChildRepo = (*childRepo)(nil)
- type childRepo struct {
- data *Data
- }
- func (repo *childRepo) FindByPhoneNumber(ctx context.Context, phoneNumber *biz.PhoneNumber) (*biz.Child, error) {
- mod, err := repo.data.db.Child.Query().
- Where(child.PhoneNumber(phoneNumber.Phone), child.AreaCode(phoneNumber.AreaCode)).
- WithChildRefs().
- Only(ctx)
- if err != nil {
- return nil, err
- }
- var refs []*biz.ChildRef
- for _, refMod := range mod.Edges.ChildRefs {
- refs = append(refs, &biz.ChildRef{
- UserID: refMod.UserID.String(),
- ChildID: refMod.ChildID.String(),
- })
- }
- return &biz.Child{
- ID: mod.ID.String(),
- Name: mod.ChildName,
- Avatar: mod.Avatar,
- Height: mod.Height,
- Weight: mod.Weight,
- Birthday: mod.Birthday,
- Gender: mod.Gender,
- PhoneNumber: biz.NewPhoneNumber(mod.PhoneNumber, mod.AreaCode),
- Refs: refs,
- }, nil
- }
- func (repo *childRepo) FindByChildID(ctx context.Context, cid string) (*biz.Child, error) {
- //TODO implement me
- panic("implement me")
- }
- func (repo *childRepo) FindByUserID(ctx context.Context, uid string) ([]*biz.Child, error) {
- //TODO implement me
- panic("implement me")
- }
- func (repo *childRepo) Create(ctx context.Context, child *biz.Child) error {
- //TODO implement me
- panic("implement me")
- }
- func (repo *childRepo) Update(ctx context.Context, child *biz.Child) error {
- //TODO implement me
- panic("implement me")
- }
- func (repo *childRepo) Delete(ctx context.Context, cid string) error {
- //TODO implement me
- panic("implement me")
- }
- func NewChildRepo(data *Data) biz.ChildRepo {
- return &childRepo{data: data}
- }
|