44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package accountlogic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"code.30cm.net/digimon/app-cloudep-member-server/pkg/domain/member"
|
|
"code.30cm.net/digimon/app-cloudep-member-server/pkg/domain/usecase"
|
|
"code.30cm.net/digimon/library-go/errs"
|
|
|
|
pb "code.30cm.net/digimon/app-cloudep-member-server/gen_result/pb/member"
|
|
"code.30cm.net/digimon/app-cloudep-member-server/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type UpdateStatusLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewUpdateStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateStatusLogic {
|
|
return &UpdateStatusLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
// UpdateStatus 修改狀態
|
|
func (l *UpdateStatusLogic) UpdateStatus(in *pb.UpdateStatusReq) (*pb.OKResp, error) {
|
|
if in.Status == pb.MemberStatus_STATUS_NONE {
|
|
return nil, errs.InvalidFormat("failed to get correct status")
|
|
}
|
|
|
|
s := member.Status(in.GetStatus().Number())
|
|
err := l.svcCtx.AccountUseCase.UpdateStatus(l.ctx, usecase.UpdateStatusRequest{Status: s, UID: in.GetUid()})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &pb.OKResp{}, nil
|
|
}
|