update
This commit is contained in:
parent
64173c1afa
commit
9f198edd1e
1
.gitignore
vendored
1
.gitignore
vendored
@ -31,3 +31,4 @@ build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
/src/main/resources/static/qr/
|
||||
|
@ -1,13 +1,19 @@
|
||||
package com.lovenav;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration;
|
||||
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(exclude = {MultipartAutoConfiguration.class})
|
||||
@MapperScan({"com.lovenav.dao"})
|
||||
public class LoveNavApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
SpringApplication.run(LoveNavApplication.class, args);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
24
src/main/java/com/lovenav/configuration/UploadConfig.java
Normal file
24
src/main/java/com/lovenav/configuration/UploadConfig.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.lovenav.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.multipart.MultipartResolver;
|
||||
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
|
||||
|
||||
|
||||
@Configuration
|
||||
public class UploadConfig {
|
||||
//显示声明CommonsMultipartResolver为mutipartResolver
|
||||
@Bean(name = "multipartResolver")
|
||||
public MultipartResolver multipartResolver() {
|
||||
CommonsMultipartResolver resolver = new CommonsMultipartResolver();
|
||||
resolver.setDefaultEncoding("UTF-8");
|
||||
//resolveLazily属性启用是为了推迟文件解析,以在在UploadAction中捕获文件大小异常
|
||||
resolver.setResolveLazily(true);
|
||||
resolver.setMaxInMemorySize(40960);
|
||||
//上传文件大小 5M 5*1024*1024
|
||||
resolver.setMaxUploadSize(5 * 1024 * 1024);
|
||||
return resolver;
|
||||
}
|
||||
|
||||
}
|
@ -6,6 +6,7 @@ import com.lovenav.service.AttachmentService;
|
||||
import com.lovenav.service.ConfigService;
|
||||
import org.apache.catalina.core.ApplicationContext;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.ui.Model;
|
||||
@ -35,8 +36,8 @@ public class AttachmentController {
|
||||
|
||||
//上传附件
|
||||
@RequestMapping(value = "/uploadfile",method = RequestMethod.POST)
|
||||
public HashMap<String, String> uploadFile(MultipartFile multipartFile, String cate, Config config) throws IOException {//@RequestPart("photos") MultipartFile multipartFile
|
||||
HashMap<String,String> map=new HashMap<>();
|
||||
public HashMap<String, Object> uploadFile(MultipartFile multipartFile, String cate, Config config) throws IOException {//@RequestPart("photos") MultipartFile multipartFile
|
||||
HashMap<String,Object> map=new HashMap<>();
|
||||
if (multipartFile==null){
|
||||
map.put("msg","文件不能为空!");
|
||||
return map;
|
||||
@ -45,9 +46,10 @@ public class AttachmentController {
|
||||
if (config1==null){
|
||||
map=attachmentService.upload(multipartFile,cate);
|
||||
// out.println(map.get("id"));
|
||||
config.setValue(map.get("id"));
|
||||
config.setValue(map.get("id").toString());
|
||||
config.setType("image");
|
||||
map.put("msg",configService.addConfig(config));
|
||||
map.put("code",200);
|
||||
}else {
|
||||
out.println(config1.getValue());
|
||||
configService.updateConfig(config1);
|
||||
@ -88,7 +90,14 @@ public class AttachmentController {
|
||||
headers.setContentType(MediaType.IMAGE_PNG);
|
||||
}else if (attachment.getSuffix().replace(".","").equals("jpeg")){
|
||||
headers.setContentType(MediaType.IMAGE_JPEG);
|
||||
}else{
|
||||
}
|
||||
else if (attachment.getSuffix().replace(".","").equals("jpg")){
|
||||
headers.setContentType(MediaType.IMAGE_JPEG);
|
||||
}
|
||||
else if (attachment.getSuffix().replace(".","").equals("gif")){
|
||||
headers.setContentType(MediaType.IMAGE_GIF);
|
||||
}
|
||||
else{
|
||||
bytes= "没有该文件!".getBytes();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
return new ResponseEntity<byte[]>(bytes, headers, HttpStatus.NOT_FOUND);
|
||||
|
@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class BannersController {
|
||||
@Autowired
|
||||
private BannersService bannersService;
|
||||
|
||||
// 跳转链接
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/jump_url")
|
||||
public String jump(int id) {
|
||||
|
@ -19,7 +19,7 @@ public class QRCodeController {
|
||||
private QRCService qrcService;
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/qrc_return")
|
||||
public String QRCode(@RequestBody int url_id) throws Exception {
|
||||
public String QRCode(Integer url_id) throws Exception {
|
||||
return qrcService.QR(url_id);
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ public class SearchController {
|
||||
//非法敏感词汇判断
|
||||
SensitiveFilter filter = SensitiveFilter.getInstance();
|
||||
String s = filter.replaceSensitiveWord(searchKey, 1, placeholder);
|
||||
System.out.println(s);
|
||||
//System.out.println(s);
|
||||
int n = filter.CheckSensitiveWord(searchKey,0,2);
|
||||
//存在非法字符
|
||||
if(n > 0){
|
||||
|
@ -80,7 +80,7 @@ public class UrlAndCateController {
|
||||
JsonNode sonNode = rootNode.get(i);
|
||||
if(String.valueOf(sonNode.get("type")).equals("\"folder\"")){
|
||||
String icon = String.valueOf(sonNode.get("icon"));
|
||||
System.out.println(icon.length());
|
||||
//System.out.println(icon.length());
|
||||
if (icon.length() == 2) icon ="https://imgbed.landaiqing.space/img/1/2023/12/25/1_6588644cb1f03_1703437387965_20231225.webp";
|
||||
else{
|
||||
icon=icon.substring(1,icon.length()-1);
|
||||
@ -202,7 +202,7 @@ public class UrlAndCateController {
|
||||
}
|
||||
Collections.sort(integers);
|
||||
for (Integer str : integers) {
|
||||
System.out.println(str);
|
||||
//System.out.println(str);
|
||||
UrlCateList urlCateList =urlCateListService.selectByPrimaryKey(Integer.valueOf(str));
|
||||
CateAndUrl cateAndUrl = new CateAndUrl();
|
||||
cateAndUrl.setFloder("true");
|
||||
@ -222,7 +222,7 @@ public class UrlAndCateController {
|
||||
// cateAndUrlList.add(cateAndUrl);
|
||||
// }
|
||||
|
||||
System.out.println(cateAndUrlList);
|
||||
//System.out.println(cateAndUrlList);
|
||||
List<CateAndUrl> parentsList = new ArrayList<>();
|
||||
//声明返回集合
|
||||
List<CateAndUrl> resultList = new ArrayList<>();
|
||||
@ -330,6 +330,8 @@ public class UrlAndCateController {
|
||||
* @throws IOException
|
||||
*/
|
||||
public HSSFWorkbook jsonToExcel(JSONArray jsonArray) throws IOException {
|
||||
|
||||
|
||||
Set<String> keys = new HashSet<>();
|
||||
// 创建HSSFWorkbook对象
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
@ -353,10 +355,9 @@ public class UrlAndCateController {
|
||||
HSSFCell cell = row.createCell(0);
|
||||
String temp = jsonObjects.get(i).keySet().toString();
|
||||
String target = temp.substring(1,temp.length()-1);
|
||||
String target1 = temp.substring(2,temp.length()-2);
|
||||
cell.setCellValue(target1);
|
||||
cell.setCellValue(target);
|
||||
cell = row.createCell(1);
|
||||
cell.setCellValue(jsonObjects.get(i).get(target).toString().substring(2,temp.length()-2));
|
||||
cell.setCellValue(jsonObjects.get(i).get(target).toString());
|
||||
}
|
||||
|
||||
return wb;
|
||||
@ -481,7 +482,7 @@ public class UrlAndCateController {
|
||||
List<String> ls=Arrays.asList(parentSet.toArray(new String[0]));
|
||||
Collections.sort(ls);
|
||||
for (String str : ls) {
|
||||
System.out.println(str);
|
||||
// System.out.println(str);
|
||||
UrlCateList urlCateList =urlCateListService.selectByPrimaryKey(Integer.valueOf(str));
|
||||
CateAndUrl cateAndUrl = new CateAndUrl();
|
||||
cateAndUrl.setFloder("true");
|
||||
@ -571,7 +572,7 @@ public class UrlAndCateController {
|
||||
cateAndUrlList.add(cateAndUrl);
|
||||
}
|
||||
|
||||
System.out.println(cateAndUrlList);
|
||||
// System.out.println(cateAndUrlList);
|
||||
List<CateAndUrl> parentsList = new ArrayList<>();
|
||||
//声明返回集合
|
||||
List<CateAndUrl> resultList = new ArrayList<>();
|
||||
|
@ -35,7 +35,7 @@ public class UrlListController {
|
||||
UrlList urlList = urlListService.selectUrlListByUrlId(Long.valueOf(urlId));
|
||||
String parentString = urlCateListService.selectUrListCateByUrlCateId(urlList.getCateId());
|
||||
String [] parentList = parentString.split(",");
|
||||
System.out.println(parentString);
|
||||
//System.out.println(parentString);
|
||||
for(String parent : parentList)
|
||||
{
|
||||
if(parent.equals("0")){
|
||||
@ -72,7 +72,7 @@ public class UrlListController {
|
||||
flag = urlListService.insertUrlByUser(urlList);
|
||||
String parentString = urlCateListService.selectUrListCateByUrlCateId(urlList.getCateId());
|
||||
String [] parentList = parentString.split(",");
|
||||
System.out.println(parentString);
|
||||
// System.out.println(parentString);
|
||||
for(String parent : parentList)
|
||||
{
|
||||
if(parent.equals("0")){
|
||||
|
@ -65,7 +65,7 @@ public class UserController {
|
||||
@Override
|
||||
public void run() {
|
||||
session.removeAttribute(user.getUserEmail());
|
||||
System.out.println(session.getAttribute(user.getUserEmail()));
|
||||
// System.out.println(session.getAttribute(user.getUserEmail()));
|
||||
}
|
||||
},60, TimeUnit.SECONDS);
|
||||
return "发送验证码成功!";
|
||||
@ -79,8 +79,8 @@ public class UserController {
|
||||
if (!user.getActiveCode().equals((String) session.getAttribute(user.getUserEmail()))) {
|
||||
return "验证码不正确";
|
||||
}
|
||||
System.out.println(user.getUserLogin());
|
||||
System.out.println(user.getUserEmail());
|
||||
// System.out.println(user.getUserLogin());
|
||||
// System.out.println(user.getUserEmail());
|
||||
// 用户注册之前根据用户名称查询该用户是否存在如果不存在的情况下才可以注册 如果存在的话就无法注册
|
||||
User user1=userService.selectUserAlreadyExist(user);
|
||||
if (user1 != null) {
|
||||
@ -118,7 +118,7 @@ public class UserController {
|
||||
|
||||
|
||||
String ip=IPutils.getIpAddress(request);
|
||||
System.out.println(ip);
|
||||
// System.out.println(ip);
|
||||
|
||||
String locat= String.valueOf(IPutils.getLocation(ip));
|
||||
User user1 = userService.userLogin(user);
|
||||
@ -164,7 +164,7 @@ public class UserController {
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
|
||||
User user1=userService.selectUserAlreadyExist(user);
|
||||
System.out.println(user1);
|
||||
// System.out.println(user1);
|
||||
if (user1==null){
|
||||
map.put("msg","无此邮箱");
|
||||
return map;
|
||||
|
@ -40,7 +40,7 @@ public class UserInterceptor implements HandlerInterceptor {
|
||||
// 拦截每个请求
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws IOException {
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
System.out.println("开始进入拦截器检验jwt头部是否含有Authorization方法!");
|
||||
//System.out.println("开始进入拦截器检验jwt头部是否含有Authorization方法!");
|
||||
// 通过url得到token请求头是否包含Authorization
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
String jwt = request.getHeader("Authorization");
|
||||
|
@ -10,10 +10,10 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public interface AttachmentService {
|
||||
HashMap<String,String> upload(MultipartFile file,String cate) throws IOException;
|
||||
HashMap<String,Object> upload(MultipartFile file,String cate) throws IOException;
|
||||
|
||||
public HashMap<String,String>storeFile(MultipartFile multipartFile,String cate) throws IOException;
|
||||
public HashMap<String,String>updateFile(MultipartFile multipartFile,String cate,Config config) throws IOException;
|
||||
public HashMap<String,Object>storeFile(MultipartFile multipartFile,String cate) throws IOException;
|
||||
public HashMap<String,Object>updateFile(MultipartFile multipartFile,String cate,Config config) throws IOException;
|
||||
|
||||
|
||||
public Attachment selectAttachment(Long id);
|
||||
|
@ -1,7 +1,8 @@
|
||||
package com.lovenav.service;
|
||||
|
||||
import com.lovenav.entity.CollectIconList;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
public interface QRCService {
|
||||
public String QR(int url_id) throws Exception;
|
||||
public String QR(@RequestBody Integer url_id) throws Exception;
|
||||
}
|
||||
|
@ -30,13 +30,13 @@ public class AttachmentServiceImpl implements AttachmentService {
|
||||
AttachmentDao attachmentDao;
|
||||
|
||||
@Override
|
||||
public HashMap<String,String> upload(MultipartFile file,String cate) throws IOException {
|
||||
HashMap<String, String> map = storeFile(file,cate);
|
||||
public HashMap<String,Object> upload(MultipartFile file,String cate) throws IOException {
|
||||
HashMap<String, Object> map = storeFile(file,cate);
|
||||
return map;
|
||||
}
|
||||
@Override
|
||||
public HashMap<String, String> storeFile(MultipartFile multipartFile,String cate) throws IOException {
|
||||
HashMap<String,String> map = new HashMap<>();
|
||||
public HashMap<String, Object> storeFile(MultipartFile multipartFile,String cate) throws IOException {
|
||||
HashMap<String,Object> map = new HashMap<>();
|
||||
Attachment attachment=new Attachment();
|
||||
File path = null;
|
||||
try {
|
||||
@ -70,6 +70,7 @@ public class AttachmentServiceImpl implements AttachmentService {
|
||||
// attachment.setId(id);
|
||||
|
||||
attachmentDao.insertSelective(attachment);
|
||||
|
||||
map.put("id", String.valueOf(attachment.getId()));
|
||||
multipartFile.transferTo(fileUp);
|
||||
map.put("url", "/img" + relPath);
|
||||
@ -83,8 +84,8 @@ public class AttachmentServiceImpl implements AttachmentService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, String> updateFile(MultipartFile multipartFile, String cate, Config config) throws IOException {
|
||||
HashMap<String,String> map = new HashMap<>();
|
||||
public HashMap<String, Object> updateFile(MultipartFile multipartFile, String cate, Config config) throws IOException {
|
||||
HashMap<String,Object> map = new HashMap<>();
|
||||
Attachment attachment=new Attachment();
|
||||
File path = null;
|
||||
try {
|
||||
@ -119,7 +120,7 @@ public class AttachmentServiceImpl implements AttachmentService {
|
||||
// attachment.setId(id);
|
||||
attachmentDao.updateByPrimaryKeySelective(attachment);
|
||||
// map.put("id", String.valueOf(attachment.getId()));
|
||||
map.put("msg","更新成功!");
|
||||
map.put("code",200);
|
||||
map.put("id", String.valueOf(attachment.getId()));
|
||||
multipartFile.transferTo(fileUp);
|
||||
map.put("url", "/img" + relPath);
|
||||
|
@ -22,18 +22,21 @@ public class QRCServiceImpl implements QRCService{
|
||||
@Autowired
|
||||
private CollectIconListDao collectIconListDao;
|
||||
|
||||
public String QR(int url_id) throws Exception {
|
||||
public String QR(Integer url_id) throws Exception {
|
||||
String logoPath = "src/main/resources/static/logo/NAV.png";
|
||||
String destPath = "src/main/resources/static/qr";
|
||||
UrlList urlList = urlListDao.selectByPrimaryKey(Long.valueOf(url_id));
|
||||
String url = urlList.getUrl();
|
||||
String list = collectIconListDao.selectByUrlid(url_id);
|
||||
CollectIconList collectIconList = new CollectIconList();
|
||||
String url = urlList.getUrl();
|
||||
collectIconList.setUrl_id(url_id);
|
||||
String list = collectIconListDao.selectByUrlid(url_id);
|
||||
if (list == null) {
|
||||
String base64 = QRCodeUtil.ImageToBase64(QRCodeUtil.encode(url, logoPath, destPath, true));
|
||||
collectIconList.setQr_url(base64);
|
||||
collectIconListDao.insertSelective(collectIconList);
|
||||
return JSON.toJSONString(base64);
|
||||
// return JSON.toJSONString(collectIconListDao.selectByUrlid(url_id));
|
||||
// return JSON.toJSONString(base64);
|
||||
return null;
|
||||
}else {
|
||||
return JSON.toJSONString(collectIconListDao.selectByUrlid(url_id));
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ public class RedisServiceImpl implements RedisService {
|
||||
if (result.size() > HOT_SEARCH_NUMBER) {
|
||||
break;
|
||||
}
|
||||
System.out.println(valueOperations.get(val));
|
||||
// System.out.println(valueOperations.get(val));
|
||||
Long time = Long.valueOf(Objects.requireNonNull(valueOperations.get("search:search-time:"+val)));
|
||||
//返回最近一个月的数据
|
||||
if ((now - time) < HOT_SEARCH_TIME) {
|
||||
|
@ -111,7 +111,7 @@ public class UrlCateListServiceImpl implements UrlCateListService {
|
||||
if(urlCateList.getId() == Integer.valueOf(str)){
|
||||
int cateNum = CateNumber.get(urlCateList.getName())+1;
|
||||
CateNumber.put(urlCateList.getName(),cateNum);
|
||||
System.out.println(urlCateList.getName());
|
||||
// System.out.println(urlCateList.getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -146,13 +146,11 @@ public class UrlCateListServiceImpl implements UrlCateListService {
|
||||
int parentId = urlCateList.getId();
|
||||
for(UrlList urlList : urlLists)
|
||||
{
|
||||
if(urlList.getCateId() == parentId)
|
||||
{
|
||||
if(!String.valueOf(urlList.getCateId()).equals(parentId+"")) continue ;
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put(urlList.getName(),urlList.getUrl());
|
||||
jsonArray.add(jsonObject);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return jsonArray;
|
||||
|
@ -117,7 +117,7 @@ public class UserServiceImpl implements UserService {
|
||||
|
||||
@Override
|
||||
public User selectUserAlreadyExist(User user) {
|
||||
System.out.println(user.getUserEmail());
|
||||
// System.out.println(user.getUserEmail());
|
||||
User user1=userDao.selectByEmail(user.getUserEmail());
|
||||
return user1;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -74,7 +74,7 @@ public class UrlCheckUtil {
|
||||
public static boolean CheckHttp(String address) throws URISyntaxException, MalformedURLException {
|
||||
URL url = new URL(address);
|
||||
URI uri = url.toURI();
|
||||
System.out.println(uri.getScheme());
|
||||
// System.out.println(uri.getScheme());
|
||||
if(uri.getScheme().equals("https")){
|
||||
return true;
|
||||
}else
|
||||
|
Loading…
Reference in New Issue
Block a user