use of io.github.tesla.ops.common.Log in project tesla by linking12.
the class FilterRouteController method save.
@Log("保存路由")
@RequiresPermissions("filter:route:add")
@PostMapping("/save")
@ResponseBody()
public CommonResponse save(RouteVo zuulVo, @RequestParam(name = "zipFile", required = false) MultipartFile zipFile) {
try {
// grpc路由
if (zipFile != null) {
InputStream directoryZipStream = zipFile.getInputStream();
CommonResponse response = judgeFileType(directoryZipStream, "zip");
if (response != null) {
return response;
} else {
String serviceFileName = zuulVo.getServiceFileName();
byte[] protoContext = protobufService.compileDirectoryProto(zipFile, serviceFileName);
FilterRouteDto zuulDto = zuulVo.buildRouteDto();
zuulDto.setProtoContext(protoContext);
routeService.save(zuulDto);
}
} else {
FilterRouteDto zuulDto = zuulVo.buildRouteDto();
routeService.save(zuulDto);
}
} catch (IOException e) {
throw new TeslaException("保存路由失败", e);
}
return CommonResponse.ok();
}
use of io.github.tesla.ops.common.Log in project tesla by linking12.
the class FilterRouteController method update.
@Log("更新路由")
@RequiresPermissions("filter:route:edit")
@PostMapping("/update")
@ResponseBody()
public CommonResponse update(RouteVo zuulVo, @RequestParam(name = "zipFile", required = false) MultipartFile zipFile) {
try {
// grpc路由
if (zipFile != null) {
InputStream directoryZipStream = zipFile.getInputStream();
CommonResponse response = judgeFileType(directoryZipStream, "zip");
if (response != null) {
return response;
} else {
String serviceFileName = zuulVo.getServiceFileName();
byte[] protoContext = protobufService.compileDirectoryProto(zipFile, serviceFileName);
FilterRouteDto zuulDto = zuulVo.buildRouteDto();
zuulDto.setProtoContext(protoContext);
routeService.update(zuulDto);
}
} else {
FilterRouteDto zuulDto = zuulVo.buildRouteDto();
routeService.update(zuulDto);
}
} catch (IOException e) {
throw new TeslaException("保存路由失败", e);
}
return CommonResponse.ok();
}
use of io.github.tesla.ops.common.Log in project tesla by linking12.
the class LoginController method ajaxLogin.
@Log("登录")
@PostMapping("/login")
@ResponseBody
CommonResponse ajaxLogin(String username, String password) {
password = MD5Utils.encrypt(username, password);
UsernamePasswordToken token = new UsernamePasswordToken(username, password);
Subject subject = SecurityUtils.getSubject();
try {
subject.login(token);
return CommonResponse.ok();
} catch (AuthenticationException e) {
return CommonResponse.error("用户或密码错误");
}
}
use of io.github.tesla.ops.common.Log in project tesla by linking12.
the class MenuController method edit.
@Log("编辑菜单")
@RequiresPermissions("sys:menu:edit")
@GetMapping("/edit/{id}")
String edit(Model model, @PathVariable("id") Long id) {
MenuDO mdo = menuService.get(id);
Long pId = mdo.getParentId();
model.addAttribute("pId", pId);
if (pId == 0) {
model.addAttribute("pName", "根目录");
} else {
model.addAttribute("pName", menuService.get(pId).getName());
}
model.addAttribute("menu", mdo);
return prefix + "/edit";
}
use of io.github.tesla.ops.common.Log in project tesla by linking12.
the class UserController method edit.
@RequiresPermissions("sys:user:edit")
@Log("编辑用户")
@GetMapping("/edit/{id}")
String edit(Model model, @PathVariable("id") Long id) {
UserDO userDO = userService.get(id);
model.addAttribute("user", userDO);
List<RoleDO> roles = roleService.list(id);
model.addAttribute("roles", roles);
return prefix + "/edit";
}
Aggregations