use of com.zyd.blog.business.annotation.BussinessLog in project OneBlog by zhangyd-c.
the class RestUserController method add.
@RequiresPermissions("user:add")
@PostMapping(value = "/add")
@BussinessLog("添加用户")
public ResponseVO add(User user) {
User u = userService.getByUserName(user.getUsername());
if (u != null) {
return ResultUtil.error("该用户名[" + user.getUsername() + "]已存在!请更改用户名");
}
try {
user.setPassword(PasswordUtil.encrypt(user.getPassword(), user.getUsername()));
userService.insert(user);
return ResultUtil.success("成功");
} catch (Exception e) {
e.printStackTrace();
return ResultUtil.error("error");
}
}
use of com.zyd.blog.business.annotation.BussinessLog in project OneBlog by zhangyd-c.
the class RenderController method edit.
@RequiresPermissions("article:publish")
@BussinessLog(value = "进入修改文章页[id={1}]")
@GetMapping("/article/update/{id}")
public ModelAndView edit(@PathVariable("id") Long id, Model model) {
model.addAttribute("id", id);
Article article = articleService.getByPrimaryKey(id);
if (!Arrays.asList("we", "md", "tiny").contains(article.getEditorType())) {
throw new ZhydException("文章异常,未知的编辑器类型");
}
return ResultUtil.view("article/publish-" + article.getEditorType());
}
use of com.zyd.blog.business.annotation.BussinessLog in project OneBlog by zhangyd-c.
the class RestApiController method uploadFileForMd.
@BussinessLog("simpleMD编辑器中上传文件")
@RequiresPermissions("article:publish")
@PostMapping("/uploadFileForMd")
public Object uploadFileForMd(@RequestParam("file") MultipartFile file) {
FileUploader uploader = new GlobalFileUploader();
VirtualFile virtualFile = uploader.upload(file, FileUploadType.SIMPLE.getPath(), true);
Map<String, Object> resultMap = new HashMap<>(3);
resultMap.put("success", 1);
resultMap.put("message", "上传成功");
resultMap.put("filename", virtualFile.getFullFilePath());
return resultMap;
}
use of com.zyd.blog.business.annotation.BussinessLog in project OneBlog by zhangyd-c.
the class RestArticleController method pushToBaidu.
@RequiresPermissions(value = { "article:batchPush", "article:push" }, logical = Logical.OR)
@PostMapping(value = "/pushToBaidu/{type}")
@BussinessLog("推送文章[{2}]到百度站长平台")
public ResponseVO pushToBaidu(@PathVariable("type") BaiduPushTypeEnum type, Long[] ids) {
if (null == ids) {
return ResultUtil.error(500, "请至少选择一条记录");
}
Map config = configService.getConfigs();
String siteUrl = (String) config.get(ConfigKeyEnum.SITE_URL.getKey());
StringBuilder params = new StringBuilder();
for (Long id : ids) {
params.append(siteUrl).append("/article/").append(id).append("\n");
}
// urls: 推送, update: 更新, del: 删除
String url = UrlBuildUtil.getBaiduPushUrl(type.toString(), (String) config.get(ConfigKeyEnum.SITE_URL.getKey()), (String) config.get(ConfigKeyEnum.BAIDU_PUSH_TOKEN.getKey()));
String result = BaiduPushUtil.doPush(url, params.toString(), (String) config.get(ConfigKeyEnum.BAIDU_PUSH_COOKIE.getKey()));
log.info(result);
JSONObject resultJson = JSONObject.parseObject(result);
if (resultJson.containsKey("error")) {
return ResultUtil.error(resultJson.getString("message"));
}
return ResultUtil.success(null, result);
}
use of com.zyd.blog.business.annotation.BussinessLog in project OneBlog by zhangyd-c.
the class RestCommentController method audit.
@RequiresPermissions("comment:audit")
@PostMapping("/audit")
@BussinessLog("审核评论")
public ResponseVO audit(Comment comment, String contentText, Boolean sendEmail) {
try {
commentService.updateSelective(comment);
if (!StringUtils.isEmpty(contentText)) {
comment.setContent(contentText);
commentService.commentForAdmin(comment);
}
if (null != sendEmail && sendEmail) {
Comment commentDB = commentService.getByPrimaryKey(comment.getId());
mailService.send(commentDB, TemplateKeyEnum.TM_COMMENT_AUDIT, true);
}
} catch (Exception e) {
e.printStackTrace();
return ResultUtil.error("评论审核失败!");
}
return ResultUtil.success(ResponseStatus.SUCCESS);
}
Aggregations