@yhiot/utils
Version:
143 lines (142 loc) • 3.66 kB
TypeScript
/**
* @api {GET} /apis/v1/mqtt/:model/:_id 通用获取单条记录
* @apiDescription model:`user,company,vehicle,device`
* @apiName getModel
* @apiGroup apiMqttV2
* @apiVersion 1.0.0
* @apiParam {String} model Mandatory modelname.
* @apiParam {String} _id Mandatory
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* {
* errcode: 0,
* result: {
* "id": "5ba27cc3a70db45dd108b53f",
* "status": 0,
* ...
* }
* }
* @apiErrorExample {json} Error-Response:
* {
* errcode: !=0,
* message: "error message"
* }
*/
export function preGetModel(ctx: any, next: any): Promise<void>;
/**
* @api {GET} /apis/v1/mqtt/:model 通用获取记录列表
* @apiDescription model:`user,company,vehicle,device`
* @apiName getModals
* @apiGroup apiMqttV2
* @apiVersion 1.0.0
* @apiParam {String} model Mandatory modelname.
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* {
* errcode: 0,
* result: {
* total: 102, // 总条数,中间有记录插入删除改变状态,可能导致每次查到总量不一致
* items: [
* {
* id: "5bd863882da794797a73001e",
* status: 0,
* author: "5ba27cc3a70db45dd108b53f",
* ...
* },
* {
* id: "5bd00a2222580a229225245e",
* status: 0,
* author: "5ba27cc3a70db45dd108b53f",
* ...
* }
* ]
* } // result
* }
* @apiErrorExample {json} Error-Response:
* {
* errcode: !=0,
* message: "error message"
* }
*/
export function preGetModels(ctx: any, next: any): Promise<void>;
/**
* @api {POST} /apis/v1/mqtt/:model 通用创建一条记录
* @apiDescription model:`user,company,vehicle,device`
* @apiName createModal
* @apiGroup apiMqttV2
* @apiVersion 1.0.0
* @apiParam {String} model Mandatory modelname.
* @apiParam {String} [_id] Option id. Mandatory at device/vehicle.
* @apiParamExample {json} Request-Example:
* {
* status,
* ...,
* }
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* {
* errcode: 0,
* result: {
* "id": "5ba27cc3a70db45dd108b53f",
* "status": 0,
* ...
* }
* }
* @apiErrorExample {json} Error-Response:
* {
* errcode: !=0,
* message: "error message"
* }
*/
export function preCreateModel(ctx: any, next: any): Promise<void>;
/**
* @api {PUT} /apis/v1/mqtt/:model/:_id 通用更新一条记录
* @apiDescription model:`user,company,vehicle,device`
* @apiName updateModal
* @apiGroup apiMqttV2
* @apiVersion 1.0.0
* @apiParam {String} model Mandatory modelname.
* @apiParam {String} _id Mandatory id.
* @apiParamExample {json} Request-Example:
* {
* status,
* ...,
* }
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* {
* errcode: 0,
* result: {
* "id": "5ba27cc3a70db45dd108b53f",
* "status": 0,
* ...
* }
* }
*/
export function preUpdateModel(ctx: any, next: any): Promise<void>;
/**
* @api {DELETE} /apis/v1/mqtt/:model/:_id 通用删除一条记录
* @apiDescription model:`user,company,vehicle,device`
* @apiName removeModal
* @apiGroup apiMqttV2
* @apiVersion 1.0.0
* @apiParam {String} model Mandatory modelname.
* @apiParam {String} _id Mandatory id.
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* {
* errcode: 0,
* result: {
* "id": "5ba27cc3a70db45dd108b53f",
* "status": 0,
* ...
* }
* }
* @apiErrorExample {json} Error-Response:
* {
* errcode: !=0,
* message: "error message"
* }
*/
export function preRemoveModel(ctx: any, next: any): Promise<void>;
export function postCRUDCreator(crudFunction: any): (ctx: any) => Promise<void>;