use of com.zyd.blog.business.annotation.BussinessLog in project OneBlog by zhangyd-c.
the class PassportController method submitLogin.
/**
* 登录
*
* @param username
* @param password
* @return
*/
@BussinessLog("[{1}]登录系统")
@PostMapping("/signin")
@ResponseBody
public ResponseVO submitLogin(String username, String password, boolean rememberMe, String kaptcha) {
if (config.isEnableKaptcha()) {
if (StringUtils.isEmpty(kaptcha) || !kaptcha.equals(SessionUtil.getKaptcha())) {
return ResultUtil.error("验证码错误!");
}
SessionUtil.removeKaptcha();
}
UsernamePasswordToken token = new UsernamePasswordToken(username, password, rememberMe);
// 获取当前的Subject
Subject currentUser = SecurityUtils.getSubject();
try {
// 在调用了login方法后,SecurityManager会收到AuthenticationToken,并将其发送给已配置的Realm执行必须的认证检查
// 每个Realm都能在必要时对提交的AuthenticationTokens作出反应
// 所以这一步在调用login(token)方法时,它会走到xxRealm.doGetAuthenticationInfo()方法中,具体验证方式详见此方法
currentUser.login(token);
SavedRequest savedRequest = WebUtils.getSavedRequest(RequestHolder.getRequest());
String historyUrl = null;
if (null != savedRequest) {
if (!savedRequest.getMethod().equals("POST")) {
historyUrl = savedRequest.getRequestUrl();
}
}
return ResultUtil.success(null, historyUrl);
} catch (Exception e) {
log.error("登录失败,用户名[{}]:{}", username, e.getMessage());
token.clear();
return ResultUtil.error(e.getMessage());
}
}
use of com.zyd.blog.business.annotation.BussinessLog in project OneBlog by zhangyd-c.
the class RestApiController method uploadFile.
@BussinessLog("wangEditor编辑器中上传文件")
@RequiresPermissions("article:publish")
@PostMapping("/uploadFile")
public ResponseVO uploadFile(@RequestParam("file") MultipartFile file) {
FileUploader uploader = new GlobalFileUploader();
VirtualFile virtualFile = uploader.upload(file, FileUploadType.SIMPLE.getPath(), true);
return ResultUtil.success("图片上传成功", virtualFile.getFullFilePath());
}
use of com.zyd.blog.business.annotation.BussinessLog in project OneBlog by zhangyd-c.
the class BussinessLogAspect method handle.
private void handle(ProceedingJoinPoint point) throws Exception {
Method currentMethod = AspectUtil.INSTANCE.getMethod(point);
// 获取操作名称
BussinessLog annotation = currentMethod.getAnnotation(BussinessLog.class);
boolean save = annotation.save();
PlatformEnum platform = annotation.platform();
String bussinessName = AspectUtil.INSTANCE.parseParams(point.getArgs(), annotation.value());
String ua = RequestUtil.getUa();
log.info("{} | {} - {} {} - {}", bussinessName, RequestUtil.getIp(), RequestUtil.getMethod(), RequestUtil.getRequestUrl(), ua);
if (!save) {
return;
}
logService.asyncSaveSystemLog(platform, bussinessName);
}
use of com.zyd.blog.business.annotation.BussinessLog in project OneBlog by zhangyd-c.
the class RenderController method type.
/**
* 分类列表
*
* @param typeId
* @param model
* @return
*/
@GetMapping("/type/{typeId}")
@BussinessLog(value = "进入文章分类[{1}]列表页", platform = PlatformEnum.WEB)
public ModelAndView type(@PathVariable("typeId") Long typeId, Model model) {
ArticleConditionVO vo = new ArticleConditionVO();
vo.setTypeId(typeId);
model.addAttribute("url", "type/" + typeId);
loadIndexPage(vo, model);
return ResultUtil.view(INDEX_URL);
}
use of com.zyd.blog.business.annotation.BussinessLog in project OneBlog by zhangyd-c.
the class RestApiController method qq.
@PostMapping("/qq/{qq}")
@BussinessLog(value = "获取QQ信息", platform = PlatformEnum.WEB)
public ResponseVO qq(@PathVariable("qq") String qq) {
if (StringUtils.isEmpty(qq)) {
return ResultUtil.error("");
}
Map<String, String> resultMap = new HashMap<>(4);
String nickname = "匿名";
String json = RestClientUtil.get("https://r.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?uins=" + qq, "GBK");
if (!StringUtils.isEmpty(json)) {
try {
json = json.replaceAll("portraitCallBack|\\\\s*|\\t|\\r|\\n", "");
json = json.substring(1, json.length() - 1);
log.info(json);
JSONObject object = JSONObject.parseObject(json);
JSONArray array = object.getJSONArray(qq);
nickname = array.getString(6);
} catch (Exception e) {
log.error("通过QQ号获取用户昵称发生异常", e);
}
}
resultMap.put("avatar", "https://q1.qlogo.cn/g?b=qq&nk=" + qq + "&s=40");
resultMap.put("nickname", nickname);
resultMap.put("email", qq + "@qq.com");
resultMap.put("url", "https://user.qzone.qq.com/" + qq);
return ResultUtil.success(null, resultMap);
}
Aggregations