From 36971f3771e9e17e5c837f0ed47b4b1f6656e851 Mon Sep 17 00:00:00 2001 From: niukai Date: Mon, 12 Jun 2023 14:46:47 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=A7=A3=E5=86=B3mapper=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=8C=89=E7=B1=BB=E5=9E=8B=E6=B3=A8=E5=85=A5=EF=BC=9B=202.?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=96=87=E7=AB=A0=E6=97=B6=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E6=97=A0=E6=B3=95=E5=88=A0=E9=99=A4=E7=9A=84bug?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../my/core/controller/admin/AdminController.java | 15 ++++++++------- .../my/core/service/impl/BlogServiceImpl.java | 12 ++++++------ .../my/core/service/impl/CategoryServiceImpl.java | 6 +++--- .../my/core/service/impl/CommentServiceImpl.java | 4 ++-- .../my/core/service/impl/ConfigServiceImpl.java | 4 ++-- .../my/core/service/impl/LinkServiceImpl.java | 4 ++-- .../blog/my/core/service/impl/TagServiceImpl.java | 7 +++---- .../resources/mapper/BlogTagRelationMapper.xml | 9 ++++++--- 8 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/site/blog/my/core/controller/admin/AdminController.java b/src/main/java/com/site/blog/my/core/controller/admin/AdminController.java index 8ead74dc..6e903c1d 100644 --- a/src/main/java/com/site/blog/my/core/controller/admin/AdminController.java +++ b/src/main/java/com/site/blog/my/core/controller/admin/AdminController.java @@ -20,6 +20,7 @@ @Controller @RequestMapping("/admin") public class AdminController { + private static final String LOGIN_INDEX = "admin/login"; @Resource private AdminUserService adminUserService; @@ -37,7 +38,7 @@ public class AdminController { @GetMapping({"/login"}) public String login() { - return "admin/login"; + return LOGIN_INDEX; } @GetMapping({"", "/", "/index", "/index.html"}) @@ -58,16 +59,16 @@ public String login(@RequestParam("userName") String userName, HttpSession session) { if (!StringUtils.hasText(verifyCode)) { session.setAttribute("errorMsg", "验证码不能为空"); - return "admin/login"; + return LOGIN_INDEX; } if (!StringUtils.hasText(userName) || !StringUtils.hasText(password)) { session.setAttribute("errorMsg", "用户名或密码不能为空"); - return "admin/login"; + return LOGIN_INDEX; } ShearCaptcha shearCaptcha = (ShearCaptcha) session.getAttribute("verifyCode"); if (shearCaptcha == null || !shearCaptcha.verify(verifyCode)) { session.setAttribute("errorMsg", "验证码错误"); - return "admin/login"; + return LOGIN_INDEX; } AdminUser adminUser = adminUserService.login(userName, password); if (adminUser != null) { @@ -78,7 +79,7 @@ public String login(@RequestParam("userName") String userName, return "redirect:/admin/index"; } else { session.setAttribute("errorMsg", "登陆失败"); - return "admin/login"; + return LOGIN_INDEX; } } @@ -87,7 +88,7 @@ public String profile(HttpServletRequest request) { Integer loginUserId = (int) request.getSession().getAttribute("loginUserId"); AdminUser adminUser = adminUserService.getUserDetailById(loginUserId); if (adminUser == null) { - return "admin/login"; + return LOGIN_INDEX; } request.setAttribute("path", "profile"); request.setAttribute("loginUserName", adminUser.getLoginUserName()); @@ -134,6 +135,6 @@ public String logout(HttpServletRequest request) { request.getSession().removeAttribute("loginUserId"); request.getSession().removeAttribute("loginUser"); request.getSession().removeAttribute("errorMsg"); - return "admin/login"; + return LOGIN_INDEX; } } diff --git a/src/main/java/com/site/blog/my/core/service/impl/BlogServiceImpl.java b/src/main/java/com/site/blog/my/core/service/impl/BlogServiceImpl.java index 526137d2..741c2318 100644 --- a/src/main/java/com/site/blog/my/core/service/impl/BlogServiceImpl.java +++ b/src/main/java/com/site/blog/my/core/service/impl/BlogServiceImpl.java @@ -14,27 +14,27 @@ import com.site.blog.my.core.util.PageResult; import com.site.blog.my.core.util.PatternUtil; import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; +import javax.annotation.Resource; import java.util.*; import java.util.stream.Collectors; @Service public class BlogServiceImpl implements BlogService { - @Autowired + @Resource private BlogMapper blogMapper; - @Autowired + @Resource private BlogCategoryMapper categoryMapper; - @Autowired + @Resource private BlogTagMapper tagMapper; - @Autowired + @Resource private BlogTagRelationMapper blogTagRelationMapper; - @Autowired + @Resource private BlogCommentMapper blogCommentMapper; @Override diff --git a/src/main/java/com/site/blog/my/core/service/impl/CategoryServiceImpl.java b/src/main/java/com/site/blog/my/core/service/impl/CategoryServiceImpl.java index 53ae1956..666f7545 100644 --- a/src/main/java/com/site/blog/my/core/service/impl/CategoryServiceImpl.java +++ b/src/main/java/com/site/blog/my/core/service/impl/CategoryServiceImpl.java @@ -6,18 +6,18 @@ import com.site.blog.my.core.service.CategoryService; import com.site.blog.my.core.util.PageQueryUtil; import com.site.blog.my.core.util.PageResult; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.util.List; @Service public class CategoryServiceImpl implements CategoryService { - @Autowired + @Resource private BlogCategoryMapper blogCategoryMapper; - @Autowired + @Resource private BlogMapper blogMapper; @Override diff --git a/src/main/java/com/site/blog/my/core/service/impl/CommentServiceImpl.java b/src/main/java/com/site/blog/my/core/service/impl/CommentServiceImpl.java index 686fe898..9ae006d8 100644 --- a/src/main/java/com/site/blog/my/core/service/impl/CommentServiceImpl.java +++ b/src/main/java/com/site/blog/my/core/service/impl/CommentServiceImpl.java @@ -5,10 +5,10 @@ import com.site.blog.my.core.service.CommentService; import com.site.blog.my.core.util.PageQueryUtil; import com.site.blog.my.core.util.PageResult; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import javax.annotation.Resource; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -16,7 +16,7 @@ @Service public class CommentServiceImpl implements CommentService { - @Autowired + @Resource private BlogCommentMapper blogCommentMapper; @Override diff --git a/src/main/java/com/site/blog/my/core/service/impl/ConfigServiceImpl.java b/src/main/java/com/site/blog/my/core/service/impl/ConfigServiceImpl.java index 14f9d211..9d5f64cf 100644 --- a/src/main/java/com/site/blog/my/core/service/impl/ConfigServiceImpl.java +++ b/src/main/java/com/site/blog/my/core/service/impl/ConfigServiceImpl.java @@ -3,10 +3,10 @@ import com.site.blog.my.core.dao.BlogConfigMapper; import com.site.blog.my.core.entity.BlogConfig; import com.site.blog.my.core.service.ConfigService; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; +import javax.annotation.Resource; import java.util.Date; import java.util.List; import java.util.Map; @@ -14,7 +14,7 @@ @Service public class ConfigServiceImpl implements ConfigService { - @Autowired + @Resource private BlogConfigMapper configMapper; public static final String websiteName = "personal blog"; diff --git a/src/main/java/com/site/blog/my/core/service/impl/LinkServiceImpl.java b/src/main/java/com/site/blog/my/core/service/impl/LinkServiceImpl.java index 5a2b45db..d95c28c9 100644 --- a/src/main/java/com/site/blog/my/core/service/impl/LinkServiceImpl.java +++ b/src/main/java/com/site/blog/my/core/service/impl/LinkServiceImpl.java @@ -5,10 +5,10 @@ import com.site.blog.my.core.service.LinkService; import com.site.blog.my.core.util.PageQueryUtil; import com.site.blog.my.core.util.PageResult; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import javax.annotation.Resource; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -16,7 +16,7 @@ @Service public class LinkServiceImpl implements LinkService { - @Autowired + @Resource private BlogLinkMapper blogLinkMapper; @Override diff --git a/src/main/java/com/site/blog/my/core/service/impl/TagServiceImpl.java b/src/main/java/com/site/blog/my/core/service/impl/TagServiceImpl.java index 842bc3b1..86a4a930 100644 --- a/src/main/java/com/site/blog/my/core/service/impl/TagServiceImpl.java +++ b/src/main/java/com/site/blog/my/core/service/impl/TagServiceImpl.java @@ -4,22 +4,21 @@ import com.site.blog.my.core.dao.BlogTagRelationMapper; import com.site.blog.my.core.entity.BlogTag; import com.site.blog.my.core.entity.BlogTagCount; -import com.site.blog.my.core.entity.BlogTagRelation; import com.site.blog.my.core.service.TagService; import com.site.blog.my.core.util.PageQueryUtil; import com.site.blog.my.core.util.PageResult; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import javax.annotation.Resource; import java.util.List; @Service public class TagServiceImpl implements TagService { - @Autowired + @Resource private BlogTagMapper blogTagMapper; - @Autowired + @Resource private BlogTagRelationMapper relationMapper; @Override diff --git a/src/main/resources/mapper/BlogTagRelationMapper.xml b/src/main/resources/mapper/BlogTagRelationMapper.xml index f7aadb56..7aca821b 100644 --- a/src/main/resources/mapper/BlogTagRelationMapper.xml +++ b/src/main/resources/mapper/BlogTagRelationMapper.xml @@ -25,9 +25,12 @@