收藏關注不迷路!!
🌟文末獲取源碼+數據庫🌟
感興趣的可以先收藏起來,還有大家在畢設選題(免費咨詢指導選題),項目以及論文編寫等相關問題都可以給我留言咨詢,希望幫助更多的人
文章目錄
- 摘要
- 一、開發技術介紹
- 二、功能介紹
- 三、代碼展示
- 四、效果圖
- 五 、源碼獲取
摘要
隨著科學技術的飛速發展,社會的方方面面、各行各業都在努力與現代的先進技術接軌,通過科技手段來提高自身的優勢,新生宿舍管理系統當然也不能排除在外。新生宿舍管理系統是以實際運用為開發背景,運用軟件工程原理和開發方法,采用springboot框架構建的一個管理系統。整個開發過程首先對軟件系統進行需求分析,得出系統的主要功能。接著對系統進行總體設計和詳細設計。總體設計主要包括系統功能設計、系統總體結構設計、系統數據結構設計和系統安全設計等;詳細設計主要包括系統數據庫訪問的實現,主要功能模塊的具體實現,模塊實現關鍵代碼等。最后對系統進行功能測試,并對測試結果進行分析總結,得出系統中存在的不足及需要改進的地方,為以后的系統維護提供了方便,同時也為今后開發類似系統提供了借鑒和幫助。這種個性化的網上管理系統特別注重交互協調與管理的相互配合,激發了管理人員的創造性與主動性,對新生宿舍管理系統而言非常有利。
本新生宿舍管理系統采用的數據庫是Mysql,使用springboot框架開發。在設計過程中,充分保證了系統代碼的良好可讀性、實用性、易擴展性、通用性、便于后期維護、操作方便以及頁面簡潔等特點。
關鍵詞:新生宿舍管理系統,springboot框架 Mysql數據庫 Java技術
一、開發技術介紹
- B/S 架構
- Java
- MySQL
- SpringBoot
二、功能介紹
三、代碼展示
package com.controller;import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;/*** 上傳文件映射表*/
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{@Autowiredprivate ConfigService configService;/*** 上傳文件*/@RequestMapping("/upload")public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {if (file.isEmpty()) {throw new EIException("上傳文件不能為空");}String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);File path = new File(ResourceUtils.getURL("classpath:static").getPath());if(!path.exists()) {path = new File("");}File upload = new File(path.getAbsolutePath(),"/upload/");if(!upload.exists()) {upload.mkdirs();}String fileName = new Date().getTime()+"."+fileExt;File dest = new File(upload.getAbsolutePath()+"/"+fileName);file.transferTo(dest);if(StringUtils.isNotBlank(type) && type.equals("1")) {ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));if(configEntity==null) {configEntity = new ConfigEntity();configEntity.setName("faceFile");configEntity.setValue(fileName);} else {configEntity.setValue(fileName);}configService.insertOrUpdate(configEntity);}return R.ok().put("file", fileName);}/*** 下載文件*/@IgnoreAuth@RequestMapping("/download")public ResponseEntity<byte[]> download(@RequestParam String fileName) {try {File path = new File(ResourceUtils.getURL("classpath:static").getPath());if(!path.exists()) {path = new File("");}File upload = new File(path.getAbsolutePath(),"/upload/");if(!upload.exists()) {upload.mkdirs();}File file = new File(upload.getAbsolutePath()+"/"+fileName);if(file.exists()){/*if(!fileService.canRead(file, SessionManager.getSessionUser())){getResponse().sendError(403);}*/HttpHeaders headers = new HttpHeaders();headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); headers.setContentDispositionFormData("attachment", fileName); return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);}} catch (IOException e) {e.printStackTrace();}return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);}}
四、效果圖
五 、源碼獲取
下方名片聯系我即可!!
大家點贊、收藏、關注、評論啦 、查看👇🏻獲取聯系方式👇🏻