夏文涛 vor 1 Jahr
Ursprung
Commit
965d98df75

+ 21 - 0
src/main/java/com/template/api/WelcomeFileControllerAPI.java

@@ -0,0 +1,21 @@
+package com.template.api;
+
+import com.template.model.request.InfoCollectionRequest;
+import com.template.model.request.InsertStudentRequest;
+import com.template.model.result.CommonResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+@RequestMapping("/api/welcomeFile")
+@Api(tags = {"WelcomeFileController"}, value = "文件管理")
+public interface WelcomeFileControllerAPI {
+
+    @PostMapping(value = "/uploadFile")
+    @ApiOperation(value = "文件上传", notes = "文件上传", httpMethod = "POST")
+    CommonResult uploadFile(@RequestParam("file") MultipartFile file) throws Exception;
+
+}

+ 89 - 0
src/main/java/com/template/controller/WelcomeFileController.java

@@ -0,0 +1,89 @@
+package com.template.controller;
+
+
+import com.jcraft.jsch.*;
+import com.template.api.WelcomeFileControllerAPI;
+import com.template.model.result.CommonResult;
+import com.template.model.vo.UploadFileVo;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.InputStream;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author ceshi
+ * @since 2025-06-13
+ */
+@RestController
+public class WelcomeFileController implements WelcomeFileControllerAPI {
+
+    /**
+     * 文件上传
+     *
+     * @param file 上传的文件
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public CommonResult uploadFile(MultipartFile file) throws Exception {
+
+        UploadFileVo result = new UploadFileVo();
+
+        String name = com.repair.common.utils.StrUtils.getRandomName(file.getOriginalFilename());
+
+        String user = "root"; //SFTP服务器用户名
+        String password = "Waimai2024#"; // SFTP服务器密码
+        String host = "172.16.40.122";  //  SFTP服务器地址
+        int port = 22; // SFTP 服务器端口
+        String remoteDirPath = "/home/image"; // 远程目录路径
+        //从MultipartFile对象中获取流
+        InputStream inputStream = null;
+        inputStream = file.getInputStream();
+        //String downpath="/book/《Python爬虫开发与项目实战》.pdf";
+        //String spath="C:/Users/F1339769/Desktop";
+        JSch jsch = new JSch();
+        Session session = null;
+        ChannelSftp channelSftp = null;
+        try {
+            session = jsch.getSession(user, host, port);
+            session.setPassword(password);
+            session.setConfig("StrictHostKeyChecking", "no");
+            session.connect(30000);
+            System.out.println("连接成功");
+            channelSftp = (ChannelSftp) session.openChannel("sftp");
+            channelSftp.connect();
+            // 创建远程目录
+            String[] dirArr = remoteDirPath.split("/");
+            String path = "";
+            for (int i = 0; i < dirArr.length; i++) {
+                path = path + "/" + dirArr[i];
+                try {
+                    channelSftp.cd(path);
+                } catch (SftpException e) {
+                    channelSftp.mkdir(path);
+                    channelSftp.cd(path);
+                }
+            }
+            //  文件上传到远程服务器上
+            channelSftp.put(inputStream, name);
+            //  从远程服务器上下载文件
+            //channelSftp.get(downpath, spath);
+        } catch (JSchException e) {
+            e.printStackTrace();
+        } finally {
+            if (channelSftp != null) {
+                channelSftp.disconnect();
+            }
+            if (session != null) {
+                session.disconnect();
+            }
+            result.setUrl("https://chtech.ncjti.edu.cn/alumnus/homeimage/" + name);
+        }
+        return CommonResult.ok(result);
+    }
+}
+

+ 9 - 3
src/main/java/com/template/controller/WelcomeStudentController.java

@@ -82,6 +82,9 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
         ws.setCollege(isr.getCollege());
         ws.setMajor(isr.getMajor());
         ws.setClassstr(isr.getClassstr());
+        ws.setCollegeId(isr.getCollegeId());
+        ws.setMajorId(isr.getMajorId());
+        ws.setClassstrId(isr.getClassstrId());
         ws.setExamNum(isr.getExamNum());
         ws.setEduSystem(isr.getEduSystem());
         ws.setGraduationSchool(isr.getGraduationSchool());
@@ -260,6 +263,9 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
         result.setCollege(ws.getCollege());
         result.setMajor(ws.getMajor());
         result.setClassstr(ws.getClassstr());
+        result.setCollegeId(ws.getCollegeId());
+        result.setMajorId(ws.getMajorId());
+        result.setClassstrId(ws.getClassstrId());
         result.setExamNum(ws.getExamNum());
         result.setEduSystem(ws.getEduSystem());
         result.setGraduationSchool(ws.getGraduationSchool());
@@ -312,9 +318,9 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
         ws.setCardId(icr.getCardId());
         ws.setSex(icr.getSex());
         ws.setBirthday(icr.getBirthday());
-        ws.setCollege(icr.getCollege());
-        ws.setMajor(icr.getMajor());
-        ws.setClassstr(icr.getClassstr());
+        ws.setCollegeId(icr.getCollegeId());
+        ws.setMajorId(icr.getMajorId());
+        ws.setClassstrId(icr.getClassstrId());
         ws.setExamNum(icr.getExamNum());
         ws.setEduSystem(icr.getEduSystem());
         ws.setGraduationSchool(icr.getGraduationSchool());

+ 8 - 2
src/main/java/com/template/model/pojo/WelcomeBed.java

@@ -52,12 +52,18 @@ public class WelcomeBed implements Serializable {
     @ApiModelProperty(value = "所属学院")
     private String college;
 
-    @ApiModelProperty(value = "所属年级")
-    private String gradestr;
+    @ApiModelProperty(value = "所属学院ID")
+    private Integer collegeId;
+
+    @ApiModelProperty(value = "所属专业ID")
+    private Integer majorId;
 
     @ApiModelProperty(value = "所属班级")
     private String classstr;
 
+    @ApiModelProperty(value = "所属班级ID")
+    private Integer classstrId;
+
     @ApiModelProperty(value = "是否入住")
     private Integer isCheck;
 

+ 8 - 2
src/main/java/com/template/model/pojo/WelcomeDormitory.java

@@ -49,8 +49,14 @@ public class WelcomeDormitory implements Serializable {
     @ApiModelProperty(value = "所属学院")
     private String college;
 
-    @ApiModelProperty(value = "所属年级")
-    private String gradestr;
+    @ApiModelProperty(value = "所属专业")
+    private String major;
+
+    @ApiModelProperty(value = "所属学院ID")
+    private Integer collegeId;
+
+    @ApiModelProperty(value = "所属专业ID")
+    private Integer majorId;
 
     @ApiModelProperty(value = "床位数")
     private Integer bedNumber;

+ 9 - 0
src/main/java/com/template/model/pojo/WelcomeStudent.java

@@ -56,12 +56,21 @@ public class WelcomeStudent implements Serializable {
     @ApiModelProperty(value = "院系")
     private String college;
 
+    @ApiModelProperty(value = "院系ID")
+    private Integer collegeId;
+
     @ApiModelProperty(value = "专业")
     private String major;
 
+    @ApiModelProperty(value = "专业ID")
+    private Integer majorId;
+
     @ApiModelProperty(value = "班级")
     private String classstr;
 
+    @ApiModelProperty(value = "班级ID")
+    private Integer classstrId;
+
     @ApiModelProperty(value = "考生号")
     private String examNum;
 

+ 9 - 0
src/main/java/com/template/model/request/InfoCollectionRequest.java

@@ -49,6 +49,15 @@ public class InfoCollectionRequest {
     @ApiModelProperty(value = "班级")
     private String classstr;
 
+    @ApiModelProperty(value = "院系ID")
+    private Integer collegeId;
+
+    @ApiModelProperty(value = "专业ID")
+    private Integer majorId;
+
+    @ApiModelProperty(value = "班级ID")
+    private Integer classstrId;
+
     @ApiModelProperty(value = "考生号")
     private String examNum;
 

+ 9 - 0
src/main/java/com/template/model/request/InsertStudentRequest.java

@@ -50,6 +50,15 @@ public class InsertStudentRequest implements Serializable {
     @ApiModelProperty(value = "班级")
     private String classstr;
 
+    @ApiModelProperty(value = "院系ID")
+    private Integer collegeId;
+
+    @ApiModelProperty(value = "专业ID")
+    private Integer majorId;
+
+    @ApiModelProperty(value = "班级ID")
+    private Integer classstrId;
+
     @ApiModelProperty(value = "考生号")
     private String examNum;
 

+ 9 - 0
src/main/java/com/template/model/vo/StudentDetailVo.java

@@ -48,6 +48,15 @@ public class StudentDetailVo {
     @ApiModelProperty(value = "班级")
     private String classstr;
 
+    @ApiModelProperty(value = "院系")
+    private Integer collegeId;
+
+    @ApiModelProperty(value = "专业")
+    private Integer majorId;
+
+    @ApiModelProperty(value = "班级")
+    private Integer classstrId;
+
     @ApiModelProperty(value = "考生号")
     private String examNum;