Add (dummy) lottery endpoint

This commit is contained in:
Ethan O'Brien 2024-04-02 14:48:01 -05:00
parent 68be3978fe
commit a1d73690e6
3 changed files with 22 additions and 2 deletions

View file

@ -90,8 +90,11 @@ async fn preset(req: HttpRequest, body: String) -> HttpResponse { router::home::
#[post("/api/lottery/get_tutorial")]
async fn lottery_tutorial(req: HttpRequest, body: String) -> HttpResponse { router::lottery::tutorial(req, body) }
#[get("/api/lottery")]
async fn lottery(req: HttpRequest) -> HttpResponse { router::lottery::lottery(req) }
#[post("/api/lottery")]
async fn lottery(req: HttpRequest, body: String) -> HttpResponse { router::lottery::lottery(req, body) }
async fn lottery_post(req: HttpRequest, body: String) -> HttpResponse { router::lottery::lottery_post(req, body) }
#[post("/api/login_bonus")]
async fn login_bonus(req: HttpRequest, body: String) -> HttpResponse { router::login::bonus(req, body) }
@ -152,6 +155,7 @@ async fn main() -> std::io::Result<()> {
.service(start_start)
.service(tutorial)
.service(lottery_tutorial)
.service(lottery_post)
.service(lottery)
.service(friend)
.service(mission)

View file

@ -85,7 +85,21 @@ fn get_random_cards(_count: i32) -> JsonValue {
rv
}
pub fn lottery(req: HttpRequest, body: String) -> HttpResponse {
pub fn lottery(_req: HttpRequest) -> HttpResponse {
let resp = object!{
"code": 0,
"server_time": global::timestamp(),
"data": {
"lottery_list": [
{"master_lottery_id":1110024,"master_lottery_price_number":1,"count":10,"daily_count":0,"last_count_date":"2024-04-30 06:07:48"}
]
}
};
global::send(resp)
}
pub fn lottery_post(req: HttpRequest, body: String) -> HttpResponse {
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
println!("lottery: {}", body);
let key = global::get_login(req.headers());

View file

@ -225,6 +225,8 @@ pub fn initialize(req: HttpRequest, body: String) -> HttpResponse {
user["user"]["guest_cool_master_card_id"] = id.into();
user["user"]["guest_pure_master_card_id"] = id.into();
user2["home"]["preset_setting"][0]["illust_master_card_id"] = id.into();
user["gem"]["free"] = (3000).into();
user["gem"]["total"] = (3000).into();
let id = body["master_character_id"].to_string();
let userr = &id[id.len() - 2..].parse::<i32>().unwrap();