org.springframework.web.bind.annotation.RequestMapping Java Examples

The following examples show how to use org.springframework.web.bind.annotation.RequestMapping. 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: UserController.java    From maven-framework-project with MIT License 6 votes vote down vote up
@RequestMapping(value="/update", method=RequestMethod.POST)
public @ResponseBody User update(
		@RequestParam String username,
		@RequestParam String firstName,
		@RequestParam String lastName,
		@RequestParam Integer role) {

	Role existingRole = new Role();
	existingRole.setRole(role);
	
	User existingUser = new User();
	existingUser.setUsername(username);
	existingUser.setFirstName(firstName);
	existingUser.setLastName(lastName);
	existingUser.setRole(existingRole);
	
	return service.update(existingUser);
}
 
Example #2
Source File: AppManageController.java    From cachecloud with Apache License 2.0 6 votes vote down vote up
/**
* 添加slave节点
* 
* @param appId
* @param masterInstanceId
* @param slaveHost
* @return
*/
  @RequestMapping(value = "/addSlave")
  public void addSlave(HttpServletRequest request, HttpServletResponse response, Model model, long appId,
          int masterInstanceId, String slaveHost) {
      AppUser appUser = getUserInfo(request);
      logger.warn("user {} addSlave: appId:{},masterInstanceId:{},slaveHost:{}", appUser.getName(), appId, masterInstanceId, slaveHost);
      boolean success = false;
      if (appId > 0 && StringUtils.isNotBlank(slaveHost) && masterInstanceId > 0) {
          try {
              success = redisDeployCenter.addSlave(appId, masterInstanceId, slaveHost);
          } catch (Exception e) {
              logger.error(e.getMessage(), e);
          }
      } 
      logger.warn("user {} addSlave: appId:{},masterInstanceId:{},slaveHost:{} result is {}", appUser.getName(), appId, masterInstanceId, slaveHost, success);
      write(response, String.valueOf(success == true ? SuccessEnum.SUCCESS.value() : SuccessEnum.FAIL.value()));
  }
 
Example #3
Source File: DTSController.java    From dtsopensource with Apache License 2.0 6 votes vote down vote up
/**
 * 申购
 * 
 * @param productName
 * @param orderAmount
 * @param currentAmount
 * @param response
 */
@RequestMapping(value = "/purchase", method = RequestMethod.GET)
public void puchase(@RequestParam String productName, @RequestParam BigDecimal orderAmount,
                    @RequestParam BigDecimal currentAmount, HttpServletResponse response) {
    response.setHeader("Content-type", "text/html;charset=UTF-8");
    try {
        this.sysout(response, "购买商品:[" + new String(productName.getBytes("iso8859-1"), "utf-8") + "],订单金额:["
                + orderAmount + "],账户余额:[" + currentAmount + "]");
        PurchaseContext context = new PurchaseContext();
        context.setCurrentAmount(currentAmount);
        context.setOrderAmount(orderAmount);
        context.setProductName(new String(productName.getBytes("iso8859-1"), "utf-8"));
        log.info(context.toString());
        String activityId = purchaseService.puchase(context);
        this.sysout(response, "业务活动ID:" + activityId);
        List<String> list = tradeLog.getNewLog(activityId);
        for (String an : list) {
            this.sysout(response, an);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
 
Example #4
Source File: ApiController.java    From kafka-webview with MIT License 6 votes vote down vote up
/**
 * POST list all consumer groups for a specific cluster.
 * This should require ADMIN role.
 */
@ResponseBody
@RequestMapping(path = "/cluster/{id}/consumer/remove", method = RequestMethod.POST, produces = "application/json")
public boolean removeConsumer(
    @PathVariable final Long id,
    @RequestBody final ConsumerRemoveRequest consumerRemoveRequest) {

    // Retrieve cluster
    final Cluster cluster = retrieveClusterById(consumerRemoveRequest.getClusterId());

    try (final KafkaOperations operations = createOperationsClient(cluster)) {
        return operations.removeConsumerGroup(consumerRemoveRequest.getConsumerId());
    } catch (final Exception exception) {
        throw new ApiException("ClusterNodes", exception);
    }
}
 
Example #5
Source File: SysLogController.java    From EasyEE with MIT License 6 votes vote down vote up
/**
 * 分页查询
 * 
 * @return
 * @throws Exception
 */
@SuppressWarnings("rawtypes")
@RequestMapping("list")
public Map<Object, Object> list(SysLogCriteria sysLogCriteria) throws Exception {
	String sort = ServletRequestUtils.getStringParameter(request, "sort", "");
	String order = ServletRequestUtils.getStringParameter(request, "order", "");

	if (!isNotNullAndEmpty(sort)) {
		sort = "logTime";
	}
	if (!isNotNullAndEmpty(order)) {
		order = "desc";
	}

	PageBean pb = super.getPageBean(); // 获得分页对象
	pb.setSort(sort);
	pb.setSortOrder(order);
	sysLogService.findByPage(pb, sysLogCriteria);

	return super.setJsonPaginationMap(pb);
}
 
Example #6
Source File: GateController.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
    * <p>
    * The dispatch method that allows the teacher to view the status of the gate. It is expecting the caller passed in
    * lesson id and gate activity id as http parameter. Otherwise, the utility method will generate some exception.
    * </p>
    *
    * <p>
    * Based on the lesson id and gate activity id, it sets up the gate form to show the waiting learners and the total
    * waiting learners. Regarding schedule gate, it also shows the estimated gate opening time and gate closing time.
    * </p>
    *
    * <b>Note:</b> gate form attribute <code>waitingLearners</code> got setup after the view is dispatch to ensure
    * there won't be casting exception occur if the activity id is not a gate by chance.
    */
   @RequestMapping("/viewGate")
   public String viewGate(@ModelAttribute GateForm gateForm, HttpServletRequest request,
    HttpServletResponse response) {
// if this is the initial call then activity id will be in the request, otherwise
// get it from the form (if being called from openGate.jsp
Long gateIdLong = WebUtil.readLongParam(request, AttributeNames.PARAM_ACTIVITY_ID, true);
if (gateIdLong == null) {
    gateIdLong = gateForm.getActivityId();
}
long gateId = gateIdLong != null ? gateIdLong.longValue() : -1;

GateActivity gate = (GateActivity) monitoringService.getActivityById(gateId);

if (gate == null) {
    throw new MonitoringServiceException("Gate activity missing. Activity id" + gateId);
}

gateForm.setActivityId(gateIdLong);

return findViewByGateType(gateForm, gate);
   }
 
Example #7
Source File: StubCartController.java    From DataHubSystem with GNU Affero General Public License v3.0 6 votes vote down vote up
@RequestMapping (value = "/users/{userid}/cart/{cartid}/getcount",
   method = RequestMethod.GET)
public int countProductsInCart(Principal principal,
   @PathVariable (value = "userid") String userid,
   @PathVariable (value = "cartid") String cartid)
      throws ProductCartServiceException
{
   User user = (User)((UsernamePasswordAuthenticationToken) principal).
      getPrincipal();
   fr.gael.dhus.service.ProductCartService productCartService =
      ApplicationContextProvider.getBean(
         fr.gael.dhus.service.ProductCartService.class);

   try
   {
      return productCartService.countProductsInCart(user.getUUID());
   }
   catch (Exception e)
   {
      e.printStackTrace();
      throw new ProductCartServiceException(e.getMessage());
   }
}
 
Example #8
Source File: IndexController.java    From kob with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = {"/change_project.htm"})
public String changeProject(Model model) {
    HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    User user = (User) request.getSession().getAttribute(Attribute.SESSION_USER);
    List<ProjectUser> projectUserList = indexService.selectProjectUserByUserCode(user.getCode());
    request.getSession().setAttribute(Attribute.PROJECT_LIST, projectUserList);
    String projectCode = request.getParameter("project_code");
    if (!KobUtils.isEmpty(projectUserList)) {
        for (ProjectUser projectUser : projectUserList) {
            if (projectUser.getProjectCode().equals(projectCode)) {
                request.getSession().setAttribute(Attribute.PROJECT_SELECTED, projectUser);
                return welcome(model);
            }
        }
    }
    return welcome(model);
}
 
Example #9
Source File: Log4JController.java    From GreenSummer with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Reset.
 *
 * @return the response entity
 */
@RequestMapping(value = "reset", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET, headers = "Accept=application/json")
@ResponseBody
public ResponseEntity<LogResponse> reset() {
    final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
    synchronized (ctx) {
        // If the config location is null, it means we are using a non-standard path for 
        // the config file (for example log4j2-spring.xml. In this case the name of the configuration
        // is usually the path to the configuration file. so we "fix" the path before reconfiguring
        if (ctx.getConfigLocation() == null) {
            ctx.setConfigLocation(Paths.get(ctx.getConfiguration().getName()).toUri());
        }
        ctx.reconfigure();
        initInMemoryAppender();
    }
    return new ResponseEntity<>(listLoggers(ctx), HttpStatus.OK);
}
 
Example #10
Source File: ConsoleUserController.java    From console with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unused")
@RequestMapping("/deleteConsoleUserByUserids")
@ResponseBody
public int deleteConsoleUserByUserids(HttpServletRequest request) {
    long startTime = System.currentTimeMillis();
    int nRows = 0;
    String _sUserIds = request.getParameter("userIds");
    String type = request.getParameter("type");
    if (!StringUtils.isNull(_sUserIds)) {
        nRows = consoleUserService.deleteConsoleUserUserIds(_sUserIds);
        boolean flag = false; // define opear result
        if (nRows != 0)
            flag = true;
    }

    return nRows;
}
 
Example #11
Source File: RegistrationController.java    From website with GNU Affero General Public License v3.0 6 votes vote down vote up
@RequestMapping(value = "/register", method = RequestMethod.POST)
public String register(Model model, @Valid UserRegistration userRegistration, BindingResult result) {
	User user = userRegistration.getUser();
	model.addAttribute("userRegistration", userRegistration);
	model.addAttribute("currencies", currencyService.getCurrencies());
	model.addAttribute("countries", countryService.getCountries());
	int captcha1 = (int)(Math.random() * ((9 - 0) + 1));
	int captcha2 = (int)(Math.random() * ((9 - 0) + 1));
	int captchaAnswer = captcha1 + captcha2;
	model.addAttribute("captcha1", captcha1);
	model.addAttribute("captcha2", captcha2);
	model.addAttribute("captchaAnswer", captchaAnswer);
	if (result.hasErrors()) {
		return "register";
	}
	userRegistration.applyUserRoles();
	saveUser(user, userRegistration.getCompany(), userRegistration.getAddress());		
	authenticationService.authenticateUser(user);
	emailGateway.userRegistration(user);
	model.addAttribute("user", user);
	return "registration/complete";
}
 
Example #12
Source File: AdminController.java    From pacbot with Apache License 2.0 6 votes vote down vote up
/**
    * API to enable disable rule or job
    * 
    * @author NKrishn3
    * @param ruleId - valid rule or job Id
    * @param user - userId who performs the action
    * @param action - valid action (disable/ enable)
    * @return Success or Failure response
    */
@ApiOperation(httpMethod = "POST", value = "API to enable disable rule or job", response = Response.class, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(path = "/enable-disable", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Object> enableDisableRuleOrJob(@AuthenticationPrincipal Principal user,
		@ApiParam(value = "provide valid rule id", required = false) @RequestParam(name = "ruleId", required = false) String ruleId,
		@ApiParam(value = "provide valid job id", required = false) @RequestParam(name = "jobId", required = false) String jobId,
		@ApiParam(value = "provide valid action", required = true) @RequestParam(name = "action", required = true) String action) {
	try {
		
		if (!StringUtils.isBlank(ruleId)) {
			return ResponseUtils.buildSucessResponse(ruleService.enableDisableRule(ruleId, action, user.getName()));
		} else if (!StringUtils.isBlank(jobId)) {
			return ResponseUtils.buildSucessResponse(jobService.enableDisableJob(jobId, action, user.getName()));
		} else {
			return ResponseUtils.buildFailureResponse(new Exception(UNEXPECTED_ERROR_OCCURRED), JOBID_OR_RULEID_NOT_EMPTY);
		}
	} catch (Exception exception) {
		log.error(UNEXPECTED_ERROR_OCCURRED, exception);
		return ResponseUtils.buildFailureResponse(new Exception(UNEXPECTED_ERROR_OCCURRED), exception.getMessage());
	}
}
 
Example #13
Source File: CommonsSpiderPanel.java    From Gather-Platform with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 所有的抓取任务列表
 *
 * @return
 */
@RequestMapping(value = "tasks", method = RequestMethod.GET)
public ModelAndView tasks(@RequestParam(required = false, defaultValue = "false") boolean showRunning) {
    ModelAndView modelAndView = new ModelAndView("panel/commons/listTasks");
    ResultListBundle<Task> listBundle;
    if (!showRunning) {
        listBundle = commonsSpiderService.getTaskList(true);
    } else {
        listBundle = commonsSpiderService.getTasksFilterByState(State.RUNNING, true);
    }
    ResultBundle<Long> runningTaskCount = commonsSpiderService.countByState(State.RUNNING);
    modelAndView.addObject("resultBundle", listBundle);
    modelAndView.addObject("runningTaskCount", runningTaskCount.getResult());
    modelAndView.addObject("spiderInfoList", listBundle.getResultList().stream()
            .map(task -> StringEscapeUtils.escapeHtml4(
                    gson.toJson(task.getExtraInfoByKey("spiderInfo")
                    ))
            ).collect(Collectors.toList()));
    return modelAndView;
}
 
Example #14
Source File: LearningController.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
    * Same as submitRankingHedging but doesn't update the records.
    *
    * @throws IOException
    * @throws ServletException
    *
    */
   @RequestMapping("/nextPrev")
   @SuppressWarnings("unchecked")
   public String nextPrev(HttpServletRequest request, HttpSession session) throws IOException, ServletException {

String sessionMapID = request.getParameter(PeerreviewConstants.ATTR_SESSION_MAP_ID);
request.setAttribute(PeerreviewConstants.ATTR_SESSION_MAP_ID, sessionMapID);

SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) session.getAttribute(sessionMapID);

ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.ATTR_MODE);
PeerreviewUser user = (PeerreviewUser) sessionMap.get(PeerreviewConstants.ATTR_USER);
Long toolSessionId = (Long) sessionMap.get(PeerreviewConstants.PARAM_TOOL_SESSION_ID);

Long criteriaId = WebUtil.readLongParam(request, "criteriaId");
RatingCriteria criteria = service.getCriteriaByCriteriaId(criteriaId);

request.setAttribute(PeerreviewConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());
request.setAttribute(AttributeNames.ATTR_MODE, mode);
request.setAttribute(PeerreviewConstants.PARAM_TOOL_SESSION_ID, toolSessionId);

Boolean next = WebUtil.readBooleanParam(request, "next");

// goto standard screen
return startRating(request, session, sessionMap, toolSessionId, user, mode, criteria, next);
   }
 
Example #15
Source File: RequestTestController.java    From spring-boot-projects with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/test2", method = RequestMethod.GET)
public List<User> test2() {
    List<User> users = new ArrayList<>();
    User user1 = new User();
    user1.setId(1);
    user1.setName("十一");
    user1.setPassword("12121");
    User user2 = new User();
    user2.setId(2);
    user2.setName("十二");
    user2.setPassword("21212");
    User user3 = new User();
    user3.setId(3);
    user3.setName("十三");
    user3.setPassword("31313");
    users.add(user1);
    users.add(user2);
    users.add(user3);
    return users;
}
 
Example #16
Source File: PreparationAPI.java    From data-prep with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/api/preparations/{preparationId}/unlock", method = PUT, produces = APPLICATION_JSON_VALUE)
@ApiOperation(value = "Mark a preparation as unlocked by a user.",
        notes = "Does not return any value, client may expect successful operation based on HTTP status code.")
@Timed
public void unlockPreparation(@PathVariable(value = "preparationId") @ApiParam(name = "preparationId",
        value = "Preparation id.") final String preparationId) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Locking preparation #{}...", preparationId);
    }

    final HystrixCommand<Void> command = getCommand(PreparationUnlock.class, preparationId);
    command.execute();

    if (LOG.isDebugEnabled()) {
        LOG.debug("Locked preparation #{}...", preparationId);
    }
}
 
Example #17
Source File: FqTopicController.java    From feiqu-opensource with Apache License 2.0 5 votes vote down vote up
/**
 * ajax删除FqTopic
 */
@ResponseBody
@RequestMapping("/delete")
public Object delete(@RequestParam Integer fqTopicId) {
    BaseResult result = new BaseResult();
    fqTopicService.deleteByPrimaryKey(fqTopicId);
    return result;
}
 
Example #18
Source File: UserController.java    From jeecg with Apache License 2.0 5 votes vote down vote up
/**
 * 检查用户邮箱
 * @param request
 * @return
 */
@RequestMapping(params="checkUserEmail")
@ResponseBody
public ValidForm checkUserEmail(HttpServletRequest request){
	ValidForm validForm = new ValidForm();
	String email=oConvertUtils.getString(request.getParameter("param"));
	String code=oConvertUtils.getString(request.getParameter("code"));
	List<TSUser> userList=systemService.findByProperty(TSUser.class,"email",email);
	if(userList.size()>0&&!code.equals(email))
	{
		validForm.setInfo("邮箱已绑定相关用户信息");
		validForm.setStatus("n");
	}
	return validForm;
}
 
Example #19
Source File: UserController.java    From zkdoctor with Apache License 2.0 5 votes vote down vote up
/**
 * 获取所有用户信息
 *
 * @return
 */
@RequestMapping("/listAll")
@ResponseBody
public ConResult getAllUsers() {
    try {
        List<User> list = userService.getAllUsersByParams(null);
        return ConResult.success(list);
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        return ConResult.fail("获取所有用户信息失败,请查看相关日志信息。");
    }
}
 
Example #20
Source File: ScriptRunnerController.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Starts a Script. Will redirect the request to the jobs controller, showing the progress of the
 * started {@link ScriptJobExecution}. The Script's output will be written to the log of the
 * {@link ScriptJobExecution}. If the Script has an outputFile, the URL of that file will be
 * written to the {@link ScriptJobExecution#getResultUrl()}
 *
 * @param scriptName name of the Script to start
 * @param parameters parameter values for the script
 * @throws IOException if an input or output exception occurs when redirecting
 */
@SuppressWarnings("java:S3752") // backwards compatability: multiple methods required
@RequestMapping(
    method = {RequestMethod.GET, RequestMethod.POST},
    value = "/scripts/{name}/start")
public void startScript(
    @PathVariable("name") String scriptName,
    @RequestParam Map<String, Object> parameters,
    HttpServletResponse response)
    throws IOException {
  String scriptJobExecutionHref = submitScript(scriptName, parameters).getBody();

  response.sendRedirect(jobsController.createJobExecutionViewHref(scriptJobExecutionHref, 1000));
}
 
Example #21
Source File: ExampleController.java    From Aooms with Apache License 2.0 5 votes vote down vote up
/**
 * 配置文件值获取
 */
@RequestMapping("/example3")
public void example3(){
    PropertyObject propertyObject = Aooms.self().getPropertyObject();
    // PropertyApplication 也可使用@Autowired直接注入
    PropertyApplication propertyApplication = propertyObject.getApplicationProperty();
    logger.info("appName = {}", propertyApplication.getName());
}
 
Example #22
Source File: ScreenController.java    From AIDR with GNU Affero General Public License v3.0 5 votes vote down vote up
@RequestMapping("protected/administration/admin-console")
public ModelAndView adminConsole(Map<String, String> model) throws Exception {
    UserAccount user = getAuthenticatedUser();
    if (!userService.isUserAdmin(user)){
        return new ModelAndView("redirect:/protected/access-error");
    }

    return new ModelAndView( "administration/admin-console");
}
 
Example #23
Source File: TestController.java    From java-course-ee with MIT License 5 votes vote down vote up
@RequestMapping(method = RequestMethod.GET, value = "/welcome")
public String test(Model model, Principal principal) {
    String name = principal.getName();
    model.addAttribute("username", name);
    model.addAttribute("message", "Spring Security Hello World");
    return "test";

}
 
Example #24
Source File: StoreApi.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "successful operation", response = Order.class),
    @ApiResponse(code = 400, message = "Invalid Order") })
@RequestMapping(value = "/store/order",
    produces = { "application/xml", "application/json" }, 
    method = RequestMethod.POST)
ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true )   @RequestBody Order body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
 
Example #25
Source File: WelcomeAct.java    From Lottery with GNU General Public License v2.0 5 votes vote down vote up
@RequestMapping("/top.do")
public String top(HttpServletRequest request, ModelMap model) {
	// 需要获得站点列表
	List<CmsSite> siteList = cmsSiteMng.getList();
	CmsSite site = CmsUtils.getSite(request);
	CmsUser user = CmsUtils.getUser(request);
	model.addAttribute("siteList", siteList);
	model.addAttribute("site", site);
	model.addAttribute("siteParam", AdminContextInterceptor.SITE_PARAM);
	model.addAttribute("user", user);
	return "top";
}
 
Example #26
Source File: ServiceController.java    From Spring-5.0-Cookbook with MIT License 5 votes vote down vote up
@RequestMapping(value="/web/employeeList.json", produces ="application/json", method = RequestMethod.GET, headers = {"Accept=text/xml, application/json"})
@ResponseBody
public WebAsyncTask<List<Employee>> jsonEmpList(){
   
    Callable<List<Employee>> callable = new Callable<List<Employee>>() {
        public List<Employee> call() throws Exception {
            Thread.sleep(3000); 
            logger.info("ServiceController#jsonEmpList task started.");
            System.out.println("jsonEmpList task executor: " + Thread.currentThread().getName());
            return employeeServiceImpl.readEmployees().get(50000, TimeUnit.MILLISECONDS);
        }
    };
    return new WebAsyncTask<List<Employee>>(5000, callable);
}
 
Example #27
Source File: RepairController.java    From jeewx with Apache License 2.0 5 votes vote down vote up
/** 
 * @Description repair
 */
@RequestMapping(params = "repair")
public ModelAndView repair() {
	repairService.deleteAndRepair();
	systemService.initAllTypeGroups();   //初始化缓存
	return new ModelAndView("login/login");
}
 
Example #28
Source File: UserPrizeService.java    From xmfcn-spring-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * getUserPrize(获取奖品信息单条数据-服务)
 *
 * @param userPrize
 * @return
 * @author rufei.cn
 */
@RequestMapping("getUserPrize")
public UserPrize getUserPrize(@RequestBody UserPrize userPrize) {
    UserPrize ret = null;
    String parms = JSON.toJSONString(userPrize);
    logger.info("getUserPrize(获取奖品信息单条数据-服务) 开始 parms={}", parms);
    if (userPrize == null) {
        return ret;
    }
    ret = userPrizeHelperService.getSignleUserPrize(userPrize);
    logger.info("getUserPrize(获取奖品信息单条数据-服务) 结束 ");
    return ret;
}
 
Example #29
Source File: MiaoshaController.java    From goods-seckill with Apache License 2.0 5 votes vote down vote up
@RequestMapping("verifyCode")
@ResponseBody
public Result<String> verifyCode(HttpServletResponse response) throws Exception {
    Long goodsId = 1L;
    Long userId = 1011955828648882178L;

    BufferedImage image = miaoshaService.createMiaoshaVerfyCode(userId, goodsId);

    ServletOutputStream outputStream = response.getOutputStream();
    ImageIO.write(image, "JPEG", outputStream);
    outputStream.flush();
    outputStream.close();

    return null;
}
 
Example #30
Source File: HelloWorldController.java    From Spring-Boot-2-Fundamentals with MIT License 5 votes vote down vote up
/**
 * Produce JSON from a map as return value. Can also be nested.
 */
@RequestMapping("/api/greeting/mapJson")
@ResponseBody
public Map<String, Object> mapJson() {
    Map<String, Object> result = new HashMap<>();
    result.put("message", "Hello from map");
    return result;
}