daster/source/requests/sms.d

40 lines
1.0 KiB
D
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module requests.sms;
import vibe.vibe;
import response;
import structures;
import sql;
import singlog;
// Получить список всех групп SMS
void getListSMSGroups(HTTPServerRequest req, HTTPServerResponse res) {
auto numbers = sqlGetSMSNumbers();
render!("list_sms_groups.dt", numbers)(res);
}
// Получить список SMS конкретной группы
void getListGroupSMS(HTTPServerRequest req, HTTPServerResponse res) {
auto jsr = req.json;
res.writeJsonBody(sqlGetListSMS(jsr["to"].get!string).serializeToJson());
}
// Просмотр SMS
void getViewSMS(HTTPServerRequest req, HTTPServerResponse res) {
auto jsr = req.json;
auto dataSMS = sqlGetSMS(jsr["id"].to!int);
render!("sms.dt", dataSMS)(res);
}
// Удалить SMS
void sendDelSMS(HTTPServerRequest req, HTTPServerResponse res) {
auto jsr = req.json;
int idsms = jsr["id"].get!int;
if (!sqlDeleteSMS(idsms)) {
res.send(true, "Не удалось удалить SMS");
return;
}
res.send();
}