use json::{JsonValue, object};
use br_addon::action::{Action, InterfaceType};
use br_addon::module::Module;
use br_addon::request::Request;
use br_addon::ApiResponse;
use br_fields::Field;
use crate::addon::dms::task::DmsTask;
pub struct DmsTaskGet {
pub module: DmsTask,
}
impl Action for DmsTaskGet {
fn tags(&self) -> &'static [&'static str] {
&[]
}
fn title(&self) -> &'static str { "配置" }
fn auth(&self) -> bool {
false
}
fn public(&self) -> bool {
false
}
fn interface_type(&self) -> InterfaceType {
InterfaceType::API
}
fn params(&mut self) -> JsonValue {
let mut params = object! {};
params[self.module.table_key()] = br_fields::str::Key::new(true, self.module.table_key(), "ID", 20).field();
params
}
fn index(&mut self, request: Request) -> ApiResponse {
let id = request.body["id"].clone();
let data = self.tools().db.table(self.module._table_name())
.where_and("id", "=", id.clone())
.find();
if data.is_empty() {
return ApiResponse::fail(111111,"配置失败");
}
ApiResponse::success(data, "配置成功")
}
}