|
| 1 | +/* |
| 2 | + * Copyright 2019-2029 geekidea(https://github.com/geekidea) |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package io.geekidea.springbootplus.example; |
| 18 | + |
| 19 | +import io.geekidea.springbootplus.common.api.ApiResult; |
| 20 | +import io.swagger.annotations.Api; |
| 21 | +import io.swagger.annotations.ApiOperation; |
| 22 | +import lombok.extern.slf4j.Slf4j; |
| 23 | +import org.apache.shiro.authz.annotation.RequiresRoles; |
| 24 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 25 | +import org.springframework.web.bind.annotation.RequestMethod; |
| 26 | +import org.springframework.web.bind.annotation.RestController; |
| 27 | + |
| 28 | +import javax.servlet.http.HttpServletResponse; |
| 29 | +import java.io.IOException; |
| 30 | + |
| 31 | +/** |
| 32 | + * Shiro Example Controller |
| 33 | + * |
| 34 | + * @author geekidea |
| 35 | + * @date 2019-10-21 |
| 36 | + **/ |
| 37 | +@Slf4j |
| 38 | +@Api("Shiro Example") |
| 39 | +@RestController |
| 40 | +@RequestMapping("/shiroExample") |
| 41 | +public class ShiroExampleController { |
| 42 | + |
| 43 | + @RequiresRoles("admin") |
| 44 | + @RequestMapping(value = "/hello", method = {RequestMethod.GET, RequestMethod.POST}) |
| 45 | + @ApiOperation(value = "Shiro Example", notes = "Shiro Example", response = String.class) |
| 46 | + public ApiResult print(HttpServletResponse response) throws IOException { |
| 47 | + log.debug("Shiro Example..."); |
| 48 | + return ApiResult.ok("Shiro Example"); |
| 49 | + } |
| 50 | + |
| 51 | +} |
0 commit comments