mirror of https://github.com/halo-dev/halo
👽 代码优化
parent
99e204fb18
commit
b7d7e9fa1c
|
@ -94,6 +94,7 @@ public interface PostService {
|
|||
|
||||
/**
|
||||
* 根据文章状态查询 分页,首页分页
|
||||
*
|
||||
* @param pageable pageable
|
||||
* @return Page
|
||||
*/
|
||||
|
|
|
@ -20,11 +20,11 @@ import java.util.Optional;
|
|||
@Service
|
||||
public class AttachmentServiceImpl implements AttachmentService {
|
||||
|
||||
private static final String ATTACHMENTS_CACHE_NAME = "attachments";
|
||||
|
||||
@Autowired
|
||||
private AttachmentRepository attachmentRepository;
|
||||
|
||||
private static final String ATTACHMENTS_CACHE_NAME = "attachments";
|
||||
|
||||
/**
|
||||
* 新增附件信息
|
||||
*
|
||||
|
|
|
@ -22,11 +22,11 @@ import java.util.Optional;
|
|||
@Service
|
||||
public class CommentServiceImpl implements CommentService {
|
||||
|
||||
private static final String COMMENTS_CACHE_NAME = "comments";
|
||||
|
||||
@Autowired
|
||||
private CommentRepository commentRepository;
|
||||
|
||||
private static final String COMMENTS_CACHE_NAME = "comments";
|
||||
|
||||
/**
|
||||
* 新增评论
|
||||
*
|
||||
|
|
|
@ -20,11 +20,11 @@ import java.util.Optional;
|
|||
@Service
|
||||
public class GalleryServiceImpl implements GalleryService {
|
||||
|
||||
private static final String GALLERIES_CACHE_NAME = "galleries";
|
||||
|
||||
@Autowired
|
||||
private GalleryRepository galleryRepository;
|
||||
|
||||
private static final String GALLERIES_CACHE_NAME = "galleries";
|
||||
|
||||
/**
|
||||
* 保存图片
|
||||
*
|
||||
|
|
|
@ -18,13 +18,13 @@ import java.util.Optional;
|
|||
@Service
|
||||
public class LinkServiceImpl implements LinkService {
|
||||
|
||||
@Autowired
|
||||
private LinkRepository linkRepository;
|
||||
|
||||
private static final String LINKS_CACHE_KEY = "'link'";
|
||||
|
||||
private static final String LINKS_CACHE_NAME = "links";
|
||||
|
||||
@Autowired
|
||||
private LinkRepository linkRepository;
|
||||
|
||||
/**
|
||||
* 新增/修改友情链接
|
||||
*
|
||||
|
|
|
@ -18,13 +18,13 @@ import java.util.Optional;
|
|||
@Service
|
||||
public class MenuServiceImpl implements MenuService {
|
||||
|
||||
@Autowired
|
||||
private MenuRepository menuRepository;
|
||||
|
||||
private static final String MENUS_CACHE_KEY = "'menu'";
|
||||
|
||||
private static final String MENUS_CACHE_NAME = "menus";
|
||||
|
||||
@Autowired
|
||||
private MenuRepository menuRepository;
|
||||
|
||||
/**
|
||||
* 查询所有菜单
|
||||
*
|
||||
|
|
|
@ -30,11 +30,11 @@ import java.util.Optional;
|
|||
@Service
|
||||
public class PostServiceImpl implements PostService {
|
||||
|
||||
private static final String POSTS_CACHE_NAME = "posts";
|
||||
|
||||
@Autowired
|
||||
private PostRepository postRepository;
|
||||
|
||||
private static final String POSTS_CACHE_NAME = "posts";
|
||||
|
||||
/**
|
||||
* 保存文章
|
||||
*
|
||||
|
|
|
@ -215,7 +215,7 @@ public class AdminController extends BaseController {
|
|||
try {
|
||||
logsService.removeAllLogs();
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:" + e.getMessage());
|
||||
log.error("清除日志失败:{}" + e.getMessage());
|
||||
}
|
||||
return "redirect:/admin";
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ public class AttachmentController {
|
|||
result.put("message", "上传成功!");
|
||||
result.put("url", attachment.getAttachPath());
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:", e.getMessage());
|
||||
log.error("上传文件失败:{}", e.getMessage());
|
||||
e.printStackTrace();
|
||||
result.put("success", 0);
|
||||
result.put("message", "上传失败!");
|
||||
|
|
|
@ -107,7 +107,7 @@ public class BackupController {
|
|||
log.info("当前时间:"+DateUtil.now()+",执行了数据库备份。");
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(), "备份成功!");
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:", e.getMessage());
|
||||
log.error("备份数据库失败:{}", e.getMessage());
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "备份失败!");
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ public class BackupController {
|
|||
log.info("当前时间:"+DateUtil.now()+",执行了资源文件备份。");
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(), "备份成功!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("备份资源文件失败:{}", e.getMessage());
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "备份失败!");
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ public class BackupController {
|
|||
log.info("当前时间:"+DateUtil.now()+",执行了文章备份。");
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(), "备份成功!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("备份文章失败:{}", e.getMessage());
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "备份失败!");
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ public class BackupController {
|
|||
content.put("size", HaloUtils.parseSize(file.length()));
|
||||
mailService.sendAttachMail(user.getUserEmail(), "有新的备份!", content, "common/mail/mail_attach.ftl", srcPath);
|
||||
} catch (Exception e) {
|
||||
log.error("邮件服务器未配置:", e.getMessage());
|
||||
log.error("邮件服务器未配置:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class CategoryController {
|
|||
try {
|
||||
categoryService.saveByCategory(category);
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{0}", e.getMessage());
|
||||
log.error("修改分类失败:{0}", e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/category";
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public class CategoryController {
|
|||
Category category = categoryService.removeByCateId(cateId);
|
||||
log.info("删除的分类目录:" + category);
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{}", e.getMessage());
|
||||
log.error("删除分类失败:{}", e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/category";
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import cn.hutool.core.date.DateUtil;
|
|||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.http.HtmlUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -92,13 +93,14 @@ public class CommentController extends BaseController {
|
|||
*/
|
||||
@GetMapping(value = "/throw")
|
||||
public String moveToTrash(@PathParam("commentId") Long commentId,
|
||||
@PathParam("status") String status) {
|
||||
@PathParam("status") String status,
|
||||
@RequestParam(value = "page",defaultValue = "0") Integer page) {
|
||||
try {
|
||||
commentService.updateCommentStatus(commentId, CommentStatus.RECYCLE.getCode());
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{}", e.getMessage());
|
||||
log.error("删除评论失败:{}", e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/comments?status=" + status;
|
||||
return "redirect:/admin/comments?status=" + status+"&page="+page;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -153,13 +155,14 @@ public class CommentController extends BaseController {
|
|||
*/
|
||||
@GetMapping("/remove")
|
||||
public String moveToAway(@PathParam("commentId") Long commentId,
|
||||
@PathParam("status") Integer status) {
|
||||
@PathParam("status") Integer status,
|
||||
@RequestParam(value = "page",defaultValue = "0") Integer page) {
|
||||
try {
|
||||
commentService.removeByCommentId(commentId);
|
||||
} catch (Exception e) {
|
||||
log.error("删除评论失败:{}", e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/comments?status=" + status;
|
||||
return "redirect:/admin/comments?status=" + status+"&page="+page;
|
||||
}
|
||||
|
||||
|
||||
|
@ -200,7 +203,7 @@ public class CommentController extends BaseController {
|
|||
comment.setCommentAuthorAvatarMd5(SecureUtil.md5(user.getUserEmail()));
|
||||
comment.setCommentDate(DateUtil.date());
|
||||
String lastContent = "<a href='#comment-id-" + lastComment.getCommentId() + "'>@" + lastComment.getCommentAuthor() + "</a> ";
|
||||
comment.setCommentContent(lastContent + OwoUtil.markToImg(commentContent));
|
||||
comment.setCommentContent(lastContent + OwoUtil.markToImg(HtmlUtil.encode(commentContent)));
|
||||
comment.setCommentAgent(userAgent);
|
||||
comment.setCommentParent(commentId);
|
||||
comment.setCommentStatus(CommentStatus.PUBLISHED.getCode());
|
||||
|
@ -228,7 +231,7 @@ public class CommentController extends BaseController {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("回复评论失败!{}", e.getMessage());
|
||||
log.error("回复评论失败:{}", e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/comments";
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class MenuController {
|
|||
try {
|
||||
menuService.saveByMenu(menu);
|
||||
} catch (Exception e) {
|
||||
log.error("保存菜单失败:" + e.getMessage());
|
||||
log.error("保存菜单失败:{}" + e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/menus";
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public class MenuController {
|
|||
try {
|
||||
menuService.removeByMenuId(menuId);
|
||||
} catch (Exception e) {
|
||||
log.error("删除菜单失败:{0}", e.getMessage());
|
||||
log.error("删除菜单失败:{}", e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/menus";
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class OptionController {
|
|||
log.info("所保存的设置选项列表:" + options);
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(),"保存成功!");
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{0}", e.getMessage());
|
||||
log.error("保存设置选项失败:{}", e.getMessage());
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"保存失败!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,10 +99,9 @@ public class PageController {
|
|||
@PostMapping(value = "/links/save")
|
||||
public String saveLink(@ModelAttribute Link link) {
|
||||
try {
|
||||
Link backLink = linkService.saveByLink(link);
|
||||
log.info("保存成功,数据为:" + backLink);
|
||||
linkService.saveByLink(link);
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:", e.getMessage());
|
||||
log.error("保存/修改友情链接失败:{}", e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/page/links";
|
||||
}
|
||||
|
@ -116,10 +115,9 @@ public class PageController {
|
|||
@GetMapping(value = "/links/remove")
|
||||
public String removeLink(@PathParam("linkId") Long linkId) {
|
||||
try {
|
||||
Link link = linkService.removeByLinkId(linkId);
|
||||
log.info("删除的友情链接:" + link);
|
||||
linkService.removeByLinkId(linkId);
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:", e.getMessage());
|
||||
log.error("删除友情链接失败:", e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/page/links";
|
||||
}
|
||||
|
@ -180,18 +178,18 @@ public class PageController {
|
|||
* 删除图库中的图片
|
||||
*
|
||||
* @param galleryId 图片编号
|
||||
* @return true:删除成功,false:删除失败
|
||||
* @return JsonResult
|
||||
*/
|
||||
@GetMapping(value = "/gallery/remove")
|
||||
@ResponseBody
|
||||
public boolean removeGallery(@RequestParam("galleryId") Long galleryId) {
|
||||
public JsonResult removeGallery(@RequestParam("galleryId") Long galleryId) {
|
||||
try {
|
||||
galleryService.removeByGalleryId(galleryId);
|
||||
} catch (Exception e) {
|
||||
log.error("删除图片失败:{0}", e.getMessage());
|
||||
return false;
|
||||
log.error("删除图片失败:{}", e.getMessage());
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "删除失败!");
|
||||
}
|
||||
return true;
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(), "删除成功!");
|
||||
}
|
||||
|
||||
|
||||
|
@ -234,7 +232,7 @@ public class PageController {
|
|||
logsService.saveByLogs(new Logs(LogsRecord.PUSH_PAGE, post.getPostTitle(), ServletUtil.getClientIP(request), DateUtil.date()));
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(),msg);
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{}", e.getMessage());
|
||||
log.error("保存页面失败:{}", e.getMessage());
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"保存失败");
|
||||
}
|
||||
}
|
||||
|
@ -257,16 +255,16 @@ public class PageController {
|
|||
* 检查该路径是否已经存在
|
||||
*
|
||||
* @param postUrl postUrl
|
||||
* @return true or false
|
||||
* @return JsonResult
|
||||
*/
|
||||
@GetMapping(value = "/checkUrl")
|
||||
@ResponseBody
|
||||
public boolean checkUrlExists(@PathParam("postUrl") String postUrl) {
|
||||
public JsonResult checkUrlExists(@PathParam("postUrl") String postUrl) {
|
||||
Post post = postService.findByPostUrl(postUrl, PostType.POST_TYPE_PAGE.getDesc());
|
||||
// TODO 还没写完
|
||||
if (null != post || StringUtils.equals("archives", postUrl) || StringUtils.equals("galleries", postUrl)) {
|
||||
return true;
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "该路径已经存在!");
|
||||
}
|
||||
return false;
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(), "");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ public class PostController extends BaseController {
|
|||
Pageable pageable = PageRequest.of(page, size, sort);
|
||||
model.addAttribute("posts", postService.searchPosts(keyword, pageable));
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:", e.getMessage());
|
||||
log.error("未知错误:{}", e.getMessage());
|
||||
}
|
||||
return "admin/admin_post";
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ public class PostController extends BaseController {
|
|||
//提取摘要
|
||||
int postSummary = 50;
|
||||
if (StringUtils.isNotEmpty(BlogProperties.POST_SUMMARY.getProp())) {
|
||||
postSummary = Integer.parseInt(BlogProperties.POST_SUMMARY.getProp());
|
||||
postSummary = Integer.parseInt(HaloConst.OPTIONS.get(BlogProperties.POST_SUMMARY.getProp()));
|
||||
}
|
||||
//文章摘要
|
||||
String summaryText = HtmlUtil.cleanHtmlTag(post.getPostContent());
|
||||
|
@ -198,7 +198,7 @@ public class PostController extends BaseController {
|
|||
logsService.saveByLogs(new Logs(LogsRecord.PUSH_POST, post.getPostTitle(), ServletUtil.getClientIP(request), DateUtil.date()));
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(), msg);
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:", e.getMessage());
|
||||
log.error("保存文章失败:{}", e.getMessage());
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "保存失败");
|
||||
}
|
||||
}
|
||||
|
@ -207,9 +207,13 @@ public class PostController extends BaseController {
|
|||
/**
|
||||
* 自动保存文章为草稿
|
||||
*
|
||||
* @param post post
|
||||
* @param postId 文章编号
|
||||
* @param postTitle 文章标题
|
||||
* @param postUrl 文章路径
|
||||
* @param postContentMd 文章内容
|
||||
* @param postType 文章类型
|
||||
* @param session session
|
||||
* @return 文章的编号
|
||||
* @return JsonResult
|
||||
*/
|
||||
@PostMapping(value = "/new/autoPush")
|
||||
@ResponseBody
|
||||
|
@ -266,7 +270,7 @@ public class PostController extends BaseController {
|
|||
postService.updatePostStatus(postId, PostStatus.RECYCLE.getCode());
|
||||
log.info("编号为" + postId + "的文章已被移到回收站");
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:", e.getMessage());
|
||||
log.error("未知错误:{}", e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/posts?status=" + status;
|
||||
}
|
||||
|
@ -284,7 +288,7 @@ public class PostController extends BaseController {
|
|||
postService.updatePostStatus(postId, PostStatus.PUBLISHED.getCode());
|
||||
log.info("编号为" + postId + "的文章已改变为发布状态");
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:", e.getMessage());
|
||||
log.error("未知错误:{}", e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/posts?status=" + status;
|
||||
}
|
||||
|
@ -302,7 +306,7 @@ public class PostController extends BaseController {
|
|||
postService.removeByPostId(postId);
|
||||
logsService.saveByLogs(new Logs(LogsRecord.REMOVE_POST, post.get().getPostTitle(), ServletUtil.getClientIP(request), DateUtil.date()));
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:", e.getMessage());
|
||||
log.error("未知错误:{}", e.getMessage());
|
||||
}
|
||||
if (StringUtils.equals(PostType.POST_TYPE_POST.getDesc(), postType)) {
|
||||
return "redirect:/admin/posts?status=2";
|
||||
|
@ -328,18 +332,19 @@ public class PostController extends BaseController {
|
|||
* 更新所有摘要
|
||||
*
|
||||
* @param postSummary 文章摘要字数
|
||||
* @return true:更新成功,false:更新失败
|
||||
* @return JsonResult
|
||||
*/
|
||||
@GetMapping(value = "/updateSummary")
|
||||
@ResponseBody
|
||||
public boolean updateSummary(@PathParam("postSummary") Integer postSummary) {
|
||||
public JsonResult updateSummary(@PathParam("postSummary") Integer postSummary) {
|
||||
try {
|
||||
postService.updateAllSummary(postSummary);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:", e.getMessage());
|
||||
return false;
|
||||
log.error("更新摘要失败:{}", e.getMessage());
|
||||
e.printStackTrace();
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "更新失败!");
|
||||
}
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(), "所有文章摘要更新成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -360,13 +365,13 @@ public class PostController extends BaseController {
|
|||
* 将所有文章推送到百度
|
||||
*
|
||||
* @param baiduToken baiduToken
|
||||
* @return true or false
|
||||
* @return JsonResult
|
||||
*/
|
||||
@GetMapping(value = "/pushAllToBaidu")
|
||||
@ResponseBody
|
||||
public boolean pushAllToBaidu(@PathParam("baiduToken") String baiduToken) {
|
||||
public JsonResult pushAllToBaidu(@PathParam("baiduToken") String baiduToken) {
|
||||
if (StringUtils.isEmpty(baiduToken)) {
|
||||
return false;
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "百度推送Token为空!");
|
||||
}
|
||||
String blogUrl = HaloConst.OPTIONS.get(BlogProperties.BLOG_URL.getProp());
|
||||
List<Post> posts = postService.findAllPosts(PostType.POST_TYPE_POST.getDesc());
|
||||
|
@ -379,8 +384,8 @@ public class PostController extends BaseController {
|
|||
}
|
||||
String result = HaloUtils.baiduPost(blogUrl, baiduToken, urls.toString());
|
||||
if (StringUtils.isEmpty(result)) {
|
||||
return false;
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "推送所有文章成功!");
|
||||
}
|
||||
return true;
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(), "推送成功!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class TagController {
|
|||
try {
|
||||
tagService.saveByTag(tag);
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{0}", e.getMessage());
|
||||
log.error("新增/修改标签失败:{}", e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/tag";
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class TagController {
|
|||
Tag tag = tagService.removeByTagId(tagId);
|
||||
log.info("删除的标签:" + tag);
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{0}", e.getMessage());
|
||||
log.error("删除标签失败:{}", e.getMessage());
|
||||
}
|
||||
return "redirect:/admin/tag";
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ public class ThemeController extends BaseController {
|
|||
return new JsonResult(ResultCode.FAIL.getCode(),"请选择上传的主题!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("上传主题失败:", e.getMessage());
|
||||
log.error("上传主题失败:{}", e.getMessage());
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"主题上传失败!");
|
||||
}
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(),"主题上传成功!");
|
||||
|
|
|
@ -57,7 +57,7 @@ public class UserController {
|
|||
return new JsonResult(ResultCode.FAIL.getCode(),"修改失败!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("未知错误:{0}", e.getMessage());
|
||||
log.error("修改用户资料失败:{}", e.getMessage());
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"修改失败!");
|
||||
}
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(),"修改成功!");
|
||||
|
@ -88,7 +88,7 @@ public class UserController {
|
|||
return new JsonResult(ResultCode.FAIL.getCode(),"原密码错误!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("修改密码:未知错误,{0}", e.getMessage());
|
||||
log.error("修改密码失败:{}", e.getMessage());
|
||||
return new JsonResult(ResultCode.FAIL.getCode(),"密码修改失败!");
|
||||
}
|
||||
return new JsonResult(ResultCode.SUCCESS.getCode(),"修改密码成功!");
|
||||
|
|
|
@ -26,6 +26,7 @@ public abstract class BaseController {
|
|||
|
||||
/**
|
||||
* 渲染404页面
|
||||
*
|
||||
* @return redirect:/404
|
||||
*/
|
||||
public String renderNotFound() {
|
||||
|
|
|
@ -104,6 +104,12 @@ public class FrontCommentController {
|
|||
public JsonResult newComment(@ModelAttribute("comment") Comment comment,
|
||||
@ModelAttribute("post") Post post,
|
||||
HttpServletRequest request) {
|
||||
if (StringUtils.equals(StringUtils.trim(comment.getCommentAuthor()), "")) {
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "请正确输入昵称!");
|
||||
}
|
||||
if (StringUtils.equals(StringUtils.trim(comment.getCommentContent()), "")) {
|
||||
return new JsonResult(ResultCode.FAIL.getCode(), "请正确输入评论内容!");
|
||||
}
|
||||
try{
|
||||
Comment lastComment = null;
|
||||
post = postService.findByPostId(post.getPostId()).get();
|
||||
|
@ -163,7 +169,7 @@ public class FrontCommentController {
|
|||
map.put("commentContent", comment.getCommentContent());
|
||||
mailService.sendTemplateMail(userService.findUser().getUserEmail(), "有新的评论", map, "common/mail/mail_admin.ftl");
|
||||
} catch (Exception e) {
|
||||
log.error("邮件服务器未配置:", e.getMessage());
|
||||
log.error("邮件服务器未配置:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,16 +63,16 @@
|
|||
<#switch comment.commentStatus>
|
||||
<#case 0>
|
||||
<button class="btn btn-primary btn-xs " onclick="replyShow('${comment.commentId?c}','${comment.post.postId?c}')" <#if comment.isAdmin==1>disabled</#if>>回复</button>
|
||||
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/comments/throw?commentId=${comment.commentId?c}&status=0','确定移动到回收站?')">丢弃</button>
|
||||
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/comments/throw?commentId=${comment.commentId?c}&status=0&page=${comments.number}','确定移动到回收站?')">丢弃</button>
|
||||
<#break >
|
||||
<#case 1>
|
||||
<a data-pjax="true" class="btn btn-primary btn-xs " href="/admin/comments/revert?commentId=${comment.commentId?c}&status=1">通过</a>
|
||||
<button class="btn btn-info btn-xs " onclick="replyShow('${comment.commentId?c}','${comment.post.postId?c}')">通过并回复</button>
|
||||
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/comments/throw?commentId=${comment.commentId?c}&status=1','确定移动到回收站?')">丢弃</button>
|
||||
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/comments/throw?commentId=${comment.commentId?c}&status=1&page=${comments.number}','确定移动到回收站?')">丢弃</button>
|
||||
<#break >
|
||||
<#case 2>
|
||||
<a data-pjax="true" class="btn btn-primary btn-xs " href="/admin/comments/revert?commentId=${comment.commentId?c}&status=2">还原</a>
|
||||
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/comments/remove?commentId=${comment.commentId?c}&status=2','确定要永久删除?')">删除</button>
|
||||
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/comments/remove?commentId=${comment.commentId?c}&status=2&page=${comments.number}','确定要永久删除?')">删除</button>
|
||||
<#break >
|
||||
</#switch>
|
||||
</td>
|
||||
|
|
|
@ -673,7 +673,7 @@
|
|||
postSummary : $('#postSummary').val()
|
||||
},
|
||||
success: function (data) {
|
||||
if(data==true){
|
||||
if(data.code==1){
|
||||
showMsg("所有文章摘要更新成功!","success",1000);
|
||||
}else{
|
||||
showMsg("更新失败!","success",2000);
|
||||
|
@ -693,10 +693,22 @@
|
|||
baiduToken : $('#baiduToken').val()
|
||||
},
|
||||
success: function (data) {
|
||||
if(data==true){
|
||||
if(data.code==1){
|
||||
showMsg("推送所有文章成功!","success",1000);
|
||||
}else{
|
||||
showMsg("推送失败!","success",2000);
|
||||
$.toast({
|
||||
text: data.msg,
|
||||
heading: '提示',
|
||||
icon: icon,
|
||||
showHideTransition: 'fade',
|
||||
allowToastClose: true,
|
||||
hideAfter: hideAfter,
|
||||
stack: 1,
|
||||
position: 'top-center',
|
||||
textAlign: 'left',
|
||||
loader: true,
|
||||
loaderBg: '#ffffff'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -183,7 +183,7 @@
|
|||
'postUrl': $('#newPostUrl').val()
|
||||
},
|
||||
success: function (data) {
|
||||
if(data==true){
|
||||
if(data.code==0){
|
||||
showMsg("该路径已经存在!","info",2000);
|
||||
return;
|
||||
}else{
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
galleryId : ${gallery.galleryId?c}
|
||||
},
|
||||
success: function (data) {
|
||||
if(data==true){
|
||||
if(data.code==1){
|
||||
$.toast({
|
||||
text: "删除成功!",
|
||||
heading: '提示',
|
||||
|
|
|
@ -379,11 +379,15 @@
|
|||
localStorage.setItem('url', url.val());
|
||||
if(data.code==1){
|
||||
$('.comment-input-content').val("");
|
||||
}
|
||||
$(".native-message").html("<span>"+data.msg+"</span>");
|
||||
}else{
|
||||
$(".native-message").html("<span style='color:red'>"+data.msg+"</span>");
|
||||
}
|
||||
$(".native-message").fadeIn(1000);
|
||||
setTimeout(function () {
|
||||
window.location.reload();
|
||||
$(".native-message").fadeOut(1000);
|
||||
$("#btn-push").removeAttr("disabled");
|
||||
$("#btn-push").html("提交");
|
||||
},1500);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue