Search in sources :

Example 26 with ApiImplicitParams

use of io.swagger.annotations.ApiImplicitParams in project CzechIdMng by bcvsolutions.

the class IdmTreeNodeController method findRoots.

@ResponseBody
@PreAuthorize("hasAuthority('" + CoreGroupPermission.TREENODE_AUTOCOMPLETE + "')")
@RequestMapping(value = "/search/roots", method = RequestMethod.GET)
@ApiOperation(value = "Search root tree nodes", nickname = "searchRootTreeNodes", tags = { IdmTreeNodeController.TAG }, notes = "Tree type parameter can be used. If no tree type ios given, then configured default tree type is used." + " If no default tree type is configured, then all roots are returnde")
@ApiImplicitParams({ @ApiImplicitParam(name = "page", dataType = "string", paramType = "query", value = "Results page you want to retrieve (0..N)"), @ApiImplicitParam(name = "size", dataType = "string", paramType = "query", value = "Number of records per page."), @ApiImplicitParam(name = "sort", allowMultiple = true, dataType = "string", paramType = "query", value = "Sorting criteria in the format: property(,asc|desc). " + "Default sort order is ascending. " + "Multiple sort criteria are supported.") })
public Resources<?> findRoots(@ApiParam(value = "Tree type uuid identifier.", required = false) @RequestParam(value = "treeTypeId", required = false) String treeTypeId, @RequestParam(required = false) MultiValueMap<String, Object> parameters, @PageableDefault Pageable pageable) {
    UUID treeTypeIdentifier = null;
    if (StringUtils.isNotEmpty(treeTypeId)) {
        treeTypeIdentifier = DtoUtils.toUuid(treeTypeId);
    } else {
        IdmTreeTypeDto defaultType = treeConfiguration.getDefaultType();
        if (defaultType != null) {
            treeTypeIdentifier = defaultType.getId();
        }
    }
    IdmTreeNodeFilter filter = toFilter(parameters);
    filter.setRoots(Boolean.TRUE);
    if (treeTypeIdentifier != null) {
        filter.setTreeTypeId(treeTypeIdentifier);
    }
    // 
    Page<IdmTreeNodeDto> roots = find(filter, pageable, IdmBasePermission.AUTOCOMPLETE);
    return toResources(roots, IdmTreeNode.class);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) UUID(java.util.UUID) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 27 with ApiImplicitParams

use of io.swagger.annotations.ApiImplicitParams in project spring-boot-starter-samples by vindell.

the class DemoController method list.

@ApiOperation(value = "获取xxx列表", notes = "分页查询xxx信息")
@ApiImplicitParams({ @ApiImplicitParam(name = "pageNo", value = "当前页码", required = true, dataType = "Integer"), @ApiImplicitParam(name = "limit", value = "每页记录数", required = true, dataType = "Integer"), @ApiImplicitParam(name = "sortName", value = "排序字段名称", required = true, dataType = "String"), @ApiImplicitParam(name = "sortOrder", value = "排序类型 asc \\ desc", required = true, dataType = "String"), @ApiImplicitParam(name = "demoVo", value = "用户详细实体user", required = true, dataType = "UserVo") })
@ApiResponses({ @ApiResponse(code = HttpStatus.SC_OK, message = "操作成功"), @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = "请求要求身份验证"), @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = "请求资源不存在"), @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = "服务器内部异常"), @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = "权限不足") })
@BusinessLog(module = LogConstant.Module.N01, business = LogConstant.BUSINESS.N010001, opt = BusinessType.SELECT)
@PostMapping(value = "list")
@ResponseBody
public Object list(Integer pageNo, Integer limit, String sortName, String sortOrder, DemoVo demoVo, HttpServletRequest request) throws Exception {
    try {
        Page<DemoModel> pageResult = getDemoService().getPagedList(null);
        List<DemoVo> retList = new ArrayList<DemoVo>();
        for (DemoModel model : pageResult.getRecords()) {
            retList.add(getBeanMapper().map(model, DemoVo.class));
        }
        return new Result<DemoVo>(pageResult, retList);
    } catch (Exception e) {
        logException(this, e);
        return error("");
    }
}
Also used : DemoModel(net.jeebiz.boot.demo.dao.entities.DemoModel) DemoVo(net.jeebiz.boot.demo.web.vo.DemoVo) ArrayList(java.util.ArrayList) Result(net.jeebiz.boot.api.webmvc.Result) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) BusinessLog(net.jeebiz.boot.api.annotation.BusinessLog) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 28 with ApiImplicitParams

use of io.swagger.annotations.ApiImplicitParams in project spring-boot-starter-samples by vindell.

the class AuthzLoginController method switchRole.

@ApiOperation(value = "switchRole", notes = "切换角色")
@ApiImplicitParams({ @ApiImplicitParam(name = "roleid", value = "角色ID", dataType = "String") })
// @BusinessLog(module = Constants.Module.LOGIN, business = "切换角色", opt = BusinessType.LOGIN)
@RequestMapping(value = "switchRole", method = { RequestMethod.POST, RequestMethod.GET })
public String switchRole(String roleid) {
    try {
        AuthzLoginModel principal = SubjectUtils.getPrincipal(AuthzLoginModel.class);
        Session session = SubjectUtils.getSession();
        if (StringUtils.isNotBlank(roleid) && (!StringUtils.equals(roleid, principal.getRoleid()))) {
            /*// 切换当前的角色信息
				getUser().setJsdm(jsdm);

				// 刷新shiro缓存
				AccountRealm shiroRealm = ServiceFactory.getService(DefaultAccountRealm.class);
				shiroRealm.clearAuthorizationCache();*/
            // 刷新shiro缓存
            // 删除用户数据范围标识
            session.removeAttribute("");
        }
    } catch (Exception e) {
        logException(this, e);
    }
    return "redirect:/index";
}
Also used : AuthzLoginModel(net.jeebiz.boot.demo.dao.entities.AuthzLoginModel) NoneRoleException(org.apache.shiro.biz.authc.exception.NoneRoleException) DisabledAccountException(org.apache.shiro.authc.DisabledAccountException) IncorrectCaptchaException(org.apache.shiro.biz.authc.exception.IncorrectCaptchaException) InvalidCaptchaException(org.apache.shiro.biz.authc.exception.InvalidCaptchaException) InvalidAccountException(org.apache.shiro.biz.authc.exception.InvalidAccountException) UnknownAccountException(org.apache.shiro.authc.UnknownAccountException) NoneCaptchaException(org.apache.shiro.biz.authc.exception.NoneCaptchaException) Session(org.apache.shiro.session.Session) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 29 with ApiImplicitParams

use of io.swagger.annotations.ApiImplicitParams in project spring-boot-starter-samples by vindell.

the class UserController method putUser.

@ApiOperation(value = "更新用户详细信息", notes = "根据url的id来指定更新对象,并根据传过来的user信息来更新用户详细信息")
@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long"), @ApiImplicitParam(name = "user", value = "用户详细实体user", required = true, dataType = "UserDto") })
@RequestMapping(value = "put/{id}", method = RequestMethod.PUT)
public String putUser(@PathVariable Long id, @RequestBody UserDto user) {
    UserDto u = users.get(id);
    u.setName(user.getName());
    u.setAge(user.getAge());
    users.put(id, u);
    return "success";
}
Also used : UserDto(io.swagger2.spring.boot.dao.UserDto) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ApiImplicitParams (io.swagger.annotations.ApiImplicitParams)29 ApiOperation (io.swagger.annotations.ApiOperation)21 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 IOException (java.io.IOException)8 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)8 ApiImplicitParam (io.swagger.annotations.ApiImplicitParam)7 ApiResponses (io.swagger.annotations.ApiResponses)7 Consumes (javax.ws.rs.Consumes)7 Response (javax.ws.rs.core.Response)7 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)7 ApiResponse (io.swagger.annotations.ApiResponse)6 URI (java.net.URI)6 POST (javax.ws.rs.POST)6 Produces (javax.ws.rs.Produces)5 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)5 PUT (javax.ws.rs.PUT)4 Path (javax.ws.rs.Path)4 Api (io.swagger.annotations.Api)3 ApiParam (io.swagger.annotations.ApiParam)3 PathParameter (io.swagger.models.parameters.PathParameter)3