diff --git a/README.md b/README.md index 391e53a4..0ef1004d 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ **我们开源一套漂亮的代码和一套整洁的代码规范**,让大家在这浮躁的代码世界里感受到一股把代码写好的清流!同时又让开发者节省大量的时间,减少加班,快乐工作,保持谦逊,保持学习,**热爱代码,更热爱生活!** -在线预览:[https://preview.smartadmin.1024lab.net](https://preview.smartadmin.1024lab.net) -部署文档:[https://smartadmin.1024lab.net](https://smartadmin.1024lab.net) +在线预览:[https://preview.smartadmin.vip](https://preview.smartadmin.vip) +官方文档:[https://smartadmin.vip](https://smartadmin.vip) ### 理念与思想 diff --git a/smart-admin-api/pom.xml b/smart-admin-api/pom.xml index 70da0158..03c7b5fe 100644 --- a/smart-admin-api/pom.xml +++ b/smart-admin-api/pom.xml @@ -203,11 +203,11 @@ - - xerces - xercesImpl - ${xerces.version} - + + + + + org.apache.poi poi-scratchpad diff --git a/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/oa/notice/controller/NoticeController.java b/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/oa/notice/controller/NoticeController.java index a06bcf12..8ac0f311 100644 --- a/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/oa/notice/controller/NoticeController.java +++ b/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/oa/notice/controller/NoticeController.java @@ -112,7 +112,6 @@ public class NoticeController { // --------------------- 【员工】查看 通知公告 ------------------------- @ApiOperation("【员工】通知公告-查看详情 @author 卓大") @GetMapping("/oa/notice/employee/view/{noticeId}") - @RepeatSubmit public ResponseDTO view(@PathVariable Long noticeId, HttpServletRequest request) { return noticeEmployeeService.view( SmartRequestUtil.getRequestUserId(), @@ -124,14 +123,12 @@ public class NoticeController { @ApiOperation("【员工】通知公告-查询全部 @author 卓大") @PostMapping("/oa/notice/employee/query") - @RepeatSubmit public ResponseDTO> queryEmployeeNotice(@RequestBody @Valid NoticeEmployeeQueryForm noticeEmployeeQueryForm) { return noticeEmployeeService.queryList(SmartRequestUtil.getRequestUserId(), noticeEmployeeQueryForm); } @ApiOperation("【员工】通知公告-查询 查看记录 @author 卓大") @PostMapping("/oa/notice/employee/queryViewRecord") - @RepeatSubmit public ResponseDTO> queryViewRecord(@RequestBody @Valid NoticeViewRecordQueryForm noticeViewRecordQueryForm) { return ResponseDTO.ok(noticeEmployeeService.queryViewRecord(noticeViewRecordQueryForm)); } diff --git a/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/employee/service/EmployeeService.java b/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/employee/service/EmployeeService.java index 6669719c..d41ff6e3 100644 --- a/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/employee/service/EmployeeService.java +++ b/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/employee/service/EmployeeService.java @@ -111,17 +111,17 @@ public class EmployeeService { */ public synchronized ResponseDTO addEmployee(EmployeeAddForm employeeAddForm) { // 校验名称是否重复 - EmployeeEntity employeeEntity = employeeDao.getByLoginName(employeeAddForm.getLoginName(), false); + EmployeeEntity employeeEntity = employeeDao.getByLoginName(employeeAddForm.getLoginName(), null); if (null != employeeEntity) { return ResponseDTO.userErrorParam("登录名重复"); } // 校验姓名是否重复 - employeeEntity = employeeDao.getByActualName(employeeAddForm.getActualName(), false); + employeeEntity = employeeDao.getByActualName(employeeAddForm.getActualName(), null); if (null != employeeEntity) { return ResponseDTO.userErrorParam("姓名重复"); } // 校验电话是否存在 - employeeEntity = employeeDao.getByPhone(employeeAddForm.getPhone(), false); + employeeEntity = employeeDao.getByPhone(employeeAddForm.getPhone(), null); if (null != employeeEntity) { return ResponseDTO.userErrorParam("手机号已存在"); } @@ -166,17 +166,17 @@ public class EmployeeService { } - EmployeeEntity existEntity = employeeDao.getByLoginName(employeeUpdateForm.getLoginName(), false); + EmployeeEntity existEntity = employeeDao.getByLoginName(employeeUpdateForm.getLoginName(), null); if (null != existEntity && !Objects.equals(existEntity.getEmployeeId(), employeeId)) { return ResponseDTO.userErrorParam("登录名重复"); } - existEntity = employeeDao.getByPhone(employeeUpdateForm.getPhone(), false); + existEntity = employeeDao.getByPhone(employeeUpdateForm.getPhone(), null); if (null != existEntity && !Objects.equals(existEntity.getEmployeeId(), employeeId)) { return ResponseDTO.userErrorParam("手机号已存在"); } - existEntity = employeeDao.getByActualName(employeeUpdateForm.getActualName(), false); + existEntity = employeeDao.getByActualName(employeeUpdateForm.getActualName(), null); if (null != existEntity && !Objects.equals(existEntity.getEmployeeId(), employeeId)) { return ResponseDTO.userErrorParam("姓名重复"); } diff --git a/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/login/service/LoginService.java b/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/login/service/LoginService.java index bc0b1bfa..95dafbe6 100644 --- a/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/login/service/LoginService.java +++ b/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/login/service/LoginService.java @@ -261,6 +261,7 @@ public class LoginService { private void saveLogoutLog(RequestUser requestUser, String ip, String userAgent) { LoginLogEntity loginEntity = LoginLogEntity.builder() .userId(requestUser.getUserId()) + .userType(requestUser.getUserType().getValue()) .userName(requestUser.getUserName()) .userAgent(userAgent) .loginIp(ip) diff --git a/smart-admin-api/sa-common/pom.xml b/smart-admin-api/sa-common/pom.xml index 0a52eeda..6a5d2b38 100644 --- a/smart-admin-api/sa-common/pom.xml +++ b/smart-admin-api/sa-common/pom.xml @@ -184,10 +184,10 @@ - - xerces - xercesImpl - + + + + org.apache.poi poi-scratchpad diff --git a/smart-admin-api/sa-common/src/main/java/net/lab1024/sa/common/module/support/codegenerator/service/variable/CodeGenerateBaseVariableService.java b/smart-admin-api/sa-common/src/main/java/net/lab1024/sa/common/module/support/codegenerator/service/variable/CodeGenerateBaseVariableService.java index d412d1fc..aff8da16 100644 --- a/smart-admin-api/sa-common/src/main/java/net/lab1024/sa/common/module/support/codegenerator/service/variable/CodeGenerateBaseVariableService.java +++ b/smart-admin-api/sa-common/src/main/java/net/lab1024/sa/common/module/support/codegenerator/service/variable/CodeGenerateBaseVariableService.java @@ -149,7 +149,7 @@ public abstract class CodeGenerateBaseVariableService { */ protected String getJavaPackageName(String javaType) { if ("BigDecimal".equals(javaType)) { - return "import java.math.BigDecimal"; + return "import java.math.BigDecimal;"; } else if ("LocalDate".equals(javaType)) { return "import java.time.LocalDate;"; } else if ("LocalDateTime".equals(javaType)) { diff --git a/smart-admin-api/sa-common/src/main/java/net/lab1024/sa/common/module/support/file/service/FileService.java b/smart-admin-api/sa-common/src/main/java/net/lab1024/sa/common/module/support/file/service/FileService.java index 34449f32..bafb75ea 100644 --- a/smart-admin-api/sa-common/src/main/java/net/lab1024/sa/common/module/support/file/service/FileService.java +++ b/smart-admin-api/sa-common/src/main/java/net/lab1024/sa/common/module/support/file/service/FileService.java @@ -139,9 +139,9 @@ public class FileService { fileEntity.setFileSize(file.getSize()); fileEntity.setFileKey(uploadVO.getFileKey()); fileEntity.setFileType(uploadVO.getFileType()); - fileEntity.setCreatorId(requestUser == null ? null:requestUser.getUserId()); - fileEntity.setCreatorName(requestUser == null ? null:requestUser.getUserName()); - fileEntity.setCreatorUserType(requestUser == null ? null:requestUser.getUserType().getValue()); + fileEntity.setCreatorId(requestUser == null ? null : requestUser.getUserId()); + fileEntity.setCreatorName(requestUser == null ? null : requestUser.getUserName()); + fileEntity.setCreatorUserType(requestUser == null ? null : requestUser.getUserType().getValue()); fileDao.insert(fileEntity); uploadVO.setFileId(fileEntity.getFileId()); // 添加缓存 @@ -230,6 +230,13 @@ public class FileService { * @throws IOException */ public ResponseEntity downloadByFileKey(String fileKey, String userAgent) { + FileVO fileVO = fileDao.getByFileKey(fileKey); + if (fileVO == null) { + HttpHeaders heads = new HttpHeaders(); + heads.add(HttpHeaders.CONTENT_TYPE, "text/html;charset=UTF-8"); + return new ResponseEntity<>("文件不存在:" + fileKey, heads, HttpStatus.OK); + } + // 根据文件服务类 获取对应文件服务 查询 url ResponseDTO responseDTO = fileStorageService.fileDownload(fileKey); if (!responseDTO.getOk()) { @@ -237,15 +244,17 @@ public class FileService { heads.add(HttpHeaders.CONTENT_TYPE, "text/html;charset=UTF-8"); return new ResponseEntity<>(responseDTO.getMsg() + ":" + fileKey, heads, HttpStatus.OK); } - // 设置下载头 - HttpHeaders heads = new HttpHeaders(); - heads.add(HttpHeaders.CONTENT_TYPE, "application/octet-stream; charset=utf-8"); - // 设置对应浏览器的文件名称编码 + FileDownloadVO fileDownloadVO = responseDTO.getData(); FileMetadataVO metadata = fileDownloadVO.getMetadata(); - String fileName = null != metadata ? metadata.getFileName() : fileKey.substring(fileKey.lastIndexOf("/")); - fileName = fileStorageService.getDownloadFileNameByUA(fileName, userAgent); - heads.add(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + fileName); + + // 设置下载头 + HttpHeaders heads = new HttpHeaders(); + heads.add(HttpHeaders.CONTENT_LENGTH, String.valueOf(metadata.getFileSize())); + heads.add(HttpHeaders.CONTENT_TYPE, "application/octet-stream; charset=utf-8"); + heads.add(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + fileStorageService.getDownloadFileNameByUA(fileVO.getFileName(), userAgent)); + + // 返回给前端 ResponseEntity responseEntity = new ResponseEntity<>(fileDownloadVO.getData(), heads, HttpStatus.OK); return responseEntity; } diff --git a/smart-admin-api/sa-common/src/main/java/net/lab1024/sa/common/module/support/file/service/FileStorageLocalServiceImpl.java b/smart-admin-api/sa-common/src/main/java/net/lab1024/sa/common/module/support/file/service/FileStorageLocalServiceImpl.java index 3842aef6..759a3fd1 100644 --- a/smart-admin-api/sa-common/src/main/java/net/lab1024/sa/common/module/support/file/service/FileStorageLocalServiceImpl.java +++ b/smart-admin-api/sa-common/src/main/java/net/lab1024/sa/common/module/support/file/service/FileStorageLocalServiceImpl.java @@ -5,6 +5,7 @@ import net.lab1024.sa.common.common.code.SystemErrorCode; import net.lab1024.sa.common.common.code.UserErrorCode; import net.lab1024.sa.common.common.domain.ResponseDTO; import net.lab1024.sa.common.module.support.file.domain.vo.FileDownloadVO; +import net.lab1024.sa.common.module.support.file.domain.vo.FileMetadataVO; import net.lab1024.sa.common.module.support.file.domain.vo.FileUploadVO; import net.lab1024.sa.common.module.support.config.ConfigKeyEnum; import net.lab1024.sa.common.module.support.config.ConfigService; @@ -119,6 +120,13 @@ public class FileStorageLocalServiceImpl implements IFileStorageService { byte[] buffer = FileCopyUtils.copyToByteArray(in); FileDownloadVO fileDownloadVO = new FileDownloadVO(); fileDownloadVO.setData(buffer); + + FileMetadataVO fileMetadataDTO = new FileMetadataVO(); + fileMetadataDTO.setFileName(localFile.getName()); + fileMetadataDTO.setFileSize(localFile.length()); + fileMetadataDTO.setFileFormat(FilenameUtils.getExtension(localFile.getName())); + fileDownloadVO.setMetadata(fileMetadataDTO); + return ResponseDTO.ok(fileDownloadVO); } catch (IOException e) { log.error("文件下载-发生异常:", e); diff --git a/smart-admin-api/sa-common/src/main/java/net/lab1024/sa/common/module/support/repeatsubmit/RepeatSubmitAspect.java b/smart-admin-api/sa-common/src/main/java/net/lab1024/sa/common/module/support/repeatsubmit/RepeatSubmitAspect.java index 1bf8cae0..bba00d9e 100644 --- a/smart-admin-api/sa-common/src/main/java/net/lab1024/sa/common/module/support/repeatsubmit/RepeatSubmitAspect.java +++ b/smart-admin-api/sa-common/src/main/java/net/lab1024/sa/common/module/support/repeatsubmit/RepeatSubmitAspect.java @@ -60,16 +60,24 @@ public class RepeatSubmitAspect { if (timeStamp != null) { Method method = ((MethodSignature) point.getSignature()).getMethod(); RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class); + + // 说明注解去掉了 + if (annotation != null) { + return point.proceed(); + } + int interval = Math.min(annotation.value(), RepeatSubmit.MAX_INTERVAL); if (System.currentTimeMillis() < timeStamp + interval) { // 提交频繁 return ResponseDTO.error(UserErrorCode.REPEAT_SUBMIT); } + } Object obj = null; try { - obj = point.proceed(); + // 先给 ticket 设置在执行中 this.repeatSubmitTicket.putTicket(ticket); + obj = point.proceed(); } catch (Throwable throwable) { log.error("", throwable); throw throwable; diff --git a/smart-admin-api/sa-common/src/main/resources/code-generator-template/js/form.vue.vm b/smart-admin-api/sa-common/src/main/resources/code-generator-template/js/form.vue.vm index e302c22c..fa5da6a5 100644 --- a/smart-admin-api/sa-common/src/main/resources/code-generator-template/js/form.vue.vm +++ b/smart-admin-api/sa-common/src/main/resources/code-generator-template/js/form.vue.vm @@ -10,19 +10,14 @@ :title="form.$!{primaryKeyFieldName} ? '编辑' : '添加'" width="$!{insertAndUpdate.width}" :visible="visibleFlag" - @close="onClose" + @cancel="onClose" :maskClosable="false" :destroyOnClose="true" > -#if($insertAndUpdate.countPerLine > 1) - -#end -#foreach ($field in $formFields) -#if($insertAndUpdate.countPerLine > 1) -#set($span=24 / $!insertAndUpdate.countPerLine ) - -#end + #if($insertAndUpdate.countPerLine == 1) + + #foreach ($field in $formFields) #if($field.frontComponent == "Input") @@ -66,19 +61,78 @@ #if($field.frontComponent == "Upload") #end -#end -#if($insertAndUpdate.countPerLine > 1) - - -#end + #end + + #end + + #if($insertAndUpdate.countPerLine > 1) + + #set($span=24 / $!insertAndUpdate.countPerLine ) + #foreach ($field in $formFields) + + #if($field.frontComponent == "Input") + + + + #end + #if($field.frontComponent == "InputNumber") + + + + #end + #if($field.frontComponent == "Textarea") + + + + #end + #if($field.frontComponent == "BooleanSelect") + + + + #end + #if($field.frontComponent == "SmartEnumSelect") + + + + #end + #if($field.frontComponent == "DictSelect") + + + + #end + #if($field.frontComponent == "Date") + + + + #end + #if($field.frontComponent == "DateTime") + + + + #end + #if($field.frontComponent == "Upload") + + + + #end + + #end + + #end @@ -64,6 +64,11 @@ return parentMenuList.value.map((e) => e.name); }); + // 展开菜单的顶级目录名字适配,只展示两个字为好 + function menuNameAdapter(name){ + return name.substr(0,2); + } + //监听路由的变化,进行更新菜单展开项目 watch( currentRoute, diff --git a/smart-admin-web/javascript-ant-design-vue3/src/layout/components/side-help-doc/index.vue b/smart-admin-web/javascript-ant-design-vue3/src/layout/components/side-help-doc/index.vue index 62c7ced4..fb160384 100644 --- a/smart-admin-web/javascript-ant-design-vue3/src/layout/components/side-help-doc/index.vue +++ b/smart-admin-web/javascript-ant-design-vue3/src/layout/components/side-help-doc/index.vue @@ -77,34 +77,34 @@ // ------------------ 意见反馈 -------------------------- let feedbackMessageList = ref([]); onMounted(() => { - // 默认先查询一次 + // 首先查询多一些意见反馈 queryFeedbackList(); - scroll(); + // 更换显示 + scheduleShowFeedback(); }); - let scrollInterval = null; - let swiper = 1; + let scheduleShowInterval = null; + let scheduleShowIndex = 0; - function scroll() { - if (scrollInterval != null) { + function scheduleShowFeedback() { + if (scheduleShowInterval != null) { return; } - scrollInterval = setInterval(() => { - if (currentPage >= pages) { - currentPage = 1; - } - if (pages == 0 || feedbackList.length == 0) { + scheduleShowInterval = setInterval(() => { + if (feedbackList.length == 0) { return; } - let initValue = (currentPage - 1) * 2; - feedbackMessageList.value[0] = feedbackList[initValue]; - if (feedbackList[initValue + 1]) { - feedbackMessageList.value[1] = feedbackList[initValue + 1]; + + // 显示两条意见反馈 + for (let i = 0; i < 2; i++) { + if (scheduleShowIndex >= feedbackList.length) { + scheduleShowIndex = 0; + } + feedbackMessageList.value[i] = feedbackList[scheduleShowIndex]; + scheduleShowIndex++; } - swiper = currentPage - 1; - currentPage++; - }, 2000); + }, 3000); } // 总页数 @@ -121,7 +121,7 @@ }; let result = await feedbackApi.queryFeedback(param); feedbackList = result.data.list; - pages = Math.ceil(result.data.total / 2); + pages = Math.ceil(feedbackList.length / 2); } catch (e) { smartSentry.captureError(e); } @@ -143,9 +143,9 @@ //SmartAdmin中 router的name 就是 后端存储menu的id let menuId = -1; try { - if(currentRoute.name === HOME_PAGE_NAME){ + if (currentRoute.name === HOME_PAGE_NAME) { menuId = 0; - }else{ + } else { menuId = _.toNumber(currentRoute.name); } } catch (e) { @@ -163,7 +163,7 @@