diff --git a/src/main/java/com/lq/api/package-info.java b/src/main/java/com/lq/api/package-info.java deleted file mode 100644 index da9ca92..0000000 --- a/src/main/java/com/lq/api/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package com.lq.api; \ No newline at end of file diff --git a/src/main/java/com/lq/api/service/SysFileService.java b/src/main/java/com/lq/api/service/SysFileService.java new file mode 100644 index 0000000..f1431ce --- /dev/null +++ b/src/main/java/com/lq/api/service/SysFileService.java @@ -0,0 +1,9 @@ +package com.lq.api.service; + +import com.lq.code.service.BaseService; +import com.lq.entity.SysFile; + +public interface SysFileService extends BaseService{ + + +} diff --git a/src/main/java/com/lq/api/service/impl/SysFileServiceImpl.java b/src/main/java/com/lq/api/service/impl/SysFileServiceImpl.java new file mode 100644 index 0000000..64ad2bb --- /dev/null +++ b/src/main/java/com/lq/api/service/impl/SysFileServiceImpl.java @@ -0,0 +1,22 @@ +package com.lq.api.service.impl; + +import com.lq.api.service.SysFileService; +import com.lq.code.dao.BaseDao; +import com.lq.code.service.BaseService; +import com.lq.code.service.impl.BaseServiceImpl; +import com.lq.dao.SysFileDao; +import com.lq.entity.SysFile; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class SysFileServiceImpl extends BaseServiceImpl implements SysFileService { + + @Autowired + private SysFileDao sysFileDao; + + @Override + public BaseDao getBaseDao() { + return sysFileDao; + } +} diff --git a/src/main/java/com/lq/api/vo/SysFileVo.java b/src/main/java/com/lq/api/vo/SysFileVo.java new file mode 100644 index 0000000..0960756 --- /dev/null +++ b/src/main/java/com/lq/api/vo/SysFileVo.java @@ -0,0 +1,6 @@ +package com.lq.api.vo; + +public class SysFileVo { + + +} diff --git a/src/main/java/com/lq/api/web/SysFileController.java b/src/main/java/com/lq/api/web/SysFileController.java index 8ac5b5f..fec17eb 100644 --- a/src/main/java/com/lq/api/web/SysFileController.java +++ b/src/main/java/com/lq/api/web/SysFileController.java @@ -1,8 +1,12 @@ package com.lq.api.web; +import com.lq.api.service.SysFileService; +import com.lq.cms.emun.StatusTypeEnum; import com.lq.code.entity.AjaxResult; import com.lq.code.util.FileUtil; import com.lq.entity.SysFile; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -11,8 +15,15 @@ import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import java.io.File; +import java.io.IOException; +import java.nio.file.FileSystems; +import java.nio.file.Path; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; +import java.util.List; +import java.util.logging.Logger; + @Controller @RequestMapping("/file") public class SysFileController { @@ -20,11 +31,13 @@ public class SysFileController { @Value("${file.upload}") private String FILE_LOAD_PATH; + @Autowired + private SysFileService sysFileService; @RequestMapping("/upload") @ResponseBody - public Object upload(@RequestParam("files")MultipartFile[] files){ + public Object upload(@RequestParam("files")MultipartFile[] files) throws IOException { AjaxResult ajaxResult = new AjaxResult(); ajaxResult.setMsg("上传成功"); Date nowTime = new Date(); @@ -33,14 +46,28 @@ public class SysFileController { if (!fileDir.exists()){ fileDir.mkdirs(); } + List sysFileList = new ArrayList<>(); for (MultipartFile multipartFile:files){ + String originalFileName = multipartFile.getOriginalFilename(); + Path path = FileSystems.getDefault().getPath(FILE_LOAD_PATH+sdf.format(nowTime),originalFileName); + //上传文件 + multipartFile.transferTo(path); + //保存文件信息 SysFile sysFile = new SysFile(); sysFile.setCreateTime(nowTime); - String fileType = FileUtil.getFileType(multipartFile.getName()); + String fileType = FileUtil.getFileType(originalFileName); sysFile.setFileType(fileType); - sysFile.setFileName(multipartFile.getName()); - + sysFile.setFileName(originalFileName); + sysFile.setPath(sdf.format(nowTime)+"/"+originalFileName); + sysFile.setStatus(StatusTypeEnum.STATUS_ACTIVITY_YES.getValue()); + sysFileService.save(sysFile); + sysFileList.add(sysFile); } + ajaxResult.setData(sysFileList); return ajaxResult; } + + + + } diff --git a/src/main/resources/spring/spring-shiro.xml b/src/main/resources/spring/spring-shiro.xml index 275f374..b6749fb 100644 --- a/src/main/resources/spring/spring-shiro.xml +++ b/src/main/resources/spring/spring-shiro.xml @@ -39,7 +39,7 @@ - + diff --git a/src/main/webapp/WEB-INF/views/jsp/cms/sys/menu/edit.jsp b/src/main/webapp/WEB-INF/views/jsp/cms/sys/menu/edit.jsp index fb04b1a..fe41b70 100644 --- a/src/main/webapp/WEB-INF/views/jsp/cms/sys/menu/edit.jsp +++ b/src/main/webapp/WEB-INF/views/jsp/cms/sys/menu/edit.jsp @@ -53,6 +53,11 @@ + @@ -91,7 +96,8 @@ }else { isSelect = ''; } - html+= ''; + html+= ''; + // html+= ''; } $("#menuIco").append(html); }