Commit 3faeeda1 authored by 黎博's avatar 黎博

update

parent fa1b2f33
......@@ -3,9 +3,11 @@ package cn.qg.holmes.controller.k8s;
import cn.qg.holmes.common.JsonResult;
import cn.qg.holmes.config.annotation.RecordOperation;
import cn.qg.holmes.entity.auth.UserInfoVo;
import cn.qg.holmes.entity.behavior.UserBehaviorRecord;
import cn.qg.holmes.entity.k8s.DockerProject;
import cn.qg.holmes.entity.k8s.ServiceCreateVo;
import cn.qg.holmes.service.auth.TokenService;
import cn.qg.holmes.service.behavior.UserBehaviorRecordService;
import cn.qg.holmes.service.k8s.*;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -45,6 +47,9 @@ public class K8sController {
@Autowired
TokenService tokenService;
@Autowired
UserBehaviorRecordService userBehaviorRecordService;
/**
* 获取namespace列表
* @return
......@@ -395,7 +400,13 @@ public class K8sController {
* @return
*/
@PostMapping("/sync/mq")
public JsonResult syncOnlineMqToTest(@RequestParam String host) {
public JsonResult syncOnlineMqToTest(@RequestHeader String token, @RequestParam String namespace, @RequestParam String host) {
UserInfoVo userInfoVo = tokenService.getUserInfoFromCache(token);
UserBehaviorRecord userBehaviorRecord = new UserBehaviorRecord();
userBehaviorRecord.setUsername(userInfoVo.getChineseName());
userBehaviorRecord.setNamespace(namespace);
userBehaviorRecord.setAction("同步mq");
userBehaviorRecordService.save(userBehaviorRecord);
return JsonResult.buildSuccessResult(mqService.setDefinitions(host));
}
......@@ -405,8 +416,14 @@ public class K8sController {
* @return
*/
@PostMapping("/redis/flush")
public JsonResult flushRedis(@RequestParam String namespace) {
public JsonResult flushRedis(@RequestHeader String token, @RequestParam String namespace) {
try {
UserInfoVo userInfoVo = tokenService.getUserInfoFromCache(token);
UserBehaviorRecord userBehaviorRecord = new UserBehaviorRecord();
userBehaviorRecord.setUsername(userInfoVo.getChineseName());
userBehaviorRecord.setNamespace(namespace);
userBehaviorRecord.setAction("清空redis");
userBehaviorRecordService.save(userBehaviorRecord);
Map<String, Object> redisInfo = k8sService.getPodAndServiceInfo(namespace, "base", "redis");
String lanIp = redisInfo.get("lanIp").toString();
List<Map<String, Object>> portMappings = (List<Map<String, Object>>) redisInfo.get("portMappings");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment