全局搜索,我们把全局搜索提供,需要博客和资源修改新增的时候同步Context的文本
This commit is contained in:
20
src/main/java/com/quinn/service/FindService.java
Normal file
20
src/main/java/com/quinn/service/FindService.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.quinn.service;
|
||||
|
||||
import com.quinn.pojo.FindResult;
|
||||
import com.quinn.vo.MyPageParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2022-05-08
|
||||
*/
|
||||
public interface FindService {
|
||||
|
||||
List<FindResult> listFinds(String findWhat, MyPageParam myPageParam);
|
||||
|
||||
}
|
||||
@@ -26,9 +26,6 @@ import java.util.List;
|
||||
*/
|
||||
@Service
|
||||
public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements BlogService {
|
||||
|
||||
@Resource
|
||||
RedisUtils redisUtils;
|
||||
@Resource
|
||||
BlogMapper blogMapper;
|
||||
|
||||
@@ -66,12 +63,8 @@ public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements Bl
|
||||
|
||||
@Override
|
||||
public void addRecord(Blog blog, String sessionId) {
|
||||
String value = redisUtils.get(sessionId);
|
||||
if (StringUtils.isEmpty(value)){
|
||||
redisUtils.set(sessionId, QuinnConstant.SESSION_LOCK,QuinnConstant.SESSION_TIME_OUT);
|
||||
blog.setViews(blog.getViews()+1);
|
||||
updateById(blog);
|
||||
}
|
||||
blog.setViews(blog.getViews()+1);
|
||||
updateById(blog);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
36
src/main/java/com/quinn/service/impl/FindServiceImpl.java
Normal file
36
src/main/java/com/quinn/service/impl/FindServiceImpl.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.quinn.service.impl;
|
||||
|
||||
import com.quinn.mapper.FindMapper;
|
||||
import com.quinn.pojo.FindResult;
|
||||
import com.quinn.service.FindService;
|
||||
import com.quinn.vo.MyPageParam;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2022-05-08
|
||||
*/
|
||||
@Service
|
||||
public class FindServiceImpl implements FindService {
|
||||
|
||||
@Resource
|
||||
FindMapper findMapper;
|
||||
|
||||
@Override
|
||||
public List<FindResult> listFinds(String findWhat, MyPageParam myPageParam) {
|
||||
int total = findMapper.countListFinds(findWhat);
|
||||
myPageParam.setTotal(total);
|
||||
if (total > 0){
|
||||
return findMapper.listFinds(findWhat,myPageParam);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import com.quinn.pojo.SourceCategory;
|
||||
import com.quinn.pojo.SourceWithStar;
|
||||
import com.quinn.service.SourceService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.quinn.utils.ContentUtil;
|
||||
import com.quinn.utils.OSSClientUtil;
|
||||
import com.quinn.utils.QuinnUtils;
|
||||
import com.quinn.utils.RedisUtils;
|
||||
@@ -83,11 +84,7 @@ public class SourceServiceImpl extends ServiceImpl<SourceMapper, Source> impleme
|
||||
@Override
|
||||
public Source view(String sid,String sessionId) {
|
||||
Source source = getOne(new QueryWrapper<Source>().eq("sid", sid));
|
||||
String value = redisUtils.get(sessionId);
|
||||
if (StringUtils.isEmpty(value)){
|
||||
redisUtils.set(sessionId,QuinnConstant.SESSION_LOCK,QuinnConstant.SESSION_TIME_OUT);
|
||||
addDownLoadRecord(source);
|
||||
}
|
||||
addDownLoadRecord(source);
|
||||
return source;
|
||||
}
|
||||
|
||||
@@ -110,19 +107,8 @@ public class SourceServiceImpl extends ServiceImpl<SourceMapper, Source> impleme
|
||||
source.setSourceName(sourceWriteForm.getTitle());
|
||||
source.setDetail(sourceWriteForm.getSubContent());
|
||||
source.setSourceContent(sourceWriteForm.getContent());
|
||||
String keyWords = sourceWriteForm.getKeyWords();
|
||||
if (!StringUtils.isEmpty(keyWords)){
|
||||
//兼容中英文逗号
|
||||
keyWords = keyWords.replaceAll(",",",");
|
||||
String[] split = keyWords.split(QuinnConstant.LINK_KEY_WORD);
|
||||
source.setKeyWord1(split[0]);
|
||||
if (split.length > 1){
|
||||
source.setKeyWord2(split[1]);
|
||||
if (split.length > 2){
|
||||
source.setKeyWord3(split[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
String s = ContentUtil.toTextContentFromWangEdit(sourceWriteForm.getContentJson());
|
||||
sourceWriteForm.setContentJson(s);
|
||||
source.setSourceType(sourceWriteForm.getSourceType());
|
||||
source.setSourceLink(fileLink);
|
||||
|
||||
@@ -158,19 +144,8 @@ public class SourceServiceImpl extends ServiceImpl<SourceMapper, Source> impleme
|
||||
before.setSourceName(sourceUpdateForm.getSourceName());
|
||||
before.setDetail(sourceUpdateForm.getDetail());
|
||||
before.setSourceContent(sourceUpdateForm.getSourceContent());
|
||||
String keyWords = sourceUpdateForm.getKeyWords();
|
||||
if (!StringUtils.isEmpty(keyWords)){
|
||||
//兼容中英文逗号
|
||||
keyWords = keyWords.replaceAll(",",",");
|
||||
String[] split = keyWords.split(QuinnConstant.LINK_KEY_WORD);
|
||||
before.setKeyWord1(split[0]);
|
||||
if (split.length > 1){
|
||||
before.setKeyWord2(split[1]);
|
||||
if (split.length > 2){
|
||||
before.setKeyWord3(split[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
String s = ContentUtil.toTextContentFromWangEdit(sourceUpdateForm.getContentJson());
|
||||
before.setContentJson(s);
|
||||
before.setSourceType(sourceUpdateForm.getSourceType());
|
||||
before.setSourceLink(fileLink);
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -28,8 +27,6 @@ import java.util.List;
|
||||
* @author limqsh
|
||||
* @since 2020-06-28
|
||||
*/
|
||||
// UserDetailsService接口用于返回用户相关数据。
|
||||
// 它有loadUserByUsername()方法,根据username查询用户实体,可以实现该接口覆盖该方法,实现自定义获取用户过程。
|
||||
// 该接口实现类被DaoAuthenticationProvider 类使用,用于认证过程中载入用户信息。
|
||||
@Service
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService,UserDetailsService {
|
||||
@@ -58,10 +55,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
session.setMaxInactiveInterval(QuinnConstant.SESSION_TIME_OUT);
|
||||
//创建一个集合来存放权限
|
||||
List<GrantedAuthority> authList = new ArrayList<GrantedAuthority>();
|
||||
RoleType[] values = RoleType.values();
|
||||
Arrays.stream(values).forEach(x->{
|
||||
authList.add(new SimpleGrantedAuthority("ROLE_" + x.name()));
|
||||
});
|
||||
RoleType roleType = RoleType.parse(user.getRole());
|
||||
if (roleType == null){
|
||||
roleType = RoleType.NORMAL;
|
||||
}
|
||||
SimpleGrantedAuthority authority = new SimpleGrantedAuthority(roleType.getName());
|
||||
authList.add(authority);
|
||||
//实例化UserDetails对象
|
||||
userDetails=new org.springframework.security.core.userdetails.User(s,password,
|
||||
true,
|
||||
|
||||
Reference in New Issue
Block a user