You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1012 B

8 months ago
'use strict';
const _ = require("lodash");
const Controller = require('egg').Controller;
class MessageController extends Controller {
//打开端口
async openCom() {
let { ctx } = this;
let params = ctx.request.body
let SerialPortItem = _.find(ctx.app.comKey, { key: params.key })
let res = await ctx.service.message.openCom(SerialPortItem);
ctx.body = res
ctx.status = 200
}
//关闭端口
async closeCom() {
let { ctx } = this;
let params = ctx.request.body
let SerialPortItem = _.find(ctx.app.comKey, { key: params.key })
let res = await ctx.service.message.closeCom(SerialPortItem);
ctx.body = res
ctx.status = 200
}
//发送指令
async index() {
let { ctx } = this;
let params = ctx.request.body
let SerialPortItem = _.find(ctx.app.comKey, { ripCom: params.ripCom })
let res = await ctx.service.message.index({ ...SerialPortItem, ...params });
ctx.body = res
ctx.status = 200
}
}
module.exports = MessageController;