Search in sources :

Example 6 with CommandExecLogModel

use of io.jpom.model.data.CommandExecLogModel in project Jpom by dromara.

the class CommandLogController method downloadLog.

/**
 * 下载日志
 *
 * @param logId 日志 id
 *
 * @api {GET} node/ssh_command_log/download_log 下载日志
 * @apiGroup node/ssh_command_log
 * @apiUse defResultJson
 * @apiParam {String} logId 日志 id
 * @apiSuccess {File} file 日志文件
 */
@RequestMapping(value = "download_log", method = RequestMethod.GET)
@ResponseBody
@Feature(method = MethodFeature.DOWNLOAD)
public void downloadLog(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "没有数据") String logId) {
    CommandExecLogModel item = commandExecLogService.getByKey(logId);
    Assert.notNull(item, "没有对应数据");
    File logFile = item.logFile();
    if (!FileUtil.exist(logFile)) {
        return;
    }
    if (logFile.isFile()) {
        ServletUtil.write(getResponse(), logFile);
    }
}
Also used : CommandExecLogModel(io.jpom.model.data.CommandExecLogModel) File(java.io.File) ClassFeature(io.jpom.permission.ClassFeature) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature)

Example 7 with CommandExecLogModel

use of io.jpom.model.data.CommandExecLogModel in project Jpom by dromara.

the class CommandService method updateStatus.

/**
 * 修改执行状态
 *
 * @param id     ID
 * @param status 状态
 */
private void updateStatus(String id, CommandExecLogModel.Status status) {
    CommandExecLogModel commandExecLogModel = new CommandExecLogModel();
    commandExecLogModel.setId(id);
    commandExecLogModel.setStatus(status.getCode());
    commandExecLogService.update(commandExecLogModel);
}
Also used : CommandExecLogModel(io.jpom.model.data.CommandExecLogModel)

Aggregations

CommandExecLogModel (io.jpom.model.data.CommandExecLogModel)7 ClassFeature (io.jpom.permission.ClassFeature)4 Feature (io.jpom.permission.Feature)4 MethodFeature (io.jpom.permission.MethodFeature)4 File (java.io.File)4 JSONObject (com.alibaba.fastjson.JSONObject)2 SshModel (io.jpom.model.data.SshModel)2 IOException (java.io.IOException)2 ExceptionUtil (cn.hutool.core.exceptions.ExceptionUtil)1 FileUtil (cn.hutool.core.io.FileUtil)1 IoUtil (cn.hutool.core.io.IoUtil)1 LineHandler (cn.hutool.core.io.LineHandler)1 ThreadUtil (cn.hutool.core.thread.ThreadUtil)1 CharsetUtil (cn.hutool.core.util.CharsetUtil)1 IdUtil (cn.hutool.core.util.IdUtil)1 StrUtil (cn.hutool.core.util.StrUtil)1 Task (cn.hutool.cron.task.Task)1 ChannelType (cn.hutool.extra.ssh.ChannelType)1 JschUtil (cn.hutool.extra.ssh.JschUtil)1 SystemUtil (cn.hutool.system.SystemUtil)1