Refine search
@ApiOperation("根据分类查询属性列表或参数列表") @ApiImplicitParams({@ApiImplicitParam(name = "type", value = "0表示属性,1表示参数", required = true, paramType = "query", dataType = "integer")}) @RequestMapping(value = "/list/{cid}", method = RequestMethod.GET) @ResponseBody public Object getList(@PathVariable Long cid, @RequestParam(value = "type") Integer type, @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) { List<PmsProductAttribute> productAttributeList = productAttributeService.getList(cid, type, pageSize, pageNum); return new CommonResult().pageSuccess(productAttributeList); }
@Produces(MediaType.APPLICATION_XML) @Path("{id}/templates/upload") @ApiOperation( value = "Uploads a template", response = TemplateEntity.class, @ApiImplicitParams( value = { @ApiImplicitParam( @Context final HttpServletRequest httpServletRequest, @Context final UriInfo uriInfo, @ApiParam( value = "The process group id.", required = true @ApiParam( value = "Acknowledges that this node is disconnected to allow for mutable requests to proceed.", required = false
@ApiOperation(value = "更新用户", notes = "根据用户id更新用户") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "用户id", required = true, dataType = "Long", paramType = "path"), @ApiImplicitParam(name = "user", value = "用户实体", required = true, dataType = "User") }) @PutMapping("/{id}") public @ResponseBody Map<String, Object> updateUser(@PathVariable(value = "id") Long id, @RequestBody User user) { Map<String, Object> map = new HashMap<>(); map.put("result", "success"); return map; }
@PostMapping @ApiOperation(value = "申请token", notes = "具体请求方式请参照: http://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html") @ApiImplicitParams( ) @ApiParam(allowableValues = GrantType.authorization_code + "," + GrantType.client_credentials + "," + GrantType.password + "," + GrantType.refresh_token + "," + GrantType.implicit) String grant_type, HttpServletRequest request) { OAuth2AccessToken accessToken = null;
@ApiOperation(value="更新信息", notes="根据url的id来指定更新图书信息") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "图书ID", required = true, dataType = "Long",paramType = "path"), @ApiImplicitParam(name = "book", value = "图书实体book", required = true, dataType = "Book") }) @RequestMapping(value="/{id}", method= RequestMethod.PUT) public String putUser(@PathVariable Long id, @RequestBody Book book) { Book book1 = books.get(id); book1.setName(book.getName()); book1.setPrice(book.getPrice()); books.put(id, book1); return "success"; } @ApiOperation(value="删除图书", notes="根据url的id来指定删除图书")
/** * Delete authentication token map. * * @param version the version * @param request the request * @return the map */ @DeleteMapping(value = "/token", produces = "application/json; charset=UTF-8") @ApiOperation(value = "清空token") @ApiImplicitParams( { @ApiImplicitParam(name = "Authorization", required = true, paramType = "header", dataType = "string", value = "authorization header", defaultValue = "Bearer ") } ) public Map<String, Object> deleteAuthenticationToken( @ApiParam(required = true, value = "版本", defaultValue = "v1") @PathVariable("version") String version, HttpServletRequest request) { String tokenHeader = request.getHeader(AuthenticationTokenFilter.TOKEN_HEADER); String token = tokenHeader.split(" ")[1]; //移除token jwtTokenUtil.removeToken(token); Map<String, Object> message = new HashMap<>(); message.put(Message.RETURN_FIELD_CODE, ReturnCode.SUCCESS); return message; }
@GetMapping("/projects") @ApiOperation("获取分页项目列表") @ApiImplicitParams({ @ApiImplicitParam(name = "type", value = "项目分类", required = false), @ApiImplicitParam(name = "progress", value = "项目进度", required = false), @ApiImplicitParam(name = "sort", value = "排序方式", required = false), @ApiImplicitParam(name = "page", value = "当前页"), @ApiImplicitParam(name = "size", value = "每页的大小"), }) public ResultVO getProjectList(@RequestParam(value = "type", required = false) Integer type, @RequestParam(value = "progress", required = false) Integer progress, @RequestParam(value = "sort", required = false) Integer sort, @RequestParam("page") Integer page, @RequestParam("size") Integer size) { List<ProjectInfoVO> projectList = Collections.emptyList(); if (type == null && progress == null) { projectList = projectService.getProjectList(page, size, sort); } else if (type == null) { projectList = projectService.getProjectListByProjectProgress(page, size, progress, sort); } else if (progress == null) { projectList = projectService.getProjectListByCategoryType(page, size, type, sort); } else { projectList = projectService.getProjectListByTypeAndProgress(page, size, type, progress, sort); } return ResultVOUtils.success(projectList); }
@ApiOperation(value = "刷新token") @ApiImplicitParams( @ApiParam(required = true, value = "版本", defaultValue = "v1") @PathVariable("version") String version, HttpServletRequest request) {
@ApiOperation(value = "计算+", notes = "加法") @ApiImplicitParams({ @ApiImplicitParam(name = "a", value = "数字a", required = true, dataType = "Long"), @ApiImplicitParam(name = "b", value = "数字b", required = true, dataType = "Long") }) @GetMapping("/{a}/{b}") public Integer get(@PathVariable Integer a, @PathVariable Integer b) { return a + b; } }
@ApiOperation(value = "修改用户信息") @ApiImplicitParams( @ApiParam(required = true, value = "版本", defaultValue = "v1") @PathVariable("version") String version, @Length(max = 10, message = "昵称最大长度为10") @ApiParam(required = true, value = "昵称") @RequestParam("nickname") String nickname, @Pattern(regexp = "0|1|2", message = "性别类型错误") @ApiParam(required = true, value = "性别 [未知,男,女]", allowableValues = "0,1,2") @RequestParam("gender") String gender, @ApiParam(required = true, value = "年龄") @RequestParam("age") String age ) {
@ApiOperation(value = "创建用户", notes = "根据User对象创建用户") @ApiImplicitParams({ @ApiImplicitParam(dataType = "java.lang.Long", name = "id", value = "id", required = true, paramType = "path"), @ApiImplicitParam(dataType = "User", name = "user", value = "用户信息", required = true) }) @ApiResponses({ @ApiResponse(code = 500, message = "接口异常"), }) @RequestMapping(value = "/user/{id}", method = RequestMethod.POST) public User insert(@PathVariable Long id, @RequestBody User user) { System.out.println("id:" + id + ", user:" + user); user.setId(id); return user; }
/** * Gets user. * * @param version the version * @return the user */ @GetMapping(value = "", produces = "application/json; charset=UTF-8") @ApiOperation(value = "获取用户信息") @ApiImplicitParams( { @ApiImplicitParam(name = "Authorization", required = true, paramType = "header", dataType = "string", value = "authorization header", defaultValue = "Bearer ") } ) public Map<String, Object> getUser( @ApiParam(required = true, value = "版本", defaultValue = "v1") @PathVariable("version") String version ) { AuthUser user = WebUtils.getCurrentUser(); TripUser tripUser = tripUserService.get(user.getId()); Map<String, Object> result = new HashMap<>(); result.put("mobile", tripUser.getMobile()); //手机号 result.put("photo", fileManager.getFileUrlByRealPath(tripUser.getPhoto())); //头像 result.put("nickname", tripUser.getNickname()); //昵称 result.put("gender", tripUser.getGender()); //性别 result.put("age", tripUser.getAge()); //年龄 Map<String, Object> message = new HashMap<>(); message.put(Message.RETURN_FIELD_CODE, ReturnCode.SUCCESS); message.put(Message.RETURN_FIELD_DATA, result); return message; }
@ApiOperation(value="更新用户详细信息", notes="根据url的id来指定更新对象,并根据传过来的user信息来更新用户详细信息") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long"), @ApiImplicitParam(name = "user", value = "用户详细实体user", required = true, dataType = "User") }) @RequestMapping(value="/{id}", method=RequestMethod.PUT) public String putUser(@PathVariable Long id, @RequestBody User user) { User u = users.get(id); u.setName(user.getName()); u.setAge(user.getAge()); users.put(id, u); return "success"; }
@ApiOperation(value = "上传头像") @ApiImplicitParams( @ApiParam(required = true, value = "版本", defaultValue = "v1") @PathVariable("version") String version, @ApiParam(required = true, value = "头像") @RequestParam(value = "photo") MultipartFile photo ) { String path = "";
@ApiOperation("获取地址信息") @ApiImplicitParams({ @ApiImplicitParam(paramType = "query", name = "province", dataType = "String", required = true, value = "省", defaultValue = "广东省"), @ApiImplicitParam(paramType = "query", name = "area", dataType = "String", required = true, value = "地区", defaultValue = "南山区"), @ApiImplicitParam(paramType = "query", name = "street", dataType = "String", required = true, value = "街道", defaultValue = "桃园路"), @ApiImplicitParam(paramType = "query", name = "num", dataType = "String", required = true, value = "门牌号", defaultValue = "666")}) @ApiResponses({@ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")}) @RequestMapping(value = "/address/list", method = RequestMethod.POST) public BaseResp<List<Address>> getAddressList(@RequestParam(value = "province") String province, @RequestParam(value = "area") String area, @RequestParam(value = "street") String street, @RequestParam(value = "num") String num) { if (StringUtils.isEmpty(province) || StringUtils.isEmpty(area) || StringUtils.isEmpty(street) || StringUtils .isEmpty(num)) { return new BaseResp(ResultStatus.error_invalid_argument); } Address address = new Address(); address.setProvince(province); address.setArea(area); address.setStreet(street); address.setNum(num); List<Address> lists = new ArrayList<>(); lists.add(address); lists.add(address); lists.add(address); return new BaseResp(ResultStatus.SUCCESS, lists); }
@ApiOperation(value = "Get a variable from a task", tags = { "Task Variables" }, nickname = "getTaskInstanceVariable") @ApiImplicitParams(@ApiImplicitParam(name = "scope", dataType = "string", value = "Scope of variable to be returned. When local, only task-local variable value is returned. When global, only variable value from the task’s parent execution-hierarchy are returned. When the parameter is omitted, a local variable will be returned if it exists, otherwise a global variable.", paramType = "query")) @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the task was found and the requested variables are returned."), @ApiResponse(code = 404, message = "Indicates the requested task was not found or the task does not have a variable with the given name (in the given scope). Status message provides additional information.") }) @GetMapping(value = "/cmmn-runtime/tasks/{taskId}/variables/{variableName}", produces = "application/json") public RestVariable getVariable(@ApiParam(name = "taskId") @PathVariable("taskId") String taskId, @ApiParam(name = "variableName") @PathVariable("variableName") String variableName, @ApiParam(hidden = true) @RequestParam(value = "scope", required = false) String scope, HttpServletRequest request, HttpServletResponse response) { return getVariableFromRequest(taskId, variableName, scope, false); }
@ApiOperation(value = "获取地址信息", notes = "我是描述") @ApiImplicitParams({ @ApiImplicitParam(paramType = "body", name = "address", dataType = "Address", required = true, value = "省", defaultValue = "广东省"), }) @PostMapping(value = "/address") public BaseResp<Address> getAddressInfo(@RequestBody Address address) { BaseResp<Address> resp = new BaseResp<Address>(); resp.setMessage(ResultStatus.SUCCESS.getErrorMsg()); resp.setCode(ResultStatus.SUCCESS.getErrorCode()); resp.setData(address); return resp; }
@ApiOperation("获取地址信息(路径传参)") @ApiImplicitParams({ @ApiImplicitParam(paramType = "path", name = "area", dataType = "String", required = true, value = "区域", defaultValue = "南山区"), @ApiImplicitParam(paramType = "path", name = "number", dataType = "String", required = true, value = "门牌号", defaultValue = "9527")}) @ApiResponses({@ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")}) @RequestMapping(value = "/address/{area}/{number}", method = RequestMethod.GET) public BaseResp<String> getAddress(@PathVariable("area") String area, @PathVariable("number") String number) { Address address = new Address(); address.setProvince("广东省"); address.setArea(area); address.setStreet("桃园街道"); address.setNum(number); return new BaseResp(ResultStatus.SUCCESS, address.toString()); } }
@ApiOperation(value = "缓存数据", notes = "缓存测试", tags = {"Redis"}) @GetMapping("/addcachedata") @ApiImplicitParams({ @ApiImplicitParam(name = "key", value = "缓存Key", required = true, example = "random_key"), @ApiImplicitParam(name = "value", value = "缓存Value", required = true, example = "XXXOOOO") }) ResponseData<UserInfo> addCacheData(@RequestParam(value = "key", required = true) String key, @RequestParam(value = "value", required = true) String value);
@ApiOperation(value="测试Get请求") @ApiImplicitParams( @ApiImplicitParam(name="name", dataType="string", required=false, value="昵称", paramType="query") ) @GetMapping("/api/hello") public String hello(@RequestParam(required=false) String name) { return (StringUtils.isEmpty(name)) ? "Hello! Swagger" : ("Hello! " + name); }