Implement /api/mission/clear
This commit is contained in:
parent
15df55dd34
commit
2115bbb08b
@ -117,6 +117,9 @@ async fn live_clearrate(req: HttpRequest) -> HttpResponse { router::live::clearr
|
||||
#[get("/api/mission")]
|
||||
async fn mission(req: HttpRequest) -> HttpResponse { router::mission::mission(req) }
|
||||
|
||||
#[get("/api/mission/clear")]
|
||||
async fn mission_clear(req: HttpRequest, body: String) -> HttpResponse { router::mission::clear(req, body) }
|
||||
|
||||
#[get("/api/home")]
|
||||
async fn home(req: HttpRequest) -> HttpResponse { router::home::home(req) }
|
||||
|
||||
@ -213,6 +216,7 @@ async fn main() -> std::io::Result<()> {
|
||||
.service(lottery)
|
||||
.service(friend)
|
||||
.service(mission)
|
||||
.service(mission_clear)
|
||||
.service(home)
|
||||
.service(start_assethash)
|
||||
.service(user)
|
||||
|
@ -2,17 +2,50 @@ use json;
|
||||
use json::object;
|
||||
use crate::router::global;
|
||||
use actix_web::{HttpResponse, HttpRequest};
|
||||
//use crate::router::userdata;
|
||||
use crate::router::userdata;
|
||||
use crate::encryption;
|
||||
|
||||
pub fn mission(_req: HttpRequest) -> HttpResponse {
|
||||
//let key = global::get_login(req.headers());
|
||||
//let user = userdata::get_acc(&key);
|
||||
pub fn mission(req: HttpRequest) -> HttpResponse {
|
||||
let key = global::get_login(req.headers(), "");
|
||||
let missions = userdata::get_acc_missions(&key);
|
||||
|
||||
let resp = object!{
|
||||
"code": 0,
|
||||
"server_time": global::timestamp(),
|
||||
"data": {
|
||||
"mission_list": []
|
||||
"mission_list": missions
|
||||
}
|
||||
};
|
||||
global::send(resp)
|
||||
}
|
||||
|
||||
pub fn clear(req: HttpRequest, body: String) -> HttpResponse {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let mut missions = userdata::get_acc_missions(&key);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
||||
for (_i, id) in body["master_mission_ids"].members().enumerate() {
|
||||
for (i, mission) in missions.members().enumerate() {
|
||||
if mission["master_mission_id"].to_string() == id.to_string() {
|
||||
//I think this is all?
|
||||
missions[i]["progress"] = (1).into();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
userdata::save_acc_missions(&key, missions);
|
||||
|
||||
let resp = object!{
|
||||
"code": 0,
|
||||
"server_time": global::timestamp(),
|
||||
"data": {
|
||||
"clear_mission_ids": body["master_mission_ids"].clone()
|
||||
}
|
||||
};
|
||||
global::send(resp)
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
global::send(resp)
|
||||
|
@ -232,7 +232,6 @@ pub fn detail(_req: HttpRequest, body: String) -> HttpResponse {
|
||||
to_push["user"].remove("ss_user_id");
|
||||
to_push["user"].remove("birthday");
|
||||
user_detail_list.push(to_push).unwrap();
|
||||
|
||||
}
|
||||
let resp = object!{
|
||||
"code": 0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user