feat: 增加list_files命令

dev
huangfeng 9 months ago
parent c6fc7635ed
commit e38480a7ee

@ -48,6 +48,7 @@ public class CmdController extends BaseController {
list.add(new ActionModel(13, "pull_files", "拉取文件"));
list.add(new ActionModel(14, "push_file", "推送文件"));
list.add(new ActionModel(15, "upd_cfg", "修改配置文件"));
list.add(new ActionModel(16, "list_files", "列出目录下的文件名"));
return ResponseReult.success(list);
}

@ -263,6 +263,9 @@ public class CmdServiceImpl implements CmdService {
case "i1_cmd_stop_aging_test":
this.stopagingtest(model);
break;
case "list_files":
this.listFiles(model);
break;
default:
throw new ApiException("action无效");
}
@ -694,6 +697,34 @@ public class CmdServiceImpl implements CmdService {
}
}
private void listFiles(CmdModel model) {
if (CollectionUtils.isEmpty(model.getTermIds())) {
throw new ApiException("termIds不能为空");
} else if (StringUtils.isBlank(model.getPath())) {
throw new ApiException("path不能为空");
}
String name = "list_files";
for (Integer termId : model.getTermIds()) {
MntnCmdsExample example = new MntnCmdsExample();
MntnCmdsExample.Criteria criteria = example.createCriteria();
criteria.andTermIdEqualTo(termId);
criteria.andNameEqualTo(name);
cmdsMapper.deleteByExample(example);
HashMap<String, Object> map = new HashMap<>();
map.put("path", model.getPath());
String json = JSONUtil.object2Json(map);
MntnCmds cmd = new MntnCmds();
cmd.setTermId(termId);
cmd.setName(name);
cmd.setCmd(json);
cmd.setCreateTime(new Date());
cmdsMapper.insert(cmd);
}
}
private void startfrpc(CmdModel model) {
if (model.getTermId() == null) {
throw new ApiException("termId不能为空");

Loading…
Cancel
Save