enableAppInfoLogic.go 867 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package logic
  2. import (
  3. "context"
  4. "GtDataStore/app/cmd/organization/internal/svc"
  5. "GtDataStore/app/cmd/organization/pb"
  6. "github.com/zeromicro/go-zero/core/logx"
  7. )
  8. type EnableAppInfoLogic struct {
  9. ctx context.Context
  10. svcCtx *svc.ServiceContext
  11. logx.Logger
  12. }
  13. func NewEnableAppInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EnableAppInfoLogic {
  14. return &EnableAppInfoLogic{
  15. ctx: ctx,
  16. svcCtx: svcCtx,
  17. Logger: logx.WithContext(ctx),
  18. }
  19. }
  20. func (l *EnableAppInfoLogic) EnableAppInfo(in *pb.EnableAppInfoReq) (*pb.EnableAppInfoResp, error) {
  21. appInfo, err := l.svcCtx.AppInfo.FindOneByAppName(l.ctx, in.AppName)
  22. if err != nil {
  23. return nil, err
  24. }
  25. if appInfo.Status != 0 {
  26. appInfo.Status = 0
  27. err = l.svcCtx.AppInfo.Update(l.ctx, appInfo)
  28. if err != nil {
  29. return nil, err
  30. }
  31. }
  32. return &pb.EnableAppInfoResp{Ok: true}, nil
  33. }