可以对资源进行增删改
This commit is contained in:
@@ -3,6 +3,10 @@ package com.quinn.common;
|
|||||||
public interface QuinnConstant {
|
public interface QuinnConstant {
|
||||||
|
|
||||||
String LINK_SUFFIX = ".";
|
String LINK_SUFFIX = ".";
|
||||||
|
|
||||||
|
String LINK_KEY_WORD = ",";
|
||||||
|
|
||||||
|
String LINK_DATE_STR = "_";
|
||||||
/**
|
/**
|
||||||
* REDIS PATTEN
|
* REDIS PATTEN
|
||||||
*/
|
*/
|
||||||
@@ -11,5 +15,9 @@ public interface QuinnConstant {
|
|||||||
String GUN = "The emperor's new clothes";
|
String GUN = "The emperor's new clothes";
|
||||||
|
|
||||||
String SOURCE_KEY = "SOURCE_KEY_";
|
String SOURCE_KEY = "SOURCE_KEY_";
|
||||||
|
/**
|
||||||
|
* PASSWORD //TODO 可以配置数据库MD5加密
|
||||||
|
*/
|
||||||
|
String SOURCE_PASSWORD = "926462";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/main/java/com/quinn/common/SourceType.java
Normal file
14
src/main/java/com/quinn/common/SourceType.java
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package com.quinn.common;
|
||||||
|
|
||||||
|
public enum SourceType {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OSS文件
|
||||||
|
*/
|
||||||
|
OSS,
|
||||||
|
/**
|
||||||
|
* 百度网盘
|
||||||
|
*/
|
||||||
|
BAIDU
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.quinn.config;
|
package com.quinn.config;
|
||||||
|
|
||||||
|
import com.quinn.common.SourceType;
|
||||||
import com.quinn.service.impl.UserServiceImpl;
|
import com.quinn.service.impl.UserServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@@ -27,6 +28,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
http.authorizeRequests()
|
http.authorizeRequests()
|
||||||
.antMatchers("/","/index").permitAll()
|
.antMatchers("/","/index").permitAll()
|
||||||
.antMatchers("/register","/login","/toLogin").permitAll()
|
.antMatchers("/register","/login","/toLogin").permitAll()
|
||||||
|
.antMatchers("/tracy/mcgrady/lmq/love/wn").permitAll()
|
||||||
.antMatchers("/*").authenticated();
|
.antMatchers("/*").authenticated();
|
||||||
|
|
||||||
// 登录配置
|
// 登录配置
|
||||||
|
|||||||
@@ -26,11 +26,19 @@ public class LoginController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
UserInfoService userInfoService;
|
UserInfoService userInfoService;
|
||||||
|
|
||||||
@GetMapping({"/","/index"})
|
@GetMapping({"/","/index","/source/view/index",
|
||||||
|
"/tracy/mcgrady/lmq/love/wn/index",
|
||||||
|
"/blog/read/index"
|
||||||
|
})
|
||||||
public String index(){
|
public String index(){
|
||||||
return "index";
|
return "index";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/error/check")
|
||||||
|
public String error(){
|
||||||
|
return "error/check";
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/toLogin")
|
@GetMapping("/toLogin")
|
||||||
public String toLogin(){
|
public String toLogin(){
|
||||||
return "login";
|
return "login";
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ import java.util.List;
|
|||||||
* @author limqsh
|
* @author limqsh
|
||||||
* @since 2020-06-28
|
* @since 2020-06-28
|
||||||
*/
|
*/
|
||||||
@Controller
|
//@Controller
|
||||||
|
@Deprecated
|
||||||
public class QuestionCategoryController {
|
public class QuestionCategoryController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ import java.util.UUID;
|
|||||||
* @author limqsh
|
* @author limqsh
|
||||||
* @since 2020-06-28
|
* @since 2020-06-28
|
||||||
*/
|
*/
|
||||||
@Controller
|
//@Controller
|
||||||
|
@Deprecated
|
||||||
public class QuestionController {
|
public class QuestionController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.quinn.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 前端控制器
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author limqsh
|
|
||||||
* @since 2022-05-03
|
|
||||||
*/
|
|
||||||
@Controller
|
|
||||||
public class SourceCommentController {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -4,11 +4,13 @@ package com.quinn.controller;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.quinn.common.QuinnConstant;
|
import com.quinn.common.QuinnConstant;
|
||||||
|
import com.quinn.common.SourceType;
|
||||||
import com.quinn.pojo.*;
|
import com.quinn.pojo.*;
|
||||||
import com.quinn.pojo.param.QuerySource;
|
import com.quinn.pojo.param.QuerySource;
|
||||||
import com.quinn.service.SourceCategoryService;
|
import com.quinn.service.SourceCategoryService;
|
||||||
import com.quinn.service.SourceCommentService;
|
import com.quinn.service.SourceCommentService;
|
||||||
import com.quinn.service.SourceService;
|
import com.quinn.service.SourceService;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
@@ -53,6 +55,10 @@ public class SourceController {
|
|||||||
if (!CollectionUtils.isEmpty(sourceList)){
|
if (!CollectionUtils.isEmpty(sourceList)){
|
||||||
sourceList.forEach(x ->{
|
sourceList.forEach(x ->{
|
||||||
x.setSourceLink(QuinnConstant.GUN);
|
x.setSourceLink(QuinnConstant.GUN);
|
||||||
|
x.setKeyWord1(QuinnConstant.GUN);
|
||||||
|
x.setKeyWord2(QuinnConstant.GUN);
|
||||||
|
x.setKeyWord3(QuinnConstant.GUN);
|
||||||
|
x.setSourceContent(QuinnConstant.GUN);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
model.addAttribute("sourceList",sourceList);
|
model.addAttribute("sourceList",sourceList);
|
||||||
@@ -97,7 +103,10 @@ public class SourceController {
|
|||||||
if (!CollectionUtils.isEmpty(sourceList)){
|
if (!CollectionUtils.isEmpty(sourceList)){
|
||||||
sourceList.forEach(x ->{
|
sourceList.forEach(x ->{
|
||||||
x.setSourceLink(QuinnConstant.GUN);
|
x.setSourceLink(QuinnConstant.GUN);
|
||||||
x.setSourceContent("");
|
x.setKeyWord1(QuinnConstant.GUN);
|
||||||
|
x.setKeyWord2(QuinnConstant.GUN);
|
||||||
|
x.setKeyWord3(QuinnConstant.GUN);
|
||||||
|
x.setSourceContent(QuinnConstant.GUN);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
model.addAttribute("sourceList",sourceList);
|
model.addAttribute("sourceList",sourceList);
|
||||||
@@ -113,9 +122,13 @@ public class SourceController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/source/view/{sid}")
|
@GetMapping("/source/view/{sid}")
|
||||||
public String read(@PathVariable("sid") String sid, Model model){
|
public String read(@PathVariable("sid") String sid, Model model){
|
||||||
Source source = sourceService.hotResource(sid);
|
Source source = sourceService.view(sid);
|
||||||
if(source != null){
|
if(source != null){
|
||||||
source.setSourceLink(QuinnConstant.GUN);
|
source.setSourceLink(QuinnConstant.GUN);
|
||||||
|
source.setKeyWord1(QuinnConstant.GUN);
|
||||||
|
source.setKeyWord2(QuinnConstant.GUN);
|
||||||
|
source.setKeyWord3(QuinnConstant.GUN);
|
||||||
|
source.setSourceType(QuinnConstant.GUN);
|
||||||
}
|
}
|
||||||
model.addAttribute("source",source);
|
model.addAttribute("source",source);
|
||||||
List<SourceComment> commentList = sourceCommentService.list(new QueryWrapper<SourceComment>().eq("topic_id", sid).orderByDesc("gmt_create"));
|
List<SourceComment> commentList = sourceCommentService.list(new QueryWrapper<SourceComment>().eq("topic_id", sid).orderByDesc("gmt_create"));
|
||||||
@@ -129,13 +142,19 @@ public class SourceController {
|
|||||||
* @param sid
|
* @param sid
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@GetMapping("/source/download/{sid}")
|
@PostMapping("/source/download/{sid}")
|
||||||
public void download(HttpServletResponse response, @PathVariable("sid") String sid) throws IOException {
|
public void download(HttpServletResponse response, @PathVariable("sid") String sid) throws IOException {
|
||||||
Source source = sourceService.getOne(new QueryWrapper<Source>().eq("id", sid));
|
Source source = sourceService.getOne(new QueryWrapper<Source>().eq("sid", sid));
|
||||||
//通知浏览器以附件形式下载
|
if (source!=null){
|
||||||
response.setHeader("Content-Disposition",
|
if (SourceType.OSS.name().equals(source.getSourceType())){
|
||||||
"attachment;filename=" + source.getEnName() + QuinnConstant.LINK_SUFFIX + source.getFileType());
|
//通知浏览器以附件形式下载
|
||||||
this.sourceService.downloadSource(response.getOutputStream(),source);
|
response.setHeader("Content-Disposition",
|
||||||
|
"attachment;filename=" + source.getEnName() + QuinnConstant.LINK_SUFFIX + source.getFileType());
|
||||||
|
this.sourceService.downloadSource(response,source);
|
||||||
|
}else {
|
||||||
|
this.sourceService.downloadForBaidu(response,source);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addParam(QueryWrapper<Source> sourceQuery, String name, int category) {
|
private void addParam(QueryWrapper<Source> sourceQuery, String name, int category) {
|
||||||
|
|||||||
110
src/main/java/com/quinn/controller/SourceUploadController.java
Normal file
110
src/main/java/com/quinn/controller/SourceUploadController.java
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
package com.quinn.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.quinn.common.QuinnConstant;
|
||||||
|
import com.quinn.pojo.Source;
|
||||||
|
import com.quinn.pojo.SourceCategory;
|
||||||
|
import com.quinn.service.SourceCategoryService;
|
||||||
|
import com.quinn.service.SourceService;
|
||||||
|
import com.quinn.vo.SourceDeleteForm;
|
||||||
|
import com.quinn.vo.SourceUpdateForm;
|
||||||
|
import com.quinn.vo.SourceWriteForm;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author limqsh
|
||||||
|
* @since 2022-05-03
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
public class SourceUploadController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
SourceCategoryService sourceCategoryService;
|
||||||
|
@Resource
|
||||||
|
SourceService sourceService;
|
||||||
|
|
||||||
|
// 写文章
|
||||||
|
@GetMapping("/tracy/mcgrady/lmq/love/wn")
|
||||||
|
public String toWrite(Model model){
|
||||||
|
// 分类信息
|
||||||
|
List<SourceCategory> categoryList = sourceCategoryService.list(null);
|
||||||
|
model.addAttribute("categoryList",categoryList);
|
||||||
|
return "source/uploadSource";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/tracy/mcgrady/lmq/love/wn")
|
||||||
|
public synchronized String write(MultipartFile file, SourceWriteForm sourceWriteForm) throws IOException {
|
||||||
|
if (!QuinnConstant.SOURCE_PASSWORD.equals(sourceWriteForm.getUploadPassWord())){
|
||||||
|
return "error/check";
|
||||||
|
}
|
||||||
|
sourceService.uploadNewSource(file,sourceWriteForm);
|
||||||
|
// 重定向到列表页面
|
||||||
|
return "redirect:/source";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑信息
|
||||||
|
@GetMapping("/tracy/mcgrady/lmq/love/wn/{sid}")
|
||||||
|
public String toEdit(@PathVariable("sid") String sid, Model model){
|
||||||
|
Source source = sourceService.getOne(new QueryWrapper<Source>().eq("sid",sid));
|
||||||
|
source.setKeyWord1(concatKeyWord(source.getKeyWord2()) + concatKeyWord(source.getKeyWord2()) + concatKeyWord(source.getKeyWord3()));
|
||||||
|
model.addAttribute("source",source);
|
||||||
|
// 分类信息
|
||||||
|
List<SourceCategory> categoryList = sourceCategoryService.list(null);
|
||||||
|
model.addAttribute("categoryList",categoryList);
|
||||||
|
return "source/editorSource";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String concatKeyWord(String keyWord) {
|
||||||
|
if (!StringUtils.isEmpty(keyWord)) {
|
||||||
|
return keyWord + QuinnConstant.LINK_KEY_WORD;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑信息
|
||||||
|
@PostMapping("/tracy/mcgrady/lmq/love/wn/update")
|
||||||
|
public String toEdit(MultipartFile file, SourceUpdateForm sourceUpdateForm) throws IOException {
|
||||||
|
if (!QuinnConstant.SOURCE_PASSWORD.equals(sourceUpdateForm.getUploadPassWord())){
|
||||||
|
return "error/check";
|
||||||
|
}
|
||||||
|
sourceService.updateSource(file,sourceUpdateForm);
|
||||||
|
// 重定向详情页面
|
||||||
|
return "redirect:/source/view/" + sourceUpdateForm.getSid();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑信息
|
||||||
|
@PostMapping("/tracy/mcgrady/lmq/love/wn/del")
|
||||||
|
public void toEdit(HttpServletResponse response, SourceDeleteForm sourceDeleteForm) throws IOException {
|
||||||
|
PrintWriter writer = response.getWriter();
|
||||||
|
if (!QuinnConstant.SOURCE_PASSWORD.equals(sourceDeleteForm.getUploadPassWord())){
|
||||||
|
writer.write("/error/check");
|
||||||
|
writer.flush();
|
||||||
|
writer.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sourceService.deleteSource(sourceDeleteForm.getSid());
|
||||||
|
// 重定向详情页面
|
||||||
|
writer.write("/source");
|
||||||
|
writer.flush();
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ import lombok.experimental.Accessors;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author limqsh
|
* @author limqsh
|
||||||
@@ -31,6 +31,9 @@ public class Source implements Serializable {
|
|||||||
@TableId(value = "id", type = IdType.AUTO)
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "资源ID")
|
||||||
|
private String sid;
|
||||||
|
|
||||||
@ApiModelProperty(value = "资源名")
|
@ApiModelProperty(value = "资源名")
|
||||||
private String sourceName;
|
private String sourceName;
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,12 @@ package com.quinn.service;
|
|||||||
|
|
||||||
import com.quinn.pojo.Source;
|
import com.quinn.pojo.Source;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.quinn.vo.SourceUpdateForm;
|
||||||
|
import com.quinn.vo.SourceWriteForm;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.ServletOutputStream;
|
import javax.servlet.ServletOutputStream;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
@@ -19,17 +23,38 @@ public interface SourceService extends IService<Source> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载对应的资源
|
* 下载对应的资源
|
||||||
* @param outputStream
|
* @param response
|
||||||
* @param source
|
* @param source
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
void downloadSource(ServletOutputStream outputStream, Source source) throws IOException;
|
void downloadSource(HttpServletResponse response, Source source) throws IOException;
|
||||||
|
|
||||||
|
void downloadForBaidu(HttpServletResponse response, Source source) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 点击对应的资源
|
* 点击对应的资源
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Source hotResource(String sid);
|
Source view(String sid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传新资源
|
||||||
|
* @param file
|
||||||
|
* @param sourceWriteForm
|
||||||
|
*/
|
||||||
|
void uploadNewSource(MultipartFile file, SourceWriteForm sourceWriteForm) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新资源
|
||||||
|
* @param file
|
||||||
|
* @param sourceUpdateForm
|
||||||
|
*/
|
||||||
|
void updateSource(MultipartFile file, SourceUpdateForm sourceUpdateForm) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资源
|
||||||
|
* @param sid
|
||||||
|
*/
|
||||||
|
void deleteSource(String sid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,20 +2,29 @@ package com.quinn.service.impl;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.quinn.common.QuinnConstant;
|
import com.quinn.common.QuinnConstant;
|
||||||
|
import com.quinn.common.SourceType;
|
||||||
|
import com.quinn.mapper.SourceCategoryMapper;
|
||||||
import com.quinn.pojo.Source;
|
import com.quinn.pojo.Source;
|
||||||
import com.quinn.mapper.SourceMapper;
|
import com.quinn.mapper.SourceMapper;
|
||||||
|
import com.quinn.pojo.SourceCategory;
|
||||||
import com.quinn.service.SourceService;
|
import com.quinn.service.SourceService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.quinn.utils.OSSClientUtil;
|
import com.quinn.utils.OSSClientUtil;
|
||||||
|
import com.quinn.utils.QuinnUtils;
|
||||||
import com.quinn.utils.RedisUtils;
|
import com.quinn.utils.RedisUtils;
|
||||||
|
import com.quinn.vo.SourceUpdateForm;
|
||||||
|
import com.quinn.vo.SourceWriteForm;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.ServletOutputStream;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -32,14 +41,16 @@ public class SourceServiceImpl extends ServiceImpl<SourceMapper, Source> impleme
|
|||||||
OSSClientUtil ossClientUtil;
|
OSSClientUtil ossClientUtil;
|
||||||
@Resource
|
@Resource
|
||||||
RedisUtils redisUtils;
|
RedisUtils redisUtils;
|
||||||
|
@Resource
|
||||||
|
SourceCategoryMapper sourceCategoryMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void downloadSource(ServletOutputStream outputStream, Source source) throws IOException {
|
public void downloadSource(HttpServletResponse response, Source source) throws IOException {
|
||||||
String sourceLink = source.getSourceLink();
|
String sourceLink = source.getSourceLink();
|
||||||
addDownLoadRecord(source);
|
addDownLoadRecord(source);
|
||||||
// 读取文件内容。
|
// 读取文件内容。
|
||||||
BufferedInputStream in = new BufferedInputStream(ossClientUtil.downloadFile(sourceLink));
|
BufferedInputStream in = new BufferedInputStream(ossClientUtil.downloadFile(sourceLink));
|
||||||
BufferedOutputStream out = new BufferedOutputStream(outputStream);
|
BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024];
|
||||||
int lenght = 0;
|
int lenght = 0;
|
||||||
while ((lenght = in.read(buffer)) != -1) {
|
while ((lenght = in.read(buffer)) != -1) {
|
||||||
@@ -55,26 +66,137 @@ public class SourceServiceImpl extends ServiceImpl<SourceMapper, Source> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Source hotResource(String sid) {
|
public void downloadForBaidu(HttpServletResponse response, Source source) throws IOException {
|
||||||
Source source = getOne(new QueryWrapper<Source>().eq("id", sid));
|
addDownLoadRecord(source);
|
||||||
|
PrintWriter writer = response.getWriter();
|
||||||
|
writer.write(source.getSourceLink());
|
||||||
|
writer.flush();
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Source view(String sid) {
|
||||||
|
Source source = getOne(new QueryWrapper<Source>().eq("sid", sid));
|
||||||
addDownLoadRecord(source);
|
addDownLoadRecord(source);
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uploadNewSource(MultipartFile file, SourceWriteForm sourceWriteForm) throws IOException {
|
||||||
|
// 先进行文件上传成功再落地
|
||||||
|
String fileType = "";
|
||||||
|
String fileLink = sourceWriteForm.getSourceLink();
|
||||||
|
if (file != null && !file.isEmpty() && SourceType.OSS.name().equals(sourceWriteForm.getSourceType())){
|
||||||
|
String originalFilename = file.getOriginalFilename();
|
||||||
|
fileType = originalFilename.substring(originalFilename.lastIndexOf(QuinnConstant.LINK_SUFFIX)).toLowerCase();
|
||||||
|
fileLink = ossClientUtil.uploadFile(QuinnUtils.getUuid() + QuinnConstant.LINK_DATE_STR
|
||||||
|
+ QuinnUtils.getStrFromDate(new Date()), file.getInputStream());
|
||||||
|
}
|
||||||
|
// 构建问题对象
|
||||||
|
Source source = new Source();
|
||||||
|
source.setSid(QuinnUtils.getUuid());
|
||||||
|
source.setEnName(sourceWriteForm.getEnName());
|
||||||
|
source.setFileType(fileType);
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
source.setSourceType(sourceWriteForm.getSourceType());
|
||||||
|
source.setSourceLink(fileLink);
|
||||||
|
|
||||||
|
// 类型
|
||||||
|
source.setCategoryId(sourceWriteForm.getCategoryId());
|
||||||
|
SourceCategory category = sourceCategoryMapper.selectById(sourceWriteForm.getCategoryId());
|
||||||
|
source.setCategoryName(category.getCategory());
|
||||||
|
source.setDownRecord(0);
|
||||||
|
source.setGmtCreate(QuinnUtils.getTime());
|
||||||
|
source.setGmtUpdate(QuinnUtils.getTime());
|
||||||
|
// 存储对象
|
||||||
|
save(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateSource(MultipartFile file, SourceUpdateForm sourceUpdateForm) throws IOException {
|
||||||
|
Source before = getOne(new QueryWrapper<Source>().eq("sid",sourceUpdateForm.getSid()));
|
||||||
|
String fileType = before.getFileType();
|
||||||
|
// 先进行文件上传成功再落地
|
||||||
|
String fileLink = before.getSourceLink();
|
||||||
|
if (file != null && !file.isEmpty() && SourceType.OSS.name().equals(sourceUpdateForm.getSourceType())){
|
||||||
|
// 上传了新文件,需要删除之前的文件
|
||||||
|
ossClientUtil.deleteFile(before.getSourceLink());
|
||||||
|
String originalFilename = file.getOriginalFilename();
|
||||||
|
fileType = originalFilename.substring(originalFilename.lastIndexOf(QuinnConstant.LINK_SUFFIX)).toLowerCase();
|
||||||
|
fileLink = ossClientUtil.uploadFile(QuinnUtils.getUuid() + QuinnConstant.LINK_DATE_STR
|
||||||
|
+ QuinnUtils.getStrFromDate(new Date()), file.getInputStream());
|
||||||
|
}else if (!SourceType.OSS.name().equals(sourceUpdateForm.getSourceType()) && !StringUtils.isEmpty(sourceUpdateForm.getSourceLink())){
|
||||||
|
fileLink = sourceUpdateForm.getSourceLink();
|
||||||
|
}
|
||||||
|
before.setEnName(sourceUpdateForm.getEnName());
|
||||||
|
before.setFileType(fileType);
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
before.setSourceType(sourceUpdateForm.getSourceType());
|
||||||
|
before.setSourceLink(fileLink);
|
||||||
|
|
||||||
|
// 类型
|
||||||
|
before.setCategoryId(sourceUpdateForm.getCategoryId());
|
||||||
|
SourceCategory category = sourceCategoryMapper.selectById(sourceUpdateForm.getCategoryId());
|
||||||
|
before.setCategoryName(category.getCategory());
|
||||||
|
before.setGmtUpdate(QuinnUtils.getTime());
|
||||||
|
updateById(before);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteSource(String sid) {
|
||||||
|
Source before = getOne(new QueryWrapper<Source>().eq("sid",sid));
|
||||||
|
if (SourceType.OSS.name().equals(before.getSourceType())){
|
||||||
|
// 上传了新文件,需要删除之前的文件
|
||||||
|
ossClientUtil.deleteFile(before.getSourceLink());
|
||||||
|
}
|
||||||
|
removeById(before);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新页码
|
* 更新页码
|
||||||
* @param source
|
* @param source
|
||||||
*/
|
*/
|
||||||
private void addDownLoadRecord(Source source) {
|
private void addDownLoadRecord(Source source) {
|
||||||
String downLoadTime = redisUtils.get(QuinnConstant.SOURCE_KEY + source.getId());
|
String downLoadTime = redisUtils.get(QuinnConstant.SOURCE_KEY + source.getSid());
|
||||||
int downTimes = 0;
|
int downTimes = 0;
|
||||||
if (StringUtils.isEmpty(downLoadTime)){
|
if (StringUtils.isEmpty(downLoadTime)){
|
||||||
downTimes = source.getDownRecord() + 1;
|
downTimes = source.getDownRecord() + 1;
|
||||||
}else {
|
}else {
|
||||||
downTimes = Integer.parseInt(downLoadTime) + 1;
|
downTimes = Integer.parseInt(downLoadTime) + 1;
|
||||||
}
|
}
|
||||||
redisUtils.set(QuinnConstant.SOURCE_KEY + source.getId(),downTimes + "");
|
redisUtils.set(QuinnConstant.SOURCE_KEY + source.getSid(),downTimes + "");
|
||||||
source.setDownRecord(source.getDownRecord() + 1);
|
source.setDownRecord(source.getDownRecord() + 1);
|
||||||
updateById(source);
|
updateById(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,10 @@ public class OSSClientUtil {
|
|||||||
private String url;
|
private String url;
|
||||||
private OSSClient ossClient;
|
private OSSClient ossClient;
|
||||||
|
|
||||||
public String upload(String filename, InputStream file) {
|
String SAVE_DIR = "data/recovery/";
|
||||||
return uploadImg(file, filename);
|
|
||||||
|
public String uploadFile(String filename, InputStream file) {
|
||||||
|
return uploadFile(file, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,28 +61,23 @@ public class OSSClientUtil {
|
|||||||
* @param file
|
* @param file
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String uploadImg(MultipartFile file) throws IOException {
|
public String uploadFile(MultipartFile file) throws IOException {
|
||||||
String originalFilename = file.getOriginalFilename();
|
String originalFilename = file.getOriginalFilename();
|
||||||
return uploadImg(file.getInputStream(), originalFilename);
|
return uploadFile(file.getInputStream(), originalFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String uploadImg(InputStream inputStream, String originalFilename) {
|
private String uploadFile(InputStream inputStream, String fileName) {
|
||||||
String backUrl = "";
|
String backUrl = "";
|
||||||
try {
|
try {
|
||||||
ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
|
ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
|
||||||
String substring = originalFilename.substring(originalFilename.lastIndexOf(".")).toLowerCase();
|
backUrl = SAVE_DIR + fileName;
|
||||||
Random random = new Random();
|
|
||||||
String name = random.nextInt(10000) + System.currentTimeMillis() + substring;
|
|
||||||
backUrl = "imageDir/" + name;
|
|
||||||
// 上传文件
|
// 上传文件
|
||||||
ossClient.putObject(bucketName, backUrl, inputStream);
|
ossClient.putObject(bucketName, backUrl, inputStream);
|
||||||
ossClient.setObjectAcl(bucketName, backUrl, CannedAccessControlList.PublicRead);
|
ossClient.setObjectAcl(bucketName, backUrl, CannedAccessControlList.PublicRead);
|
||||||
// 判断是否上传成功
|
// 判断是否上传成功
|
||||||
boolean uploadResult = ossClient.doesObjectExist(bucketName, backUrl);
|
boolean uploadResult = ossClient.doesObjectExist(bucketName, backUrl);
|
||||||
|
|
||||||
if (uploadResult) {
|
if (!uploadResult) {
|
||||||
backUrl = getImgUrl(name);
|
|
||||||
} else {
|
|
||||||
backUrl = "";
|
backUrl = "";
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@@ -112,4 +109,14 @@ public class OSSClientUtil {
|
|||||||
return ossObject.getObjectContent();
|
return ossObject.getObjectContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteFile(String objName){
|
||||||
|
// ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
|
||||||
|
ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
|
||||||
|
try {
|
||||||
|
ossClient.deleteObject(bucketName,objName);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("删除失败",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.quinn.utils;
|
package com.quinn.utils;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -8,6 +9,8 @@ public class QuinnUtils {
|
|||||||
|
|
||||||
static boolean printFlag = true;
|
static boolean printFlag = true;
|
||||||
|
|
||||||
|
private final static SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMdd");
|
||||||
|
|
||||||
public static String getUuid(){
|
public static String getUuid(){
|
||||||
return UUID.randomUUID().toString().replaceAll("-","");
|
return UUID.randomUUID().toString().replaceAll("-","");
|
||||||
}
|
}
|
||||||
@@ -16,6 +19,10 @@ public class QuinnUtils {
|
|||||||
return new Timestamp(new Date().getTime());
|
return new Timestamp(new Date().getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getStrFromDate(Date date){
|
||||||
|
return sdf.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
public static void print(String msg){
|
public static void print(String msg){
|
||||||
if (printFlag){
|
if (printFlag){
|
||||||
System.out.println("quinn:=>"+msg);
|
System.out.println("quinn:=>"+msg);
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ import lombok.experimental.Accessors;
|
|||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class QuestionWriteForm {
|
public class QuestionWriteForm {
|
||||||
|
|
||||||
@ApiModelProperty(value = "问题标题")
|
@ApiModelProperty(value = "标题")
|
||||||
private String title;
|
private String title;
|
||||||
@ApiModelProperty(value = "问题内容")
|
@ApiModelProperty(value = "内容")
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
@ApiModelProperty(value = "问题分类id")
|
@ApiModelProperty(value = "分类")
|
||||||
private Integer categoryId;
|
private Integer categoryId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "作者id")
|
@ApiModelProperty(value = "作者id")
|
||||||
|
|||||||
27
src/main/java/com/quinn/vo/SourceDeleteForm.java
Normal file
27
src/main/java/com/quinn/vo/SourceDeleteForm.java
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package com.quinn.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author limqsh
|
||||||
|
* @since 2022-05-03
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class SourceDeleteForm {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "资源ID")
|
||||||
|
private String sid;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "管理员密码")
|
||||||
|
private String uploadPassWord;
|
||||||
|
|
||||||
|
}
|
||||||
54
src/main/java/com/quinn/vo/SourceUpdateForm.java
Normal file
54
src/main/java/com/quinn/vo/SourceUpdateForm.java
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package com.quinn.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author limqsh
|
||||||
|
* @since 2022-05-03
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class SourceUpdateForm {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "资源ID")
|
||||||
|
private String sid;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "资源名")
|
||||||
|
private String sourceName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "描述")
|
||||||
|
private String detail;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "资源内容")
|
||||||
|
private String sourceContent;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "关键字")
|
||||||
|
private String keyWords;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "资源类型")
|
||||||
|
private String sourceType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "资源链接")
|
||||||
|
private String sourceLink;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "类别ID")
|
||||||
|
private Integer categoryId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "类别名")
|
||||||
|
private String categoryName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "英文名")
|
||||||
|
private String enName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "管理员密码")
|
||||||
|
private String uploadPassWord;
|
||||||
|
|
||||||
|
}
|
||||||
34
src/main/java/com/quinn/vo/SourceWriteForm.java
Normal file
34
src/main/java/com/quinn/vo/SourceWriteForm.java
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
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 SourceWriteForm {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "标题")
|
||||||
|
private String title;
|
||||||
|
@ApiModelProperty(value = "简介")
|
||||||
|
private String subContent;
|
||||||
|
@ApiModelProperty(value = "内容")
|
||||||
|
private String content;
|
||||||
|
@ApiModelProperty(value = "英文名")
|
||||||
|
private String enName;
|
||||||
|
@ApiModelProperty(value = "摘要")
|
||||||
|
private String keyWords;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "分类")
|
||||||
|
private Integer categoryId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "文档类型")
|
||||||
|
private String sourceType;
|
||||||
|
@ApiModelProperty(value = "文档路径")
|
||||||
|
private String sourceLink;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "管理员密码")
|
||||||
|
private String uploadPassWord;
|
||||||
|
}
|
||||||
@@ -1,5 +1,10 @@
|
|||||||
spring.profiles.active=dev
|
spring.profiles.active=dev
|
||||||
|
|
||||||
|
#设置单个文件大小
|
||||||
|
spring.servlet.multipart.max-file-size= 20MB
|
||||||
|
#设置单次请求文件的总大小
|
||||||
|
spring.servlet.multipart.max-request-size= 20MB
|
||||||
|
|
||||||
oss.accessKeyId=LTAIlbtS4W2Xe4OV
|
oss.accessKeyId=LTAIlbtS4W2Xe4OV
|
||||||
oss.accessKeySecret=qWMYkSfmXFtRoIv9q9OCbszcF9U7dX
|
oss.accessKeySecret=qWMYkSfmXFtRoIv9q9OCbszcF9U7dX
|
||||||
oss.protocol=http
|
oss.protocol=http
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ body {
|
|||||||
.NotPage {
|
.NotPage {
|
||||||
position: relative;
|
position: relative;
|
||||||
/*z-index: -10;*/
|
/*z-index: -10;*/
|
||||||
background: #000;
|
background: #4d4d4d;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ try {
|
|||||||
"www.fghrsh.net": ["FGHRSH 的论坛"]
|
"www.fghrsh.net": ["FGHRSH 的论坛"]
|
||||||
},
|
},
|
||||||
"model_message": {
|
"model_message": {
|
||||||
"1": ["来自 Potion Maker 的 Pio 酱 ~"],
|
"1": ["来自 Pio 酱 ~"],
|
||||||
"2": ["来自 Potion Maker 的 Tia 酱 ~"]
|
"2": ["来自 Tia 酱 ~"]
|
||||||
},
|
},
|
||||||
"hitokoto_api_message": {
|
"hitokoto_api_message": {
|
||||||
"lwl12.com": ["干了这碗鸡汤,再来一碗?"],
|
"lwl12.com": ["干了这碗鸡汤,再来一碗?"],
|
||||||
@@ -90,7 +90,7 @@ try {
|
|||||||
{ "selector": "c-player div.volume", "text": ["在这里可以调整<span style=\"color:#0099cc;\">音量</span>呢"] },
|
{ "selector": "c-player div.volume", "text": ["在这里可以调整<span style=\"color:#0099cc;\">音量</span>呢"] },
|
||||||
{ "selector": "c-player div.list-button", "text": ["<span style=\"color:#0099cc;\">播放列表</span>里都有什么呢"] },
|
{ "selector": "c-player div.list-button", "text": ["<span style=\"color:#0099cc;\">播放列表</span>里都有什么呢"] },
|
||||||
{ "selector": "c-player div.lyric-button", "text": ["有<span style=\"color:#0099cc;\">歌词</span>的话就能跟着一起唱呢"] },
|
{ "selector": "c-player div.lyric-button", "text": ["有<span style=\"color:#0099cc;\">歌词</span>的话就能跟着一起唱呢"] },
|
||||||
{ "selector": ".waifu #live2d", "text": ["干嘛呢你,快把手拿开", "鼠…鼠标放错地方了!"] }
|
{ "selector": ".waifu #live2d", "text": ["要不~给我换个位置(ó﹏ò。)", "快…快把手拿开!"] }
|
||||||
],
|
],
|
||||||
"click": [
|
"click": [
|
||||||
{
|
{
|
||||||
@@ -132,7 +132,7 @@ try {
|
|||||||
live2d_settings['screenshotCaptureName']= 'quinn.png';
|
live2d_settings['screenshotCaptureName']= 'quinn.png';
|
||||||
live2d_settings['waifuEdgeSide'] = 'right:88'; // 看板娘贴边方向,例如 'left:0'(靠左 0px), 'right:30'(靠右 30px)
|
live2d_settings['waifuEdgeSide'] = 'right:88'; // 看板娘贴边方向,例如 'left:0'(靠左 0px), 'right:30'(靠右 30px)
|
||||||
live2d_settings['waifuDraggable'] = 'unlimited'; // 拖拽样式,例如 'disable'(禁用), 'axis-x'(只能水平拖拽), 'unlimited'(自由拖拽)
|
live2d_settings['waifuDraggable'] = 'unlimited'; // 拖拽样式,例如 'disable'(禁用), 'axis-x'(只能水平拖拽), 'unlimited'(自由拖拽)
|
||||||
live2d_settings['waifuDraggableRevert'] = true; // 松开鼠标还原拖拽位置,可选 true(真), false(假)
|
live2d_settings['waifuDraggableRevert'] = false; // 松开鼠标还原拖拽位置,可选 true(真), false(假)
|
||||||
initModel(modelJson);
|
initModel(modelJson);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
85
src/main/resources/static/wangedit/js/wang.init.js
Normal file
85
src/main/resources/static/wangedit/js/wang.init.js
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/* 如果使用该初始化方法,请一定要在html放三个标签,或者直接看代码修改内容
|
||||||
|
* <div id="editor-toolbar"></div>
|
||||||
|
* <div id="editor-text-area" style="height: 400px;border: 1px solid lightgrey"></div>
|
||||||
|
* <textarea id="content-textarea" name="content" style="display: none;"></textarea>
|
||||||
|
* 另外此方法依赖layer.js & axios.js 做遮罩弹框,
|
||||||
|
* 也可以重写 uploadImage:onFailed | onError 自定义提示
|
||||||
|
* */
|
||||||
|
const E = window.wangEditor
|
||||||
|
|
||||||
|
// 切换语言
|
||||||
|
const LANG = location.href.indexOf('lang=en') > 0 ? 'en' : 'zh-CN'
|
||||||
|
E.i18nChangeLanguage(LANG)
|
||||||
|
|
||||||
|
const editorConfig = {
|
||||||
|
placeholder: '请输入...',
|
||||||
|
scroll: true, // 禁止编辑器滚动
|
||||||
|
MENU_CONF: {
|
||||||
|
uploadImage: {
|
||||||
|
fieldName: 'your-fileName',
|
||||||
|
server: '#', // 可以配置上传应用的地址
|
||||||
|
base64LimitSize: 2 * 1024 * 1024, // 5M 以下插入 base64
|
||||||
|
// 单个文件的最大体积限制,默认为 2M
|
||||||
|
maxFileSize: 2 * 1024 * 1024,
|
||||||
|
// 单个文件上传失败
|
||||||
|
onFailed(file, res) {
|
||||||
|
console.log("文件过大")
|
||||||
|
$('#warn-text').html(res);
|
||||||
|
$('.toast').toast();
|
||||||
|
},
|
||||||
|
// 上传错误,或者触发 timeout 超时
|
||||||
|
onError(file, err, res) {
|
||||||
|
console.log("文件过大")
|
||||||
|
layer.open({
|
||||||
|
type: 1, //1:自定义内容 2:iframe
|
||||||
|
title: '图片大于2M',
|
||||||
|
// area: ['500px', '170px'],
|
||||||
|
content: '资源有限,大佬请使用网络图片╮(╯▽╰)╭',
|
||||||
|
btn: ['好吧穷鬼'],
|
||||||
|
skin: 'layui-layer-hui',
|
||||||
|
yes: function(){
|
||||||
|
layer.closeAll(); //关闭所有弹出框
|
||||||
|
},
|
||||||
|
cancel: function(){
|
||||||
|
//右上角关闭回调
|
||||||
|
//return false 开启该代码可禁止点击该按钮关闭
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onChange(editor) {
|
||||||
|
// console.log(editor.getHtml())
|
||||||
|
// $('#content-textarea').value = editor.getHtml()
|
||||||
|
const content = editor.children
|
||||||
|
// const contentStr = JSON.stringify(content)
|
||||||
|
// document.getElementById('content-textarea').value = contentStr
|
||||||
|
const html = editor.getHtml()
|
||||||
|
$('#content-textarea').val(html)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 先创建 editor
|
||||||
|
const editor = E.createEditor({
|
||||||
|
selector: '#editor-text-area',
|
||||||
|
// content: [],
|
||||||
|
html: $('#content-textarea').val(),
|
||||||
|
config: editorConfig
|
||||||
|
})
|
||||||
|
|
||||||
|
// 创建 toolbar
|
||||||
|
const toolbar = E.createToolbar({
|
||||||
|
editor,
|
||||||
|
selector: '#editor-toolbar',
|
||||||
|
config: {
|
||||||
|
excludeKeys: 'fullScreen,uploadVideo',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 点击空白处 focus 编辑器
|
||||||
|
$('#editor-text-area')[0].addEventListener('click', e => {
|
||||||
|
if (e.target.id === 'editor-text-area') {
|
||||||
|
editor.blur()
|
||||||
|
editor.focus(true) // focus 到末尾
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -52,13 +52,13 @@
|
|||||||
<div id="blog-content">
|
<div id="blog-content">
|
||||||
<div id="editor-toolbar"></div>
|
<div id="editor-toolbar"></div>
|
||||||
<div id="editor-text-area" style="height: 400px;border: 1px solid lightgrey"></div>
|
<div id="editor-text-area" style="height: 400px;border: 1px solid lightgrey"></div>
|
||||||
<textarea id="blog-textarea" name="content" th:text="${blog.getContent()}" style="display: none;"></textarea>
|
<textarea id="content-textarea" name="content" th:text="${blog.getContent()}" style="display: none;"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="btn btn-primary btn-lg btn-block" type="submit">提交修改</button>
|
<button class="btn btn-primary btn-lg btn-block" onclick="this.disabled=true; this.form.submit();" type="submit">提交修改</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -75,57 +75,8 @@
|
|||||||
<script th:src="@{/live/js/addlive2d.js}"></script>
|
<script th:src="@{/live/js/addlive2d.js}"></script>
|
||||||
|
|
||||||
<script th:src="@{/wangedit/js/wang.min.js}"></script>
|
<script th:src="@{/wangedit/js/wang.min.js}"></script>
|
||||||
<script type="text/javascript">
|
<script th:src="@{/wangedit/js/wang.init.js}"></script>
|
||||||
const E = window.wangEditor
|
<script th:src="@{/layer/layer.js}"></script>
|
||||||
|
<script th:src="@{/js/axios.js}"></script>
|
||||||
// 切换语言
|
|
||||||
const LANG = location.href.indexOf('lang=en') > 0 ? 'en' : 'zh-CN'
|
|
||||||
E.i18nChangeLanguage(LANG)
|
|
||||||
|
|
||||||
const editorConfig = {
|
|
||||||
placeholder: '请输入...',
|
|
||||||
scroll: true, // 禁止编辑器滚动
|
|
||||||
MENU_CONF: {
|
|
||||||
uploadImage: {
|
|
||||||
fieldName: 'your-fileName',
|
|
||||||
base64LimitSize: 10 * 1024 * 1024 // 10M 以下插入 base64
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onChange(editor) {
|
|
||||||
// console.log(editor.getHtml())
|
|
||||||
// $('#blog-textarea').value = editor.getHtml()
|
|
||||||
const content = editor.children
|
|
||||||
// const contentStr = JSON.stringify(content)
|
|
||||||
// document.getElementById('blog-textarea').value = contentStr
|
|
||||||
const html = editor.getHtml()
|
|
||||||
$('#blog-textarea').val(html)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 先创建 editor
|
|
||||||
const editor = E.createEditor({
|
|
||||||
selector: '#editor-text-area',
|
|
||||||
// content: [],
|
|
||||||
html: $('#blog-textarea').val(),
|
|
||||||
config: editorConfig
|
|
||||||
})
|
|
||||||
|
|
||||||
// 创建 toolbar
|
|
||||||
const toolbar = E.createToolbar({
|
|
||||||
editor,
|
|
||||||
selector: '#editor-toolbar',
|
|
||||||
config: {
|
|
||||||
excludeKeys: 'fullScreen',
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// 点击空白处 focus 编辑器
|
|
||||||
$('#editor-text-area').addEventListener('click', e => {
|
|
||||||
if (e.target.id === 'editor-text-area') {
|
|
||||||
editor.blur()
|
|
||||||
editor.focus(true) // focus 到末尾
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<textarea name="content" class="form-control" rows="3" required></textarea>
|
<textarea name="content" class="form-control" rows="3" required></textarea>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary float-right">提交评论</button>
|
<button type="submit" onclick="this.disabled=true; this.form.submit();" class="btn btn-primary float-right">提交评论</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -53,19 +53,18 @@
|
|||||||
<div id="blog-content">
|
<div id="blog-content">
|
||||||
<div id="editor-toolbar"></div>
|
<div id="editor-toolbar"></div>
|
||||||
<div id="editor-text-area" style="height: 400px;border: 1px solid lightgrey"></div>
|
<div id="editor-text-area" style="height: 400px;border: 1px solid lightgrey"></div>
|
||||||
<textarea id="blog-textarea" name="content" style="display: none;"></textarea>
|
<textarea id="content-textarea" name="content" style="display: none;"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="btn btn-primary btn-lg btn-block" type="submit">发布文章</button>
|
<button class="btn btn-primary btn-lg btn-block" type="submit" onclick="this.disabled=true; this.form.submit();" >发布文章</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<div th:replace="~{common/footer::footer}"></div>
|
<div th:replace="~{common/footer::footer}"></div>
|
||||||
|
|
||||||
<a class="to-top">返回顶部</a>
|
<a class="to-top">返回顶部</a>
|
||||||
@@ -76,58 +75,9 @@
|
|||||||
<script th:src="@{/live/js/addlive2d.js}"></script>
|
<script th:src="@{/live/js/addlive2d.js}"></script>
|
||||||
|
|
||||||
<script th:src="@{/wangedit/js/wang.min.js}"></script>
|
<script th:src="@{/wangedit/js/wang.min.js}"></script>
|
||||||
<script type="text/javascript">
|
<script th:src="@{/wangedit/js/wang.init.js}"></script>
|
||||||
const E = window.wangEditor
|
<script th:src="@{/layer/layer.js}"></script>
|
||||||
|
<script th:src="@{/js/axios.js}"></script>
|
||||||
// 切换语言
|
|
||||||
const LANG = location.href.indexOf('lang=en') > 0 ? 'en' : 'zh-CN'
|
|
||||||
E.i18nChangeLanguage(LANG)
|
|
||||||
|
|
||||||
const editorConfig = {
|
|
||||||
placeholder: '请输入...',
|
|
||||||
scroll: true, // 禁止编辑器滚动
|
|
||||||
MENU_CONF: {
|
|
||||||
uploadImage: {
|
|
||||||
fieldName: 'your-fileName',
|
|
||||||
base64LimitSize: 10 * 1024 * 1024 // 10M 以下插入 base64
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onChange(editor) {
|
|
||||||
// console.log(editor.getHtml())
|
|
||||||
// $('#blog-textarea').value = editor.getHtml()
|
|
||||||
const content = editor.children
|
|
||||||
// const contentStr = JSON.stringify(content)
|
|
||||||
// document.getElementById('blog-textarea').value = contentStr
|
|
||||||
const html = editor.getHtml()
|
|
||||||
$('#blog-textarea').val(html)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 先创建 editor
|
|
||||||
const editor = E.createEditor({
|
|
||||||
selector: '#editor-text-area',
|
|
||||||
content: [],
|
|
||||||
// html: '',
|
|
||||||
config: editorConfig
|
|
||||||
})
|
|
||||||
|
|
||||||
// 创建 toolbar
|
|
||||||
const toolbar = E.createToolbar({
|
|
||||||
editor,
|
|
||||||
selector: '#editor-toolbar',
|
|
||||||
config: {
|
|
||||||
excludeKeys: 'fullScreen',
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// 点击空白处 focus 编辑器
|
|
||||||
$('#editor-text-area').addEventListener('click', e => {
|
|
||||||
if (e.target.id === 'editor-text-area') {
|
|
||||||
editor.blur()
|
|
||||||
editor.focus(true) // focus 到末尾
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -20,9 +20,9 @@
|
|||||||
<li th:class="${activeUrl=='index.html'?'nav-item active':'nav-item'}">
|
<li th:class="${activeUrl=='index.html'?'nav-item active':'nav-item'}">
|
||||||
<a class="nav-link" th:href="@{/index}">首页 </a>
|
<a class="nav-link" th:href="@{/index}">首页 </a>
|
||||||
</li>
|
</li>
|
||||||
<li th:class="${activeUrl=='question'?'nav-item active':'nav-item'}">
|
<!-- <li th:class="${activeUrl=='question'?'nav-item active':'nav-item'}">-->
|
||||||
<a class="nav-link" th:href="@{/question}">问答 </a>
|
<!-- <a class="nav-link" th:href="@{/question}">问答 </a>-->
|
||||||
</li>
|
<!-- </li>-->
|
||||||
<li th:class="${activeUrl=='blog'?'nav-item active':'nav-item'}">
|
<li th:class="${activeUrl=='blog'?'nav-item active':'nav-item'}">
|
||||||
<a class="nav-link" th:href="@{/blog}">论坛 </a>
|
<a class="nav-link" th:href="@{/blog}">论坛 </a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
18
src/main/resources/templates/error/check.html
Normal file
18
src/main/resources/templates/error/check.html
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<title>ERROR-Quinn</title>
|
||||||
|
<link rel="stylesheet" th:href="@{/css/error.css}">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="NotPage">
|
||||||
|
<div class="message"><a th:href="@{/index}" style="color: white">请使用浏览器后退,或者点此处【主页】</a></div>
|
||||||
|
<div class="message2" style="text-align: center"><a style="color: white">Quinn-管理员密码错误,请关注公众号寻找密码!</a></div>
|
||||||
|
<img th:src="@{/images/logo/logo.png}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="btn btn-lg btn-primary btn-block mt-3" type="submit">登 录</button>
|
<button class="btn btn-lg btn-primary btn-block mt-3" type="submit" onclick="this.disabled=true; this.form.submit();">登 录</button>
|
||||||
|
|
||||||
<p class="clearfix">
|
<p class="clearfix">
|
||||||
<a th:href="@{/register}" class="float-right">没有账号?去注册</a>
|
<a th:href="@{/register}" class="float-right">没有账号?去注册</a>
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="btn btn-primary btn-lg btn-block" type="submit">提交修改</button>
|
<button class="btn btn-primary btn-lg btn-block" type="submit" onclick="this.disabled=true; this.form.submit();">提交修改</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<textarea required name="content" class="form-control" rows="3"></textarea>
|
<textarea required name="content" class="form-control" rows="3"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary float-right">提交评论</button>
|
<button type="submit" onclick="this.disabled=true; this.form.submit();" class="btn btn-primary float-right">提交评论</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="btn btn-primary btn-lg btn-block" type="submit">发布问题</button>
|
<button class="btn btn-primary btn-lg btn-block" type="submit" onclick="this.disabled=true; this.form.submit();">发布问题</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<input type="password" name="repassword" class="form-control" placeholder="确认密码" required="">
|
<input type="password" name="repassword" class="form-control" placeholder="确认密码" required="">
|
||||||
<input type="text" name="code" class="form-control" placeholder="社区邀请码" required="">
|
<input type="text" name="code" class="form-control" placeholder="社区邀请码" required="">
|
||||||
|
|
||||||
<button class="btn btn-lg btn-primary btn-block mt-3" type="submit">注 册</button>
|
<button class="btn btn-lg btn-primary btn-block mt-3" type="submit" onclick="this.disabled=true; this.form.submit();">注 册</button>
|
||||||
|
|
||||||
<p class="clearfix">
|
<p class="clearfix">
|
||||||
<a th:href="@{/toLogin}" class="float-right">已有账号?去登录</a>
|
<a th:href="@{/toLogin}" class="float-right">已有账号?去登录</a>
|
||||||
|
|||||||
151
src/main/resources/templates/source/editorSource.html
Normal file
151
src/main/resources/templates/source/editorSource.html
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<title>论坛-Quinn</title>
|
||||||
|
<link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}">
|
||||||
|
<link rel="stylesheet" th:href="@{/wangedit/css/wang.style.css}"/>
|
||||||
|
</head>
|
||||||
|
<body style="background: #f2f2f2;">
|
||||||
|
|
||||||
|
<!-- 导航栏 -->
|
||||||
|
<main role="main" class="container mt-3 p-3 bg-white rounded">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 blog-main">
|
||||||
|
<div class="col-md-12 order-md-1">
|
||||||
|
<div class="row mb-4">
|
||||||
|
<h4 class="col-md-11">修改资源</h4>
|
||||||
|
<a href="javascript:deleteFile(this);" class="btn btn-outline-danger col-md-1">删除资源</a>
|
||||||
|
</div>
|
||||||
|
<form class="needs-validation" th:action="@{/tracy/mcgrady/lmq/love/wn/update}" enctype="multipart/form-data" method="post">
|
||||||
|
<input type="hidden" id="sid" name="sid" th:value="${source.getSid()}">
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group col-md-8">
|
||||||
|
<label for="title">资源标题</label>
|
||||||
|
<input type="text" name="sourceName" class="form-control" id="title" th:value="${source.getSourceName()}" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="enName">英文名</label>
|
||||||
|
<input type="text" name="enName" class="form-control" id="enName" th:value="${source.getEnName()}" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="sType">资源标签</label>
|
||||||
|
<select name="categoryId" class="custom-select d-block w-100" id="sType">
|
||||||
|
<option th:each="category:${categoryList}"
|
||||||
|
th:selected="${source.getCategoryId() == category.getId()}"
|
||||||
|
th:value="${category.getId()}" th:text="${category.getCategory()}">
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="keyWords">摘要</label>
|
||||||
|
<input type="text" name="keyWords" class="form-control" id="keyWords" th:value="${source.getKeyWord1()}" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="uploadPassWordDiv" class="form-group col-md-4">
|
||||||
|
<label for="uploadPassWord">管理员密码(*重要*)</label>
|
||||||
|
<input type="text" name="uploadPassWord" class="form-control" id="uploadPassWord" required />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<label for="subContent">简介</label>
|
||||||
|
<textarea name="detail" class="form-control" id="subContent" th:text="${source.getDetail()}" required></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="sourceType">下载方式</label>
|
||||||
|
<select name="sourceType" class="custom-select d-block w-100" id="sourceType" required>
|
||||||
|
<option value="">请选择...</option>
|
||||||
|
<option th:selected="${source.getSourceType() != 'OSS'}" value="BAIDU">百度云</option>
|
||||||
|
<option th:selected="${source.getSourceType() == 'OSS'}" value="OSS" >服务器</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="baiduSourceTypeDiv" style="display: none" class="form-group col-md-6">
|
||||||
|
<label for="sourceLink">百度云URL</label>
|
||||||
|
<input type="text" name="sourceLink" class="form-control" id="sourceLink" th:value="${source.getSourceType()} == 'OSS' ? '' : ${source.getSourceLink()}" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="uploadData" style="display: none" class="form-group col-md-12">
|
||||||
|
<label for="uploadDataDiv" style="color: darkgreen">注意:如果没有修改文件,则无需重复上传!</label>
|
||||||
|
<input type="file" class="btn" name="file" id="uploadDataDiv" value="选择本地文件" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-12 mb-3">
|
||||||
|
<hr/>
|
||||||
|
<div id="blog-content">
|
||||||
|
<div id="editor-toolbar"></div>
|
||||||
|
<div id="editor-text-area" style="height: 400px;border: 1px solid lightgrey"></div>
|
||||||
|
<textarea id="content-textarea" name="sourceContent" style="display: none;" th:text="${source.getSourceContent()}"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button class="btn btn-primary btn-lg btn-block" type="submit" onclick="this.disabled=true; this.form.submit();">修改资源</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<div th:replace="~{common/footer::footer}"></div>
|
||||||
|
|
||||||
|
<a class="to-top">返回顶部</a>
|
||||||
|
<script th:src="@{/js/jquery-3.5.1.min.js}"></script>
|
||||||
|
<script th:src="@{/bootstrap/js/bootstrap.bundle.min.js}"></script>
|
||||||
|
<script th:src="@{/js/toTop.js}"></script>
|
||||||
|
<script th:src="@{/js/jquery-ui.min.js}"></script>
|
||||||
|
<script th:src="@{/live/js/addlive2d.js}"></script>
|
||||||
|
|
||||||
|
<script th:src="@{/wangedit/js/wang.min.js}"></script>
|
||||||
|
<script th:src="@{/wangedit/js/wang.init.js}"></script>
|
||||||
|
<script th:src="@{/layer/layer.js}"></script>
|
||||||
|
<script th:src="@{/js/axios.js}"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function() {// 初始化内容
|
||||||
|
const jSourceType = $('#sourceType').val();
|
||||||
|
if (jSourceType == 'OSS') {
|
||||||
|
$("#uploadData").show();
|
||||||
|
}else {
|
||||||
|
$("#baiduSourceTypeDiv").show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function deleteFile(btn) {
|
||||||
|
btn.disabled=true;
|
||||||
|
if(!confirm('你确认要删除吗?')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var sid = $('#sid').val();
|
||||||
|
var uploadPassWord = $('#uploadPassWord').val();
|
||||||
|
$.ajax({
|
||||||
|
url: "/tracy/mcgrady/lmq/love/wn/del",
|
||||||
|
async: false,
|
||||||
|
type: "post",
|
||||||
|
data: {"sid":sid,"uploadPassWord":uploadPassWord},
|
||||||
|
success: function (res) {
|
||||||
|
location.href=res;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#sourceType").change(function(){
|
||||||
|
const jSourceType = $('#sourceType').val();
|
||||||
|
if (jSourceType == 'BAIDU') {
|
||||||
|
$("#uploadData").hide();
|
||||||
|
$("#baiduSourceTypeDiv").show();
|
||||||
|
}
|
||||||
|
if (jSourceType == 'OSS') {
|
||||||
|
$("#baiduSourceTypeDiv").hide();
|
||||||
|
$("#uploadData").show();
|
||||||
|
}
|
||||||
|
if (jSourceType != 'OSS' && jSourceType != 'BAIDU'){
|
||||||
|
$("#baiduSourceTypeDiv").hide();
|
||||||
|
$("#uploadData").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p th:text="${source.getDetail()}"></p>
|
<p th:text="${source.getDetail()}"></p>
|
||||||
<a th:href="@{'/source/view/'+${source.getId()}}" style="color: white" class="btn btn-sm btn-primary">查看详情</a>
|
<a th:href="@{'/source/view/'+${source.getSid()}}" class="btn btn-sm btn-outline-success">查看详情</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -48,21 +48,21 @@
|
|||||||
<table class="table">
|
<table class="table">
|
||||||
<thead class="thead-light">
|
<thead class="thead-light">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">#</th>
|
|
||||||
<th scope="col">资源名</th>
|
<th scope="col">资源名</th>
|
||||||
<th scope="col">资源简介</th>
|
<th scope="col">资源简介</th>
|
||||||
<th scope="col">资源类型</th>
|
<th scope="col">资源类型</th>
|
||||||
|
<th scope="col">热度</th>
|
||||||
<th scope="col">去下载</th>
|
<th scope="col">去下载</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr th:each="source:${sourceList}">
|
<tr th:each="source:${sourceList}">
|
||||||
<td th:text="${source.getId()}"></td>
|
|
||||||
<td th:text="${source.getSourceName()}"></td>
|
<td th:text="${source.getSourceName()}"></td>
|
||||||
<td th:text="${source.getDetail()}"></td>
|
<td th:text="${source.getDetail()}"></td>
|
||||||
<td th:text="${source.getCategoryName()}"></td>
|
<td th:text="${source.getCategoryName()}"></td>
|
||||||
<td th:name="${source.getId()}">
|
<td th:text="${source.getDownRecord()}"></td>
|
||||||
<a style="color: white" th:href="@{'/source/view/'+${source.getId()}}" class="btn btn-sm btn-primary">详情</a>
|
<td th:name="${source.getSid()}">
|
||||||
|
<a style="color: white" th:href="@{'/source/view/'+${source.getSid()}}" class="btn btn-sm btn-secondary">详情</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
124
src/main/resources/templates/source/uploadSource.html
Normal file
124
src/main/resources/templates/source/uploadSource.html
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<title>资源-Quinn</title>
|
||||||
|
<link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}">
|
||||||
|
<link rel="stylesheet" th:href="@{/wangedit/css/wang.style.css}"/>
|
||||||
|
</head>
|
||||||
|
<body style="background: #f2f2f2;">
|
||||||
|
<main role="main" class="container mt-3 p-3 bg-white rounded">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 blog-main">
|
||||||
|
<div class="col-md-12 order-md-1">
|
||||||
|
<h4 class="mb-3">发布新资源</h4>
|
||||||
|
|
||||||
|
<form class="needs-validation" th:action="@{/tracy/mcgrady/lmq/love/wn}" enctype="multipart/form-data" method="post">
|
||||||
|
<!-- 隐藏域 -->
|
||||||
|
<!-- <input type="hidden" name="authorId" th:value="${session.loginUser.getUid()}">-->
|
||||||
|
<!-- <input type="hidden" name="authorName" th:value="${session.loginUser.getUsername()}">-->
|
||||||
|
<!-- <input type="hidden" name="authorAvatar" th:value="${session.loginUser.getAvatar()}">-->
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group col-md-8">
|
||||||
|
<label for="title">资源标题</label>
|
||||||
|
<input type="text" name="title" class="form-control" id="title" value="" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="enName">英文名</label>
|
||||||
|
<input type="text" name="enName" class="form-control" id="enName" value="" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="sType">资源标签</label>
|
||||||
|
<select name="categoryId" class="custom-select d-block w-100" id="sType">
|
||||||
|
<option th:each="category:${categoryList}"
|
||||||
|
th:value="${category.getId()}" th:text="${category.getCategory()}">
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="keyWords">摘要</label>
|
||||||
|
<input type="text" name="keyWords" class="form-control" id="keyWords" value="" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="uploadPassWordDiv" class="form-group col-md-4">
|
||||||
|
<label for="uploadPassWord">管理员密码(*重要*)</label>
|
||||||
|
<input type="text" class="form-control" id="uploadPassWord" name="uploadPassWord" required />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<label for="subContent">简介</label>
|
||||||
|
<textarea name="subContent" class="form-control" id="subContent" required></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="sourceType">下载方式</label>
|
||||||
|
<select name="sourceType" class="custom-select d-block w-100" id="sourceType" required>
|
||||||
|
<option value="">请选择...</option>
|
||||||
|
<option value="BAIDU">百度云</option>
|
||||||
|
<option value="OSS" >服务器</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="baiduSourceTypeDiv" style="display: none" class="form-group col-md-6">
|
||||||
|
<label for="sourceLink">百度云URL</label>
|
||||||
|
<input type="text" name="sourceLink" class="form-control" id="sourceLink" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="uploadData" style="display: none" class="form-group col-md-12">
|
||||||
|
<label for="toUploadFile" style="color: darkgreen">穷~文件请不要大于20M,否则会报错</label>
|
||||||
|
<input type="file" id="toUploadFile" class="btn" name="file" value="请选择文件" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-12 mb-3">
|
||||||
|
<hr/>
|
||||||
|
<div id="blog-content">
|
||||||
|
<div id="editor-toolbar"></div>
|
||||||
|
<div id="editor-text-area" style="height: 400px;border: 1px solid lightgrey"></div>
|
||||||
|
<textarea id="content-textarea" name="content" style="display: none;"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-primary btn-lg btn-block" type="submit" onclick="this.disabled=true; this.form.submit();">发布资源</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<a class="to-top">返回顶部</a>
|
||||||
|
<script th:src="@{/js/jquery-3.5.1.min.js}"></script>
|
||||||
|
<script th:src="@{/bootstrap/js/bootstrap.bundle.min.js}"></script>
|
||||||
|
<script th:src="@{/js/toTop.js}"></script>
|
||||||
|
<script th:src="@{/js/jquery-ui.min.js}"></script>
|
||||||
|
<script th:src="@{/live/js/addlive2d.js}"></script>
|
||||||
|
|
||||||
|
<script th:src="@{/wangedit/js/wang.min.js}"></script>
|
||||||
|
<script th:src="@{/wangedit/js/wang.init.js}"></script>
|
||||||
|
<script th:src="@{/layer/layer.js}"></script>
|
||||||
|
<script th:src="@{/js/axios.js}"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$("#sourceType").change(function(){
|
||||||
|
const jSourceType = $('#sourceType').val();
|
||||||
|
if (jSourceType == 'BAIDU') {
|
||||||
|
$("#uploadData").hide();
|
||||||
|
$("#baiduSourceTypeDiv").show();
|
||||||
|
}
|
||||||
|
if (jSourceType == 'OSS') {
|
||||||
|
$("#baiduSourceTypeDiv").hide();
|
||||||
|
$("#uploadData").show();
|
||||||
|
}
|
||||||
|
if (jSourceType != 'OSS' && jSourceType != 'BAIDU'){
|
||||||
|
$("#baiduSourceTypeDiv").hide();
|
||||||
|
$("#uploadData").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -22,10 +22,15 @@
|
|||||||
<span th:text="${#dates.format(source.getGmtUpdate(),'yyyy-MM-dd')}"></span>
|
<span th:text="${#dates.format(source.getGmtUpdate(),'yyyy-MM-dd')}"></span>
|
||||||
类别-
|
类别-
|
||||||
<span th:text="${source.getCategoryName()}"></span>
|
<span th:text="${source.getCategoryName()}"></span>
|
||||||
<a th:href="@{'/source/download/' + ${source.getId()}}" class="btn btn-outline-success col-md-2 float-right">下载</a>
|
<a href="javascript:downloadFile(this);" class="btn btn-outline-success col-md-2 float-right">下载</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div style="display: none">
|
||||||
|
<form th:action="@{'/source/download/'+${source.getSid()}}" method="post">
|
||||||
|
<input type="submit" id="downloadTrans" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<input type="hidden" id="sourceDType" name="sourceDType" th:value="${source.getSourceType()}">
|
||||||
<hr style="margin-top: 18px">
|
<hr style="margin-top: 18px">
|
||||||
|
|
||||||
<!--文章主体内容-->
|
<!--文章主体内容-->
|
||||||
@@ -40,15 +45,15 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-12 source-main" style="margin-top: 20px">
|
<div class="col-md-12 source-main" style="margin-top: 20px">
|
||||||
<form th:action="@{'/source/comment/'+${source.getId()}}" method="post">
|
<form th:action="@{'/source/comment/'+${source.getSid()}}" method="post">
|
||||||
<input type="hidden" name="userId" th:value="${session.loginUser.getUid()}">
|
<input type="hidden" name="userId" th:value="${session.loginUser.getUid()}">
|
||||||
<input type="hidden" name="userName" th:value="${session.loginUser.getUsername()}">
|
<input type="hidden" name="userName" th:value="${session.loginUser.getUsername()}">
|
||||||
<input type="hidden" name="userAvatar" th:value="${session.loginUser.getAvatar()}">
|
<input type="hidden" name="userAvatar" th:value="${session.loginUser.getAvatar()}">
|
||||||
<input type="hidden" name="topicId" th:value="${source.getId()}">
|
<input type="hidden" id="topicId" name="topicId" th:value="${source.getSid()}">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<textarea name="content" class="form-control" rows="3" required></textarea>
|
<textarea name="content" class="form-control" rows="3" required></textarea>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary float-right">提交评论</button>
|
<button type="submit" onclick="this.disabled=true; this.form.submit();" class="btn btn-primary float-right">提交评论</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -96,6 +101,26 @@
|
|||||||
<script th:src="@{/editormd/lib/jquery.flowchart.min.js}"></script>
|
<script th:src="@{/editormd/lib/jquery.flowchart.min.js}"></script>
|
||||||
<script th:src="@{/editormd/editormd.js}"></script>
|
<script th:src="@{/editormd/editormd.js}"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
function downloadFile(btn){
|
||||||
|
btn.disabled=true;
|
||||||
|
var sid = $('#topicId').val();
|
||||||
|
var sourceDType = $('#sourceDType').val();
|
||||||
|
if (sourceDType == 'OSS'){
|
||||||
|
$('#downloadTrans').click();
|
||||||
|
}else {
|
||||||
|
$.ajax({
|
||||||
|
url: "/source/download/" + sid,
|
||||||
|
async: false,
|
||||||
|
type: "post",
|
||||||
|
data: '',
|
||||||
|
success: function (res) {
|
||||||
|
window.open(res);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var testEditor;
|
var testEditor;
|
||||||
$(function () {
|
$(function () {
|
||||||
@@ -109,7 +134,6 @@
|
|||||||
sequenceDiagram: true, // 默认不解析
|
sequenceDiagram: true, // 默认不解析
|
||||||
codeFold: true
|
codeFold: true
|
||||||
});});
|
});});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
|
|
||||||
<hr class="mb-4">
|
<hr class="mb-4">
|
||||||
|
|
||||||
<button class="btn btn-primary btn-lg btn-block" type="submit"> 更新资料 </button>
|
<button class="btn btn-primary btn-lg btn-block" type="submit" > 更新资料 </button>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user