Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.解决mapper无法按类型注入;2.修复无文章时标签无法删除的bug; #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
@Controller
@RequestMapping("/admin")
public class AdminController {
private static final String LOGIN_INDEX = "admin/login";

@Resource
private AdminUserService adminUserService;
Expand All @@ -37,7 +38,7 @@ public class AdminController {

@GetMapping({"/login"})
public String login() {
return "admin/login";
return LOGIN_INDEX;
}

@GetMapping({"", "/", "/index", "/index.html"})
Expand All @@ -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) {
Expand All @@ -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;
}
}

Expand All @@ -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());
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
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;
import java.util.Map;

@Service
public class CommentServiceImpl implements CommentService {
@Autowired
@Resource
private BlogCommentMapper blogCommentMapper;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
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;
import java.util.stream.Collectors;

@Service
public class ConfigServiceImpl implements ConfigService {
@Autowired
@Resource
private BlogConfigMapper configMapper;

public static final String websiteName = "personal blog";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
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;

@Service
public class LinkServiceImpl implements LinkService {

@Autowired
@Resource
private BlogLinkMapper blogLinkMapper;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions src/main/resources/mapper/BlogTagRelationMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
</select>

<select id="selectDistinctTagIds" resultType="java.lang.Long">
select
DISTINCT(tag_id)
from tb_blog_tag_relation
SELECT DISTINCT
( tr.tag_id )
FROM
tb_blog AS tb
LEFT JOIN tb_blog_tag_relation AS tr ON tb.blog_id = tr.blog_id
AND tb.is_deleted = '0'
where tag_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
Expand Down