当前位置: 首页>>代码示例>>Java>>正文


Java RequestUtil类代码示例

本文整理汇总了Java中com.zheng.common.util.RequestUtil的典型用法代码示例。如果您正苦于以下问题:Java RequestUtil类的具体用法?Java RequestUtil怎么用?Java RequestUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RequestUtil类属于com.zheng.common.util包,在下文中一共展示了RequestUtil类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: comment

import com.zheng.common.util.RequestUtil; //导入依赖的package包/类
/**
 * 新增回复
 * @param articleId
 * @param cmsComment
 * @param request
 * @return
 */
@RequestMapping(value = "/comment/{articleId}", method = RequestMethod.POST)
@ResponseBody
public Object comment(@PathVariable("articleId") int articleId, CmsComment cmsComment, HttpServletRequest request) {
    // 系统id
    CmsSystemExample cmsSystemExample = new CmsSystemExample();
    cmsSystemExample.createCriteria()
            .andCodeEqualTo(CODE);
    CmsSystem system = cmsSystemService.selectFirstByExample(cmsSystemExample);
    long time = System.currentTimeMillis();
    cmsComment.setCtime(time);
    cmsComment.setArticleId(articleId);
    cmsComment.setUserId(USERID);
    cmsComment.setStatus((byte) 1);
    cmsComment.setIp(RequestUtil.getIpAddr(request));
    cmsComment.setAgent(request.getHeader("User-Agent"));
    cmsComment.setSystemId(system.getSystemId());
    int count = cmsCommentService.insertSelective(cmsComment);
    return new CmsResult(CmsResultConstant.SUCCESS, count);
}
 
开发者ID:youngMen1,项目名称:-Spring-SpringMVC-Mybatis-,代码行数:27,代码来源:NewsController.java

示例2: answer

import com.zheng.common.util.RequestUtil; //导入依赖的package包/类
/**
 * 新增回复
 * @param articleId
 * @param cmsComment
 * @param request
 * @return
 */
@RequestMapping(value = "/answer/{articleId}", method = RequestMethod.POST)
@ResponseBody
public Object answer(@PathVariable("articleId") int articleId, CmsComment cmsComment, HttpServletRequest request) {
    // 系统id
    CmsSystemExample cmsSystemExample = new CmsSystemExample();
    cmsSystemExample.createCriteria()
            .andCodeEqualTo(CODE);
    CmsSystem system = cmsSystemService.selectFirstByExample(cmsSystemExample);
    long time = System.currentTimeMillis();
    cmsComment.setCtime(time);
    cmsComment.setArticleId(articleId);
    cmsComment.setUserId(USERID);
    cmsComment.setStatus((byte) 1);
    cmsComment.setIp(RequestUtil.getIpAddr(request));
    cmsComment.setAgent(request.getHeader("User-Agent"));
    cmsComment.setSystemId(system.getSystemId());
    int count = cmsCommentService.insertSelective(cmsComment);
    return new CmsResult(CmsResultConstant.SUCCESS, count);
}
 
开发者ID:youngMen1,项目名称:-Spring-SpringMVC-Mybatis-,代码行数:27,代码来源:QaController.java

示例3: notifyUrl

import com.zheng.common.util.RequestUtil; //导入依赖的package包/类
@RequestMapping("/notifyUrl")
@ResponseBody
public Object notifyUrl(HttpServletRequest request) throws Exception {
    Map<String, String> parameterMap = RequestUtil.getParameterMap(request);
    // 验签
    boolean signVerified = AlipaySignature.rsaCheckV1(
            parameterMap,
            PropertiesFileUtil.getInstance().get("alipay.alipay_public_key"),
            PropertiesFileUtil.getInstance().get("alipay.charset"),
            PropertiesFileUtil.getInstance().get("alipay.sign_type"));
    if (!signVerified) {
        return PayConstant.FAILED;
    }
    return PayConstant.SUCCESS;
}
 
开发者ID:ChangyiHuang,项目名称:shuzheng,代码行数:16,代码来源:AlipayController.java

示例4: doAround

import com.zheng.common.util.RequestUtil; //导入依赖的package包/类
@Around("execution(* *..controller..*.*(..))")
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
	// 获取request
	RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
	ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) requestAttributes;
	HttpServletRequest request = servletRequestAttributes.getRequest();

	UpmsLog upmsLog = new UpmsLog();
	// 从注解中获取操作名称、获取响应结果
	Object result = pjp.proceed();
	Signature signature = pjp.getSignature();
	MethodSignature methodSignature = (MethodSignature) signature;
	Method method = methodSignature.getMethod();
	if (method.isAnnotationPresent(ApiOperation.class)) {
		ApiOperation log = method.getAnnotation(ApiOperation.class);
		upmsLog.setDescription(log.value());
	}
	if (method.isAnnotationPresent(RequiresPermissions.class)) {
		RequiresPermissions requiresPermissions = method.getAnnotation(RequiresPermissions.class);
		String[] permissions = requiresPermissions.value();
		if (permissions.length > 0) {
			upmsLog.setPermissions(permissions[0]);
		}
	}
	endTime = System.currentTimeMillis();
	_log.debug("doAround>>>result={},耗时:{}", result, endTime - startTime);

	upmsLog.setBasePath(RequestUtil.getBasePath(request));
	upmsLog.setIp(RequestUtil.getIpAddr(request));
	upmsLog.setMethod(request.getMethod());
	if (request.getMethod().equalsIgnoreCase("GET")) {
		upmsLog.setParameter(request.getQueryString());
	} else {
		upmsLog.setParameter(ObjectUtils.toString(request.getParameterMap()));
	}
	upmsLog.setResult(JSON.toJSONString(result));
	upmsLog.setSpendTime((int) (endTime - startTime));
	upmsLog.setStartTime(startTime);
	upmsLog.setUri(request.getRequestURI());
	upmsLog.setUrl(ObjectUtils.toString(request.getRequestURL()));
	upmsLog.setUserAgent(request.getHeader("User-Agent"));
	upmsLog.setUsername(ObjectUtils.toString(request.getUserPrincipal()));
	upmsApiService.insertUpmsLogSelective(upmsLog);
	return result;
}
 
开发者ID:youngMen1,项目名称:-Spring-SpringMVC-Mybatis-,代码行数:46,代码来源:LogAspect.java

示例5: doAround

import com.zheng.common.util.RequestUtil; //导入依赖的package包/类
@Around("execution(* *..controller..*.*(..))")
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
	// 获取request
	RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
	ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) requestAttributes;
	HttpServletRequest request = servletRequestAttributes.getRequest();

	UpmsLog upmsLog = new UpmsLog();
	// 从注解中获取操作名称、获取响应结果
	Object result = pjp.proceed();
	Signature signature = pjp.getSignature();
	MethodSignature methodSignature = (MethodSignature) signature;
	Method method = methodSignature.getMethod();
	if (method.isAnnotationPresent(ApiOperation.class)) {
		ApiOperation log = method.getAnnotation(ApiOperation.class);
		upmsLog.setDescription(log.value());
	}
	if (method.isAnnotationPresent(RequiresPermissions.class)) {
		RequiresPermissions requiresPermissions = method.getAnnotation(RequiresPermissions.class);
		String[] permissions = requiresPermissions.value();
		if (permissions.length > 0) {
			upmsLog.setPermissions(permissions[0]);
		}
	}
	endTime = System.currentTimeMillis();
	LOGGER.debug("doAround>>>result={},耗时:{}", result, endTime - startTime);

	upmsLog.setBasePath(RequestUtil.getBasePath(request));
	upmsLog.setIp(RequestUtil.getIpAddr(request));
	upmsLog.setMethod(request.getMethod());
	if ("GET".equalsIgnoreCase(request.getMethod())) {
		upmsLog.setParameter(request.getQueryString());
	} else {
		upmsLog.setParameter(ObjectUtils.toString(request.getParameterMap()));
	}
	upmsLog.setResult(JSON.toJSONString(result));
	upmsLog.setSpendTime((int) (endTime - startTime));
	upmsLog.setStartTime(startTime);
	upmsLog.setUri(request.getRequestURI());
	upmsLog.setUrl(ObjectUtils.toString(request.getRequestURL()));
	upmsLog.setUserAgent(request.getHeader("User-Agent"));
	upmsLog.setUsername(ObjectUtils.toString(request.getUserPrincipal()));
	upmsApiService.insertUpmsLogSelective(upmsLog);
	return result;
}
 
开发者ID:ChangyiHuang,项目名称:shuzheng,代码行数:46,代码来源:LogAspect.java


注:本文中的com.zheng.common.util.RequestUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。