From 816797070a3074fb99716bb96fef190bdfa42262 Mon Sep 17 00:00:00 2001
From: azhao <1655939151@qq.com>
Date: Wed, 23 Sep 2020 11:12:11 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E5=AD=A6=E9=99=A2=E5=90=8E=E7=AB=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
admin/pom.xml | 4 ++
.../controller/FundApplyController.java | 3 +
.../neuedu/controller/ProjectController.java | 14 ++++-
.../com/neuedu/service/IFundApplyService.java | 4 +-
.../com/neuedu/service/IProjectService.java | 4 ++
.../service/impl/FundApplyServiceImpl.java | 24 ++++++++
.../service/impl/ProjectServiceImpl.java | 56 +++++++++++++++++++
admin/src/main/resources/bootstrap.yml | 8 +++
.../main/java/com/neuedu/pojo/FundApply.java | 6 ++
.../main/java/com/neuedu/pojo/Project.java | 6 ++
10 files changed, 127 insertions(+), 2 deletions(-)
diff --git a/admin/pom.xml b/admin/pom.xml
index 2c2a5e1..46e6fea 100644
--- a/admin/pom.xml
+++ b/admin/pom.xml
@@ -98,6 +98,10 @@
com.alibaba
fastjson
+
+ com.github.tobato
+ fastdfs-client
+
diff --git a/admin/src/main/java/com/neuedu/controller/FundApplyController.java b/admin/src/main/java/com/neuedu/controller/FundApplyController.java
index 707a4ed..865b955 100644
--- a/admin/src/main/java/com/neuedu/controller/FundApplyController.java
+++ b/admin/src/main/java/com/neuedu/controller/FundApplyController.java
@@ -1,5 +1,6 @@
package com.neuedu.controller;
+import java.io.IOException;
import java.util.Map;
import javax.annotation.Resource;
@@ -35,6 +36,8 @@ public class FundApplyController {
@Resource
private IFundApplyService iFundApplyService;
+ @PostMapping("/add")
+ CommonResult add(FundApply fundApply) throws IOException { return CommonResult.success(iFundApplyService.add(fundApply));}
/**
* 进行分页查询
diff --git a/admin/src/main/java/com/neuedu/controller/ProjectController.java b/admin/src/main/java/com/neuedu/controller/ProjectController.java
index 69ff127..8fe09d2 100644
--- a/admin/src/main/java/com/neuedu/controller/ProjectController.java
+++ b/admin/src/main/java/com/neuedu/controller/ProjectController.java
@@ -1,5 +1,6 @@
package com.neuedu.controller;
+import java.io.IOException;
import java.util.Map;
import javax.annotation.Resource;
@@ -29,13 +30,24 @@ import org.slf4j.LoggerFactory;
* @since 2020-09-17
*/
@RestController
-@RequestMapping("/project")
+@RequestMapping("/college_project")
public class ProjectController {
private final Logger logger = LoggerFactory.getLogger(ProjectController.class);
@Resource
private IProjectService iProjectService;
+ @GetMapping("/list")
+ CommonResult list(Project project)
+ {
+ return CommonResult.success(iProjectService.list(project));
+ }
+ @PostMapping("/add")
+ CommonResult add(Project project) throws IOException {
+ System.out.println(project.getMultipartFile());
+ System.out.println(project.getMultipartFile().getSize());
+ return CommonResult.success(iProjectService.add(project));}
+
/**
* 进行分页查询
*/
diff --git a/admin/src/main/java/com/neuedu/service/IFundApplyService.java b/admin/src/main/java/com/neuedu/service/IFundApplyService.java
index 04c75a0..3c384a4 100644
--- a/admin/src/main/java/com/neuedu/service/IFundApplyService.java
+++ b/admin/src/main/java/com/neuedu/service/IFundApplyService.java
@@ -3,6 +3,8 @@ package com.neuedu.service;
import com.neuedu.pojo.FundApply;
import com.baomidou.mybatisplus.extension.service.IService;
+import java.io.IOException;
+
/**
*
* 项目资金申请 服务类
@@ -12,5 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @since 2020-09-17
*/
public interface IFundApplyService extends IService {
-
+ boolean add(FundApply fundApply) throws IOException;
}
diff --git a/admin/src/main/java/com/neuedu/service/IProjectService.java b/admin/src/main/java/com/neuedu/service/IProjectService.java
index 2e40eb3..14c9127 100644
--- a/admin/src/main/java/com/neuedu/service/IProjectService.java
+++ b/admin/src/main/java/com/neuedu/service/IProjectService.java
@@ -3,6 +3,8 @@ package com.neuedu.service;
import com.neuedu.pojo.Project;
import com.baomidou.mybatisplus.extension.service.IService;
+import java.io.IOException;
+
/**
*
* 项目 服务类
@@ -12,5 +14,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @since 2020-09-17
*/
public interface IProjectService extends IService {
+ Object list(Project project);
+ boolean add(Project project) throws IOException;
}
diff --git a/admin/src/main/java/com/neuedu/service/impl/FundApplyServiceImpl.java b/admin/src/main/java/com/neuedu/service/impl/FundApplyServiceImpl.java
index 056cc10..47eb449 100644
--- a/admin/src/main/java/com/neuedu/service/impl/FundApplyServiceImpl.java
+++ b/admin/src/main/java/com/neuedu/service/impl/FundApplyServiceImpl.java
@@ -1,10 +1,19 @@
package com.neuedu.service.impl;
+import com.github.tobato.fastdfs.domain.fdfs.StorePath;
+import com.github.tobato.fastdfs.domain.upload.FastImageFile;
+import com.github.tobato.fastdfs.service.FastFileStorageClient;
import com.neuedu.pojo.FundApply;
import com.neuedu.mapper.FundApplyMapper;
import com.neuedu.service.IFundApplyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.commons.io.FilenameUtils;
import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+import java.util.HashSet;
/**
*
@@ -16,5 +25,20 @@ import org.springframework.stereotype.Service;
*/
@Service
public class FundApplyServiceImpl extends ServiceImpl implements IFundApplyService {
+ @Resource
+ FastFileStorageClient fastFileStorageClient;
+ @Override
+ public boolean add(FundApply fundApply) throws IOException {
+ MultipartFile file=fundApply.getMultipartFile();
+ FastImageFile fastImageFile=new FastImageFile(
+ file.getInputStream(),
+ file.getSize(),
+ FilenameUtils.getExtension(file.getOriginalFilename()),
+ new HashSet<>()
+ );
+ StorePath storePath=fastFileStorageClient.uploadImage(fastImageFile);
+ fundApply.setApplyFileUrl(storePath.getFullPath());
+ return this.saveOrUpdate(fundApply);
+ }
}
diff --git a/admin/src/main/java/com/neuedu/service/impl/ProjectServiceImpl.java b/admin/src/main/java/com/neuedu/service/impl/ProjectServiceImpl.java
index 3b9d6af..11f49a6 100644
--- a/admin/src/main/java/com/neuedu/service/impl/ProjectServiceImpl.java
+++ b/admin/src/main/java/com/neuedu/service/impl/ProjectServiceImpl.java
@@ -1,10 +1,23 @@
package com.neuedu.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.tobato.fastdfs.domain.fdfs.StorePath;
+import com.github.tobato.fastdfs.domain.upload.FastImageFile;
+import com.github.tobato.fastdfs.service.FastFileStorageClient;
import com.neuedu.pojo.Project;
import com.neuedu.mapper.ProjectMapper;
import com.neuedu.service.IProjectService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.commons.io.FilenameUtils;
import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.util.HashSet;
/**
*
@@ -16,5 +29,48 @@ import org.springframework.stereotype.Service;
*/
@Service
public class ProjectServiceImpl extends ServiceImpl implements IProjectService {
+ @Resource
+ FastFileStorageClient fastFileStorageClient;
+ @Override
+ public Object list(Project project) {
+ QueryWrapper wrapper = new QueryWrapper<>();
+ if(StringUtils.isNotBlank(project.getName())){
+ wrapper.like("name",project.getName());
+ }
+ if(project.getActive() != null){
+ wrapper.eq("active",project.getActive());
+ }
+ if(project.getWithPage() == 1) {
+ return page(new Page<>(project.getPageNo(), project.getPageSize()), wrapper);
+ }else {
+ return this.list(wrapper);
+ }
+ }
+
+ @Override
+ public boolean add(Project project) throws IOException {
+ MultipartFile file=project.getMultipartFile();
+ FastImageFile fastImageFile=new FastImageFile(
+ file.getInputStream(),
+ file.getSize(),
+ FilenameUtils.getExtension(file.getOriginalFilename()),
+ new HashSet<>()
+ );
+ QueryWrapper wrapper = new QueryWrapper<>();
+ wrapper.eq("name",project.getName());
+ Project query = this.getOne(wrapper);
+ if(query == null )
+ {
+ StorePath storePath=fastFileStorageClient.uploadImage(fastImageFile);
+ LocalDateTime dateTime=LocalDateTime.now();
+ project.setActive(1);
+ project.setCreateTime(dateTime);
+ project.setUpdateTime(dateTime);
+ project.setApplyFileUrl(storePath.getFullPath());
+ return this.save(project);
+
+ }
+ else {return false;}
+ }
}
diff --git a/admin/src/main/resources/bootstrap.yml b/admin/src/main/resources/bootstrap.yml
index a6de1a3..a9c8ca4 100644
--- a/admin/src/main/resources/bootstrap.yml
+++ b/admin/src/main/resources/bootstrap.yml
@@ -16,3 +16,11 @@ spring:
redis:
host: 39.99.142.143
port: 8888
+fdfs:
+ so-timeout: 1501
+ connect-timeout: 1601
+ thumb-image:
+ width: 150
+ height: 150
+ tracker-list:
+ - 39.100.66.68:22122
\ No newline at end of file
diff --git a/pojo/src/main/java/com/neuedu/pojo/FundApply.java b/pojo/src/main/java/com/neuedu/pojo/FundApply.java
index 8685b21..4c8e03c 100644
--- a/pojo/src/main/java/com/neuedu/pojo/FundApply.java
+++ b/pojo/src/main/java/com/neuedu/pojo/FundApply.java
@@ -2,10 +2,12 @@ package com.neuedu.pojo;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import com.neuedu.pojo.BasePojo;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.EqualsAndHashCode;
+import org.springframework.web.multipart.MultipartFile;
/**
*
@@ -57,6 +59,10 @@ public class FundApply extends BasePojo {
*/
@TableField("apply_file_url")
private String applyFileUrl;
+ @JsonIgnore
+ @TableField(exist = false)
+ private MultipartFile multipartFile;
+
}
diff --git a/pojo/src/main/java/com/neuedu/pojo/Project.java b/pojo/src/main/java/com/neuedu/pojo/Project.java
index 80e1aae..a82031d 100644
--- a/pojo/src/main/java/com/neuedu/pojo/Project.java
+++ b/pojo/src/main/java/com/neuedu/pojo/Project.java
@@ -1,10 +1,13 @@
package com.neuedu.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import com.neuedu.pojo.BasePojo;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.EqualsAndHashCode;
+import org.springframework.web.multipart.MultipartFile;
+
/**
*
@@ -62,6 +65,9 @@ public class Project extends BasePojo {
*/
@TableField("conclusion_file_url")
private String conclusionFileUrl;
+ @JsonIgnore
+ @TableField(exist = false)
+ private MultipartFile multipartFile;
}
--
Gitee
From 191b2d55d18969ab6984ba9c31bf7266c43c2774 Mon Sep 17 00:00:00 2001
From: azhao <1655939151@qq.com>
Date: Thu, 24 Sep 2020 14:22:16 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E5=AD=A6=E9=99=A2=E5=90=8E=E7=AB=AF?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/com/neuedu/controller/FundApplyController.java | 6 +++++-
.../main/java/com/neuedu/controller/ProjectController.java | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/admin/src/main/java/com/neuedu/controller/FundApplyController.java b/admin/src/main/java/com/neuedu/controller/FundApplyController.java
index 865b955..2b4d85e 100644
--- a/admin/src/main/java/com/neuedu/controller/FundApplyController.java
+++ b/admin/src/main/java/com/neuedu/controller/FundApplyController.java
@@ -37,7 +37,10 @@ public class FundApplyController {
@Resource
private IFundApplyService iFundApplyService;
@PostMapping("/add")
- CommonResult add(FundApply fundApply) throws IOException { return CommonResult.success(iFundApplyService.add(fundApply));}
+ CommonResult add(FundApply fundApply) throws IOException {
+ fundApply.setStatus(1);
+ return CommonResult.success(iFundApplyService.add(fundApply));
+ }
/**
* 进行分页查询
@@ -49,6 +52,7 @@ public class FundApplyController {
int limit = Integer.parseInt(param.get("limit").toString());
QueryWrapper wrapper = new QueryWrapper<>();
InitUtil.initEq(param, wrapper, "active");
+ InitUtil.initLike(param, wrapper, "name");
IPage page = new Page<>(num, limit);
return CommonResult.success(iFundApplyService.page(page, wrapper));
}
diff --git a/admin/src/main/java/com/neuedu/controller/ProjectController.java b/admin/src/main/java/com/neuedu/controller/ProjectController.java
index 8fe09d2..2cf1d1e 100644
--- a/admin/src/main/java/com/neuedu/controller/ProjectController.java
+++ b/admin/src/main/java/com/neuedu/controller/ProjectController.java
@@ -30,7 +30,7 @@ import org.slf4j.LoggerFactory;
* @since 2020-09-17
*/
@RestController
-@RequestMapping("/college_project")
+@RequestMapping("/project")
public class ProjectController {
private final Logger logger = LoggerFactory.getLogger(ProjectController.class);
@@ -44,6 +44,7 @@ public class ProjectController {
}
@PostMapping("/add")
CommonResult add(Project project) throws IOException {
+ project.setStatus(1);
System.out.println(project.getMultipartFile());
System.out.println(project.getMultipartFile().getSize());
return CommonResult.success(iProjectService.add(project));}
@@ -58,6 +59,7 @@ public class ProjectController {
int limit = Integer.parseInt(param.get("limit").toString());
QueryWrapper wrapper = new QueryWrapper<>();
InitUtil.initEq(param, wrapper, "active");
+ InitUtil.initLike(param, wrapper, "name");
IPage page = new Page<>(num, limit);
return CommonResult.success(iProjectService.page(page, wrapper));
}
--
Gitee
From c08496711beb42a546437efbb505f7da52d84bf2 Mon Sep 17 00:00:00 2001
From: azhao <1655939151@qq.com>
Date: Thu, 24 Sep 2020 14:30:34 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E5=AD=A6=E9=99=A2=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/pom.xml b/pom.xml
index 1e27c5b..3d81578 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,6 +38,7 @@
2.3.30
3.10.3
1.2.70
+ 1.27.2
@@ -111,6 +112,11 @@
fastjson
${fastjson.version}
+
+ com.github.tobato
+ fastdfs-client
+ ${fastdfs.verson}
+
--
Gitee