Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrate redeem code system #2354

Merged
merged 2 commits into from
Jan 7, 2025
Merged

integrate redeem code system #2354

merged 2 commits into from
Jan 7, 2025

Conversation

qhy040404
Copy link
Member

Description

Related Issue

Checklist

  • The target PR branch is develop branch

@Copilot Copilot bot review requested due to automatic review settings January 6, 2025 16:27
@dgp-bot
Copy link

dgp-bot bot commented Jan 6, 2025

Integrate Redeem Code System

This pull request introduces a redeem code system to the Hutao application, allowing users to redeem codes for various services. The changes span multiple areas, including UI, backend services, and data models.

Changes by feature
  • Hutao Passport Page

    • Added a "Use Redeem Code" button to the Hutao Passport page, replacing the previous "Open Redeem Website" button. This button opens a dialog for entering redeem codes.
  • Redeem Code Dialog

    • Introduced a new HutaoPassportUseRedeemCodeDialog for inputting redeem codes.
    • This dialog includes a TextBox for entering the redeem code and utilizes localization for its title, button text, and placeholder text.
  • Redeem Code Service Integration

    • Added UseRedeemCodeAsync to HutaoUserOptions to handle the redeem code process.
    • This method sends the redeem code to the server using HutaoRedeemCodeClient and displays the result in an InfoBar.
  • Redeem Code Web API

    • Created new API endpoints and clients for redeem code functionality:
      • IHomaRedeemCodeEndpoints defines the /Redeem/Use endpoint.
      • HutaoRedeemCodeClient handles the API calls to the redeem endpoint.
      • RedeemUseRequest and RedeemUseResponse defines the request and response models for redeeming code.
    • Implemented HutaoAsAServiceClient to handle /Service/Redeem/Generate endpoint to generate redeem code.
      • RedeemGenerateRequest and RedeemGenerateResponse defines the request and response models for generating redeem code.
    • Added RedeemCodeTargetServiceType, RedeemCodeType and RedeemStatus enums to represent the related data structure.
  • Test Page Enhancement

    • Added a new Expander control on the test page, named "Generate Redeem Code".
      • This UI allows for testing the generation of redeem codes with various options, including count, type (time-limited, times-limited), service type, value, description, expire hours and times.
      • Added a command GenerateRedeemCodeCommand to test redeem code generation function.
  • ViewModel Updates

    • HutaoPassportViewModel:
      • The OpenRedeemWebsiteCommand was removed and replaced with UseRedeemCodeCommand which handles showing the redeem code dialog and processing input.
    • TestViewModel:
      • Implemented the GenerateRedeemCodeCommand logic to call the service to generate redeem codes and display the result.
      • Added related properties like RedeemCodeGenerateOption and helper class RedeemCodeGenerateOptions to bind and maintain the state.

Key Change Highlights

  • New Redeem Code System: The most significant change is the addition of the redeem code system. This allows for distributing in-app rewards via redeem codes.
  • API Endpoint Introduction: New API endpoints (/Redeem/Use and /Service/Redeem/Generate) have been introduced. This adds server-side functionality to manage redeem code usage and generation.
  • Data Structure Changes: New data structures (RedeemUseRequest, RedeemUseResponse, RedeemGenerateRequest, RedeemGenerateResponse, RedeemCodeTargetServiceType, RedeemCodeType, RedeemStatus) were introduced to align with the new redeem code feature.

This is a key feature that expands the functionality of the application, which should be thoroughly tested.

@qhy040404 qhy040404 requested a review from Lightczx January 6, 2025 16:28
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 8 out of 22 changed files in this pull request and generated 1 comment.

Files not reviewed (14)
  • src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx: Language not supported
  • src/Snap.Hutao/Snap.Hutao/UI/Xaml/View/Dialog/HutaoPassportUseRedeemCodeDialog.xaml: Language not supported
  • src/Snap.Hutao/Snap.Hutao/UI/Xaml/View/Page/HutaoPassportPage.xaml: Language not supported
  • src/Snap.Hutao/Snap.Hutao/UI/Xaml/View/Page/TestPage.xaml: Language not supported
  • src/Snap.Hutao/Snap.Hutao/Web/Hutao/Redeem/RedeemCodeType.cs: Evaluated as low risk
  • src/Snap.Hutao/Snap.Hutao/Web/Hutao/Redeem/RedeemGenerateResponse.cs: Evaluated as low risk
  • src/Snap.Hutao/Snap.Hutao/Web/Endpoint/Hutao/IHomaEndpoints.cs: Evaluated as low risk
  • src/Snap.Hutao/Snap.Hutao/Core/Setting/LocalSetting.cs: Evaluated as low risk
  • src/Snap.Hutao/Snap.Hutao/Web/Hutao/HutaoAsAService/HutaoAsAServiceClient.cs: Evaluated as low risk
  • src/Snap.Hutao/Snap.Hutao/Web/Endpoint/Hutao/IHomaServiceEndpoints.cs: Evaluated as low risk
  • src/Snap.Hutao/Snap.Hutao/ViewModel/HutaoPassport/HutaoPassportViewModel.cs: Evaluated as low risk
  • src/Snap.Hutao/Snap.Hutao/Service/Hutao/HutaoUserOptions.cs: Evaluated as low risk
  • src/Snap.Hutao/Snap.Hutao/ViewModel/TestViewModel.cs: Evaluated as low risk
  • src/Snap.Hutao/Snap.Hutao/Web/Hutao/Redeem/RedeemCodeTargetServiceType.cs: Evaluated as low risk


public int Value { get; set; }

public string Description { get; set; } = default!;
Copy link
Preview

Copilot AI Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Description property is initialized with default!, which could lead to issues if not handled properly. Consider initializing it with an empty string or a meaningful default value.

Suggested change
public string Description { get; set; } = default!;
public string Description { get; set; } = string.Empty;

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@Lightczx Lightczx merged commit 195643d into develop Jan 7, 2025
3 checks passed
@Lightczx Lightczx deleted the feat/redeem_code branch January 10, 2025 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants