use of com.dimple.framework.aspectj.lang.annotation.Log in project DimpleBlog by martin-chips.
the class SettingController method editSiteSetting.
@PutMapping("siteSetting")
@PreAuthorize("@permissionService.hasPermission('system:setting:siteSetting:edit')")
@Log(title = "系统设置-网站设置", businessType = BusinessType.UPDATE)
public AjaxResult editSiteSetting(@RequestBody SiteSetting siteSetting) {
String jsonString = JSON.toJSONString(siteSetting);
Config config = new Config();
config.setConfigKey(ConfigKey.CONFIG_KEY_SITE_SETTING);
config.setConfigValue(jsonString);
return AjaxResult.success(configService.updateConfigByConfigKey(config));
}
use of com.dimple.framework.aspectj.lang.annotation.Log in project DimpleBlog by martin-chips.
the class LogAspect method handleLog.
/**
* for log record
*
* @param joinPoint join point
* @param e exception
* @param jsonResult result
* @param cost the time of this method cost
*/
protected void handleLog(final JoinPoint joinPoint, final Exception e, Object jsonResult, long cost) {
try {
// get annotation
Log controllerLog = getAnnotationLog(joinPoint);
if (controllerLog == null) {
return;
}
// get current user from servlet
LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
OperateLog operateLog = new OperateLog();
operateLog.setStatus(Constants.SUCCESS);
// get the IP of this request
operateLog.setIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
// get result with JSON format
operateLog.setJsonResult(JSON.toJSONString(jsonResult));
operateLog.setCost(cost);
operateLog.setUrl(ServletUtils.getRequest().getRequestURI());
if (loginUser != null) {
operateLog.setOperateName(loginUser.getUsername());
}
if (e != null) {
operateLog.setStatus(Constants.FAILED);
operateLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000));
}
// get the class name
String className = joinPoint.getTarget().getClass().getName();
// get method name
String methodName = joinPoint.getSignature().getName();
operateLog.setMethod(StringUtils.format("{}.{}()", className, methodName));
// get request method
operateLog.setRequestMethod(ServletUtils.getRequest().getMethod());
// set method args
getControllerMethodDescription(joinPoint, controllerLog, operateLog);
// save log
AsyncManager.me().execute(AsyncFactory.recordOperateLog(operateLog));
} catch (Exception exception) {
log.error("get exception in handleLog,{} ", exception.getMessage(), exception);
}
}
use of com.dimple.framework.aspectj.lang.annotation.Log in project DimpleBlog by martin-chips.
the class CarouselController method changeDisplay.
@PreAuthorize("@permissionService.hasPermission('system:carousel:edit')")
@Log(title = "轮播图管理", businessType = BusinessType.UPDATE)
@PutMapping("/{id}/display/{display}")
public AjaxResult changeDisplay(@PathVariable Long id, @PathVariable Boolean display) {
Carousel carousel = new Carousel();
carousel.setDisplay(display);
carousel.setId(id);
return toAjax(carouselService.updateCarousel(carousel));
}
use of com.dimple.framework.aspectj.lang.annotation.Log in project DimpleBlog by martin-chips.
the class CarouselController method changeTarget.
@PreAuthorize("@permissionService.hasPermission('system:carousel:edit')")
@Log(title = "轮播图管理", businessType = BusinessType.UPDATE)
@PutMapping("/{id}/target/{target}")
public AjaxResult changeTarget(@PathVariable Long id, @PathVariable Boolean target) {
Carousel carousel = new Carousel();
carousel.setTarget(target);
carousel.setId(id);
return toAjax(carouselService.updateCarousel(carousel));
}
use of com.dimple.framework.aspectj.lang.annotation.Log in project DimpleBlog by martin-chips.
the class ProfileController method updatePwd.
/**
* 重置密码
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
public AjaxResult updatePwd(String oldPassword, String newPassword) {
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
String userName = loginUser.getUsername();
String password = loginUser.getPassword();
if (!SecurityUtils.matchesPassword(oldPassword, password)) {
return AjaxResult.error("修改密码失败,旧密码错误");
}
if (SecurityUtils.matchesPassword(newPassword, password)) {
return AjaxResult.error("新密码不能与旧密码相同");
}
return toAjax(userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)));
}
Aggregations