@RequestMapping({ "helloWithOptionalName", "helloWithOptional/{name}" })
public ObjectNode helloWithOptionalName(@PathVariable Optional<String> name) {
ObjectNode resultJson = jacksonMapper.createObjectNode();
logger.info( "simple log" ) ;
if (name.isPresent() )
resultJson.put("name", name.get()) ;
else
resultJson.put( "name", "not-provided" ) ;
resultJson.put( "Response", "Hello from " + HOST_NAME + " at "
+ LocalDateTime.now().format( DateTimeFormatter.ofPattern( "HH:mm:ss, MMMM d uuuu " ) ));
return resultJson ;
}
java类org.springframework.web.bind.annotation.PathVariable的实例源码
HelloService.java 文件源码
项目:csap-core
阅读 41
收藏 0
点赞 0
评论 0
MovieController.java 文件源码
项目:movie-db-java-on-azure
阅读 45
收藏 0
点赞 0
评论 0
/**
* Get movie info by movie id.
*
* @param id movie id
* @param model spring model
* @return movie detail page
*/
@RequestMapping(value = "/movies/{id}", method = RequestMethod.GET)
public String getMovieById(@PathVariable Long id, Model model) {
Movie movie = movieRepository.getMovie(Long.toString(id));
if (movie != null) {
if (movie.getImageUri() != null) {
movie.setImageFullPathUri(
azureStorageUploader.getAzureStorageBaseUri(applicationContext) + movie.getImageUri());
}
model.addAttribute("movie", movie);
return "moviedetail";
} else {
return "moviedetailerror";
}
}
BrownFieldSiteController.java 文件源码
项目:SpringMicroservice
阅读 48
收藏 0
点赞 0
评论 0
@RequestMapping(value="/checkin/{flightNumber}/{origin}/{destination}/{flightDate}/{fare}/{firstName}/{lastName}/{gender}/{bookingid}", method=RequestMethod.GET)
public String bookQuery(@PathVariable String flightNumber,
@PathVariable String origin,
@PathVariable String destination,
@PathVariable String flightDate,
@PathVariable String fare,
@PathVariable String firstName,
@PathVariable String lastName,
@PathVariable String gender,
@PathVariable String bookingid,
Model model) {
CheckInRecord checkIn = new CheckInRecord(firstName, lastName, "28C", null,
flightDate,flightDate, new Long(bookingid).longValue());
long checkinId = checkInClient.postForObject("http://checkin-apigateway/api/checkin/create", checkIn, long.class);
model.addAttribute("message","Checked In, Seat Number is 28c , checkin id is "+ checkinId);
return "checkinconfirm";
}
LancamentoController.java 文件源码
项目:ponto-inteligente-api
阅读 35
收藏 0
点赞 0
评论 0
/**
* Atualiza os dados de um lançamento.
*
* @param id
* @param lancamentoDto
* @return ResponseEntity<Response<Lancamento>>
* @throws ParseException
*/
@PutMapping(value = "/{id}")
public ResponseEntity<Response<LancamentoDto>> atualizar(@PathVariable("id") Long id,
@Valid @RequestBody LancamentoDto lancamentoDto, BindingResult result) throws ParseException {
log.info("Atualizando lançamento: {}", lancamentoDto.toString());
Response<LancamentoDto> response = new Response<LancamentoDto>();
validarFuncionario(lancamentoDto, result);
lancamentoDto.setId(Optional.of(id));
Lancamento lancamento = this.converterDtoParaLancamento(lancamentoDto, result);
if (result.hasErrors()) {
log.error("Erro validando lançamento: {}", result.getAllErrors());
result.getAllErrors().forEach(error -> response.getErrors().add(error.getDefaultMessage()));
return ResponseEntity.badRequest().body(response);
}
lancamento = this.lancamentoService.persistir(lancamento);
response.setData(this.converterLancamentoDto(lancamento));
return ResponseEntity.ok(response);
}
TaskIdentityResource.java 文件源码
项目:plumdo-work
阅读 31
收藏 0
点赞 0
评论 0
@RequestMapping(value="/task/{taskId}/identity/{type}/{identityId}", method = RequestMethod.DELETE, name="任务候选人删除")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteIdentityLink(@PathVariable("taskId") String taskId, @PathVariable("identityId") String identityId,
@PathVariable("type") String type) {
Task task = getTaskFromRequest(taskId,false);
validateIdentityLinkArguments(identityId, type);
getIdentityLink(taskId, identityId, type);
if (TaskIdentityRequest.AUTHORIZE_GROUP.equals(type)) {
taskService.deleteGroupIdentityLink(task.getId(), identityId,IdentityLinkType.CANDIDATE);
} else if(TaskIdentityRequest.AUTHORIZE_USER.equals(type)) {
taskService.deleteUserIdentityLink(task.getId(), identityId,IdentityLinkType.CANDIDATE);
}
}
CISAdaptorConnectorRestController.java 文件源码
项目:CommonInformationSpace
阅读 48
收藏 0
点赞 0
评论 0
@ApiOperation(value = "getParticipantFromCGOR", nickname = "getParticipantFromCGOR")
@RequestMapping(value = "/CISConnector/getParticipantFromCGOR/{cgorName}", method = RequestMethod.GET)
@ApiImplicitParams({
@ApiImplicitParam(name = "cgorName", value = "the CGOR name", required = true, dataType = "String", paramType = "path"),
@ApiImplicitParam(name = "organisation", value = "the Organisation name", required = true, dataType = "String", paramType = "query")
})
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = Participant.class),
@ApiResponse(code = 400, message = "Bad Request", response = Participant.class),
@ApiResponse(code = 500, message = "Failure", response = Participant.class)})
public ResponseEntity<Participant> getParticipantFromCGOR(@PathVariable String cgorName, @QueryParam("organisation") String organisation) {
log.info("--> getParticipantFromCGOR: " + cgorName);
Participant participant;
try {
participant = connector.getParticipantFromCGOR(cgorName, organisation);
} catch (CISCommunicationException e) {
log.error("Error executing the request: Communication Error" , e);
participant = null;
}
HttpHeaders responseHeaders = new HttpHeaders();
log.info("getParticipantFromCGOR -->");
return new ResponseEntity<Participant>(participant, responseHeaders, HttpStatus.OK);
}
UserController.java 文件源码
项目:gauravbytes
阅读 44
收藏 0
点赞 0
评论 0
@PutMapping(value = "/{id}")
public ResponseEntity<User> updateUser(@PathVariable("id") long id, @RequestBody User user) {
logger.info("Updating User: {} ", user);
Optional<User> optionalUser = userService.findById(id);
if (optionalUser.isPresent()) {
User currentUser = optionalUser.get();
currentUser.setUsername(user.getUsername());
currentUser.setAddress(user.getAddress());
currentUser.setEmail(user.getEmail());
userService.updateUser(currentUser);
return ResponseEntity.ok(currentUser);
}
else {
logger.warn("User with id :{} doesn't exists", id);
return ResponseEntity.notFound().build();
}
}
ClientRegistrationEndpoint.java 文件源码
项目:simple-openid-provider
阅读 47
收藏 0
点赞 0
评论 0
@DeleteMapping(path = "/{id:.*}")
public void deleteClientConfiguration(HttpServletRequest request, HttpServletResponse response,
@PathVariable ClientID id) throws IOException {
HTTPRequest httpRequest = ServletUtils.createHTTPRequest(request);
try {
ClientDeleteRequest clientDeleteRequest = ClientDeleteRequest.parse(httpRequest);
resolveAndValidateClient(id, clientDeleteRequest);
this.clientRepository.deleteById(id);
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
catch (GeneralException e) {
ClientRegistrationResponse registrationResponse = new ClientRegistrationErrorResponse(e.getErrorObject());
ServletUtils.applyHTTPResponse(registrationResponse.toHTTPResponse(), response);
}
}
TagAppController.java 文件源码
项目:sjk
阅读 38
收藏 0
点赞 0
评论 0
@Cacheable(exp = defaultCacheTime)
@RequestMapping(value = "/tagapp/topic/{catalog}/{tagId}.json", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
@ResponseBody
public String appTagTopic(@PathVariable short catalog, @PathVariable int tagId) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
try {
Set<AppTopic> list = service.getAppTopic(tagId, catalog);
output.put("result", server);
output.put("data", list);
output.put("total", list == null ? 0 : list.size());
server.put("code", SvrResult.OK.getCode());
server.put("msg", SvrResult.OK.getMsg());
} catch (Exception e) {
server.put("code", SvrResult.ERROR.getCode());
server.put("msg", SvrResult.ERROR.getMsg());
logger.error("Exception", e);
}
return output.toJSONString(jsonStyle);
}
NamespaceBranchController.java 文件源码
项目:apollo-custom
阅读 44
收藏 0
点赞 0
评论 0
@RequestMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules",
method = RequestMethod.GET)
public GrayReleaseRuleDTO findBranchGrayRules(@PathVariable String appId,
@PathVariable String clusterName,
@PathVariable String namespaceName,
@PathVariable String branchName) {
checkBranch(appId, clusterName, namespaceName, branchName);
GrayReleaseRule rules = namespaceBranchService.findBranchGrayRules(appId, clusterName, namespaceName, branchName);
if (rules == null) {
return null;
}
GrayReleaseRuleDTO ruleDTO =
new GrayReleaseRuleDTO(rules.getAppId(), rules.getClusterName(), rules.getNamespaceName(),
rules.getBranchName());
ruleDTO.setReleaseId(rules.getReleaseId());
ruleDTO.setRuleItems(GrayReleaseRuleItemTransformer.batchTransformFromJSON(rules.getRules()));
return ruleDTO;
}
BuildController.java 文件源码
项目:mirrorgate
阅读 35
收藏 0
点赞 0
评论 0
@RequestMapping(value = "/dashboards/{name}/builds", method = GET,
produces = APPLICATION_JSON_VALUE)
public Map<String, Object> getBuildsByBoardName(@PathVariable("name") String name) {
DashboardDTO dashboard = dashboardService.getDashboard(name);
if (dashboard == null || dashboard.getCodeRepos() == null
|| dashboard.getCodeRepos().isEmpty()) {
return null;
}
List<Build> builds = buildService
.getLastBuildsByKeywordsAndByTeamMembers(
dashboard.getCodeRepos(), dashboard.getTeamMembers());
BuildStats stats = buildService.getStatsByKeywordsAndByTeamMembers(
dashboard.getCodeRepos(), dashboard.getTeamMembers());
Map<String, Object> response = new HashMap<>();
response.put("lastBuilds", builds);
response.put("stats", stats);
return response;
}
PostController.java 文件源码
项目:spring-boot-blog
阅读 37
收藏 0
点赞 0
评论 0
/**
* Edit post with provided id.
* It is not possible to edit if the user is not authenticated
* and if he is now the owner of the post
*
* @param id
* @param principal
* @return post model and postForm view, for editing post
*/
@RequestMapping(value = "/editPost/{id}", method = RequestMethod.GET)
public ModelAndView editPostWithId(@PathVariable Long id, Principal principal) {
ModelAndView modelAndView = new ModelAndView();
Post post = postService.findPostForId(id);
// Not possible to edit if user is not logged in, or if he is now the owner of the post
if (principal == null || !principal.getName().equals(post.getUser().getUsername())) {
modelAndView.setViewName("403");
}
if (post == null) {
modelAndView.setViewName("404");
} else {
modelAndView.addObject("post", post);
modelAndView.setViewName("postForm");
}
return modelAndView;
}
UploadController.java 文件源码
项目:Learning-Spring-Boot-2.0-Second-Edition
阅读 40
收藏 0
点赞 0
评论 0
@GetMapping(value = BASE_PATH + "/" + FILENAME + "/raw",
produces = MediaType.IMAGE_JPEG_VALUE)
@ResponseBody
public Mono<ResponseEntity<?>> oneRawImage(
@PathVariable String filename) {
// tag::try-catch[]
return imageService.findOneImage(filename)
.map(resource -> {
try {
return ResponseEntity.ok()
.contentLength(resource.contentLength())
.body(new InputStreamResource(
resource.getInputStream()));
} catch (IOException e) {
return ResponseEntity.badRequest()
.body("Couldn't find " + filename +
" => " + e.getMessage());
}
});
// end::try-catch[]
}
ApiController.java 文件源码
项目:kafka-webview
阅读 40
收藏 0
点赞 0
评论 0
/**
* GET Details for a specific Topic.
*/
@ResponseBody
@RequestMapping(path = "/cluster/{id}/topic/{topic}/details", method = RequestMethod.GET, produces = "application/json")
public TopicDetails getTopicDetails(@PathVariable final Long id, @PathVariable final String topic) {
// Retrieve cluster
final Cluster cluster = clusterRepository.findOne(id);
if (cluster == null) {
throw new NotFoundApiException("TopicDetails", "Unable to find cluster");
}
// Create new Operational Client
try (final KafkaOperations operations = createOperationsClient(cluster)) {
return operations.getTopicDetails(topic);
} catch (final Exception e) {
throw new ApiException("TopicDetails", e);
}
}
NamespaceBranchController.java 文件源码
项目:apollo-custom
阅读 45
收藏 0
点赞 0
评论 0
@RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}", method = RequestMethod.DELETE)
public void deleteBranch(@PathVariable String appId,
@PathVariable String env,
@PathVariable String clusterName,
@PathVariable String namespaceName,
@PathVariable String branchName) {
boolean canDelete = permissionValidator.hasReleaseNamespacePermission(appId, namespaceName) ||
(permissionValidator.hasModifyNamespacePermission(appId, namespaceName) &&
releaseService.loadLatestRelease(appId, Env.valueOf(env), branchName, namespaceName) == null);
if (!canDelete) {
throw new AccessDeniedException("Forbidden operation. "
+ "Caused by: 1.you don't have release permission "
+ "or 2. you don't have modification permission "
+ "or 3. you have modification permission but branch has been released");
}
namespaceBranchService.deleteBranch(appId, Env.valueOf(env), clusterName, namespaceName, branchName);
}
RestControllerAdminUser.java 文件源码
项目:sporticus
阅读 37
收藏 0
点赞 0
评论 0
/**
* Function to delete a user -
* Only the administrators can perform this operation
*
* @param id
* @return ResponseEntity<DtoUser>
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public ResponseEntity<DtoUser> deleteOne(@PathVariable("id") final long id) {
if (!this.getLoggedInUser().isAdmin()) {
LOGGER.error(() -> "Users can only be deleted by system administrators");
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
}
final IUser found = serviceUser.findOne(id);
if (found == null) {
LOGGER.warn(() -> "User with id " + id + " not found");
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
LOGGER.debug(() -> "Deleting User with id " + id);
serviceUser.deleteUser(found.getId());
return new ResponseEntity<>(getDtoUser(found), HttpStatus.OK);
}
DictController.java 文件源码
项目:DAFramework
阅读 32
收藏 0
点赞 0
评论 0
@RequestMapping(value="type/{type}")
public ActionResultObj findByType(@PathVariable String type){
ActionResultObj result = new ActionResultObj();
try{
if(StringUtil.isNotBlank(type)){
List<EDict> dictList = dictDao.query(Cnd.where("type", "=", type).and("del_flag", "=", Constans.POS_NEG.NEG).orderBy("sort", "asc"));
//处理返回值
WMap map = new WMap();
map.put("type", type);
map.put("data", dictList);
result.ok(map);
result.okMsg("查询成功!");
}else{
result.errorMsg("查询失败,字典类型不存在!");
}
}catch(Exception e){
e.printStackTrace();
LOG.error("查询失败,原因:"+e.getMessage());
result.error(e);
}
return result;
}
MeetingRoomController.java 文件源码
项目:agile-wroking-backend
阅读 34
收藏 0
点赞 0
评论 0
/**
* 创新排期,单 JVM 并发量可期的情况下,简单粗暴的使用 synchronized 来解决并发创建、更新排期的问题.
*
* @param id 会议室 id
* @param schedule 新建的排期
*/
@RequestMapping(path = "/meetingRooms/{id}/schedule", method = RequestMethod.POST)
public synchronized Result<Schedule> createOrUpdateSchedule(@PathVariable(name = "id") Long id,
@RequestParam(name = "formId", required = false) String formId, @RequestBody Schedule schedule) {
MeetingRoom meetingRoom = meetingRoomRepository.findOne(id);
validate(id, schedule);
if (null == schedule.getId()) {
schedule.setMeetingRoom(meetingRoom);
schedule.addParticipant(creatorAsParticipant(schedule, formId));
scheduleRepository.save(schedule);
} else {
Schedule s = scheduleRepository.findOne(schedule.getId());
Assert.notNull(s, "修改的排期不存在.");
s.setTitle(schedule.getTitle());
s.setStartTime(schedule.getStartTime());
s.setEndTime(schedule.getEndTime());
s.setDate(schedule.getDate());
s.setRepeatMode(schedule.getRepeatMode());
scheduleRepository.save(s);
}
return DefaultResult.newResult(schedule);
}
GroupController.java 文件源码
项目:opencron
阅读 39
收藏 0
点赞 0
评论 0
@RequestMapping("edit/{groupId}.htm")
public String edit(@PathVariable("groupId")Long groupId, Model model) {
Group group = groupService.getById(groupId);
List<Group> groups = groupService.getGroupforAgent();
model.addAttribute("group",group);
model.addAttribute("groups",groups);
return "/group/edit";
}
UserController.java 文件源码
项目:product-management-system
阅读 34
收藏 0
点赞 0
评论 0
/**
* Return json-information about all users in database.
*/
@GetMapping("/{id}")
@ResponseStatus(HttpStatus.OK)
public UserDto loadUserById(@PathVariable final String id) {
log.info("Start loadUserById: {}", id);
return mapper.map(userService.find(id), UserDto.class);
}
ImportStatusController.java 文件源码
项目:omero-ms-queue
阅读 38
收藏 0
点赞 0
评论 0
@RequestMapping(method = GET, value = "{" + ImportIdPathVar + "}")
public ResponseEntity<String> getStatusUpdate(
@PathVariable(value=ImportIdPathVar) String importId,
HttpServletResponse response) throws IOException {
ImportId taskId = new ImportId(importId);
Path importLog = service.importLogPathFor(taskId).get();
FileStreamer streamer = new FileStreamer(importLog,
MediaType.TEXT_PLAIN,
Caches::doNotCache);
return streamer.streamOr404(response);
}
BotStatusController.java 文件源码
项目:bxbot-ui-server
阅读 43
收藏 0
点赞 0
评论 0
/**
* Returns the Bot status for a given Bot id.
*
* @param user the authenticated user.
* @param botId the id of the Bot to fetch.
* @return the Bot status for the given id.
*/
@PreAuthorize("hasRole('USER')")
@RequestMapping(value = "/{botId}" + STATUS_RESOURCE_PATH, method = RequestMethod.GET)
public ResponseEntity<?> getBotStatus(@AuthenticationPrincipal User user, @PathVariable String botId) {
LOG.info("GET " + RUNTIME_ENDPOINT_BASE_URI + botId + STATUS_RESOURCE_PATH + " - getBotStatus()"); // - caller: " + user.getUsername());
final BotStatus botStatus = botProcessService.getBotStatus(botId);
return botStatus == null
? new ResponseEntity<>(HttpStatus.NOT_FOUND)
: buildResponseEntity(botStatus, HttpStatus.OK);
}
DepartmentController.java 文件源码
项目:Spring-5.0-Cookbook
阅读 35
收藏 0
点赞 0
评论 0
@RequestMapping(value="/updatedept.html/{id}", method=RequestMethod.POST)
public String updateRecordSubmit(Model model, @ModelAttribute("departmentForm") DepartmentForm departmentForm, @PathVariable("id") Integer id ){
departmentServiceImpl.updateDepartment(departmentForm, id);
model.addAttribute("departments", departmentServiceImpl.readDepartments());
return "dept_result";
}
SaleWebController.java 文件源码
项目:SaleWeb
阅读 48
收藏 0
点赞 0
评论 0
@GetMapping("/articulo/{id}/eliminar")
public String eliminarArticulo (Model model, @PathVariable long id){
Articulo articulo = articulo_repository.findOne(id);
articulo_repository.delete(articulo);
model.addAttribute("articulos", articulo_repository.findAll());
return "articulo_eliminado";
}
UserApi.java 文件源码
项目:ci-hands-on
阅读 43
收藏 0
点赞 0
评论 0
@RequestMapping(value = "/{user_id}", method = GET)
public ResponseEntity<UserView> get(@PathVariable("user_id") final String userId)
{
Optional<User> userOptional = userRemoteService.get(userId);
if (userOptional.isPresent()) {
UserView userView = userMapper.map(userOptional.get(), UserView.class);
return ResponseEntity.ok(userView);
}
return ResponseEntity.notFound().build();
}
W3CProtocolController.java 文件源码
项目:SilkAppDriver
阅读 33
收藏 0
点赞 0
评论 0
/**
* Implements the "Go" command See https://www.w3.org/TR/webdriver/#dfn-go
*/
@RequestMapping(value = "/session/{sessionId}/url", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
public @ResponseBody ResponseEntity<Response> go(@PathVariable String sessionId,
@RequestBody(required = false) String body) throws Throwable {
LOGGER.info("go -->");
LOGGER.info(" -> " + body);
LOGGER.info(" <- ERROR: unknown command");
LOGGER.info("go <--");
return responseFactory.error(sessionId, ProtocolError.UNKNOWN_COMMAND);
}
TElementController.java 文件源码
项目:FCat
阅读 46
收藏 0
点赞 0
评论 0
/**
* 通过menuId获取元素列表
* @return
* @throws RuntimeException
*/
@ApiOperation(value = "通过menuId获取元素列表" )
@RequestMapping(value = "getByMenuId/{menuId}", method = RequestMethod.GET)
public JSONObject getByMenuId(@PathVariable Integer menuId)throws Exception{
List<TElement> result = bsi.getListByMenuId(menuId);
return JsonUtil.getSuccessJsonObject(result);
}
FaqController.java 文件源码
项目:karanotes
阅读 33
收藏 0
点赞 0
评论 0
@RequestMapping(value="/extra/user/deletefaq/{faqid}")
public ResultBody deleteFaq(@PathVariable String faqid) throws GlobalErrorInfoException{
try {
faqinfoServiceImpl.deleteFaqinfo(faqid);
} catch (Exception e) {
e.printStackTrace();
logger.debug(e);
throw new GlobalErrorInfoException(NodescribeErrorInfoEnum.NO_DESCRIBE_ERROR);
}
return new ResultBody(new HashMap<>());
}
FinancialController.java 文件源码
项目:Practical-Microservices
阅读 38
收藏 0
点赞 0
评论 0
@RequestMapping(method = RequestMethod.POST, value = "{userId}/obligation", produces = "application/json", consumes = "application/json")
public ResponseEntity<String> addObligationDetails(@RequestBody ObligationDetails obligationDetails, @PathVariable("userId") UUID userId) {
logger.debug(addObligationDetails + " Creating user's obligation with Id " + userId + " and details : " + obligationDetails);
obligationDetails.setUserId(userId.toString());
financialService.saveObligation(obligationDetails);
return new ResponseEntity<>(HttpStatus.CREATED);
}
CustomerController.java 文件源码
项目:microservice-kubernetes
阅读 40
收藏 0
点赞 0
评论 0
@RequestMapping(value = "/{id}.html", method = RequestMethod.PUT)
public ModelAndView put(@PathVariable("id") long id, Customer customer,
HttpServletRequest httpRequest) {
customer.setId(id);
customerRepository.save(customer);
return new ModelAndView("success");
}