【CHG】南瓜瞄
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
package com.quinn.common;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ExpBucket {
|
||||
|
||||
String name;
|
||||
String category;
|
||||
String url;
|
||||
|
||||
}
|
||||
@@ -3,12 +3,9 @@ package com.quinn.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.quinn.common.ExpBucket;
|
||||
import com.quinn.pojo.About;
|
||||
import com.quinn.service.AboutService;
|
||||
import com.quinn.utils.QuinnUtils;
|
||||
import com.quinn.vo.FindNavReq;
|
||||
import com.quinn.vo.MyPageParam;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -16,7 +13,6 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -45,41 +41,36 @@ public class AboutController extends BaseModelController {
|
||||
return "page/about";
|
||||
}
|
||||
|
||||
@GetMapping("/guess")
|
||||
public String guess(){
|
||||
return "cimi/guess";
|
||||
}
|
||||
|
||||
@GetMapping("/firework")
|
||||
public String firework(){
|
||||
return "firework/index";
|
||||
}
|
||||
|
||||
// 列表展示
|
||||
@GetMapping("/favor")
|
||||
public String sourceList(Model model) throws IOException {
|
||||
MyPageParam pageParam = new MyPageParam(1,24);
|
||||
List<ExpBucket> recordList = aboutService.listExp(null,pageParam);
|
||||
model.addAttribute("recordList",recordList);
|
||||
model.addAttribute("pageParam",pageParam);
|
||||
return "page/favor";
|
||||
}
|
||||
|
||||
@PostMapping("/favor")
|
||||
public String blogListPage(FindNavReq findNavReq, Model model) throws IOException {
|
||||
int page = findNavReq.getPageNum();
|
||||
int limit = findNavReq.getLimit();
|
||||
if (findNavReq.getPageNum() < 1){
|
||||
page = 1;
|
||||
}
|
||||
MyPageParam pageParam = new MyPageParam(page,limit);
|
||||
List<ExpBucket> recordList = aboutService.listExp(findNavReq.getFindWhat(),pageParam);
|
||||
// 结果
|
||||
model.addAttribute("recordList",recordList);
|
||||
model.addAttribute("pageParam",pageParam);
|
||||
model.addAttribute("findBucket",findNavReq.getFindWhat());
|
||||
return "page/favor::user_table_refresh";
|
||||
}
|
||||
// // 列表展示
|
||||
// @GetMapping("/favor")
|
||||
// public String sourceList(Model model) throws IOException {
|
||||
// MyPageParam pageParam = new MyPageParam(1,24);
|
||||
// List<ExpBucket> recordList = aboutService.listExp(null,pageParam);
|
||||
// model.addAttribute("recordList",recordList);
|
||||
// model.addAttribute("pageParam",pageParam);
|
||||
// return "page/favor";
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/favor")
|
||||
// public String blogListPage(FindNavReq findNavReq, Model model) throws IOException {
|
||||
// int page = findNavReq.getPageNum();
|
||||
// int limit = findNavReq.getLimit();
|
||||
// if (findNavReq.getPageNum() < 1){
|
||||
// page = 1;
|
||||
// }
|
||||
// MyPageParam pageParam = new MyPageParam(page,limit);
|
||||
// List<ExpBucket> recordList = aboutService.listExp(findNavReq.getFindWhat(),pageParam);
|
||||
// // 结果
|
||||
// model.addAttribute("recordList",recordList);
|
||||
// model.addAttribute("pageParam",pageParam);
|
||||
// model.addAttribute("findBucket",findNavReq.getFindWhat());
|
||||
// return "page/favor::user_table_refresh";
|
||||
// }
|
||||
|
||||
@PostMapping("/about/append")
|
||||
@PreAuthorize("hasAuthority('ADMIN')")
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.quinn.controller;
|
||||
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2022-05-03
|
||||
*/
|
||||
@Controller
|
||||
public class SourceCategoryController {
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.List;
|
||||
* @author limqsh
|
||||
* @since 2022-05-03
|
||||
*/
|
||||
@Controller
|
||||
//@Controller
|
||||
public class SourceController extends BaseModelController {
|
||||
|
||||
@Resource
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.io.IOException;
|
||||
* @author limqsh
|
||||
* @since 2022-05-03
|
||||
*/
|
||||
@Controller
|
||||
@PreAuthorize("hasAuthority('ADMIN')")
|
||||
//@Controller
|
||||
//@PreAuthorize("hasAuthority('ADMIN')")
|
||||
public class SourceUploadController {
|
||||
@Resource
|
||||
SourceService sourceService;
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
package com.quinn.intergration;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.quinn.common.ExpBucket;
|
||||
import com.quinn.utils.JsonUtils;
|
||||
import com.quinn.vo.MyPageParam;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class BucketImage implements InitializingBean {
|
||||
|
||||
Map<String,String> dictionary = new HashMap<>();
|
||||
|
||||
public List<ExpBucket> listExp(String findWhat, MyPageParam myPageParam) throws IOException {
|
||||
List<ExpBucket> result = new ArrayList<>();
|
||||
if (CollectionUtils.isEmpty(dictionary)){
|
||||
makeDictionary();
|
||||
}
|
||||
List<String> resultAll = dictionary.keySet().stream().filter(x ->
|
||||
StringUtils.isEmpty(findWhat) ? true : x.contains(findWhat)).collect(Collectors.toList());
|
||||
myPageParam.setTotal(resultAll.size());
|
||||
int pageNum = myPageParam.getPageNum();
|
||||
for (int i = 0;i<myPageParam.getSize(); i++){
|
||||
if (pageNum + i >= myPageParam.getTotal()){
|
||||
break;
|
||||
}
|
||||
ExpBucket expBucket = new ExpBucket();
|
||||
expBucket.setName(resultAll.get(pageNum + i));
|
||||
expBucket.setUrl(dictionary.get(resultAll.get(pageNum + i)));
|
||||
result.add(expBucket);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
makeDictionary();
|
||||
}
|
||||
|
||||
private void makeDictionary() throws IOException {
|
||||
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
Resource[] resources = resolver.getResources("bqb/image.json");
|
||||
Resource resource = resources[0];
|
||||
InputStream is = resource.getInputStream();
|
||||
InputStreamReader insReader = new InputStreamReader(
|
||||
is, "UTF-8");
|
||||
BufferedReader bufReader = new BufferedReader(insReader);
|
||||
String json = bufReader.readLine();
|
||||
bufReader.close();
|
||||
insReader.close();
|
||||
List<ExpBucket> decode = JsonUtils.decode(json, new TypeReference<List<ExpBucket>>() {
|
||||
});
|
||||
for (ExpBucket expBucket : decode) {
|
||||
this.dictionary.put(expBucket.getName(),expBucket.getUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,29 +3,19 @@
|
||||
<mapper namespace="com.quinn.mapper.FindMapper">
|
||||
|
||||
<select id="countListFinds" resultType="int">
|
||||
select count(1) from (
|
||||
select 1 from qn_source a
|
||||
where a.source_name like CONCAT('%',#{findWhat},'%')
|
||||
or a.content_json like CONCAT('%',#{findWhat},'%')
|
||||
union all
|
||||
select 1 from qn_blog b
|
||||
select count(1) from qn_blog b
|
||||
where (b.title like CONCAT('%',#{findWhat},'%')
|
||||
or b.content_json like CONCAT('%',#{findWhat},'%'))
|
||||
and b.category_id = '2'
|
||||
) t
|
||||
</select>
|
||||
|
||||
<select id="listFinds" resultType="com.quinn.pojo.FindResult">
|
||||
select * from (
|
||||
select a.sid as topicId,'SOURCE' as category,a.gmt_create as gmtCreate,a.source_name as topicName,a.content_json as contentText from qn_source a
|
||||
where a.source_name like CONCAT('%',#{findWhat},'%')
|
||||
or a.content_json like CONCAT('%',#{findWhat},'%')
|
||||
union all
|
||||
select b.bid as topicId,'BLOG' as category,b.gmt_create as gmtCreate,b.title as topicName,b.content_json as contentText from qn_blog b
|
||||
where b.title like CONCAT('%',#{findWhat},'%')
|
||||
or b.content_json like CONCAT('%',#{findWhat},'%')
|
||||
) t order by gmtCreate
|
||||
limit #{myPageParam.pageNum},#{myPageParam.size}
|
||||
where and b.category_id = '2'
|
||||
and (
|
||||
b.title like CONCAT('%',#{findWhat},'%') or b.content_json like CONCAT('%',#{findWhat},'%')
|
||||
)
|
||||
order by b.gmt_create limit #{myPageParam.pageNum},#{myPageParam.size}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
package com.quinn.service;
|
||||
|
||||
import com.quinn.common.ExpBucket;
|
||||
import com.quinn.pojo.About;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.quinn.vo.MyPageParam;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -18,6 +13,4 @@ import java.util.List;
|
||||
*/
|
||||
public interface AboutService extends IService<About> {
|
||||
|
||||
List<ExpBucket> listExp(String findWhat, MyPageParam pageParam) throws IOException;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
package com.quinn.service.impl;
|
||||
|
||||
import com.quinn.common.ExpBucket;
|
||||
import com.quinn.intergration.BucketImage;
|
||||
import com.quinn.pojo.About;
|
||||
import com.quinn.mapper.AboutMapper;
|
||||
import com.quinn.service.AboutService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.quinn.vo.MyPageParam;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -24,11 +18,4 @@ import java.util.List;
|
||||
@Service
|
||||
public class AboutServiceImpl extends ServiceImpl<AboutMapper, About> implements AboutService {
|
||||
|
||||
@Resource
|
||||
BucketImage bucketImage;
|
||||
|
||||
@Override
|
||||
public List<ExpBucket> listExp(String findWhat, MyPageParam pageParam) throws IOException {
|
||||
return bucketImage.listExp(findWhat,pageParam);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user