mirror of
https://gitea.tendokyu.moe/Kayori/MedusaPluginChargeMachine.git
synced 2026-10-08 15:07:59 +03:00
53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
using Abstractions.Handlers;
|
|
using Abstractions.SerializationTypes;
|
|
using MedusaPluginChargeMachine.Models.Request;
|
|
using MedusaPluginChargeMachine.Models.Response;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace MedusaPluginChargeMachine.Handlers.LA9;
|
|
|
|
public class GetConfigEaChargeHandler(ChargeMachineDbContext db) : Handler<EmptyRequest, EaChargeConfigResponse>
|
|
{
|
|
public override void Configure()
|
|
{
|
|
Module("eacharge");
|
|
Method("getconf");
|
|
}
|
|
|
|
public override async Task<EaChargeConfigResponse> HandleAsync(EmptyRequest _, string model)
|
|
{
|
|
var articles = await db.ArticleContents.ToListAsync();
|
|
|
|
var articleList = articles
|
|
.Select(a => new EaChargeConfigChargeArticleItem
|
|
{
|
|
ArticleType = new XrpcString(a.ArticleType.ToString()),
|
|
ArticleDoc = new XrpcString(a.ArticleDoc)
|
|
})
|
|
.ToList();
|
|
|
|
return new EaChargeConfigResponse
|
|
{
|
|
Status = 0,
|
|
Expire = 1200,
|
|
MultiBills = new XrpcInt(1),
|
|
ReadAgreement = new XrpcInt(0),
|
|
ChargeArticle = new EaChargeConfigChargeArticle
|
|
{
|
|
ArticleRevision = new XrpcString("1"),
|
|
ArticleList = articleList
|
|
},
|
|
ChargeDetail = new EaChargeConfigChargeDetail
|
|
{
|
|
ChargeDaily = new XrpcInt(0),
|
|
ChargeDailyLimit = new XrpcInt(100000)
|
|
},
|
|
ChargeStatus = new EaChargeConfigChargeStatus
|
|
{
|
|
CurrentCode = new XrpcInt(0),
|
|
LastChargeStatus = new XrpcInt(1)
|
|
}
|
|
};
|
|
}
|
|
}
|