io.swagger.annotations.ApiImplicitParams Java Examples

The following examples show how to use io.swagger.annotations.ApiImplicitParams. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CatalogController.java    From logging-log4j-audit with Apache License 2.0 6 votes vote down vote up
@ApiImplicitParams( {@ApiImplicitParam(dataType = "String", name = "Authorization", paramType = "header")})
@ApiOperation(value = "Create a catalog Product", notes = "Creates a catalog product", tags = {"Catalog"})
@PostMapping(value = "/product", consumes=Versions.V1_0, produces=Versions.V1_0)
public ResponseEntity<Product> createProduct(@ApiParam(value = "product", required = true) @RequestBody Product product) {
    if (product.getCatalogId() == null) {
        throw new IllegalArgumentException("A catalog id is required to create a product.");
    }
    if (DEFAULT_CATALOG.equals(product.getCatalogId())) {
        throw new IllegalArgumentException("The default catalog cannot be modified at run time.");
    }
    Optional<ProductModel> opt = productService.getProduct(product.getCatalogId(), product.getName());
    if (opt != null && opt.isPresent()) {
        throw new IllegalStateException("A product named "+ product.getName() + " in catalog " +
                product.getCatalogId() + " already exists");
    }
    ProductModel model = productConverter.convert(product);
    model = productService.saveProduct(model);
    return new ResponseEntity<>(productModelConverter.convert(model), HttpStatus.CREATED);
}
 
Example #2
Source File: ReCiterPubManagerController.java    From ReCiter with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Create user for ReCiter publications manager", response = Boolean.class, notes = "This api create user for reciter publication manager app.")
@ApiImplicitParams({
	@ApiImplicitParam(name = "api-key", value = "api-key for this resource", paramType = "header")
})
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "User created"),
        @ApiResponse(code = 401, message = "You are not authorized to view the resource"),
        @ApiResponse(code = 403, message = "Accessing the resource you were trying to reach is forbidden"),
        @ApiResponse(code = 404, message = "The resource you were trying to reach is not found")
})
@RequestMapping(value = "/reciter/publication/manager/user/create", method = RequestMethod.POST, produces = "application/json")
@ResponseBody
public boolean createUser(@RequestParam(value = "username") String uid, @RequestParam(value = "name") String username, @RequestParam(value = "password") String password) {
    log.info("Creating user with username: " + uid);
    
    ApplicationUser appUser = new ApplicationUser(uid, username, password);
    if(applicationUserService.createUser(appUser)) {
    	return true;
    }
    return false;
}
 
Example #3
Source File: GatewayIpLimitController.java    From open-cloud with MIT License 6 votes vote down vote up
/**
 * 编辑IP限制
 *
 * @param policyId   IP限制ID
 * @param policyName 策略名称
 * @param policyType 策略类型:0-拒绝/黑名单 1-允许/白名单
 * @param ipAddress  ip地址/IP段:多个用隔开;最多10个
 * @return
 */
@ApiOperation(value = "编辑IP限制", notes = "编辑IP限制")
@ApiImplicitParams({
        @ApiImplicitParam(name = "policyId", required = true, value = "接口Id", paramType = "form"),
        @ApiImplicitParam(name = "policyName", required = true, value = "策略名称", paramType = "form"),
        @ApiImplicitParam(name = "policyType", required = true, value = "策略类型:0-拒绝/黑名单 1-允许/白名单", allowableValues = "0,1", paramType = "form"),
        @ApiImplicitParam(name = "ipAddress", required = true, value = "ip地址/IP段:多个用隔开;最多10个", paramType = "form")
})
@PostMapping("/gateway/limit/ip/update")
public ResultBody updateIpLimit(
        @RequestParam("policyId") Long policyId,
        @RequestParam(value = "policyName") String policyName,
        @RequestParam(value = "policyType") Integer policyType,
        @RequestParam(value = "ipAddress") String ipAddress
) {
    GatewayIpLimit ipLimit = new GatewayIpLimit();
    ipLimit.setPolicyId(policyId);
    ipLimit.setPolicyName(policyName);
    ipLimit.setPolicyType(policyType);
    ipLimit.setIpAddress(ipAddress);
    gatewayIpLimitService.updateIpLimitPolicy(ipLimit);
    openRestTemplate.refreshGateway();
    return ResultBody.ok();
}
 
Example #4
Source File: ReCiterPubManagerController.java    From ReCiter with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Authenticate user for ReCiter publications manager", response = Boolean.class, notes = "This api checks for credentials for access to reciter publication manager app.")
@ApiImplicitParams({
	@ApiImplicitParam(name = "api-key", value = "api-key for this resource", paramType = "header")
})
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "User authenticated"),
        @ApiResponse(code = 401, message = "You are not authorized to view the resource"),
        @ApiResponse(code = 403, message = "Accessing the resource you were trying to reach is forbidden"),
        @ApiResponse(code = 404, message = "The resource you were trying to reach is not found")
})
@RequestMapping(value = "/reciter/publication/manager/authenticate", method = RequestMethod.POST, produces = "application/json")
@ResponseBody
public boolean authenticate(@RequestParam(value = "username") String uid, @RequestParam(value = "password") String password) {
    log.info("Authenticating user with username: " + uid);
    
    ApplicationUser appUser = new ApplicationUser(uid, "", password);
    if(applicationUserService.authenticateUser(appUser)) {
    	return true;
    }
    return false;
}
 
Example #5
Source File: SysUserController.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
/**
 *  修改用户状态
 * @param params
 * @return
 * @author gitgeek
 */
@ApiOperation(value = "修改用户状态")
@GetMapping("/users/updateEnabled")
@ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "用户id", required = true, dataType = "Integer"),
        @ApiImplicitParam(name = "enabled",value = "是否启用", required = true, dataType = "Boolean")
})
@LogAnnotation(module="user-center",recordRequestParam=false)
@PreAuthorize("hasAnyAuthority('user:get/users/updateEnabled' ,'user:put/users/me')")
public Result updateEnabled(@RequestParam Map<String, Object> params){
    Long id = MapUtils.getLong(params, "id");
    if (id == 1L){
        return Result.failed("超级管理员不给予修改");
    }
    return appUserService.updateEnabled(params);
}
 
Example #6
Source File: AndroidController.java    From app-version with Apache License 2.0 6 votes vote down vote up
@ApiImplicitParams({
        @ApiImplicitParam(name = "Authorization", value = "用户登录凭证", paramType = "header", dataType = "string", defaultValue = "Bearer ", required = true),
})
@PutMapping("/{id}")
@OperationRecord(type = OperationRecordLog.OperationType.UPDATE, resource = OperationRecordLog.OperationResource.ANDROID_VERSION, description = OperationRecordLog.OperationDescription.UPDATE_ANDROID_VERSION)
public ServiceResult update(@RequestBody AndroidVersionRequestDTO androidVersionRequestDTO, @PathVariable int id) {
    if (id < 1) {
        return ServiceResultConstants.NEED_PARAMS;
    }

    String appVersion = androidVersionRequestDTO.getAppVersion();
    String allowLowestVersion = androidVersionRequestDTO.getAllowLowestVersion();
    //校验版本区间
    if (StringUtilsExt.hasNotBlank(allowLowestVersion, appVersion) && basicService.compareVersion(appVersion, allowLowestVersion) < 0) {
        return ServiceResultConstants.ALLOWLOWESTVERSION_BIG_THAN_APPVERSION;
    }
    AndroidVersion androidVersion = new AndroidVersion();
    BeanUtils.copyProperties(androidVersionRequestDTO, androidVersion);
    androidVersion.setId(id);
    return androidVersionService.updateAndroidVersion(androidVersion);
}
 
Example #7
Source File: RnPackageController.java    From app-version with Apache License 2.0 6 votes vote down vote up
@ApiImplicitParams({
        @ApiImplicitParam(name = "Authorization", value = "用户登录凭证", paramType = "header", dataType = "string", defaultValue = "Bearer ", required = true),
})
@PostMapping
@OperationRecord(type = OperationRecordLog.OperationType.CREATE, resource = OperationRecordLog.OperationResource.RN_PACKAGE, description = OperationRecordLog.OperationDescription.CREATE_RN_PACKAGE)
public ServiceResult create(@RequestBody RnPackageRequestDTO rnPackageRequestDTO) {
    if (StringUtilsExt.hasEmpty(
            rnPackageRequestDTO.getRnName(),
            rnPackageRequestDTO.getRnNickName(),
            rnPackageRequestDTO.getResourceUrl(),
            rnPackageRequestDTO.getRnVersion(),
            rnPackageRequestDTO.getRnUpdateLog()
    )) {
        return ServiceResultConstants.NEED_PARAMS;
    }
    //校验版本区间
    if (StringUtilsExt.hasNotBlank(rnPackageRequestDTO.getVersionMin(), rnPackageRequestDTO.getVersionMax())) {
        if (basicService.compareVersion(rnPackageRequestDTO.getVersionMax(), rnPackageRequestDTO.getVersionMin()) <= 0) {
            return ServiceResultConstants.MIN_BIG_THAN_MAX;
        }
    }

    RnPackage rnPackage = new RnPackage();
    BeanUtils.copyProperties(rnPackageRequestDTO, rnPackage);
    return rnPackageService.create(rnPackage);
}
 
Example #8
Source File: RnPackageController.java    From app-version with Apache License 2.0 6 votes vote down vote up
@ApiImplicitParams({
        @ApiImplicitParam(name = "Authorization", value = "用户登录凭证", paramType = "header", dataType = "string", defaultValue = "Bearer ", required = true),
})
@PutMapping("/{id}")
@OperationRecord(type = OperationRecordLog.OperationType.UPDATE, resource = OperationRecordLog.OperationResource.RN_PACKAGE, description = OperationRecordLog.OperationDescription.UPDATE_RN_PACKAGE)
public ServiceResult update(@PathVariable int id, @RequestBody RnPackageRequestDTO rnPackageRequestDTO) {
    if (id < 1) {
        return ServiceResultConstants.NEED_PARAMS;
    }
    //校验版本区间
    if (StringUtilsExt.hasNotBlank(rnPackageRequestDTO.getVersionMin(), rnPackageRequestDTO.getVersionMax()) && basicService.compareVersion(rnPackageRequestDTO.getVersionMax(), rnPackageRequestDTO.getVersionMin()) <= 0) {
        return ServiceResultConstants.MIN_BIG_THAN_MAX;
    }
    RnPackage rnPackage = new RnPackage();
    BeanUtils.copyProperties(rnPackageRequestDTO, rnPackage);
    rnPackage.setId(id);
    return rnPackageService.update(rnPackage);
}
 
Example #9
Source File: ItemController.java    From poseidon with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "get item by id", response = ItemDto.class)
@ApiImplicitParams({
		@ApiImplicitParam(paramType = "query", dataType = "String", name = "id",
				value = "商品id", required = true),
		@ApiImplicitParam(paramType = "query", dataType = "int", name = "blob",
				value = "0代表不包含大字段信息,1表示包含大字段信息", required = true) })

@GetMapping(path = "/{id}/{blob}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Message item(@PathVariable("id") String id, @PathVariable("blob") int blob) {
	try {
		ItemDto data = itemService.getById(id, blob);
		return success(data);
	}
	catch (Exception e) {
		e.printStackTrace();
	}
	return failed();
}
 
Example #10
Source File: CartController.java    From gpmall with Apache License 2.0 6 votes vote down vote up
/**
 * 删除购物车中的商品
 *
 * @return
 */
@ApiOperation("删除购物车中的商品")
@DeleteMapping("/carts/{uid}/{pid}")
@ApiImplicitParams({
        @ApiImplicitParam(name = "uid", value = "用户ID", paramType = "path"),
        @ApiImplicitParam(name = "pid", value = "商品ID", paramType = "path")
})
public ResponseData deleteCarts(@PathVariable("uid") long uid, @PathVariable("pid") long pid) {
    DeleteCartItemRequest request = new DeleteCartItemRequest();
    request.setUserId(uid);
    request.setItemId(pid);

    DeleteCartItemResponse response = iCartService.deleteCartItem(request);
    if (response.getCode().equals(ShoppingRetCode.SUCCESS.getCode())) {
        return new ResponseUtil().setData(response.getMsg());
    }
    return new ResponseUtil().setErrorMsg(response.getMsg());
}
 
Example #11
Source File: BaseAuthorityController.java    From open-cloud with MIT License 6 votes vote down vote up
/**
 * 分配应用权限
 *
 * @param appId        应用Id
 * @param expireTime   授权过期时间
 * @param authorityIds 权限ID.多个以,隔开
 * @return
 */
@ApiOperation(value = "分配应用权限", notes = "分配应用权限")
@ApiImplicitParams({
        @ApiImplicitParam(name = "appId", value = "应用Id", defaultValue = "", required = true, paramType = "form"),
        @ApiImplicitParam(name = "expireTime", value = "过期时间.选填", defaultValue = "", required = false, paramType = "form"),
        @ApiImplicitParam(name = "authorityIds", value = "权限ID.多个以,隔开.选填", defaultValue = "", required = false, paramType = "form")
})
@PostMapping("/authority/app/grant")
public ResultBody grantAuthorityApp(
        @RequestParam(value = "appId") String appId,
        @RequestParam(value = "expireTime", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date expireTime,
        @RequestParam(value = "authorityIds", required = false) String authorityIds
) {
    baseAuthorityService.addAuthorityApp(appId, expireTime, StringUtils.isNotBlank(authorityIds) ? authorityIds.split(",") : new String[]{});
    openRestTemplate.refreshGateway();
    return ResultBody.ok();
}
 
Example #12
Source File: UserController.java    From springboot-learn with MIT License 6 votes vote down vote up
@ApiOperation(value = "列表查询(分页)", notes = "列表查询(分页)")
@ApiImplicitParams({
        @ApiImplicitParam(name = "pageNum", value = "页码", required = true, defaultValue = "1", dataType = "int", paramType = "query"),
        @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = true, defaultValue = "10", dataType = "int", paramType = "query"),
        @ApiImplicitParam(name = "orderBy", value = "排序", dataType = "int", paramType = "query", example = "updateTime desc, id asc"),
        @ApiImplicitParam(name = "name", value = "用户名称", dataType = "String", paramType = "query"),
})
@GetMapping("/list")
public Result list(@RequestParam(required = false) @ApiIgnore Map<String, Object> params) {
    PageInfo<?> pageInfo = PageBuiler.builder(params);
    Result result = userService.queryPage(params, pageInfo);
    Map<String, Object> data = (Map<String, Object>) result.getData();
    List<User> userList = (List<User>) data.get(Constants.LIST);
    if (userList != null && userList.size() > 0) {
        for (User user : userList) {
            user.setPassword("");
        }
    }
    return result;
}
 
Example #13
Source File: PostsController.java    From JavaQuarkBBS with Apache License 2.0 6 votes vote down vote up
@ApiOperation("根据labelId获取帖子接口")
@ApiImplicitParams({
        @ApiImplicitParam(name = "labelid", value = "标签的id", dataType = "int"),
        @ApiImplicitParam(name = "pageNo", value = "页码[从1开始]", dataType = "int"),
        @ApiImplicitParam(name = "length", value = "返回结果数量[默认20]", dataType = "int"),
})
@GetMapping("/label/{labelid}")
public QuarkResult GetPostsByLabel(
        @PathVariable("labelid") Integer labelid,
        @RequestParam(required = false, defaultValue = "1") int pageNo,
        @RequestParam(required = false, defaultValue = "20") int length) {

    QuarkResult result = restProcessor(() -> {
        Label label = labelService.findOne(labelid);
        if (label == null) return QuarkResult.error("标签不存在");
        Page<Posts> page = postsService.getPostsByLabel(label, pageNo - 1, length);
        return QuarkResult.ok(page.getContent(), page.getTotalElements(), page.getNumberOfElements());

    });

    return result;

}
 
Example #14
Source File: IosController.java    From app-version with Apache License 2.0 6 votes vote down vote up
@ApiImplicitParams({
        @ApiImplicitParam(name = "Authorization", value = "用户登录凭证", paramType = "header", dataType = "string", defaultValue = "Bearer ", required = true),
})
@PutMapping("/{id}")
@OperationRecord(type = OperationRecordLog.OperationType.UPDATE, resource = OperationRecordLog.OperationResource.IOS_VERSION, description = OperationRecordLog.OperationDescription.UPDATE_IOS_VERSION)
public ServiceResult update(@RequestBody IosVersionRequestDTO iosVersionRequestDTO, @PathVariable int id) {
    if (id < 1) {
        return ServiceResultConstants.NEED_PARAMS;
    }
    String appVersion = iosVersionRequestDTO.getAppVersion();
    String allowLowestVersion = iosVersionRequestDTO.getAllowLowestVersion();
    //校验版本区间
    if (StringUtilsExt.hasNotBlank(allowLowestVersion, appVersion)) {
        if (basicService.compareVersion(appVersion, allowLowestVersion) < 0) {
            return ServiceResultConstants.ALLOWLOWESTVERSION_BIG_THAN_APPVERSION;
        }
    }
    IosVersion iosVersion = new IosVersion();
    BeanUtils.copyProperties(iosVersionRequestDTO, iosVersion);
    iosVersion.setId(id);
    return iosVersionService.update(iosVersion);
}
 
Example #15
Source File: SieveQuotaRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@PUT
@ApiOperation(value = "Update global sieve quota size")
@ApiImplicitParams({
        @ApiImplicitParam(required = true, dataType = "long", name = REQUESTED_SIZE, paramType = "body")
})
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "OK", response = Long.class),
        @ApiResponse(code = 400, message = "The body is not a positive integer."),
        @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
})
public void defineUpdateGlobalSieveQuota(Service service) {
    service.put(DEFAULT_QUOTA_PATH, (request, response) -> {
        QuotaSizeLimit requestedSize = extractRequestedQuotaSizeFromRequest(request);
        sieveQuotaRepository.setDefaultQuota(requestedSize);
        return Responses.returnNoContent(response);
    }, jsonTransformer);
}
 
Example #16
Source File: PanelController.java    From poseidon with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "点击商品分类,查看商品分类下的版块(包含商品)", response = PanelDto.class)
@ApiImplicitParams({
		@ApiImplicitParam(paramType = "query", dataType = "String", name = "cId", value = "商品分类id"),
		@ApiImplicitParam(paramType = "query", dataType = "Integer", name = "limit", value = "限制显示的商品数量")

})
@GetMapping(path = { "/cat/{cId}",
		"/cat/{cId}/{limit}" }, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Message panelWithItems(@PathVariable("cId") Long itemCatId,
		@PathVariable(value = "limit", required = false) Integer limit) {
	try {
		List<PanelDto> data = panelService.getPanelWithItemsByItemCatId(itemCatId,
				limit);
		return success(data);
	}
	catch (Exception e) {
		e.printStackTrace();
	}
	return failed();
}
 
Example #17
Source File: CatalogController.java    From logging-log4j-audit with Apache License 2.0 6 votes vote down vote up
@ApiImplicitParams( {@ApiImplicitParam(dataType = "String", name = "Authorization", paramType = "header")})
@ApiOperation(value = "Update a catalog Event", notes = "Updates a catalog event", tags = {"Catalog"})
@PutMapping(value = "/event", consumes=Versions.V1_0, produces=Versions.V1_0)
public ResponseEntity<Event> updateEvent(@ApiParam(value = "event", required = true) @RequestBody Event event) {
    if (event.getCatalogId() == null) {
        throw new IllegalArgumentException("A catalog id is required to update an event.");
    }
    if (DEFAULT_CATALOG.equals(event.getCatalogId())) {
        throw new IllegalArgumentException("The default catalog cannot be modified at run time.");
    }
    EventModel model;
    synchronized(this) {
        model = eventConverter.convert(event);
        model = eventService.saveEvent(model);
    }
    return new ResponseEntity<>(eventModelConverter.convert(model), HttpStatus.OK);
}
 
Example #18
Source File: ExaminationController.java    From spring-microservice-exam with MIT License 6 votes vote down vote up
/**
  * 根据考试ID获取题目分页数据
  *
  * @param pageNum    pageNum
  * @param pageSize   pageSize
  * @param sort       sort
  * @param order      order
  * @param subjectDto subjectDto
  * @return PageInfo
  * @author tangyi
  * @date 2019/6/16 15:45
  */
 @RequestMapping("subjectList")
 @ApiOperation(value = "获取题目列表")
 @ApiImplicitParams({
         @ApiImplicitParam(name = CommonConstant.PAGE_NUM, value = "分页页码", defaultValue = CommonConstant.PAGE_NUM_DEFAULT, dataType = "String"),
         @ApiImplicitParam(name = CommonConstant.PAGE_SIZE, value = "分页大小", defaultValue = CommonConstant.PAGE_SIZE_DEFAULT, dataType = "String"),
         @ApiImplicitParam(name = CommonConstant.SORT, value = "排序字段", defaultValue = CommonConstant.PAGE_SORT_DEFAULT, dataType = "String"),
         @ApiImplicitParam(name = CommonConstant.ORDER, value = "排序方向", defaultValue = CommonConstant.PAGE_ORDER_DEFAULT, dataType = "String"),
         @ApiImplicitParam(name = "subjectDto", value = "题目信息", dataType = "SubjectDto")
 })
 public PageInfo<SubjectDto> subjectList(@RequestParam(value = CommonConstant.PAGE_NUM, required = false, defaultValue = CommonConstant.PAGE_NUM_DEFAULT) String pageNum,
                                         @RequestParam(value = CommonConstant.PAGE_SIZE, required = false, defaultValue = CommonConstant.PAGE_SIZE_DEFAULT) String pageSize,
                                         @RequestParam(value = CommonConstant.SORT, required = false, defaultValue = CommonConstant.PAGE_SORT_DEFAULT) String sort,
                                         @RequestParam(value = CommonConstant.ORDER, required = false, defaultValue = CommonConstant.PAGE_ORDER_DEFAULT) String order,
SubjectDto subjectDto) {
     return examinationService.findSubjectPageById(subjectDto, pageNum, pageSize, sort, order);
 }
 
Example #19
Source File: UserController.java    From JavaQuarkBBS with Apache License 2.0 6 votes vote down vote up
@ApiOperation("登录接口")
@ApiImplicitParams({
        @ApiImplicitParam(name = "email", value = "用户邮箱",dataType = "String"),
        @ApiImplicitParam(name = "password", value = "用户密码",dataType = "String")
})
@PostMapping("/login")
public QuarkResult Login(String email,String password) {

    QuarkResult result = restProcessor(() -> {
        User loginUser = userService.findByEmail(email);
        if (loginUser == null)
            return QuarkResult.warn("用户邮箱不存在,请重新输入");
        if (!loginUser.getPassword().equals(DigestUtils.md5DigestAsHex(password.getBytes())))
            return QuarkResult.warn("用户密码错误,请重新输入");
        String token = userService.LoginUser(loginUser);
        return QuarkResult.ok(token);
    });
    return result;
}
 
Example #20
Source File: OrderController.java    From gpmall with Apache License 2.0 6 votes vote down vote up
/**
 * 获取当前用户的所有订单
 * @return
 */
@GetMapping("/order")
@ApiOperation("获取当前用户的所有订单")
@ApiImplicitParams({
        @ApiImplicitParam(name = "pageInfo", value = "分页信息", dataType = "PageInfo", required = true),
        @ApiImplicitParam(name = "servletRequest", value = "HttpServletRequest", dataType = "HttpServletRequest", required = true)
})
public ResponseData orderByCurrentId(PageInfo pageInfo,HttpServletRequest servletRequest){
    OrderListRequest request = new OrderListRequest();
    request.setPage(pageInfo.getPage());
    request.setSize(pageInfo.getSize());
    request.setSort(pageInfo.getSort());
    String userInfo=(String)servletRequest.getAttribute(TokenIntercepter.USER_INFO_KEY);
    JSONObject object= JSON.parseObject(userInfo);
    Long uid=Long.parseLong(object.get("uid").toString());
    request.setUserId(uid);
    OrderListResponse listResponse = orderQueryService.orderList(request);
    if(listResponse.getCode().equals(OrderRetCode.SUCCESS.getCode())){
        PageResponse response = new PageResponse();
        response.setData(listResponse.getDetailInfoList());
        response.setTotal(listResponse.getTotal());
        return new ResponseUtil<>().setData(response);
    }
    return new ResponseUtil<>().setErrorMsg(listResponse.getMsg());
}
 
Example #21
Source File: UserController.java    From efo with MIT License 6 votes vote down vote up
@ApiOperation(value = "登录(用户名密码和token必须有一个输入)")
@ApiImplicitParams({@ApiImplicitParam(name = "username", value = "用户名"), @ApiImplicitParam(name
        = "password", value = "密码"), @ApiImplicitParam(name = "auto", value = "是否自动登录", dataType = "Boolean"),
        @ApiImplicitParam(name = "token", value = "用于自动登录")})
@AuthInterceptor(InterceptorLevel.NONE)
@RequestMapping(value = "/login", method = RequestMethod.PUT)
public String login(String username, String password, boolean auto, String token) {
    //使用密码登录
    User user = userService.login(username, password, ValueConsts.NULL_STRING, ValueConsts.NULL_RESPONSE);
    if (Checker.isNull(user) || user.getPermission() < 1) {
        jsonObject.put("status", "failed");
    } else {
        request.getSession().setAttribute(ValueConsts.USER_STRING, user);
        jsonObject.put("status", "success");
        if (auto) {
            jsonObject.put("token", TokenConfig.generateToken(token, user.getId()));
        } else {
            jsonObject.put("token", "");
            TokenConfig.removeTokenByValue(user.getId());
        }
    }
    return jsonObject.toString();
}
 
Example #22
Source File: DomainMappingsRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@DELETE
@Path(SPECIFIC_MAPPING_PATH)
@ApiOperation(value = "Removes domain mapping between source and destination domains.")
@ApiImplicitParams({
    @ApiImplicitParam(required = true, dataType = "string", name = FROM_DOMAIN, paramType = "path")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "Ok"),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Domain name is invalid"),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
        message = "Internal server error - Something went bad on the server side.")
})
public HaltException removeDomainMapping(Request request, Response response) throws RecipientRewriteTableException {
    MappingSource mappingSource = mappingSourceFrom(request);
    Domain destinationDomain = extractDomain(request.body());

    recipientRewriteTable.removeDomainMapping(mappingSource, destinationDomain);
    return halt(HttpStatus.NO_CONTENT_204);
}
 
Example #23
Source File: DomainController.java    From hauth-java with MIT License 6 votes vote down vote up
/**
 * 查询某一个域的详细信息
 * 如果http请求的参数domain_id为空,则返回null
 */
@RequestMapping(value = "/details", method = RequestMethod.GET)
@ApiOperation(value = "查询域的详细信息", notes = "查询某一个指定域的详细定义信息,如果请求的参数为空,则返回用户自己所在域的详细信息")
@ApiImplicitParams({
        @ApiImplicitParam(required = true, name = "domain_id", value = "域编码")
})
public String getDomainDetails(HttpServletRequest request) {
    String domainId = request.getParameter("domain_id");
    if (domainId == null || domainId.isEmpty()) {
        logger.info("domain id is empty, return null");
        return null;
    }

    // 检查用户对域有没有读权限
    Boolean status = authService.domainAuth(request, domainId, "r").getStatus();
    if (status) {
        return Hret.error(403, "您没有被授权访问域【" + domainId + "】", null);
    }

    DomainEntity domainEntity = domainService.getDomainDetails(domainId);
    return new GsonBuilder().create().toJson(domainEntity);
}
 
Example #24
Source File: UserController.java    From efo with MIT License 6 votes vote down vote up
@ApiOperation(value = "重置我的密码")
@ApiImplicitParams({@ApiImplicitParam(name = "email", value = "邮箱", required = true), @ApiImplicitParam(name =
        "code", value = "验证码", required = true), @ApiImplicitParam(name = "password", value = "密码", required =
        true)})
@AuthInterceptor(InterceptorLevel.NONE)
@RequestMapping(value = "/password/reset", method = RequestMethod.PUT)
public String resetPassword(String email, String code, String password) {
    jsonObject.put("status", "error");
    if (isCodeValidate(code)) {
        if (userService.resetPasswordByEmail(email, password)) {
            jsonObject.put("status", "success");
        } else {
            jsonObject.put("message", "格式不合法");
        }
    } else {
        jsonObject.put("message", "验证码校验失败");
    }
    return jsonObject.toString();
}
 
Example #25
Source File: RoleController.java    From spring-microservice-boilerplate with MIT License 5 votes vote down vote up
@GetMapping
@ApiOperation(value = "List", httpMethod = "GET", response = RoleVO.class)
@ApiImplicitParams({
    @ApiImplicitParam(name = "Authorization", value = "token", paramType = "header", dataType = "string", required = true)
})
public ResponseEntity all() {
  try {
    return new ResponseEntity<>(roleDomain.all(), HttpStatus.OK);
  } catch (Exception e) {
    // Return unknown error and log the exception.
    return resultHelper.errorResp(logger, e, ErrorType.UNKNOWN, e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
  }
}
 
Example #26
Source File: HeartbeatController.java    From spring-microservice-boilerplate with MIT License 5 votes vote down vote up
@RequestMapping(method = RequestMethod.GET)
@ApiOperation(value = "Heartbeat", httpMethod = "GET", response = ResponseEntity.class)
@ApiImplicitParams({
    @ApiImplicitParam(name = "Authorization", value = "token", paramType = "header", dataType = "string", required = true),
    @ApiImplicitParam(name = "Limit-Key", value = "limit key", paramType = "header", dataType = "string")
})
public ResponseEntity heartbeat() {
  return ResponseEntity.ok().build();
}
 
Example #27
Source File: ArtifactsRestController.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
@ApiOperation(value = "Search artifact to KB")
@RequestMapping(value = "search/{artifact_query}", produces = { "application/json",
		"application/xml" }, method = RequestMethod.GET)
@ApiImplicitParams({ // FIXME
		@ApiImplicitParam(name = "page", dataType = "integer", paramType = "query", value = "Results page you want to retrieve (0..N)"),
		@ApiImplicitParam(name = "size", dataType = "integer", paramType = "query", value = "Number of records per page."),
		@ApiImplicitParam(name = "sort", dataType = "string", paramType = "query", value = "Sorting criteria in the format: [asc|desc]") })
public @ResponseBody List<Artifact> getProject(@PathVariable("artifact_query") String projectQuery,
		@RequestParam(value = "page", defaultValue = "0") int page,
		@RequestParam(value = "size", defaultValue = "10") int size,
		@RequestParam(value = "sort", defaultValue = "asc") String sort) {
	PageRequest pr = new PageRequest(page, size, new Sort(Arrays.asList(
			sort.equalsIgnoreCase("ASC") ? new Order(Direction.ASC, "temp") : new Order(Direction.DESC, "temp"))));
	return recommenderManager.getArtifactsByQuery(projectQuery, pr);
}
 
Example #28
Source File: ItemCartController.java    From poseidon with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "添加购物车记录", response = Boolean.class)
@ApiImplicitParams({
		@ApiImplicitParam(paramType = "insert", dataType = "ItemCartDto", name = "itemCartDto", value = "购物车记录信息") })
@PostMapping(produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Message add(@RequestBody ItemCartDto itemCartDto) {
	if (itemCartService.add(itemCartDto)) {
		return Message.success(null);
	}
	else {
		return Message.failed("添加商品到购物车失败,请重试");
	}
}
 
Example #29
Source File: GlobalQuotaRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@PUT
@ApiOperation(value = "Updating count and size at the same time")
@ApiImplicitParams({
        @ApiImplicitParam(required = true, dataTypeClass = QuotaDTO.class, paramType = "body")
})
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. The value has been updated."),
        @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "The body is not a positive integer or not unlimited value (-1)."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineUpdateQuota() {
    service.put(QUOTA_ENDPOINT, ((request, response) -> {
        try {
            QuotaDTO quotaDTO = jsonExtractor.parse(request.body());
            ValidatedQuotaDTO validatedQuotaDTO = quotaDTOValidator.validatedQuotaDTO(quotaDTO);
            globalQuotaService.defineQuota(validatedQuotaDTO);
            return Responses.returnNoContent(response);
        } catch (IllegalArgumentException e) {
            throw ErrorResponder.builder()
                .statusCode(HttpStatus.BAD_REQUEST_400)
                .type(ErrorType.INVALID_ARGUMENT)
                .message("Quota should be positive or unlimited (-1)")
                .cause(e)
                .haltError();
        }
    }));
}
 
Example #30
Source File: BurpController.java    From burp-rest-api with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@ApiOperation(value = "Get the current scan issues", notes = "Returns all of the current scan issues for URLs matching the specified urlPrefix. Performs a simple case-sensitive text match, returning all scan issues whose URL begins with the given urlPrefix. Returns all issues if urlPrefix is null.")
@ApiImplicitParams({
      @ApiImplicitParam(name = "urlPrefix", value = "URL prefix in order to extract a specific subset of scan issues.", dataType = "string", paramType = "query")
})
@ApiResponses(value = {
      @ApiResponse(code = 200, message = "Success", response = ScanIssueList.class),
      @ApiResponse(code = 500, message = "Failure")
})
@RequestMapping(method = GET, value = "/scanner/issues")
public ScanIssueList getScanIssues(@RequestParam(required = false) String urlPrefix) throws UnsupportedEncodingException {
   ScanIssueList scanIssueList = new ScanIssueList();
   scanIssueList.setScanIssues(burp.getIssues(urlPrefix));
   return scanIssueList;
}