Search in sources :

Example 1 with Log

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();
}
Also used : InputStream(java.io.InputStream) FilterRouteDto(io.github.tesla.ops.filter.dto.FilterRouteDto) IOException(java.io.IOException) CommonResponse(io.github.tesla.ops.common.CommonResponse) TeslaException(io.github.tesla.ops.common.TeslaException) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) PostMapping(org.springframework.web.bind.annotation.PostMapping) Log(io.github.tesla.ops.common.Log) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with Log

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();
}
Also used : InputStream(java.io.InputStream) FilterRouteDto(io.github.tesla.ops.filter.dto.FilterRouteDto) IOException(java.io.IOException) CommonResponse(io.github.tesla.ops.common.CommonResponse) TeslaException(io.github.tesla.ops.common.TeslaException) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) PostMapping(org.springframework.web.bind.annotation.PostMapping) Log(io.github.tesla.ops.common.Log) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with Log

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("用户或密码错误");
    }
}
Also used : AuthenticationException(org.apache.shiro.authc.AuthenticationException) Subject(org.apache.shiro.subject.Subject) UsernamePasswordToken(org.apache.shiro.authc.UsernamePasswordToken) PostMapping(org.springframework.web.bind.annotation.PostMapping) Log(io.github.tesla.ops.common.Log) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with Log

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";
}
Also used : MenuDO(io.github.tesla.ops.system.domain.MenuDO) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) GetMapping(org.springframework.web.bind.annotation.GetMapping) Log(io.github.tesla.ops.common.Log)

Example 5 with Log

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";
}
Also used : UserDO(io.github.tesla.ops.system.domain.UserDO) RoleDO(io.github.tesla.ops.system.domain.RoleDO) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) GetMapping(org.springframework.web.bind.annotation.GetMapping) Log(io.github.tesla.ops.common.Log)

Aggregations

Log (io.github.tesla.ops.common.Log)9 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)8 GetMapping (org.springframework.web.bind.annotation.GetMapping)6 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 FilterRouteDto (io.github.tesla.ops.filter.dto.FilterRouteDto)3 PostMapping (org.springframework.web.bind.annotation.PostMapping)3 CommonResponse (io.github.tesla.ops.common.CommonResponse)2 TeslaException (io.github.tesla.ops.common.TeslaException)2 RoleDO (io.github.tesla.ops.system.domain.RoleDO)2 UserDO (io.github.tesla.ops.system.domain.UserDO)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 ClientDetails (io.github.tesla.authz.domain.ClientDetails)1 RouteVo (io.github.tesla.ops.filter.vo.RouteVo)1 MenuDO (io.github.tesla.ops.system.domain.MenuDO)1 PageDO (io.github.tesla.ops.system.domain.PageDO)1 Query (io.github.tesla.ops.utils.Query)1 AuthenticationException (org.apache.shiro.authc.AuthenticationException)1 UsernamePasswordToken (org.apache.shiro.authc.UsernamePasswordToken)1 Subject (org.apache.shiro.subject.Subject)1