This commit is contained in:
limqhz
2022-05-11 22:47:44 +08:00
parent 03d805641a
commit 4eadfe16f3
30 changed files with 2252 additions and 119 deletions

View File

@@ -2,7 +2,14 @@ package com.quinn.common;
import lombok.Data;
import java.util.List;
@Data
public class EditText {
List<EditText> children;
String text;
String type;
}

View File

@@ -35,7 +35,7 @@ public enum RoleType {
* @return
*/
public static RoleType parse(String name){
if (StringUtils.isEmpty(name)){
if (!StringUtils.isEmpty(name)){
if (ADMIN.getName().equals(name)){
return RoleType.ADMIN;
}

View File

@@ -3,8 +3,10 @@ package com.quinn.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.quinn.common.QuinnConstant;
import com.quinn.common.RoleType;
import com.quinn.pojo.*;
import com.quinn.service.*;
import com.quinn.vo.FindNavReq;
import com.quinn.vo.MyPageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@@ -14,6 +16,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
@@ -25,7 +28,7 @@ import java.util.List;
* @since 2022-05-01
*/
@Controller
public class SearchController {
public class SearchController extends BaseModelController{
@Resource
SourceService sourceService;
@@ -39,15 +42,53 @@ public class SearchController {
SourceCategoryService sourceCategoryService;
@Resource
FindService findService;
@Resource
UserService userService;
@GetMapping("/search")
public String searchAll(String findWhat,Model model){
public String searchAll(HttpServletRequest request, String findWhat, Model model){
/**
* 为空返回主页
*/
if (StringUtils.isEmpty(findWhat)){
return "index";
}
String loginUserId = getLoginUserId(request);
User uid = userService.getOne(new QueryWrapper<User>().eq("uid", loginUserId));
if (RoleType.ADMIN.getName().equals(uid.getRole())){
String result = doAdmin(findWhat, model);
if (!QuinnConstant.GUN.equals(result)){
return result;
}
}
/**
* 正式开始,全局搜索
*/
MyPageParam myPageParam = new MyPageParam(1, 20);
List<FindResult> findList = findService.listFinds(findWhat, myPageParam);
model.addAttribute("findWhat",findWhat);
// 结果
model.addAttribute("findList",findList);
model.addAttribute("pageParam",myPageParam);
return "page/allsearch";
}
@PostMapping("/search")
public String search(FindNavReq findNavReq, Model model){
String findWhat = findNavReq.getFindWhat();
if (findNavReq.getPageNum() < 1){
findNavReq.setPageNum(1);
}
MyPageParam myPageParam = new MyPageParam(findNavReq.getPageNum(),findNavReq.getLimit());
List<FindResult> findList = findService.listFinds(findWhat, myPageParam);
model.addAttribute("findWhat",findWhat);
// 结果
model.addAttribute("findList",findList);
model.addAttribute("pageParam",myPageParam);
return "page/allsearch::user_table_refresh";
}
private String doAdmin(String findWhat,Model model){
/**
* 新增资源
*/
@@ -81,20 +122,9 @@ public class SearchController {
}
}
}
/**
* 正式开始,全局搜索
*/
MyPageParam myPageParam = new MyPageParam(1, 10);
List<FindResult> findList = findService.listFinds(findWhat, myPageParam);
model.addAttribute("findWhat",findWhat);
// 结果
model.addAttribute("findList",findList);
model.addAttribute("pageParam",myPageParam);
return "page/allsearch";
return QuinnConstant.GUN;
}
}

View File

@@ -59,7 +59,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
if (roleType == null){
roleType = RoleType.NORMAL;
}
SimpleGrantedAuthority authority = new SimpleGrantedAuthority(roleType.getName());
SimpleGrantedAuthority authority = new SimpleGrantedAuthority(roleType.name());
authList.add(authority);
//实例化UserDetails对象
userDetails=new org.springframework.security.core.userdetails.User(s,password,

View File

@@ -7,20 +7,31 @@ import org.springframework.util.CollectionUtils;
import java.util.List;
public interface ContentUtil {
public class ContentUtil {
static String toTextContentFromWangEdit(String wangEdit){
public static String toTextContentFromWangEdit(String wangEdit){
List<WangEdit> decode = JsonUtils.decode(wangEdit, new TypeReference<List<WangEdit>>(){});
StringBuffer sb = new StringBuffer();
decode.forEach(x->{
List<EditText> children = x.getChildren();
if (!CollectionUtils.isEmpty(children)){
children.forEach(y ->{
sb.append(y.getText());
getChildText(sb,y);
});
}
});
return sb.toString();
}
private static void getChildText(StringBuffer sb, EditText editText){
List<EditText> children = editText.getChildren();
if (!CollectionUtils.isEmpty(children)){
children.forEach(y ->{
getChildText(sb,y);
});
}else {
sb.append(editText.getText());
}
}
}

View File

@@ -0,0 +1,22 @@
package com.quinn.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class FindNavReq {
@ApiModelProperty(value = "页码")
private int pageNum;
@ApiModelProperty(value = "个数")
private int limit;
@ApiModelProperty(value = "用户编号")
private String findWhat;
}