热点资源
This commit is contained in:
7
src/main/java/com/quinn/common/QuinnConstant.java
Normal file
7
src/main/java/com/quinn/common/QuinnConstant.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.quinn.common;
|
||||
|
||||
public interface QuinnConstant {
|
||||
|
||||
String LINK_SUFFIX = ".";
|
||||
|
||||
}
|
||||
@@ -3,11 +3,11 @@ package com.quinn.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.quinn.common.QuinnConstant;
|
||||
import com.quinn.pojo.*;
|
||||
import com.quinn.service.SourceCategoryService;
|
||||
import com.quinn.service.SourceCommentService;
|
||||
import com.quinn.service.SourceService;
|
||||
import com.quinn.utils.UUIDGenerator;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -41,8 +41,7 @@ public class SourceController {
|
||||
|
||||
// 列表展示
|
||||
@GetMapping("/source")
|
||||
public String blogList(@RequestParam String name,@RequestParam int category,Model model){
|
||||
System.out.println(name + category);
|
||||
public String sourceList(@RequestParam String name,@RequestParam int category,Model model){
|
||||
Page<Source> pageParam = new Page<>(1, 10);
|
||||
QueryWrapper<Source> sourceQuery = new QueryWrapper<>();
|
||||
sourceQuery.orderByDesc("gmt_create");
|
||||
@@ -59,6 +58,20 @@ public class SourceController {
|
||||
return "source/list";
|
||||
}
|
||||
|
||||
// 列表展示
|
||||
@GetMapping("/hot/source")
|
||||
public String sourceHotPot(Model model){
|
||||
Page<Source> pageParam = new Page<>(1, 10);
|
||||
QueryWrapper<Source> sourceQuery = new QueryWrapper<>();
|
||||
sourceQuery.orderByDesc("down_record");
|
||||
sourceService.page(pageParam,sourceQuery);
|
||||
// 结果
|
||||
List<Source> sourceList = pageParam.getRecords();
|
||||
model.addAttribute("sourceList",sourceList);
|
||||
return "source/list";
|
||||
}
|
||||
|
||||
|
||||
// 查看文件详情
|
||||
@GetMapping("/source/view/{sid}")
|
||||
public String read(@PathVariable("sid") String sid, Model model){
|
||||
@@ -73,11 +86,11 @@ public class SourceController {
|
||||
// 下载文件
|
||||
@GetMapping("/source/download/{sid}")
|
||||
public void read(HttpServletResponse response, @PathVariable("sid") String sid) throws IOException {
|
||||
Source source = sourceService.getOne(new QueryWrapper<Source>().eq("id", sid));
|
||||
//通知浏览器以附件形式下载
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment;filename=" + UUIDGenerator.randomUUID());
|
||||
this.sourceService.downloadSource(response.getOutputStream(),sid);
|
||||
"attachment;filename=" + source.getEnName() + QuinnConstant.LINK_SUFFIX + source.getFileType());
|
||||
this.sourceService.downloadSource(response.getOutputStream(),source);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -43,15 +43,15 @@ public class CodeGenerator {
|
||||
PackageConfig pc = new PackageConfig();
|
||||
pc.setModuleName("quinn");
|
||||
pc.setParent("com");
|
||||
pc.setController("controller");
|
||||
// pc.setController("controller");
|
||||
pc.setEntity("pojo");
|
||||
pc.setService("service");
|
||||
pc.setMapper("mapper");
|
||||
// pc.setService("service");
|
||||
// pc.setMapper("mapper");
|
||||
mpg.setPackageInfo(pc);
|
||||
|
||||
// 5、策略配置
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
strategy.setInclude("qn_source_comment");//设置要映射的表名
|
||||
strategy.setInclude("qn_source");//设置要映射的表名
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略
|
||||
strategy.setTablePrefix("qn_");//设置表前缀不生成
|
||||
|
||||
|
||||
@@ -58,6 +58,12 @@ public class Source implements Serializable {
|
||||
@ApiModelProperty(value = "类别名")
|
||||
private String categoryName;
|
||||
|
||||
@ApiModelProperty(value = "英文名")
|
||||
private String enName;
|
||||
|
||||
@ApiModelProperty(value = "文件后缀")
|
||||
private String fileType;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date gmtCreate;
|
||||
|
||||
|
||||
@@ -17,6 +17,6 @@ import java.io.OutputStream;
|
||||
*/
|
||||
public interface SourceService extends IService<Source> {
|
||||
|
||||
void downloadSource(ServletOutputStream outputStream, String sid) throws IOException;
|
||||
void downloadSource(ServletOutputStream outputStream, Source source) throws IOException;
|
||||
|
||||
}
|
||||
|
||||
@@ -30,8 +30,7 @@ public class SourceServiceImpl extends ServiceImpl<SourceMapper, Source> impleme
|
||||
OSSClientUtil ossClientUtil;
|
||||
|
||||
@Override
|
||||
public void downloadSource(ServletOutputStream outputStream, String sid) throws IOException {
|
||||
Source source = getOne(new QueryWrapper<Source>().eq("id", sid));
|
||||
public void downloadSource(ServletOutputStream outputStream, Source source) throws IOException {
|
||||
String sourceLink = source.getSourceLink();
|
||||
// 读取文件内容。
|
||||
BufferedInputStream in = new BufferedInputStream(ossClientUtil.downloadFile(sourceLink));
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<main role="main" class="mt-3">
|
||||
<div class="container">
|
||||
<div class="alert alert-primary" role="alert">
|
||||
资源慢慢日积月累,需要什么可以在群里@我,如果我有就放到这里!
|
||||
需要什么资料请提交论坛,或者关注公众号反馈!我们会及时更新!
|
||||
</div>
|
||||
|
||||
<div class="card-deck mb-3 text-center">
|
||||
Reference in New Issue
Block a user