本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}