👽 修复了一些放我犯强迫症的地方:)

pull/1/head
RYAN0UP_ 2018-03-26 17:52:50 +08:00
parent f57d8254e0
commit a6d72991ff
45 changed files with 70 additions and 63 deletions

View File

@ -11,8 +11,8 @@ import org.springframework.web.servlet.config.annotation.*;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2018/1/2 * @date : 2018/1/2
* @version : 1.0
* description: * description:
*/ */
@Slf4j @Slf4j
@ -22,8 +22,6 @@ import org.springframework.web.servlet.config.annotation.*;
@PropertySource(value = "classpath:application.yaml",ignoreResourceNotFound = true,encoding = "UTF-8") @PropertySource(value = "classpath:application.yaml",ignoreResourceNotFound = true,encoding = "UTF-8")
public class MvcConfiguration implements WebMvcConfigurer { public class MvcConfiguration implements WebMvcConfigurer {
@Autowired @Autowired
private LoginInterceptor loginInterceptor; private LoginInterceptor loginInterceptor;

View File

@ -11,8 +11,8 @@ import java.util.Date;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2018/2/26 * @date : 2018/2/26
* @version : 1.0
* description : * description :
*/ */

View File

@ -7,8 +7,8 @@ import java.util.List;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2018/1/20 * @date : 2018/1/20
* @version : 1.0
* description : * description :
*/ */
@Data @Data

View File

@ -15,6 +15,7 @@ import java.util.Map;
* description: * description:
*/ */
public class HaloConst { public class HaloConst {
/** /**
* key,value * key,value
*/ */

View File

@ -2,9 +2,9 @@ package cc.ryanc.halo.model.dto;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @date : 2018/1/19
* @version : 1.0 * @version : 1.0
* description : * description :
* @date : 2018/1/19
*/ */
public interface LogsRecord { public interface LogsRecord {

View File

@ -6,8 +6,8 @@ import java.io.Serializable;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2018/1/3 * @date : 2018/1/3
* @version : 1.0
* description : * description :
*/ */
@Data @Data

View File

@ -7,9 +7,9 @@ import org.springframework.data.jpa.repository.JpaRepository;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @date : 2018/1/10
* @version : 1.0 * @version : 1.0
* description : * description :
* @date : 2018/1/10
*/ */
public interface AttachmentRepository extends JpaRepository<Attachment,Long>{ public interface AttachmentRepository extends JpaRepository<Attachment,Long>{

View File

@ -11,9 +11,9 @@ import java.util.List;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @date : 2018/1/22
* @version : 1.0 * @version : 1.0
* description : * description :
* @date : 2018/1/22
*/ */
public interface CommentRepository extends JpaRepository<Comment,Long> { public interface CommentRepository extends JpaRepository<Comment,Long> {

View File

@ -5,8 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2018/2/26 * @date : 2018/2/26
* @version : 1.0
* description : * description :
*/ */
public interface GalleryRepository extends JpaRepository<Gallery,Long> { public interface GalleryRepository extends JpaRepository<Gallery,Long> {

View File

@ -4,9 +4,9 @@ import cc.ryanc.halo.model.domain.Link;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
/** /**
* className: LinkRepository
* @author : RYAN0UP * @author : RYAN0UP
* @date : 2017/11/14 * @date : 2017/11/14
* @version : 1.0
* description: * description:
*/ */
public interface LinkRepository extends JpaRepository<Link,Long>{ public interface LinkRepository extends JpaRepository<Link,Long>{

View File

@ -8,8 +8,8 @@ import java.util.List;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2018/1/19 * @date : 2018/1/19
* @version : 1.0
* description : * description :
*/ */
public interface LogsRepository extends JpaRepository<Logs,Long> { public interface LogsRepository extends JpaRepository<Logs,Long> {

View File

@ -8,8 +8,8 @@ import java.util.List;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2018/1/24 * @date : 2018/1/24
* @version : 1.0
* description : * description :
*/ */
public interface MenuRepository extends JpaRepository<Menu,Long> { public interface MenuRepository extends JpaRepository<Menu,Long> {

View File

@ -13,8 +13,8 @@ import java.util.List;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2017/11/14 * @date : 2017/11/14
* @version : 1.0
* description : * description :
*/ */
public interface PostRepository extends JpaRepository<Post,Long>{ public interface PostRepository extends JpaRepository<Post,Long>{

View File

@ -5,9 +5,9 @@ import org.springframework.data.jpa.repository.JpaRepository;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @date : 2018/1/12
* @version : 1.0 * @version : 1.0
* description : * description :
* @date : 2018/1/12
*/ */
public interface TagRepository extends JpaRepository<Tag,Long>{ public interface TagRepository extends JpaRepository<Tag,Long>{

View File

@ -9,11 +9,12 @@ import java.util.Optional;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @date : 2018/1/10
* @version : 1.0 * @version : 1.0
* description : * description :
* @date : 2018/1/10
*/ */
public interface AttachmentService { public interface AttachmentService {
/** /**
* *
* *

View File

@ -12,6 +12,7 @@ import java.util.Optional;
* description : * description :
*/ */
public interface CategoryService { public interface CategoryService {
/** /**
* *
* *

View File

@ -10,8 +10,8 @@ import java.util.Optional;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2018/1/22 * @date : 2018/1/22
* @version : 1.0
* description : * description :
*/ */
public interface CommentService { public interface CommentService {

View File

@ -9,8 +9,8 @@ import java.util.Optional;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2018/2/26 * @date : 2018/2/26
* @version : 1.0
* description : * description :
*/ */
public interface GalleryService { public interface GalleryService {

View File

@ -12,6 +12,7 @@ import java.util.Optional;
* description: * description:
*/ */
public interface LinkService { public interface LinkService {
/** /**
* *
* *

View File

@ -9,9 +9,9 @@ import java.util.Optional;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @date : 2018/1/19
* @version : 1.0 * @version : 1.0
* description : * description :
* @date : 2018/1/19
*/ */
public interface LogsService { public interface LogsService {

View File

@ -4,9 +4,9 @@ import java.util.Map;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @date : 2018/1/23
* @version : 1.0 * @version : 1.0
* description : * description :
* @date : 2018/1/23
*/ */
public interface MailService { public interface MailService {

View File

@ -7,9 +7,9 @@ import java.util.Optional;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @date : 2018/1/24
* @version : 1.0 * @version : 1.0
* description : * description :
* @date : 2018/1/24
*/ */
public interface MenuService { public interface MenuService {

View File

@ -12,7 +12,6 @@ import java.util.Map;
*/ */
public interface OptionsService { public interface OptionsService {
/** /**
* *
* *

View File

@ -17,6 +17,7 @@ import java.util.Optional;
* description : * description :
*/ */
public interface PostService { public interface PostService {
/** /**
* *
* *

View File

@ -7,8 +7,8 @@ import java.util.Optional;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2018/1/12 * @date : 2018/1/12
* @version : 1.0
* description : * description :
*/ */
public interface TagService { public interface TagService {

View File

@ -7,11 +7,12 @@ import java.util.List;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2017/11/14 * @date : 2017/11/14
* @version : 1.0
* description: * description:
*/ */
public interface UserService { public interface UserService {
/** /**
* *
* *
@ -41,7 +42,7 @@ public interface UserService {
* *
* @return list * @return list
*/ */
List<User> findAllUser(); User findUser();
/** /**
* *

View File

@ -13,9 +13,9 @@ import java.util.Optional;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @date : 2018/1/10
* @version : 1.0 * @version : 1.0
* description : * description :
* @date : 2018/1/10
*/ */
@Service @Service
public class AttachmentServiceImpl implements AttachmentService{ public class AttachmentServiceImpl implements AttachmentService{

View File

@ -15,9 +15,9 @@ import java.util.Optional;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @date : 2018/1/22
* @version : 1.0 * @version : 1.0
* description : * description :
* @date : 2018/1/22
*/ */
@Service @Service
public class CommentServiceImpl implements CommentService { public class CommentServiceImpl implements CommentService {

View File

@ -13,8 +13,8 @@ import java.util.Optional;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2018/2/26 * @date : 2018/2/26
* @version : 1.0
* description : * description :
*/ */
@Service @Service

View File

@ -13,9 +13,9 @@ import java.util.Optional;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @date : 2018/1/19
* @version : 1.0 * @version : 1.0
* description : * description :
* @date : 2018/1/19
*/ */
@Service @Service
public class LogsServiceImpl implements LogsService { public class LogsServiceImpl implements LogsService {

View File

@ -14,9 +14,9 @@ import java.util.Map;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @date : 2018/1/23
* @version : 1.0 * @version : 1.0
* description : * description :
* @date : 2018/1/23
*/ */
@Service @Service
public class MailServiceImpl implements MailService{ public class MailServiceImpl implements MailService{

View File

@ -11,9 +11,9 @@ import java.util.Optional;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @date : 2018/1/24
* @version : 1.0 * @version : 1.0
* description : * description :
* @date : 2018/1/24
*/ */
@Service @Service
public class MenuServiceImpl implements MenuService{ public class MenuServiceImpl implements MenuService{

View File

@ -15,8 +15,8 @@ import java.util.Map;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2017/11/14 * @date : 2017/11/14
* @version : 1.0
* description: * description:
*/ */
@Service @Service

View File

@ -11,8 +11,8 @@ import java.util.Optional;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2018/1/12 * @date : 2018/1/12
* @version : 1.0
* description : * description :
*/ */
@Service @Service

View File

@ -11,8 +11,8 @@ import java.util.List;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2017/11/14 * @date : 2017/11/14
* @version : 1.0
* description: * description:
*/ */
@Service @Service
@ -61,8 +61,8 @@ public class UserServiceImpl implements UserService {
* @return list * @return list
*/ */
@Override @Override
public List<User> findAllUser() { public User findUser() {
return userRepository.findAll(); return userRepository.findAll().get(0);
} }
/** /**
@ -84,7 +84,7 @@ public class UserServiceImpl implements UserService {
*/ */
@Override @Override
public void updateUserLoginEnable(String enable) { public void updateUserLoginEnable(String enable) {
User user = this.findAllUser().get(0); User user = this.findUser();
user.setLoginEnable(enable); user.setLoginEnable(enable);
userRepository.save(user); userRepository.save(user);
} }
@ -96,7 +96,7 @@ public class UserServiceImpl implements UserService {
*/ */
@Override @Override
public User updateUserLoginLast(Date lastDate) { public User updateUserLoginLast(Date lastDate) {
User user = this.findAllUser().get(0); User user = this.findUser();
user.setLoginLast(lastDate); user.setLoginLast(lastDate);
userRepository.save(user); userRepository.save(user);
return user; return user;
@ -109,7 +109,7 @@ public class UserServiceImpl implements UserService {
*/ */
@Override @Override
public Integer updateUserLoginError() { public Integer updateUserLoginError() {
User user = this.findAllUser().get(0); User user = this.findUser();
user.setLoginError(user.getLoginError()+1); user.setLoginError(user.getLoginError()+1);
userRepository.save(user); userRepository.save(user);
return user.getLoginError(); return user.getLoginError();
@ -120,7 +120,7 @@ public class UserServiceImpl implements UserService {
*/ */
@Override @Override
public User updateUserNormal() { public User updateUserNormal() {
User user = this.findAllUser().get(0); User user = this.findUser();
user.setLoginEnable("true"); user.setLoginEnable("true");
user.setLoginError(0); user.setLoginError(0);
user.setLoginLast(new Date()); user.setLoginLast(new Date());

View File

@ -100,8 +100,8 @@ public class IndexController extends BaseController{
model.addAttribute("is_home",true); model.addAttribute("is_home",true);
//用户信息 //用户信息
List<User> users = userService.findAllUser(); User user = userService.findUser();
model.addAttribute("user",users.get(0)); model.addAttribute("user",user);
//所有分类目录 //所有分类目录
List<Category> categories = categoryService.findAllCategories(); List<Category> categories = categoryService.findAllCategories();
@ -177,8 +177,8 @@ public class IndexController extends BaseController{
model.addAttribute("postsCount",postService.findAllPosts().size()); model.addAttribute("postsCount",postService.findAllPosts().size());
//用户信息 //用户信息
List<User> users = userService.findAllUser(); User user = userService.findUser();
model.addAttribute("user",users.get(0)); model.addAttribute("user",user);
//所有分类目录 //所有分类目录
List<Category> categories = categoryService.findAllCategories(); List<Category> categories = categoryService.findAllCategories();
@ -267,8 +267,8 @@ public class IndexController extends BaseController{
model.addAttribute("links",links); model.addAttribute("links",links);
//用户信息 //用户信息
List<User> users = userService.findAllUser(); User user = userService.findUser();
model.addAttribute("user",users.get(0)); model.addAttribute("user",user);
model.addAttribute("is_links",true); model.addAttribute("is_links",true);
@ -308,8 +308,8 @@ public class IndexController extends BaseController{
List<Category> categories = categoryService.findAllCategories(); List<Category> categories = categoryService.findAllCategories();
model.addAttribute("categories",categories); model.addAttribute("categories",categories);
List<User> users = userService.findAllUser(); User user = userService.findUser();
model.addAttribute("user",users.get(0)); model.addAttribute("user",user);
//文章总数 //文章总数
model.addAttribute("postsCount",postService.findAllPosts().size()); model.addAttribute("postsCount",postService.findAllPosts().size());
@ -380,8 +380,8 @@ public class IndexController extends BaseController{
model.addAttribute("archives",archives); model.addAttribute("archives",archives);
//用户信息 //用户信息
List<User> users = userService.findAllUser(); User user = userService.findUser();
model.addAttribute("user",users.get(0)); model.addAttribute("user",user);
//菜单列表 //菜单列表
List<Menu> menus = menuService.findAllMenus(); List<Menu> menus = menuService.findAllMenus();
@ -424,8 +424,8 @@ public class IndexController extends BaseController{
model.addAttribute("postsCount",postService.findAllPosts().size()); model.addAttribute("postsCount",postService.findAllPosts().size());
//用户信息 //用户信息
List<User> users = userService.findAllUser(); User user = userService.findUser();
model.addAttribute("user",users.get(0)); model.addAttribute("user",user);
//分类目录 //分类目录
List<Category> categories = categoryService.findAllCategories(); List<Category> categories = categoryService.findAllCategories();
@ -505,12 +505,12 @@ public class IndexController extends BaseController{
try { try {
//发送邮件到博主 //发送邮件到博主
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("author",userService.findAllUser().get(0).getUserDisplayName()); map.put("author",userService.findUser().getUserDisplayName());
map.put("pageName",postService.findByPostId(post.getPostId()).get().getPostTitle()); map.put("pageName",postService.findByPostId(post.getPostId()).get().getPostTitle());
map.put("siteUrl",HaloConst.OPTIONS.get("site_url")); map.put("siteUrl",HaloConst.OPTIONS.get("site_url"));
map.put("visitor",comment.getCommentAuthor()); map.put("visitor",comment.getCommentAuthor());
map.put("commentContent",comment.getCommentContent()); map.put("commentContent",comment.getCommentContent());
mailService.sendTemplateMail(userService.findAllUser().get(0).getUserEmail(),"有新的评论",map,"common/mail/mail_admin.ftl"); mailService.sendTemplateMail(userService.findUser().getUserEmail(),"有新的评论",map,"common/mail/mail_admin.ftl");
}catch (Exception e){ }catch (Exception e){
log.error("邮件服务器未配置:"+e.getMessage()); log.error("邮件服务器未配置:"+e.getMessage());
} }

View File

@ -21,8 +21,8 @@ import java.util.List;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2018/1/28 * @date : 2018/1/28
* @version : 1.0
* description : * description :
*/ */
@Slf4j @Slf4j

View File

@ -120,7 +120,7 @@ public class AdminController extends BaseController{
HttpSession session){ HttpSession session){
String status = "false"; String status = "false";
try { try {
User aUser = userService.findAllUser().get(0); User aUser = userService.findUser();
User user = null; User user = null;
if("false".equals(aUser.getLoginEnable())){ if("false".equals(aUser.getLoginEnable())){
status = "disable"; status = "disable";

View File

@ -29,7 +29,6 @@ public class BackupController {
@Autowired @Autowired
private PostService postService; private PostService postService;
/** /**
* *
* *

View File

@ -125,7 +125,7 @@ public class CommentController extends BaseController{
map.put("commentContent", comment.getCommentContent()); map.put("commentContent", comment.getCommentContent());
map.put("siteUrl", HaloConst.OPTIONS.get("site_url")); map.put("siteUrl", HaloConst.OPTIONS.get("site_url"));
map.put("siteTitle", HaloConst.OPTIONS.get("site_title")); map.put("siteTitle", HaloConst.OPTIONS.get("site_title"));
map.put("author", userService.findAllUser().get(0).getUserDisplayName()); map.put("author", userService.findUser().getUserDisplayName());
mailService.sendTemplateMail( mailService.sendTemplateMail(
comment.getCommentAuthorEmail(), comment.getCommentAuthorEmail(),
"您在" + HaloConst.OPTIONS.get("site_title") + "的评论已审核通过!", map, "common/mail/mail_passed.ftl"); "您在" + HaloConst.OPTIONS.get("site_title") + "的评论已审核通过!", map, "common/mail/mail_passed.ftl");
@ -184,6 +184,10 @@ public class CommentController extends BaseController{
//被回复的评论 //被回复的评论
Comment lastComment = commentService.findCommentById(commentId).get(); Comment lastComment = commentService.findCommentById(commentId).get();
//修改被回复的评论的状态
lastComment.setCommentStatus(0);
commentService.saveByComment(lastComment);
//保存评论 //保存评论
Comment comment = new Comment(); Comment comment = new Comment();
comment.setPost(post); comment.setPost(post);
@ -191,7 +195,7 @@ public class CommentController extends BaseController{
comment.setCommentAuthorEmail(user.getUserEmail()); comment.setCommentAuthorEmail(user.getUserEmail());
comment.setCommentAuthorUrl(HaloConst.OPTIONS.get("site_url")); comment.setCommentAuthorUrl(HaloConst.OPTIONS.get("site_url"));
comment.setCommentAuthorIp(HaloUtil.getIpAddr(request)); comment.setCommentAuthorIp(HaloUtil.getIpAddr(request));
comment.setCommentAuthorAvatarMd5(HaloUtil.getMD5(userService.findAllUser().get(0).getUserEmail())); comment.setCommentAuthorAvatarMd5(HaloUtil.getMD5(userService.findUser().getUserEmail()));
comment.setCommentDate(new Date()); comment.setCommentDate(new Date());
String lastContent = " //<a href='#'>@"+lastComment.getCommentAuthor()+"</a>:"+lastComment.getCommentContent(); String lastContent = " //<a href='#'>@"+lastComment.getCommentAuthor()+"</a>:"+lastComment.getCommentContent();
comment.setCommentContent(commentContent+lastContent); comment.setCommentContent(commentContent+lastContent);

View File

@ -9,8 +9,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2018/2/26 * @date : 2018/2/26
* @version : 1.0
* description : * description :
*/ */
@Slf4j @Slf4j

View File

@ -16,9 +16,9 @@ import java.util.List;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @date : 2018/1/30
* @version : 1.0 * @version : 1.0
* description : * description :
* @date : 2018/1/30
*/ */
@Slf4j @Slf4j
@Controller @Controller

View File

@ -33,7 +33,7 @@ public class UserController {
*/ */
@GetMapping @GetMapping
public String profile(Model model){ public String profile(Model model){
model.addAttribute("user",userService.findAllUser().get(0)); model.addAttribute("user",userService.findUser());
//设置选项 //设置选项
model.addAttribute("options",HaloConst.OPTIONS); model.addAttribute("options",HaloConst.OPTIONS);
return "admin/admin_profile"; return "admin/admin_profile";

View File

@ -11,8 +11,8 @@ import java.io.File;
/** /**
* @author : RYAN0UP * @author : RYAN0UP
* @version : 1.0
* @date : 2018/1/28 * @date : 2018/1/28
* @version : 1.0
* description : * description :
*/ */
@Component @Component

View File

@ -61,6 +61,7 @@
<#break > <#break >
<#case 1> <#case 1>
<a class="btn btn-info btn-sm btn-flat" href="/admin/comments/revert?commentId=${comment.commentId}&status=1">通过</a> <a class="btn btn-info btn-sm btn-flat" href="/admin/comments/revert?commentId=${comment.commentId}&status=1">通过</a>
<a class="btn btn-primary btn-sm btn-flat" onclick="replyShow('${comment.commentId}','${comment.post.postId}')">通过并回复</a>
<button class="btn btn-danger btn-sm btn-flat" onclick="modelShow('/admin/comments/throw?commentId=${comment.commentId}','确定移动到回收站?')">丢弃</button> <button class="btn btn-danger btn-sm btn-flat" onclick="modelShow('/admin/comments/throw?commentId=${comment.commentId}','确定移动到回收站?')">丢弃</button>
<#break > <#break >
<#case 2> <#case 2>