From 6b98f0289f97f34ff4017f06588f17c42badb99f Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Mon, 30 Sep 2024 13:32:31 +0800 Subject: [PATCH 001/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feishu/config/FolderProperties.java | 26 +++++++++++++++++++ .../feishu/config/ResourceProperties.java | 2 ++ .../feishu/constants/FeishuConstants.java | 15 +++++++---- 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/achobeta/feishu/config/FolderProperties.java diff --git a/src/main/java/com/achobeta/feishu/config/FolderProperties.java b/src/main/java/com/achobeta/feishu/config/FolderProperties.java new file mode 100644 index 00000000..83a36a8e --- /dev/null +++ b/src/main/java/com/achobeta/feishu/config/FolderProperties.java @@ -0,0 +1,26 @@ +package com.achobeta.feishu.config; + +import com.achobeta.util.HttpRequestUtil; +import lombok.Data; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-09-30 + * Time: 13:21 + */ +@Data +public class FolderProperties { + + private String root; + + private String docxResource; + + private String docxCooperate; + + private String sheetResource; + + private String sheetCooperate; + +} diff --git a/src/main/java/com/achobeta/feishu/config/ResourceProperties.java b/src/main/java/com/achobeta/feishu/config/ResourceProperties.java index 338efb22..66c8aa8f 100644 --- a/src/main/java/com/achobeta/feishu/config/ResourceProperties.java +++ b/src/main/java/com/achobeta/feishu/config/ResourceProperties.java @@ -22,4 +22,6 @@ public class ResourceProperties { private Integer maxCount; + private FolderProperties folder; + } diff --git a/src/main/java/com/achobeta/feishu/constants/FeishuConstants.java b/src/main/java/com/achobeta/feishu/constants/FeishuConstants.java index cd8e0c46..3893e0a2 100644 --- a/src/main/java/com/achobeta/feishu/constants/FeishuConstants.java +++ b/src/main/java/com/achobeta/feishu/constants/FeishuConstants.java @@ -1,5 +1,8 @@ package com.achobeta.feishu.constants; +import cn.hutool.extra.spring.SpringUtil; +import com.achobeta.feishu.config.FeishuAppConfig; +import com.achobeta.feishu.config.FolderProperties; import com.achobeta.util.HttpRequestUtil; import java.util.Optional; @@ -13,12 +16,14 @@ */ public interface FeishuConstants { - String ACHOBETA_RECRUITMENT_ROOT_FOLDER = "Sx9KfdvAzlY0YudYhEMcziRznpe"; + FolderProperties ACHOBETA_RESOURCE_FOLDER = SpringUtil.getBean(FeishuAppConfig.class).getResource().getFolder(); + + String ACHOBETA_RECRUITMENT_ROOT_FOLDER = ACHOBETA_RESOURCE_FOLDER.getRoot(); String ACHOBETA_RECRUITMENT_ROOT_URL = HttpRequestUtil.buildUrl("https://j16c0vnbedn.feishu.cn/drive/folder/{folderToken}", null, ACHOBETA_RECRUITMENT_ROOT_FOLDER); - String ACHOBETA_RECRUITMENT_DOCX_FOLDER_RESOURCE = "LpDBf0emllgCc2dKNfKcsqxJnjc"; - String ACHOBETA_RECRUITMENT_SHEET_FOLDER_RESOURCE = "OQbUfIGR9lqdFVdbJCDcQ3CSntd"; - String ACHOBETA_RECRUITMENT_DOCX_FOLDER_COOPERATE = "LpDBf0emllgCc2dKNfKcsqxJnjc"; - String ACHOBETA_RECRUITMENT_SHEET_FOLDER_COOPERATE = "SyBEf61JglcR5NdCp34cs2tGnMd"; + String ACHOBETA_RECRUITMENT_DOCX_FOLDER_RESOURCE = ACHOBETA_RESOURCE_FOLDER.getDocxResource(); + String ACHOBETA_RECRUITMENT_SHEET_FOLDER_RESOURCE = ACHOBETA_RESOURCE_FOLDER.getSheetResource(); + String ACHOBETA_RECRUITMENT_DOCX_FOLDER_COOPERATE = ACHOBETA_RESOURCE_FOLDER.getDocxCooperate(); + String ACHOBETA_RECRUITMENT_SHEET_FOLDER_COOPERATE = ACHOBETA_RESOURCE_FOLDER.getSheetCooperate(); String AUTHORIZATION_HEADER = "Authorization"; From 0023ccd637b89abcb40a6c7e587b3e80616e2fcf Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Mon, 30 Sep 2024 13:32:53 +0800 Subject: [PATCH 002/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/achobeta/feishu/config/FolderProperties.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/achobeta/feishu/config/FolderProperties.java b/src/main/java/com/achobeta/feishu/config/FolderProperties.java index 83a36a8e..0e6b2cc0 100644 --- a/src/main/java/com/achobeta/feishu/config/FolderProperties.java +++ b/src/main/java/com/achobeta/feishu/config/FolderProperties.java @@ -1,6 +1,5 @@ package com.achobeta.feishu.config; -import com.achobeta.util.HttpRequestUtil; import lombok.Data; /** From a1b4f27d864647de473b7a95f1529d285a5ec80e Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Mon, 30 Sep 2024 22:53:04 +0800 Subject: [PATCH 003/104] =?UTF-8?q?feat:=20=E6=95=B4=E7=90=86sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/database/achobeta_recruitment.sql | 4 ++ sql/feedback/user_feedback.sql | 22 +++++++ sql/message/message.sql | 8 +-- sql/{ => shortlink}/short_link.sql | 0 .../resume_status_process.sql | 0 sql/{ => student}/stu_attachment.sql | 0 sql/{ => student}/stu_resume.sql | 0 sql/{interview => user}/member.sql | 0 sql/{ => user}/user.sql | 0 .../ext/MessageSendWithEmailHandler.java | 63 ++++++------------- .../domain/message/model/entity/Message.java | 4 +- src/main/java/com/achobeta/util/TimeUtil.java | 4 -- 12 files changed, 51 insertions(+), 54 deletions(-) create mode 100644 sql/database/achobeta_recruitment.sql create mode 100644 sql/feedback/user_feedback.sql rename sql/{ => shortlink}/short_link.sql (100%) rename sql/{resumestate => student}/resume_status_process.sql (100%) rename sql/{ => student}/stu_attachment.sql (100%) rename sql/{ => student}/stu_resume.sql (100%) rename sql/{interview => user}/member.sql (100%) rename sql/{ => user}/user.sql (100%) diff --git a/sql/database/achobeta_recruitment.sql b/sql/database/achobeta_recruitment.sql new file mode 100644 index 00000000..0c9ce607 --- /dev/null +++ b/sql/database/achobeta_recruitment.sql @@ -0,0 +1,4 @@ + +drop database if exists achobeta_recruitment; +create database achobeta_recruitment charset=utf8mb4; +use achobeta_recruitment; diff --git a/sql/feedback/user_feedback.sql b/sql/feedback/user_feedback.sql new file mode 100644 index 00000000..4e27d6f1 --- /dev/null +++ b/sql/feedback/user_feedback.sql @@ -0,0 +1,22 @@ +create table user_feedback +( + id bigint auto_increment comment '反馈id' primary key, + user_id bigint not null comment '用户id', + batch_id bigint not null comment '招新批次', + message_id bigint default null comment '处理结果的消息id', + title varchar(256) default '' not null comment '反馈标题', + content text not null comment '反馈内容', + attachment bigint default null comment '附件链接', + feedback_time datetime default CURRENT_TIMESTAMP not null comment '反馈时间' + is_handle bit default b'0' not null comment '是否处理标记', + version int default 1 not null comment '乐观锁', + is_deleted bit default b'0' not null comment '伪删除标记', + create_time datetime default CURRENT_TIMESTAMP not null comment '插入时间', + update_time datetime default CURRENT_TIMESTAMP not null comment '更新时间' +); + +create index idx_batch_id + on user_feedback (batch_id); + +create index idx_user_id + on user_feedback (user_id); \ No newline at end of file diff --git a/sql/message/message.sql b/sql/message/message.sql index 8611a6de..70430dee 100644 --- a/sql/message/message.sql +++ b/sql/message/message.sql @@ -24,17 +24,17 @@ DROP TABLE IF EXISTS `message`; CREATE TABLE `message` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '消息id', `manager_id` bigint NOT NULL COMMENT '发送消息的管理员id', - `tittle` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '消息标题', - `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '消息内容', + `tittle` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '消息标题', + `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '消息内容', `send_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '发送时间', `attachment` bigint NULL DEFAULT NULL COMMENT '附件url', `version` int NOT NULL DEFAULT 0 COMMENT '乐观锁', `is_deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '伪删除标记', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `user_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `user_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, PRIMARY KEY (`id`) USING BTREE, INDEX `idx_manager_id`(`manager_id` ASC) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 4222 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '“活动参与”表' ROW_FORMAT = Dynamic; +) ENGINE = InnoDB AUTO_INCREMENT = 4222 CHARACTER SET = utf8mb4 COLLATE utf8mb4_bin COMMENT = '“活动参与”表' ROW_FORMAT = Dynamic; SET FOREIGN_KEY_CHECKS = 1; diff --git a/sql/short_link.sql b/sql/shortlink/short_link.sql similarity index 100% rename from sql/short_link.sql rename to sql/shortlink/short_link.sql diff --git a/sql/resumestate/resume_status_process.sql b/sql/student/resume_status_process.sql similarity index 100% rename from sql/resumestate/resume_status_process.sql rename to sql/student/resume_status_process.sql diff --git a/sql/stu_attachment.sql b/sql/student/stu_attachment.sql similarity index 100% rename from sql/stu_attachment.sql rename to sql/student/stu_attachment.sql diff --git a/sql/stu_resume.sql b/sql/student/stu_resume.sql similarity index 100% rename from sql/stu_resume.sql rename to sql/student/stu_resume.sql diff --git a/sql/interview/member.sql b/sql/user/member.sql similarity index 100% rename from sql/interview/member.sql rename to sql/user/member.sql diff --git a/sql/user.sql b/sql/user/user.sql similarity index 100% rename from sql/user.sql rename to sql/user/user.sql diff --git a/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java b/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java index 2a43892b..933db5df 100644 --- a/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java +++ b/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java @@ -1,23 +1,26 @@ package com.achobeta.domain.message.handler.ext; +import com.achobeta.config.DateTimeConfig; import com.achobeta.domain.message.handler.MessageSendHandler; import com.achobeta.domain.message.handler.websocket.MessageReceiveServer; import com.achobeta.domain.message.model.dto.MessageSendDTO; import com.achobeta.domain.message.model.entity.AttachmentFile; import com.achobeta.domain.message.model.vo.EmailMessageSendTemplate; -import com.achobeta.domain.resource.service.ResourceService; import com.achobeta.email.model.po.EmailAttachment; import com.achobeta.email.model.po.EmailMessage; import com.achobeta.email.sender.EmailSender; import com.achobeta.template.engine.HtmlEngine; -import jakarta.servlet.http.HttpServletRequest; +import com.achobeta.template.util.TemplateUtil; +import com.achobeta.util.TimeUtil; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; @@ -33,10 +36,8 @@ public class MessageSendWithEmailHandler extends MessageSendHandler { @Value("${spring.mail.username}") private String achobetaEmail; - private final ResourceService resourceService; private final EmailSender emailSender; private final HtmlEngine htmlEngine; - private final HttpServletRequest request; @Override public void handle(MessageSendDTO messageSendBody, CopyOnWriteArraySet webSocketSet) { @@ -51,8 +52,7 @@ public void handle(MessageSendDTO messageSendBody, CopyOnWriteArraySet attachmentInfoList) { + private EmailMessage getNoticeMessage(String email, String tittle, String content, String stuName, List attachmentInfoList) { // 封装 Email EmailMessage emailMessage = new EmailMessage(); emailMessage.setCreateTime(new Date()); @@ -60,66 +60,43 @@ public void sendEmail(String email, String tittle, String content, String stuNam emailMessage.setRecipient(email); emailMessage.setCarbonCopy(); emailMessage.setSender(achobetaEmail); + //构造当前时间 - LocalDateTime nowTime = LocalDateTime.now(); - DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - String now = nowTime.format(timeFormatter); + String now = TimeUtil.getDateTime(new Date()); // 构造模板消息 + String contentTarget = TemplateUtil.getUniqueSymbol(); EmailMessageSendTemplate emailMessageSendTemplate = EmailMessageSendTemplate.builder() .stuName(stuName) .tittle(tittle) - .content(content) + .content(contentTarget) .sendTime(now) .attachmentInfoList(attachmentInfoList) .build(); - - + String html = htmlEngine.builder() .append(MESSAGE_EMAIL_NOTICE.getTemplate(), emailMessageSendTemplate) + .replaceMarkdown(contentTarget, content) .build(); emailMessage.setContent(html); - // 发送模板消息 - emailSender.send(emailMessage); + return emailMessage; } public void sendEmail(String email, String tittle, String content, String stuName, List attachmentInfoList, List multipartFileList) { // 封装 Email - EmailMessage emailMessage = new EmailMessage(); - emailMessage.setCreateTime(new Date()); - emailMessage.setTitle(MESSAGE_EMAIL_NOTICE.getTitle()); - emailMessage.setRecipient(email); - emailMessage.setCarbonCopy(); - emailMessage.setSender(achobetaEmail); - //构造当前时间 - LocalDateTime nowTime = LocalDateTime.now(); - DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - String now = nowTime.format(timeFormatter); - - // 构造模板消息 - EmailMessageSendTemplate emailMessageSendTemplate = EmailMessageSendTemplate.builder() - .stuName(stuName) - .tittle(tittle) - .content(content) - .sendTime(now) - .attachmentInfoList(attachmentInfoList) - .build(); - - - String html = htmlEngine.builder() - .append(MESSAGE_EMAIL_NOTICE.getTemplate(), emailMessageSendTemplate) - .build(); - emailMessage.setContent(html); + EmailMessage emailMessage = getNoticeMessage(email, tittle, content, stuName, attachmentInfoList); List emailAttachmentList = Collections.emptyList(); - if(multipartFileList!=null&&!multipartFileList.isEmpty()){ + if(!CollectionUtils.isEmpty(multipartFileList)){ //构造邮箱附件列表 - emailAttachmentList = multipartFileList.stream().map(file -> { - return EmailAttachment.of(file); - }).toList(); + emailAttachmentList = multipartFileList.stream().map(EmailAttachment::of).toList(); } // 发送模板消息 emailSender.send(emailMessage,true,emailAttachmentList); } + + public void sendEmail(String email, String tittle, String content, String stuName, List attachmentInfoList) { + sendEmail(email, tittle, content, stuName, attachmentInfoList, new ArrayList<>()); + } } diff --git a/src/main/java/com/achobeta/domain/message/model/entity/Message.java b/src/main/java/com/achobeta/domain/message/model/entity/Message.java index d61d06e9..6f651dc8 100644 --- a/src/main/java/com/achobeta/domain/message/model/entity/Message.java +++ b/src/main/java/com/achobeta/domain/message/model/entity/Message.java @@ -45,9 +45,7 @@ public class Message extends BaseIncrIDEntity implements Serializable { /** * 附件url */ - private long attachment; - - + private Long attachment; @TableField(exist = false) private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/achobeta/util/TimeUtil.java b/src/main/java/com/achobeta/util/TimeUtil.java index f71b6143..fd6480a5 100644 --- a/src/main/java/com/achobeta/util/TimeUtil.java +++ b/src/main/java/com/achobeta/util/TimeUtil.java @@ -18,10 +18,6 @@ public static String getDate(Date date) { return DateTimeConfig.DATE_FORMAT.format(date); } - public static String getDate(long date) { - return DateTimeConfig.DATE_FORMAT.format(new Date(date)); - } - public static String getDateTime(Date date) { return DateTimeConfig.DATE_TIME_FORMAT.format(date); } From 97ccce445737748eaf30182711221fdf6bd2e961 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Mon, 30 Sep 2024 22:53:47 +0800 Subject: [PATCH 004/104] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../message/handler/ext/MessageSendWithEmailHandler.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java b/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java index 933db5df..0c6a0ba1 100644 --- a/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java +++ b/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java @@ -1,6 +1,5 @@ package com.achobeta.domain.message.handler.ext; -import com.achobeta.config.DateTimeConfig; import com.achobeta.domain.message.handler.MessageSendHandler; import com.achobeta.domain.message.handler.websocket.MessageReceiveServer; import com.achobeta.domain.message.model.dto.MessageSendDTO; @@ -18,8 +17,6 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Collections; import java.util.Date; From 2a794ef891534d915c1e96b2f85d567d7423170e Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Mon, 30 Sep 2024 23:17:27 +0800 Subject: [PATCH 005/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../achobeta/common/enums/GlobalServiceStatusCode.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/achobeta/common/enums/GlobalServiceStatusCode.java b/src/main/java/com/achobeta/common/enums/GlobalServiceStatusCode.java index efcefa3c..f87b0dbe 100644 --- a/src/main/java/com/achobeta/common/enums/GlobalServiceStatusCode.java +++ b/src/main/java/com/achobeta/common/enums/GlobalServiceStatusCode.java @@ -95,10 +95,6 @@ public enum GlobalServiceStatusCode { INTERVIEW_COMMENT_NOT_EXISTS(6201, "面试评论不存在"), INTERVIEW_NOT_SUMMARIZED(6202, "面试还未总结"), - /*消息错误 7001-8000*/ - MESSAGE_TEMPLATE_NOT_EXIST(7001,"消息模板不存在"), - MESSAGE_NOT_EXIST(7002,"反馈消息不存在"), - MESSAGE_HANDLER_NOT_EXIST(7003,"反馈处理员不存在"), /* 资源错误 7001-8000 */ RESOURCE_LEVEL_NOT_EXISTS(7001, "资源权限不存在"), @@ -117,6 +113,10 @@ public enum GlobalServiceStatusCode { RESOURCE_OUT_SIZE(7014, "资源过大"), RESOURCE_TYPE_NOT_MATCH(7015, "资源类型不匹配"), + /*消息错误 8001-9000*/ + MESSAGE_TEMPLATE_NOT_EXIST(8001,"消息模板不存在"), + MESSAGE_NOT_EXIST(8002,"反馈消息不存在"), + MESSAGE_HANDLER_NOT_EXIST(8003,"反馈处理员不存在"), /* -------------- */; From 28f0028e8ce3fafc0d351316197fd037d15479f5 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 1 Oct 2024 01:02:03 +0800 Subject: [PATCH 006/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/student/stu_attachment.sql | 4 ++-- sql/student/stu_resume.sql | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/student/stu_attachment.sql b/sql/student/stu_attachment.sql index ad900f16..c1f5d071 100644 --- a/sql/student/stu_attachment.sql +++ b/sql/student/stu_attachment.sql @@ -35,8 +35,8 @@ CREATE TABLE `stu_attachment` INDEX `idx_resume_id` (`resume_id` ASC) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 1 - CHARACTER SET = utf8 - COLLATE = utf8_bin COMMENT = '学生附件表' + CHARACTER SET = utf8mb4 + COLLATE = utf8mb4_bin COMMENT = '学生附件表' ROW_FORMAT = Dynamic; SET FOREIGN_KEY_CHECKS = 1; diff --git a/sql/student/stu_resume.sql b/sql/student/stu_resume.sql index 5911235e..15ac05b5 100644 --- a/sql/student/stu_resume.sql +++ b/sql/student/stu_resume.sql @@ -75,8 +75,8 @@ CREATE TABLE `stu_resume` INDEX `idx_name` (`name` ASC) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 1 - CHARACTER SET = utf8 - COLLATE = utf8_bin COMMENT = '学生简历表' + CHARACTER SET = utf8mb4 + COLLATE = utf8mb4_bin COMMENT = '学生简历表' ROW_FORMAT = Dynamic; SET FOREIGN_KEY_CHECKS = 1; From d59464f2400a9b80f2cf8e2ba13adad99438422a Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 1 Oct 2024 01:43:00 +0800 Subject: [PATCH 007/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/feedback/user_feedback.sql | 41 +++++----- sql/message/message.sql | 59 +++++--------- sql/message/message_template.sql | 44 +++------- sql/student/stu_attachment.sql | 55 ++++--------- sql/student/stu_resume.sql | 135 +++++++++++++------------------ sql/user/user.sql | 62 ++++++-------- 6 files changed, 146 insertions(+), 250 deletions(-) diff --git a/sql/feedback/user_feedback.sql b/sql/feedback/user_feedback.sql index 4e27d6f1..7d6eb6ea 100644 --- a/sql/feedback/user_feedback.sql +++ b/sql/feedback/user_feedback.sql @@ -1,22 +1,21 @@ -create table user_feedback +drop table if exists `user_feedback`; +create table `user_feedback` ( - id bigint auto_increment comment '反馈id' primary key, - user_id bigint not null comment '用户id', - batch_id bigint not null comment '招新批次', - message_id bigint default null comment '处理结果的消息id', - title varchar(256) default '' not null comment '反馈标题', - content text not null comment '反馈内容', - attachment bigint default null comment '附件链接', - feedback_time datetime default CURRENT_TIMESTAMP not null comment '反馈时间' - is_handle bit default b'0' not null comment '是否处理标记', - version int default 1 not null comment '乐观锁', - is_deleted bit default b'0' not null comment '伪删除标记', - create_time datetime default CURRENT_TIMESTAMP not null comment '插入时间', - update_time datetime default CURRENT_TIMESTAMP not null comment '更新时间' -); - -create index idx_batch_id - on user_feedback (batch_id); - -create index idx_user_id - on user_feedback (user_id); \ No newline at end of file + `id` bigint primary key auto_increment comment '反馈id' , + `user_id` bigint not null comment '用户id', + `batch_id` bigint not null comment '招新批次', + `message_id` bigint default null comment '处理结果的消息id', + `title` varchar(256) default '' not null comment '反馈标题', + `content` text not null comment '反馈内容', + `attachment` bigint default null comment '附件链接', + `feedback_time` datetime default CURRENT_TIMESTAMP not null comment '反馈时间' + `is_handle` bit default b'0' not null comment '是否处理标记', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_batch_id`(`batch_id` asc) using btree, + index `idx_user_id`(`user_id` asc) using btree +) comment = '用户反馈表'; \ No newline at end of file diff --git a/sql/message/message.sql b/sql/message/message.sql index 70430dee..320f4fe9 100644 --- a/sql/message/message.sql +++ b/sql/message/message.sql @@ -1,40 +1,19 @@ -/* - Navicat Premium Data Transfer - - Source Server : 袁哥 - Source Server Type : MySQL - Source Server Version : 80300 - Source Host : 120.78.157.4:3306 - Source Schema : achobeta_recruitment - - Target Server Type : MySQL - Target Server Version : 80300 - File Encoding : 65001 - - Date: 25/09/2024 17:52:32 -*/ - -SET NAMES utf8mb4; -SET FOREIGN_KEY_CHECKS = 0; - --- ---------------------------- --- Table structure for message --- ---------------------------- -DROP TABLE IF EXISTS `message`; -CREATE TABLE `message` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '消息id', - `manager_id` bigint NOT NULL COMMENT '发送消息的管理员id', - `tittle` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '消息标题', - `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '消息内容', - `send_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '发送时间', - `attachment` bigint NULL DEFAULT NULL COMMENT '附件url', - `version` int NOT NULL DEFAULT 0 COMMENT '乐观锁', - `is_deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '伪删除标记', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `user_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_manager_id`(`manager_id` ASC) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 4222 CHARACTER SET = utf8mb4 COLLATE utf8mb4_bin COMMENT = '“活动参与”表' ROW_FORMAT = Dynamic; - -SET FOREIGN_KEY_CHECKS = 1; +drop table if exists `message`; +create table `message` +( + `id` bigint primary key auto_increment comment '消息 id', + `manager_id` bigint not null comment '发送消息的管理员 id', + `user_id` bigint not null comment '用户 id', + `tittle` varchar(256) not null default '' comment '消息标题', + `content` text not null comment '消息内容', + `send_time` datetime not null default current_timestamp comment '发送时间', + `attachment` bigint null default null comment '附件 url', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_manager_id`(`manager_id` asc) using btree, + index `idx_user_id`(`user_id` asc) using btree +) comment = '消息表'; \ No newline at end of file diff --git a/sql/message/message_template.sql b/sql/message/message_template.sql index 85935f7c..87bef4aa 100644 --- a/sql/message/message_template.sql +++ b/sql/message/message_template.sql @@ -1,32 +1,12 @@ -/* - Navicat Premium Data Transfer - - Source Server Type : MySQL - Source Server Version : 80300 - Source Host : 120.78.157.4:3306 - Source Schema : achobeta_recruitment - - Target Server Type : MySQL - Target Server Version : 80300 - File Encoding : 65001 -*/ - -SET NAMES utf8mb4; -SET FOREIGN_KEY_CHECKS = 0; - --- ---------------------------- --- Table structure for message_template --- ---------------------------- -DROP TABLE IF EXISTS `message_template`; -CREATE TABLE `message_template` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '模板消息 ID', - `template_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '模板消息标题', - `template_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '模板消息内容', - `version` int NOT NULL DEFAULT 0 COMMENT '乐观锁', - `is_deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '伪删除标记', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '模板消息表' ROW_FORMAT = Dynamic; - -SET FOREIGN_KEY_CHECKS = 1; +drop table if exists `message_template`; +create table `message_template` +( + `id` bigint primary key auto_increment comment '模板消息 id', + `template_title` varchar(100) not null default '' comment '模板消息标题', + `template_content` text not null comment '模板消息内容', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间' +) comment = '模板消息表'; \ No newline at end of file diff --git a/sql/student/stu_attachment.sql b/sql/student/stu_attachment.sql index c1f5d071..9433a3c6 100644 --- a/sql/student/stu_attachment.sql +++ b/sql/student/stu_attachment.sql @@ -1,42 +1,15 @@ -/* - Navicat Premium Data Transfer - - Source Server : 本机 - Source Server Type : MySQL - Source Server Version : 80026 - Source Host : localhost:3306 - Source Schema : achobeta_recruitment - - Target Server Type : MySQL - Target Server Version : 80026 - File Encoding : 65001 - - Date: 17/01/2024 13:44:01 -*/ - -SET NAMES utf8mb4; -SET FOREIGN_KEY_CHECKS = 0; - --- ---------------------------- --- Table structure for stu_attachment --- ---------------------------- -DROP TABLE IF EXISTS `stu_attachment`; -CREATE TABLE `stu_attachment` +drop table if exists `stu_attachment`; +create table `stu_attachment` ( - `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID', - `resume_id` bigint UNSIGNED NOT NULL COMMENT '学生表主键id', - `filename` varchar(256) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '附件名', - `attachment` bigint NOT NULL COMMENT '附件资源码', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间', - `version` int NOT NULL DEFAULT 0 COMMENT '乐观锁', - `is_deleted` tinyint NOT NULL DEFAULT 0 COMMENT '伪删除标记', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_resume_id` (`resume_id` ASC) USING BTREE -) ENGINE = InnoDB - AUTO_INCREMENT = 1 - CHARACTER SET = utf8mb4 - COLLATE = utf8mb4_bin COMMENT = '学生附件表' - ROW_FORMAT = Dynamic; - -SET FOREIGN_KEY_CHECKS = 1; + `id` bigint primary key auto_increment comment 'id', + `resume_id` bigint not null comment '学生表主键 id', + `filename` varchar(256) not null default '' comment '附件名', + `attachment` bigint not null comment '附件资源码', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_resume_id`(`resume_id` asc) using btree +) comment = '学生附件表'; \ No newline at end of file diff --git a/sql/student/stu_resume.sql b/sql/student/stu_resume.sql index 15ac05b5..2fd0e7a5 100644 --- a/sql/student/stu_resume.sql +++ b/sql/student/stu_resume.sql @@ -1,82 +1,63 @@ -/* - Navicat Premium Data Transfer - - Source Server : 本机 - Source Server Type : MySQL - Source Server Version : 80026 - Source Host : localhost:3306 - Source Schema : achobeta_recruitment - - Target Server Type : MySQL - Target Server Version : 80026 - File Encoding : 65001 - - Date: 17/01/2024 13:44:06 -*/ - -SET NAMES utf8mb4; -SET FOREIGN_KEY_CHECKS = 0; - --- ---------------------------- -- Table structure for student -- 简历状态comment说明 -- 范围:0~16,简历状态{ -# - 0-草稿 -# - 1-待筛选 -# - 2-筛选不通过 -# - 3-待安排初试 -# - 4-待初试 -# - 5-初试通过(仅当初试为最后一个流程时显示) -# - 6-初试不通过(仅当初试为最后一个流程时显示) -# - 7-待安排复试 -# - 8-待复试 -# - 9-复试通过(仅当复试为最后一个流程时显示) -# - 10-复试不通过(仅当复试为最后一个流程时显示) -# - 11-待安排终试 -# - 12-待终试 -# - 13-终试通过(仅当复试为最后一个流程时显示) -# - 14-终试不通过(仅当复试为最后一个流程时显示) -# - 15-待处理(反馈异常/或管理员主动设置为该状态) -# - 16-挂起(管理员可以主动设置该状态)} +-- 0-草稿 +-- 1-待筛选 +-- 2-筛选不通过 +-- +-- 3-待安排初试 +-- 4-待初试 +-- 5-初试通过(仅当初试为最后一个流程时显示) +-- 6-初试不通过(仅当初试为最后一个流程时显示) +-- +-- 7-待安排复试 +-- 8-待复试 +-- 9-复试通过(仅当复试为最后一个流程时显示) +-- 10-复试不通过(仅当复试为最后一个流程时显示) +-- +-- 11-待安排终试 +-- 12-待终试 +-- 13-终试通过(仅当复试为最后一个流程时显示) +-- 14-终试不通过(仅当复试为最后一个流程时显示) +-- +-- 15-待处理(反馈异常/或管理员主动设置为该状态) +-- 16-挂起(管理员可以主动设置该状态) +-- } -- ---------------------------- -DROP TABLE IF EXISTS `stu_resume`; -CREATE TABLE `stu_resume` +-- 创建学生简历表 +drop table if exists `stu_resume`; +create table `stu_resume` ( - `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID', - `user_id` bigint NOT NULL COMMENT '用户 id', - `batch_id` bigint NOT NULL COMMENT '招新批次 id', - `student_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '学号', - `name` varchar(10) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '姓名', - `gender` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '性别', - `grade` int NOT NULL COMMENT '年级', - `major` varchar(20) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '专业', - `class` varchar(30) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '班级', - `email` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '邮箱', - `phone_number` varchar(11) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '手机号码', - `reason` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '加入 AchoBeta 的理由', - `introduce` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '个人介绍(自我认知)', - `experience` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '个人经历 (项目经历、 职业规划等)', - `awards` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '获奖经历', - `image` bigint NOT NULL COMMENT '照片', - `remark` varchar(500) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '备注', - `status` int NOT NULL DEFAULT 1 COMMENT '简历状态', - `submit_count` int NOT NULL DEFAULT 0 COMMENT '提交次数', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间', - `version` int NOT NULL DEFAULT 0 COMMENT '乐观锁', - `is_deleted` tinyint NOT NULL DEFAULT 0 COMMENT '伪删除标记', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_student_id` (`student_id` ASC) USING BTREE, - INDEX `idx_email` (`email` ASC) USING BTREE, - INDEX `idx_user_id` (`user_id` ASC) USING BTREE, - INDEX `idx_batch_id` (`batch_id` ASC) USING BTREE, - INDEX `idx_class` (`class` ASC) USING BTREE, - INDEX `idx_major` (`major` ASC) USING BTREE, - INDEX `idx_name` (`name` ASC) USING BTREE -) ENGINE = InnoDB - AUTO_INCREMENT = 1 - CHARACTER SET = utf8mb4 - COLLATE = utf8mb4_bin COMMENT = '学生简历表' - ROW_FORMAT = Dynamic; - -SET FOREIGN_KEY_CHECKS = 1; + `id` bigint primary key auto_increment comment 'id', + `user_id` bigint not null comment '用户 id', + `batch_id` bigint not null comment '招新批次 id', + `student_id` varchar(13) not null default '' comment '学号', + `name` varchar(10) not null default '' comment '姓名', + `gender` tinyint not null default 0 comment '性别', + `grade` int not null comment '年级', + `major` varchar(20) not null default '' comment '专业', + `class` varchar(30) not null default '' comment '班级', + `email` varchar(50) not null default '' comment '邮箱', + `phone_number` varchar(11) not null default '' comment '手机号码', + `reason` text not null comment '加入 achobeta 的理由', + `introduce` text not null comment '个人介绍(自我认知)', + `experience` text not null comment '个人经历(项目经历、职业规划等)', + `awards` text not null comment '获奖经历', + `image` bigint not null comment '照片', + `remark` varchar(500) not null default '' comment '备注', + `status` int not null default 1 comment '简历状态,范围:0~16', + `submit_count` int not null default 0 comment '提交次数', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_student_id` (`student_id` asc) using btree, + index `idx_email` (`email` asc) using btree, + index `idx_user_id` (`user_id` asc) using btree, + index `idx_batch_id` (`batch_id` asc) using btree, + index `idx_class` (`class` asc) using btree, + index `idx_major` (`major` asc) using btree, + index `idx_name` (`name` asc) using btree +) comment = '学生简历表'; \ No newline at end of file diff --git a/sql/user/user.sql b/sql/user/user.sql index 9e642ff7..266df56d 100644 --- a/sql/user/user.sql +++ b/sql/user/user.sql @@ -1,40 +1,24 @@ -SET NAMES utf8mb4; -SET FOREIGN_KEY_CHECKS = 0; +drop table if exists `user`; +create table `user`( + `id` bigint primary key auto_increment comment '用户唯一 id', + `username` varchar(50) not null default '' comment '用户名', + `nickname` varchar(50) not null default '' comment '用户昵称', + `email` varchar(50) not null default '' comment '邮箱', + `phone_number` varchar(11) not null default '' comment '手机号码', + `password` varchar(100) not null default '' comment '密码', + `user_type` int not null default 1 comment '用户类型:1.普通用户 2. 管理员', + `avatar` bigint comment '头像地址', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_email`(`email` asc) using btree, + index `idx_phone`(`phone_number` asc) using btree, + unique index `uni_name`(`username` asc) using btree +) auto_increment = 10000 comment = '用户基本信息表'; --- ---------------------------- --- Table structure for user --- ---------------------------- -DROP TABLE IF EXISTS `user`; -CREATE TABLE `user` -( - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '用户唯一ID', - `username` varchar(50) NOT NULL DEFAULT '' COMMENT '用户名', - `nickname` varchar(50) NOT NULL DEFAULT '' COMMENT '用户昵称', - `email` varchar(50) NOT NULL DEFAULT '' COMMENT '邮箱', - `phone_number` varchar(11) NOT NULL DEFAULT '' COMMENT '手机号码', - `password` varchar(100) NOT NULL DEFAULT '' COMMENT '密码', - `user_type` int NOT NULL DEFAULT 1 COMMENT '用户类型:1.普通用户 2. 管理员', - `avatar` bigint(20) COMMENT '头像地址', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间', - `version` int NOT NULL DEFAULT 0 COMMENT '乐观锁', - `is_deleted` tinyint NOT NULL DEFAULT 0 COMMENT '伪删除标记', - PRIMARY KEY (`id`), - INDEX `idx_email` (`email`), - INDEX `idx_phone` (`phone_number`), - UNIQUE INDEX `uni_name` (`username`) -) ENGINE = InnoDB - AUTO_INCREMENT = 10000 - CHARACTER SET = utf8 - COLLATE = utf8_bin COMMENT = '用户基本信息表' - ROW_FORMAT = DYNAMIC; - -SET FOREIGN_KEY_CHECKS = 1; - --- 管理员,username: root; password: AchoBeta666 - -insert into user -(`username`, `nickname`, `password`, `user_type`) -values - ('root', 'root', '$2a$10$YPKp0kzLjnNrW5CgKuDdiuF4tZO0KXacmhy2KT7N9Zey49Cmi/rfu', 2) -; \ No newline at end of file +-- root 管理员,username: root; password: AchoBeta666 +insert into user(`username`, `nickname`, `password`, `user_type`) + values('root', 'root', '$2a$10$YPKp0kzLjnNrW5CgKuDdiuF4tZO0KXacmhy2KT7N9Zey49Cmi/rfu', 2); From a35e9d2890036700846c8a77bf5510b0e1e3663e Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 1 Oct 2024 01:50:18 +0800 Subject: [PATCH 008/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/feedback/user_feedback.sql | 11 ++++++----- sql/student/stu_resume.sql | 3 +-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sql/feedback/user_feedback.sql b/sql/feedback/user_feedback.sql index 7d6eb6ea..7edaa42a 100644 --- a/sql/feedback/user_feedback.sql +++ b/sql/feedback/user_feedback.sql @@ -1,14 +1,14 @@ drop table if exists `user_feedback`; create table `user_feedback` ( - `id` bigint primary key auto_increment comment '反馈id' , + `id` bigint primary key auto_increment comment '反馈 id' , `user_id` bigint not null comment '用户id', - `batch_id` bigint not null comment '招新批次', - `message_id` bigint default null comment '处理结果的消息id', + `batch_id` bigint not null comment '招新批次 id', + `message_id` bigint default null comment '处理结果的消息 id', `title` varchar(256) default '' not null comment '反馈标题', `content` text not null comment '反馈内容', `attachment` bigint default null comment '附件链接', - `feedback_time` datetime default CURRENT_TIMESTAMP not null comment '反馈时间' + `feedback_time` datetime default CURRENT_TIMESTAMP not null comment '反馈时间', `is_handle` bit default b'0' not null comment '是否处理标记', -- common column `version` int not null default 0 comment '乐观锁', @@ -16,6 +16,7 @@ create table `user_feedback` `create_time` datetime not null default current_timestamp comment '创建时间', `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', -- index + index `idx_user_id`(`user_id` asc) using btree, index `idx_batch_id`(`batch_id` asc) using btree, - index `idx_user_id`(`user_id` asc) using btree + index `idx_message_id`(`message_id` asc) using btree ) comment = '用户反馈表'; \ No newline at end of file diff --git a/sql/student/stu_resume.sql b/sql/student/stu_resume.sql index 2fd0e7a5..85d1dcaf 100644 --- a/sql/student/stu_resume.sql +++ b/sql/student/stu_resume.sql @@ -1,5 +1,4 @@ --- Table structure for student --- 简历状态comment说明 +-- 简历状态 comment 说明 -- 范围:0~16,简历状态{ -- 0-草稿 -- 1-待筛选 From d8d05f4469d524efead58a9ffc7ed149a4eb9ded Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Mon, 7 Oct 2024 15:46:06 +0800 Subject: [PATCH 009/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../achobeta/feishu/aspect/FeishuRequestAspect.java | 7 ++----- .../achobeta/feishu/constants/FeishuConstants.java | 2 -- .../feishu/token/FeishuTenantAccessToken.java | 13 ++++--------- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/achobeta/feishu/aspect/FeishuRequestAspect.java b/src/main/java/com/achobeta/feishu/aspect/FeishuRequestAspect.java index 1c9550a6..53c47837 100644 --- a/src/main/java/com/achobeta/feishu/aspect/FeishuRequestAspect.java +++ b/src/main/java/com/achobeta/feishu/aspect/FeishuRequestAspect.java @@ -11,7 +11,6 @@ import org.aspectj.lang.annotation.Pointcut; import org.springframework.stereotype.Component; -import static com.achobeta.feishu.constants.FeishuConstants.SHOULD_REFRESH_CODE; import static com.achobeta.feishu.constants.FeishuConstants.SUCCESS_CODE; /** @@ -43,10 +42,8 @@ public void doAfterReturning(Object result) { if(code == SUCCESS_CODE) { log.info("飞书请求成功"); } else { - if(code == SHOULD_REFRESH_CODE) { - log.info("飞书 token 刷新"); - feishuTenantAccessToken.refreshToken(); - } + log.info("飞书 token 刷新"); + feishuTenantAccessToken.refreshToken(); throw new GlobalServiceException(response.getMsg(), GlobalServiceStatusCode.REQUEST_NOT_VALID); } }else { diff --git a/src/main/java/com/achobeta/feishu/constants/FeishuConstants.java b/src/main/java/com/achobeta/feishu/constants/FeishuConstants.java index 3229a67b..003954b9 100644 --- a/src/main/java/com/achobeta/feishu/constants/FeishuConstants.java +++ b/src/main/java/com/achobeta/feishu/constants/FeishuConstants.java @@ -36,8 +36,6 @@ public interface FeishuConstants { int SUCCESS_CODE = 0; - int SHOULD_REFRESH_CODE = 4001; - static String getAuthorization(String accessToken) { return Optional.ofNullable(accessToken) .map(token -> AUTHORIZATION_PREFIX + token) diff --git a/src/main/java/com/achobeta/feishu/token/FeishuTenantAccessToken.java b/src/main/java/com/achobeta/feishu/token/FeishuTenantAccessToken.java index e2252d11..f4db5353 100644 --- a/src/main/java/com/achobeta/feishu/token/FeishuTenantAccessToken.java +++ b/src/main/java/com/achobeta/feishu/token/FeishuTenantAccessToken.java @@ -30,18 +30,13 @@ public class FeishuTenantAccessToken { private volatile String tenantAccessToken; - private volatile Integer expire; - - - private long compareToNow(int tokenExpire) { - return TimeUtil.millisToSecond(tokenExpire) - System.currentTimeMillis(); - } + private volatile Long expire; private boolean shouldRefresh() { return !StringUtils.hasText(tenantAccessToken) || Optional.ofNullable(expire) // 这里判断的一般是准确的,如果非本类请求到的 token,可能会出现到期前三十分钟获取另一个 token,那也不影响这个 token 的有效性 - .filter(tokenExpire -> compareToNow(tokenExpire) > 0) - .isPresent(); + .filter(tokenExpire -> tokenExpire - System.currentTimeMillis() > 0) + .isEmpty(); } public void refreshToken() { @@ -68,7 +63,7 @@ public void refreshToken() { null ); this.tenantAccessToken = responseBody.getTenantAccessToken(); - this.expire = responseBody.getExpire(); + this.expire = TimeUtil.secondToMillis(responseBody.getExpire()) + System.currentTimeMillis(); } public String getToken() { From abccdee26164d4446ee612b32872d0400b9b98da Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 8 Oct 2024 22:01:22 +0800 Subject: [PATCH 010/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/recruit/service/impl/TimePeriodServiceImpl.java | 6 +++++- .../schedule/controller/InterviewScheduleController.java | 3 --- .../schedule/service/impl/InterviewScheduleServiceImpl.java | 2 +- .../mapper/recruit/ext/ActivityParticipationExtMapper.xml | 2 ++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/achobeta/domain/recruit/service/impl/TimePeriodServiceImpl.java b/src/main/java/com/achobeta/domain/recruit/service/impl/TimePeriodServiceImpl.java index 73903637..4b569a14 100644 --- a/src/main/java/com/achobeta/domain/recruit/service/impl/TimePeriodServiceImpl.java +++ b/src/main/java/com/achobeta/domain/recruit/service/impl/TimePeriodServiceImpl.java @@ -48,7 +48,11 @@ private void timePeriodValidate(Long startTime, Long endTime) { @Override public List getTimePeriodsByActId(Long actId) { - List timePeriods = this.lambdaQuery().eq(TimePeriod::getActId, actId).list(); + List timePeriods = this.lambdaQuery() + .eq(TimePeriod::getActId, actId) + .orderBy(Boolean.TRUE, Boolean.TRUE, TimePeriod::getStartTime) + .orderBy(Boolean.TRUE, Boolean.TRUE, TimePeriod::getEndTime) + .list(); return TimePeriodConverter.INSTANCE.timePeriodListToTimePeriodVOList(timePeriods); } diff --git a/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java b/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java index 16b906ab..63d55371 100644 --- a/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java +++ b/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java @@ -9,7 +9,6 @@ import com.achobeta.domain.resource.constants.ResourceConstants; import com.achobeta.domain.resource.enums.ResourceAccessLevel; import com.achobeta.domain.resource.model.vo.OnlineResourceVO; -import com.achobeta.domain.resource.service.ResourceService; import com.achobeta.domain.schedule.model.dto.ScheduleDTO; import com.achobeta.domain.schedule.model.dto.ScheduleUpdateDTO; import com.achobeta.domain.schedule.model.vo.ParticipationDetailVO; @@ -52,8 +51,6 @@ public class InterviewScheduleController { private final RecruitmentActivityService recruitmentActivityService; - private final ResourceService resourceService; - @PostMapping("/create") public SystemJsonResponse createInterviewSchedule(@Valid @RequestBody ScheduleDTO scheduleDTO) { // 校验 diff --git a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java index 1f5d36c3..43b64696 100644 --- a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java +++ b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java @@ -129,6 +129,7 @@ public UserSituationVO getSituationsByActId(Long actId) { List userParticipationVOS = userParticipationVOMap.values() .stream() .sorted(Comparator.comparingInt(up -> up.getTimePeriodVOS().size())) // 根据选择时间段排序 + .sorted(Comparator.comparingLong(up -> CollectionUtils.isEmpty(up.getTimePeriodVOS()) ? 0L : up.getTimePeriodVOS().getFirst().getStartTime().getTime())) .sorted(Comparator.comparingInt(up -> up.getScheduleVOS().size())) // 没被安排的会被排在前面 .toList(); List timePeriodCountVOS = countMap.values() @@ -141,7 +142,6 @@ public UserSituationVO getSituationsByActId(Long actId) { return userSituationVO; } - @Override public ScheduleDetailVO getInterviewScheduleDetail(Long scheduleId) { ScheduleDetailVO scheduleDetail = interviewScheduleMapper.getInterviewerScheduleDetail(scheduleId); diff --git a/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml b/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml index dc48f363..8323ec75 100644 --- a/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml +++ b/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml @@ -45,6 +45,7 @@ left join participation_period_link pp on ap.id = pp.participation_id and ap.is_deleted = 0 and pp.is_deleted = 0 left join time_period t on pp.period_id = t.id and pp.is_deleted = 0 and t.is_deleted = 0 where ap.id = #{participationId,jdbcType=BIGINT} and t.id is not null and ap.is_deleted = 0 + order by t.start_time asc, t.end_time asc select - p.id, s.id s_id, s.start_time s_start_time, s.end_time s_end_time, + p.id, s.id s_id, s.participation_id s_participation_id, s.start_time s_start_time, s.end_time s_end_time, from activity_participation p left join user stu on p.stu_id = stu.id and p.is_deleted = 0 and stu.is_deleted = 0 From 59eb867996f18dd647d3aa2f13e2516c4fc5d40d Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sat, 12 Oct 2024 18:33:07 +0800 Subject: [PATCH 026/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InterviewScheduleController.java | 15 +++++--- .../dao/mapper/InterviewScheduleMapper.java | 3 +- .../service/InterviewScheduleService.java | 3 +- .../impl/InterviewScheduleServiceImpl.java | 5 +-- .../achobeta/interceptor/UserInterceptor.java | 36 ++++++++++--------- .../jwt/propertities/JwtProperties.java | 1 + .../java/com/achobeta/jwt/util/JwtUtil.java | 5 ++- .../ext/InterviewScheduleExtMapper.xml | 15 ++++++-- 8 files changed, 53 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java b/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java index 63d55371..43406640 100644 --- a/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java +++ b/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java @@ -3,6 +3,7 @@ import com.achobeta.common.SystemJsonResponse; import com.achobeta.common.annotation.Intercept; import com.achobeta.common.enums.UserTypeEnum; +import com.achobeta.domain.interview.model.dto.InterviewConditionDTO; import com.achobeta.domain.recruit.model.entity.RecruitmentActivity; import com.achobeta.domain.recruit.service.ActivityParticipationService; import com.achobeta.domain.recruit.service.RecruitmentActivityService; @@ -107,13 +108,19 @@ public SystemJsonResponse exitInterview(@PathVariable("scheduleId") @NotNull Lon return SystemJsonResponse.SYSTEM_SUCCESS(); } - @GetMapping("/list/{actId}") - public SystemJsonResponse getInterviewScheduleList(@PathVariable("actId") @NotNull Long actId) { + @PostMapping("/list/own") + public SystemJsonResponse getInterviewScheduleList(@Valid @RequestBody(required = false) InterviewConditionDTO interviewConditionDTO) { // 检测 Long managerId = BaseContext.getCurrentUser().getUserId(); - recruitmentActivityService.checkRecruitmentActivityExists(actId); // 查询 - List interviewScheduleList = interviewScheduleService.getInterviewScheduleList(managerId, actId); + List interviewScheduleList = interviewScheduleService.getInterviewScheduleList(managerId, InterviewConditionDTO.of(interviewConditionDTO)); + return SystemJsonResponse.SYSTEM_SUCCESS(interviewScheduleList); + } + + @PostMapping("/list/all") + public SystemJsonResponse getInterviewScheduleListAll(@Valid @RequestBody(required = false) InterviewConditionDTO interviewConditionDTO) { + // 查询 + List interviewScheduleList = interviewScheduleService.getInterviewScheduleList(null, InterviewConditionDTO.of(interviewConditionDTO)); return SystemJsonResponse.SYSTEM_SUCCESS(interviewScheduleList); } diff --git a/src/main/java/com/achobeta/domain/schedule/model/dao/mapper/InterviewScheduleMapper.java b/src/main/java/com/achobeta/domain/schedule/model/dao/mapper/InterviewScheduleMapper.java index 7a0a9d7d..e7b914b7 100644 --- a/src/main/java/com/achobeta/domain/schedule/model/dao/mapper/InterviewScheduleMapper.java +++ b/src/main/java/com/achobeta/domain/schedule/model/dao/mapper/InterviewScheduleMapper.java @@ -1,5 +1,6 @@ package com.achobeta.domain.schedule.model.dao.mapper; +import com.achobeta.domain.interview.model.dto.InterviewConditionDTO; import com.achobeta.domain.schedule.model.entity.InterviewSchedule; import com.achobeta.domain.schedule.model.vo.ParticipationScheduleVO; import com.achobeta.domain.schedule.model.vo.ScheduleDetailVO; @@ -17,7 +18,7 @@ */ public interface InterviewScheduleMapper extends BaseMapper { - List getInterviewScheduleList(@Param("managerId") Long managerId, @Param("actId") Long actId); + List getInterviewScheduleList(@Param("managerId") Long managerId, @Param("condition") InterviewConditionDTO interviewConditionDTO); List getSituationsByActId(@Param("actId") Long actId); diff --git a/src/main/java/com/achobeta/domain/schedule/service/InterviewScheduleService.java b/src/main/java/com/achobeta/domain/schedule/service/InterviewScheduleService.java index 6b236ec7..fd96ad27 100644 --- a/src/main/java/com/achobeta/domain/schedule/service/InterviewScheduleService.java +++ b/src/main/java/com/achobeta/domain/schedule/service/InterviewScheduleService.java @@ -1,5 +1,6 @@ package com.achobeta.domain.schedule.service; +import com.achobeta.domain.interview.model.dto.InterviewConditionDTO; import com.achobeta.domain.recruit.model.entity.RecruitmentActivity; import com.achobeta.domain.resource.enums.ResourceAccessLevel; import com.achobeta.domain.resource.model.vo.OnlineResourceVO; @@ -24,7 +25,7 @@ public interface InterviewScheduleService extends IService { Optional getInterviewSchedule(Long scheduleId); - List getInterviewScheduleList(Long managerId, Long actId); + List getInterviewScheduleList(Long managerId, InterviewConditionDTO interviewConditionDTO); /** * @param actId 活动 id diff --git a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java index b9192ef4..60de1f5f 100644 --- a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java +++ b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java @@ -1,6 +1,7 @@ package com.achobeta.domain.schedule.service.impl; import com.achobeta.common.enums.GlobalServiceStatusCode; +import com.achobeta.domain.interview.model.dto.InterviewConditionDTO; import com.achobeta.domain.interview.model.vo.InterviewVO; import com.achobeta.domain.interview.service.InterviewService; import com.achobeta.domain.recruit.model.converter.TimePeriodConverter; @@ -80,8 +81,8 @@ public Optional getInterviewSchedule(Long scheduleId) { } @Override - public List getInterviewScheduleList(Long managerId, Long actId) { - return interviewScheduleMapper.getInterviewScheduleList(managerId, actId); + public List getInterviewScheduleList(Long managerId, InterviewConditionDTO interviewConditionDTO) { + return interviewScheduleMapper.getInterviewScheduleList(managerId, interviewConditionDTO); } /** diff --git a/src/main/java/com/achobeta/interceptor/UserInterceptor.java b/src/main/java/com/achobeta/interceptor/UserInterceptor.java index 8cb38afb..304505a3 100644 --- a/src/main/java/com/achobeta/interceptor/UserInterceptor.java +++ b/src/main/java/com/achobeta/interceptor/UserInterceptor.java @@ -75,23 +75,24 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons if (!(handler instanceof HandlerMethod)) { // 并不处理非目标方法的请求 // todo: 例如通过本服务,但不是通过目标方法获取资源的请求,而这些请求需要进行其他的处理! - return true; + return Boolean.TRUE; } // 设置请求 id - response.setHeader(requestIdConfig.getHeader(), String.valueOf(requestIdGenerator.nextId())); + long requestId = requestIdGenerator.nextId(); + response.setHeader(requestIdConfig.getHeader(), String.valueOf(requestId)); // 获取目标方法 Method targetMethod = ((HandlerMethod) handler).getMethod(); // 获取 intercept 注解实例 Intercept intercept = InterceptHelper.getIntercept(targetMethod); // 判断是否忽略 if(InterceptHelper.isIgnore(intercept)) { - return true; + return Boolean.TRUE; } String token = request.getHeader(jwtProperties.getTokenName()); //从请求头中获取token if (StrUtil.isEmpty(token)) { - throw new GlobalServiceException("用户未登录,token为空", GlobalServiceStatusCode.USER_NOT_LOGIN); + throw new GlobalServiceException("用户未登录,token 为空", GlobalServiceStatusCode.USER_NOT_LOGIN); } //通过明文钥匙生成密钥 SecretKey secretKey = JwtUtil.generalKey(jwtProperties.getSecretKey()); @@ -99,37 +100,38 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons Claims claims = JwtUtil.parseJWT(secretKey, token); // permit 中没有 role 就会抛异常 - UserTypeEnum role = UserTypeEnum.get(Integer.parseInt(claims.get(UserInterceptor.USER_ROLE_NAME).toString())); - if(!InterceptHelper.isValid(intercept, role)) { + Long userId = Long.valueOf(claims.get(UserInterceptor.USER_ID).toString()); + log.info("请求 {} 账户 {} 访问接口 {} ", requestId, userId, request.getRequestURI()); + + Integer role = Integer.parseInt(claims.get(UserInterceptor.USER_ROLE_NAME).toString()); + UserTypeEnum userTypeEnum = UserTypeEnum.get(role); + if(!InterceptHelper.isValid(intercept, userTypeEnum)) { throw new GlobalServiceException(GlobalServiceStatusCode.USER_NO_PERMISSION); } //通过线程局部变量设置当前线程用户信息 - setGlobalUserInfoByClaims(claims, token); + setGlobalUserInfoByClaims(userId, role, token); //判断token是否即将过期 - if (JwtUtil.judgeApproachExpiration(token, secretKey)) { + if (JwtUtil.judgeApproachExpiration(token, secretKey, jwtProperties.getRefreshTime())) { refreshToken(response, secretKey, claims); } - return true; + return Boolean.TRUE; } private void refreshToken(HttpServletResponse response, SecretKey secretKey, Claims claims) { - long ttl = jwtProperties.getTtl(); - String refreshToken = JwtUtil.createJWT(secretKey, ttl, claims); + String refreshToken = JwtUtil.createJWT(secretKey, jwtProperties.getTtl(), claims); //刷新token,通过请求头返回前端 response.setHeader(jwtProperties.getTokenName(), refreshToken); - log.info("无感刷新token:{}", refreshToken); + log.info("无感刷新 token: {}", refreshToken); } - private void setGlobalUserInfoByClaims(Claims claims, String token) { - Long userId = Long.valueOf(claims.get(UserInterceptor.USER_ID).toString()); - Integer role = Integer.parseInt(claims.get(UserInterceptor.USER_ROLE_NAME).toString()); + private void setGlobalUserInfoByClaims(Long userId, Integer role, String token) { UserHelper userHelper = UserHelper.builder() .userId(userId) .token(token) .role(role) .build(); - log.info("登录信息->{}",userHelper); + log.info("登录信息 -> {}",userHelper); BaseContext.setCurrentUser(userHelper); } @@ -143,7 +145,7 @@ public void afterCompletion(HttpServletRequest request, HttpServletResponse resp Method targetMethod = handlerMethod.getMethod(); if(InterceptHelper.shouldPrintLog(targetMethod)) { String requestId = response.getHeader(requestIdConfig.getHeader()); - log.warn("请求 {} 访问 {},响应 HTTP 状态码 {},错误信息 {}", + log.warn("请求 {} 访问接口 {},响应 HTTP 状态码 {},错误信息 {}", requestId, request.getRequestURI(), response.getStatus(), Optional.ofNullable(ex).map(Exception::getMessage).orElse(null) ); diff --git a/src/main/java/com/achobeta/jwt/propertities/JwtProperties.java b/src/main/java/com/achobeta/jwt/propertities/JwtProperties.java index 86db5a9f..5359177b 100644 --- a/src/main/java/com/achobeta/jwt/propertities/JwtProperties.java +++ b/src/main/java/com/achobeta/jwt/propertities/JwtProperties.java @@ -16,6 +16,7 @@ public class JwtProperties { */ private String secretKey; private Long ttl; + private Long refreshTime; private String tokenName; } \ No newline at end of file diff --git a/src/main/java/com/achobeta/jwt/util/JwtUtil.java b/src/main/java/com/achobeta/jwt/util/JwtUtil.java index 1a424b29..aee0f45b 100644 --- a/src/main/java/com/achobeta/jwt/util/JwtUtil.java +++ b/src/main/java/com/achobeta/jwt/util/JwtUtil.java @@ -90,10 +90,9 @@ public static SecretKey generalKey(@NotNull String secretKey) { return key; } - // - public static boolean judgeApproachExpiration(@NotNull String token, @NotNull SecretKey secretKey) { + public static boolean judgeApproachExpiration(String token, SecretKey secretKey, long refreshTime) { long cur = System.currentTimeMillis(); long exp = getTokenExpiration(secretKey, token).getTime(); - return (exp - cur) < REFRESH_TIME; + return (exp - cur) < refreshTime; } } diff --git a/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml b/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml index 446c5c17..77ae012e 100644 --- a/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml +++ b/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml @@ -36,7 +36,7 @@ From 412729655376d5a8e3c59075485b5280e8fced71 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sat, 12 Oct 2024 18:36:17 +0800 Subject: [PATCH 027/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/achobeta/interceptor/UserInterceptor.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/achobeta/interceptor/UserInterceptor.java b/src/main/java/com/achobeta/interceptor/UserInterceptor.java index 304505a3..d0e34147 100644 --- a/src/main/java/com/achobeta/interceptor/UserInterceptor.java +++ b/src/main/java/com/achobeta/interceptor/UserInterceptor.java @@ -99,13 +99,13 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons Claims claims = JwtUtil.parseJWT(secretKey, token); - // permit 中没有 role 就会抛异常 + // 记录接口的访问记录 Long userId = Long.valueOf(claims.get(UserInterceptor.USER_ID).toString()); log.info("请求 {} 账户 {} 访问接口 {} ", requestId, userId, request.getRequestURI()); + // permit 中没有 role 就会抛异常 Integer role = Integer.parseInt(claims.get(UserInterceptor.USER_ROLE_NAME).toString()); - UserTypeEnum userTypeEnum = UserTypeEnum.get(role); - if(!InterceptHelper.isValid(intercept, userTypeEnum)) { + if(!InterceptHelper.isValid(intercept, UserTypeEnum.get(role))) { throw new GlobalServiceException(GlobalServiceStatusCode.USER_NO_PERMISSION); } From 7f1a1770b177a74517e4458e5970b8f9ffb72b52 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sat, 12 Oct 2024 18:59:13 +0800 Subject: [PATCH 028/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schedule/service/impl/InterviewScheduleServiceImpl.java | 1 - .../mapper/schedule/ext/InterviewScheduleExtMapper.xml | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java index 60de1f5f..23f395a7 100644 --- a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java +++ b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java @@ -130,7 +130,6 @@ public UserSituationVO getSituationsByActId(Long actId) { List userParticipationVOS = userParticipationVOMap.values() .stream() .filter(up -> !CollectionUtils.isEmpty(up.getTimePeriodVOS()) || !CollectionUtils.isEmpty(up.getScheduleVOS())) // 过滤出有选时间段的或有预约的 - .sorted(Comparator.comparingLong(up -> CollectionUtils.isEmpty(up.getTimePeriodVOS()) ? 0L : up.getTimePeriodVOS().getFirst().getStartTime().getTime())) .sorted(Comparator.comparingInt(up -> up.getTimePeriodVOS().size())) // 根据选择时间段排序 .sorted(Comparator.comparingInt(up -> up.getScheduleVOS().size())) // 没被安排的会被排在前面 .toList(); diff --git a/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml b/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml index 77ae012e..f23092fe 100644 --- a/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml +++ b/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml @@ -36,6 +36,7 @@ From f52cd572b3ffe90b3f345b6fd7e07b3f78a66b7d Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sat, 12 Oct 2024 19:03:50 +0800 Subject: [PATCH 029/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schedule/service/impl/InterviewScheduleServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java index 23f395a7..4d591f2b 100644 --- a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java +++ b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java @@ -130,11 +130,13 @@ public UserSituationVO getSituationsByActId(Long actId) { List userParticipationVOS = userParticipationVOMap.values() .stream() .filter(up -> !CollectionUtils.isEmpty(up.getTimePeriodVOS()) || !CollectionUtils.isEmpty(up.getScheduleVOS())) // 过滤出有选时间段的或有预约的 + .sorted(Comparator.comparingLong(up -> CollectionUtils.isEmpty(up.getTimePeriodVOS()) ? 0L : up.getTimePeriodVOS().getFirst().getStartTime().getTime())) .sorted(Comparator.comparingInt(up -> up.getTimePeriodVOS().size())) // 根据选择时间段排序 .sorted(Comparator.comparingInt(up -> up.getScheduleVOS().size())) // 没被安排的会被排在前面 .toList(); List timePeriodCountVOS = countMap.values() .stream() + .sorted(Comparator.comparingLong(tc -> tc.getStartTime().getTime())) .sorted((x1, x2) -> x2.getCount().compareTo(x1.getCount())) .toList(); UserSituationVO userSituationVO = new UserSituationVO(); From cbe677510a4690f98d7609a90a182ea2aba50b2a Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sat, 12 Oct 2024 22:48:22 +0800 Subject: [PATCH 030/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resumestate/controller/ResumeStateController.java | 7 ++----- .../domain/resumestate/service/ResumeStateService.java | 4 ++-- .../resumestate/service/impl/ResumeStateServiceImpl.java | 6 ++++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/achobeta/domain/resumestate/controller/ResumeStateController.java b/src/main/java/com/achobeta/domain/resumestate/controller/ResumeStateController.java index f4a3a012..d8600e89 100644 --- a/src/main/java/com/achobeta/domain/resumestate/controller/ResumeStateController.java +++ b/src/main/java/com/achobeta/domain/resumestate/controller/ResumeStateController.java @@ -8,7 +8,6 @@ import com.achobeta.domain.resumestate.machine.context.ResumeContext; import com.achobeta.domain.resumestate.model.converter.ResumeStateConverter; import com.achobeta.domain.resumestate.model.dto.ResumeExecuteDTO; -import com.achobeta.domain.resumestate.model.entity.ResumeStatusProcess; import com.achobeta.domain.resumestate.model.vo.ResumeEventVO; import com.achobeta.domain.resumestate.model.vo.ResumeStatusProcessVO; import com.achobeta.domain.resumestate.model.vo.ResumeStatusVO; @@ -102,16 +101,14 @@ public SystemJsonResponse getResumeEventList() { public SystemJsonResponse getProcesses(@PathVariable("batchId") @NotNull Long batchId) { long userId = BaseContext.getCurrentUser().getUserId(); StuResume currentResume = stuResumeService.checkAndGetStuResumeByBatchIdAndStuId(batchId, userId); - List processes = resumeStateService.getProcessByResumeId(currentResume); - List resumeStatusProcessVOList = ResumeStateConverter.INSTANCE.processesToProcessVOList(processes); + List resumeStatusProcessVOList = resumeStateService.getProcessByResumeId(currentResume); return SystemJsonResponse.SYSTEM_SUCCESS(resumeStatusProcessVOList); } @GetMapping("/process/manager/{resumeId}") public SystemJsonResponse getProcessesByResumeId(@PathVariable("resumeId") @NotNull Long resumeId) { StuResume currentResume = stuResumeService.checkAndGetResume(resumeId); - List processes = resumeStateService.getProcessByResumeId(currentResume); - List resumeStatusProcessVOList = ResumeStateConverter.INSTANCE.processesToProcessVOList(processes); + List resumeStatusProcessVOList = resumeStateService.getProcessByResumeId(currentResume); return SystemJsonResponse.SYSTEM_SUCCESS(resumeStatusProcessVOList); } diff --git a/src/main/java/com/achobeta/domain/resumestate/service/ResumeStateService.java b/src/main/java/com/achobeta/domain/resumestate/service/ResumeStateService.java index f23ec63e..d85bd9ae 100644 --- a/src/main/java/com/achobeta/domain/resumestate/service/ResumeStateService.java +++ b/src/main/java/com/achobeta/domain/resumestate/service/ResumeStateService.java @@ -3,7 +3,7 @@ import com.achobeta.domain.resumestate.enums.ResumeEvent; import com.achobeta.domain.resumestate.enums.ResumeStatus; import com.achobeta.domain.resumestate.machine.context.ResumeContext; -import com.achobeta.domain.resumestate.model.entity.ResumeStatusProcess; +import com.achobeta.domain.resumestate.model.vo.ResumeStatusProcessVO; import com.achobeta.domain.student.model.entity.StuResume; import java.util.List; @@ -21,6 +21,6 @@ public interface ResumeStateService { ResumeStatus executeResumeEvent(ResumeEvent resumeEvent, ResumeContext resumeContext); - List getProcessByResumeId(StuResume currentResume); + List getProcessByResumeId(StuResume currentResume); } diff --git a/src/main/java/com/achobeta/domain/resumestate/service/impl/ResumeStateServiceImpl.java b/src/main/java/com/achobeta/domain/resumestate/service/impl/ResumeStateServiceImpl.java index 13c5ae36..b104da31 100644 --- a/src/main/java/com/achobeta/domain/resumestate/service/impl/ResumeStateServiceImpl.java +++ b/src/main/java/com/achobeta/domain/resumestate/service/impl/ResumeStateServiceImpl.java @@ -6,7 +6,9 @@ import com.achobeta.domain.resumestate.enums.ResumeStatus; import com.achobeta.domain.resumestate.machine.constants.ResumeStateMachineConstants; import com.achobeta.domain.resumestate.machine.context.ResumeContext; +import com.achobeta.domain.resumestate.model.converter.ResumeStateConverter; import com.achobeta.domain.resumestate.model.entity.ResumeStatusProcess; +import com.achobeta.domain.resumestate.model.vo.ResumeStatusProcessVO; import com.achobeta.domain.resumestate.service.ResumeStateService; import com.achobeta.domain.resumestate.service.ResumeStatusProcessService; import com.achobeta.domain.student.model.entity.StuResume; @@ -80,7 +82,7 @@ public ResumeStatus executeResumeEvent(ResumeEvent resumeEvent, ResumeContext re @Override @Transactional - public List getProcessByResumeId(StuResume currentResume) { + public List getProcessByResumeId(StuResume currentResume) { Long resumeId = currentResume.getId(); ResumeStatus currentStatus = currentResume.getStatus(); List statusProcesses = resumeStatusProcessService.getProcessByResumeId(resumeId); @@ -89,6 +91,6 @@ public List getProcessByResumeId(StuResume currentResume) { ResumeStatusProcess process = resumeStatusProcessService.createResumeStatusProcess(resumeId, currentStatus, ResumeEvent.NEXT); statusProcesses.add(process); } - return statusProcesses; + return ResumeStateConverter.INSTANCE.processesToProcessVOList(statusProcesses); } } From baddcb05395e571e6c09403de0a0a4dc40b227c8 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sat, 12 Oct 2024 23:06:48 +0800 Subject: [PATCH 031/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/UserFeedbackController.java | 20 +++++++++----- .../feedback/service/UserFeedbackService.java | 7 ++--- .../service/impl/UserFeedbackServiceImpl.java | 27 ++++++------------- .../message/controller/MessageController.java | 3 ++- .../message/service/MessageService.java | 2 +- .../service/impl/MessageServiceImpl.java | 8 ++---- 6 files changed, 30 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/achobeta/domain/feedback/controller/UserFeedbackController.java b/src/main/java/com/achobeta/domain/feedback/controller/UserFeedbackController.java index 7f3507e9..70b949e7 100644 --- a/src/main/java/com/achobeta/domain/feedback/controller/UserFeedbackController.java +++ b/src/main/java/com/achobeta/domain/feedback/controller/UserFeedbackController.java @@ -11,6 +11,8 @@ import com.achobeta.domain.feedback.model.vo.UserPersonalFeedBackVO; import com.achobeta.domain.feedback.service.UserFeedbackService; import com.achobeta.domain.message.model.entity.Message; +import com.achobeta.domain.users.context.BaseContext; +import com.achobeta.domain.users.model.po.UserHelper; import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; @@ -41,26 +43,28 @@ public class UserFeedbackController { * @return: com.achobeta.common.SystemJsonResponse **/ @GetMapping("/query") - @Intercept(permit = UserTypeEnum.USER) + @Intercept(permit = {UserTypeEnum.USER}) public SystemJsonResponse queryPersonalFeedbackList() { + long userId = BaseContext.getCurrentUser().getUserId(); //查询用户个人反馈列表 - List userPersonalFeedBackVOList = userFeedbackService.getUserFeedbackList(); + List userPersonalFeedBackVOList = userFeedbackService.getUserFeedbackList(userId); return SystemJsonResponse.SYSTEM_SUCCESS(userPersonalFeedBackVOList); } @PostMapping("/submit") - @Intercept(permit = UserTypeEnum.USER) + @Intercept(permit = {UserTypeEnum.USER}) public SystemJsonResponse submitFeedback(@Valid @RequestBody UserFeedbackDTO userFeedbackDTO) { + long userId = BaseContext.getCurrentUser().getUserId(); //提交反馈 - userFeedbackService.submitUserFeedback(userFeedbackDTO); + userFeedbackService.submitUserFeedback(userId, userFeedbackDTO); return SystemJsonResponse.SYSTEM_SUCCESS(); } //管理端查询用户反馈列表 @PostMapping("/query") - @Intercept(permit = UserTypeEnum.ADMIN) + @Intercept(permit = {UserTypeEnum.ADMIN}) public SystemJsonResponse queryFeedbackofUserList(@Valid @RequestBody QueryUserOfFeedbackDTO queryUserOfFeedbackDTO) { //条件分页查询列表 QueryUserOfFeedbackVO queryUserOfFeedbackVO = userFeedbackService.queryUserOfFeedbackList(queryUserOfFeedbackDTO); @@ -68,7 +72,7 @@ public SystemJsonResponse queryFeedbackofUserList(@Valid @RequestBody QueryUserO } @PostMapping("/handle") - @Intercept(permit = UserTypeEnum.ADMIN) + @Intercept(permit = {UserTypeEnum.ADMIN}) public SystemJsonResponse handleFeedbackofUser(@Valid @RequestBody HandleFeedbackDTO handleFeedbackDTO) { //处理反馈结果 Long feedBackId = userFeedbackService.handleFeedbackOfUser(handleFeedbackDTO); @@ -79,11 +83,13 @@ public SystemJsonResponse handleFeedbackofUser(@Valid @RequestBody HandleFeedbac @GetMapping("/get") @Intercept(permit = {UserTypeEnum.ADMIN, UserTypeEnum.USER}) public SystemJsonResponse queryHandleMessage(@RequestParam @NotNull Long messageId) { + // 获取当前用户 + UserHelper currentUser = BaseContext.getCurrentUser(); //检查消息是否存在 Message message = userFeedbackService.judgeMessageOfFeedbackIfExist(messageId); //处理反馈结果 - FeedbackMessageVO feedbackMessageVO = userFeedbackService.queryMessageOfFeedback(message); + FeedbackMessageVO feedbackMessageVO = userFeedbackService.queryMessageOfFeedback(currentUser, message); return SystemJsonResponse.SYSTEM_SUCCESS(feedbackMessageVO); } diff --git a/src/main/java/com/achobeta/domain/feedback/service/UserFeedbackService.java b/src/main/java/com/achobeta/domain/feedback/service/UserFeedbackService.java index c3df370c..34edbdc2 100644 --- a/src/main/java/com/achobeta/domain/feedback/service/UserFeedbackService.java +++ b/src/main/java/com/achobeta/domain/feedback/service/UserFeedbackService.java @@ -8,6 +8,7 @@ import com.achobeta.domain.feedback.model.vo.QueryUserOfFeedbackVO; import com.achobeta.domain.feedback.model.vo.UserPersonalFeedBackVO; import com.achobeta.domain.message.model.entity.Message; +import com.achobeta.domain.users.model.po.UserHelper; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; @@ -19,15 +20,15 @@ */ public interface UserFeedbackService extends IService { - List getUserFeedbackList(); + List getUserFeedbackList(Long userId); - void submitUserFeedback(UserFeedbackDTO userFeedbackDTO); + void submitUserFeedback(Long userId, UserFeedbackDTO userFeedbackDTO); QueryUserOfFeedbackVO queryUserOfFeedbackList(QueryUserOfFeedbackDTO queryUserOfFeedbackDTO); Long handleFeedbackOfUser(HandleFeedbackDTO handleFeedbackDTO); - FeedbackMessageVO queryMessageOfFeedback(Message message); + FeedbackMessageVO queryMessageOfFeedback(UserHelper currentUser, Message message); Message judgeMessageOfFeedbackIfExist(Long messageId); diff --git a/src/main/java/com/achobeta/domain/feedback/service/impl/UserFeedbackServiceImpl.java b/src/main/java/com/achobeta/domain/feedback/service/impl/UserFeedbackServiceImpl.java index b31882dc..1abe38fe 100644 --- a/src/main/java/com/achobeta/domain/feedback/service/impl/UserFeedbackServiceImpl.java +++ b/src/main/java/com/achobeta/domain/feedback/service/impl/UserFeedbackServiceImpl.java @@ -16,7 +16,7 @@ import com.achobeta.domain.login.model.dao.UserEntity; import com.achobeta.domain.message.model.entity.Message; import com.achobeta.domain.message.service.MessageService; -import com.achobeta.domain.users.context.BaseContext; +import com.achobeta.domain.users.model.po.UserHelper; import com.achobeta.domain.users.service.UserService; import com.achobeta.exception.GlobalServiceException; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -43,20 +43,15 @@ public class UserFeedbackServiceImpl extends ServiceImpl getUserFeedbackList() { - long userId = BaseContext.getCurrentUser().getUserId(); + public List getUserFeedbackList(Long userId) { //根据用户id查询反馈列表 List userFeedbackList = lambdaQuery().eq(UserFeedback::getUserId, userId).list(); //构造返回实体 - List userPersonalFeedBackVOList = feedbackConverter.userFeedbackPoToPersonalVoList(userFeedbackList); - - return userPersonalFeedBackVOList; + return feedbackConverter.userFeedbackPoToPersonalVoList(userFeedbackList); } @Override - public void submitUserFeedback(UserFeedbackDTO userFeedbackDTO) { - //获取用户id - long userId = BaseContext.getCurrentUser().getUserId(); + public void submitUserFeedback(Long userId, UserFeedbackDTO userFeedbackDTO) { //构造反馈实体 UserFeedback userFeedback = feedbackConverter.userFeedbackDTOToPo(userFeedbackDTO); userFeedback.setUserId(userId); @@ -84,22 +79,16 @@ public Long handleFeedbackOfUser(HandleFeedbackDTO handleFeedbackDTO) { UserFeedback userFeedback = this.getById(handleFeedbackDTO.getFeedbackId()); Optional.ofNullable(userFeedback).orElseThrow(() -> new GlobalServiceException("不存在的用户反馈")); //处理用户反馈 - Long messageId = handleFeedback(handleFeedbackDTO, userFeedback); - - return messageId; + return handleFeedback(handleFeedbackDTO, userFeedback); } @Override - public FeedbackMessageVO queryMessageOfFeedback(Message message) { - - Integer role = BaseContext.getCurrentUser().getRole(); - + public FeedbackMessageVO queryMessageOfFeedback(UserHelper currentUser, Message message) { //学生用户只能查自己的反馈消息 - if (!(role.equals(UserTypeEnum.USER) && message.getUserId().equals(BaseContext.getCurrentUser().getUserId()))) + if (UserTypeEnum.USER.getCode().equals(currentUser.getRole()) && message.getUserId().equals(currentUser.getUserId())) { throw new GlobalServiceException(GlobalServiceStatusCode.USER_NO_PERMISSION); - + } return getFeedbackMessageVO(message); - } private FeedbackMessageVO getFeedbackMessageVO(Message message) { diff --git a/src/main/java/com/achobeta/domain/message/controller/MessageController.java b/src/main/java/com/achobeta/domain/message/controller/MessageController.java index 5b79957a..2900a6f4 100644 --- a/src/main/java/com/achobeta/domain/message/controller/MessageController.java +++ b/src/main/java/com/achobeta/domain/message/controller/MessageController.java @@ -42,7 +42,8 @@ public SystemJsonResponse queryStuList(@Valid @RequestBody QueryStuListDTO query @GetMapping("/info/query") @Intercept(permit = {UserTypeEnum.ADMIN, UserTypeEnum.USER}) public SystemJsonResponse queryMessageListOfUser() { - List messageContentVOList = messageService.getMessageListOfUser(); + Long userId = BaseContext.getCurrentUser().getUserId(); + List messageContentVOList = messageService.getMessageListOfUser(userId); return SystemJsonResponse.SYSTEM_SUCCESS(messageContentVOList); } diff --git a/src/main/java/com/achobeta/domain/message/service/MessageService.java b/src/main/java/com/achobeta/domain/message/service/MessageService.java index c92ecf56..1b8e1862 100644 --- a/src/main/java/com/achobeta/domain/message/service/MessageService.java +++ b/src/main/java/com/achobeta/domain/message/service/MessageService.java @@ -34,7 +34,7 @@ public interface MessageService extends IService { Long storeMessage(MessageContentDTO messageContent); - List getMessageListOfUser(); + List getMessageListOfUser(Long userId); void sendMessageByEmail(Long managerId, EmailSendDTO emailSendDTO, List attachmentList); diff --git a/src/main/java/com/achobeta/domain/message/service/impl/MessageServiceImpl.java b/src/main/java/com/achobeta/domain/message/service/impl/MessageServiceImpl.java index 41e0459e..e255a736 100644 --- a/src/main/java/com/achobeta/domain/message/service/impl/MessageServiceImpl.java +++ b/src/main/java/com/achobeta/domain/message/service/impl/MessageServiceImpl.java @@ -15,7 +15,6 @@ import com.achobeta.domain.resource.service.ResourceService; import com.achobeta.domain.student.model.entity.StuResume; import com.achobeta.domain.student.service.StuResumeService; -import com.achobeta.domain.users.context.BaseContext; import com.achobeta.email.model.po.EmailAttachment; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -160,8 +159,7 @@ public Long storeMessage(MessageContentDTO messageContent) { } @Override - public List getMessageListOfUser() { - Long userId = BaseContext.getCurrentUser().getUserId(); + public List getMessageListOfUser(Long userId) { //缓存消息列表 /*Optional> messageOptional = redisCache.getCacheList(MESSAGE_CACHE_NAME + userId, MessageContentVO.class); @@ -169,9 +167,7 @@ public List getMessageListOfUser() { return messageOptional.get();*/ //查询并封装返回结果 List messageList = lambdaQuery().eq(Message::getUserId, userId).list(); - List messageContentVOList = messageConverter.messageContentPoToVOList(messageList); - - return messageContentVOList; + return messageConverter.messageContentPoToVOList(messageList); } @Override From 324ef59c14245bf886956950ad55673ad38b8c2c Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 13 Oct 2024 01:14:01 +0800 Subject: [PATCH 032/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resource/service/ResourceService.java | 6 +- .../service/impl/ResourceServiceImpl.java | 30 ++++----- .../impl/ResumeStatusProcessServiceImpl.java | 6 +- .../service/impl/StuResumeServiceImpl.java | 2 +- .../feishu/aspect/FeishuRequestAspect.java | 4 +- .../feishu/constants/FeishuConstants.java | 2 - .../achobeta/interceptor/UserInterceptor.java | 63 +++++++------------ .../com/achobeta/redis/lock/RedisLock.java | 16 +++-- .../redis/lock/RedisLockProperties.java | 29 +++++++++ .../com/achobeta/util/HttpRequestUtil.java | 3 +- .../com/achobeta/util/HttpServletUtil.java | 5 +- src/main/resources/application.yml | 2 + 12 files changed, 91 insertions(+), 77 deletions(-) create mode 100644 src/main/java/com/achobeta/redis/lock/RedisLockProperties.java diff --git a/src/main/java/com/achobeta/domain/resource/service/ResourceService.java b/src/main/java/com/achobeta/domain/resource/service/ResourceService.java index 2d10d644..f6c2051c 100644 --- a/src/main/java/com/achobeta/domain/resource/service/ResourceService.java +++ b/src/main/java/com/achobeta/domain/resource/service/ResourceService.java @@ -19,14 +19,14 @@ */ public interface ResourceService { - DigitalResource checkAndGetResource(Long code, ResourceAccessLevel level); + DigitalResource analyzeCode(Long code, ResourceAccessLevel level); DigitalResource analyzeCode(Long code); - void download(Long code, HttpServletResponse response); - void preview(Long code, HttpServletResponse response); + void download(Long code, HttpServletResponse response); + byte[] load(Long code); void checkImage(Long code); diff --git a/src/main/java/com/achobeta/domain/resource/service/impl/ResourceServiceImpl.java b/src/main/java/com/achobeta/domain/resource/service/impl/ResourceServiceImpl.java index 252814b9..92fb1877 100644 --- a/src/main/java/com/achobeta/domain/resource/service/impl/ResourceServiceImpl.java +++ b/src/main/java/com/achobeta/domain/resource/service/impl/ResourceServiceImpl.java @@ -21,6 +21,7 @@ import com.achobeta.feishu.constants.ObjectType; import com.achobeta.redis.cache.RedisCache; import com.achobeta.redis.lock.RedisLock; +import com.achobeta.redis.lock.RedisLockProperties; import com.achobeta.redis.lock.strategy.SimpleLockStrategy; import com.achobeta.util.*; import com.lark.oapi.service.drive.v1.model.ImportTask; @@ -53,11 +54,8 @@ @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") public class ResourceServiceImpl implements ResourceService { - @Value("${spring.redisson.lock.timeout:10}") - private Long timeout; - - @Value("${spring.redisson.lock.unit:SECONDS}") - private TimeUnit unit; + @Value("${resource.compression.threshold}") + private Integer compressionThreshold; private final UploadLimitProperties uploadLimitProperties; @@ -75,10 +73,12 @@ public class ResourceServiceImpl implements ResourceService { private final RedisLock redisLock; + private final RedisLockProperties redisLockProperties; + private final SimpleLockStrategy simpleLockStrategy; @Override - public DigitalResource checkAndGetResource(Long code, ResourceAccessLevel level) { + public DigitalResource analyzeCode(Long code, ResourceAccessLevel level) { DigitalResource resource = digitalResourceService.getResourceByCode(code); // 获取策略并判断是否可以访问(level 取最高的那个) ResourceAccessStrategy accessStrategy = accessStrategyFactory.getStrategy(resource.getAccessLevel().and(level)); @@ -94,19 +94,19 @@ public DigitalResource checkAndGetResource(Long code, ResourceAccessLevel level) @Override public DigitalResource analyzeCode(Long code) { - return checkAndGetResource(code, null); + return analyzeCode(code, null); } @Override - public void download(Long code, HttpServletResponse response) { + public void preview(Long code, HttpServletResponse response) { DigitalResource resource = analyzeCode(code); - objectStorageService.download(resource.getOriginalName(), resource.getFileName(), response); + objectStorageService.preview(resource.getFileName(), response); } @Override - public void preview(Long code, HttpServletResponse response) { + public void download(Long code, HttpServletResponse response) { DigitalResource resource = analyzeCode(code); - objectStorageService.preview(resource.getFileName(), response); + objectStorageService.download(resource.getOriginalName(), resource.getFileName(), response); } @Override @@ -163,8 +163,8 @@ public Long upload(Long userId, String originalName, byte[] data, ResourceAccess // 判断文件类型 String contentType = MediaUtil.getContentType(data); String suffix = null; - // 判断是否是图片类型,若是则压缩图片 - if(ResourceUtil.matchType(contentType, ResourceType.IMAGE)) { + // 判断是否是图片类型,并判断是否达到压缩阈值(否则压缩适得其反),若是则压缩图片 + if(ResourceUtil.matchType(contentType, ResourceType.IMAGE) && compressionThreshold.compareTo(data.length) <= 0) { // 压缩图片 data = MediaUtil.compressImage(data); suffix = "." + MediaUtil.COMPRESS_FORMAT_NAME; @@ -203,7 +203,7 @@ public Long upload(Long userId, MultipartFile file) { @Transactional public OnlineResourceVO synchronousFeishuUpload(Long managerId, byte[] bytes, ResourceAccessLevel level, ObjectType objectType, String fileName, Boolean synchronous) { // 若同一管理员同时访问这个同步飞书的方法,未获得锁的上传任务都拒绝(防抖)(可能上传时间长,多点了几下...) - return redisLock.tryLockGetSomething(ResourceConstants.REDIS_MANAGER_SYNC_FEISHU_LOCK + managerId, 0L, timeout, unit, () -> { + return redisLock.tryLockGetSomething(ResourceConstants.REDIS_MANAGER_SYNC_FEISHU_LOCK + managerId, 0L, redisLockProperties.getTimeout(), redisLockProperties.getUnit(), () -> { // 获取一个文件名 String originName = ResourceUtil.getFileNameByExtension(fileName, objectType.getFileExtension()); OnlineResourceVO onlineResourceVO = new OnlineResourceVO(); @@ -256,7 +256,7 @@ public void setAccessLevel(Long resourceId, ResourceAccessLevel level) { @Transactional public void remove(Long code) { // 若权限小于 USER_ACCESS 就按 USER_ACCESS 权限 - DigitalResource resource = checkAndGetResource(code, DEFAULT_RESOURCE_ACCESS_LEVEL); + DigitalResource resource = analyzeCode(code, DEFAULT_RESOURCE_ACCESS_LEVEL); objectStorageService.remove(resource.getFileName()); digitalResourceService.removeDigitalResource(resource.getId()); } diff --git a/src/main/java/com/achobeta/domain/resumestate/service/impl/ResumeStatusProcessServiceImpl.java b/src/main/java/com/achobeta/domain/resumestate/service/impl/ResumeStatusProcessServiceImpl.java index bc655e75..bc4c0ffe 100644 --- a/src/main/java/com/achobeta/domain/resumestate/service/impl/ResumeStatusProcessServiceImpl.java +++ b/src/main/java/com/achobeta/domain/resumestate/service/impl/ResumeStatusProcessServiceImpl.java @@ -38,8 +38,4 @@ public List getProcessByResumeId(Long resumeId) { .orderBy(Boolean.TRUE, Boolean.TRUE, ResumeStatusProcess::getCreateTime) .list(); } -} - - - - +} \ No newline at end of file diff --git a/src/main/java/com/achobeta/domain/student/service/impl/StuResumeServiceImpl.java b/src/main/java/com/achobeta/domain/student/service/impl/StuResumeServiceImpl.java index 5808db76..e967c7e9 100644 --- a/src/main/java/com/achobeta/domain/student/service/impl/StuResumeServiceImpl.java +++ b/src/main/java/com/achobeta/domain/student/service/impl/StuResumeServiceImpl.java @@ -195,7 +195,7 @@ public void saveStuAttachment(List stuAttachmentDTOList, Long //类型转换 stuAttachmentList = stuAttachmentDTOList.stream().distinct().map(attach -> { // 判断是否可以访问这个资源 - resourceService.checkAndGetResource(attach.getAttachment(), null); + resourceService.analyzeCode(attach.getAttachment(), null); // 移出枪毙名单 oldAttachmentHash.remove(attach.getAttachment()); // 转化 diff --git a/src/main/java/com/achobeta/feishu/aspect/FeishuRequestAspect.java b/src/main/java/com/achobeta/feishu/aspect/FeishuRequestAspect.java index 53c47837..af0b5168 100644 --- a/src/main/java/com/achobeta/feishu/aspect/FeishuRequestAspect.java +++ b/src/main/java/com/achobeta/feishu/aspect/FeishuRequestAspect.java @@ -11,8 +11,6 @@ import org.aspectj.lang.annotation.Pointcut; import org.springframework.stereotype.Component; -import static com.achobeta.feishu.constants.FeishuConstants.SUCCESS_CODE; - /** * Created With Intellij IDEA * Description: @@ -39,7 +37,7 @@ public void doAfterReturning(Object result) { if(result instanceof BaseResponse response) { int code = response.getCode(); log.info("飞书响应码 {}", code); - if(code == SUCCESS_CODE) { + if(response.success()) { log.info("飞书请求成功"); } else { log.info("飞书 token 刷新"); diff --git a/src/main/java/com/achobeta/feishu/constants/FeishuConstants.java b/src/main/java/com/achobeta/feishu/constants/FeishuConstants.java index 003954b9..83d95392 100644 --- a/src/main/java/com/achobeta/feishu/constants/FeishuConstants.java +++ b/src/main/java/com/achobeta/feishu/constants/FeishuConstants.java @@ -34,8 +34,6 @@ public interface FeishuConstants { String MEDIA_TICKET_QUERY_KEY = "ticket"; - int SUCCESS_CODE = 0; - static String getAuthorization(String accessToken) { return Optional.ofNullable(accessToken) .map(token -> AUTHORIZATION_PREFIX + token) diff --git a/src/main/java/com/achobeta/interceptor/UserInterceptor.java b/src/main/java/com/achobeta/interceptor/UserInterceptor.java index d0e34147..a08dbd0b 100644 --- a/src/main/java/com/achobeta/interceptor/UserInterceptor.java +++ b/src/main/java/com/achobeta/interceptor/UserInterceptor.java @@ -37,29 +37,46 @@ @RequiredArgsConstructor public class UserInterceptor implements HandlerInterceptor { + public static final String USER_ID = "user_id"; + + public static final String USER_ROLE_NAME = "user"; + private final RequestIdConfig requestIdConfig; private final JwtProperties jwtProperties; private final SnowflakeIdGenerator requestIdGenerator; - public static final String USER_ID = "user_id"; - public static final String USER_ROLE_NAME = "user"; + private void refreshToken(HttpServletResponse response, SecretKey secretKey, Claims claims) { + String refreshToken = JwtUtil.createJWT(secretKey, jwtProperties.getTtl(), claims); + //刷新 token,通过请求头返回前端 + response.setHeader(jwtProperties.getTokenName(), refreshToken); + log.info("无感刷新 token: {}", refreshToken); + } public UserHelper getUserHelper(HttpServletRequest request) { String token = request.getHeader(jwtProperties.getTokenName()); - //从请求头中获取token + //从请求头中获取 token if (StrUtil.isEmpty(token)) { throw new GlobalServiceException("用户未登录,token为空", GlobalServiceStatusCode.USER_NOT_LOGIN); } //通过明文钥匙生成密钥 SecretKey secretKey = JwtUtil.generalKey(jwtProperties.getSecretKey()); Claims claims = JwtUtil.parseJWT(secretKey, token); + + // 记录接口的访问记录 UserHelper userHelper = UserHelper.builder() .userId(Long.parseLong(claims.get(UserInterceptor.USER_ID).toString())) .token(token) .role(Integer.parseInt(claims.get(UserInterceptor.USER_ROLE_NAME).toString())) .build(); + log.info("登录信息 -> {}", userHelper); + + //判断 token 是否即将过期 + if (JwtUtil.judgeApproachExpiration(token, secretKey, jwtProperties.getRefreshTime())) { + refreshToken(HttpServletUtil.getResponse(), secretKey, claims); + } + //通过线程局部变量设置当前线程用户信息 BaseContext.setCurrentUser(userHelper); return userHelper; } @@ -89,52 +106,18 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons return Boolean.TRUE; } - String token = request.getHeader(jwtProperties.getTokenName()); - //从请求头中获取token - if (StrUtil.isEmpty(token)) { - throw new GlobalServiceException("用户未登录,token 为空", GlobalServiceStatusCode.USER_NOT_LOGIN); - } - //通过明文钥匙生成密钥 - SecretKey secretKey = JwtUtil.generalKey(jwtProperties.getSecretKey()); - - Claims claims = JwtUtil.parseJWT(secretKey, token); - + UserHelper userHelper = getUserHelper(request); // 记录接口的访问记录 - Long userId = Long.valueOf(claims.get(UserInterceptor.USER_ID).toString()); - log.info("请求 {} 账户 {} 访问接口 {} ", requestId, userId, request.getRequestURI()); - + log.info("请求 {} 账户 {} 访问接口 {} ", requestId, userHelper.getUserId(), request.getRequestURI()); // permit 中没有 role 就会抛异常 - Integer role = Integer.parseInt(claims.get(UserInterceptor.USER_ROLE_NAME).toString()); + Integer role = userHelper.getRole(); if(!InterceptHelper.isValid(intercept, UserTypeEnum.get(role))) { throw new GlobalServiceException(GlobalServiceStatusCode.USER_NO_PERMISSION); } - //通过线程局部变量设置当前线程用户信息 - setGlobalUserInfoByClaims(userId, role, token); - //判断token是否即将过期 - if (JwtUtil.judgeApproachExpiration(token, secretKey, jwtProperties.getRefreshTime())) { - refreshToken(response, secretKey, claims); - } return Boolean.TRUE; } - private void refreshToken(HttpServletResponse response, SecretKey secretKey, Claims claims) { - String refreshToken = JwtUtil.createJWT(secretKey, jwtProperties.getTtl(), claims); - //刷新token,通过请求头返回前端 - response.setHeader(jwtProperties.getTokenName(), refreshToken); - log.info("无感刷新 token: {}", refreshToken); - } - - private void setGlobalUserInfoByClaims(Long userId, Integer role, String token) { - UserHelper userHelper = UserHelper.builder() - .userId(userId) - .token(token) - .role(role) - .build(); - log.info("登录信息 -> {}",userHelper); - BaseContext.setCurrentUser(userHelper); - } - // 此方法在全局响应异常处理器处理异常之后再执行,已经是大局已定了,对响应的写不会生效,抛出的异常也不会影响正常响应 // 因为请求还没结束,这个方法的处理时间也在请求时间内,会影响响应速度 @Override diff --git a/src/main/java/com/achobeta/redis/lock/RedisLock.java b/src/main/java/com/achobeta/redis/lock/RedisLock.java index 16f0177f..546d66cc 100644 --- a/src/main/java/com/achobeta/redis/lock/RedisLock.java +++ b/src/main/java/com/achobeta/redis/lock/RedisLock.java @@ -5,7 +5,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.redisson.api.RLock; -import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.factory.InitializingBean; import org.springframework.stereotype.Repository; import java.util.concurrent.TimeUnit; @@ -21,19 +21,25 @@ @Repository @RequiredArgsConstructor @Slf4j -public class RedisLock { +public class RedisLock implements InitializingBean { - @Value("${spring.redisson.lock.wait:10}") private Long wait; - @Value("${spring.redisson.lock.timeout:10}") private Long timeout; - @Value("${spring.redisson.lock.unit:SECONDS}") private TimeUnit unit; private final SimpleLockStrategy simpleLockStrategy; + private final RedisLockProperties redisLockProperties; + + @Override + public void afterPropertiesSet() throws Exception { + this.wait = redisLockProperties.getWait(); + this.timeout = redisLockProperties.getTimeout(); + this.unit = redisLockProperties.getUnit(); + } + private boolean tryLock(RLock rLock, final Long wait, final Long timeout, final TimeUnit timeUnit) throws InterruptedException { String key = rLock.getName(); diff --git a/src/main/java/com/achobeta/redis/lock/RedisLockProperties.java b/src/main/java/com/achobeta/redis/lock/RedisLockProperties.java new file mode 100644 index 00000000..04da93a5 --- /dev/null +++ b/src/main/java/com/achobeta/redis/lock/RedisLockProperties.java @@ -0,0 +1,29 @@ +package com.achobeta.redis.lock; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import java.util.concurrent.TimeUnit; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-10-13 + * Time: 0:34 + */ +@Configuration +@Setter +@Getter +@ConfigurationProperties(prefix = "spring.redisson.lock") +public class RedisLockProperties { + + private Long wait; + + private Long timeout; + + private TimeUnit unit; + +} diff --git a/src/main/java/com/achobeta/util/HttpRequestUtil.java b/src/main/java/com/achobeta/util/HttpRequestUtil.java index 6bbc34af..3f4b8664 100644 --- a/src/main/java/com/achobeta/util/HttpRequestUtil.java +++ b/src/main/java/com/achobeta/util/HttpRequestUtil.java @@ -4,6 +4,7 @@ import cn.hutool.http.HttpUtil; import cn.hutool.http.Method; import com.achobeta.common.enums.HttpRequestEnum; +import org.springframework.http.HttpHeaders; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.StringUtils; import org.springframework.web.util.UriComponentsBuilder; @@ -28,7 +29,7 @@ */ public class HttpRequestUtil { - public final static Map JSON_CONTENT_TYPE_HEADER = Map.of("CONTENT_TYPE", "application/json; charset=utf-8"); + public final static Map JSON_CONTENT_TYPE_HEADER = Map.of(HttpHeaders.CONTENT_TYPE, "application/json; charset=utf-8"); public static final Pattern HTTP_URL_PATTERN = Pattern.compile("^(?i)(http|https):(//(([^@\\[/?#]*)@)?(\\[[\\p{XDigit}:.]*[%\\p{Alnum}]*]|[^\\[/?#:]*)(:(\\{[^}]+\\}?|[^/?#]*))?)?([^?#]*)(\\?([^#]*))?(#(.*))?"); diff --git a/src/main/java/com/achobeta/util/HttpServletUtil.java b/src/main/java/com/achobeta/util/HttpServletUtil.java index 43826e8b..52b0134a 100644 --- a/src/main/java/com/achobeta/util/HttpServletUtil.java +++ b/src/main/java/com/achobeta/util/HttpServletUtil.java @@ -4,6 +4,7 @@ import jakarta.servlet.ServletOutputStream; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.springframework.http.HttpHeaders; import org.springframework.util.StringUtils; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -54,12 +55,12 @@ public static void returnBytes(byte[] bytes, HttpServletResponse response) { public static void returnBytes(String downloadName, byte[] bytes, HttpServletResponse response) { // 在设置内容类型之前设置下载的文件名称 - response.addHeader("Content-Disposition", "attachment; fileName=" + HttpRequestUtil.encodeString(downloadName)); + response.addHeader(HttpHeaders.CONTENT_DISPOSITION, String.format("attachment; fileName=%s", HttpRequestUtil.encodeString(downloadName))); returnBytes(bytes, response); } public static String getHost(HttpServletRequest request) { - return String.format("%s://%s", request.getScheme(), request.getHeader("host")); + return String.format("%s://%s", request.getScheme(), request.getHeader(HttpHeaders.HOST)); } public static String getBaseUrl(HttpServletRequest request, String... uris) { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 9cf49918..aaa48ede 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -34,6 +34,8 @@ ab: header: Request-ID resource: + compression: + threshold: 65536 code: workerId: 2 upload: From 7dcf85729f095322ba99b1068cc4874cf2662cbf Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 13 Oct 2024 01:31:53 +0800 Subject: [PATCH 033/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../achobeta/domain/resource/service/ResourceService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/achobeta/domain/resource/service/ResourceService.java b/src/main/java/com/achobeta/domain/resource/service/ResourceService.java index f6c2051c..cbb878f0 100644 --- a/src/main/java/com/achobeta/domain/resource/service/ResourceService.java +++ b/src/main/java/com/achobeta/domain/resource/service/ResourceService.java @@ -16,9 +16,13 @@ * Date: 2024-09-21 * Time: 12:16 * Description: 仅仅针对本服务内部的资源 + * 本接口大部分方法都需要真实存在一次请求才能访问 */ public interface ResourceService { + /** + * 此方法可能需要真实存在一次请求才能调用(权限等级大于 FREE_ACCESS 时,此请求需要用到 HttpServletRequest,内部会尝试获取当前请求的 HttpServletRequest) + */ DigitalResource analyzeCode(Long code, ResourceAccessLevel level); DigitalResource analyzeCode(Long code); @@ -72,6 +76,7 @@ public interface ResourceService { /** * 压缩图片,同时更新对象上传服务器,以及数据库的记录 + * 此方法不要求真实存在一次请求 * @param code 资源码 * @throws Exception 若不是图片会抛异常 */ From 77ea812f57ba432e08d312d734f90aa3509d6046 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 13 Oct 2024 01:33:38 +0800 Subject: [PATCH 034/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/achobeta/util/MediaUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/achobeta/util/MediaUtil.java b/src/main/java/com/achobeta/util/MediaUtil.java index d2dbfc27..a6b6d4a7 100644 --- a/src/main/java/com/achobeta/util/MediaUtil.java +++ b/src/main/java/com/achobeta/util/MediaUtil.java @@ -36,7 +36,7 @@ public class MediaUtil { public static byte[] compressImage(byte[] bytes) { try(InputStream inputStream = getInputStream(bytes); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) { - // 使用 thumbnailator 进行压缩,指定输出格式为 formatName(无损格式) + // 使用 thumbnailator 进行压缩,指定输出格式 Thumbnails.of(inputStream) .outputFormat(COMPRESS_FORMAT_NAME) .scale(COMPRESS_SCALE) From 35f3fbff96cb900eb47ca77a0a13fbc539aeb525 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 13 Oct 2024 10:24:06 +0800 Subject: [PATCH 035/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/feishu/service/impl/FeishuServiceImpl.java | 2 +- .../com/achobeta/feishu/constants/FeishuConstants.java | 2 -- .../java/com/achobeta/interceptor/UserInterceptor.java | 8 ++++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuServiceImpl.java b/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuServiceImpl.java index ace31a3e..b70fcaca 100644 --- a/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuServiceImpl.java +++ b/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuServiceImpl.java @@ -271,7 +271,7 @@ public GetImportTaskRespBody getImportTask(String ticket) { GetImportTaskResp.class, Map.of(AUTHORIZATION_HEADER, getAuthorization(token)), null, - Map.of(MEDIA_TICKET_QUERY_KEY, ticket) + ticket ).getData(); } diff --git a/src/main/java/com/achobeta/feishu/constants/FeishuConstants.java b/src/main/java/com/achobeta/feishu/constants/FeishuConstants.java index 83d95392..d305330b 100644 --- a/src/main/java/com/achobeta/feishu/constants/FeishuConstants.java +++ b/src/main/java/com/achobeta/feishu/constants/FeishuConstants.java @@ -32,8 +32,6 @@ public interface FeishuConstants { String USER_ID_TYPE_QUERY_KEY = "use_id_type"; - String MEDIA_TICKET_QUERY_KEY = "ticket"; - static String getAuthorization(String accessToken) { return Optional.ofNullable(accessToken) .map(token -> AUTHORIZATION_PREFIX + token) diff --git a/src/main/java/com/achobeta/interceptor/UserInterceptor.java b/src/main/java/com/achobeta/interceptor/UserInterceptor.java index a08dbd0b..f8222a62 100644 --- a/src/main/java/com/achobeta/interceptor/UserInterceptor.java +++ b/src/main/java/com/achobeta/interceptor/UserInterceptor.java @@ -54,7 +54,7 @@ private void refreshToken(HttpServletResponse response, SecretKey secretKey, Cla log.info("无感刷新 token: {}", refreshToken); } - public UserHelper getUserHelper(HttpServletRequest request) { + public UserHelper getUserHelper(HttpServletRequest request, HttpServletResponse response) { String token = request.getHeader(jwtProperties.getTokenName()); //从请求头中获取 token if (StrUtil.isEmpty(token)) { @@ -74,7 +74,7 @@ public UserHelper getUserHelper(HttpServletRequest request) { //判断 token 是否即将过期 if (JwtUtil.judgeApproachExpiration(token, secretKey, jwtProperties.getRefreshTime())) { - refreshToken(HttpServletUtil.getResponse(), secretKey, claims); + refreshToken(response, secretKey, claims); } //通过线程局部变量设置当前线程用户信息 BaseContext.setCurrentUser(userHelper); @@ -83,7 +83,7 @@ public UserHelper getUserHelper(HttpServletRequest request) { public UserHelper getUserHelper() { return Optional.ofNullable(BaseContext.getCurrentUser()) - .orElseGet(() -> getUserHelper(HttpServletUtil.getRequest())); + .orElseGet(() -> getUserHelper(HttpServletUtil.getRequest(), HttpServletUtil.getResponse())); } @Override @@ -106,7 +106,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons return Boolean.TRUE; } - UserHelper userHelper = getUserHelper(request); + UserHelper userHelper = getUserHelper(request, response); // 记录接口的访问记录 log.info("请求 {} 账户 {} 访问接口 {} ", requestId, userHelper.getUserId(), request.getRequestURI()); // permit 中没有 role 就会抛异常 From aab1dc7241280279d56a6aa87255f14ddb4846f3 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 13 Oct 2024 10:42:34 +0800 Subject: [PATCH 036/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/achobeta/domain/message/model/dto/EmailMassDTO.java | 4 ++++ .../com/achobeta/domain/message/service/MessageService.java | 2 +- .../domain/message/service/impl/MessageServiceImpl.java | 6 +++--- .../achobeta/domain/student/service/StuResumeService.java | 2 +- .../domain/student/service/impl/StuResumeServiceImpl.java | 3 ++- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/achobeta/domain/message/model/dto/EmailMassDTO.java b/src/main/java/com/achobeta/domain/message/model/dto/EmailMassDTO.java index 4e595c82..9003e10a 100644 --- a/src/main/java/com/achobeta/domain/message/model/dto/EmailMassDTO.java +++ b/src/main/java/com/achobeta/domain/message/model/dto/EmailMassDTO.java @@ -2,6 +2,7 @@ import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import lombok.Data; import java.util.List; @@ -28,6 +29,9 @@ public class EmailMassDTO { @NotBlank(message = "消息内容不能为空") private String content; + @NotNull(message = "招新批次 id 不能为空") + private Long batchId; + @NotEmpty(message = "用户 id 列表不能为空") private List userIds; diff --git a/src/main/java/com/achobeta/domain/message/service/MessageService.java b/src/main/java/com/achobeta/domain/message/service/MessageService.java index 1b8e1862..c0cdf767 100644 --- a/src/main/java/com/achobeta/domain/message/service/MessageService.java +++ b/src/main/java/com/achobeta/domain/message/service/MessageService.java @@ -28,7 +28,7 @@ public interface MessageService extends IService { QueryStuListVO queryStuListByCondition(QueryStuListDTO queryStuDTO); - List queryStuList(List userIds); + List queryStuList(Long batchId, List userIds); void sendMessage(MessageContentDTO messageContentBody, CopyOnWriteArraySet webSocketSet); diff --git a/src/main/java/com/achobeta/domain/message/service/impl/MessageServiceImpl.java b/src/main/java/com/achobeta/domain/message/service/impl/MessageServiceImpl.java index e255a736..f665fa43 100644 --- a/src/main/java/com/achobeta/domain/message/service/impl/MessageServiceImpl.java +++ b/src/main/java/com/achobeta/domain/message/service/impl/MessageServiceImpl.java @@ -63,8 +63,8 @@ public QueryStuListVO queryStuListByCondition(QueryStuListDTO queryStuDTO) { } @Override - public List queryStuList(List userIds) { - List stuResumeList = stuResumeService.queryStuList(userIds.stream().distinct().toList()); + public List queryStuList(Long batchId, List userIds) { + List stuResumeList = stuResumeService.queryStuList(batchId, userIds.stream().distinct().toList()); return messageConverter.stuResumeListToStuBaseInfoDTOList(stuResumeList); } @@ -193,7 +193,7 @@ public void sendMessageByEmail(Long managerId, EmailSendDTO emailSendDTO, List attachmentList) { // 查询学生列表 - List stuBaseInfoDTOS = queryStuList(emailMassDTO.getUserIds()); + List stuBaseInfoDTOS = queryStuList(emailMassDTO.getBatchId(), emailMassDTO.getUserIds()); // 转换对象 EmailSendDTO emailSendDTO = new EmailSendDTO(); emailSendDTO.setTittle(emailMassDTO.getTittle()); diff --git a/src/main/java/com/achobeta/domain/student/service/StuResumeService.java b/src/main/java/com/achobeta/domain/student/service/StuResumeService.java index f680ac0d..467e6051 100644 --- a/src/main/java/com/achobeta/domain/student/service/StuResumeService.java +++ b/src/main/java/com/achobeta/domain/student/service/StuResumeService.java @@ -31,5 +31,5 @@ public interface StuResumeService extends IService { StuResume checkResumeSubmitCount(StuSimpleResumeDTO stuSimpleResumeDTO, Long userId); - List queryStuList(List userIds); + List queryStuList(Long batchId, List userIds); } diff --git a/src/main/java/com/achobeta/domain/student/service/impl/StuResumeServiceImpl.java b/src/main/java/com/achobeta/domain/student/service/impl/StuResumeServiceImpl.java index e967c7e9..4360213f 100644 --- a/src/main/java/com/achobeta/domain/student/service/impl/StuResumeServiceImpl.java +++ b/src/main/java/com/achobeta/domain/student/service/impl/StuResumeServiceImpl.java @@ -229,8 +229,9 @@ public StuResume checkResumeSubmitCount(StuSimpleResumeDTO resumeDTO, Long userI } @Override - public List queryStuList(List userIds) { + public List queryStuList(Long batchId, List userIds) { return lambdaQuery() + .eq(StuResume::getBatchId, batchId) .in(StuResume::getUserId, userIds) .list(); } From 938d97a4b76989d505ee0438f151aa4533ad9361 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 13 Oct 2024 12:05:54 +0800 Subject: [PATCH 037/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/message-email-notice.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/resources/templates/message-email-notice.html b/src/main/resources/templates/message-email-notice.html index 3e0e91d3..a8b58919 100644 --- a/src/main/resources/templates/message-email-notice.html +++ b/src/main/resources/templates/message-email-notice.html @@ -34,14 +34,14 @@ 亲爱的同学
-
- Attachment: -
+

+ +

Attachment: +

-

From 47a3658827918b672cf6e28d1fa17aa5172e1446 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 13 Oct 2024 16:02:40 +0800 Subject: [PATCH 038/104] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=A4=9A?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8F=91=E9=80=81=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../email/service/impl/EmailServiceImpl.java | 4 -- .../internal/InterviewExperienceHelper.java | 5 -- .../internal/InterviewSummaryHelper.java | 5 -- .../internal/InterviewStateNoticeHelper.java | 5 -- .../ext/MessageSendWithEmailHandler.java | 5 -- .../ResumeStateTransitionHelperConfig.java | 5 -- .../events/internal/ResumeConfirmHelper.java | 5 -- .../email/factory/EmailSenderFactory.java | 50 +++++++++++++++++++ .../email/factory/EmailSenderProperties.java | 24 +++++++++ .../achobeta/email/model/po/EmailMessage.java | 6 +-- .../achobeta/email/sender/EmailSender.java | 16 ++++-- 11 files changed, 89 insertions(+), 41 deletions(-) create mode 100644 src/main/java/com/achobeta/email/factory/EmailSenderFactory.java create mode 100644 src/main/java/com/achobeta/email/factory/EmailSenderProperties.java diff --git a/src/main/java/com/achobeta/domain/email/service/impl/EmailServiceImpl.java b/src/main/java/com/achobeta/domain/email/service/impl/EmailServiceImpl.java index d166819f..dbb1e071 100644 --- a/src/main/java/com/achobeta/domain/email/service/impl/EmailServiceImpl.java +++ b/src/main/java/com/achobeta/domain/email/service/impl/EmailServiceImpl.java @@ -40,9 +40,6 @@ public class EmailServiceImpl implements EmailService { @Value("${ab.email.riskControlTime:1}") private Integer riskControlTime; - @Value("${spring.mail.username}") - private String achobetaEmail; - private final RedisCache redisCache; private final EmailSender emailSender; private final HtmlEngine htmlEngine; @@ -102,7 +99,6 @@ private void buildEmailAndSend(String email, String code) { emailMessage.setTitle(CAPTCHA.getTitle()); emailMessage.setRecipient(email); emailMessage.setCarbonCopy(); - emailMessage.setSender(achobetaEmail); // 构造模板消息 VerificationCodeTemplate verificationCodeTemplate = VerificationCodeTemplate.builder() .code(code) diff --git a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java index 24a4965c..7b2171f9 100644 --- a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java +++ b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java @@ -21,7 +21,6 @@ import com.alibaba.cola.statemachine.Action; import com.alibaba.cola.statemachine.Condition; import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.util.Date; @@ -39,9 +38,6 @@ @RequiredArgsConstructor public class InterviewExperienceHelper implements InterviewStateInternalTransitionHelper { - @Value("${spring.mail.username}") - private String achobetaEmail; - private final EmailSender emailSender; private final HtmlEngine htmlEngine; @@ -89,7 +85,6 @@ public Action getPerformActio // 构造邮件消息 EmailTemplateEnum emailTemplate = EmailTemplateEnum.INTERVIEW_EXPERIENCE; EmailMessage emailMessage = new EmailMessage(); - emailMessage.setSender(achobetaEmail); emailMessage.setCarbonCopy(); emailMessage.setCreateTime(new Date()); emailMessage.setTitle(emailTemplate.getTitle()); diff --git a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewSummaryHelper.java b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewSummaryHelper.java index d55f198c..1aaac197 100644 --- a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewSummaryHelper.java +++ b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewSummaryHelper.java @@ -18,7 +18,6 @@ import com.alibaba.cola.statemachine.Action; import com.alibaba.cola.statemachine.Condition; import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.util.Date; @@ -35,9 +34,6 @@ @RequiredArgsConstructor public class InterviewSummaryHelper implements InterviewStateInternalTransitionHelper { - @Value("${spring.mail.username}") - private String achobetaEmail; - private final EmailSender emailSender; private final HtmlEngine htmlEngine; @@ -83,7 +79,6 @@ public Action getPerformActio // 封装 email EmailTemplateEnum emailTemplate = EmailTemplateEnum.INTERVIEW_SUMMARY; EmailMessage emailMessage = new EmailMessage(); - emailMessage.setSender(achobetaEmail); emailMessage.setCarbonCopy(); emailMessage.setCreateTime(new Date()); emailMessage.setTitle(emailTemplate.getTitle()); diff --git a/src/main/java/com/achobeta/domain/interview/machine/events/internal/InterviewStateNoticeHelper.java b/src/main/java/com/achobeta/domain/interview/machine/events/internal/InterviewStateNoticeHelper.java index ae5d3bbc..878f126e 100644 --- a/src/main/java/com/achobeta/domain/interview/machine/events/internal/InterviewStateNoticeHelper.java +++ b/src/main/java/com/achobeta/domain/interview/machine/events/internal/InterviewStateNoticeHelper.java @@ -18,7 +18,6 @@ import com.alibaba.cola.statemachine.Action; import com.alibaba.cola.statemachine.Condition; import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.util.Date; @@ -35,9 +34,6 @@ @RequiredArgsConstructor public class InterviewStateNoticeHelper implements InterviewStateInternalTransitionHelper{ - @Value("${spring.mail.username}") - private String achobetaEmail; - private final EmailSender emailSender; private final HtmlEngine htmlEngine; @@ -78,7 +74,6 @@ public Action getPerformActio // 封装 email EmailTemplateEnum emailTemplate = EmailTemplateEnum.INTERVIEW_NOTICE; EmailMessage emailMessage = new EmailMessage(); - emailMessage.setSender(achobetaEmail); emailMessage.setCarbonCopy(); emailMessage.setCreateTime(new Date()); emailMessage.setTitle(emailTemplate.getTitle()); diff --git a/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java b/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java index c0461613..a502c0f6 100644 --- a/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java +++ b/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java @@ -12,7 +12,6 @@ import com.achobeta.template.util.TemplateUtil; import com.achobeta.util.TimeUtil; import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.util.ArrayList; @@ -27,9 +26,6 @@ @RequiredArgsConstructor public class MessageSendWithEmailHandler extends MessageSendHandler { - @Value("${spring.mail.username}") - private String achobetaEmail; - private final EmailSender emailSender; private final HtmlEngine htmlEngine; @@ -53,7 +49,6 @@ private EmailMessage getNoticeMessage(String email, String tittle, String conten emailMessage.setTitle(MESSAGE_EMAIL_NOTICE.getTitle()); emailMessage.setRecipient(email); emailMessage.setCarbonCopy(); - emailMessage.setSender(achobetaEmail); //构造当前时间 String now = TimeUtil.getDateTime(new Date()); diff --git a/src/main/java/com/achobeta/domain/resumestate/machine/config/ResumeStateTransitionHelperConfig.java b/src/main/java/com/achobeta/domain/resumestate/machine/config/ResumeStateTransitionHelperConfig.java index 1ba4a5c6..ef83cb58 100644 --- a/src/main/java/com/achobeta/domain/resumestate/machine/config/ResumeStateTransitionHelperConfig.java +++ b/src/main/java/com/achobeta/domain/resumestate/machine/config/ResumeStateTransitionHelperConfig.java @@ -13,7 +13,6 @@ import com.alibaba.cola.statemachine.Action; import com.alibaba.cola.statemachine.Condition; import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -31,9 +30,6 @@ @RequiredArgsConstructor public class ResumeStateTransitionHelperConfig { - @Value("${spring.mail.username}") - private String achobetaEmail; - private final HtmlEngine htmlEngine; private final EmailSender emailSender; @@ -63,7 +59,6 @@ public Action resumeNotice() { // 封装 email EmailTemplateEnum emailTemplate = EmailTemplateEnum.RESUME_NOTICE; EmailMessage emailMessage = new EmailMessage(); - emailMessage.setSender(achobetaEmail); emailMessage.setCarbonCopy(); emailMessage.setCreateTime(new Date()); emailMessage.setTitle(emailTemplate.getTitle()); diff --git a/src/main/java/com/achobeta/domain/resumestate/machine/events/internal/ResumeConfirmHelper.java b/src/main/java/com/achobeta/domain/resumestate/machine/events/internal/ResumeConfirmHelper.java index e96a63ea..32888339 100644 --- a/src/main/java/com/achobeta/domain/resumestate/machine/events/internal/ResumeConfirmHelper.java +++ b/src/main/java/com/achobeta/domain/resumestate/machine/events/internal/ResumeConfirmHelper.java @@ -18,7 +18,6 @@ import com.alibaba.cola.statemachine.Condition; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.util.Date; @@ -38,9 +37,6 @@ public class ResumeConfirmHelper implements ResumeStateInternalTransitionHelper{ - @Value("${spring.mail.username}") - private String achobetaEmail; - private final EmailSender emailSender; private final HtmlEngine htmlEngine; @@ -92,7 +88,6 @@ public Action getPerformAction() { // 封装 email EmailTemplateEnum emailTemplate = EmailTemplateEnum.MEMBER_NOTICE; EmailMessage emailMessage = new EmailMessage(); - emailMessage.setSender(achobetaEmail); emailMessage.setCarbonCopy(); emailMessage.setCreateTime(new Date()); emailMessage.setTitle(emailTemplate.getTitle()); diff --git a/src/main/java/com/achobeta/email/factory/EmailSenderFactory.java b/src/main/java/com/achobeta/email/factory/EmailSenderFactory.java new file mode 100644 index 00000000..9a2a51c2 --- /dev/null +++ b/src/main/java/com/achobeta/email/factory/EmailSenderFactory.java @@ -0,0 +1,50 @@ +package com.achobeta.email.factory; + +import cn.hutool.core.util.RandomUtil; +import lombok.Setter; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; +import org.springframework.mail.javamail.JavaMailSenderImpl; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-10-13 + * Time: 15:22 + */ +@Configuration +@Setter +@ConfigurationProperties("ab.mail") +public class EmailSenderFactory implements InitializingBean { + + private List senders; + + private List senderList; + + @Override + public void afterPropertiesSet() throws Exception { + this.senderList = new ArrayList<>(); + Optional.ofNullable(senders).stream().flatMap(List::stream).forEach(sender -> { + // 邮件发送者 + JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl(); + javaMailSender.setDefaultEncoding(sender.getDefaultEncoding()); + javaMailSender.setHost(sender.getHost()); + javaMailSender.setPort(sender.getPort()); + javaMailSender.setProtocol(sender.getProtocol()); + javaMailSender.setUsername(sender.getUsername()); + javaMailSender.setPassword(sender.getPassword()); + javaMailSender.setJavaMailProperties(sender.getProperties()); + senderList.add(javaMailSender); + }); + } + + public JavaMailSenderImpl fetch() { + return senderList.get(RandomUtil.randomInt(senderList.size())); + } +} diff --git a/src/main/java/com/achobeta/email/factory/EmailSenderProperties.java b/src/main/java/com/achobeta/email/factory/EmailSenderProperties.java new file mode 100644 index 00000000..3d1eac2b --- /dev/null +++ b/src/main/java/com/achobeta/email/factory/EmailSenderProperties.java @@ -0,0 +1,24 @@ +package com.achobeta.email.factory; + +import lombok.Data; + +import java.util.Properties; + +@Data +public class EmailSenderProperties { + + private String username; + + private String password; + + private String host; + + private Integer port; + + private String protocol; + + private String defaultEncoding; + + private Properties properties; + +} \ No newline at end of file diff --git a/src/main/java/com/achobeta/email/model/po/EmailMessage.java b/src/main/java/com/achobeta/email/model/po/EmailMessage.java index b337c16d..4d4ae723 100644 --- a/src/main/java/com/achobeta/email/model/po/EmailMessage.java +++ b/src/main/java/com/achobeta/email/model/po/EmailMessage.java @@ -11,11 +11,11 @@ @Data public class EmailMessage implements Serializable { - private String sender; + private String sender; // 可以为空,默认按照邮件发送器实现的用户名 - String[] recipient; + private String[] recipient; - String[] carbonCopy; + private String[] carbonCopy; private String title; diff --git a/src/main/java/com/achobeta/email/sender/EmailSender.java b/src/main/java/com/achobeta/email/sender/EmailSender.java index 2a27d263..e63d2a46 100644 --- a/src/main/java/com/achobeta/email/sender/EmailSender.java +++ b/src/main/java/com/achobeta/email/sender/EmailSender.java @@ -1,6 +1,7 @@ package com.achobeta.email.sender; import com.achobeta.common.enums.GlobalServiceStatusCode; +import com.achobeta.email.factory.EmailSenderFactory; import com.achobeta.email.model.po.EmailAttachment; import com.achobeta.email.model.po.EmailMessage; import com.achobeta.exception.GlobalServiceException; @@ -8,9 +9,10 @@ import jakarta.mail.internet.MimeMessage; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.mail.javamail.JavaMailSender; +import org.springframework.mail.javamail.JavaMailSenderImpl; import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; import java.util.*; import java.util.function.Function; @@ -18,19 +20,25 @@ @Slf4j @Component @RequiredArgsConstructor -@SuppressWarnings({"SpringJavaInjectionPointsAutowiringInspection"}) public class EmailSender { - private final JavaMailSender javaMailSender; + private final EmailSenderFactory emailSenderFactory; public void send(String sender, String[] recipient, String[] carbonCopy, String title, String content, boolean isHtml, Date sentDate, List fileList) { // 封装对象 try { + // 获取邮件发送器实现 + JavaMailSenderImpl javaMailSender = emailSenderFactory.fetch(); + // 构造邮件 MimeMessage mimeMessage = javaMailSender.createMimeMessage(); MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, Boolean.TRUE); - mimeMessageHelper.setFrom(sender); + String from = Optional.ofNullable(sender) + .filter(StringUtils::hasText) + .or(() -> Optional.ofNullable(javaMailSender.getUsername())) + .orElseThrow(() -> new GlobalServiceException("无法确定发送者邮箱地址", GlobalServiceStatusCode.EMAIL_SEND_FAIL)); + mimeMessageHelper.setFrom(Objects.requireNonNull(from)); mimeMessageHelper.setCc(carbonCopy); mimeMessageHelper.setSubject(title); mimeMessageHelper.setSentDate(sentDate); From b1f5d7a268bfb8399b55af990fc96fca74d44370 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 13 Oct 2024 16:12:09 +0800 Subject: [PATCH 039/104] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=A4=9A?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8F=91=E9=80=81=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/achobeta/email/sender/EmailSender.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/achobeta/email/sender/EmailSender.java b/src/main/java/com/achobeta/email/sender/EmailSender.java index e63d2a46..11471f1f 100644 --- a/src/main/java/com/achobeta/email/sender/EmailSender.java +++ b/src/main/java/com/achobeta/email/sender/EmailSender.java @@ -37,6 +37,7 @@ public void send(String sender, String[] recipient, String[] carbonCopy, String from = Optional.ofNullable(sender) .filter(StringUtils::hasText) .or(() -> Optional.ofNullable(javaMailSender.getUsername())) + .filter(StringUtils::hasText) .orElseThrow(() -> new GlobalServiceException("无法确定发送者邮箱地址", GlobalServiceStatusCode.EMAIL_SEND_FAIL)); mimeMessageHelper.setFrom(Objects.requireNonNull(from)); mimeMessageHelper.setCc(carbonCopy); From b2ef655946099fdbd7cd4ba291b1fe2278fa715d Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 13 Oct 2024 16:38:46 +0800 Subject: [PATCH 040/104] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=A4=9A?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8F=91=E9=80=81=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/achobeta/common/enums/GlobalServiceStatusCode.java | 5 +++-- .../java/com/achobeta/email/factory/EmailSenderFactory.java | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/achobeta/common/enums/GlobalServiceStatusCode.java b/src/main/java/com/achobeta/common/enums/GlobalServiceStatusCode.java index 3d0521ec..ac88b26f 100644 --- a/src/main/java/com/achobeta/common/enums/GlobalServiceStatusCode.java +++ b/src/main/java/com/achobeta/common/enums/GlobalServiceStatusCode.java @@ -52,8 +52,9 @@ public enum GlobalServiceStatusCode { /* 邮箱错误 3001-4000 */ EMAIL_PATTERN_ERROR(3001, "邮箱格式错误"), - EMAIL_SEND_FAIL(3002, "邮箱发送失败"), - EMAIL_ATTACH_SEND_FAIL(3003, "邮箱附件发送失败"), + EMAIL_SENDER_NOT_EXISTS(3002, "邮箱发送器不存在"), + EMAIL_SEND_FAIL(3003, "邮箱发送失败"), + EMAIL_ATTACH_SEND_FAIL(3004, "邮箱附件发送失败"), EMAIL_NOT_EXIST_RECORD(3101, "邮箱不存在记录"), EMAIL_CAPTCHA_CODE_COUNT_EXHAUST(3103, "申请次数达到上限"), diff --git a/src/main/java/com/achobeta/email/factory/EmailSenderFactory.java b/src/main/java/com/achobeta/email/factory/EmailSenderFactory.java index 9a2a51c2..02ce89eb 100644 --- a/src/main/java/com/achobeta/email/factory/EmailSenderFactory.java +++ b/src/main/java/com/achobeta/email/factory/EmailSenderFactory.java @@ -1,11 +1,14 @@ package com.achobeta.email.factory; import cn.hutool.core.util.RandomUtil; +import com.achobeta.common.enums.GlobalServiceStatusCode; +import com.achobeta.exception.GlobalServiceException; import lombok.Setter; import org.springframework.beans.factory.InitializingBean; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; import org.springframework.mail.javamail.JavaMailSenderImpl; +import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.List; @@ -42,6 +45,9 @@ public void afterPropertiesSet() throws Exception { javaMailSender.setJavaMailProperties(sender.getProperties()); senderList.add(javaMailSender); }); + if(CollectionUtils.isEmpty(this.senderList)) { + throw new GlobalServiceException(GlobalServiceStatusCode.EMAIL_SENDER_NOT_EXISTS); + } } public JavaMailSenderImpl fetch() { From b0524062f71e94038ec36dd1530f63be36477db4 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 13 Oct 2024 17:36:00 +0800 Subject: [PATCH 041/104] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=A4=9A?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8F=91=E9=80=81=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/email/service/impl/EmailServiceImpl.java | 1 - .../events/internal/InterviewExperienceHelper.java | 1 - .../events/internal/InterviewSummaryHelper.java | 1 - .../events/internal/InterviewStateNoticeHelper.java | 1 - .../handler/ext/MessageSendWithEmailHandler.java | 1 - .../config/ResumeStateTransitionHelperConfig.java | 1 - .../machine/events/internal/ResumeConfirmHelper.java | 1 - .../achobeta/email/factory/EmailSenderFactory.java | 4 ++-- .../com/achobeta/email/model/po/EmailMessage.java | 11 +---------- .../java/com/achobeta/email/sender/EmailSender.java | 12 ++++++++---- 10 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/achobeta/domain/email/service/impl/EmailServiceImpl.java b/src/main/java/com/achobeta/domain/email/service/impl/EmailServiceImpl.java index dbb1e071..4bbd6151 100644 --- a/src/main/java/com/achobeta/domain/email/service/impl/EmailServiceImpl.java +++ b/src/main/java/com/achobeta/domain/email/service/impl/EmailServiceImpl.java @@ -98,7 +98,6 @@ private void buildEmailAndSend(String email, String code) { emailMessage.setCreateTime(new Date()); emailMessage.setTitle(CAPTCHA.getTitle()); emailMessage.setRecipient(email); - emailMessage.setCarbonCopy(); // 构造模板消息 VerificationCodeTemplate verificationCodeTemplate = VerificationCodeTemplate.builder() .code(code) diff --git a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java index 7b2171f9..9df836b6 100644 --- a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java +++ b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java @@ -85,7 +85,6 @@ public Action getPerformActio // 构造邮件消息 EmailTemplateEnum emailTemplate = EmailTemplateEnum.INTERVIEW_EXPERIENCE; EmailMessage emailMessage = new EmailMessage(); - emailMessage.setCarbonCopy(); emailMessage.setCreateTime(new Date()); emailMessage.setTitle(emailTemplate.getTitle()); emailMessage.setRecipient(simpleStudentVO.getEmail()); diff --git a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewSummaryHelper.java b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewSummaryHelper.java index 1aaac197..77599368 100644 --- a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewSummaryHelper.java +++ b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewSummaryHelper.java @@ -79,7 +79,6 @@ public Action getPerformActio // 封装 email EmailTemplateEnum emailTemplate = EmailTemplateEnum.INTERVIEW_SUMMARY; EmailMessage emailMessage = new EmailMessage(); - emailMessage.setCarbonCopy(); emailMessage.setCreateTime(new Date()); emailMessage.setTitle(emailTemplate.getTitle()); emailMessage.setRecipient(simpleStudentVO.getEmail()); diff --git a/src/main/java/com/achobeta/domain/interview/machine/events/internal/InterviewStateNoticeHelper.java b/src/main/java/com/achobeta/domain/interview/machine/events/internal/InterviewStateNoticeHelper.java index 878f126e..6157fc37 100644 --- a/src/main/java/com/achobeta/domain/interview/machine/events/internal/InterviewStateNoticeHelper.java +++ b/src/main/java/com/achobeta/domain/interview/machine/events/internal/InterviewStateNoticeHelper.java @@ -74,7 +74,6 @@ public Action getPerformActio // 封装 email EmailTemplateEnum emailTemplate = EmailTemplateEnum.INTERVIEW_NOTICE; EmailMessage emailMessage = new EmailMessage(); - emailMessage.setCarbonCopy(); emailMessage.setCreateTime(new Date()); emailMessage.setTitle(emailTemplate.getTitle()); emailMessage.setRecipient(simpleStudentVO.getEmail()); diff --git a/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java b/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java index a502c0f6..43413700 100644 --- a/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java +++ b/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java @@ -48,7 +48,6 @@ private EmailMessage getNoticeMessage(String email, String tittle, String conten emailMessage.setCreateTime(new Date()); emailMessage.setTitle(MESSAGE_EMAIL_NOTICE.getTitle()); emailMessage.setRecipient(email); - emailMessage.setCarbonCopy(); //构造当前时间 String now = TimeUtil.getDateTime(new Date()); diff --git a/src/main/java/com/achobeta/domain/resumestate/machine/config/ResumeStateTransitionHelperConfig.java b/src/main/java/com/achobeta/domain/resumestate/machine/config/ResumeStateTransitionHelperConfig.java index ef83cb58..5ef95e63 100644 --- a/src/main/java/com/achobeta/domain/resumestate/machine/config/ResumeStateTransitionHelperConfig.java +++ b/src/main/java/com/achobeta/domain/resumestate/machine/config/ResumeStateTransitionHelperConfig.java @@ -59,7 +59,6 @@ public Action resumeNotice() { // 封装 email EmailTemplateEnum emailTemplate = EmailTemplateEnum.RESUME_NOTICE; EmailMessage emailMessage = new EmailMessage(); - emailMessage.setCarbonCopy(); emailMessage.setCreateTime(new Date()); emailMessage.setTitle(emailTemplate.getTitle()); emailMessage.setRecipient(currentResume.getEmail()); diff --git a/src/main/java/com/achobeta/domain/resumestate/machine/events/internal/ResumeConfirmHelper.java b/src/main/java/com/achobeta/domain/resumestate/machine/events/internal/ResumeConfirmHelper.java index 32888339..f43f496d 100644 --- a/src/main/java/com/achobeta/domain/resumestate/machine/events/internal/ResumeConfirmHelper.java +++ b/src/main/java/com/achobeta/domain/resumestate/machine/events/internal/ResumeConfirmHelper.java @@ -88,7 +88,6 @@ public Action getPerformAction() { // 封装 email EmailTemplateEnum emailTemplate = EmailTemplateEnum.MEMBER_NOTICE; EmailMessage emailMessage = new EmailMessage(); - emailMessage.setCarbonCopy(); emailMessage.setCreateTime(new Date()); emailMessage.setTitle(emailTemplate.getTitle()); emailMessage.setRecipient(currentResume.getEmail()); diff --git a/src/main/java/com/achobeta/email/factory/EmailSenderFactory.java b/src/main/java/com/achobeta/email/factory/EmailSenderFactory.java index 02ce89eb..eaa5ab49 100644 --- a/src/main/java/com/achobeta/email/factory/EmailSenderFactory.java +++ b/src/main/java/com/achobeta/email/factory/EmailSenderFactory.java @@ -36,12 +36,12 @@ public void afterPropertiesSet() throws Exception { Optional.ofNullable(senders).stream().flatMap(List::stream).forEach(sender -> { // 邮件发送者 JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl(); - javaMailSender.setDefaultEncoding(sender.getDefaultEncoding()); javaMailSender.setHost(sender.getHost()); javaMailSender.setPort(sender.getPort()); - javaMailSender.setProtocol(sender.getProtocol()); javaMailSender.setUsername(sender.getUsername()); javaMailSender.setPassword(sender.getPassword()); + javaMailSender.setProtocol(sender.getProtocol()); + javaMailSender.setDefaultEncoding(sender.getDefaultEncoding()); javaMailSender.setJavaMailProperties(sender.getProperties()); senderList.add(javaMailSender); }); diff --git a/src/main/java/com/achobeta/email/model/po/EmailMessage.java b/src/main/java/com/achobeta/email/model/po/EmailMessage.java index 4d4ae723..76293103 100644 --- a/src/main/java/com/achobeta/email/model/po/EmailMessage.java +++ b/src/main/java/com/achobeta/email/model/po/EmailMessage.java @@ -15,7 +15,7 @@ public class EmailMessage implements Serializable { private String[] recipient; - private String[] carbonCopy; + private String[] carbonCopy; // 可以为空,默认是 sender,若 sender 也为空,默认按照邮件发送器实现的用户名 private String title; @@ -41,15 +41,6 @@ public void setCarbonCopy(String cc) { this.carbonCopy = new String[]{cc}; } - public String[] getRecipient() { - return recipient; - } - - - public String[] getCarbonCopy() { - return carbonCopy; - } - public String getRecipient(int i) { return recipient != null ? recipient[i] : null; } diff --git a/src/main/java/com/achobeta/email/sender/EmailSender.java b/src/main/java/com/achobeta/email/sender/EmailSender.java index 11471f1f..e26e713e 100644 --- a/src/main/java/com/achobeta/email/sender/EmailSender.java +++ b/src/main/java/com/achobeta/email/sender/EmailSender.java @@ -34,18 +34,22 @@ public void send(String sender, String[] recipient, String[] carbonCopy, // 构造邮件 MimeMessage mimeMessage = javaMailSender.createMimeMessage(); MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, Boolean.TRUE); + // 确定发送至邮箱地址 String from = Optional.ofNullable(sender) .filter(StringUtils::hasText) .or(() -> Optional.ofNullable(javaMailSender.getUsername())) .filter(StringUtils::hasText) .orElseThrow(() -> new GlobalServiceException("无法确定发送者邮箱地址", GlobalServiceStatusCode.EMAIL_SEND_FAIL)); - mimeMessageHelper.setFrom(Objects.requireNonNull(from)); - mimeMessageHelper.setCc(carbonCopy); + mimeMessageHelper.setFrom(from); + // 指定抄送人,避免一些情况导致发送邮件失败 + mimeMessageHelper.setCc(Optional.ofNullable(carbonCopy).filter(cc -> cc.length > 0).orElseGet(() -> new String[]{from})); + // 设置标题与内容 mimeMessageHelper.setSubject(title); + mimeMessageHelper.setText(content, isHtml); + // 设置发送时间(但大部分邮箱不支持此功能) mimeMessageHelper.setSentDate(sentDate); + // 设置接受者邮箱地址 mimeMessageHelper.setTo(recipient); - // 设置文本 - mimeMessageHelper.setText(content, isHtml); // 设置附件 for (EmailAttachment attachment : fileList) { if (Objects.nonNull(attachment)) { From 264570bf5ec17e762ac6f0fbdcaa78d413cf7260 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 13 Oct 2024 17:52:35 +0800 Subject: [PATCH 042/104] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/email/service/impl/EmailServiceImpl.java | 2 -- .../events/internal/InterviewExperienceHelper.java | 2 -- .../machine/events/internal/InterviewSummaryHelper.java | 2 -- .../events/internal/InterviewStateNoticeHelper.java | 2 -- .../message/handler/ext/MessageSendWithEmailHandler.java | 1 - .../machine/config/ResumeStateTransitionHelperConfig.java | 2 -- .../machine/events/internal/ResumeConfirmHelper.java | 2 -- .../java/com/achobeta/email/model/po/EmailMessage.java | 2 +- src/main/java/com/achobeta/email/sender/EmailSender.java | 8 ++++---- 9 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/achobeta/domain/email/service/impl/EmailServiceImpl.java b/src/main/java/com/achobeta/domain/email/service/impl/EmailServiceImpl.java index 4bbd6151..080de558 100644 --- a/src/main/java/com/achobeta/domain/email/service/impl/EmailServiceImpl.java +++ b/src/main/java/com/achobeta/domain/email/service/impl/EmailServiceImpl.java @@ -12,7 +12,6 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Optional; @@ -95,7 +94,6 @@ public void sendIdentifyingCode(String email, String code) { private void buildEmailAndSend(String email, String code) { // 封装 Email EmailMessage emailMessage = new EmailMessage(); - emailMessage.setCreateTime(new Date()); emailMessage.setTitle(CAPTCHA.getTitle()); emailMessage.setRecipient(email); // 构造模板消息 diff --git a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java index 9df836b6..1a2b730e 100644 --- a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java +++ b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java @@ -23,7 +23,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; -import java.util.Date; import java.util.LinkedList; import java.util.List; @@ -85,7 +84,6 @@ public Action getPerformActio // 构造邮件消息 EmailTemplateEnum emailTemplate = EmailTemplateEnum.INTERVIEW_EXPERIENCE; EmailMessage emailMessage = new EmailMessage(); - emailMessage.setCreateTime(new Date()); emailMessage.setTitle(emailTemplate.getTitle()); emailMessage.setRecipient(simpleStudentVO.getEmail()); diff --git a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewSummaryHelper.java b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewSummaryHelper.java index 77599368..f8d3ddb9 100644 --- a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewSummaryHelper.java +++ b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewSummaryHelper.java @@ -20,7 +20,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; -import java.util.Date; import java.util.List; /** @@ -79,7 +78,6 @@ public Action getPerformActio // 封装 email EmailTemplateEnum emailTemplate = EmailTemplateEnum.INTERVIEW_SUMMARY; EmailMessage emailMessage = new EmailMessage(); - emailMessage.setCreateTime(new Date()); emailMessage.setTitle(emailTemplate.getTitle()); emailMessage.setRecipient(simpleStudentVO.getEmail()); // 构造模板消息 diff --git a/src/main/java/com/achobeta/domain/interview/machine/events/internal/InterviewStateNoticeHelper.java b/src/main/java/com/achobeta/domain/interview/machine/events/internal/InterviewStateNoticeHelper.java index 6157fc37..79954801 100644 --- a/src/main/java/com/achobeta/domain/interview/machine/events/internal/InterviewStateNoticeHelper.java +++ b/src/main/java/com/achobeta/domain/interview/machine/events/internal/InterviewStateNoticeHelper.java @@ -20,7 +20,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; -import java.util.Date; import java.util.List; /** @@ -74,7 +73,6 @@ public Action getPerformActio // 封装 email EmailTemplateEnum emailTemplate = EmailTemplateEnum.INTERVIEW_NOTICE; EmailMessage emailMessage = new EmailMessage(); - emailMessage.setCreateTime(new Date()); emailMessage.setTitle(emailTemplate.getTitle()); emailMessage.setRecipient(simpleStudentVO.getEmail()); // 构造模板消息 diff --git a/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java b/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java index 43413700..85d68399 100644 --- a/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java +++ b/src/main/java/com/achobeta/domain/message/handler/ext/MessageSendWithEmailHandler.java @@ -45,7 +45,6 @@ public void handle(MessageSendDTO messageSendBody, CopyOnWriteArraySet attachmentInfoList) { // 封装 Email EmailMessage emailMessage = new EmailMessage(); - emailMessage.setCreateTime(new Date()); emailMessage.setTitle(MESSAGE_EMAIL_NOTICE.getTitle()); emailMessage.setRecipient(email); diff --git a/src/main/java/com/achobeta/domain/resumestate/machine/config/ResumeStateTransitionHelperConfig.java b/src/main/java/com/achobeta/domain/resumestate/machine/config/ResumeStateTransitionHelperConfig.java index 5ef95e63..90ec6036 100644 --- a/src/main/java/com/achobeta/domain/resumestate/machine/config/ResumeStateTransitionHelperConfig.java +++ b/src/main/java/com/achobeta/domain/resumestate/machine/config/ResumeStateTransitionHelperConfig.java @@ -16,7 +16,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import java.util.Date; import java.util.Optional; /** @@ -59,7 +58,6 @@ public Action resumeNotice() { // 封装 email EmailTemplateEnum emailTemplate = EmailTemplateEnum.RESUME_NOTICE; EmailMessage emailMessage = new EmailMessage(); - emailMessage.setCreateTime(new Date()); emailMessage.setTitle(emailTemplate.getTitle()); emailMessage.setRecipient(currentResume.getEmail()); // 构造模板消息 diff --git a/src/main/java/com/achobeta/domain/resumestate/machine/events/internal/ResumeConfirmHelper.java b/src/main/java/com/achobeta/domain/resumestate/machine/events/internal/ResumeConfirmHelper.java index f43f496d..47f891af 100644 --- a/src/main/java/com/achobeta/domain/resumestate/machine/events/internal/ResumeConfirmHelper.java +++ b/src/main/java/com/achobeta/domain/resumestate/machine/events/internal/ResumeConfirmHelper.java @@ -20,7 +20,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; -import java.util.Date; import java.util.List; import java.util.Optional; @@ -88,7 +87,6 @@ public Action getPerformAction() { // 封装 email EmailTemplateEnum emailTemplate = EmailTemplateEnum.MEMBER_NOTICE; EmailMessage emailMessage = new EmailMessage(); - emailMessage.setCreateTime(new Date()); emailMessage.setTitle(emailTemplate.getTitle()); emailMessage.setRecipient(currentResume.getEmail()); // 构造模板消息 diff --git a/src/main/java/com/achobeta/email/model/po/EmailMessage.java b/src/main/java/com/achobeta/email/model/po/EmailMessage.java index 76293103..4daf1cc3 100644 --- a/src/main/java/com/achobeta/email/model/po/EmailMessage.java +++ b/src/main/java/com/achobeta/email/model/po/EmailMessage.java @@ -15,7 +15,7 @@ public class EmailMessage implements Serializable { private String[] recipient; - private String[] carbonCopy; // 可以为空,默认是 sender,若 sender 也为空,默认按照邮件发送器实现的用户名 + private String[] carbonCopy; // 可以为空,默认是 recipient private String title; diff --git a/src/main/java/com/achobeta/email/sender/EmailSender.java b/src/main/java/com/achobeta/email/sender/EmailSender.java index e26e713e..1ae4754f 100644 --- a/src/main/java/com/achobeta/email/sender/EmailSender.java +++ b/src/main/java/com/achobeta/email/sender/EmailSender.java @@ -41,17 +41,17 @@ public void send(String sender, String[] recipient, String[] carbonCopy, .filter(StringUtils::hasText) .orElseThrow(() -> new GlobalServiceException("无法确定发送者邮箱地址", GlobalServiceStatusCode.EMAIL_SEND_FAIL)); mimeMessageHelper.setFrom(from); - // 指定抄送人,避免一些情况导致发送邮件失败 - mimeMessageHelper.setCc(Optional.ofNullable(carbonCopy).filter(cc -> cc.length > 0).orElseGet(() -> new String[]{from})); // 设置标题与内容 mimeMessageHelper.setSubject(title); mimeMessageHelper.setText(content, isHtml); // 设置发送时间(但大部分邮箱不支持此功能) - mimeMessageHelper.setSentDate(sentDate); + mimeMessageHelper.setSentDate(Optional.ofNullable(sentDate).orElseGet(Date::new)); // 设置接受者邮箱地址 mimeMessageHelper.setTo(recipient); + // 指定抄送人,避免一些情况导致发送邮件失败 + mimeMessageHelper.setCc(Optional.ofNullable(carbonCopy).filter(cc -> cc.length > 0).orElse(recipient)); // 设置附件 - for (EmailAttachment attachment : fileList) { + for (EmailAttachment attachment : Optional.ofNullable(fileList).orElseGet(ArrayList::new)) { if (Objects.nonNull(attachment)) { mimeMessageHelper.addAttachment(attachment.getFileName(), attachment); } From a7ca7f19f5a3213bf3b89bdac4e583b224bad1c1 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 13 Oct 2024 18:15:20 +0800 Subject: [PATCH 043/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/identifying-code-model.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/templates/identifying-code-model.html b/src/main/resources/templates/identifying-code-model.html index 6e7eb085..15909318 100644 --- a/src/main/resources/templates/identifying-code-model.html +++ b/src/main/resources/templates/identifying-code-model.html @@ -25,8 +25,8 @@

Code -

- +
+

Tips From 63421baa177ef080f3d00e0da975598a8389e5c1 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 13 Oct 2024 23:36:52 +0800 Subject: [PATCH 044/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/FeishuResourceServiceImpl.java | 4 +- .../websocket/MessageReceiveServer.java | 4 +- .../email/config/EmailSenderConfig.java | 27 +++++++++++++ .../EmailSenderProperties.java | 2 +- .../EmailSenderProvider.java} | 38 ++++++++++++------- .../provider/strategy/ProvideStrategy.java | 22 +++++++++++ .../strategy/RandomProvideStrategy.java | 25 ++++++++++++ .../strategy/RoundRobinProvideStrategy.java | 28 ++++++++++++++ .../achobeta/email/sender/EmailSender.java | 33 +++++++++------- 9 files changed, 152 insertions(+), 31 deletions(-) create mode 100644 src/main/java/com/achobeta/email/config/EmailSenderConfig.java rename src/main/java/com/achobeta/email/{factory => config}/EmailSenderProperties.java (89%) rename src/main/java/com/achobeta/email/{factory/EmailSenderFactory.java => provider/EmailSenderProvider.java} (58%) create mode 100644 src/main/java/com/achobeta/email/provider/strategy/ProvideStrategy.java create mode 100644 src/main/java/com/achobeta/email/provider/strategy/RandomProvideStrategy.java create mode 100644 src/main/java/com/achobeta/email/provider/strategy/RoundRobinProvideStrategy.java diff --git a/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuResourceServiceImpl.java b/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuResourceServiceImpl.java index d31a63fc..ea9364f3 100644 --- a/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuResourceServiceImpl.java +++ b/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuResourceServiceImpl.java @@ -66,8 +66,8 @@ public FeishuResource createAndGetFeishuResource(String ticket, String originalN @Override public void updateFeishuResource(Long id, ImportTask importTask) { FeishuResource feishuResource = FeishuResourceConverter.INSTANCE.importTaskToFeishuResource(importTask); - log.warn("任务状态 {},额外提示 {}, 任务若失败,失败的原因 {},参考 {}", ( - importTask.getJobStatus()), Arrays.toString(importTask.getExtra()), importTask.getJobErrorMsg(), + log.warn("任务状态 {},额外提示 {}, 任务若失败,失败的原因 {},参考 {}", + importTask.getJobStatus(), importTask.getExtra(), importTask.getJobErrorMsg(), "https://open.feishu.cn/document/server-docs/docs/drive-v1/import_task/get?appId=cli_a67eb2cebcf99013" ); log.warn("飞书资源 {},更新为 {}", id, feishuResource); diff --git a/src/main/java/com/achobeta/domain/message/handler/websocket/MessageReceiveServer.java b/src/main/java/com/achobeta/domain/message/handler/websocket/MessageReceiveServer.java index fac9ac63..e56be270 100644 --- a/src/main/java/com/achobeta/domain/message/handler/websocket/MessageReceiveServer.java +++ b/src/main/java/com/achobeta/domain/message/handler/websocket/MessageReceiveServer.java @@ -56,12 +56,12 @@ private static MessageSendHandlerChain buildMessageSendHandlerChain(MessageSendD String chainName = messageSendDTO.getMessageContent().getSendType() + MessageSendHandlerChain.CHAIN_BASE_NAME; judgeBeanIfExist(chainName); //初始化消息处理链路 - MessageSendHandlerChain sendHandlerChain = (MessageSendHandlerChain) SpringUtil.getBean(chainName); + MessageSendHandlerChain sendHandlerChain = SpringUtil.getBean(chainName, MessageSendHandlerChain.class); messageSendDTO.getSendTypeList().stream().forEach(sendType->{ //获取要发送的所有消息类型 String handlerBeanName=sendType+MessageSendHandler.HANDLER_BASE_NAME; judgeBeanIfExist(handlerBeanName); - sendHandlerChain.addHandler((MessageSendHandler)SpringUtil.getBean(handlerBeanName)); + sendHandlerChain.addHandler(SpringUtil.getBean(handlerBeanName, MessageSendHandler.class)); }); return sendHandlerChain; } diff --git a/src/main/java/com/achobeta/email/config/EmailSenderConfig.java b/src/main/java/com/achobeta/email/config/EmailSenderConfig.java new file mode 100644 index 00000000..88f72732 --- /dev/null +++ b/src/main/java/com/achobeta/email/config/EmailSenderConfig.java @@ -0,0 +1,27 @@ +package com.achobeta.email.config; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import java.util.List; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-10-13 + * Time: 22:14 + */ +@Setter +@Getter +@Configuration +@ConfigurationProperties("ab.mail") +public class EmailSenderConfig { + + private String strategy; + + private List senders; + +} diff --git a/src/main/java/com/achobeta/email/factory/EmailSenderProperties.java b/src/main/java/com/achobeta/email/config/EmailSenderProperties.java similarity index 89% rename from src/main/java/com/achobeta/email/factory/EmailSenderProperties.java rename to src/main/java/com/achobeta/email/config/EmailSenderProperties.java index 3d1eac2b..d824631d 100644 --- a/src/main/java/com/achobeta/email/factory/EmailSenderProperties.java +++ b/src/main/java/com/achobeta/email/config/EmailSenderProperties.java @@ -1,4 +1,4 @@ -package com.achobeta.email.factory; +package com.achobeta.email.config; import lombok.Data; diff --git a/src/main/java/com/achobeta/email/factory/EmailSenderFactory.java b/src/main/java/com/achobeta/email/provider/EmailSenderProvider.java similarity index 58% rename from src/main/java/com/achobeta/email/factory/EmailSenderFactory.java rename to src/main/java/com/achobeta/email/provider/EmailSenderProvider.java index eaa5ab49..c2942f63 100644 --- a/src/main/java/com/achobeta/email/factory/EmailSenderFactory.java +++ b/src/main/java/com/achobeta/email/provider/EmailSenderProvider.java @@ -1,13 +1,15 @@ -package com.achobeta.email.factory; +package com.achobeta.email.provider; -import cn.hutool.core.util.RandomUtil; +import cn.hutool.extra.spring.SpringUtil; import com.achobeta.common.enums.GlobalServiceStatusCode; +import com.achobeta.email.config.EmailSenderConfig; +import com.achobeta.email.config.EmailSenderProperties; +import com.achobeta.email.provider.strategy.ProvideStrategy; import com.achobeta.exception.GlobalServiceException; -import lombok.Setter; +import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.InitializingBean; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; import org.springframework.mail.javamail.JavaMailSenderImpl; +import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import java.util.ArrayList; @@ -19,20 +21,23 @@ * Description: * User: 马拉圈 * Date: 2024-10-13 - * Time: 15:22 + * Time: 22:50 */ -@Configuration -@Setter -@ConfigurationProperties("ab.mail") -public class EmailSenderFactory implements InitializingBean { +@Component +@RequiredArgsConstructor +public class EmailSenderProvider implements InitializingBean { - private List senders; + private final EmailSenderConfig emailSenderConfig; private List senderList; + private ProvideStrategy provideStrategy; + @Override public void afterPropertiesSet() throws Exception { + // 构造邮件发送器实现 this.senderList = new ArrayList<>(); + List senders = emailSenderConfig.getSenders(); Optional.ofNullable(senders).stream().flatMap(List::stream).forEach(sender -> { // 邮件发送者 JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl(); @@ -45,12 +50,19 @@ public void afterPropertiesSet() throws Exception { javaMailSender.setJavaMailProperties(sender.getProperties()); senderList.add(javaMailSender); }); + // 若不存在一个实现则抛出异常(启动项目时) if(CollectionUtils.isEmpty(this.senderList)) { throw new GlobalServiceException(GlobalServiceStatusCode.EMAIL_SENDER_NOT_EXISTS); } + // 初始化获取发送器实现的策略 + this.provideStrategy = SpringUtil.getBean( + emailSenderConfig.getStrategy() + ProvideStrategy.BASE_NAME, + ProvideStrategy.class + ); } - public JavaMailSenderImpl fetch() { - return senderList.get(RandomUtil.randomInt(senderList.size())); + public JavaMailSenderImpl provide() { + return provideStrategy.getSender(senderList); } + } diff --git a/src/main/java/com/achobeta/email/provider/strategy/ProvideStrategy.java b/src/main/java/com/achobeta/email/provider/strategy/ProvideStrategy.java new file mode 100644 index 00000000..128d5fe5 --- /dev/null +++ b/src/main/java/com/achobeta/email/provider/strategy/ProvideStrategy.java @@ -0,0 +1,22 @@ +package com.achobeta.email.provider.strategy; + +import jakarta.validation.constraints.NotEmpty; +import org.springframework.mail.javamail.JavaMailSenderImpl; +import org.springframework.validation.annotation.Validated; + +import java.util.List; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-10-13 + * Time: 22:22 + */ +@Validated +public interface ProvideStrategy { + + String BASE_NAME = "ProvideStrategy"; + + JavaMailSenderImpl getSender(@NotEmpty List senderList); +} diff --git a/src/main/java/com/achobeta/email/provider/strategy/RandomProvideStrategy.java b/src/main/java/com/achobeta/email/provider/strategy/RandomProvideStrategy.java new file mode 100644 index 00000000..42981dd9 --- /dev/null +++ b/src/main/java/com/achobeta/email/provider/strategy/RandomProvideStrategy.java @@ -0,0 +1,25 @@ +package com.achobeta.email.provider.strategy; + +import cn.hutool.core.util.RandomUtil; +import jakarta.validation.constraints.NotEmpty; +import org.springframework.mail.javamail.JavaMailSenderImpl; +import org.springframework.stereotype.Component; +import org.springframework.validation.annotation.Validated; + +import java.util.List; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-10-13 + * Time: 22:21 + */ +@Component +public class RandomProvideStrategy implements ProvideStrategy { + + @Override + public JavaMailSenderImpl getSender(List senderList) { + return senderList.get(RandomUtil.randomInt(senderList.size())); + } +} diff --git a/src/main/java/com/achobeta/email/provider/strategy/RoundRobinProvideStrategy.java b/src/main/java/com/achobeta/email/provider/strategy/RoundRobinProvideStrategy.java new file mode 100644 index 00000000..eb64a5c8 --- /dev/null +++ b/src/main/java/com/achobeta/email/provider/strategy/RoundRobinProvideStrategy.java @@ -0,0 +1,28 @@ +package com.achobeta.email.provider.strategy; + +import jakarta.validation.constraints.NotEmpty; +import org.springframework.mail.javamail.JavaMailSenderImpl; +import org.springframework.stereotype.Component; +import org.springframework.validation.annotation.Validated; + +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-10-13 + * Time: 22:28 + */ +@Component +public class RoundRobinProvideStrategy implements ProvideStrategy { + + private final static AtomicInteger COUNTER = new AtomicInteger(0); + + @Override + public JavaMailSenderImpl getSender(List senderList) { + return senderList.get(COUNTER.getAndIncrement() % senderList.size()); + } + +} diff --git a/src/main/java/com/achobeta/email/sender/EmailSender.java b/src/main/java/com/achobeta/email/sender/EmailSender.java index 1ae4754f..9e01a6d9 100644 --- a/src/main/java/com/achobeta/email/sender/EmailSender.java +++ b/src/main/java/com/achobeta/email/sender/EmailSender.java @@ -1,10 +1,11 @@ package com.achobeta.email.sender; import com.achobeta.common.enums.GlobalServiceStatusCode; -import com.achobeta.email.factory.EmailSenderFactory; import com.achobeta.email.model.po.EmailAttachment; import com.achobeta.email.model.po.EmailMessage; +import com.achobeta.email.provider.EmailSenderProvider; import com.achobeta.exception.GlobalServiceException; +import com.achobeta.util.TimeUtil; import jakarta.mail.MessagingException; import jakarta.mail.internet.MimeMessage; import lombok.RequiredArgsConstructor; @@ -22,41 +23,47 @@ @RequiredArgsConstructor public class EmailSender { - private final EmailSenderFactory emailSenderFactory; + private final EmailSenderProvider emailSenderProvider; public void send(String sender, String[] recipient, String[] carbonCopy, String title, String content, boolean isHtml, - Date sentDate, List fileList) { + Date sendDate, List fileList) { // 封装对象 try { // 获取邮件发送器实现 - JavaMailSenderImpl javaMailSender = emailSenderFactory.fetch(); + JavaMailSenderImpl javaMailSender = emailSenderProvider.provide(); // 构造邮件 MimeMessage mimeMessage = javaMailSender.createMimeMessage(); MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, Boolean.TRUE); // 确定发送至邮箱地址 - String from = Optional.ofNullable(sender) + sender = Optional.ofNullable(sender) .filter(StringUtils::hasText) .or(() -> Optional.ofNullable(javaMailSender.getUsername())) .filter(StringUtils::hasText) .orElseThrow(() -> new GlobalServiceException("无法确定发送者邮箱地址", GlobalServiceStatusCode.EMAIL_SEND_FAIL)); - mimeMessageHelper.setFrom(from); - // 设置标题与内容 - mimeMessageHelper.setSubject(title); - mimeMessageHelper.setText(content, isHtml); - // 设置发送时间(但大部分邮箱不支持此功能) - mimeMessageHelper.setSentDate(Optional.ofNullable(sentDate).orElseGet(Date::new)); + mimeMessageHelper.setFrom(sender); // 设置接受者邮箱地址 mimeMessageHelper.setTo(recipient); // 指定抄送人,避免一些情况导致发送邮件失败 - mimeMessageHelper.setCc(Optional.ofNullable(carbonCopy).filter(cc -> cc.length > 0).orElse(recipient)); + carbonCopy = Optional.ofNullable(carbonCopy).filter(cc -> cc.length > 0).orElse(recipient); + mimeMessageHelper.setCc(carbonCopy); + // 设置标题与内容 + mimeMessageHelper.setSubject(title); + mimeMessageHelper.setText(content, isHtml); // 设置附件 - for (EmailAttachment attachment : Optional.ofNullable(fileList).orElseGet(ArrayList::new)) { + fileList = Optional.ofNullable(fileList).orElseGet(ArrayList::new); + for (EmailAttachment attachment : fileList) { if (Objects.nonNull(attachment)) { mimeMessageHelper.addAttachment(attachment.getFileName(), attachment); } } + // 设置发送时间(但大部分邮箱不支持此功能) + sendDate = Optional.ofNullable(sendDate).orElseGet(Date::new); + mimeMessageHelper.setSentDate(sendDate); // 发送 + log.info("发送者 {},接收者 {},抄送人 {},标题 {},附件数 {},发送日期 {}", + sender, recipient, carbonCopy, title, fileList.size(), TimeUtil.getDateTime(sendDate) + ); javaMailSender.send(mimeMessage); } catch (MessagingException e) { throw new GlobalServiceException(e.getMessage(), GlobalServiceStatusCode.EMAIL_SEND_FAIL); From 4081093fa96fe962003528ec4d96d4962d152b65 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 13 Oct 2024 23:42:00 +0800 Subject: [PATCH 045/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/achobeta/domain/email/constants/EmailConstants.java | 2 ++ .../achobeta/domain/email/controller/EmailController.java | 5 +++-- .../feishu/service/impl/FeishuResourceServiceImpl.java | 1 - .../email/provider/strategy/RandomProvideStrategy.java | 2 -- .../email/provider/strategy/RoundRobinProvideStrategy.java | 2 -- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/achobeta/domain/email/constants/EmailConstants.java b/src/main/java/com/achobeta/domain/email/constants/EmailConstants.java index b59a96a7..96693765 100644 --- a/src/main/java/com/achobeta/domain/email/constants/EmailConstants.java +++ b/src/main/java/com/achobeta/domain/email/constants/EmailConstants.java @@ -6,6 +6,8 @@ */ public interface EmailConstants { + Integer EMAIL_VERIFICATION_CODE_LENGTH = 6; + /** * 验证码集合 */ diff --git a/src/main/java/com/achobeta/domain/email/controller/EmailController.java b/src/main/java/com/achobeta/domain/email/controller/EmailController.java index e6d15c2f..65b4f491 100644 --- a/src/main/java/com/achobeta/domain/email/controller/EmailController.java +++ b/src/main/java/com/achobeta/domain/email/controller/EmailController.java @@ -2,6 +2,7 @@ import cn.hutool.core.util.RandomUtil; import com.achobeta.common.SystemJsonResponse; +import com.achobeta.domain.email.constants.EmailConstants; import com.achobeta.domain.email.service.EmailService; import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotBlank; @@ -32,8 +33,8 @@ public class EmailController { */ @PostMapping("/code") public SystemJsonResponse emailIdentityCheck(@RequestParam("email") @NotBlank @Email(message = "邮箱非法") String email) { - // 生成 6位数 随机验证码 - String code = RandomUtil.randomNumbers(6); + // 生成随机验证码 + String code = RandomUtil.randomNumbers(EmailConstants.EMAIL_VERIFICATION_CODE_LENGTH); emailService.sendIdentifyingCode(email, code); // 能到这一步就成功了 log.info("发送验证码:{} -> email:{}", code, email); diff --git a/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuResourceServiceImpl.java b/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuResourceServiceImpl.java index ea9364f3..cee8a9b8 100644 --- a/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuResourceServiceImpl.java +++ b/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuResourceServiceImpl.java @@ -25,7 +25,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; -import java.util.Arrays; import java.util.Objects; import static com.achobeta.domain.feishu.constants.FeishuResourceConstants.*; diff --git a/src/main/java/com/achobeta/email/provider/strategy/RandomProvideStrategy.java b/src/main/java/com/achobeta/email/provider/strategy/RandomProvideStrategy.java index 42981dd9..0f8754af 100644 --- a/src/main/java/com/achobeta/email/provider/strategy/RandomProvideStrategy.java +++ b/src/main/java/com/achobeta/email/provider/strategy/RandomProvideStrategy.java @@ -1,10 +1,8 @@ package com.achobeta.email.provider.strategy; import cn.hutool.core.util.RandomUtil; -import jakarta.validation.constraints.NotEmpty; import org.springframework.mail.javamail.JavaMailSenderImpl; import org.springframework.stereotype.Component; -import org.springframework.validation.annotation.Validated; import java.util.List; diff --git a/src/main/java/com/achobeta/email/provider/strategy/RoundRobinProvideStrategy.java b/src/main/java/com/achobeta/email/provider/strategy/RoundRobinProvideStrategy.java index eb64a5c8..b632b626 100644 --- a/src/main/java/com/achobeta/email/provider/strategy/RoundRobinProvideStrategy.java +++ b/src/main/java/com/achobeta/email/provider/strategy/RoundRobinProvideStrategy.java @@ -1,9 +1,7 @@ package com.achobeta.email.provider.strategy; -import jakarta.validation.constraints.NotEmpty; import org.springframework.mail.javamail.JavaMailSenderImpl; import org.springframework.stereotype.Component; -import org.springframework.validation.annotation.Validated; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; From cd69e7f70251d7c176852357f68ac46f40807c60 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 13 Oct 2024 23:56:36 +0800 Subject: [PATCH 046/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/resource/digital_resource.sql | 1 - .../achobeta/domain/resource/constants/ResourceConstants.java | 1 - 2 files changed, 2 deletions(-) diff --git a/sql/resource/digital_resource.sql b/sql/resource/digital_resource.sql index e7f6b3f9..22059f6b 100644 --- a/sql/resource/digital_resource.sql +++ b/sql/resource/digital_resource.sql @@ -4,7 +4,6 @@ create table `digital_resource` `id` bigint primary key auto_increment comment '资源 id', `code` bigint unique not null comment '资源码', `user_id` bigint not null comment '上传文件的用户 id', - -- todo: 设置默认的权限等级 `access_level` int not null default 2 comment '访问权限', `original_name` varchar(100) not null comment '上传时的文件名', `file_name` varchar(256) not null comment '在对象存储服务中存储的对象名', diff --git a/src/main/java/com/achobeta/domain/resource/constants/ResourceConstants.java b/src/main/java/com/achobeta/domain/resource/constants/ResourceConstants.java index ad657b95..02bffd93 100644 --- a/src/main/java/com/achobeta/domain/resource/constants/ResourceConstants.java +++ b/src/main/java/com/achobeta/domain/resource/constants/ResourceConstants.java @@ -11,7 +11,6 @@ */ public interface ResourceConstants { - // todo: 设置默认的权限等级 ResourceAccessLevel DEFAULT_RESOURCE_ACCESS_LEVEL = ResourceAccessLevel.USER_ACCESS; ResourceAccessLevel DEFAULT_EXCEL_ACCESS_LEVEL = ResourceAccessLevel.FREE_ACCESS; From 6e7edb47543c2e9bc518c4128de76b8723328953 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Mon, 14 Oct 2024 10:15:33 +0800 Subject: [PATCH 047/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../achobeta/domain/interview/model/vo/InterviewVO.java | 3 +++ .../resources/mapper/interview/ext/InterviewExtMapper.xml | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/achobeta/domain/interview/model/vo/InterviewVO.java b/src/main/java/com/achobeta/domain/interview/model/vo/InterviewVO.java index 384432f3..b0f03b1b 100644 --- a/src/main/java/com/achobeta/domain/interview/model/vo/InterviewVO.java +++ b/src/main/java/com/achobeta/domain/interview/model/vo/InterviewVO.java @@ -2,6 +2,7 @@ import com.achobeta.domain.interview.enums.InterviewStatus; import com.achobeta.domain.schedule.model.vo.ScheduleVO; +import com.achobeta.domain.student.model.vo.SimpleStudentVO; import lombok.Data; /** @@ -22,4 +23,6 @@ public class InterviewVO { private ScheduleVO scheduleVO; + private SimpleStudentVO simpleStudentVO; + } diff --git a/src/main/resources/mapper/interview/ext/InterviewExtMapper.xml b/src/main/resources/mapper/interview/ext/InterviewExtMapper.xml index ddcba071..97a042e0 100644 --- a/src/main/resources/mapper/interview/ext/InterviewExtMapper.xml +++ b/src/main/resources/mapper/interview/ext/InterviewExtMapper.xml @@ -10,6 +10,8 @@ + @@ -22,14 +24,17 @@ select -- 面试预约与面试官多对多,在本条 sql 容易出现重复行 distinct i.id, i.title, i.status, - s.id s_id, s.participation_id s_participation_id, s.start_time s_start_time, s.end_time s_end_time + s.id s_id, s.participation_id s_participation_id, s.start_time s_start_time, s.end_time s_end_time, + from user m left join interviewer ir on ir.manager_id = m.id and ir.is_deleted = 0 and m.is_deleted = 0 left join interview_schedule s on ir.schedule_id = s.id and ir.is_deleted = 0 and s.is_deleted = 0 left join interview i on i.schedule_id = s.id and i.is_deleted = 0 and s.is_deleted = 0 left join activity_participation p on p.id = s.participation_id and p.is_deleted = 0 and s.is_deleted = 0 + left join user stu on p.stu_id = stu.id and p.is_deleted = 0 and stu.is_deleted = 0 left join recruitment_activity a on a.id = p.act_id and p.is_deleted = 0 and a.is_deleted = 0 left join recruitment_batch b on b.id = a.batch_id and a.is_deleted = 0 and b.is_deleted = 0 + left join stu_resume r on r.batch_id = b.id and r.user_id = stu.id and r.is_deleted = 0 and b.is_deleted = 0 and stu.is_deleted = 0 i.id is not null and m.is_deleted = 0 From 865e16e5b221162a2ccf4b98ee3ded1997bc6ea3 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Mon, 14 Oct 2024 11:19:31 +0800 Subject: [PATCH 048/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InterviewSummaryController.java | 2 +- .../controller/InterviewController.java | 15 +------------ .../interview/model/vo/InterviewDetailVO.java | 4 +--- .../interview/service/InterviewService.java | 2 -- .../service/impl/InterviewServiceImpl.java | 17 --------------- .../InterviewScheduleController.java | 17 +++++++++++++++ .../service/InterviewScheduleService.java | 3 +++ .../impl/InterviewScheduleServiceImpl.java | 21 +++++++++++++++++++ .../interview/ext/InterviewExtMapper.xml | 12 ++++++++--- 9 files changed, 53 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/achobeta/domain/evaluate/controller/InterviewSummaryController.java b/src/main/java/com/achobeta/domain/evaluate/controller/InterviewSummaryController.java index 8b01bb4e..1975f4b3 100644 --- a/src/main/java/com/achobeta/domain/evaluate/controller/InterviewSummaryController.java +++ b/src/main/java/com/achobeta/domain/evaluate/controller/InterviewSummaryController.java @@ -59,7 +59,7 @@ public SystemJsonResponse queryInterviewSummary(@PathVariable("interviewId") @No // 如果当前用户是普通用户,则判断是否可以查询活动的总结 UserHelper currentUser = BaseContext.getCurrentUser(); if(UserTypeEnum.USER.getCode().equals(currentUser.getRole())) { - Long stuId = interviewService.getInterviewDetail(interviewId).getStuId(); + Long stuId = interviewService.getInterviewDetail(interviewId).getSimpleStudentVO().getUserId(); if(!Objects.equals(stuId, currentUser.getUserId())) { throw new GlobalServiceException(GlobalServiceStatusCode.USER_NO_PERMISSION); } diff --git a/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java b/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java index 7de21cc6..220a2396 100644 --- a/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java +++ b/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java @@ -75,19 +75,6 @@ public SystemJsonResponse updateInterview(@Valid @RequestBody InterviewUpdateDTO return SystemJsonResponse.SYSTEM_SUCCESS(); } - @GetMapping("/reserve/{interviewId}") - public SystemJsonResponse interviewReserveApply(@PathVariable("interviewId") @NotNull Long interviewId, - @RequestParam(name = "mobile", required = false) @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号非法") String mobile) { - // 检查 - interviewService.checkInterviewExists(interviewId); - // 当前管理员 - Long managerId = BaseContext.getCurrentUser().getUserId(); - log.warn("管理员 {} 尝试预约面试 {}", managerId, interviewId); - // 预约会议 - InterviewReserveVO interviewReserveVO = interviewService.interviewReserveApply(interviewId, mobile); - return SystemJsonResponse.SYSTEM_SUCCESS(interviewReserveVO); - } - @GetMapping("/list/status") @Intercept(permit = {UserTypeEnum.ADMIN, UserTypeEnum.USER}) public SystemJsonResponse getInterviewStatusList() { @@ -190,7 +177,7 @@ public SystemJsonResponse getInterviewDetail(@PathVariable("interviewId") @NotNu InterviewDetailVO interviewDetail = interviewService.getInterviewDetail(interviewId); if(UserTypeEnum.USER.getCode().equals(currentUser.getRole())) { // 判断是否是当前用户的面试 - if(!Objects.equals(currentUser.getUserId(), interviewDetail.getStuId())) { + if(!Objects.equals(currentUser.getUserId(), interviewDetail.getSimpleStudentVO().getUserId())) { throw new GlobalServiceException(GlobalServiceStatusCode.USER_NO_PERMISSION); } // 对于普通用户,隐藏一些字段 diff --git a/src/main/java/com/achobeta/domain/interview/model/vo/InterviewDetailVO.java b/src/main/java/com/achobeta/domain/interview/model/vo/InterviewDetailVO.java index edf89b93..9fc34ef9 100644 --- a/src/main/java/com/achobeta/domain/interview/model/vo/InterviewDetailVO.java +++ b/src/main/java/com/achobeta/domain/interview/model/vo/InterviewDetailVO.java @@ -12,14 +12,12 @@ @Data public class InterviewDetailVO extends InterviewVO { - private Long stuId; - private String description; private String address; public void hidden() { - setStuId(null); + setSimpleStudentVO(null); } } diff --git a/src/main/java/com/achobeta/domain/interview/service/InterviewService.java b/src/main/java/com/achobeta/domain/interview/service/InterviewService.java index a1c33965..bc33f0bc 100644 --- a/src/main/java/com/achobeta/domain/interview/service/InterviewService.java +++ b/src/main/java/com/achobeta/domain/interview/service/InterviewService.java @@ -40,8 +40,6 @@ public interface InterviewService extends IService { Long getInterviewPaperId(Long interviewId); - InterviewReserveVO interviewReserveApply(Long interviewId, String mobile); - // 写入 ------------------------------------------ Long createInterview(InterviewCreateDTO interviewCreateDTO, Long managerId); diff --git a/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java b/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java index c445fd70..46a946a0 100644 --- a/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java +++ b/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java @@ -57,8 +57,6 @@ public class InterviewServiceImpl extends ServiceImpl { OnlineResourceVO printSituations(Long managerId, RecruitmentActivity activity, ResourceAccessLevel level, Boolean synchronous); + InterviewReserveVO interviewReserveApply(Long scheduleId, String title, String mobile); + // 写入 ------------------------------------------ Long createInterviewSchedule(Long managerId, Long participationId, Long startTime, Long endTime); diff --git a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java index 4d591f2b..fc072007 100644 --- a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java +++ b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java @@ -1,7 +1,11 @@ package com.achobeta.domain.schedule.service.impl; import com.achobeta.common.enums.GlobalServiceStatusCode; +import com.achobeta.domain.feishu.service.FeishuService; +import com.achobeta.domain.interview.model.converter.InterviewConverter; import com.achobeta.domain.interview.model.dto.InterviewConditionDTO; +import com.achobeta.domain.interview.model.vo.InterviewDetailVO; +import com.achobeta.domain.interview.model.vo.InterviewReserveVO; import com.achobeta.domain.interview.model.vo.InterviewVO; import com.achobeta.domain.interview.service.InterviewService; import com.achobeta.domain.recruit.model.converter.TimePeriodConverter; @@ -27,6 +31,7 @@ import com.achobeta.redis.lock.RedisLock; import com.achobeta.redis.lock.strategy.SimpleLockStrategy; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.lark.oapi.service.vc.v1.model.ApplyReserveRespBody; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -57,6 +62,8 @@ public class InterviewScheduleServiceImpl extends ServiceImpl - + select - i.id, i.title, i.description, i.status, i.address, p.stu_id, - s.id s_id, s.participation_id s_participation_id, s.start_time s_start_time, s.end_time s_end_time + i.id, i.title, i.description, i.status, i.address, + s.id s_id, s.participation_id s_participation_id, s.start_time s_start_time, s.end_time s_end_time, + from interview i left join interview_schedule s on i.schedule_id = s.id and i.is_deleted = 0 and s.is_deleted = 0 left join activity_participation p on p.id = s.participation_id and s.is_deleted = 0 and p.is_deleted = 0 + left join user stu on p.stu_id = stu.id and p.is_deleted = 0 and stu.is_deleted = 0 + left join recruitment_activity a on a.id = p.act_id and p.is_deleted = 0 and a.is_deleted = 0 + left join recruitment_batch b on b.id = a.batch_id and a.is_deleted = 0 and b.is_deleted = 0 + left join stu_resume r on r.batch_id = b.id and r.user_id = stu.id and r.is_deleted = 0 and b.is_deleted = 0 and stu.is_deleted = 0 where i.id = #{interviewId,jdbcType=BIGINT} and i.is_deleted = 0 From 4dcf77edff32cca299cc0cd8f47e9c93da86500e Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Mon, 14 Oct 2024 11:20:11 +0800 Subject: [PATCH 049/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/interview/controller/InterviewController.java | 6 ++++-- .../achobeta/domain/interview/service/InterviewService.java | 1 - .../domain/interview/service/impl/InterviewServiceImpl.java | 3 --- .../schedule/service/impl/InterviewScheduleServiceImpl.java | 1 - 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java b/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java index 220a2396..bced860e 100644 --- a/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java +++ b/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java @@ -10,7 +10,10 @@ import com.achobeta.domain.interview.model.converter.InterviewConverter; import com.achobeta.domain.interview.model.dto.*; import com.achobeta.domain.interview.model.entity.Interview; -import com.achobeta.domain.interview.model.vo.*; +import com.achobeta.domain.interview.model.vo.InterviewDetailVO; +import com.achobeta.domain.interview.model.vo.InterviewEventVO; +import com.achobeta.domain.interview.model.vo.InterviewStatusVO; +import com.achobeta.domain.interview.model.vo.InterviewVO; import com.achobeta.domain.interview.service.InterviewService; import com.achobeta.domain.paper.service.QuestionPaperService; import com.achobeta.domain.resource.constants.ResourceConstants; @@ -22,7 +25,6 @@ import com.achobeta.exception.GlobalServiceException; import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Pattern; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; diff --git a/src/main/java/com/achobeta/domain/interview/service/InterviewService.java b/src/main/java/com/achobeta/domain/interview/service/InterviewService.java index bc33f0bc..1837643c 100644 --- a/src/main/java/com/achobeta/domain/interview/service/InterviewService.java +++ b/src/main/java/com/achobeta/domain/interview/service/InterviewService.java @@ -8,7 +8,6 @@ import com.achobeta.domain.interview.model.dto.InterviewUpdateDTO; import com.achobeta.domain.interview.model.entity.Interview; import com.achobeta.domain.interview.model.vo.InterviewDetailVO; -import com.achobeta.domain.interview.model.vo.InterviewReserveVO; import com.achobeta.domain.interview.model.vo.InterviewVO; import com.achobeta.domain.resource.enums.ResourceAccessLevel; import com.achobeta.domain.resource.model.vo.OnlineResourceVO; diff --git a/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java b/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java index 46a946a0..716cc919 100644 --- a/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java +++ b/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java @@ -2,7 +2,6 @@ import com.achobeta.common.enums.GlobalServiceStatusCode; import com.achobeta.domain.evaluate.model.entity.InterviewQuestionScore; -import com.achobeta.domain.feishu.service.FeishuService; import com.achobeta.domain.interview.constants.InterviewConstants; import com.achobeta.domain.interview.enums.InterviewEvent; import com.achobeta.domain.interview.enums.InterviewStatus; @@ -16,7 +15,6 @@ import com.achobeta.domain.interview.model.entity.Interview; import com.achobeta.domain.interview.model.vo.InterviewDetailVO; import com.achobeta.domain.interview.model.vo.InterviewExcelTemplate; -import com.achobeta.domain.interview.model.vo.InterviewReserveVO; import com.achobeta.domain.interview.model.vo.InterviewVO; import com.achobeta.domain.interview.service.InterviewService; import com.achobeta.domain.paper.service.PaperQuestionLinkService; @@ -31,7 +29,6 @@ import com.achobeta.redis.lock.strategy.SimpleLockStrategy; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.toolkit.Db; -import com.lark.oapi.service.vc.v1.model.ApplyReserveRespBody; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java index fc072007..50614fe4 100644 --- a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java +++ b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java @@ -4,7 +4,6 @@ import com.achobeta.domain.feishu.service.FeishuService; import com.achobeta.domain.interview.model.converter.InterviewConverter; import com.achobeta.domain.interview.model.dto.InterviewConditionDTO; -import com.achobeta.domain.interview.model.vo.InterviewDetailVO; import com.achobeta.domain.interview.model.vo.InterviewReserveVO; import com.achobeta.domain.interview.model.vo.InterviewVO; import com.achobeta.domain.interview.service.InterviewService; From e98267277b4e0f4a0a8731d51f3f68654ba3fc3e Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Mon, 14 Oct 2024 12:29:43 +0800 Subject: [PATCH 050/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../machine/events/internal/InterviewExperienceHelper.java | 7 +------ .../machine/events/internal/InterviewSummaryHelper.java | 7 +------ .../events/internal/InterviewStateNoticeHelper.java | 4 +--- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java index 1a2b730e..0812f0ba 100644 --- a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java +++ b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java @@ -10,7 +10,6 @@ import com.achobeta.domain.interview.model.vo.InterviewDetailVO; import com.achobeta.domain.interview.service.InterviewService; import com.achobeta.domain.schedule.model.vo.ScheduleVO; -import com.achobeta.domain.schedule.service.InterviewScheduleService; import com.achobeta.domain.student.model.vo.SimpleStudentVO; import com.achobeta.email.enums.EmailTemplateEnum; import com.achobeta.email.model.po.EmailMessage; @@ -49,8 +48,6 @@ public class InterviewExperienceHelper implements InterviewStateInternalTransiti private final InterviewService interviewService; - private final InterviewScheduleService interviewScheduleService; - @Override public List getWithin() { return List.of( @@ -77,9 +74,7 @@ public Action getPerformActio Long interviewId = context.getInterview().getId(); InterviewDetailVO interviewDetail = interviewService.getInterviewDetail(interviewId); ScheduleVO interviewDetailScheduleVO = interviewDetail.getScheduleVO(); - SimpleStudentVO simpleStudentVO = interviewScheduleService - .getDetailActivityParticipation(interviewDetailScheduleVO.getParticipationId()) - .getSimpleStudentVO(); + SimpleStudentVO simpleStudentVO = interviewDetail.getSimpleStudentVO(); // 构造邮件消息 EmailTemplateEnum emailTemplate = EmailTemplateEnum.INTERVIEW_EXPERIENCE; diff --git a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewSummaryHelper.java b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewSummaryHelper.java index f8d3ddb9..c53254d2 100644 --- a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewSummaryHelper.java +++ b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewSummaryHelper.java @@ -9,7 +9,6 @@ import com.achobeta.domain.interview.machine.events.internal.InterviewStateInternalTransitionHelper; import com.achobeta.domain.interview.model.vo.InterviewDetailVO; import com.achobeta.domain.interview.service.InterviewService; -import com.achobeta.domain.schedule.service.InterviewScheduleService; import com.achobeta.domain.student.model.vo.SimpleStudentVO; import com.achobeta.email.enums.EmailTemplateEnum; import com.achobeta.email.model.po.EmailMessage; @@ -45,8 +44,6 @@ public class InterviewSummaryHelper implements InterviewStateInternalTransitionH private final InterviewService interviewService; - private final InterviewScheduleService interviewScheduleService; - @Override public List getWithin() { return List.of( @@ -72,9 +69,7 @@ public Action getPerformActio Long interviewId = context.getInterview().getId(); InterviewSummaryVO interviewSummaryVO = interviewSummaryService.queryInterviewSummaryByInterviewId(interviewId); InterviewDetailVO interviewDetail = interviewService.getInterviewDetail(interviewId); - SimpleStudentVO simpleStudentVO = interviewScheduleService - .getDetailActivityParticipation(interviewDetail.getScheduleVO().getParticipationId()) - .getSimpleStudentVO(); + SimpleStudentVO simpleStudentVO = interviewDetail.getSimpleStudentVO(); // 封装 email EmailTemplateEnum emailTemplate = EmailTemplateEnum.INTERVIEW_SUMMARY; EmailMessage emailMessage = new EmailMessage(); diff --git a/src/main/java/com/achobeta/domain/interview/machine/events/internal/InterviewStateNoticeHelper.java b/src/main/java/com/achobeta/domain/interview/machine/events/internal/InterviewStateNoticeHelper.java index 79954801..cf5d9511 100644 --- a/src/main/java/com/achobeta/domain/interview/machine/events/internal/InterviewStateNoticeHelper.java +++ b/src/main/java/com/achobeta/domain/interview/machine/events/internal/InterviewStateNoticeHelper.java @@ -7,7 +7,6 @@ import com.achobeta.domain.interview.model.vo.InterviewDetailVO; import com.achobeta.domain.interview.model.vo.InterviewNoticeTemplate; import com.achobeta.domain.interview.service.InterviewService; -import com.achobeta.domain.schedule.model.vo.ParticipationDetailVO; import com.achobeta.domain.schedule.model.vo.ScheduleVO; import com.achobeta.domain.schedule.service.InterviewScheduleService; import com.achobeta.domain.student.model.vo.SimpleStudentVO; @@ -68,8 +67,7 @@ public Action getPerformActio Interview currentInterview = context.getInterview(); InterviewDetailVO interviewDetail = interviewService.getInterviewDetail(currentInterview.getId()); ScheduleVO scheduleVO = interviewDetail.getScheduleVO(); - ParticipationDetailVO detailActivityParticipation = interviewScheduleService.getDetailActivityParticipation(scheduleVO.getParticipationId()); - SimpleStudentVO simpleStudentVO = detailActivityParticipation.getSimpleStudentVO(); + SimpleStudentVO simpleStudentVO = interviewDetail.getSimpleStudentVO(); // 封装 email EmailTemplateEnum emailTemplate = EmailTemplateEnum.INTERVIEW_NOTICE; EmailMessage emailMessage = new EmailMessage(); From 8d3c8d39654c50d2dd0b66ae8d266f43ca3462b2 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Mon, 14 Oct 2024 14:44:08 +0800 Subject: [PATCH 051/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/message-email-notice.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/templates/message-email-notice.html b/src/main/resources/templates/message-email-notice.html index a8b58919..91006bd7 100644 --- a/src/main/resources/templates/message-email-notice.html +++ b/src/main/resources/templates/message-email-notice.html @@ -31,7 +31,7 @@

Message Content:
- 亲爱的同学: + 亲爱的同学,你好:

From 5c5f9ebb9f52214071f3413a8aec5781adefda2c Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Mon, 14 Oct 2024 17:07:03 +0800 Subject: [PATCH 052/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/InterviewController.java | 4 +-- .../model/converter/InterviewConverter.java | 2 +- .../model/dao/mapper/InterviewMapper.java | 2 +- .../interview/service/InterviewService.java | 2 +- .../service/impl/InterviewServiceImpl.java | 4 +-- .../InterviewScheduleController.java | 5 ++- .../dao/mapper/InterviewScheduleMapper.java | 3 +- .../model/dao/mapper/InterviewerMapper.java | 7 ++++ .../model/vo/ScheduleInterviewerVO.java | 19 ++++++++++ .../service/InterviewScheduleService.java | 3 +- .../schedule/service/InterviewerService.java | 3 ++ .../impl/InterviewScheduleServiceImpl.java | 20 +++++++++-- .../service/impl/InterviewerServiceImpl.java | 13 +++++++ .../interview/ext/InterviewExtMapper.xml | 6 ++-- .../ext/InterviewScheduleExtMapper.xml | 32 +++++++---------- .../schedule/ext/InterviewerExtMapper.xml | 35 +++++++++++++++++++ 16 files changed, 121 insertions(+), 39 deletions(-) create mode 100644 src/main/java/com/achobeta/domain/schedule/model/vo/ScheduleInterviewerVO.java create mode 100644 src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml diff --git a/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java b/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java index bced860e..4c40b757 100644 --- a/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java +++ b/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java @@ -132,7 +132,7 @@ public SystemJsonResponse setPaperForInterview(@Valid @RequestBody InterviewPape @PostMapping("/list/manager/all") public SystemJsonResponse managerGetAllInterviewList(@Valid @RequestBody(required = false) InterviewConditionDTO interviewConditionDTO) { // 查询 - List interviewVOList = interviewService.managerGetInterviewList(null, InterviewConditionDTO.of(interviewConditionDTO)); + List interviewVOList = interviewService.managerGetInterviewList(null, InterviewConditionDTO.of(interviewConditionDTO)); return SystemJsonResponse.SYSTEM_SUCCESS(interviewVOList); } @@ -154,7 +154,7 @@ public SystemJsonResponse managerGetOwnInterviewList(@Valid @RequestBody(require // 获取当前管理员 id Long managerId = BaseContext.getCurrentUser().getUserId(); // 查询 - List interviewVOList = interviewService.managerGetInterviewList(managerId, InterviewConditionDTO.of(interviewConditionDTO)); + List interviewVOList = interviewService.managerGetInterviewList(managerId, InterviewConditionDTO.of(interviewConditionDTO)); return SystemJsonResponse.SYSTEM_SUCCESS(interviewVOList); } diff --git a/src/main/java/com/achobeta/domain/interview/model/converter/InterviewConverter.java b/src/main/java/com/achobeta/domain/interview/model/converter/InterviewConverter.java index d16ab1bb..4ba5d93d 100644 --- a/src/main/java/com/achobeta/domain/interview/model/converter/InterviewConverter.java +++ b/src/main/java/com/achobeta/domain/interview/model/converter/InterviewConverter.java @@ -39,6 +39,6 @@ public interface InterviewConverter { InterviewReserveVO feishuReserveToInterviewReserveVO(Reserve reserve); - List interviewVOListToInterviewExcelTemplateList(List interviewVOList); + List interviewVOListToInterviewExcelTemplateList(List interviewVOList); } diff --git a/src/main/java/com/achobeta/domain/interview/model/dao/mapper/InterviewMapper.java b/src/main/java/com/achobeta/domain/interview/model/dao/mapper/InterviewMapper.java index caa12348..0fe15a8e 100644 --- a/src/main/java/com/achobeta/domain/interview/model/dao/mapper/InterviewMapper.java +++ b/src/main/java/com/achobeta/domain/interview/model/dao/mapper/InterviewMapper.java @@ -17,7 +17,7 @@ */ public interface InterviewMapper extends BaseMapper { - List managerGetInterviewList(@Param("managerId") Long managerId, @Param("condition") InterviewConditionDTO interviewConditionDTO); + List managerGetInterviewList(@Param("managerId") Long managerId, @Param("condition") InterviewConditionDTO interviewConditionDTO); List userGetInterviewList(@Param("userId") Long userId, @Param("condition") InterviewConditionDTO interviewConditionDTO); diff --git a/src/main/java/com/achobeta/domain/interview/service/InterviewService.java b/src/main/java/com/achobeta/domain/interview/service/InterviewService.java index 1837643c..89f4c062 100644 --- a/src/main/java/com/achobeta/domain/interview/service/InterviewService.java +++ b/src/main/java/com/achobeta/domain/interview/service/InterviewService.java @@ -29,7 +29,7 @@ public interface InterviewService extends IService { List getInterviewListByScheduleId(Long scheduleId); - List managerGetInterviewList(Long managerId, InterviewConditionDTO condition); + List managerGetInterviewList(Long managerId, InterviewConditionDTO condition); OnlineResourceVO printAllInterviewList(Long managerId, InterviewConditionDTO condition, ResourceAccessLevel level, Boolean synchronous); diff --git a/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java b/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java index 716cc919..43dbe223 100644 --- a/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java +++ b/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java @@ -74,13 +74,13 @@ public List getInterviewListByScheduleId(Long scheduleId) { } @Override - public List managerGetInterviewList(Long managerId, InterviewConditionDTO condition) { + public List managerGetInterviewList(Long managerId, InterviewConditionDTO condition) { return interviewMapper.managerGetInterviewList(managerId, condition); } @Override public OnlineResourceVO printAllInterviewList(Long managerId, InterviewConditionDTO condition, ResourceAccessLevel level, Boolean synchronous) { - List interviewVOList = managerGetInterviewList(null, condition); + List interviewVOList = managerGetInterviewList(null, condition); // 上传表格到对象存储服务器 ExcelTemplateEnum achobetaInterviewAll = ExcelTemplateEnum.ACHOBETA_INTERVIEW_ALL; return resourceService.uploadExcel( diff --git a/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java b/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java index fdc26819..96dd1c66 100644 --- a/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java +++ b/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java @@ -15,7 +15,6 @@ import com.achobeta.domain.schedule.model.dto.ScheduleUpdateDTO; import com.achobeta.domain.schedule.model.vo.ParticipationDetailVO; import com.achobeta.domain.schedule.model.vo.ScheduleDetailVO; -import com.achobeta.domain.schedule.model.vo.ScheduleResumeVO; import com.achobeta.domain.schedule.model.vo.UserSituationVO; import com.achobeta.domain.schedule.service.InterviewScheduleService; import com.achobeta.domain.schedule.service.InterviewerService; @@ -116,14 +115,14 @@ public SystemJsonResponse getInterviewScheduleList(@Valid @RequestBody(required // 检测 Long managerId = BaseContext.getCurrentUser().getUserId(); // 查询 - List interviewScheduleList = interviewScheduleService.getInterviewScheduleList(managerId, InterviewConditionDTO.of(interviewConditionDTO)); + List interviewScheduleList = interviewScheduleService.getInterviewScheduleList(managerId, InterviewConditionDTO.of(interviewConditionDTO)); return SystemJsonResponse.SYSTEM_SUCCESS(interviewScheduleList); } @PostMapping("/list/all") public SystemJsonResponse getInterviewScheduleListAll(@Valid @RequestBody(required = false) InterviewConditionDTO interviewConditionDTO) { // 查询 - List interviewScheduleList = interviewScheduleService.getInterviewScheduleList(null, InterviewConditionDTO.of(interviewConditionDTO)); + List interviewScheduleList = interviewScheduleService.getInterviewScheduleList(null, InterviewConditionDTO.of(interviewConditionDTO)); return SystemJsonResponse.SYSTEM_SUCCESS(interviewScheduleList); } diff --git a/src/main/java/com/achobeta/domain/schedule/model/dao/mapper/InterviewScheduleMapper.java b/src/main/java/com/achobeta/domain/schedule/model/dao/mapper/InterviewScheduleMapper.java index e7b914b7..72d88808 100644 --- a/src/main/java/com/achobeta/domain/schedule/model/dao/mapper/InterviewScheduleMapper.java +++ b/src/main/java/com/achobeta/domain/schedule/model/dao/mapper/InterviewScheduleMapper.java @@ -4,7 +4,6 @@ import com.achobeta.domain.schedule.model.entity.InterviewSchedule; import com.achobeta.domain.schedule.model.vo.ParticipationScheduleVO; import com.achobeta.domain.schedule.model.vo.ScheduleDetailVO; -import com.achobeta.domain.schedule.model.vo.ScheduleResumeVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; @@ -18,7 +17,7 @@ */ public interface InterviewScheduleMapper extends BaseMapper { - List getInterviewScheduleList(@Param("managerId") Long managerId, @Param("condition") InterviewConditionDTO interviewConditionDTO); + List getInterviewScheduleList(@Param("managerId") Long managerId, @Param("condition") InterviewConditionDTO interviewConditionDTO); List getSituationsByActId(@Param("actId") Long actId); diff --git a/src/main/java/com/achobeta/domain/schedule/model/dao/mapper/InterviewerMapper.java b/src/main/java/com/achobeta/domain/schedule/model/dao/mapper/InterviewerMapper.java index b74aaf3c..e212940c 100644 --- a/src/main/java/com/achobeta/domain/schedule/model/dao/mapper/InterviewerMapper.java +++ b/src/main/java/com/achobeta/domain/schedule/model/dao/mapper/InterviewerMapper.java @@ -1,7 +1,11 @@ package com.achobeta.domain.schedule.model.dao.mapper; import com.achobeta.domain.schedule.model.entity.Interviewer; +import com.achobeta.domain.schedule.model.vo.ScheduleInterviewerVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * @author 马拉圈 @@ -11,6 +15,9 @@ */ public interface InterviewerMapper extends BaseMapper { + List getInterviewersByScheduleIds(@Param("scheduleIds") List scheduleIds); + + } diff --git a/src/main/java/com/achobeta/domain/schedule/model/vo/ScheduleInterviewerVO.java b/src/main/java/com/achobeta/domain/schedule/model/vo/ScheduleInterviewerVO.java new file mode 100644 index 00000000..37e7ce36 --- /dev/null +++ b/src/main/java/com/achobeta/domain/schedule/model/vo/ScheduleInterviewerVO.java @@ -0,0 +1,19 @@ +package com.achobeta.domain.schedule.model.vo; + +import lombok.Data; + +import java.util.List; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-10-14 + * Time: 16:20 + */ +@Data +public class ScheduleInterviewerVO extends ScheduleVO { + + private List interviewerVOList; + +} diff --git a/src/main/java/com/achobeta/domain/schedule/service/InterviewScheduleService.java b/src/main/java/com/achobeta/domain/schedule/service/InterviewScheduleService.java index bcaa9514..5775e404 100644 --- a/src/main/java/com/achobeta/domain/schedule/service/InterviewScheduleService.java +++ b/src/main/java/com/achobeta/domain/schedule/service/InterviewScheduleService.java @@ -8,7 +8,6 @@ import com.achobeta.domain.schedule.model.entity.InterviewSchedule; import com.achobeta.domain.schedule.model.vo.ParticipationDetailVO; import com.achobeta.domain.schedule.model.vo.ScheduleDetailVO; -import com.achobeta.domain.schedule.model.vo.ScheduleResumeVO; import com.achobeta.domain.schedule.model.vo.UserSituationVO; import com.baomidou.mybatisplus.extension.service.IService; @@ -26,7 +25,7 @@ public interface InterviewScheduleService extends IService { Optional getInterviewSchedule(Long scheduleId); - List getInterviewScheduleList(Long managerId, InterviewConditionDTO interviewConditionDTO); + List getInterviewScheduleList(Long managerId, InterviewConditionDTO interviewConditionDTO); /** * @param actId 活动 id diff --git a/src/main/java/com/achobeta/domain/schedule/service/InterviewerService.java b/src/main/java/com/achobeta/domain/schedule/service/InterviewerService.java index 2955d89b..1176d0d7 100644 --- a/src/main/java/com/achobeta/domain/schedule/service/InterviewerService.java +++ b/src/main/java/com/achobeta/domain/schedule/service/InterviewerService.java @@ -1,6 +1,7 @@ package com.achobeta.domain.schedule.service; import com.achobeta.domain.schedule.model.entity.Interviewer; +import com.achobeta.domain.schedule.model.vo.ScheduleInterviewerVO; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; @@ -19,6 +20,8 @@ public interface InterviewerService extends IService { List getInterviewersByScheduleId(Long scheduleId); + List getInterviewersByScheduleIds(List scheduleIds); + // 写入 ------------------------------------------ Long createInterviewer(Long managerId, Long scheduleId); diff --git a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java index 50614fe4..524205c9 100644 --- a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java +++ b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java @@ -87,8 +87,24 @@ public Optional getInterviewSchedule(Long scheduleId) { } @Override - public List getInterviewScheduleList(Long managerId, InterviewConditionDTO interviewConditionDTO) { - return interviewScheduleMapper.getInterviewScheduleList(managerId, interviewConditionDTO); + public List getInterviewScheduleList(Long managerId, InterviewConditionDTO interviewConditionDTO) { + Map scheduleDetailVOMap = interviewScheduleMapper.getInterviewScheduleList(managerId, interviewConditionDTO).stream().collect(Collectors.toMap( + ScheduleDetailVO::getId, + scheduleDetailVO -> { + // 处理 MP 给枚举默认值的情况 + List interviewVOList = scheduleDetailVO.getInterviewVOList().stream().filter(i -> Objects.nonNull(i.getId())).toList(); + scheduleDetailVO.setInterviewVOList(interviewVOList); + return scheduleDetailVO; + }, + (oldData, newData) -> newData + )); + List scheduleIds = new ArrayList<>(scheduleDetailVOMap.keySet()); + interviewerService.getInterviewersByScheduleIds(scheduleIds).stream() + .filter(scheduleDetailVO -> scheduleDetailVOMap.containsKey(scheduleDetailVO.getId())) + .forEach(scheduleDetailVO -> { + scheduleDetailVOMap.get(scheduleDetailVO.getId()).setInterviewerVOList(scheduleDetailVO.getInterviewerVOList()); + }); + return new ArrayList<>(scheduleDetailVOMap.values()); } /** diff --git a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewerServiceImpl.java b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewerServiceImpl.java index bbe0e702..d59a737e 100644 --- a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewerServiceImpl.java +++ b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewerServiceImpl.java @@ -3,12 +3,15 @@ import com.achobeta.common.enums.GlobalServiceStatusCode; import com.achobeta.domain.schedule.model.dao.mapper.InterviewerMapper; import com.achobeta.domain.schedule.model.entity.Interviewer; +import com.achobeta.domain.schedule.model.vo.ScheduleInterviewerVO; import com.achobeta.domain.schedule.service.InterviewerService; import com.achobeta.exception.GlobalServiceException; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -22,6 +25,8 @@ public class InterviewerServiceImpl extends ServiceImpl implements InterviewerService{ + private final InterviewerMapper interviewerMapper; + @Override public Optional getInterviewer(Long managerId, Long scheduleId) { return this.lambdaQuery() @@ -37,6 +42,14 @@ public List getInterviewersByScheduleId(Long scheduleId) { .list(); } + @Override + public List getInterviewersByScheduleIds(List scheduleIds) { + if(CollectionUtils.isEmpty(scheduleIds)) { + return new ArrayList<>(); + } + return interviewerMapper.getInterviewersByScheduleIds(scheduleIds); + } + @Override public Long createInterviewer(Long managerId, Long scheduleId) { return getInterviewer(managerId, scheduleId).orElseGet(() -> { diff --git a/src/main/resources/mapper/interview/ext/InterviewExtMapper.xml b/src/main/resources/mapper/interview/ext/InterviewExtMapper.xml index da48a2f1..d948d170 100644 --- a/src/main/resources/mapper/interview/ext/InterviewExtMapper.xml +++ b/src/main/resources/mapper/interview/ext/InterviewExtMapper.xml @@ -17,14 +17,12 @@ - - select -- 面试预约与面试官多对多,在本条 sql 容易出现重复行 - distinct i.id, i.title, i.status, + distinct i.id, i.title, i.status, i.description, i.address, s.id s_id, s.participation_id s_participation_id, s.start_time s_start_time, s.end_time s_end_time, from user m diff --git a/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml b/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml index f23092fe..959e1f24 100644 --- a/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml +++ b/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml @@ -4,15 +4,6 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - @@ -25,7 +16,8 @@ - + + @@ -34,19 +26,21 @@ - select -- 面试预约与面试官多对多,在本条 sql 容易出现重复行 distinct s.id, s.participation_id, s.start_time, s.end_time, + i.id i_id, i.title i_title, i.status i_status, from user m - left join interviewer i on m.id = i.manager_id and m.is_deleted = 0 and i.is_deleted = 0 - left join interview_schedule s on i.schedule_id = s.id and i.is_deleted = 0 and s.is_deleted = 0 - left join activity_participation p on p.id = s.participation_id and p.is_deleted = 0 and s.is_deleted = 0 - left join user stu on p.stu_id = stu.id and p.is_deleted = 0 and stu.is_deleted = 0 - left join recruitment_activity a on p.act_id = a.id and p.is_deleted = 0 and a.is_deleted = 0 - left join recruitment_batch b on a.batch_id = b.id and a.is_deleted = 0 and b.is_deleted = 0 - left join stu_resume r on r.batch_id = b.id and r.user_id = stu.id and r.is_deleted = 0 and b.is_deleted = 0 and stu.is_deleted = 0 + left join interviewer ir on m.id = ir.manager_id and m.is_deleted = 0 and ir.is_deleted = 0 + left join interview_schedule s on ir.schedule_id = s.id and ir.is_deleted = 0 and s.is_deleted = 0 + left join activity_participation p on p.id = s.participation_id and p.is_deleted = 0 and s.is_deleted = 0 + left join user stu on p.stu_id = stu.id and p.is_deleted = 0 and stu.is_deleted = 0 + left join recruitment_activity a on p.act_id = a.id and p.is_deleted = 0 and a.is_deleted = 0 + left join recruitment_batch b on a.batch_id = b.id and a.is_deleted = 0 and b.is_deleted = 0 + left join stu_resume r on r.batch_id = b.id and r.user_id = stu.id and r.is_deleted = 0 and b.is_deleted = 0 and stu.is_deleted = 0 + left join interview i on i.schedule_id = s.id and i.is_deleted = 0 and s.is_deleted = 0 s.id is not null and m.is_deleted = 0 @@ -93,7 +87,7 @@ + select + s.id, s.participation_id, s.start_time, s.end_time, + m.id m_id, m.username m_username, m.nickname m_nickname, m.email m_email, + m.phone_number m_phone_number, m.avatar m_acvtar + from interview_schedule s + left join interviewer i on s.id = i.schedule_id and s.is_deleted = 0 and i.is_deleted = 0 + left join user m on m.id = i.manager_id and m.is_deleted = 0 and i.is_deleted = 0 + where s.is_deleted = 0 and m.id is not null and s.id + + #{scheduleId,jdbcType=BIGINT} + + order by s.start_time asc, s.end_time asc + + + From 733e28d9a74ea31131d5b51044bc8beab4056635 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Mon, 14 Oct 2024 20:11:34 +0800 Subject: [PATCH 053/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml b/src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml index 8637160c..ca2aad77 100644 --- a/src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml +++ b/src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml @@ -25,7 +25,7 @@ from interview_schedule s left join interviewer i on s.id = i.schedule_id and s.is_deleted = 0 and i.is_deleted = 0 left join user m on m.id = i.manager_id and m.is_deleted = 0 and i.is_deleted = 0 - where s.is_deleted = 0 and m.id is not null and s.id + where s.is_deleted = 0 and m.id is not null and s.id #{scheduleId,jdbcType=BIGINT} From d6dda26a0871fa510280af91d10267f5bebc91ea Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Mon, 14 Oct 2024 20:24:29 +0800 Subject: [PATCH 054/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schedule/service/impl/InterviewScheduleServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java index 524205c9..202cb69b 100644 --- a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java +++ b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java @@ -104,7 +104,9 @@ public List getInterviewScheduleList(Long managerId, Interview .forEach(scheduleDetailVO -> { scheduleDetailVOMap.get(scheduleDetailVO.getId()).setInterviewerVOList(scheduleDetailVO.getInterviewerVOList()); }); - return new ArrayList<>(scheduleDetailVOMap.values()); + return scheduleDetailVOMap.values().stream() + .sorted(Comparator.comparingLong(s -> s.getStartTime().getTime())) + .toList(); } /** From 559200825b1f50675faa69f98eaf311e4ab865ff Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Mon, 14 Oct 2024 22:09:04 +0800 Subject: [PATCH 055/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/evaluate/model/vo/InterviewRankVO.java | 8 ++++---- .../mapper/evaluate/ext/InterviewSummaryExtMapper.xml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/achobeta/domain/evaluate/model/vo/InterviewRankVO.java b/src/main/java/com/achobeta/domain/evaluate/model/vo/InterviewRankVO.java index f7a9f8bc..6975f419 100644 --- a/src/main/java/com/achobeta/domain/evaluate/model/vo/InterviewRankVO.java +++ b/src/main/java/com/achobeta/domain/evaluate/model/vo/InterviewRankVO.java @@ -14,16 +14,16 @@ @Data public class InterviewRankVO { - private Long summaryId; - - private Integer average; - private Long interviewId; private String title; private InterviewStatus status; + private Long summaryId; + + private Integer sum; + private SimpleStudentVO simpleStudentVO; } diff --git a/src/main/resources/mapper/evaluate/ext/InterviewSummaryExtMapper.xml b/src/main/resources/mapper/evaluate/ext/InterviewSummaryExtMapper.xml index cb2106dc..2af42994 100644 --- a/src/main/resources/mapper/evaluate/ext/InterviewSummaryExtMapper.xml +++ b/src/main/resources/mapper/evaluate/ext/InterviewSummaryExtMapper.xml @@ -5,18 +5,18 @@ - - + + From b8258e423e4ac5576cfe763d68a8a510194a8ff1 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 01:09:34 +0800 Subject: [PATCH 056/104] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=8F=82?= =?UTF-8?q?=E4=B8=8E=E6=83=85=E5=86=B5=E7=9A=84=E6=9D=A1=E4=BB=B6=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/MessageServiceImpl.java | 8 ++--- .../condition/allmatch/StatusCondition.java | 6 ++-- .../condition/anymatch/GradeCondition.java | 6 ++-- .../condition/anymatch/UserIdCondition.java | 6 ++-- .../InterviewScheduleController.java | 32 ++++++++++++++++--- .../dao/mapper/InterviewScheduleMapper.java | 3 +- .../schedule/model/dto/SituationQueryDTO.java | 29 +++++++++++++++++ .../service/InterviewScheduleService.java | 10 ++++-- .../impl/InterviewScheduleServiceImpl.java | 26 ++++++++++++--- .../users/service/impl/MemberServiceImpl.java | 1 + .../mapper/member/ext/MemberExtMapper.xml | 3 +- .../ext/InterviewScheduleExtMapper.xml | 9 ++++-- 12 files changed, 106 insertions(+), 33 deletions(-) create mode 100644 src/main/java/com/achobeta/domain/schedule/model/dto/SituationQueryDTO.java diff --git a/src/main/java/com/achobeta/domain/message/service/impl/MessageServiceImpl.java b/src/main/java/com/achobeta/domain/message/service/impl/MessageServiceImpl.java index f665fa43..4821c7a6 100644 --- a/src/main/java/com/achobeta/domain/message/service/impl/MessageServiceImpl.java +++ b/src/main/java/com/achobeta/domain/message/service/impl/MessageServiceImpl.java @@ -25,10 +25,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.concurrent.CopyOnWriteArraySet; /** @@ -64,7 +61,8 @@ public QueryStuListVO queryStuListByCondition(QueryStuListDTO queryStuDTO) { @Override public List queryStuList(Long batchId, List userIds) { - List stuResumeList = stuResumeService.queryStuList(batchId, userIds.stream().distinct().toList()); + List stuIds = Optional.ofNullable(userIds).stream().flatMap(Collection::stream).distinct().filter(Objects::nonNull).toList(); + List stuResumeList = stuResumeService.queryStuList(batchId, stuIds); return messageConverter.stuResumeListToStuBaseInfoDTOList(stuResumeList); } diff --git a/src/main/java/com/achobeta/domain/recruit/model/condition/allmatch/StatusCondition.java b/src/main/java/com/achobeta/domain/recruit/model/condition/allmatch/StatusCondition.java index a509681e..ee796a67 100644 --- a/src/main/java/com/achobeta/domain/recruit/model/condition/allmatch/StatusCondition.java +++ b/src/main/java/com/achobeta/domain/recruit/model/condition/allmatch/StatusCondition.java @@ -18,11 +18,9 @@ public class StatusCondition extends ArrayList implements StudentCondit @Override public Predicate predicate() { - return stuResume -> this - .stream() + return stuResume -> this.stream() .filter(Objects::nonNull) - .anyMatch(status -> status.equals(stuResume.getStatus().getCode())) - ; + .anyMatch(status -> status.equals(stuResume.getStatus().getCode())); } } diff --git a/src/main/java/com/achobeta/domain/recruit/model/condition/anymatch/GradeCondition.java b/src/main/java/com/achobeta/domain/recruit/model/condition/anymatch/GradeCondition.java index 40fde831..b9e5fddf 100644 --- a/src/main/java/com/achobeta/domain/recruit/model/condition/anymatch/GradeCondition.java +++ b/src/main/java/com/achobeta/domain/recruit/model/condition/anymatch/GradeCondition.java @@ -18,10 +18,8 @@ public class GradeCondition extends ArrayList implements StudentConditi @Override public Predicate predicate() { - return stuResume -> this - .stream() + return stuResume -> this.stream() .filter(Objects::nonNull) - .anyMatch(grade -> grade.equals(stuResume.getGrade())) - ; + .anyMatch(grade -> grade.equals(stuResume.getGrade())); } } diff --git a/src/main/java/com/achobeta/domain/recruit/model/condition/anymatch/UserIdCondition.java b/src/main/java/com/achobeta/domain/recruit/model/condition/anymatch/UserIdCondition.java index 599efb2a..54953fbb 100644 --- a/src/main/java/com/achobeta/domain/recruit/model/condition/anymatch/UserIdCondition.java +++ b/src/main/java/com/achobeta/domain/recruit/model/condition/anymatch/UserIdCondition.java @@ -18,10 +18,8 @@ public class UserIdCondition extends ArrayList implements StudentCondition @Override public Predicate predicate() { - return stuResume -> this - .stream() + return stuResume -> this.stream() .filter(Objects::nonNull) - .anyMatch(userId -> userId.equals(stuResume.getUserId())) - ; + .anyMatch(userId -> userId.equals(stuResume.getUserId())); } } diff --git a/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java b/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java index 96dd1c66..230e4103 100644 --- a/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java +++ b/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java @@ -5,7 +5,6 @@ import com.achobeta.common.enums.UserTypeEnum; import com.achobeta.domain.interview.model.dto.InterviewConditionDTO; import com.achobeta.domain.interview.model.vo.InterviewReserveVO; -import com.achobeta.domain.recruit.model.entity.RecruitmentActivity; import com.achobeta.domain.recruit.service.ActivityParticipationService; import com.achobeta.domain.recruit.service.RecruitmentActivityService; import com.achobeta.domain.resource.constants.ResourceConstants; @@ -13,6 +12,7 @@ import com.achobeta.domain.resource.model.vo.OnlineResourceVO; import com.achobeta.domain.schedule.model.dto.ScheduleDTO; import com.achobeta.domain.schedule.model.dto.ScheduleUpdateDTO; +import com.achobeta.domain.schedule.model.dto.SituationQueryDTO; import com.achobeta.domain.schedule.model.vo.ParticipationDetailVO; import com.achobeta.domain.schedule.model.vo.ScheduleDetailVO; import com.achobeta.domain.schedule.model.vo.UserSituationVO; @@ -28,7 +28,9 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.util.Collection; import java.util.List; +import java.util.Objects; import java.util.Optional; /** @@ -137,7 +139,18 @@ public SystemJsonResponse getUserParticipationSituationByActId(@PathVariable("ac // 检测 recruitmentActivityService.checkRecruitmentActivityExists(actId); // 获取参与本次招新活动的所有用户参与和预约情况 - UserSituationVO situations = interviewScheduleService.getSituationsByActId(actId); + UserSituationVO situations = interviewScheduleService.querySituations(actId); + return SystemJsonResponse.SYSTEM_SUCCESS(situations); + } + + @PostMapping("/situations") + public SystemJsonResponse querySituations(@Valid @RequestBody SituationQueryDTO situationQueryDTO) { + // 检测 + recruitmentActivityService.checkRecruitmentActivityExists(situationQueryDTO.getActId()); + List statusList = Optional.ofNullable(situationQueryDTO.getStatusList()).stream().flatMap(Collection::stream).filter(Objects::nonNull).toList(); + situationQueryDTO.setStatusList(statusList); + // 获取参与本次招新活动的所有用户参与和预约情况 + UserSituationVO situations = interviewScheduleService.querySituations(situationQueryDTO); return SystemJsonResponse.SYSTEM_SUCCESS(situations); } @@ -146,11 +159,22 @@ public SystemJsonResponse printUserParticipationSituationByActId(@PathVariable(" @RequestParam(name = "level", required = false) Integer level, @RequestParam(name = "synchronous", required = false) Boolean synchronous) { // 检测 - RecruitmentActivity activity = recruitmentActivityService.checkAndGetRecruitmentActivity(actId); ResourceAccessLevel accessLevel = Optional.ofNullable(level).map(ResourceAccessLevel::get).orElse(ResourceConstants.DEFAULT_EXCEL_ACCESS_LEVEL); // 打印表格 Long managerId = BaseContext.getCurrentUser().getUserId(); - OnlineResourceVO onlineResourceVO = interviewScheduleService.printSituations(managerId, activity, accessLevel, synchronous); + OnlineResourceVO onlineResourceVO = interviewScheduleService.printSituations(managerId, actId, accessLevel, synchronous); + return SystemJsonResponse.SYSTEM_SUCCESS(onlineResourceVO); + } + + @PostMapping("/print/situations") + public SystemJsonResponse printUserParticipationSituations(@Valid @RequestBody SituationQueryDTO situationQueryDTO, + @RequestParam(name = "level", required = false) Integer level, + @RequestParam(name = "synchronous", required = false) Boolean synchronous) { + // 检测 + ResourceAccessLevel accessLevel = Optional.ofNullable(level).map(ResourceAccessLevel::get).orElse(ResourceConstants.DEFAULT_EXCEL_ACCESS_LEVEL); + // 打印表格 + Long managerId = BaseContext.getCurrentUser().getUserId(); + OnlineResourceVO onlineResourceVO = interviewScheduleService.printSituations(managerId, situationQueryDTO, accessLevel, synchronous); return SystemJsonResponse.SYSTEM_SUCCESS(onlineResourceVO); } diff --git a/src/main/java/com/achobeta/domain/schedule/model/dao/mapper/InterviewScheduleMapper.java b/src/main/java/com/achobeta/domain/schedule/model/dao/mapper/InterviewScheduleMapper.java index 72d88808..ab6b937c 100644 --- a/src/main/java/com/achobeta/domain/schedule/model/dao/mapper/InterviewScheduleMapper.java +++ b/src/main/java/com/achobeta/domain/schedule/model/dao/mapper/InterviewScheduleMapper.java @@ -1,6 +1,7 @@ package com.achobeta.domain.schedule.model.dao.mapper; import com.achobeta.domain.interview.model.dto.InterviewConditionDTO; +import com.achobeta.domain.schedule.model.dto.SituationQueryDTO; import com.achobeta.domain.schedule.model.entity.InterviewSchedule; import com.achobeta.domain.schedule.model.vo.ParticipationScheduleVO; import com.achobeta.domain.schedule.model.vo.ScheduleDetailVO; @@ -19,7 +20,7 @@ public interface InterviewScheduleMapper extends BaseMapper { List getInterviewScheduleList(@Param("managerId") Long managerId, @Param("condition") InterviewConditionDTO interviewConditionDTO); - List getSituationsByActId(@Param("actId") Long actId); + List querySituations(@Param("condition") SituationQueryDTO situationQueryDTO); ParticipationScheduleVO getSituationsByParticipationId(@Param("participationId") Long participationId); diff --git a/src/main/java/com/achobeta/domain/schedule/model/dto/SituationQueryDTO.java b/src/main/java/com/achobeta/domain/schedule/model/dto/SituationQueryDTO.java new file mode 100644 index 00000000..38bf8ea7 --- /dev/null +++ b/src/main/java/com/achobeta/domain/schedule/model/dto/SituationQueryDTO.java @@ -0,0 +1,29 @@ +package com.achobeta.domain.schedule.model.dto; + +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-10-15 + * Time: 0:14 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SituationQueryDTO { + + @NotNull(message = "活动 id 不能为空") + private Long actId; + +// @NotEmpty(message = "状态列表不能为空") + private List statusList; + +} diff --git a/src/main/java/com/achobeta/domain/schedule/service/InterviewScheduleService.java b/src/main/java/com/achobeta/domain/schedule/service/InterviewScheduleService.java index 5775e404..e13451e8 100644 --- a/src/main/java/com/achobeta/domain/schedule/service/InterviewScheduleService.java +++ b/src/main/java/com/achobeta/domain/schedule/service/InterviewScheduleService.java @@ -2,9 +2,9 @@ import com.achobeta.domain.interview.model.dto.InterviewConditionDTO; import com.achobeta.domain.interview.model.vo.InterviewReserveVO; -import com.achobeta.domain.recruit.model.entity.RecruitmentActivity; import com.achobeta.domain.resource.enums.ResourceAccessLevel; import com.achobeta.domain.resource.model.vo.OnlineResourceVO; +import com.achobeta.domain.schedule.model.dto.SituationQueryDTO; import com.achobeta.domain.schedule.model.entity.InterviewSchedule; import com.achobeta.domain.schedule.model.vo.ParticipationDetailVO; import com.achobeta.domain.schedule.model.vo.ScheduleDetailVO; @@ -35,13 +35,17 @@ public interface InterviewScheduleService extends IService { * 3. 学生面试预约情况 * 并统计各个时间段选中次数 */ - UserSituationVO getSituationsByActId(Long actId); + UserSituationVO querySituations(Long actId); + + UserSituationVO querySituations(SituationQueryDTO situationQueryDTO); ScheduleDetailVO getInterviewScheduleDetail(Long scheduleId); ParticipationDetailVO getDetailActivityParticipation(Long participationId); - OnlineResourceVO printSituations(Long managerId, RecruitmentActivity activity, ResourceAccessLevel level, Boolean synchronous); + OnlineResourceVO printSituations(Long managerId, Long actId, ResourceAccessLevel level, Boolean synchronous); + + OnlineResourceVO printSituations(Long managerId, SituationQueryDTO situationQueryDTO, ResourceAccessLevel level, Boolean synchronous); InterviewReserveVO interviewReserveApply(Long scheduleId, String title, String mobile); diff --git a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java index 202cb69b..ccab5cfa 100644 --- a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java +++ b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java @@ -14,6 +14,7 @@ import com.achobeta.domain.recruit.model.vo.TimePeriodCountVO; import com.achobeta.domain.recruit.model.vo.TimePeriodVO; import com.achobeta.domain.recruit.service.ActivityParticipationService; +import com.achobeta.domain.recruit.service.RecruitmentActivityService; import com.achobeta.domain.recruit.service.TimePeriodService; import com.achobeta.domain.resource.enums.ExcelTemplateEnum; import com.achobeta.domain.resource.enums.ResourceAccessLevel; @@ -21,6 +22,7 @@ import com.achobeta.domain.resource.service.ResourceService; import com.achobeta.domain.schedule.model.converter.SituationConverter; import com.achobeta.domain.schedule.model.dao.mapper.InterviewScheduleMapper; +import com.achobeta.domain.schedule.model.dto.SituationQueryDTO; import com.achobeta.domain.schedule.model.entity.InterviewSchedule; import com.achobeta.domain.schedule.model.entity.Interviewer; import com.achobeta.domain.schedule.model.vo.*; @@ -57,6 +59,8 @@ public class InterviewScheduleServiceImpl extends ServiceImpl getInterviewScheduleList(Long managerId, Interview * 4. 构造返回值返回 */ @Override - public UserSituationVO getSituationsByActId(Long actId) { + public UserSituationVO querySituations(Long actId) { + return querySituations(new SituationQueryDTO(actId, null)); + } + + @Override + public UserSituationVO querySituations(SituationQueryDTO situationQueryDTO) { // periodId --> 时间段计数器 - Map countMap = timePeriodService.getTimePeriodsByActId(actId) + Map countMap = timePeriodService.getTimePeriodsByActId(situationQueryDTO.getActId()) .stream() .collect(Collectors.toMap( TimePeriodVO::getId, @@ -126,7 +135,7 @@ public UserSituationVO getSituationsByActId(Long actId) { (oldData, newData) -> newData) ); // participationId --> 用户预约情况 - Map userParticipationVOMap = interviewScheduleMapper.getSituationsByActId(actId) + Map userParticipationVOMap = interviewScheduleMapper.querySituations(situationQueryDTO) .stream() .collect(Collectors.toMap( ParticipationScheduleVO::getParticipationId, @@ -199,10 +208,16 @@ public ParticipationDetailVO getDetailActivityParticipation(Long participationId } @Override - public OnlineResourceVO printSituations(Long managerId, RecruitmentActivity activity, ResourceAccessLevel level, Boolean synchronous) { + public OnlineResourceVO printSituations(Long managerId, Long actId, ResourceAccessLevel level, Boolean synchronous) { + return printSituations(managerId, new SituationQueryDTO(actId, null), level, synchronous); + } + + @Override + public OnlineResourceVO printSituations(Long managerId, SituationQueryDTO situationQueryDTO, ResourceAccessLevel level, Boolean synchronous) { + RecruitmentActivity activity = recruitmentActivityService.checkAndGetRecruitmentActivity(situationQueryDTO.getActId()); // 构造数据 Map resultMap = new LinkedHashMap<>(); - getSituationsByActId(activity.getId()).getUserParticipationVOS().forEach(situation -> { + querySituations(situationQueryDTO).getUserParticipationVOS().forEach(situation -> { ActivitySituationExcelTemplate activitySituationExcelTemplate = new ActivitySituationExcelTemplate(); activitySituationExcelTemplate.setTimePeriodVOS(situation.getTimePeriodVOS()); activitySituationExcelTemplate.setScheduleVOS(situation.getScheduleVOS()); @@ -227,6 +242,7 @@ public OnlineResourceVO printSituations(Long managerId, RecruitmentActivity acti activity.getTitle(), synchronous ); + } @Override diff --git a/src/main/java/com/achobeta/domain/users/service/impl/MemberServiceImpl.java b/src/main/java/com/achobeta/domain/users/service/impl/MemberServiceImpl.java index 2691a82f..fe6da17b 100644 --- a/src/main/java/com/achobeta/domain/users/service/impl/MemberServiceImpl.java +++ b/src/main/java/com/achobeta/domain/users/service/impl/MemberServiceImpl.java @@ -90,6 +90,7 @@ public List queryMemberList(Long batchId) { return memberMapper.queryMemberList(batchId) .stream() .peek(member -> { + // 处理 MP 给枚举设置默认值的现象 if(Objects.isNull(member.getId())) { member.setSimpleStudentVO(null); } diff --git a/src/main/resources/mapper/member/ext/MemberExtMapper.xml b/src/main/resources/mapper/member/ext/MemberExtMapper.xml index 1c25ae76..052062bd 100644 --- a/src/main/resources/mapper/member/ext/MemberExtMapper.xml +++ b/src/main/resources/mapper/member/ext/MemberExtMapper.xml @@ -26,7 +26,7 @@ m.id, m.manager_id, m.parent_id, stu.username u_username, stu.nickname u_nickname, stu.email u_email, stu.phone_number u_phone_number, - stu.user_type u_user_type, stu.avatar u_avatar, + stu.user_type u_user_type, stu.avatar u_avatar, stu.create_time, from user stu left join member m on stu.id = m.manager_id and stu.is_deleted = 0 and m.is_deleted = 0 @@ -37,6 +37,7 @@ and r.batch_id = #{batchId,jdbcType=BIGINT} + order by stu.create_time diff --git a/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml b/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml index 959e1f24..60416aff 100644 --- a/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml +++ b/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml @@ -56,7 +56,7 @@ order by s.start_time asc, s.end_time asc - select p.id, s.id s_id, s.participation_id s_participation_id, s.start_time s_start_time, s.end_time s_end_time, @@ -66,7 +66,12 @@ left join recruitment_batch b on a.batch_id = b.id and a.is_deleted = 0 and b.is_deleted = 0 left join stu_resume r on r.batch_id = b.id and r.user_id = stu.id and r.is_deleted = 0 and b.is_deleted = 0 and stu.is_deleted = 0 left join interview_schedule s on s.participation_id = p.id and s.is_deleted = 0 and p.is_deleted = 0 - where a.id = #{actId,jdbcType=BIGINT} and r.id is not null and p.is_deleted = 0 + + a.id = #{condition.actId,jdbcType=BIGINT} and r.id is not null and p.is_deleted = 0 + + #{status,jdbcType=BIGINT} + + order by s.start_time asc, s.end_time asc From b0ad528a343c227149dc2f5b8f4fe0fa0206c7e8 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 01:10:10 +0800 Subject: [PATCH 057/104] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../achobeta/domain/schedule/model/dto/SituationQueryDTO.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/achobeta/domain/schedule/model/dto/SituationQueryDTO.java b/src/main/java/com/achobeta/domain/schedule/model/dto/SituationQueryDTO.java index 38bf8ea7..5c3dc36b 100644 --- a/src/main/java/com/achobeta/domain/schedule/model/dto/SituationQueryDTO.java +++ b/src/main/java/com/achobeta/domain/schedule/model/dto/SituationQueryDTO.java @@ -1,6 +1,5 @@ package com.achobeta.domain.schedule.model.dto; -import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; From eacfa57c6739fc59e5e19c6dcb067548408325e0 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 01:16:14 +0800 Subject: [PATCH 058/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml b/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml index 60416aff..a07abe9f 100644 --- a/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml +++ b/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml @@ -68,6 +68,7 @@ left join interview_schedule s on s.participation_id = p.id and s.is_deleted = 0 and p.is_deleted = 0 a.id = #{condition.actId,jdbcType=BIGINT} and r.id is not null and p.is_deleted = 0 + -- and r.status 放在外面,foreach 内部为空导致没有 in,可能会因为 r.status 为 0 而没有查询到一些行 #{status,jdbcType=BIGINT} From df22afe1fa5b3826a3576fad6819c94af2e90712 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 10:21:35 +0800 Subject: [PATCH 059/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InterviewScheduleController.java | 25 ------------------- .../service/InterviewScheduleService.java | 14 +++++++---- .../impl/InterviewScheduleServiceImpl.java | 12 ++------- 3 files changed, 11 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java b/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java index 230e4103..88e113d0 100644 --- a/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java +++ b/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java @@ -131,41 +131,16 @@ public SystemJsonResponse getInterviewScheduleListAll(@Valid @RequestBody(requir /** * 管理员查看用户参与和预约情况 * - * @param actId - * @return */ - @GetMapping("/situations/{actId}") - public SystemJsonResponse getUserParticipationSituationByActId(@PathVariable("actId") @NotNull Long actId) { - // 检测 - recruitmentActivityService.checkRecruitmentActivityExists(actId); - // 获取参与本次招新活动的所有用户参与和预约情况 - UserSituationVO situations = interviewScheduleService.querySituations(actId); - return SystemJsonResponse.SYSTEM_SUCCESS(situations); - } - @PostMapping("/situations") public SystemJsonResponse querySituations(@Valid @RequestBody SituationQueryDTO situationQueryDTO) { // 检测 recruitmentActivityService.checkRecruitmentActivityExists(situationQueryDTO.getActId()); - List statusList = Optional.ofNullable(situationQueryDTO.getStatusList()).stream().flatMap(Collection::stream).filter(Objects::nonNull).toList(); - situationQueryDTO.setStatusList(statusList); // 获取参与本次招新活动的所有用户参与和预约情况 UserSituationVO situations = interviewScheduleService.querySituations(situationQueryDTO); return SystemJsonResponse.SYSTEM_SUCCESS(situations); } - @GetMapping("/print/situations/{actId}") - public SystemJsonResponse printUserParticipationSituationByActId(@PathVariable("actId") @NotNull Long actId, - @RequestParam(name = "level", required = false) Integer level, - @RequestParam(name = "synchronous", required = false) Boolean synchronous) { - // 检测 - ResourceAccessLevel accessLevel = Optional.ofNullable(level).map(ResourceAccessLevel::get).orElse(ResourceConstants.DEFAULT_EXCEL_ACCESS_LEVEL); - // 打印表格 - Long managerId = BaseContext.getCurrentUser().getUserId(); - OnlineResourceVO onlineResourceVO = interviewScheduleService.printSituations(managerId, actId, accessLevel, synchronous); - return SystemJsonResponse.SYSTEM_SUCCESS(onlineResourceVO); - } - @PostMapping("/print/situations") public SystemJsonResponse printUserParticipationSituations(@Valid @RequestBody SituationQueryDTO situationQueryDTO, @RequestParam(name = "level", required = false) Integer level, diff --git a/src/main/java/com/achobeta/domain/schedule/service/InterviewScheduleService.java b/src/main/java/com/achobeta/domain/schedule/service/InterviewScheduleService.java index e13451e8..4b6a3ff7 100644 --- a/src/main/java/com/achobeta/domain/schedule/service/InterviewScheduleService.java +++ b/src/main/java/com/achobeta/domain/schedule/service/InterviewScheduleService.java @@ -28,23 +28,27 @@ public interface InterviewScheduleService extends IService { List getInterviewScheduleList(Long managerId, InterviewConditionDTO interviewConditionDTO); /** - * @param actId 活动 id + * @param situationQueryDTO 查询条件 * @return 学生们参与情况,每一个学生包括: * 1. 学生的基础信息 * 2. 学生时间段选择情况 * 3. 学生面试预约情况 * 并统计各个时间段选中次数 */ - UserSituationVO querySituations(Long actId); - UserSituationVO querySituations(SituationQueryDTO situationQueryDTO); ScheduleDetailVO getInterviewScheduleDetail(Long scheduleId); ParticipationDetailVO getDetailActivityParticipation(Long participationId); - OnlineResourceVO printSituations(Long managerId, Long actId, ResourceAccessLevel level, Boolean synchronous); - + /** + * 打印参与情况为表格 + * @param managerId 管理员 id + * @param situationQueryDTO 查询条件 + * @param level 资源等级 + * @param synchronous 是否同步飞书 + * @return 链接 + */ OnlineResourceVO printSituations(Long managerId, SituationQueryDTO situationQueryDTO, ResourceAccessLevel level, Boolean synchronous); InterviewReserveVO interviewReserveApply(Long scheduleId, String title, String mobile); diff --git a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java index ccab5cfa..1f5cd44b 100644 --- a/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java +++ b/src/main/java/com/achobeta/domain/schedule/service/impl/InterviewScheduleServiceImpl.java @@ -119,13 +119,10 @@ public List getInterviewScheduleList(Long managerId, Interview * 3. 根据活动的预约情况得到 participationIds,查询每个学生的时间段选择情况,通过 map 设置到 VO 对象里并进行时间段次数统计 * 4. 构造返回值返回 */ - @Override - public UserSituationVO querySituations(Long actId) { - return querySituations(new SituationQueryDTO(actId, null)); - } - @Override public UserSituationVO querySituations(SituationQueryDTO situationQueryDTO) { + List statusList = Optional.ofNullable(situationQueryDTO.getStatusList()).stream().flatMap(Collection::stream).filter(Objects::nonNull).toList(); + situationQueryDTO.setStatusList(statusList); // periodId --> 时间段计数器 Map countMap = timePeriodService.getTimePeriodsByActId(situationQueryDTO.getActId()) .stream() @@ -207,11 +204,6 @@ public ParticipationDetailVO getDetailActivityParticipation(Long participationId }).orElseThrow(() -> new GlobalServiceException(GlobalServiceStatusCode.ACTIVITY_PARTICIPATION_NOT_EXISTS)); } - @Override - public OnlineResourceVO printSituations(Long managerId, Long actId, ResourceAccessLevel level, Boolean synchronous) { - return printSituations(managerId, new SituationQueryDTO(actId, null), level, synchronous); - } - @Override public OnlineResourceVO printSituations(Long managerId, SituationQueryDTO situationQueryDTO, ResourceAccessLevel level, Boolean synchronous) { RecruitmentActivity activity = recruitmentActivityService.checkAndGetRecruitmentActivity(situationQueryDTO.getActId()); From 89de8ed17950d7610565fed9ea6f5bfbe6f4573d Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 10:23:05 +0800 Subject: [PATCH 060/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/schedule/controller/InterviewScheduleController.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java b/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java index 88e113d0..8261f478 100644 --- a/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java +++ b/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java @@ -28,9 +28,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import java.util.Collection; import java.util.List; -import java.util.Objects; import java.util.Optional; /** From e9444c69031432e85ec793f0904982d56a5a235f Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 11:06:23 +0800 Subject: [PATCH 061/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ext/InterviewQuestionScoreExtMapper.xml | 11 +++++---- .../mapper/member/ext/MemberExtMapper.xml | 4 ++-- .../ext/ActivityParticipationExtMapper.xml | 24 ++++++++++++------- .../ext/InterviewScheduleExtMapper.xml | 8 ++++--- .../schedule/ext/InterviewerExtMapper.xml | 12 ++++++---- 5 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml b/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml index 2aacc018..5504fc63 100644 --- a/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml +++ b/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml @@ -15,11 +15,14 @@ q.id, q.title, q.standard, q.create_time, q.update_time, avg(s.score) average from question q left join interview_question_score s on q.id = s.question_id and s.is_deleted = 0 and q.is_deleted = 0 and s.score != -1 - where + q.is_deleted = 0 and q.id - - #{questionId,jdbcType=BIGINT} - + + + #{questionId,jdbcType=BIGINT} + + + group by q.id order by q.id diff --git a/src/main/resources/mapper/member/ext/MemberExtMapper.xml b/src/main/resources/mapper/member/ext/MemberExtMapper.xml index 052062bd..e267e95d 100644 --- a/src/main/resources/mapper/member/ext/MemberExtMapper.xml +++ b/src/main/resources/mapper/member/ext/MemberExtMapper.xml @@ -26,7 +26,7 @@ m.id, m.manager_id, m.parent_id, stu.username u_username, stu.nickname u_nickname, stu.email u_email, stu.phone_number u_phone_number, - stu.user_type u_user_type, stu.avatar u_avatar, stu.create_time, + stu.user_type u_user_type, stu.avatar u_avatar, stu.id from user stu left join member m on stu.id = m.manager_id and stu.is_deleted = 0 and m.is_deleted = 0 @@ -37,7 +37,7 @@ and r.batch_id = #{batchId,jdbcType=BIGINT} - order by stu.create_time + order by stu.id diff --git a/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml b/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml index 8323ec75..ce897cb2 100644 --- a/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml +++ b/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml @@ -55,10 +55,14 @@ activity_participation ap left join participation_period_link pp on ap.id = pp.participation_id and ap.is_deleted = 0 and pp.is_deleted = 0 left join time_period t on pp.period_id = t.id and pp.is_deleted = 0 and t.is_deleted = 0 - where ap.is_deleted = 0 and ap.id - - #{participationId,jdbcType=BIGINT} - + + ap.is_deleted = 0 and ap.id + + + #{participationId,jdbcType=BIGINT} + + + order by t.start_time asc, t.end_time asc @@ -73,9 +77,13 @@ left join stu_resume r on r.batch_id = b.id and r.user_id = ap.stu_id and b.is_deleted = 0 and r.is_deleted = 0 left join participation_question_link pq on ap.id = pq.participation_id and ap.is_deleted = 0 and pq.is_deleted = 0 left join question q on pq.question_id = q.id and pq.is_deleted = 0 and q.is_deleted = 0 - where ap.is_deleted = 0 and ap.id - - #{participationId,jdbcType=BIGINT} - + + ap.is_deleted = 0 and ap.id + + + #{participationId,jdbcType=BIGINT} + + + diff --git a/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml b/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml index a07abe9f..81815e13 100644 --- a/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml +++ b/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml @@ -69,9 +69,11 @@ a.id = #{condition.actId,jdbcType=BIGINT} and r.id is not null and p.is_deleted = 0 -- and r.status 放在外面,foreach 内部为空导致没有 in,可能会因为 r.status 为 0 而没有查询到一些行 - - #{status,jdbcType=BIGINT} - + + + #{status,jdbcType=INTEGER} + + order by s.start_time asc, s.end_time asc diff --git a/src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml b/src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml index ca2aad77..88308362 100644 --- a/src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml +++ b/src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml @@ -25,10 +25,14 @@ from interview_schedule s left join interviewer i on s.id = i.schedule_id and s.is_deleted = 0 and i.is_deleted = 0 left join user m on m.id = i.manager_id and m.is_deleted = 0 and i.is_deleted = 0 - where s.is_deleted = 0 and m.id is not null and s.id - - #{scheduleId,jdbcType=BIGINT} - + + s.is_deleted = 0 and m.id is not null and s.id + + + #{scheduleId,jdbcType=BIGINT} + + + order by s.start_time asc, s.end_time asc From 294203777ce3b2cff3d13c365bc3d28d9a7ccbb4 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 12:18:54 +0800 Subject: [PATCH 062/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feishu/service/impl/FeishuServiceImpl.java | 12 ++++++------ .../achobeta/feishu/aspect/FeishuRequestAspect.java | 6 +++--- ...nantAccessToken.java => FeishuTenantSession.java} | 2 +- .../evaluate/ext/InterviewQuestionScoreExtMapper.xml | 1 - 4 files changed, 10 insertions(+), 11 deletions(-) rename src/main/java/com/achobeta/feishu/token/{FeishuTenantAccessToken.java => FeishuTenantSession.java} (98%) diff --git a/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuServiceImpl.java b/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuServiceImpl.java index b70fcaca..497e208f 100644 --- a/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuServiceImpl.java +++ b/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuServiceImpl.java @@ -7,7 +7,7 @@ import com.achobeta.feishu.config.ResourceProperties; import com.achobeta.feishu.constants.ObjectType; import com.achobeta.feishu.request.FeishuRequestEngine; -import com.achobeta.feishu.token.FeishuTenantAccessToken; +import com.achobeta.feishu.token.FeishuTenantSession; import com.achobeta.util.GsonUtil; import com.achobeta.util.MediaUtil; import com.achobeta.util.TimeUtil; @@ -57,7 +57,7 @@ public class FeishuServiceImpl implements FeishuService, InitializingBean { private final FeishuAppConfig feishuAppConfig; - private final FeishuTenantAccessToken feishuTenantAccessToken; + private final FeishuTenantSession feishuTenantSession; private final FeishuRequestEngine feishuRequestEngine; @@ -86,7 +86,7 @@ public BatchGetIdUserRespBody batchGetUserId(BatchGetIdUserReqBody batchGetIdUse // } catch (Exception e) { // throw new GlobalServiceException(e.getMessage()); // } - String token = feishuTenantAccessToken.getToken(); + String token = feishuTenantSession.getToken(); return feishuRequestEngine.jsonRequest( GET_USER_ID, batchGetIdUserReqBody, @@ -133,7 +133,7 @@ public ApplyReserveRespBody reserveApply(ApplyReserveReqBody applyReserveReqBody // } catch (Exception e) { // throw new GlobalServiceException(e.getMessage()); // } - String token = feishuTenantAccessToken.getToken(); + String token = feishuTenantSession.getToken(); return feishuRequestEngine.jsonRequest( RESERVE_APPLY, applyReserveReqBody, @@ -228,7 +228,7 @@ public CreateImportTaskRespBody importTask(ImportTask importTask) { // } catch (Exception e) { // throw new GlobalServiceException(e.getMessage()); // } - String token = feishuTenantAccessToken.getToken(); + String token = feishuTenantSession.getToken(); return feishuRequestEngine.jsonRequest( IMPORT_TASK, importTask, @@ -264,7 +264,7 @@ public GetImportTaskRespBody getImportTask(String ticket) { // } catch (Exception e) { // throw new GlobalServiceException(e.getMessage()); // } - String token = feishuTenantAccessToken.getToken(); + String token = feishuTenantSession.getToken(); return feishuRequestEngine.jsonRequest( GET_IMPORT_TASK, null, diff --git a/src/main/java/com/achobeta/feishu/aspect/FeishuRequestAspect.java b/src/main/java/com/achobeta/feishu/aspect/FeishuRequestAspect.java index af0b5168..68a26571 100644 --- a/src/main/java/com/achobeta/feishu/aspect/FeishuRequestAspect.java +++ b/src/main/java/com/achobeta/feishu/aspect/FeishuRequestAspect.java @@ -2,7 +2,7 @@ import com.achobeta.common.enums.GlobalServiceStatusCode; import com.achobeta.exception.GlobalServiceException; -import com.achobeta.feishu.token.FeishuTenantAccessToken; +import com.achobeta.feishu.token.FeishuTenantSession; import com.lark.oapi.core.response.BaseResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -24,7 +24,7 @@ @RequiredArgsConstructor public class FeishuRequestAspect { - private final FeishuTenantAccessToken feishuTenantAccessToken; + private final FeishuTenantSession feishuTenantSession; // 虽然不排除没有返回值的情况,idea 插件识别切点目标方法里没有无返回值的目标方法,但实际上无返回值的目标方法也会执行 AfterReturning,result 为 null 罢了 // 所以要专门排除! @@ -41,7 +41,7 @@ public void doAfterReturning(Object result) { log.info("飞书请求成功"); } else { log.info("飞书 token 刷新"); - feishuTenantAccessToken.refreshToken(); + feishuTenantSession.refreshToken(); throw new GlobalServiceException(response.getMsg(), GlobalServiceStatusCode.REQUEST_NOT_VALID); } }else { diff --git a/src/main/java/com/achobeta/feishu/token/FeishuTenantAccessToken.java b/src/main/java/com/achobeta/feishu/token/FeishuTenantSession.java similarity index 98% rename from src/main/java/com/achobeta/feishu/token/FeishuTenantAccessToken.java rename to src/main/java/com/achobeta/feishu/token/FeishuTenantSession.java index 43523eb0..50d04f79 100644 --- a/src/main/java/com/achobeta/feishu/token/FeishuTenantAccessToken.java +++ b/src/main/java/com/achobeta/feishu/token/FeishuTenantSession.java @@ -20,7 +20,7 @@ */ @Component @RequiredArgsConstructor -public class FeishuTenantAccessToken { +public class FeishuTenantSession { private final Client feishuClient; diff --git a/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml b/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml index 5504fc63..57523dc9 100644 --- a/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml +++ b/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml @@ -24,7 +24,6 @@ group by q.id - order by q.id From ceedfd54d6a25aac619c2cba96014d4d1b5c134e Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 12:29:15 +0800 Subject: [PATCH 063/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/mapper/member/ext/MemberExtMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/mapper/member/ext/MemberExtMapper.xml b/src/main/resources/mapper/member/ext/MemberExtMapper.xml index e267e95d..f04cd35d 100644 --- a/src/main/resources/mapper/member/ext/MemberExtMapper.xml +++ b/src/main/resources/mapper/member/ext/MemberExtMapper.xml @@ -26,7 +26,7 @@ m.id, m.manager_id, m.parent_id, stu.username u_username, stu.nickname u_nickname, stu.email u_email, stu.phone_number u_phone_number, - stu.user_type u_user_type, stu.avatar u_avatar, stu.id + stu.user_type u_user_type, stu.avatar u_avatar, stu.id, from user stu left join member m on stu.id = m.manager_id and stu.is_deleted = 0 and m.is_deleted = 0 From 2fbbfc278f149bfe23bd3f9c758cb0e292a2b9f7 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 14:26:51 +0800 Subject: [PATCH 064/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interview/controller/InterviewController.java | 2 +- .../domain/interview/service/InterviewService.java | 2 +- .../interview/service/impl/InterviewServiceImpl.java | 5 +++-- .../domain/paper/service/PaperQuestionLinkService.java | 2 +- .../service/impl/PaperQuestionLinkServiceImpl.java | 10 +++++++--- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java b/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java index 4c40b757..e6538a24 100644 --- a/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java +++ b/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java @@ -124,7 +124,7 @@ public SystemJsonResponse setPaperForInterview(@Valid @RequestBody InterviewPape // 检查试卷是否存在 questionPaperService.checkPaperExists(paperId); // 设置试卷 - interviewService.setPaperForInterview(interviewId, paperId); + interviewService.setPaperForInterview(interview, paperId); } return SystemJsonResponse.SYSTEM_SUCCESS(); } diff --git a/src/main/java/com/achobeta/domain/interview/service/InterviewService.java b/src/main/java/com/achobeta/domain/interview/service/InterviewService.java index 89f4c062..d5171e83 100644 --- a/src/main/java/com/achobeta/domain/interview/service/InterviewService.java +++ b/src/main/java/com/achobeta/domain/interview/service/InterviewService.java @@ -49,7 +49,7 @@ public interface InterviewService extends IService { InterviewStatus executeInterviewStateEvent(InterviewEvent interviewEvent, InterviewContext interviewContext); - void setPaperForInterview(Long interviewId, Long paperId); + void setPaperForInterview(Interview interview, Long paperId); // 检测 ------------------------------------------ diff --git a/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java b/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java index 43dbe223..e6e883ea 100644 --- a/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java +++ b/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java @@ -161,13 +161,14 @@ public InterviewStatus executeInterviewStateEvent(InterviewEvent interviewEvent, @Override @Transactional - public void setPaperForInterview(Long interviewId, Long paperId) { + public void setPaperForInterview(Interview interview, Long paperId) { // 删除面试相关的打分 + Long interviewId = interview.getId(); Db.lambdaUpdate(InterviewQuestionScore.class) .eq(InterviewQuestionScore::getInterviewId, interviewId) .remove(); // 拷贝一份试卷 - Long newPaperId = paperQuestionLinkService.cloneQuestionPaper(paperId); + Long newPaperId = paperQuestionLinkService.cloneQuestionPaper(paperId, interview.getTitle()); // 设置试卷 this.lambdaUpdate() .eq(Interview::getId, interviewId) diff --git a/src/main/java/com/achobeta/domain/paper/service/PaperQuestionLinkService.java b/src/main/java/com/achobeta/domain/paper/service/PaperQuestionLinkService.java index 0cd292ad..79edab6a 100644 --- a/src/main/java/com/achobeta/domain/paper/service/PaperQuestionLinkService.java +++ b/src/main/java/com/achobeta/domain/paper/service/PaperQuestionLinkService.java @@ -25,7 +25,7 @@ public interface PaperQuestionLinkService extends IService { QuestionPaperDetailVO getPaperDetail(Long paperId); - Long cloneQuestionPaper(Long paperId); + Long cloneQuestionPaper(Long paperId, String title); void checkQuestionExistInPaper(Long paperId, Long questionId); diff --git a/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java b/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java index 0b15347c..116144ac 100644 --- a/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java +++ b/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java @@ -14,6 +14,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; import java.util.HashSet; import java.util.List; @@ -85,15 +86,18 @@ public QuestionPaperDetailVO getPaperDetail(Long paperId) { @Override @Transactional - public Long cloneQuestionPaper(Long paperId) { + public Long cloneQuestionPaper(Long paperId, String title) { // 拷贝试卷的定义 QuestionPaperDetailVO paperDetail = getPaperDetail(paperId); List libIds = paperDetail.getTypes() .stream() .map(PaperLibraryVO::getId) .toList(); - Long newPaperId = questionPaperService.addQuestionPaper(libIds, - paperDetail.getTitle(), paperDetail.getDescription()); + Long newPaperId = questionPaperService.addQuestionPaper( + libIds, + Optional.ofNullable(title).filter(StringUtils::hasText).orElseGet(paperDetail::getTitle), + paperDetail.getDescription() + ); // 拷贝试卷的题目 List questionIds = paperDetail.getQuestions() .stream() From 4dedb3e4d0acf2caa375b181d11fc304565fe64c Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 15:03:02 +0800 Subject: [PATCH 065/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../achobeta/common/annotation/Intercept.java | 2 -- .../annotation/handler/InterceptHelper.java | 8 ------- .../ext/RemovePaperIQScoreHandler.java | 21 +++++++++--------- .../RemoveQuestionFromPaperIQSHandler.java | 11 ++++++---- .../handler/chain/MessageSendDelayChain.java | 2 ++ .../handler/chain/MessageSendNowChain.java | 2 ++ .../chain/RemovePaperHandlerChain.java | 2 ++ .../RemoveQuestionFromPaperHandlerChain.java | 2 ++ .../impl/PaperQuestionLinkServiceImpl.java | 11 ++++++---- .../chain/RemoveQuestionHandlerChain.java | 2 ++ .../handler/ext/RemovePaperPQLinkHandler.java | 22 +++++++++---------- .../RemoveQuestionFromPaperPQLinkHandler.java | 13 +++++------ .../controller/ResourceController.java | 8 ++----- .../service/impl/StuResumeServiceImpl.java | 3 +++ .../achobeta/interceptor/UserInterceptor.java | 16 +++++--------- .../ext/InterviewQuestionScoreExtMapper.xml | 4 ++-- .../paper/ext/QuestionPaperExtMapper.xml | 3 +-- .../mapper/question/ext/QuestionExtMapper.xml | 3 +-- .../ext/ActivityParticipationExtMapper.xml | 8 +++---- .../schedule/ext/InterviewerExtMapper.xml | 4 ++-- 21 files changed, 72 insertions(+), 77 deletions(-) diff --git a/pom.xml b/pom.xml index 35fa158d..94887463 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ prod prod - info + debug true diff --git a/src/main/java/com/achobeta/common/annotation/Intercept.java b/src/main/java/com/achobeta/common/annotation/Intercept.java index 0b666922..5b367db9 100644 --- a/src/main/java/com/achobeta/common/annotation/Intercept.java +++ b/src/main/java/com/achobeta/common/annotation/Intercept.java @@ -27,6 +27,4 @@ boolean ignore() default false; - boolean log() default false; - } diff --git a/src/main/java/com/achobeta/common/annotation/handler/InterceptHelper.java b/src/main/java/com/achobeta/common/annotation/handler/InterceptHelper.java index a2288b90..f2a47cb5 100644 --- a/src/main/java/com/achobeta/common/annotation/handler/InterceptHelper.java +++ b/src/main/java/com/achobeta/common/annotation/handler/InterceptHelper.java @@ -39,14 +39,6 @@ public static boolean isIgnore(Method targetMethod) { return isIgnore(getIntercept(targetMethod)); } - public static boolean shouldPrintLog(Intercept intercept) { - return Objects.isNull(intercept) || intercept.log(); - } - - public static boolean shouldPrintLog(Method targetMethod) { - return shouldPrintLog(getIntercept(targetMethod)); - } - public static boolean isValid(Intercept intercept, UserTypeEnum role) { // permit 中没有 role 就会抛异常 return Arrays.stream(intercept.permit()) diff --git a/src/main/java/com/achobeta/domain/evaluate/handler/ext/RemovePaperIQScoreHandler.java b/src/main/java/com/achobeta/domain/evaluate/handler/ext/RemovePaperIQScoreHandler.java index 2255eccc..94360315 100644 --- a/src/main/java/com/achobeta/domain/evaluate/handler/ext/RemovePaperIQScoreHandler.java +++ b/src/main/java/com/achobeta/domain/evaluate/handler/ext/RemovePaperIQScoreHandler.java @@ -34,18 +34,17 @@ public void handle(Long paperId) { .stream() .map(Interview::getId) .toList(); - if(CollectionUtils.isEmpty(interviewIds)) { - return; + if(!CollectionUtils.isEmpty(interviewIds)) { + // 将面试试卷设置为空 + interviewService.lambdaUpdate() + .in(Interview::getId, interviewIds) + .set(Interview::getPaperId, null) + .update(); + // 删除对应的评分 + interviewQuestionScoreService.lambdaUpdate() + .in(InterviewQuestionScore::getInterviewId, interviewIds) + .remove(); } - // 将面试试卷设置为空 - interviewService.lambdaUpdate() - .in(Interview::getId, interviewIds) - .set(Interview::getPaperId, null) - .update(); - // 删除对应的评分 - interviewQuestionScoreService.lambdaUpdate() - .in(InterviewQuestionScore::getInterviewId, interviewIds) - .remove(); // 执行下一个 super.doNextHandler(paperId); } diff --git a/src/main/java/com/achobeta/domain/evaluate/handler/ext/RemoveQuestionFromPaperIQSHandler.java b/src/main/java/com/achobeta/domain/evaluate/handler/ext/RemoveQuestionFromPaperIQSHandler.java index 85502700..7e0590e4 100644 --- a/src/main/java/com/achobeta/domain/evaluate/handler/ext/RemoveQuestionFromPaperIQSHandler.java +++ b/src/main/java/com/achobeta/domain/evaluate/handler/ext/RemoveQuestionFromPaperIQSHandler.java @@ -7,6 +7,7 @@ import com.achobeta.domain.paper.handler.RemoveQuestionFromPaperHandler; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import java.util.List; @@ -34,10 +35,12 @@ public void handle(Long paperId, List questionIds) { .map(Interview::getId) .toList(); // 删除对应的评分 - interviewQuestionScoreService.lambdaUpdate() - .in(InterviewQuestionScore::getInterviewId, interviewIds) - .in(InterviewQuestionScore::getQuestionId, questionIds) - .remove(); + if(!CollectionUtils.isEmpty(interviewIds) && !CollectionUtils.isEmpty(questionIds)) { + interviewQuestionScoreService.lambdaUpdate() + .in(InterviewQuestionScore::getInterviewId, interviewIds) + .in(InterviewQuestionScore::getQuestionId, questionIds) + .remove(); + } // 执行下一个 super.doNextHandler(paperId, questionIds); } diff --git a/src/main/java/com/achobeta/domain/message/handler/chain/MessageSendDelayChain.java b/src/main/java/com/achobeta/domain/message/handler/chain/MessageSendDelayChain.java index 5912c613..cc8429db 100644 --- a/src/main/java/com/achobeta/domain/message/handler/chain/MessageSendDelayChain.java +++ b/src/main/java/com/achobeta/domain/message/handler/chain/MessageSendDelayChain.java @@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import java.time.Duration; import java.time.LocalDateTime; @@ -37,6 +38,7 @@ private MessageSendHandler initHandlerChain() { } @Override + @Transactional public void handleChain(MessageSendDTO messageSendBody, CopyOnWriteArraySet webSocketSet) { //初始化责任链 MessageSendHandler messageSendHandler = initHandlerChain(); diff --git a/src/main/java/com/achobeta/domain/message/handler/chain/MessageSendNowChain.java b/src/main/java/com/achobeta/domain/message/handler/chain/MessageSendNowChain.java index 72ca72ed..74e8e3b1 100644 --- a/src/main/java/com/achobeta/domain/message/handler/chain/MessageSendNowChain.java +++ b/src/main/java/com/achobeta/domain/message/handler/chain/MessageSendNowChain.java @@ -6,6 +6,7 @@ import com.achobeta.domain.message.model.dto.MessageSendDTO; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import java.util.Optional; import java.util.concurrent.CopyOnWriteArraySet; @@ -27,6 +28,7 @@ private MessageSendHandler initHandlerChain() { } @Override + @Transactional public void handleChain(MessageSendDTO messageSendBody, CopyOnWriteArraySet webSocketSet) { //初始化责任链 MessageSendHandler messageSendHandler = initHandlerChain(); diff --git a/src/main/java/com/achobeta/domain/paper/handler/chain/RemovePaperHandlerChain.java b/src/main/java/com/achobeta/domain/paper/handler/chain/RemovePaperHandlerChain.java index c03799d8..c2bc5438 100644 --- a/src/main/java/com/achobeta/domain/paper/handler/chain/RemovePaperHandlerChain.java +++ b/src/main/java/com/achobeta/domain/paper/handler/chain/RemovePaperHandlerChain.java @@ -5,6 +5,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -39,6 +40,7 @@ public void doPostConstruct() { } @Override + @Transactional public void handle(Long paperId) { log.info("责任链开始处理 [paperId 为 {}] 的“删除试卷”事件", paperId); super.doNextHandler(paperId); diff --git a/src/main/java/com/achobeta/domain/paper/handler/chain/RemoveQuestionFromPaperHandlerChain.java b/src/main/java/com/achobeta/domain/paper/handler/chain/RemoveQuestionFromPaperHandlerChain.java index 3fe882ee..cca60772 100644 --- a/src/main/java/com/achobeta/domain/paper/handler/chain/RemoveQuestionFromPaperHandlerChain.java +++ b/src/main/java/com/achobeta/domain/paper/handler/chain/RemoveQuestionFromPaperHandlerChain.java @@ -5,6 +5,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -39,6 +40,7 @@ public void doPostConstruct() { } @Override + @Transactional public void handle(Long paperId, List questionIds) { log.info("责任链开始处理 [paperId 为 {},questionIds 为 {}] 的“从试卷中移除若干题”事件", paperId, questionIds); super.doNextHandler(paperId, questionIds); diff --git a/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java b/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java index 116144ac..20b0aadf 100644 --- a/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java +++ b/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java @@ -14,6 +14,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.util.HashSet; @@ -70,10 +71,12 @@ public void addQuestionsForPaper(Long paperId, List questionIds) { @Override public void removeQuestionsFromPaper(Long paperId, List questionIds) { - this.lambdaUpdate() - .eq(PaperQuestionLink::getPaperId, paperId) - .in(PaperQuestionLink::getQuestionId, questionIds) - .remove(); + if(!CollectionUtils.isEmpty(questionIds)) { + this.lambdaUpdate() + .eq(PaperQuestionLink::getPaperId, paperId) + .in(PaperQuestionLink::getQuestionId, questionIds) + .remove(); + } } @Override diff --git a/src/main/java/com/achobeta/domain/question/handler/chain/RemoveQuestionHandlerChain.java b/src/main/java/com/achobeta/domain/question/handler/chain/RemoveQuestionHandlerChain.java index 7a93dad3..c7d5ad61 100644 --- a/src/main/java/com/achobeta/domain/question/handler/chain/RemoveQuestionHandlerChain.java +++ b/src/main/java/com/achobeta/domain/question/handler/chain/RemoveQuestionHandlerChain.java @@ -5,6 +5,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -39,6 +40,7 @@ public void doPostConstruct() { } @Override + @Transactional public void handle(Long questionId) { log.info("责任链开始处理 [questionId 为 {}] 的“删除问题”事件", questionId); super.doNextHandler(questionId); diff --git a/src/main/java/com/achobeta/domain/recruit/handler/ext/RemovePaperPQLinkHandler.java b/src/main/java/com/achobeta/domain/recruit/handler/ext/RemovePaperPQLinkHandler.java index 8c471131..880ae55d 100644 --- a/src/main/java/com/achobeta/domain/recruit/handler/ext/RemovePaperPQLinkHandler.java +++ b/src/main/java/com/achobeta/domain/recruit/handler/ext/RemovePaperPQLinkHandler.java @@ -32,22 +32,20 @@ public class RemovePaperPQLinkHandler extends RemovePaperHandler { @Override public void handle(Long paperId) { List participationIds = activityParticipationService.getParticipationIdsByPaperId(paperId); - if(CollectionUtils.isEmpty(participationIds)) { - return; + if(!CollectionUtils.isEmpty(participationIds)) { + // 删除对应的行 + participationQuestionLinkService.lambdaUpdate() + .in(ParticipationQuestionLink::getParticipationId, participationIds) + .remove(); } - // 删除对应的行 - participationQuestionLinkService.lambdaUpdate() - .in(ParticipationQuestionLink::getParticipationId, participationIds) - .remove(); // 涉及的招新活动的 paperId 置为 null List actIds = recruitmentActivityService.getActIdsByPaperId(paperId); - if(CollectionUtils.isEmpty(actIds)) { - return; + if(!CollectionUtils.isEmpty(actIds)) { + recruitmentActivityService.lambdaUpdate() + .in(RecruitmentActivity::getId, actIds) + .set(RecruitmentActivity::getPaperId, null) + .update(); } - recruitmentActivityService.lambdaUpdate() - .in(RecruitmentActivity::getId, actIds) - .set(RecruitmentActivity::getPaperId, null) - .update(); // 执行下一个 super.doNextHandler(paperId); } diff --git a/src/main/java/com/achobeta/domain/recruit/handler/ext/RemoveQuestionFromPaperPQLinkHandler.java b/src/main/java/com/achobeta/domain/recruit/handler/ext/RemoveQuestionFromPaperPQLinkHandler.java index 5e055b32..d0014805 100644 --- a/src/main/java/com/achobeta/domain/recruit/handler/ext/RemoveQuestionFromPaperPQLinkHandler.java +++ b/src/main/java/com/achobeta/domain/recruit/handler/ext/RemoveQuestionFromPaperPQLinkHandler.java @@ -28,14 +28,13 @@ public class RemoveQuestionFromPaperPQLinkHandler extends RemoveQuestionFromPape @Override public void handle(Long paperId, List questionIds) { List participationIds = activityParticipationService.getParticipationIdsByPaperId(paperId); - if(CollectionUtils.isEmpty(participationIds)) { - return; + if(!CollectionUtils.isEmpty(participationIds)) { + // 删除对应的行 + participationQuestionLinkService.lambdaUpdate() + .in(ParticipationQuestionLink::getParticipationId, participationIds) + .in(ParticipationQuestionLink::getQuestionId, questionIds) + .remove(); } - // 删除对应的行 - participationQuestionLinkService.lambdaUpdate() - .in(ParticipationQuestionLink::getParticipationId, participationIds) - .in(ParticipationQuestionLink::getQuestionId, questionIds) - .remove(); // 执行下一个 super.doNextHandler(paperId, questionIds); } diff --git a/src/main/java/com/achobeta/domain/resource/controller/ResourceController.java b/src/main/java/com/achobeta/domain/resource/controller/ResourceController.java index 610c2988..f3453183 100644 --- a/src/main/java/com/achobeta/domain/resource/controller/ResourceController.java +++ b/src/main/java/com/achobeta/domain/resource/controller/ResourceController.java @@ -88,7 +88,6 @@ public SystemJsonResponse getLevels() { } @PostMapping("/upload/one") - @Intercept(permit = {UserTypeEnum.ADMIN, UserTypeEnum.USER}, log = true) public SystemJsonResponse upload(@RequestPart("file") MultipartFile file) { Long userId = BaseContext.getCurrentUser().getUserId(); Long code = resourceService.upload(userId, file); @@ -96,7 +95,7 @@ public SystemJsonResponse upload(@RequestPart("file") MultipartFile file) { } @PostMapping("/upload/syncfeishu/markdown") - @Intercept(permit = {UserTypeEnum.ADMIN}, log = true) + @Intercept(permit = {UserTypeEnum.ADMIN}) public SystemJsonResponse uploadMarkdown(@RequestPart("file") MultipartFile file, @RequestParam(name = "level", required = false) Integer level) { ResourceUtil.checkText(MediaUtil.getContentType(file)); @@ -109,7 +108,7 @@ public SystemJsonResponse uploadMarkdown(@RequestPart("file") MultipartFile file } @PostMapping("/upload/syncfeishu/sheet") - @Intercept(permit = {UserTypeEnum.ADMIN}, log = true) + @Intercept(permit = {UserTypeEnum.ADMIN}) public SystemJsonResponse uploadExcel(@RequestPart("file") MultipartFile file, @RequestParam(name = "level", required = false) Integer level) { ResourceUtil.checkSheet(MediaUtil.getBytes(file)); @@ -122,7 +121,6 @@ public SystemJsonResponse uploadExcel(@RequestPart("file") MultipartFile file, } @PostMapping("/upload/image") - @Intercept(permit = {UserTypeEnum.ADMIN, UserTypeEnum.USER}, log = true) public SystemJsonResponse uploadImage(@RequestPart("file") MultipartFile file) { // 检查 ResourceUtil.checkImage(MediaUtil.getContentType(file)); @@ -132,7 +130,6 @@ public SystemJsonResponse uploadImage(@RequestPart("file") MultipartFile file) { } @PostMapping("/upload/video") - @Intercept(permit = {UserTypeEnum.ADMIN, UserTypeEnum.USER}, log = true) public SystemJsonResponse uploadVideo(@RequestPart("file") MultipartFile file) { // 检查 ResourceUtil.checkVideo(MediaUtil.getContentType(file)); @@ -142,7 +139,6 @@ public SystemJsonResponse uploadVideo(@RequestPart("file") MultipartFile file) { } @PostMapping("/upload/list") - @Intercept(permit = {UserTypeEnum.ADMIN, UserTypeEnum.USER}, log = true) public SystemJsonResponse upload(@RequestPart("file") List fileList) { Long userId = BaseContext.getCurrentUser().getUserId(); List codeList = resourceService.uploadList(userId, fileList); diff --git a/src/main/java/com/achobeta/domain/student/service/impl/StuResumeServiceImpl.java b/src/main/java/com/achobeta/domain/student/service/impl/StuResumeServiceImpl.java index 4360213f..ae002648 100644 --- a/src/main/java/com/achobeta/domain/student/service/impl/StuResumeServiceImpl.java +++ b/src/main/java/com/achobeta/domain/student/service/impl/StuResumeServiceImpl.java @@ -230,6 +230,9 @@ public StuResume checkResumeSubmitCount(StuSimpleResumeDTO resumeDTO, Long userI @Override public List queryStuList(Long batchId, List userIds) { + if(CollectionUtils.isEmpty(userIds)) { + return new ArrayList<>(); + } return lambdaQuery() .eq(StuResume::getBatchId, batchId) .in(StuResume::getUserId, userIds) diff --git a/src/main/java/com/achobeta/interceptor/UserInterceptor.java b/src/main/java/com/achobeta/interceptor/UserInterceptor.java index f8222a62..9c454a9e 100644 --- a/src/main/java/com/achobeta/interceptor/UserInterceptor.java +++ b/src/main/java/com/achobeta/interceptor/UserInterceptor.java @@ -123,16 +123,12 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons @Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { try { - if(handler instanceof HandlerMethod handlerMethod) { - // 获取目标方法 - Method targetMethod = handlerMethod.getMethod(); - if(InterceptHelper.shouldPrintLog(targetMethod)) { - String requestId = response.getHeader(requestIdConfig.getHeader()); - log.warn("请求 {} 访问接口 {},响应 HTTP 状态码 {},错误信息 {}", - requestId, request.getRequestURI(), response.getStatus(), - Optional.ofNullable(ex).map(Exception::getMessage).orElse(null) - ); - } + if(handler instanceof HandlerMethod) { + String requestId = response.getHeader(requestIdConfig.getHeader()); + log.warn("请求 {} 访问接口 {},响应 HTTP 状态码 {},错误信息 {}", + requestId, request.getRequestURI(), response.getStatus(), + Optional.ofNullable(ex).map(Exception::getMessage).orElse(null) + ); } } finally { log.info("删除本地线程变量"); diff --git a/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml b/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml index 57523dc9..717d0e05 100644 --- a/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml +++ b/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml @@ -16,9 +16,9 @@ from question q left join interview_question_score s on q.id = s.question_id and s.is_deleted = 0 and q.is_deleted = 0 and s.score != -1 - q.is_deleted = 0 and q.id + q.is_deleted = 0 - + #{questionId,jdbcType=BIGINT} diff --git a/src/main/resources/mapper/paper/ext/QuestionPaperExtMapper.xml b/src/main/resources/mapper/paper/ext/QuestionPaperExtMapper.xml index 612ac9c7..551d7958 100644 --- a/src/main/resources/mapper/paper/ext/QuestionPaperExtMapper.xml +++ b/src/main/resources/mapper/paper/ext/QuestionPaperExtMapper.xml @@ -23,8 +23,7 @@ p.id is not null and l.is_deleted = 0 - and l.id - + #{libId,jdbcType=BIGINT} diff --git a/src/main/resources/mapper/question/ext/QuestionExtMapper.xml b/src/main/resources/mapper/question/ext/QuestionExtMapper.xml index 4b3145de..2a2f47cc 100644 --- a/src/main/resources/mapper/question/ext/QuestionExtMapper.xml +++ b/src/main/resources/mapper/question/ext/QuestionExtMapper.xml @@ -23,8 +23,7 @@ q.id is not null and l.is_deleted = 0 - and l.id - + #{libId,jdbcType=BIGINT} diff --git a/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml b/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml index ce897cb2..ec36bdf4 100644 --- a/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml +++ b/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml @@ -56,9 +56,9 @@ left join participation_period_link pp on ap.id = pp.participation_id and ap.is_deleted = 0 and pp.is_deleted = 0 left join time_period t on pp.period_id = t.id and pp.is_deleted = 0 and t.is_deleted = 0 - ap.is_deleted = 0 and ap.id + ap.is_deleted = 0 - + #{participationId,jdbcType=BIGINT} @@ -78,9 +78,9 @@ left join participation_question_link pq on ap.id = pq.participation_id and ap.is_deleted = 0 and pq.is_deleted = 0 left join question q on pq.question_id = q.id and pq.is_deleted = 0 and q.is_deleted = 0 - ap.is_deleted = 0 and ap.id + ap.is_deleted = 0 - + #{participationId,jdbcType=BIGINT} diff --git a/src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml b/src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml index 88308362..c599021a 100644 --- a/src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml +++ b/src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml @@ -26,9 +26,9 @@ left join interviewer i on s.id = i.schedule_id and s.is_deleted = 0 and i.is_deleted = 0 left join user m on m.id = i.manager_id and m.is_deleted = 0 and i.is_deleted = 0 - s.is_deleted = 0 and m.id is not null and s.id + s.is_deleted = 0 and m.id is not null - + #{scheduleId,jdbcType=BIGINT} From 1137de4bc478930f77a39d43f428e244b77644df Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 17:15:46 +0800 Subject: [PATCH 066/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../paper/service/impl/PaperQuestionLinkServiceImpl.java | 7 ++----- .../service/impl/ParticipationQuestionLinkServiceImpl.java | 7 ++----- .../mapper/paper/ext/PaperQuestionLinkExtMapper.xml | 3 ++- .../resources/mapper/paper/ext/QuestionPaperExtMapper.xml | 3 ++- .../mapper/paper/ext/QuestionPaperLibraryExtMapper.xml | 3 ++- .../resources/mapper/question/ext/QuestionExtMapper.xml | 3 ++- .../mapper/question/ext/QuestionLibararyExtMapper.xml | 3 ++- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java b/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java index 20b0aadf..dfbe77e7 100644 --- a/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java +++ b/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java @@ -17,10 +17,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; +import java.util.*; /** * @author 马拉圈 @@ -54,7 +51,7 @@ public Optional getPaperQuestionLink(Long paperId, Long quest @Override @Transactional public void addQuestionsForPaper(Long paperId, List questionIds) { - Set hash = new HashSet<>(); + Set hash = new LinkedHashSet<>(); // 获取试卷的所有题 getQuestionsOnPaper(paperId).forEach(questionVO -> hash.add(questionVO.getId())); // 将不存在于原试卷的题滤出来 diff --git a/src/main/java/com/achobeta/domain/recruit/service/impl/ParticipationQuestionLinkServiceImpl.java b/src/main/java/com/achobeta/domain/recruit/service/impl/ParticipationQuestionLinkServiceImpl.java index 32c0736e..4956602b 100644 --- a/src/main/java/com/achobeta/domain/recruit/service/impl/ParticipationQuestionLinkServiceImpl.java +++ b/src/main/java/com/achobeta/domain/recruit/service/impl/ParticipationQuestionLinkServiceImpl.java @@ -15,10 +15,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; /** * @author 马拉圈 @@ -76,7 +73,7 @@ public Optional getParticipationQuestionLink(Long par @Override public void putQuestionAnswers(Long participationId, List questionAnswerDTOS) { Long recId = getActivityParticipationActId(participationId); - Map hash = new HashMap<>(); + Map hash = new LinkedHashMap<>(); // 获取答题模板 recruitmentActivityService.getQuestionsByActId(recId).forEach(questionVO -> { hash.put(questionVO.getId(), ActivityParticipationConstants.DEFAULT_ANSWER); diff --git a/src/main/resources/mapper/paper/ext/PaperQuestionLinkExtMapper.xml b/src/main/resources/mapper/paper/ext/PaperQuestionLinkExtMapper.xml index 0d43205f..9b624f31 100644 --- a/src/main/resources/mapper/paper/ext/PaperQuestionLinkExtMapper.xml +++ b/src/main/resources/mapper/paper/ext/PaperQuestionLinkExtMapper.xml @@ -6,11 +6,12 @@ diff --git a/src/main/resources/mapper/paper/ext/QuestionPaperExtMapper.xml b/src/main/resources/mapper/paper/ext/QuestionPaperExtMapper.xml index 551d7958..c06d18ac 100644 --- a/src/main/resources/mapper/paper/ext/QuestionPaperExtMapper.xml +++ b/src/main/resources/mapper/paper/ext/QuestionPaperExtMapper.xml @@ -16,7 +16,7 @@ resultMap="com.achobeta.domain.paper.model.dao.mapper.QuestionPaperMapper.BaseResultMap"> select -- 试卷与试卷库多对多,在本条 sql 容易出现重复行 - distinct p.id, p.title, p.description, p.create_time, p.update_time + distinct p.id, p.title, p.description, p.create_time, p.update_time, lp.create_time lp_create_time from question_paper_library l left join library_paper_link lp on l.id = lp.lib_id and l.is_deleted = 0 and lp.is_deleted = 0 left join question_paper p on p.id = lp.paper_id and p.is_deleted = 0 and lp.is_deleted = 0 @@ -28,6 +28,7 @@ + order by lp_create_time diff --git a/src/main/resources/mapper/paper/ext/QuestionPaperLibraryExtMapper.xml b/src/main/resources/mapper/paper/ext/QuestionPaperLibraryExtMapper.xml index 1edfb210..5ad9b615 100644 --- a/src/main/resources/mapper/paper/ext/QuestionPaperLibraryExtMapper.xml +++ b/src/main/resources/mapper/paper/ext/QuestionPaperLibraryExtMapper.xml @@ -19,10 +19,11 @@ diff --git a/src/main/resources/mapper/question/ext/QuestionExtMapper.xml b/src/main/resources/mapper/question/ext/QuestionExtMapper.xml index 2a2f47cc..e9b7a136 100644 --- a/src/main/resources/mapper/question/ext/QuestionExtMapper.xml +++ b/src/main/resources/mapper/question/ext/QuestionExtMapper.xml @@ -16,7 +16,7 @@ resultMap="com.achobeta.domain.question.model.dao.mapper.QuestionMapper.BaseResultMap"> select -- 问题与题库多对多,在本条 sql 容易出现重复行 - distinct q.id, q.title, q.standard, q.create_time, q.update_time + distinct q.id, q.title, q.standard, q.create_time, q.update_time, lq.create_time lq_create_time from question_library l left join library_question_link lq on l.id = lq.lib_id and l.is_deleted = 0 and lq.is_deleted = 0 left join question q on q.id = lq.question_id and q.is_deleted = 0 and lq.is_deleted = 0 @@ -28,5 +28,6 @@ + order by lq_create_time diff --git a/src/main/resources/mapper/question/ext/QuestionLibararyExtMapper.xml b/src/main/resources/mapper/question/ext/QuestionLibararyExtMapper.xml index 8101f804..69994f5a 100644 --- a/src/main/resources/mapper/question/ext/QuestionLibararyExtMapper.xml +++ b/src/main/resources/mapper/question/ext/QuestionLibararyExtMapper.xml @@ -19,11 +19,12 @@ From 9ac4fe1a34c1d915e24f91720aaec2aa2aeb10d9 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 17:39:42 +0800 Subject: [PATCH 067/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/evaluate/ext/InterviewCommentExtMapper.xml | 2 +- .../mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml | 5 +++-- .../resources/mapper/interview/ext/InterviewExtMapper.xml | 1 + src/main/resources/mapper/member/ext/MemberExtMapper.xml | 4 ++-- .../mapper/paper/ext/PaperQuestionLinkExtMapper.xml | 2 +- .../resources/mapper/paper/ext/QuestionPaperExtMapper.xml | 2 +- .../mapper/paper/ext/QuestionPaperLibraryExtMapper.xml | 2 +- .../resources/mapper/question/ext/QuestionExtMapper.xml | 2 +- .../mapper/question/ext/QuestionLibararyExtMapper.xml | 2 +- .../mapper/recruit/ext/ActivityParticipationExtMapper.xml | 6 ++++-- .../mapper/recruit/ext/RecruitmentBatchExtMapper.xml | 3 ++- 11 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/main/resources/mapper/evaluate/ext/InterviewCommentExtMapper.xml b/src/main/resources/mapper/evaluate/ext/InterviewCommentExtMapper.xml index e72295ae..8510997c 100644 --- a/src/main/resources/mapper/evaluate/ext/InterviewCommentExtMapper.xml +++ b/src/main/resources/mapper/evaluate/ext/InterviewCommentExtMapper.xml @@ -30,7 +30,7 @@ left join interview_comment c on c.interview_id = i.id and c.is_deleted = 0 and i.is_deleted = 0 left join user m on m.id = c.manager_id and m.is_deleted = 0 and c.is_deleted = 0 where i.id = #{interviewId,jdbcType=BIGINT} and c.id is not null and i.is_deleted = 0 - order by c.create_time + order by c.create_time asc diff --git a/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml b/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml index 717d0e05..87b41d71 100644 --- a/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml +++ b/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml @@ -12,7 +12,7 @@ diff --git a/src/main/resources/mapper/interview/ext/InterviewExtMapper.xml b/src/main/resources/mapper/interview/ext/InterviewExtMapper.xml index d948d170..afe8fc3a 100644 --- a/src/main/resources/mapper/interview/ext/InterviewExtMapper.xml +++ b/src/main/resources/mapper/interview/ext/InterviewExtMapper.xml @@ -85,6 +85,7 @@ left join recruitment_batch b on b.id = a.batch_id and a.is_deleted = 0 and b.is_deleted = 0 left join stu_resume r on r.batch_id = b.id and r.user_id = stu.id and r.is_deleted = 0 and b.is_deleted = 0 and stu.is_deleted = 0 where i.id = #{interviewId,jdbcType=BIGINT} and i.is_deleted = 0 + order by s.start_time asc, s.end_time asc diff --git a/src/main/resources/mapper/member/ext/MemberExtMapper.xml b/src/main/resources/mapper/member/ext/MemberExtMapper.xml index f04cd35d..9843c762 100644 --- a/src/main/resources/mapper/member/ext/MemberExtMapper.xml +++ b/src/main/resources/mapper/member/ext/MemberExtMapper.xml @@ -26,7 +26,7 @@ m.id, m.manager_id, m.parent_id, stu.username u_username, stu.nickname u_nickname, stu.email u_email, stu.phone_number u_phone_number, - stu.user_type u_user_type, stu.avatar u_avatar, stu.id, + stu.user_type u_user_type, stu.avatar u_avatar, stu.create_time, from user stu left join member m on stu.id = m.manager_id and stu.is_deleted = 0 and m.is_deleted = 0 @@ -37,7 +37,7 @@ and r.batch_id = #{batchId,jdbcType=BIGINT} - order by stu.id + order by stu.create_time asc diff --git a/src/main/resources/mapper/paper/ext/PaperQuestionLinkExtMapper.xml b/src/main/resources/mapper/paper/ext/PaperQuestionLinkExtMapper.xml index 9b624f31..d359fa5e 100644 --- a/src/main/resources/mapper/paper/ext/PaperQuestionLinkExtMapper.xml +++ b/src/main/resources/mapper/paper/ext/PaperQuestionLinkExtMapper.xml @@ -11,7 +11,7 @@ left join paper_question_link pq on p.id = pq.paper_id and p.is_deleted = 0 and pq.is_deleted = 0 left join question q on q.id = pq.question_id and q.is_deleted = 0 and pq.is_deleted = 0 where p.id = #{paperId,jdbcType=BIGINT} and q.id is not null and p.is_deleted = 0 - order by pq_create_time + order by pq_create_time asc diff --git a/src/main/resources/mapper/paper/ext/QuestionPaperExtMapper.xml b/src/main/resources/mapper/paper/ext/QuestionPaperExtMapper.xml index c06d18ac..c6fd0986 100644 --- a/src/main/resources/mapper/paper/ext/QuestionPaperExtMapper.xml +++ b/src/main/resources/mapper/paper/ext/QuestionPaperExtMapper.xml @@ -28,7 +28,7 @@ - order by lp_create_time + order by lp_create_time asc diff --git a/src/main/resources/mapper/paper/ext/QuestionPaperLibraryExtMapper.xml b/src/main/resources/mapper/paper/ext/QuestionPaperLibraryExtMapper.xml index 5ad9b615..9aed00d7 100644 --- a/src/main/resources/mapper/paper/ext/QuestionPaperLibraryExtMapper.xml +++ b/src/main/resources/mapper/paper/ext/QuestionPaperLibraryExtMapper.xml @@ -24,6 +24,6 @@ left join library_paper_link lp on p.id = lp.paper_id and p.is_deleted = 0 and lp.is_deleted = 0 left join question_paper_library l on l.id = lp.lib_id and l.is_deleted = 0 and lp.is_deleted = 0 where p.id = #{paperId,jdbcType=BIGINT} and p.is_deleted = 0 - order by lp_create_time + order by lp_create_time asc diff --git a/src/main/resources/mapper/question/ext/QuestionExtMapper.xml b/src/main/resources/mapper/question/ext/QuestionExtMapper.xml index e9b7a136..5ddf8826 100644 --- a/src/main/resources/mapper/question/ext/QuestionExtMapper.xml +++ b/src/main/resources/mapper/question/ext/QuestionExtMapper.xml @@ -28,6 +28,6 @@ - order by lq_create_time + order by lq_create_time asc diff --git a/src/main/resources/mapper/question/ext/QuestionLibararyExtMapper.xml b/src/main/resources/mapper/question/ext/QuestionLibararyExtMapper.xml index 69994f5a..a3e3bb24 100644 --- a/src/main/resources/mapper/question/ext/QuestionLibararyExtMapper.xml +++ b/src/main/resources/mapper/question/ext/QuestionLibararyExtMapper.xml @@ -24,7 +24,7 @@ left join library_question_link lq on q.id = lq.question_id and q.is_deleted = 0 and lq.is_deleted = 0 left join question_library l on l.id = lq.lib_id and l.is_deleted = 0 and lq.is_deleted = 0 where q.id = #{questionId,jdbcType=BIGINT} and q.is_deleted = 0 - order by lq_create_time + order by lq_create_time asc diff --git a/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml b/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml index ec36bdf4..1a1e8cf6 100644 --- a/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml +++ b/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml @@ -29,12 +29,13 @@ select - ap.id, q.id q_id, q.title q_title, pq.answer q_answer, + ap.id, q.id q_id, q.title q_title, pq.answer q_answer, pq.create_time pq_create_time, from activity_participation ap @@ -85,5 +86,6 @@ + order by pq_create_time asc diff --git a/src/main/resources/mapper/recruit/ext/RecruitmentBatchExtMapper.xml b/src/main/resources/mapper/recruit/ext/RecruitmentBatchExtMapper.xml index 7ccb9f79..e005fa32 100644 --- a/src/main/resources/mapper/recruit/ext/RecruitmentBatchExtMapper.xml +++ b/src/main/resources/mapper/recruit/ext/RecruitmentBatchExtMapper.xml @@ -6,10 +6,11 @@ From e4118f1870a7b70bc4c9c0ce296a801638198a8d Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 17:39:58 +0800 Subject: [PATCH 068/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/mapper/feedback/UserFeedbackMapper.xml | 7 ++++--- src/main/resources/mapper/message/MessageMapper.xml | 1 + .../resources/mapper/message/MessageTemplateMapper.xml | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/resources/mapper/feedback/UserFeedbackMapper.xml b/src/main/resources/mapper/feedback/UserFeedbackMapper.xml index bd83f350..2f580a4e 100644 --- a/src/main/resources/mapper/feedback/UserFeedbackMapper.xml +++ b/src/main/resources/mapper/feedback/UserFeedbackMapper.xml @@ -9,18 +9,19 @@ - + - + + id,user_id,batch_id, - message_id,title,content, + message_id,tittle,content, attchment,is_handle,version, is_deleted,create_time,update_time diff --git a/src/main/resources/mapper/message/MessageMapper.xml b/src/main/resources/mapper/message/MessageMapper.xml index 2977949a..efc5abeb 100644 --- a/src/main/resources/mapper/message/MessageMapper.xml +++ b/src/main/resources/mapper/message/MessageMapper.xml @@ -12,6 +12,7 @@ + diff --git a/src/main/resources/mapper/message/MessageTemplateMapper.xml b/src/main/resources/mapper/message/MessageTemplateMapper.xml index e11c0190..6c7daaf8 100644 --- a/src/main/resources/mapper/message/MessageTemplateMapper.xml +++ b/src/main/resources/mapper/message/MessageTemplateMapper.xml @@ -9,6 +9,7 @@ + From 8dbe502cacff423c72269d5d5f02526496852c92 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 17:57:09 +0800 Subject: [PATCH 069/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/paper/handler/ext/RemovePaperLPLinkHandler.java | 7 +++++++ .../paper/service/impl/PaperQuestionLinkServiceImpl.java | 5 ++++- .../service/impl/ParticipationQuestionLinkServiceImpl.java | 5 ++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/achobeta/domain/paper/handler/ext/RemovePaperLPLinkHandler.java b/src/main/java/com/achobeta/domain/paper/handler/ext/RemovePaperLPLinkHandler.java index 642e2b55..65a4c1ef 100644 --- a/src/main/java/com/achobeta/domain/paper/handler/ext/RemovePaperLPLinkHandler.java +++ b/src/main/java/com/achobeta/domain/paper/handler/ext/RemovePaperLPLinkHandler.java @@ -2,7 +2,9 @@ import com.achobeta.domain.paper.handler.RemovePaperHandler; import com.achobeta.domain.paper.model.entity.LibraryPaperLink; +import com.achobeta.domain.paper.model.entity.PaperQuestionLink; import com.achobeta.domain.paper.service.LibraryPaperLinkService; +import com.achobeta.domain.paper.service.PaperQuestionLinkService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -19,12 +21,17 @@ public class RemovePaperLPLinkHandler extends RemovePaperHandler { private final LibraryPaperLinkService libraryPaperLinkService; + private final PaperQuestionLinkService paperQuestionLinkService; + @Override public void handle(Long paperId) { // 删除关联表的一些行 libraryPaperLinkService.lambdaUpdate() .eq(LibraryPaperLink::getPaperId, paperId) .remove(); + paperQuestionLinkService.lambdaUpdate() + .eq(PaperQuestionLink::getPaperId, paperId) + .remove(); super.doNextHandler(paperId); } diff --git a/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java b/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java index dfbe77e7..c89c7503 100644 --- a/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java +++ b/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java @@ -17,7 +17,10 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import java.util.*; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; /** * @author 马拉圈 diff --git a/src/main/java/com/achobeta/domain/recruit/service/impl/ParticipationQuestionLinkServiceImpl.java b/src/main/java/com/achobeta/domain/recruit/service/impl/ParticipationQuestionLinkServiceImpl.java index 4956602b..463a4373 100644 --- a/src/main/java/com/achobeta/domain/recruit/service/impl/ParticipationQuestionLinkServiceImpl.java +++ b/src/main/java/com/achobeta/domain/recruit/service/impl/ParticipationQuestionLinkServiceImpl.java @@ -15,7 +15,10 @@ import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; -import java.util.*; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; /** * @author 马拉圈 From 8ecac40d8df5758c4aa39e961137bdbcf4114955 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 19:02:33 +0800 Subject: [PATCH 070/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml | 4 ++-- src/main/resources/mapper/member/ext/MemberExtMapper.xml | 2 +- .../mapper/recruit/ext/ActivityParticipationExtMapper.xml | 4 ++-- .../resources/mapper/schedule/ext/InterviewerExtMapper.xml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml b/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml index 87b41d71..9ba27282 100644 --- a/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml +++ b/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml @@ -16,14 +16,14 @@ from question q left join interview_question_score s on q.id = s.question_id and s.is_deleted = 0 and q.is_deleted = 0 and s.score != -1 - q.is_deleted = 0 + q.id is not null and q.is_deleted = 0 #{questionId,jdbcType=BIGINT} - group by q.create_time + group by q.id order by s_create_time asc diff --git a/src/main/resources/mapper/member/ext/MemberExtMapper.xml b/src/main/resources/mapper/member/ext/MemberExtMapper.xml index 9843c762..7bffaaaa 100644 --- a/src/main/resources/mapper/member/ext/MemberExtMapper.xml +++ b/src/main/resources/mapper/member/ext/MemberExtMapper.xml @@ -32,7 +32,7 @@ left join member m on stu.id = m.manager_id and stu.is_deleted = 0 and m.is_deleted = 0 left join stu_resume r on r.id = m.resume_id and r.is_deleted = 0 and m.is_deleted = 0 - stu.user_type = 2 and stu.is_deleted = 0 + stu.id is not null and stu.user_type = 2 and stu.is_deleted = 0 and r.batch_id = #{batchId,jdbcType=BIGINT} diff --git a/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml b/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml index 1a1e8cf6..463b2720 100644 --- a/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml +++ b/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml @@ -57,7 +57,7 @@ left join participation_period_link pp on ap.id = pp.participation_id and ap.is_deleted = 0 and pp.is_deleted = 0 left join time_period t on pp.period_id = t.id and pp.is_deleted = 0 and t.is_deleted = 0 - ap.is_deleted = 0 + ap.id is not null and ap.is_deleted = 0 #{participationId,jdbcType=BIGINT} @@ -79,7 +79,7 @@ left join participation_question_link pq on ap.id = pq.participation_id and ap.is_deleted = 0 and pq.is_deleted = 0 left join question q on pq.question_id = q.id and pq.is_deleted = 0 and q.is_deleted = 0 - ap.is_deleted = 0 + ap.id is not null and ap.is_deleted = 0 #{participationId,jdbcType=BIGINT} diff --git a/src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml b/src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml index c599021a..e5bd102a 100644 --- a/src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml +++ b/src/main/resources/mapper/schedule/ext/InterviewerExtMapper.xml @@ -26,7 +26,7 @@ left join interviewer i on s.id = i.schedule_id and s.is_deleted = 0 and i.is_deleted = 0 left join user m on m.id = i.manager_id and m.is_deleted = 0 and i.is_deleted = 0 - s.is_deleted = 0 and m.id is not null + s.id is not null and s.is_deleted = 0 and m.id is not null #{scheduleId,jdbcType=BIGINT} From 82d3d779ec22760107fa21704db29c7509a36776 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 19:03:45 +0800 Subject: [PATCH 071/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 94887463..35fa158d 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ prod prod - debug + info true From fbbb30459b3767ca033534c7765a21462594d5fc Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 19:13:06 +0800 Subject: [PATCH 072/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml b/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml index 9ba27282..c580e416 100644 --- a/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml +++ b/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml @@ -12,7 +12,7 @@ From 231af5de4f90b6742b89d58e98c1901452aa810e Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Tue, 15 Oct 2024 23:05:30 +0800 Subject: [PATCH 073/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../paper/service/impl/PaperQuestionLinkServiceImpl.java | 4 ++-- .../mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java b/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java index c89c7503..20b0aadf 100644 --- a/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java +++ b/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java @@ -17,7 +17,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import java.util.LinkedHashSet; +import java.util.HashSet; import java.util.List; import java.util.Optional; import java.util.Set; @@ -54,7 +54,7 @@ public Optional getPaperQuestionLink(Long paperId, Long quest @Override @Transactional public void addQuestionsForPaper(Long paperId, List questionIds) { - Set hash = new LinkedHashSet<>(); + Set hash = new HashSet<>(); // 获取试卷的所有题 getQuestionsOnPaper(paperId).forEach(questionVO -> hash.add(questionVO.getId())); // 将不存在于原试卷的题滤出来 diff --git a/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml b/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml index c580e416..d406f29a 100644 --- a/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml +++ b/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml @@ -24,6 +24,7 @@ group by q.id + order by q.create_time From e71867a50156116b485bbf1c1f27d79a55e2b4e5 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Wed, 16 Oct 2024 00:33:37 +0800 Subject: [PATCH 074/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/resource/service/impl/ResourceServiceImpl.java | 3 +-- src/main/java/com/achobeta/util/HttpRequestUtil.java | 2 +- src/main/java/com/achobeta/util/HttpServletUtil.java | 6 ++++++ .../mapper/schedule/ext/InterviewScheduleExtMapper.xml | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/achobeta/domain/resource/service/impl/ResourceServiceImpl.java b/src/main/java/com/achobeta/domain/resource/service/impl/ResourceServiceImpl.java index 92fb1877..1c1ccdb2 100644 --- a/src/main/java/com/achobeta/domain/resource/service/impl/ResourceServiceImpl.java +++ b/src/main/java/com/achobeta/domain/resource/service/impl/ResourceServiceImpl.java @@ -167,8 +167,7 @@ public Long upload(Long userId, String originalName, byte[] data, ResourceAccess if(ResourceUtil.matchType(contentType, ResourceType.IMAGE) && compressionThreshold.compareTo(data.length) <= 0) { // 压缩图片 data = MediaUtil.compressImage(data); - suffix = "." + MediaUtil.COMPRESS_FORMAT_NAME; - originalName = ResourceUtil.changeSuffix(originalName, suffix); + originalName = ResourceUtil.changeExtension(originalName, MediaUtil.COMPRESS_FORMAT_NAME); } else { // 使用原后缀 suffix = ResourceUtil.getSuffix(originalName); diff --git a/src/main/java/com/achobeta/util/HttpRequestUtil.java b/src/main/java/com/achobeta/util/HttpRequestUtil.java index 3f4b8664..34e6675f 100644 --- a/src/main/java/com/achobeta/util/HttpRequestUtil.java +++ b/src/main/java/com/achobeta/util/HttpRequestUtil.java @@ -22,10 +22,10 @@ /** * Created With Intellij IDEA - * Description: * User: 马拉圈 * Date: 2024-09-26 * Time: 7:41 + * Description: 用 Gson 序列化,已有业务依赖 Gson,不建议修改为其他序列化器 */ public class HttpRequestUtil { diff --git a/src/main/java/com/achobeta/util/HttpServletUtil.java b/src/main/java/com/achobeta/util/HttpServletUtil.java index 52b0134a..8056a793 100644 --- a/src/main/java/com/achobeta/util/HttpServletUtil.java +++ b/src/main/java/com/achobeta/util/HttpServletUtil.java @@ -29,10 +29,16 @@ public static Optional getAttributes() { return Optional.ofNullable((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()); } + /** + * 获取本次请求的 HttpServletRequest 对象 + */ public static HttpServletRequest getRequest() { return getAttributes().map(ServletRequestAttributes::getRequest).orElseThrow(GlobalServiceException::new); } + /** + * 获取本次请求的 HttpServletResponse 对象 + */ public static HttpServletResponse getResponse() { return getAttributes().map(ServletRequestAttributes::getResponse).orElseThrow(GlobalServiceException::new); } diff --git a/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml b/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml index 81815e13..c319b840 100644 --- a/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml +++ b/src/main/resources/mapper/schedule/ext/InterviewScheduleExtMapper.xml @@ -16,6 +16,7 @@ + From 84f431a3a848bd77b9b1179140486267990945ce Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Wed, 16 Oct 2024 00:43:08 +0800 Subject: [PATCH 075/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../machine/events/internal/InterviewExperienceHelper.java | 1 - .../evaluate/model/vo/InterviewExperienceTemplateInner.java | 2 -- src/main/resources/templates/interview-experience-model.html | 2 -- 3 files changed, 5 deletions(-) diff --git a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java index 0812f0ba..bf9beb24 100644 --- a/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java +++ b/src/main/java/com/achobeta/domain/evaluate/machine/events/internal/InterviewExperienceHelper.java @@ -91,7 +91,6 @@ public Action getPerformActio InterviewExperienceTemplateInner inner = InterviewExperienceTemplateInner.builder() .title(question.getTitle()) .score(question.getScore()) - .average(question.getAverage()) .standard(target) .build(); replaceResourceList.add(new ReplaceResource(target, question.getStandard())); diff --git a/src/main/java/com/achobeta/domain/evaluate/model/vo/InterviewExperienceTemplateInner.java b/src/main/java/com/achobeta/domain/evaluate/model/vo/InterviewExperienceTemplateInner.java index 08903b4f..19945649 100644 --- a/src/main/java/com/achobeta/domain/evaluate/model/vo/InterviewExperienceTemplateInner.java +++ b/src/main/java/com/achobeta/domain/evaluate/model/vo/InterviewExperienceTemplateInner.java @@ -22,8 +22,6 @@ public class InterviewExperienceTemplateInner { private Integer score; - private Double average; - private String standard; } diff --git a/src/main/resources/templates/interview-experience-model.html b/src/main/resources/templates/interview-experience-model.html index 5d4913c9..bdc63846 100644 --- a/src/main/resources/templates/interview-experience-model.html +++ b/src/main/resources/templates/interview-experience-model.html @@ -39,8 +39,6 @@
- 历史平均分: -
标准答案:

From b10649724b011e1b51821a287a17246d0a18b3ab Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Wed, 16 Oct 2024 13:32:39 +0800 Subject: [PATCH 076/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/GlobalExceptionHandler.java | 55 ++++++++++--------- .../achobeta/interceptor/UserInterceptor.java | 19 +++---- 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/achobeta/handler/GlobalExceptionHandler.java b/src/main/java/com/achobeta/handler/GlobalExceptionHandler.java index 35527199..32f29484 100644 --- a/src/main/java/com/achobeta/handler/GlobalExceptionHandler.java +++ b/src/main/java/com/achobeta/handler/GlobalExceptionHandler.java @@ -1,12 +1,14 @@ package com.achobeta.handler; import com.achobeta.common.SystemJsonResponse; -import com.achobeta.common.enums.GlobalServiceStatusCode; +import com.achobeta.config.RequestIdConfig; import com.achobeta.exception.GlobalServiceException; import com.mysql.jdbc.MysqlDataTruncation; import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.ConstraintViolation; import jakarta.validation.ConstraintViolationException; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.tomcat.util.http.fileupload.FileUploadException; import org.springframework.dao.DataIntegrityViolationException; @@ -32,38 +34,43 @@ */ @Slf4j @RestControllerAdvice +@RequiredArgsConstructor public class GlobalExceptionHandler { + private final RequestIdConfig requestIdConfig; + + private void logError(HttpServletRequest request, HttpServletResponse response, Exception e) { + log.error("请求 {} 访问接口 {},错误信息 {}", + response.getHeader(requestIdConfig.getHeader()), + request.getRequestURI(), + e.getMessage() + ); + } + @ExceptionHandler(GlobalServiceException.class) - public SystemJsonResponse handleGlobalServiceException(GlobalServiceException e, HttpServletRequest request) { - String requestURI = request.getRequestURI(); - String message = e.getMessage(); - GlobalServiceStatusCode statusCode = e.getStatusCode(); - log.error("请求地址'{}', {}: '{}'", requestURI, statusCode, message); - return SystemJsonResponse.CUSTOMIZE_MSG_ERROR(statusCode, message); + public SystemJsonResponse handleGlobalServiceException(GlobalServiceException e, HttpServletRequest request, HttpServletResponse response) { + logError(request, response, e); + return SystemJsonResponse.CUSTOMIZE_MSG_ERROR(e.getStatusCode(), e.getMessage()); } @ExceptionHandler({FileUploadException.class}) - public SystemJsonResponse handleFileUploadException(FileUploadException e, HttpServletRequest request) { - String requestURI = request.getRequestURI(); - String message = e.getMessage(); - log.error("请求地址'{}', '{}'", requestURI, message); + public SystemJsonResponse handleFileUploadException(FileUploadException e, HttpServletRequest request, HttpServletResponse response) { + logError(request, response, e); + String message = "文件上传异常"; return SystemJsonResponse.CUSTOMIZE_MSG_ERROR(RESOURCE_NOT_VALID, message); } @ExceptionHandler({DataIntegrityViolationException.class}) - public SystemJsonResponse handleDataIntegrityViolationException(DataIntegrityViolationException e, HttpServletRequest request) { - String requestURI = request.getRequestURI(); - String message = e.getCause() instanceof MysqlDataTruncation ? "文本长度超出限制" : "数据异常"; - log.error("请求地址'{}', '{}', '{}'", requestURI, message, e.getMessage()); + public SystemJsonResponse handleDataIntegrityViolationException(DataIntegrityViolationException e, HttpServletRequest request, HttpServletResponse response) { + logError(request, response, e); + String message = e.getCause() instanceof MysqlDataTruncation ? "数据截断,请检查长度、范围和类型" : "数据非法"; return SystemJsonResponse.CUSTOMIZE_MSG_ERROR(SYSTEM_SERVICE_ERROR, message); } @ExceptionHandler({SQLException.class}) - public SystemJsonResponse handleSQLException(SQLException e, HttpServletRequest request) { - String requestURI = request.getRequestURI(); - String message = "数据异常"; - log.error("请求地址'{}', '{}', '{}'", requestURI, message, e.getMessage()); + public SystemJsonResponse handleSQLException(SQLException e, HttpServletRequest request, HttpServletResponse response) { + logError(request, response, e); + String message = "数据访问与交互异常"; return SystemJsonResponse.CUSTOMIZE_MSG_ERROR(SYSTEM_SERVICE_ERROR, message); } @@ -71,9 +78,8 @@ public SystemJsonResponse handleSQLException(SQLException e, HttpServletRequest * 自定义验证异常 */ @ExceptionHandler(ConstraintViolationException.class) - public SystemJsonResponse constraintViolationException(ConstraintViolationException e, HttpServletRequest request) { - String requestURI = request.getRequestURI(); - log.error("请求地址'{}', 自定义验证异常'{}'", requestURI, e.getMessage()); + public SystemJsonResponse constraintViolationException(ConstraintViolationException e, HttpServletRequest request, HttpServletResponse response) { + logError(request, response, e); String message = e.getConstraintViolations().stream() .map(ConstraintViolation::getMessage) .filter(Objects::nonNull) @@ -82,9 +88,8 @@ public SystemJsonResponse constraintViolationException(ConstraintViolationExcept } @ExceptionHandler(MethodArgumentNotValidException.class) - public SystemJsonResponse ValidationHandler(MethodArgumentNotValidException e, HttpServletRequest request) { - String requestURI = request.getRequestURI(); - log.error("请求地址'{}', 自定义验证异常'{}'", requestURI, e.getMessage()); + public SystemJsonResponse ValidationHandler(MethodArgumentNotValidException e, HttpServletRequest request, HttpServletResponse response) { + logError(request, response, e); String message = e.getBindingResult().getFieldErrors().stream() .map(FieldError::getDefaultMessage) .filter(Objects::nonNull) diff --git a/src/main/java/com/achobeta/interceptor/UserInterceptor.java b/src/main/java/com/achobeta/interceptor/UserInterceptor.java index 9c454a9e..7e5518d9 100644 --- a/src/main/java/com/achobeta/interceptor/UserInterceptor.java +++ b/src/main/java/com/achobeta/interceptor/UserInterceptor.java @@ -88,15 +88,16 @@ public UserHelper getUserHelper() { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + // 设置请求 id + long requestId = requestIdGenerator.nextId(); + response.setHeader(requestIdConfig.getHeader(), String.valueOf(requestId)); + //可以解决拦截器跨域问题 if (!(handler instanceof HandlerMethod)) { // 并不处理非目标方法的请求 // todo: 例如通过本服务,但不是通过目标方法获取资源的请求,而这些请求需要进行其他的处理! return Boolean.TRUE; } - // 设置请求 id - long requestId = requestIdGenerator.nextId(); - response.setHeader(requestIdConfig.getHeader(), String.valueOf(requestId)); // 获取目标方法 Method targetMethod = ((HandlerMethod) handler).getMethod(); // 获取 intercept 注解实例 @@ -123,13 +124,11 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons @Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { try { - if(handler instanceof HandlerMethod) { - String requestId = response.getHeader(requestIdConfig.getHeader()); - log.warn("请求 {} 访问接口 {},响应 HTTP 状态码 {},错误信息 {}", - requestId, request.getRequestURI(), response.getStatus(), - Optional.ofNullable(ex).map(Exception::getMessage).orElse(null) - ); - } + String requestId = response.getHeader(requestIdConfig.getHeader()); + log.warn("请求 {} 访问接口 {},响应 HTTP 状态码 {},错误信息 {}", + requestId, request.getRequestURI(), response.getStatus(), + Optional.ofNullable(ex).map(Exception::getMessage).orElse(null) + ); } finally { log.info("删除本地线程变量"); BaseContext.removeCurrentUser(); From de9cb6aef3afb174b0d508cadb7a017d1f15d2fc Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Wed, 16 Oct 2024 13:45:52 +0800 Subject: [PATCH 077/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resource/service/impl/ObjectStorageMinioServiceImpl.java | 2 +- .../domain/resource/service/impl/ResourceServiceImpl.java | 5 +++-- src/main/java/com/achobeta/util/MediaUtil.java | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/achobeta/domain/resource/service/impl/ObjectStorageMinioServiceImpl.java b/src/main/java/com/achobeta/domain/resource/service/impl/ObjectStorageMinioServiceImpl.java index d7a50673..0068d329 100644 --- a/src/main/java/com/achobeta/domain/resource/service/impl/ObjectStorageMinioServiceImpl.java +++ b/src/main/java/com/achobeta/domain/resource/service/impl/ObjectStorageMinioServiceImpl.java @@ -112,7 +112,7 @@ public String compressImage(Long userId, String fileName) throws Exception { // 压缩图片 bytes = MediaUtil.compressImage(bytes); // 上传图片 - String uniqueFileName = ResourceUtil.getUniqueFileName(userId, "." + MediaUtil.COMPRESS_FORMAT_NAME); + String uniqueFileName = ResourceUtil.getUniqueFileName(userId, MediaUtil.COMPRESS_FORMAT_SUFFIX); minioEngine.upload(uniqueFileName, bytes); return uniqueFileName; } diff --git a/src/main/java/com/achobeta/domain/resource/service/impl/ResourceServiceImpl.java b/src/main/java/com/achobeta/domain/resource/service/impl/ResourceServiceImpl.java index 1c1ccdb2..80ca3366 100644 --- a/src/main/java/com/achobeta/domain/resource/service/impl/ResourceServiceImpl.java +++ b/src/main/java/com/achobeta/domain/resource/service/impl/ResourceServiceImpl.java @@ -167,7 +167,8 @@ public Long upload(Long userId, String originalName, byte[] data, ResourceAccess if(ResourceUtil.matchType(contentType, ResourceType.IMAGE) && compressionThreshold.compareTo(data.length) <= 0) { // 压缩图片 data = MediaUtil.compressImage(data); - originalName = ResourceUtil.changeExtension(originalName, MediaUtil.COMPRESS_FORMAT_NAME); + suffix = MediaUtil.COMPRESS_FORMAT_SUFFIX; + originalName = ResourceUtil.changeSuffix(originalName, suffix); } else { // 使用原后缀 suffix = ResourceUtil.getSuffix(originalName); @@ -307,7 +308,7 @@ public void compressImage(Long code) throws Exception { String compressImage = objectStorageService.compressImage(resource.getUserId(), resource.getFileName()); digitalResourceService.renameDigitalResource( resource.getId(), - ResourceUtil.changeExtension(resource.getOriginalName(), MediaUtil.COMPRESS_FORMAT_NAME), + ResourceUtil.changeSuffix(resource.getOriginalName(), MediaUtil.COMPRESS_FORMAT_SUFFIX), compressImage ); } diff --git a/src/main/java/com/achobeta/util/MediaUtil.java b/src/main/java/com/achobeta/util/MediaUtil.java index a6b6d4a7..3c4c0e18 100644 --- a/src/main/java/com/achobeta/util/MediaUtil.java +++ b/src/main/java/com/achobeta/util/MediaUtil.java @@ -27,6 +27,8 @@ public class MediaUtil { public final static String COMPRESS_FORMAT_NAME = "jpg"; // 压缩图片格式 + public final static String COMPRESS_FORMAT_SUFFIX = "." + COMPRESS_FORMAT_NAME; // 压缩图片格式 + public final static float COMPRESS_SCALE = 1.0f; // 压缩图片大小 public final static float COMPRESS_QUALITY = 0.5f; // 压缩图片质量 From 2c516690dcc542a46b41c9ded199499e51213df4 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Wed, 16 Oct 2024 16:00:43 +0800 Subject: [PATCH 078/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/resource/service/ResourceService.java | 2 +- .../resource/service/impl/ResourceServiceImpl.java | 5 +++-- .../student/service/impl/StuResumeServiceImpl.java | 8 +++++++- .../domain/users/service/impl/UserServiceImpl.java | 9 ++++++--- .../mapper/evaluate/ext/InterviewCommentExtMapper.xml | 2 +- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/achobeta/domain/resource/service/ResourceService.java b/src/main/java/com/achobeta/domain/resource/service/ResourceService.java index cbb878f0..f44222bd 100644 --- a/src/main/java/com/achobeta/domain/resource/service/ResourceService.java +++ b/src/main/java/com/achobeta/domain/resource/service/ResourceService.java @@ -35,7 +35,7 @@ public interface ResourceService { void checkImage(Long code); - void checkAndRemoveImage(Long code, Long old); + Boolean shouldRemove(Long code, Long old); String getSystemUrl(Long code); diff --git a/src/main/java/com/achobeta/domain/resource/service/impl/ResourceServiceImpl.java b/src/main/java/com/achobeta/domain/resource/service/impl/ResourceServiceImpl.java index 80ca3366..70526148 100644 --- a/src/main/java/com/achobeta/domain/resource/service/impl/ResourceServiceImpl.java +++ b/src/main/java/com/achobeta/domain/resource/service/impl/ResourceServiceImpl.java @@ -125,11 +125,12 @@ public void checkImage(Long code) { @Override @Transactional - public void checkAndRemoveImage(Long code, Long old) { + public Boolean shouldRemove(Long code, Long old) { if(!code.equals(old)) { checkImage(code); - removeKindly(old); + return Boolean.TRUE; } + return Boolean.FALSE; } @Override diff --git a/src/main/java/com/achobeta/domain/student/service/impl/StuResumeServiceImpl.java b/src/main/java/com/achobeta/domain/student/service/impl/StuResumeServiceImpl.java index ae002648..90a98790 100644 --- a/src/main/java/com/achobeta/domain/student/service/impl/StuResumeServiceImpl.java +++ b/src/main/java/com/achobeta/domain/student/service/impl/StuResumeServiceImpl.java @@ -80,7 +80,8 @@ public void submitResume(StuResumeDTO stuResumeDTO, Long userId) { StuSimpleResumeDTO resumeDTO = stuResumeDTO.getStuSimpleResumeDTO(); // 检测 - resourceService.checkAndRemoveImage(resumeDTO.getImage(), stuResume.getImage()); + Long oldImage = stuResume.getImage(); + Boolean shouldRemove = resourceService.shouldRemove(resumeDTO.getImage(), oldImage); //附件列表 List stuAttachmentDTOList = stuResumeDTO.getStuAttachmentDTOList(); @@ -91,6 +92,11 @@ public void submitResume(StuResumeDTO stuResumeDTO, Long userId) { //保存附件信息 saveStuAttachment(stuAttachmentDTOList, stuResume.getId()); + + // 等提交成功后再删除 + if(Boolean.TRUE.equals(shouldRemove)) { + resourceService.removeKindly(oldImage); + } }, () -> {}, simpleLockStrategy); } diff --git a/src/main/java/com/achobeta/domain/users/service/impl/UserServiceImpl.java b/src/main/java/com/achobeta/domain/users/service/impl/UserServiceImpl.java index 88421b44..8ec37b3d 100644 --- a/src/main/java/com/achobeta/domain/users/service/impl/UserServiceImpl.java +++ b/src/main/java/com/achobeta/domain/users/service/impl/UserServiceImpl.java @@ -56,12 +56,15 @@ public void updateUser(Long userId, UserDTO userDTO) { // 设置默认头像 Long avatar = userDTO.getAvatar(); UserEntity userEntity = UserConverter.INSTANCE.userDTOToUser(userDTO); - getUserById(userId).map(UserEntity::getAvatar).ifPresent(code -> { - resourceService.checkAndRemoveImage(avatar, code); - }); + Long oldAvatar = getUserById(userId).map(UserEntity::getAvatar).orElse(null); + Boolean shouldRemove = resourceService.shouldRemove(avatar, oldAvatar); // 更新 this.lambdaUpdate() .eq(UserEntity::getId, userId) .update(userEntity); + // 更新成功再删除 + if(Boolean.TRUE.equals(shouldRemove)) { + resourceService.removeKindly(oldAvatar); + } } } diff --git a/src/main/resources/mapper/evaluate/ext/InterviewCommentExtMapper.xml b/src/main/resources/mapper/evaluate/ext/InterviewCommentExtMapper.xml index 8510997c..6eab9f40 100644 --- a/src/main/resources/mapper/evaluate/ext/InterviewCommentExtMapper.xml +++ b/src/main/resources/mapper/evaluate/ext/InterviewCommentExtMapper.xml @@ -25,7 +25,7 @@ select c.id, c.content, c.create_time, c.update_time, m.id m_id, m.username m_username, m.nickname m_nickname,m.email m_email, - m.phone_number m_phone_number, m.avatar m_acvtar + m.phone_number m_phone_number, m.avatar m_acvatar from interview i left join interview_comment c on c.interview_id = i.id and c.is_deleted = 0 and i.is_deleted = 0 left join user m on m.id = c.manager_id and m.is_deleted = 0 and c.is_deleted = 0 From 82b9cc4bf56c80dfc2f12685865cca51d22c2841 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Wed, 16 Oct 2024 16:04:12 +0800 Subject: [PATCH 079/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mapper/evaluate/ext/InterviewCommentExtMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/mapper/evaluate/ext/InterviewCommentExtMapper.xml b/src/main/resources/mapper/evaluate/ext/InterviewCommentExtMapper.xml index 6eab9f40..696c6ce9 100644 --- a/src/main/resources/mapper/evaluate/ext/InterviewCommentExtMapper.xml +++ b/src/main/resources/mapper/evaluate/ext/InterviewCommentExtMapper.xml @@ -25,7 +25,7 @@ select c.id, c.content, c.create_time, c.update_time, m.id m_id, m.username m_username, m.nickname m_nickname,m.email m_email, - m.phone_number m_phone_number, m.avatar m_acvatar + m.phone_number m_phone_number, m.avatar m_avatar from interview i left join interview_comment c on c.interview_id = i.id and c.is_deleted = 0 and i.is_deleted = 0 left join user m on m.id = c.manager_id and m.is_deleted = 0 and c.is_deleted = 0 From 78c0b9d666f8849a2ce13cf84191b43299d29d51 Mon Sep 17 00:00:00 2001 From: BanTanger <1290288968@qq.com> Date: Wed, 16 Oct 2024 16:05:25 +0800 Subject: [PATCH 080/104] =?UTF-8?q?feat:=20docker=20=E5=9F=BA=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 14 + build.sh | 22 +- docker-compose.yml | 179 ++++++++- docker/mysql/Dockerfile | 9 + docker/mysql/conf/my.conf | 57 +++ docker/mysql/db/recruitment-core.sql | 559 +++++++++++++++++++++++++++ docker/rabbitmq/enabled_plugins | 1 + docker/redis/Dockerfile | 14 + docker/redis/conf/redis.conf | 5 + dockerfile | 22 +- 10 files changed, 860 insertions(+), 22 deletions(-) create mode 100644 Dockerfile create mode 100644 docker/mysql/Dockerfile create mode 100644 docker/mysql/conf/my.conf create mode 100644 docker/mysql/db/recruitment-core.sql create mode 100644 docker/rabbitmq/enabled_plugins create mode 100644 docker/redis/Dockerfile create mode 100644 docker/redis/conf/redis.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..de055307 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# 基础镜像 +FROM openjdk:21 + +# 配置 +ENV PARAMS="" + +# 时区 +ENV TZ=PRC +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +# 添加应用 +ADD ../target/AchoBeta-Recruitment-1.0.jar /AchoBeta-Recruitment-1.0.jar + +ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS /AchoBeta-Recruitment-1.0.jar $PARAMS"] diff --git a/build.sh b/build.sh index e273e82d..ff583106 100644 --- a/build.sh +++ b/build.sh @@ -1,5 +1,17 @@ -#!/bin/zsh -# shellcheck disable=SC2164 -mvn clean install package -Dmaven.test.skip=true -docker-compose pull -docker-compose up -d --build \ No newline at end of file +#!/usr/bin/env bash +# Be sure your script exits whenever encounter errors + +echo "--------------------------------" +echo "::: Welcome to AB-Recruitment :::" + +set -e +# Be sure your charset is correct. eg: zh_CN.UTF-8 +export LC_ALL=en_US.UTF-8 +export LANG=en_US.UTF-8 +export LANGUAGE=en_US.UTF-8 + +#mvn clean install package -Dmaven.test.skip=true + +# 普通镜像构建,随系统版本构建 amd/arm + +docker-compose -f docker-compose.yml up -d diff --git a/docker-compose.yml b/docker-compose.yml index ff897245..3d1e1bcc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,175 @@ -version: '3' +# 命令执行 docker-compose -f docker-compose.yml up -d +version: '3.9' services: - recruitment: - container_name: achobeta-recruitment #配置容器名 + mysql: + image: mysql:5.7 + container_name: mysql + command: --default-authentication-plugin=mysql_native_password + restart: always + environment: + TZ: Asia/Shanghai + MYSQL_ROOT_PASSWORD: bitter-macaron + networks: + - my-network + depends_on: + - mysql-job-dbdata + ports: + - "13306:3306" + volumes: + - ./mysql/sql:/docker-entrypoint-initdb.d + - ./mysql/conf/my.conf:/usr/local/etc/mysql/my.conf + healthcheck: + test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] + interval: 5s + timeout: 10s + retries: 10 + start_period: 15s + + # 自动加载数据 + mysql-job-dbdata: + image: alpine:3.18.2 + container_name: mysql-job-dbdata + volumes: + - /var/lib/mysql + + # phpmyadmin https://hub.docker.com/_/phpmyadmin + phpmyadmin: + image: phpmyadmin:5.2.1 + container_name: phpmyadmin + hostname: phpmyadmin + ports: + - 8899:80 + environment: + - PMA_HOST=mysql + - PMA_PORT=13306 + - MYSQL_ROOT_PASSWORD=bitter-macaron + depends_on: + mysql: + condition: service_healthy + networks: + - my-network + + # Redis + redis: + image: redis:6.2 + container_name: redis + restart: always + hostname: redis + privileged: true + ports: + - "6379:6379" + volumes: + - ./redis/conf/redis.conf:/usr/local/etc/redis/redis.conf + command: redis-server /usr/local/etc/redis/redis.conf + networks: + - my-network + healthcheck: + test: [ "CMD", "redis-cli", "ping" ] + interval: 10s + timeout: 5s + retries: 3 + + # RedisAdmin https://github.com/joeferner/redis-commander + # 账密 admin/admin + redis-admin: + image: spryker/redis-commander:0.8.0 + container_name: redis-admin + hostname: redis-commander + restart: always + ports: + - "8081:8081" + environment: + - REDIS_HOSTS=local:redis:6379 + - HTTP_USER=admin + - HTTP_PASSWORD=bitter-macaron + - LANG=C.UTF-8 + - LANGUAGE=C.UTF-8 + - LC_ALL=C.UTF-8 + networks: + - my-network + depends_on: + redis: + condition: service_healthy + + # rabbitmq + # 账密 admin/admin + # rabbitmq-plugins enable rabbitmq_management + rabbitmq: + image: rabbitmq:3.12.9 + container_name: rabbitmq + restart: always + ports: + - "5672:5672" + - "15672:15672" + environment: + RABBITMQ_DEFAULT_USER: itcast + RABBITMQ_DEFAULT_PASS: 123321 + command: rabbitmq-server + volumes: + - ./rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins + networks: + - my-network + + # minio + # minio 的 docker 有问题,一直没法连接,只好先用旧服务器了 + minio: + image: minio/minio:RELEASE.2021-06-17T00-10-46Z + container_name: minio + hostname: minio + privileged: true + restart: always + environment: + # 账号 + MINIO_ROOT_USER: mms + # 密码 + MINIO_ROOT_PASSWORD: bitter-macaron + ports: + - "9005:9005" + - "19005:19005" + volumes: + - ./minio/data:/data + command: server /data + networks: + - my-network + + ab-recruitment-app: + container_name: ab-recruitment-app build: - context: . - dockerfile: ./dockerfile #指定dockerFile文件 - image: java/achobeta-recruitment:1.0.0 # 指定镜像名 + context: ../ + dockerfile: Dockerfile + restart: always ports: - - "9001:9001" # 暴露端口 + - "9001:9001" + environment: + - TZ=PRC + - SERVER_PORT=9001 + - APP_CONFIG_API_VERSION=v1 + - APP_CONFIG_CROSS_ORIGIN=* + - SPRING_DATASOURCE_USERNAME=mms + - SPRING_DATASOURCE_PASSWORD=bitter-macaron + - SPRING_DATASOURCE_URL=jdbc:mysql://mysql:13306/achobeta_recruitment?serverTimezone=UTC&characterEncoding=utf8&autoReconnect=true&serverTimezone=Asia/Shanghai + - SPRING_DATASOURCE_DRIVER_CLASS_NAME=com.mysql.jdbc.Driver + - SPRING_HIKARI_POOL_NAME=Retail_HikariCP + - REDIS_SDK_CONFIG_HOST=redis + - REDIS_SDK_CONFIG_PORT=6379 volumes: - - ./logs:/logs # 创建容器数据卷 \ No newline at end of file + - ./log:/data/log + depends_on: + - redis + - rabbitmq + - mysql + links: + - redis + - rabbitmq + - mysql + networks: + - my-network + logging: + driver: "json-file" + options: + max-size: "10m" + max-file: "3" + +networks: + my-network: + driver: bridge \ No newline at end of file diff --git a/docker/mysql/Dockerfile b/docker/mysql/Dockerfile new file mode 100644 index 00000000..37d7b973 --- /dev/null +++ b/docker/mysql/Dockerfile @@ -0,0 +1,9 @@ +# 基础镜像 +FROM mysql:5.7 + +# author +MAINTAINER BanTanger + +# 执行sql脚本 +# `/docker-entrypoint-initdb.d/`是MySQL官方镜像中的一个特殊目录,用于存放初始化数据库的脚本文件。 +ADD ./db/*.sql /docker-entrypoint-initdb.d/ diff --git a/docker/mysql/conf/my.conf b/docker/mysql/conf/my.conf new file mode 100644 index 00000000..e6ad824e --- /dev/null +++ b/docker/mysql/conf/my.conf @@ -0,0 +1,57 @@ +[mysqld] +# 设置13306端口 +port=13306 + +# 设置mysql的安装目录 +basedir=/usr/local/mysql + +# 设置mysql数据库的数据的存放目录 +datadir=/usr/local/mysql/mysqldb + +# 允许最大连接数 +max_connections=1000 + +# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统 +max_connect_errors=100 + +init_connect='SET collation_connection = utf8_unicode_ci' +init_connect='SET NAMES utf8' + +# 服务端使用的字符集默认为UTF8 +character-set-server=utf8 + +collation-server=utf8_unicode_ci +skip-character-set-client-handshake + +# 创建新表时将使用的默认存储引擎 +default-storage-engine=INNODB + +# 默认使用“mysql_native_password”插件认证 +default_authentication_plugin=mysql_native_password + +#是否对sql语句大小写敏感,1表示不敏感 +lower_case_table_names = 1 + +#MySQL连接闲置超过一定时间后(单位:秒)将会被强行关闭 +#MySQL默认的wait_timeout 值为8个小时, interactive_timeout参数需要同时配置才能生效 +interactive_timeout = 1800 +wait_timeout = 1800 + +#Metadata Lock最大时长(秒), 一般用于控制 alter操作的最大时长sine mysql5.6 +#执行 DML操作时除了增加innodb事务锁外还增加Metadata Lock,其他alter(DDL)session将阻塞 +lock_wait_timeout = 3600 + +#内部内存临时表的最大值。 +#比如大数据量的group by ,order by时可能用到临时表, +#超过了这个值将写入磁盘,系统IO压力增大 +tmp_table_size = 64M +max_heap_table_size = 64M + +[mysql] +# 设置mysql客户端默认字符集 +default-character-set=utf8 + +[client] +# 设置mysql客户端连接服务端时默认使用的端口 +port=13306 +default-character-set=utf8 diff --git a/docker/mysql/db/recruitment-core.sql b/docker/mysql/db/recruitment-core.sql new file mode 100644 index 00000000..71f99c13 --- /dev/null +++ b/docker/mysql/db/recruitment-core.sql @@ -0,0 +1,559 @@ + +drop database if exists achobeta_recruitment; +create database achobeta_recruitment character set utf8mb4 collate utf8mb4_bin; +use achobeta_recruitment; + +drop table if exists `user`; +create table `user` +( + `id` bigint primary key auto_increment comment '用户唯一 id', + `username` varchar(50) not null default '' comment '用户名', + `nickname` varchar(50) not null default '' comment '用户昵称', + `email` varchar(50) not null default '' comment '邮箱', + `phone_number` varchar(11) not null default '' comment '手机号码', + `password` varchar(100) not null default '' comment '密码', + `user_type` int not null default 1 comment '用户类型:1.普通用户 2. 管理员', + `avatar` bigint comment '头像地址', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_email`(`email` asc) using btree, + index `idx_phone`(`phone_number` asc) using btree, + unique `uni_username`(`username` asc) using btree +) auto_increment = 10000 comment = '用户基本信息表'; + +-- root 管理员,username: root; password: AchoBeta666 +insert into user(`username`, `nickname`, `password`, `user_type`) + values('root', 'root', '$2a$10$YPKp0kzLjnNrW5CgKuDdiuF4tZO0KXacmhy2KT7N9Zey49Cmi/rfu', 2); + +drop table if exists `member`; +create table `member` +( + `id` bigint primary key auto_increment comment '正式成员 id', + `resume_id` bigint not null comment '简历 id', + `manager_id` bigint unique not null comment '新开的管理员账号 id', + `parent_id` bigint not null comment '父管理员 id', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_resume_id`(`resume_id` asc) using btree, + unique index `uni_manager_id`(`manager_id` asc) using btree, + index `idx_parent_id`(`parent_id` asc) using btree +) comment '正式成员表'; + +drop table if exists `user_feedback`; +create table `user_feedback` +( + `id` bigint primary key auto_increment comment '反馈 id' , + `user_id` bigint not null comment '用户id', + `batch_id` bigint not null comment '招新批次 id', + `message_id` bigint default null comment '处理结果的消息 id', + `title` varchar(256) default '' not null comment '反馈标题', + `content` text not null comment '反馈内容', + `attachment` bigint default null comment '附件链接', + `feedback_time` datetime default CURRENT_TIMESTAMP not null comment '反馈时间', + `is_handle` bit default b'0' not null comment '是否处理标记', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_user_id`(`user_id` asc) using btree, + index `idx_batch_id`(`batch_id` asc) using btree, + index `idx_message_id`(`message_id` asc) using btree +) comment = '用户反馈表'; + +drop table if exists `interview`; +create table `interview` +( + `id` bigint primary key auto_increment comment '面试 id', + `schedule_id` bigint unsigned not null comment '面试预约 id', + `paper_id` bigint default null comment '面试试卷 id', + `title` varchar(100) not null default '' comment '面试主题', + `description` text not null comment '面试说明', + `status` tinyint not null default 0 comment '是否开始(0未开始、1进行中、2已结束)', + `address` varchar(500) not null default '' comment '线下面试地址/显示面试会议链接', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_schedule_id`(`schedule_id` asc) using btree, + index `idx_paper_id`(`paper_id` asc) using btree +) comment '面试表'; + +drop table if exists `interview_comment`; +create table `interview_comment` +( + `id` bigint primary key auto_increment comment '面评 id', + `interview_id` bigint not null comment '面试 id', + `manager_id` bigint not null comment '管理员 id', + `content` text not null comment '评论内容', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_interview_id`(`interview_id` asc) using btree, + index `idx_manager_id`(`manager_id` asc) using btree +) comment '面试评论表'; + +drop table if exists `interview_question_score`; +create table `interview_question_score` +( + `id` bigint primary key auto_increment comment '面试题评分 id', + `interview_id` bigint not null comment '面试 id', + `question_id` bigint not null comment '问题 id', + `score` int not null comment '评分(0-10,-1为超纲)', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_interview_id`(`interview_id` asc) using btree, + index `idx_question_id`(`question_id` asc) using btree +) comment '面试题评分关联表'; + +drop table if exists `interview_schedule`; +create table `interview_schedule` +( + `id` bigint primary key auto_increment comment '面试预约 id', + `participation_id` bigint not null comment '用户的“活动参与” id', + `start_time` datetime not null comment '预约开始时间', + `end_time` datetime not null comment '预约结束时间', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_participation_id`(`participation_id` asc) using btree +) comment '面试预约表'; + +drop table if exists `interview_summary`; +create table `interview_summary` +( + `id` bigint primary key auto_increment comment '面试总结 id', + `interview_id` bigint not null comment '面试 id', + `basis` tinyint not null default 0 comment '基础理论知识掌握(0-5)', + `coding` tinyint not null default 0 comment '代码能力(0-5)', + `thinking` tinyint not null default 0 comment '思维能力(0-5)', + `express` tinyint not null default 0 comment '表达能力(0-5)', + `evaluate` varchar(500) not null default '' comment '面试总评', + `suggest` varchar(500) not null default '' comment '复习建议', + `playback` varchar(256) not null default '' comment '面试回放链接', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_interview_id`(`interview_id` asc) using btree +) comment '面试总结表'; + +drop table if exists `interviewer`; +create table `interviewer` +( + `id` bigint primary key auto_increment comment '面试官 id', + `manager_id` bigint not null comment '管理员 id', + `schedule_id` bigint not null comment '面试预约 id', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_manager_id`(`manager_id` asc) using btree, + index `idx_schedule_id`(`schedule_id` asc) using btree +) comment '面试官表'; + +drop table if exists `message`; +create table `message` +( + `id` bigint primary key auto_increment comment '消息 id', + `manager_id` bigint not null comment '发送消息的管理员 id', + `user_id` bigint not null comment '用户 id', + `tittle` varchar(256) not null default '' comment '消息标题', + `content` text not null comment '消息内容', + `send_time` datetime not null default current_timestamp comment '发送时间', + `attachment` bigint null default null comment '附件 url', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_manager_id`(`manager_id` asc) using btree, + index `idx_user_id`(`user_id` asc) using btree +) comment = '消息表'; + +drop table if exists `message_template`; +create table `message_template` +( + `id` bigint primary key auto_increment comment '模板消息 id', + `template_title` varchar(100) not null default '' comment '模板消息标题', + `template_content` text not null comment '模板消息内容', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间' +) comment = '模板消息表'; + +drop table if exists `library_paper_link`; +create table `library_paper_link` +( + `id` bigint primary key auto_increment comment 'id', + `lib_id` bigint not null comment '试卷库 id', + `paper_id` bigint not null comment '试卷 id', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_lp_id`(`lib_id` asc, `paper_id`) using btree +) comment '试卷库-试卷关联表'; + +drop table if exists `paper_question_link`; +create table `paper_question_link` +( + `id` bigint primary key auto_increment comment 'id', + `paper_id` bigint not null comment '试卷 id', + `question_id` bigint not null comment '问题 id', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index idx_pq_id(`paper_id` asc, `question_id`) using btree +) comment '试卷-问题关联表'; + +drop table if exists `question_paper`; +create table `question_paper` +( + `id` bigint primary key auto_increment comment '试卷 id', + `title` varchar(100) not null default '' comment '试卷标题', + `description` text not null comment '试卷说明', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间' +) comment '试卷表'; + +drop table if exists `question_paper_library`; +create table `question_paper_library` +( + `id` bigint primary key auto_increment comment '试卷库 id', + `lib_type` varchar(100) not null default '' comment '试卷库的类别,例如技术类的后端试卷,前端试卷;非技术的信息收集试卷;筛选的笔试试卷...', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_lib_type`(`lib_type` asc) using btree +) comment '试卷库表'; + +drop table if exists `library_question_link`; +create table `library_question_link` +( + `id` bigint primary key auto_increment comment 'id', + `lib_id` bigint not null comment '题库 id', + `question_id` bigint not null comment '问题 id', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_lq_id`(`lib_id` asc, `question_id`) using btree +) comment '题库-问题关联表'; + +drop table if exists `question`; +create table `question` +( + `id` bigint primary key auto_increment comment '问题 id', + `title` varchar(2048) not null default '' comment '问题标题', + `standard` text not null comment '问题标答', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间' +) comment '问题表'; + +drop table if exists `question_library`; +create table `question_library` +( + `id` bigint primary key auto_increment comment '题库 id', + `lib_type` varchar(100) not null default '' comment '题库的类别', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_lib_type`(`lib_type` asc) using btree +) comment '题库表'; + +drop table if exists `activity_participation`; +create table `activity_participation` +( + `id` bigint primary key auto_increment comment '“活动参与” id', + `stu_id` bigint not null comment '学生 id', + `act_id` bigint not null comment '活动 id', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_stu_id`(`stu_id` asc) using btree, + index `idx_act_id`(`act_id` asc) using btree +) comment '“活动参与”表'; + +drop table if exists `participation_period_link`; +create table `participation_period_link` +( + `id` bigint primary key auto_increment comment 'id', + `participation_id` bigint not null comment '“活动参与” id', + `period_id` bigint not null comment '时间段 id', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_pp_id`(`participation_id` asc, `period_id` asc) using btree +) comment '“活动参与”-时间段关联表'; + +drop table if exists `participation_question_link`; +create table `participation_question_link` +( + `id` bigint primary key auto_increment comment 'id', + `participation_id` bigint not null comment '“活动参与” id', + `question_id` bigint not null comment '问题 id', + `answer` text not null comment '回答', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_pq_id`(`participation_id` asc, `question_id` asc) using btree +) comment '“活动参与”-问题关联表'; + +drop table if exists `recruitment_activity`; +create table `recruitment_activity` +( + `id` bigint primary key auto_increment comment '招新活动 id', + `batch_id` bigint not null comment '招新批次 id', + `paper_id` bigint default null comment '试卷 id', + `title` varchar(100) not null default '' comment '活动标题', + `target` json not null comment '面向的人群', + `description` text not null comment '活动说明', + `deadline` datetime not null comment '截止时间', + `is_run` bit not null default b'0' comment '是否启动', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_batch_id`(`batch_id` asc) using btree, + index `idx_paper_id`(`paper_id` asc) using btree +) comment '招新活动表'; + +drop table if exists `recruitment_batch`; +create table `recruitment_batch` +( + `id` bigint primary key auto_increment comment '招新批次 id', + `batch` int not null comment 'AchoBeta 届数', + `title` varchar(100) not null default '' comment '招新标题', + `deadline` datetime not null comment '截止时间', + `is_run` bit not null default b'0' comment '是否启动', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_batch`(`batch` asc) using btree +) comment '招新批次表'; + +drop table if exists `time_period`; +create table `time_period` +( + `id` bigint primary key auto_increment comment '时间段 id', + `act_id` bigint not null comment '招新活动 id', + `start_time` datetime not null comment '开始时间', + `end_time` datetime not null comment '结束时间', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_act_id`(`act_id` asc) using btree +) comment '时间段表'; + +drop table if exists `digital_resource`; +create table `digital_resource` +( + `id` bigint primary key auto_increment comment '资源 id', + `code` bigint unique not null comment '资源码', + `user_id` bigint not null comment '上传文件的用户 id', + `access_level` int not null default 2 comment '访问权限', + `original_name` varchar(100) not null comment '上传时的文件名', + `file_name` varchar(256) not null comment '在对象存储服务中存储的对象名', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + unique index `uni_code`(`code` asc) using btree, + index `idx_user_id`(`user_id` asc) using btree +) comment '资源表'; + +drop table if exists `feishu_resource`; +create table `feishu_resource` +( + `id` bigint primary key auto_increment comment '飞书资源 id', + `ticket` varchar(50) unique not null comment '任务 ID', + `original_name` varchar(100) not null comment '上传时的文件名', + `token` varchar(50) not null default '' comment '导入云文档的 token', + `type` varchar(20) not null default '' comment '导入的在线云文档类型', + `url` varchar(200) not null default '' comment '导入云文档的 URL', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + unique index `uni_ticket`(`ticket`) using btree +) comment '飞书资源表'; + +drop table if exists `short_link`; +create table `short_link` +( + `id` bigint primary key auto_increment comment '短链接编号', + `origin_url` varchar(512) default '' comment '原链接', + `short_code` char(6) unique default '' comment '短链code', + `is_used` bit default b'0' comment '是否使用过', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- 索引 + index `idx_short_code`(`short_code` asc) using btree +) comment '长短链关系表'; + +drop table if exists `resume_status_process`; +create table `resume_status_process` +( + `id` bigint primary key auto_increment comment 'id', + `resume_id` bigint not null comment '简历 id', + `resume_status` int not null comment '简历状态', + `resume_event` int not null comment '简历事件', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- 索引 + index `idx_resume_id`(`resume_id` asc) using btree +) comment '招新简历状态过程表'; + +drop table if exists `stu_attachment`; +create table `stu_attachment` +( + `id` bigint primary key auto_increment comment 'id', + `resume_id` bigint not null comment '学生表主键 id', + `filename` varchar(256) not null default '' comment '附件名', + `attachment` bigint not null comment '附件资源码', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_resume_id`(`resume_id` asc) using btree +) comment = '学生附件表'; + +-- 简历状态 comment 说明 +-- 范围:0~16,简历状态{ +-- 0-草稿 +-- 1-待筛选 +-- 2-筛选不通过 +-- +-- 3-待安排初试 +-- 4-待初试 +-- 5-初试通过(仅当初试为最后一个流程时显示) +-- 6-初试不通过(仅当初试为最后一个流程时显示) +-- +-- 7-待安排复试 +-- 8-待复试 +-- 9-复试通过(仅当复试为最后一个流程时显示) +-- 10-复试不通过(仅当复试为最后一个流程时显示) +-- +-- 11-待安排终试 +-- 12-待终试 +-- 13-终试通过(仅当复试为最后一个流程时显示) +-- 14-终试不通过(仅当复试为最后一个流程时显示) +-- +-- 15-待处理(反馈异常/或管理员主动设置为该状态) +-- 16-挂起(管理员可以主动设置该状态) +-- } +-- ---------------------------- +-- 创建学生简历表 +drop table if exists `stu_resume`; +create table `stu_resume` +( + `id` bigint primary key auto_increment comment 'id', + `user_id` bigint not null comment '用户 id', + `batch_id` bigint not null comment '招新批次 id', + `student_id` varchar(13) not null default '' comment '学号', + `name` varchar(10) not null default '' comment '姓名', + `gender` tinyint not null default 0 comment '性别', + `grade` int not null comment '年级', + `major` varchar(20) not null default '' comment '专业', + `class` varchar(30) not null default '' comment '班级', + `email` varchar(50) not null default '' comment '邮箱', + `phone_number` varchar(11) not null default '' comment '手机号码', + `reason` text not null comment '加入 achobeta 的理由', + `introduce` text not null comment '个人介绍(自我认知)', + `experience` text not null comment '个人经历(项目经历、职业规划等)', + `awards` text not null comment '获奖经历', + `image` bigint not null comment '照片', + `remark` varchar(500) not null default '' comment '备注', + `status` int not null default 1 comment '简历状态,范围:0~16', + `submit_count` int not null default 0 comment '提交次数', + -- common column + `version` int not null default 0 comment '乐观锁', + `is_deleted` bit not null default b'0' comment '伪删除标记', + `create_time` datetime not null default current_timestamp comment '创建时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + -- index + index `idx_student_id` (`student_id` asc) using btree, + index `idx_email` (`email` asc) using btree, + index `idx_user_id` (`user_id` asc) using btree, + index `idx_batch_id` (`batch_id` asc) using btree, + index `idx_class` (`class` asc) using btree, + index `idx_major` (`major` asc) using btree, + index `idx_name` (`name` asc) using btree +) comment = '学生简历表'; diff --git a/docker/rabbitmq/enabled_plugins b/docker/rabbitmq/enabled_plugins new file mode 100644 index 00000000..90fdaa37 --- /dev/null +++ b/docker/rabbitmq/enabled_plugins @@ -0,0 +1 @@ +[rabbitmq_management]. \ No newline at end of file diff --git a/docker/redis/Dockerfile b/docker/redis/Dockerfile new file mode 100644 index 00000000..845d6315 --- /dev/null +++ b/docker/redis/Dockerfile @@ -0,0 +1,14 @@ +# 基础镜像 +FROM redis:6.0.8 +# author +MAINTAINER BanTanger + +EXPOSE 6379 +# 挂载目录 +VOLUME /home/order/redis +# 创建目录 +RUN mkdir -p /home/order/redis +# 指定路径 +WORKDIR /home/order/redis +# 复制conf文件到路径 +COPY ./conf/redis.conf /home/order/redis/redis.conf diff --git a/docker/redis/conf/redis.conf b/docker/redis/conf/redis.conf new file mode 100644 index 00000000..8fe64b4e --- /dev/null +++ b/docker/redis/conf/redis.conf @@ -0,0 +1,5 @@ +bind 0.0.0.0 +requirepass bitter-macaron +protected-mode no +appendonly yes +daemonize no diff --git a/dockerfile b/dockerfile index 433514a0..d8264b39 100644 --- a/dockerfile +++ b/dockerfile @@ -1,10 +1,14 @@ -# 以jdk8为基础镜像 +# 基础镜像 FROM openjdk:21 -# 描述 -LABEL description="AchoBeta Recruitment" -# 暴露接口 -EXPOSE 9001 -# 将主机中的jar包添加到镜像中 -ADD target/AchoBeta-Recruitment-1.0.jar AchoBeta-Recruitment-1.0.jar -# 运行jar包 -ENTRYPOINT ["java", "-jar","AchoBeta-Recruitment-1.0.jar"] \ No newline at end of file + +# 配置 +ENV PARAMS="" + +# 时区 +ENV TZ=PRC +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +# 添加应用 +ADD target/AchoBeta-Recruitment-1.0.jar /AchoBeta-Recruitment-1.0.jar + +ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS /AchoBeta-Recruitment-1.0.jar $PARAMS"] From 9d0825eb50b6447a2e415f96d6537a6b5dddcccd Mon Sep 17 00:00:00 2001 From: BanTanger <1290288968@qq.com> Date: Wed, 16 Oct 2024 16:05:48 +0800 Subject: [PATCH 081/104] =?UTF-8?q?feat:=20docker=20=E5=9F=BA=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- dockerfile | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 dockerfile diff --git a/Dockerfile b/Dockerfile index de055307..d8264b39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,6 @@ ENV TZ=PRC RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # 添加应用 -ADD ../target/AchoBeta-Recruitment-1.0.jar /AchoBeta-Recruitment-1.0.jar +ADD target/AchoBeta-Recruitment-1.0.jar /AchoBeta-Recruitment-1.0.jar ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS /AchoBeta-Recruitment-1.0.jar $PARAMS"] diff --git a/dockerfile b/dockerfile deleted file mode 100644 index d8264b39..00000000 --- a/dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -# 基础镜像 -FROM openjdk:21 - -# 配置 -ENV PARAMS="" - -# 时区 -ENV TZ=PRC -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone - -# 添加应用 -ADD target/AchoBeta-Recruitment-1.0.jar /AchoBeta-Recruitment-1.0.jar - -ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS /AchoBeta-Recruitment-1.0.jar $PARAMS"] From 7756f860321c677413e356b09cead5774d8388cd Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Wed, 16 Oct 2024 21:17:08 +0800 Subject: [PATCH 082/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PaperLibraryController.java | 11 ++++++++ .../model/dao/mapper/QuestionPaperMapper.java | 2 ++ .../model/dto/LibraryReferencePaperDTO.java | 25 +++++++++++++++++++ .../paper/model/dto/PaperLibraryDTO.java | 2 +- .../paper/model/dto/PaperQuestionLinkDTO.java | 3 ++- .../paper/model/dto/QuestionPaperDTO.java | 5 ++-- .../paper/service/QuestionPaperService.java | 2 ++ .../impl/QuestionPaperServiceImpl.java | 16 ++++++++++++ .../controller/QuestionLibraryController.java | 11 ++++++++ .../model/dao/mapper/QuestionMapper.java | 2 ++ .../dto/LibraryReferenceQuestionDTO.java | 25 +++++++++++++++++++ .../model/dto/QuestionLibraryDTO.java | 2 +- .../question/service/QuestionService.java | 2 ++ .../service/impl/QuestionServiceImpl.java | 16 ++++++++++++ .../paper/ext/QuestionPaperExtMapper.xml | 19 ++++++++++++++ .../mapper/question/ext/QuestionExtMapper.xml | 19 ++++++++++++++ 16 files changed, 156 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/achobeta/domain/paper/model/dto/LibraryReferencePaperDTO.java create mode 100644 src/main/java/com/achobeta/domain/question/model/dto/LibraryReferenceQuestionDTO.java diff --git a/src/main/java/com/achobeta/domain/paper/controller/PaperLibraryController.java b/src/main/java/com/achobeta/domain/paper/controller/PaperLibraryController.java index 6442b9e8..20ec0aad 100644 --- a/src/main/java/com/achobeta/domain/paper/controller/PaperLibraryController.java +++ b/src/main/java/com/achobeta/domain/paper/controller/PaperLibraryController.java @@ -4,9 +4,11 @@ import com.achobeta.common.annotation.Intercept; import com.achobeta.common.enums.UserTypeEnum; import com.achobeta.domain.paper.model.converter.LibraryConverter; +import com.achobeta.domain.paper.model.dto.LibraryReferencePaperDTO; import com.achobeta.domain.paper.model.dto.PaperLibraryDTO; import com.achobeta.domain.paper.model.entity.QuestionPaperLibrary; import com.achobeta.domain.paper.service.QuestionPaperLibraryService; +import com.achobeta.domain.paper.service.QuestionPaperService; import jakarta.validation.Valid; import jakarta.validation.constraints.NotBlank; import lombok.RequiredArgsConstructor; @@ -33,12 +35,21 @@ public class PaperLibraryController { private final QuestionPaperLibraryService questionPaperLibraryService; + private final QuestionPaperService questionPaperService; + @PostMapping("/create") public SystemJsonResponse createPaperLibrary(@RequestParam("libType") @NotBlank String libType) { Long paperLibraryId = questionPaperLibraryService.createPaperLibrary(libType); return SystemJsonResponse.SYSTEM_SUCCESS(paperLibraryId); } + @PostMapping("/reference") + public SystemJsonResponse referencePapers(@Valid @RequestBody LibraryReferencePaperDTO libraryReferencePaperDTO) { + // 引用 + questionPaperService.referencePapers(libraryReferencePaperDTO.getLibId(), libraryReferencePaperDTO.getPaperIds()); + return SystemJsonResponse.SYSTEM_SUCCESS(); + } + @PostMapping("/rename") public SystemJsonResponse renamePaperLibrary(@Valid @RequestBody PaperLibraryDTO paperLibraryDTO) { // 检查 diff --git a/src/main/java/com/achobeta/domain/paper/model/dao/mapper/QuestionPaperMapper.java b/src/main/java/com/achobeta/domain/paper/model/dao/mapper/QuestionPaperMapper.java index d8270db0..2b0993f1 100644 --- a/src/main/java/com/achobeta/domain/paper/model/dao/mapper/QuestionPaperMapper.java +++ b/src/main/java/com/achobeta/domain/paper/model/dao/mapper/QuestionPaperMapper.java @@ -17,6 +17,8 @@ public interface QuestionPaperMapper extends BaseMapper { // 并不会将结果集加入 page,而是返回值 IPage 里 IPage queryPapers(IPage page, @Param("libIds") List libIds); + + List getPapers(@Param("libIds") List libIds); } diff --git a/src/main/java/com/achobeta/domain/paper/model/dto/LibraryReferencePaperDTO.java b/src/main/java/com/achobeta/domain/paper/model/dto/LibraryReferencePaperDTO.java new file mode 100644 index 00000000..fc3fc0f9 --- /dev/null +++ b/src/main/java/com/achobeta/domain/paper/model/dto/LibraryReferencePaperDTO.java @@ -0,0 +1,25 @@ +package com.achobeta.domain.paper.model.dto; + +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.util.List; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-10-16 + * Time: 20:43 + */ +@Data +public class LibraryReferencePaperDTO { + + @NotNull(message = "试卷库 id 不能为空") + private Long libId; + + @NotEmpty(message = "试卷 id 列表不能为空") + private List paperIds; + +} diff --git a/src/main/java/com/achobeta/domain/paper/model/dto/PaperLibraryDTO.java b/src/main/java/com/achobeta/domain/paper/model/dto/PaperLibraryDTO.java index e6de6bc9..7d9dfbde 100644 --- a/src/main/java/com/achobeta/domain/paper/model/dto/PaperLibraryDTO.java +++ b/src/main/java/com/achobeta/domain/paper/model/dto/PaperLibraryDTO.java @@ -14,7 +14,7 @@ @Data public class PaperLibraryDTO { - @NotNull(message = "库的 id 不能为空") + @NotNull(message = "试卷库 id 不能为空") private Long libId; @NotBlank(message = "库的类型不能为空") diff --git a/src/main/java/com/achobeta/domain/paper/model/dto/PaperQuestionLinkDTO.java b/src/main/java/com/achobeta/domain/paper/model/dto/PaperQuestionLinkDTO.java index 34f39141..8a149324 100644 --- a/src/main/java/com/achobeta/domain/paper/model/dto/PaperQuestionLinkDTO.java +++ b/src/main/java/com/achobeta/domain/paper/model/dto/PaperQuestionLinkDTO.java @@ -1,5 +1,6 @@ package com.achobeta.domain.paper.model.dto; +import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import lombok.Data; @@ -18,7 +19,7 @@ public class PaperQuestionLinkDTO { @NotNull(message = "试卷 id 不能为空") private Long paperId; - @NotNull(message = "问题 ids 不能为空") + @NotEmpty(message = "问题 ids 不能为空") private List questionIds; } diff --git a/src/main/java/com/achobeta/domain/paper/model/dto/QuestionPaperDTO.java b/src/main/java/com/achobeta/domain/paper/model/dto/QuestionPaperDTO.java index e15294e2..24361403 100644 --- a/src/main/java/com/achobeta/domain/paper/model/dto/QuestionPaperDTO.java +++ b/src/main/java/com/achobeta/domain/paper/model/dto/QuestionPaperDTO.java @@ -1,7 +1,7 @@ package com.achobeta.domain.paper.model.dto; import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.NotEmpty; import lombok.Data; import java.util.List; @@ -16,7 +16,7 @@ @Data public class QuestionPaperDTO { - @NotNull(message = "试卷库 ids 不能为空") + @NotEmpty(message = "试卷库 ids 不能为空") private List libIds; @NotBlank(message = "题目不能为空") @@ -25,5 +25,4 @@ public class QuestionPaperDTO { @NotBlank(message = "试卷说明不能为空") private String description; - } diff --git a/src/main/java/com/achobeta/domain/paper/service/QuestionPaperService.java b/src/main/java/com/achobeta/domain/paper/service/QuestionPaperService.java index 5565f0c9..2363f269 100644 --- a/src/main/java/com/achobeta/domain/paper/service/QuestionPaperService.java +++ b/src/main/java/com/achobeta/domain/paper/service/QuestionPaperService.java @@ -21,6 +21,8 @@ public interface QuestionPaperService extends IService { Long addQuestionPaper(List libIds, String title, String description); + void referencePapers(Long libId, List paperIds); + void updateQuestionPaper(Long paperId, List libIds, String title, String description); /** diff --git a/src/main/java/com/achobeta/domain/paper/service/impl/QuestionPaperServiceImpl.java b/src/main/java/com/achobeta/domain/paper/service/impl/QuestionPaperServiceImpl.java index eff1936b..51876914 100644 --- a/src/main/java/com/achobeta/domain/paper/service/impl/QuestionPaperServiceImpl.java +++ b/src/main/java/com/achobeta/domain/paper/service/impl/QuestionPaperServiceImpl.java @@ -19,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.stream.Collectors; /** * @author 马拉圈 @@ -77,6 +78,21 @@ public Long addQuestionPaper(List libIds, String title, String description return paperId; } + @Override + public void referencePapers(Long libId, List paperIds) { + Set hash = questionPaperMapper.getPapers(List.of(libId)).stream().map(QuestionPaper::getId).collect(Collectors.toSet()); + List libraryPaperLinkList = paperIds.stream() + .distinct() + .filter(paperId -> Objects.nonNull(paperId) && !hash.contains(paperId)) + .map(paperId -> { + LibraryPaperLink libraryPaperLink = new LibraryPaperLink(); + libraryPaperLink.setPaperId(paperId); + libraryPaperLink.setLibId(libId); + return libraryPaperLink; + }).toList(); + libraryPaperLinkService.saveBatch(libraryPaperLinkList); + } + @Override @Transactional public void updateQuestionPaper(Long paperId, List libIds, String title, String description) { diff --git a/src/main/java/com/achobeta/domain/question/controller/QuestionLibraryController.java b/src/main/java/com/achobeta/domain/question/controller/QuestionLibraryController.java index 75929d49..03bf1c28 100644 --- a/src/main/java/com/achobeta/domain/question/controller/QuestionLibraryController.java +++ b/src/main/java/com/achobeta/domain/question/controller/QuestionLibraryController.java @@ -4,9 +4,11 @@ import com.achobeta.common.annotation.Intercept; import com.achobeta.common.enums.UserTypeEnum; import com.achobeta.domain.paper.model.converter.LibraryConverter; +import com.achobeta.domain.question.model.dto.LibraryReferenceQuestionDTO; import com.achobeta.domain.question.model.dto.QuestionLibraryDTO; import com.achobeta.domain.question.model.entity.QuestionLibrary; import com.achobeta.domain.question.service.QuestionLibraryService; +import com.achobeta.domain.question.service.QuestionService; import jakarta.validation.Valid; import jakarta.validation.constraints.NotBlank; import lombok.RequiredArgsConstructor; @@ -33,12 +35,21 @@ public class QuestionLibraryController { private final QuestionLibraryService questionLibraryService; + private final QuestionService questionService; + @PostMapping("/create") public SystemJsonResponse createQuestionLibrary(@RequestParam("libType") @NotBlank String libType) { Long questionLibraryId = questionLibraryService.createQuestionLibrary(libType); return SystemJsonResponse.SYSTEM_SUCCESS(questionLibraryId); } + @PostMapping("/reference") + public SystemJsonResponse referenceQuestions(@Valid @RequestBody LibraryReferenceQuestionDTO libraryReferenceQuestionDTO) { + // 引用 + questionService.referenceQuestions(libraryReferenceQuestionDTO.getLibId(), libraryReferenceQuestionDTO.getQuestionIds()); + return SystemJsonResponse.SYSTEM_SUCCESS(); + } + @PostMapping("/rename") public SystemJsonResponse renameQuestionLibrary(@Valid @RequestBody QuestionLibraryDTO questionLibraryDTO) { // 检查 diff --git a/src/main/java/com/achobeta/domain/question/model/dao/mapper/QuestionMapper.java b/src/main/java/com/achobeta/domain/question/model/dao/mapper/QuestionMapper.java index abcb0c6a..eb41d0d2 100644 --- a/src/main/java/com/achobeta/domain/question/model/dao/mapper/QuestionMapper.java +++ b/src/main/java/com/achobeta/domain/question/model/dao/mapper/QuestionMapper.java @@ -18,6 +18,8 @@ public interface QuestionMapper extends BaseMapper { // 并不会将结果集加入 page,而是返回值 IPage 里 IPage queryQuestions(IPage page, @Param("libIds") List libIds); + List getQuestions(@Param("libIds") List libIds); + } diff --git a/src/main/java/com/achobeta/domain/question/model/dto/LibraryReferenceQuestionDTO.java b/src/main/java/com/achobeta/domain/question/model/dto/LibraryReferenceQuestionDTO.java new file mode 100644 index 00000000..9de7a50b --- /dev/null +++ b/src/main/java/com/achobeta/domain/question/model/dto/LibraryReferenceQuestionDTO.java @@ -0,0 +1,25 @@ +package com.achobeta.domain.question.model.dto; + +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.util.List; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-10-16 + * Time: 20:22 + */ +@Data +public class LibraryReferenceQuestionDTO { + + @NotNull(message = "题库 id 不能为空") + private Long libId; + + @NotEmpty(message = "问题 id 列表不能为空") + private List questionIds; + +} diff --git a/src/main/java/com/achobeta/domain/question/model/dto/QuestionLibraryDTO.java b/src/main/java/com/achobeta/domain/question/model/dto/QuestionLibraryDTO.java index 3064be85..41cea0b5 100644 --- a/src/main/java/com/achobeta/domain/question/model/dto/QuestionLibraryDTO.java +++ b/src/main/java/com/achobeta/domain/question/model/dto/QuestionLibraryDTO.java @@ -14,7 +14,7 @@ @Data public class QuestionLibraryDTO { - @NotNull(message = "库的 id 不能为空") + @NotNull(message = "题库 id 不能为空") private Long libId; @NotBlank(message = "库的类型不能为空") diff --git a/src/main/java/com/achobeta/domain/question/service/QuestionService.java b/src/main/java/com/achobeta/domain/question/service/QuestionService.java index 2bf8bce9..da9c9079 100644 --- a/src/main/java/com/achobeta/domain/question/service/QuestionService.java +++ b/src/main/java/com/achobeta/domain/question/service/QuestionService.java @@ -23,6 +23,8 @@ public interface QuestionService extends IService { Long addQuestion(List libIds, String title, String standard); + void referenceQuestions(Long libId, List questionIds); + void saveBatchQuestion(QuestionSaveBatchDTO questionSaveBatchDTO); void updateQuestion(Long questionId, List libIds, String title, String standard); diff --git a/src/main/java/com/achobeta/domain/question/service/impl/QuestionServiceImpl.java b/src/main/java/com/achobeta/domain/question/service/impl/QuestionServiceImpl.java index 6c4c475e..52c14c82 100644 --- a/src/main/java/com/achobeta/domain/question/service/impl/QuestionServiceImpl.java +++ b/src/main/java/com/achobeta/domain/question/service/impl/QuestionServiceImpl.java @@ -27,6 +27,7 @@ import org.springframework.util.CollectionUtils; import java.util.*; +import java.util.stream.Collectors; /** * @author 马拉圈 @@ -90,6 +91,21 @@ public Long addQuestion(List libIds, String title, String standard) { return questionId; } + @Override + public void referenceQuestions(Long libId, List questionIds) { + Set hash = questionMapper.getQuestions(List.of(libId)).stream().map(Question::getId).collect(Collectors.toSet()); + List libraryQuestionLinkList = questionIds.stream() + .distinct() + .filter(questionId -> Objects.nonNull(questionId) && !hash.contains(questionId)) + .map(questionId -> { + LibraryQuestionLink libraryQuestionLink = new LibraryQuestionLink(); + libraryQuestionLink.setQuestionId(questionId); + libraryQuestionLink.setLibId(libId); + return libraryQuestionLink; + }).toList(); + libraryQuestionLinkService.saveBatch(libraryQuestionLinkList); + } + @Override @Transactional public void saveBatchQuestion(QuestionSaveBatchDTO questionSaveBatchDTO) { diff --git a/src/main/resources/mapper/paper/ext/QuestionPaperExtMapper.xml b/src/main/resources/mapper/paper/ext/QuestionPaperExtMapper.xml index c6fd0986..6c027d12 100644 --- a/src/main/resources/mapper/paper/ext/QuestionPaperExtMapper.xml +++ b/src/main/resources/mapper/paper/ext/QuestionPaperExtMapper.xml @@ -31,4 +31,23 @@ order by lp_create_time asc + + diff --git a/src/main/resources/mapper/question/ext/QuestionExtMapper.xml b/src/main/resources/mapper/question/ext/QuestionExtMapper.xml index 5ddf8826..927e36ec 100644 --- a/src/main/resources/mapper/question/ext/QuestionExtMapper.xml +++ b/src/main/resources/mapper/question/ext/QuestionExtMapper.xml @@ -30,4 +30,23 @@
order by lq_create_time asc + + From 308bcebb890d32f2cca46d61f8bc5ec99b0376cc Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Wed, 16 Oct 2024 21:42:39 +0800 Subject: [PATCH 083/104] =?UTF-8?q?fix:=20=E4=BD=BF=E7=94=A8=20redis=20?= =?UTF-8?q?=E9=94=81=E9=81=BF=E5=85=8D=E5=87=BA=E7=8E=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constants/PaperLibraryConstants.java | 14 +++++++ .../constants/QuestionPaperConstants.java | 14 +++++++ .../impl/PaperQuestionLinkServiceImpl.java | 41 +++++++++++-------- .../impl/QuestionPaperServiceImpl.java | 31 +++++++++----- .../constants/QuestionLibraryConstants.java | 16 ++++++++ .../service/impl/QuestionServiceImpl.java | 32 +++++++++------ .../mapper/question/ext/QuestionExtMapper.xml | 8 ++-- 7 files changed, 112 insertions(+), 44 deletions(-) create mode 100644 src/main/java/com/achobeta/domain/paper/constants/PaperLibraryConstants.java create mode 100644 src/main/java/com/achobeta/domain/paper/constants/QuestionPaperConstants.java create mode 100644 src/main/java/com/achobeta/domain/question/constants/QuestionLibraryConstants.java diff --git a/src/main/java/com/achobeta/domain/paper/constants/PaperLibraryConstants.java b/src/main/java/com/achobeta/domain/paper/constants/PaperLibraryConstants.java new file mode 100644 index 00000000..17446db6 --- /dev/null +++ b/src/main/java/com/achobeta/domain/paper/constants/PaperLibraryConstants.java @@ -0,0 +1,14 @@ +package com.achobeta.domain.paper.constants; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-10-16 + * Time: 21:24 + */ +public interface PaperLibraryConstants { + + String PAPER_LIBRARY_REFERENCE_PAPERS_LOCK = "paperLibraryReferencePapersLock:"; + +} diff --git a/src/main/java/com/achobeta/domain/paper/constants/QuestionPaperConstants.java b/src/main/java/com/achobeta/domain/paper/constants/QuestionPaperConstants.java new file mode 100644 index 00000000..23176cbd --- /dev/null +++ b/src/main/java/com/achobeta/domain/paper/constants/QuestionPaperConstants.java @@ -0,0 +1,14 @@ +package com.achobeta.domain.paper.constants; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-10-16 + * Time: 21:36 + */ +public interface QuestionPaperConstants { + + String PAPER_ADD_QUESTIONS_LOCK = "paperAddQuestionsLock:"; + +} diff --git a/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java b/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java index 20b0aadf..6013dd4c 100644 --- a/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java +++ b/src/main/java/com/achobeta/domain/paper/service/impl/PaperQuestionLinkServiceImpl.java @@ -1,6 +1,7 @@ package com.achobeta.domain.paper.service.impl; import com.achobeta.common.enums.GlobalServiceStatusCode; +import com.achobeta.domain.paper.constants.QuestionPaperConstants; import com.achobeta.domain.paper.model.dao.mapper.PaperQuestionLinkMapper; import com.achobeta.domain.paper.model.dao.mapper.QuestionPaperLibraryMapper; import com.achobeta.domain.paper.model.entity.PaperQuestionLink; @@ -10,6 +11,8 @@ import com.achobeta.domain.paper.service.QuestionPaperService; import com.achobeta.domain.question.model.vo.QuestionVO; import com.achobeta.exception.GlobalServiceException; +import com.achobeta.redis.lock.RedisLock; +import com.achobeta.redis.lock.strategy.SimpleLockStrategy; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -17,10 +20,8 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; +import java.util.*; +import java.util.stream.Collectors; /** * @author 马拉圈 @@ -38,6 +39,10 @@ public class PaperQuestionLinkServiceImpl extends ServiceImpl getQuestionsOnPaper(Long paperId) { return paperQuestionLinkMapper.getQuestionsOnPaper(paperId); @@ -54,19 +59,21 @@ public Optional getPaperQuestionLink(Long paperId, Long quest @Override @Transactional public void addQuestionsForPaper(Long paperId, List questionIds) { - Set hash = new HashSet<>(); - // 获取试卷的所有题 - getQuestionsOnPaper(paperId).forEach(questionVO -> hash.add(questionVO.getId())); - // 将不存在于原试卷的题滤出来 - List paperQuestionLinks = questionIds.stream() - .filter(questionId -> !hash.contains(questionId)) - .map(questionId -> { - PaperQuestionLink paperQuestionLink = new PaperQuestionLink(); - paperQuestionLink.setPaperId(paperId); - paperQuestionLink.setQuestionId(questionId); - return paperQuestionLink; - }).toList(); - this.saveBatch(paperQuestionLinks); + redisLock.tryLockDoSomething(QuestionPaperConstants.PAPER_ADD_QUESTIONS_LOCK + paperId, () -> { + // 获取试卷的所有题 + Set hash = getQuestionsOnPaper(paperId).stream().map(QuestionVO::getId).collect(Collectors.toSet()); + // 将不存在于原试卷的题滤出来 + List paperQuestionLinks = questionIds.stream() + .distinct() + .filter(questionId -> Objects.nonNull(questionId) && !hash.contains(questionId)) + .map(questionId -> { + PaperQuestionLink paperQuestionLink = new PaperQuestionLink(); + paperQuestionLink.setPaperId(paperId); + paperQuestionLink.setQuestionId(questionId); + return paperQuestionLink; + }).toList(); + this.saveBatch(paperQuestionLinks); + }, () -> {}, simpleLockStrategy); } @Override diff --git a/src/main/java/com/achobeta/domain/paper/service/impl/QuestionPaperServiceImpl.java b/src/main/java/com/achobeta/domain/paper/service/impl/QuestionPaperServiceImpl.java index 51876914..213c9178 100644 --- a/src/main/java/com/achobeta/domain/paper/service/impl/QuestionPaperServiceImpl.java +++ b/src/main/java/com/achobeta/domain/paper/service/impl/QuestionPaperServiceImpl.java @@ -3,6 +3,7 @@ import com.achobeta.common.base.BasePageQuery; import com.achobeta.common.base.BasePageResult; import com.achobeta.common.enums.GlobalServiceStatusCode; +import com.achobeta.domain.paper.constants.PaperLibraryConstants; import com.achobeta.domain.paper.model.converter.QuestionPaperConverter; import com.achobeta.domain.paper.model.dao.mapper.QuestionPaperMapper; import com.achobeta.domain.paper.model.dto.PaperQueryDTO; @@ -12,6 +13,8 @@ import com.achobeta.domain.paper.service.LibraryPaperLinkService; import com.achobeta.domain.paper.service.QuestionPaperService; import com.achobeta.exception.GlobalServiceException; +import com.achobeta.redis.lock.RedisLock; +import com.achobeta.redis.lock.strategy.SimpleLockStrategy; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.RequiredArgsConstructor; @@ -35,6 +38,10 @@ public class QuestionPaperServiceImpl extends ServiceImpl BasePageQuery -> page -> BasePageResult -> vo * @param paperQueryDTO 分页参数 @@ -80,17 +87,19 @@ public Long addQuestionPaper(List libIds, String title, String description @Override public void referencePapers(Long libId, List paperIds) { - Set hash = questionPaperMapper.getPapers(List.of(libId)).stream().map(QuestionPaper::getId).collect(Collectors.toSet()); - List libraryPaperLinkList = paperIds.stream() - .distinct() - .filter(paperId -> Objects.nonNull(paperId) && !hash.contains(paperId)) - .map(paperId -> { - LibraryPaperLink libraryPaperLink = new LibraryPaperLink(); - libraryPaperLink.setPaperId(paperId); - libraryPaperLink.setLibId(libId); - return libraryPaperLink; - }).toList(); - libraryPaperLinkService.saveBatch(libraryPaperLinkList); + redisLock.tryLockDoSomething(PaperLibraryConstants.PAPER_LIBRARY_REFERENCE_PAPERS_LOCK + libId, () -> { + Set hash = questionPaperMapper.getPapers(List.of(libId)).stream().map(QuestionPaper::getId).collect(Collectors.toSet()); + List libraryPaperLinkList = paperIds.stream() + .distinct() + .filter(paperId -> Objects.nonNull(paperId) && !hash.contains(paperId)) + .map(paperId -> { + LibraryPaperLink libraryPaperLink = new LibraryPaperLink(); + libraryPaperLink.setPaperId(paperId); + libraryPaperLink.setLibId(libId); + return libraryPaperLink; + }).toList(); + libraryPaperLinkService.saveBatch(libraryPaperLinkList); + }, () -> {}, simpleLockStrategy); } @Override diff --git a/src/main/java/com/achobeta/domain/question/constants/QuestionLibraryConstants.java b/src/main/java/com/achobeta/domain/question/constants/QuestionLibraryConstants.java new file mode 100644 index 00000000..1178386b --- /dev/null +++ b/src/main/java/com/achobeta/domain/question/constants/QuestionLibraryConstants.java @@ -0,0 +1,16 @@ +package com.achobeta.domain.question.constants; + +import lombok.Data; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-10-16 + * Time: 21:30 + */ +public interface QuestionLibraryConstants { + + String QUESTION_LIBRARY_REFERENCE_QUESTIONS_LOCK = "questionLibraryReferenceQuestionsLock:"; + +} diff --git a/src/main/java/com/achobeta/domain/question/service/impl/QuestionServiceImpl.java b/src/main/java/com/achobeta/domain/question/service/impl/QuestionServiceImpl.java index 52c14c82..c4dd241b 100644 --- a/src/main/java/com/achobeta/domain/question/service/impl/QuestionServiceImpl.java +++ b/src/main/java/com/achobeta/domain/question/service/impl/QuestionServiceImpl.java @@ -3,6 +3,7 @@ import com.achobeta.common.base.BasePageQuery; import com.achobeta.common.base.BasePageResult; import com.achobeta.common.enums.GlobalServiceStatusCode; +import com.achobeta.domain.question.constants.QuestionLibraryConstants; import com.achobeta.domain.question.model.converter.QuestionConverter; import com.achobeta.domain.question.model.dao.mapper.QuestionLibraryMapper; import com.achobeta.domain.question.model.dao.mapper.QuestionMapper; @@ -19,6 +20,8 @@ import com.achobeta.domain.question.service.QuestionLibraryService; import com.achobeta.domain.question.service.QuestionService; import com.achobeta.exception.GlobalServiceException; +import com.achobeta.redis.lock.RedisLock; +import com.achobeta.redis.lock.strategy.SimpleLockStrategy; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.RequiredArgsConstructor; @@ -39,7 +42,6 @@ public class QuestionServiceImpl extends ServiceImpl implements QuestionService{ - private final QuestionMapper questionMapper; private final QuestionLibraryMapper questionLibraryMapper; @@ -48,6 +50,10 @@ public class QuestionServiceImpl extends ServiceImpl private final LibraryQuestionLinkService libraryQuestionLinkService; + private final RedisLock redisLock; + + private final SimpleLockStrategy simpleLockStrategy; + /** * 流程:dto -> BasePageQuery -> page -> BasePageResult -> vo * @param questionQueryDTO 分页参数 @@ -93,17 +99,19 @@ public Long addQuestion(List libIds, String title, String standard) { @Override public void referenceQuestions(Long libId, List questionIds) { - Set hash = questionMapper.getQuestions(List.of(libId)).stream().map(Question::getId).collect(Collectors.toSet()); - List libraryQuestionLinkList = questionIds.stream() - .distinct() - .filter(questionId -> Objects.nonNull(questionId) && !hash.contains(questionId)) - .map(questionId -> { - LibraryQuestionLink libraryQuestionLink = new LibraryQuestionLink(); - libraryQuestionLink.setQuestionId(questionId); - libraryQuestionLink.setLibId(libId); - return libraryQuestionLink; - }).toList(); - libraryQuestionLinkService.saveBatch(libraryQuestionLinkList); + redisLock.tryLockDoSomething(QuestionLibraryConstants.QUESTION_LIBRARY_REFERENCE_QUESTIONS_LOCK + libId, () -> { + Set hash = questionMapper.getQuestions(List.of(libId)).stream().map(Question::getId).collect(Collectors.toSet()); + List libraryQuestionLinkList = questionIds.stream() + .distinct() + .filter(questionId -> Objects.nonNull(questionId) && !hash.contains(questionId)) + .map(questionId -> { + LibraryQuestionLink libraryQuestionLink = new LibraryQuestionLink(); + libraryQuestionLink.setQuestionId(questionId); + libraryQuestionLink.setLibId(libId); + return libraryQuestionLink; + }).toList(); + libraryQuestionLinkService.saveBatch(libraryQuestionLinkList); + }, () -> {}, simpleLockStrategy); } @Override diff --git a/src/main/resources/mapper/question/ext/QuestionExtMapper.xml b/src/main/resources/mapper/question/ext/QuestionExtMapper.xml index 927e36ec..293cbc0b 100644 --- a/src/main/resources/mapper/question/ext/QuestionExtMapper.xml +++ b/src/main/resources/mapper/question/ext/QuestionExtMapper.xml @@ -34,11 +34,11 @@ select - s.id summary_id, s.basis + s.coding + s.thinking + s.express sum, + s.id summary_id, s.basis + s.coding + s.thinking + s.express sum, s.update_time update_time, i.id interview_id, i.title title, i.status status, from recruitment_batch b @@ -36,7 +36,7 @@ and a.id = #{condition.actId,jdbcType=BIGINT}
- order by sum desc + order by sum desc, status desc, update_time asc From f68e2c66033f9f89c5d739a0febe51284da942d5 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Thu, 17 Oct 2024 22:11:32 +0800 Subject: [PATCH 095/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{IsAccessible.java => Accessible.java} | 6 ++-- .../common/annotation/MobilePhone.java | 27 ++++++++++++++++++ ...alidator.java => AccessibleValidator.java} | 4 +-- .../handler/MobilePhoneValidator.java | 28 +++++++++++++++++++ .../model/dto/InterviewSummaryDTO.java | 4 +-- .../domain/login/model/dto/SmsLoginDTO.java | 4 +-- .../InterviewScheduleController.java | 4 +-- .../controller/ShortLinkController.java | 4 +-- .../student/model/dto/StuSimpleResumeDTO.java | 3 +- 9 files changed, 70 insertions(+), 14 deletions(-) rename src/main/java/com/achobeta/common/annotation/{IsAccessible.java => Accessible.java} (80%) create mode 100644 src/main/java/com/achobeta/common/annotation/MobilePhone.java rename src/main/java/com/achobeta/common/annotation/handler/{IsAccessibleValidator.java => AccessibleValidator.java} (86%) create mode 100644 src/main/java/com/achobeta/common/annotation/handler/MobilePhoneValidator.java diff --git a/src/main/java/com/achobeta/common/annotation/IsAccessible.java b/src/main/java/com/achobeta/common/annotation/Accessible.java similarity index 80% rename from src/main/java/com/achobeta/common/annotation/IsAccessible.java rename to src/main/java/com/achobeta/common/annotation/Accessible.java index c8321048..cd3a03a7 100644 --- a/src/main/java/com/achobeta/common/annotation/IsAccessible.java +++ b/src/main/java/com/achobeta/common/annotation/Accessible.java @@ -1,6 +1,6 @@ package com.achobeta.common.annotation; -import com.achobeta.common.annotation.handler.IsAccessibleValidator; +import com.achobeta.common.annotation.handler.AccessibleValidator; import jakarta.validation.Constraint; import jakarta.validation.Payload; @@ -14,10 +14,10 @@ * Time: 23:50 */ @Documented -@Constraint(validatedBy = {IsAccessibleValidator.class}) +@Constraint(validatedBy = {AccessibleValidator.class}) @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE}) @Retention(RetentionPolicy.RUNTIME) -public @interface IsAccessible { +public @interface Accessible { String message() default "url 无法访问"; // 默认消息 diff --git a/src/main/java/com/achobeta/common/annotation/MobilePhone.java b/src/main/java/com/achobeta/common/annotation/MobilePhone.java new file mode 100644 index 00000000..5cf8ac13 --- /dev/null +++ b/src/main/java/com/achobeta/common/annotation/MobilePhone.java @@ -0,0 +1,27 @@ +package com.achobeta.common.annotation; + +import com.achobeta.common.annotation.handler.MobilePhoneValidator; +import jakarta.validation.Constraint; +import jakarta.validation.Payload; + +import java.lang.annotation.*; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-10-17 + * Time: 21:59 + */ +@Documented +@Constraint(validatedBy = {MobilePhoneValidator.class}) +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface MobilePhone { + + String message() default "手机号非法"; // 默认消息 + + Class[] groups() default {}; // 分组校验 + + Class[] payload() default {}; // 负载信息 +} diff --git a/src/main/java/com/achobeta/common/annotation/handler/IsAccessibleValidator.java b/src/main/java/com/achobeta/common/annotation/handler/AccessibleValidator.java similarity index 86% rename from src/main/java/com/achobeta/common/annotation/handler/IsAccessibleValidator.java rename to src/main/java/com/achobeta/common/annotation/handler/AccessibleValidator.java index 485a4f68..393917b3 100644 --- a/src/main/java/com/achobeta/common/annotation/handler/IsAccessibleValidator.java +++ b/src/main/java/com/achobeta/common/annotation/handler/AccessibleValidator.java @@ -1,6 +1,6 @@ package com.achobeta.common.annotation.handler; -import com.achobeta.common.annotation.IsAccessible; +import com.achobeta.common.annotation.Accessible; import com.achobeta.util.HttpRequestUtil; import jakarta.validation.ConstraintValidator; import jakarta.validation.ConstraintValidatorContext; @@ -10,7 +10,7 @@ import java.util.Optional; @Slf4j -public class IsAccessibleValidator implements ConstraintValidator { +public class AccessibleValidator implements ConstraintValidator { @Override public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) { diff --git a/src/main/java/com/achobeta/common/annotation/handler/MobilePhoneValidator.java b/src/main/java/com/achobeta/common/annotation/handler/MobilePhoneValidator.java new file mode 100644 index 00000000..94bd15f5 --- /dev/null +++ b/src/main/java/com/achobeta/common/annotation/handler/MobilePhoneValidator.java @@ -0,0 +1,28 @@ +package com.achobeta.common.annotation.handler; + +import com.achobeta.common.annotation.MobilePhone; +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; + +import java.util.Optional; +import java.util.regex.Pattern; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-10-17 + * Time: 22:00 + */ +public class MobilePhoneValidator implements ConstraintValidator { + + private final static Pattern MOBILE_PHONE_PATTERN = Pattern.compile("^1[3-9]\\d{9}$"); + + @Override + public boolean isValid(String phone, ConstraintValidatorContext constraintValidatorContext) { + return Optional.ofNullable(phone) + .map(s -> MOBILE_PHONE_PATTERN.matcher(s).matches()) + .orElse(Boolean.TRUE); + } + +} diff --git a/src/main/java/com/achobeta/domain/evaluate/model/dto/InterviewSummaryDTO.java b/src/main/java/com/achobeta/domain/evaluate/model/dto/InterviewSummaryDTO.java index c2793e2f..a5941986 100644 --- a/src/main/java/com/achobeta/domain/evaluate/model/dto/InterviewSummaryDTO.java +++ b/src/main/java/com/achobeta/domain/evaluate/model/dto/InterviewSummaryDTO.java @@ -1,7 +1,7 @@ package com.achobeta.domain.evaluate.model.dto; +import com.achobeta.common.annotation.Accessible; import com.achobeta.common.annotation.IntRange; -import com.achobeta.common.annotation.IsAccessible; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.Data; @@ -44,7 +44,7 @@ public class InterviewSummaryDTO { private String suggest; // @NotBlank(message = "回放不能为空") - @IsAccessible(message = "回放链接不可访问") + @Accessible(message = "回放链接不可访问") private String playback; } diff --git a/src/main/java/com/achobeta/domain/login/model/dto/SmsLoginDTO.java b/src/main/java/com/achobeta/domain/login/model/dto/SmsLoginDTO.java index 99dc0eb2..492e7f93 100644 --- a/src/main/java/com/achobeta/domain/login/model/dto/SmsLoginDTO.java +++ b/src/main/java/com/achobeta/domain/login/model/dto/SmsLoginDTO.java @@ -1,7 +1,7 @@ package com.achobeta.domain.login.model.dto; +import com.achobeta.common.annotation.MobilePhone; import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.Pattern; import lombok.Getter; import lombok.Setter; import lombok.ToString; @@ -25,7 +25,7 @@ public class SmsLoginDTO implements Serializable { * 手机号 */ @NotBlank(message = "手机号不能为空") - @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号非法") + @MobilePhone private String phoneNumber; /** diff --git a/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java b/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java index 8261f478..8529a910 100644 --- a/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java +++ b/src/main/java/com/achobeta/domain/schedule/controller/InterviewScheduleController.java @@ -2,6 +2,7 @@ import com.achobeta.common.SystemJsonResponse; import com.achobeta.common.annotation.Intercept; +import com.achobeta.common.annotation.MobilePhone; import com.achobeta.common.enums.UserTypeEnum; import com.achobeta.domain.interview.model.dto.InterviewConditionDTO; import com.achobeta.domain.interview.model.vo.InterviewReserveVO; @@ -22,7 +23,6 @@ import jakarta.validation.Valid; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Pattern; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; @@ -172,7 +172,7 @@ public SystemJsonResponse getParticipationDetail(@PathVariable("participationId" @GetMapping("/reserve/{scheduleId}") public SystemJsonResponse interviewReserveApply(@PathVariable("scheduleId") @NotNull Long scheduleId, @RequestParam("title") @NotBlank(message = "标题不能为空") String title, - @RequestParam(name = "mobile", required = false) @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号非法") String mobile) { + @RequestParam(name = "mobile", required = false) @MobilePhone String mobile) { // 检查 interviewScheduleService.checkInterviewScheduleExists(scheduleId); // 当前管理员 diff --git a/src/main/java/com/achobeta/domain/shortlink/controller/ShortLinkController.java b/src/main/java/com/achobeta/domain/shortlink/controller/ShortLinkController.java index d5fb70c8..5f3d0b72 100644 --- a/src/main/java/com/achobeta/domain/shortlink/controller/ShortLinkController.java +++ b/src/main/java/com/achobeta/domain/shortlink/controller/ShortLinkController.java @@ -1,8 +1,8 @@ package com.achobeta.domain.shortlink.controller; import com.achobeta.common.SystemJsonResponse; +import com.achobeta.common.annotation.Accessible; import com.achobeta.common.annotation.Intercept; -import com.achobeta.common.annotation.IsAccessible; import com.achobeta.common.enums.UserTypeEnum; import com.achobeta.domain.shortlink.model.dto.ShortLinkQueryDTO; import com.achobeta.domain.shortlink.model.vo.ShortLinkQueryVO; @@ -51,7 +51,7 @@ public RedirectView getShortLink(@PathVariable("code") @NotBlank String code) { */ @PostMapping("/trans") public SystemJsonResponse transferAndSaveShortLink(HttpServletRequest request, - @RequestParam("url") @NotBlank @IsAccessible(message = "链接不可访问") String url) { + @RequestParam("url") @NotBlank @Accessible(message = "链接不可访问") String url) { // 转化 String shortLinkURL = shortLinkService.transShortLinkURL(request, url); log.info("原链接:{} -> 短链接:{}", url, shortLinkURL); diff --git a/src/main/java/com/achobeta/domain/student/model/dto/StuSimpleResumeDTO.java b/src/main/java/com/achobeta/domain/student/model/dto/StuSimpleResumeDTO.java index 59658c8a..7b90253f 100644 --- a/src/main/java/com/achobeta/domain/student/model/dto/StuSimpleResumeDTO.java +++ b/src/main/java/com/achobeta/domain/student/model/dto/StuSimpleResumeDTO.java @@ -1,6 +1,7 @@ package com.achobeta.domain.student.model.dto; import com.achobeta.common.annotation.IntRange; +import com.achobeta.common.annotation.MobilePhone; import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; @@ -45,7 +46,7 @@ public class StuSimpleResumeDTO implements Serializable { private String email; @NotBlank(message = "手机号不能为空") - @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号非法") + @MobilePhone private String phoneNumber; @NotBlank(message = "加入ab理由不能为空") From 7a1275a3da7df4a51426f660d1286fa623f22292 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Fri, 18 Oct 2024 00:20:50 +0800 Subject: [PATCH 096/104] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../evaluate/service/impl/InterviewSummaryServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/achobeta/domain/evaluate/service/impl/InterviewSummaryServiceImpl.java b/src/main/java/com/achobeta/domain/evaluate/service/impl/InterviewSummaryServiceImpl.java index fd4a3656..ffe7bd09 100644 --- a/src/main/java/com/achobeta/domain/evaluate/service/impl/InterviewSummaryServiceImpl.java +++ b/src/main/java/com/achobeta/domain/evaluate/service/impl/InterviewSummaryServiceImpl.java @@ -65,6 +65,8 @@ public void summaryInterview(InterviewSummaryDTO interviewSummaryDTO) { getInterviewSummaryByInterviewId(interviewId).map(InterviewSummary::getId).ifPresentOrElse(summaryId -> { this.lambdaUpdate() .eq(InterviewSummary::getId, summaryId) + .set(InterviewSummary::getPlayback, Optional.ofNullable(interviewSummary.getPlayback()).orElse("")) + .set(InterviewSummary::getSuggest, Optional.ofNullable(interviewSummary.getSuggest()).orElse("")) .update(interviewSummary); }, () -> { this.save(interviewSummary); From bbd7f4ad1c51f6a8a13e01142a4699b0407acaf9 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Fri, 18 Oct 2024 16:49:59 +0800 Subject: [PATCH 097/104] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/paper/controller/PaperLibraryController.java | 2 ++ .../domain/question/controller/QuestionLibraryController.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/main/java/com/achobeta/domain/paper/controller/PaperLibraryController.java b/src/main/java/com/achobeta/domain/paper/controller/PaperLibraryController.java index 20ec0aad..682bb666 100644 --- a/src/main/java/com/achobeta/domain/paper/controller/PaperLibraryController.java +++ b/src/main/java/com/achobeta/domain/paper/controller/PaperLibraryController.java @@ -45,6 +45,8 @@ public SystemJsonResponse createPaperLibrary(@RequestParam("libType") @NotBlank @PostMapping("/reference") public SystemJsonResponse referencePapers(@Valid @RequestBody LibraryReferencePaperDTO libraryReferencePaperDTO) { + Long libId = libraryReferencePaperDTO.getLibId(); + questionPaperLibraryService.checkPaperLibraryExists(libId); // 引用 questionPaperService.referencePapers(libraryReferencePaperDTO.getLibId(), libraryReferencePaperDTO.getPaperIds()); return SystemJsonResponse.SYSTEM_SUCCESS(); diff --git a/src/main/java/com/achobeta/domain/question/controller/QuestionLibraryController.java b/src/main/java/com/achobeta/domain/question/controller/QuestionLibraryController.java index 03bf1c28..ee253f51 100644 --- a/src/main/java/com/achobeta/domain/question/controller/QuestionLibraryController.java +++ b/src/main/java/com/achobeta/domain/question/controller/QuestionLibraryController.java @@ -45,6 +45,8 @@ public SystemJsonResponse createQuestionLibrary(@RequestParam("libType") @NotBla @PostMapping("/reference") public SystemJsonResponse referenceQuestions(@Valid @RequestBody LibraryReferenceQuestionDTO libraryReferenceQuestionDTO) { + Long libId = libraryReferenceQuestionDTO.getLibId(); + questionLibraryService.checkQuestionLibraryExists(libId); // 引用 questionService.referenceQuestions(libraryReferenceQuestionDTO.getLibId(), libraryReferenceQuestionDTO.getQuestionIds()); return SystemJsonResponse.SYSTEM_SUCCESS(); From d3e253ed579af6cc3212d1116c86f15fee870c74 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sat, 19 Oct 2024 11:40:45 +0800 Subject: [PATCH 098/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../achobeta/common/annotation/HttpUrl.java | 27 ++++++++++++++++ .../annotation/handler/HttpUrlValidator.java | 27 ++++++++++++++++ .../model/dto/InterviewSummaryDTO.java | 3 +- .../achobeta/template/util/MarkdownUtil.java | 32 ++++++++++++++++++- .../templates/interview-experience-model.html | 4 +-- 5 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/achobeta/common/annotation/HttpUrl.java create mode 100644 src/main/java/com/achobeta/common/annotation/handler/HttpUrlValidator.java diff --git a/src/main/java/com/achobeta/common/annotation/HttpUrl.java b/src/main/java/com/achobeta/common/annotation/HttpUrl.java new file mode 100644 index 00000000..3eddd77e --- /dev/null +++ b/src/main/java/com/achobeta/common/annotation/HttpUrl.java @@ -0,0 +1,27 @@ +package com.achobeta.common.annotation; + +import com.achobeta.common.annotation.handler.AccessibleValidator; +import jakarta.validation.Constraint; +import jakarta.validation.Payload; + +import java.lang.annotation.*; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-10-19 + * Time: 11:35 + */ +@Documented +@Constraint(validatedBy = {AccessibleValidator.class}) +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface HttpUrl { + + String message() default "链接非法"; // 默认消息 + + Class[] groups() default {}; // 分组校验 + + Class[] payload() default {}; // 负载信息 +} diff --git a/src/main/java/com/achobeta/common/annotation/handler/HttpUrlValidator.java b/src/main/java/com/achobeta/common/annotation/handler/HttpUrlValidator.java new file mode 100644 index 00000000..cec25d8b --- /dev/null +++ b/src/main/java/com/achobeta/common/annotation/handler/HttpUrlValidator.java @@ -0,0 +1,27 @@ +package com.achobeta.common.annotation.handler; + +import com.achobeta.common.annotation.HttpUrl; +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; + +import java.util.Optional; +import java.util.regex.Pattern; + +/** + * Created With Intellij IDEA + * Description: + * User: 马拉圈 + * Date: 2024-10-19 + * Time: 11:35 + */ +public class HttpUrlValidator implements ConstraintValidator { + + private static final Pattern HTTP_URL_PATTERN = Pattern.compile("^(?i)(http|https):(//(([^@\\[/?#]*)@)?(\\[[\\p{XDigit}:.]*[%\\p{Alnum}]*]|[^\\[/?#:]*)(:(\\{[^}]+\\}?|[^/?#]*))?)?([^?#]*)(\\?([^#]*))?(#(.*))?"); + + @Override + public boolean isValid(String url, ConstraintValidatorContext constraintValidatorContext) { + return Optional.ofNullable(url) + .map(s -> HTTP_URL_PATTERN.matcher(s).matches()) + .orElse(Boolean.TRUE); + } +} diff --git a/src/main/java/com/achobeta/domain/evaluate/model/dto/InterviewSummaryDTO.java b/src/main/java/com/achobeta/domain/evaluate/model/dto/InterviewSummaryDTO.java index a5941986..9da9e592 100644 --- a/src/main/java/com/achobeta/domain/evaluate/model/dto/InterviewSummaryDTO.java +++ b/src/main/java/com/achobeta/domain/evaluate/model/dto/InterviewSummaryDTO.java @@ -1,6 +1,7 @@ package com.achobeta.domain.evaluate.model.dto; import com.achobeta.common.annotation.Accessible; +import com.achobeta.common.annotation.HttpUrl; import com.achobeta.common.annotation.IntRange; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; @@ -44,7 +45,7 @@ public class InterviewSummaryDTO { private String suggest; // @NotBlank(message = "回放不能为空") - @Accessible(message = "回放链接不可访问") + @HttpUrl private String playback; } diff --git a/src/main/java/com/achobeta/template/util/MarkdownUtil.java b/src/main/java/com/achobeta/template/util/MarkdownUtil.java index 3aaaa458..413bbbbe 100644 --- a/src/main/java/com/achobeta/template/util/MarkdownUtil.java +++ b/src/main/java/com/achobeta/template/util/MarkdownUtil.java @@ -2,17 +2,28 @@ import com.vladsch.flexmark.ext.abbreviation.AbbreviationExtension; +import com.vladsch.flexmark.ext.admonition.AdmonitionExtension; +import com.vladsch.flexmark.ext.anchorlink.AnchorLinkExtension; +import com.vladsch.flexmark.ext.aside.AsideExtension; import com.vladsch.flexmark.ext.autolink.AutolinkExtension; import com.vladsch.flexmark.ext.definition.DefinitionExtension; +import com.vladsch.flexmark.ext.emoji.EmojiExtension; import com.vladsch.flexmark.ext.footnotes.FootnoteExtension; +import com.vladsch.flexmark.ext.gfm.issues.GfmIssuesExtension; import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughSubscriptExtension; import com.vladsch.flexmark.ext.gfm.tasklist.TaskListExtension; +import com.vladsch.flexmark.ext.gfm.users.GfmUsersExtension; +import com.vladsch.flexmark.ext.gitlab.GitLabExtension; import com.vladsch.flexmark.ext.ins.InsExtension; +import com.vladsch.flexmark.ext.media.tags.MediaTagsExtension; +import com.vladsch.flexmark.ext.resizable.image.ResizableImageExtension; import com.vladsch.flexmark.ext.superscript.SuperscriptExtension; import com.vladsch.flexmark.ext.tables.TablesExtension; import com.vladsch.flexmark.ext.toc.TocExtension; import com.vladsch.flexmark.ext.typographic.TypographicExtension; +import com.vladsch.flexmark.ext.wikilink.WikiLinkExtension; import com.vladsch.flexmark.html.HtmlRenderer; +import com.vladsch.flexmark.html2md.converter.FlexmarkHtmlConverter; import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.parser.ParserEmulationProfile; import com.vladsch.flexmark.util.ast.Node; @@ -35,26 +46,40 @@ public class MarkdownUtil { private final static HtmlRenderer HTML_RENDERER; + private final static FlexmarkHtmlConverter HTML_CONVERTER; + static { OPTIONS = new MutableDataSet() // 指定 Markdown 标准为 COMMONMARK(使用 ParserEmulationProfile.MARKDOWN 可能会有一些语法失效!) .setFrom(ParserEmulationProfile.COMMONMARK) .set(Parser.EXTENSIONS, List.of(new Parser.ParserExtension[]{ - // 设置一些常见的扩展 + // 设置一些常扩展 TocExtension.create(), TablesExtension.create(), + AbbreviationExtension.create(), AutolinkExtension.create(), + AnchorLinkExtension.create(), + AsideExtension.create(), + AdmonitionExtension.create(), + GfmIssuesExtension.create(), + GfmUsersExtension.create(), SuperscriptExtension.create(), StrikethroughSubscriptExtension.create(), + GitLabExtension.create(), FootnoteExtension.create(), TaskListExtension.create(), InsExtension.create(), TypographicExtension.create(), DefinitionExtension.create(), AbbreviationExtension.create(), + ResizableImageExtension.create(), + MediaTagsExtension.create(), + EmojiExtension.create(), + WikiLinkExtension.create(), })).set(HtmlRenderer.SOFT_BREAK, "
\n"); PARSER = Parser.builder(OPTIONS).build(); HTML_RENDERER = HtmlRenderer.builder(OPTIONS).build(); + HTML_CONVERTER = FlexmarkHtmlConverter.builder(OPTIONS).build(); } public static String markdownToHtml(String markdown) { @@ -64,4 +89,9 @@ public static String markdownToHtml(String markdown) { return HTML_RENDERER.render(document); } + public static String htmlToMarkdown(String html) { + // 将 HTML 转化为 Markdown + return HTML_CONVERTER.convert(html); + } + } diff --git a/src/main/resources/templates/interview-experience-model.html b/src/main/resources/templates/interview-experience-model.html index bdc63846..20480f96 100644 --- a/src/main/resources/templates/interview-experience-model.html +++ b/src/main/resources/templates/interview-experience-model.html @@ -30,8 +30,8 @@

-

- +

+
得分(0-10): 问题超纲 From 4939bae1c3f595ffbdf1e5f25b84e86b0f34358a Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sat, 19 Oct 2024 12:19:53 +0800 Subject: [PATCH 099/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../achobeta/common/annotation/HttpUrl.java | 4 +-- .../handler/AccessibleValidator.java | 4 +-- .../annotation/handler/HttpUrlValidator.java | 6 ++--- .../model/dto/InterviewSummaryDTO.java | 3 +-- .../com/achobeta/util/HttpRequestUtil.java | 25 +++++++++++-------- .../java/com/achobeta/util/MediaUtil.java | 6 ++--- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/achobeta/common/annotation/HttpUrl.java b/src/main/java/com/achobeta/common/annotation/HttpUrl.java index 3eddd77e..036e06a2 100644 --- a/src/main/java/com/achobeta/common/annotation/HttpUrl.java +++ b/src/main/java/com/achobeta/common/annotation/HttpUrl.java @@ -1,6 +1,6 @@ package com.achobeta.common.annotation; -import com.achobeta.common.annotation.handler.AccessibleValidator; +import com.achobeta.common.annotation.handler.HttpUrlValidator; import jakarta.validation.Constraint; import jakarta.validation.Payload; @@ -14,7 +14,7 @@ * Time: 11:35 */ @Documented -@Constraint(validatedBy = {AccessibleValidator.class}) +@Constraint(validatedBy = {HttpUrlValidator.class}) @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE}) @Retention(RetentionPolicy.RUNTIME) public @interface HttpUrl { diff --git a/src/main/java/com/achobeta/common/annotation/handler/AccessibleValidator.java b/src/main/java/com/achobeta/common/annotation/handler/AccessibleValidator.java index 393917b3..7575e732 100644 --- a/src/main/java/com/achobeta/common/annotation/handler/AccessibleValidator.java +++ b/src/main/java/com/achobeta/common/annotation/handler/AccessibleValidator.java @@ -6,7 +6,6 @@ import jakarta.validation.ConstraintValidatorContext; import lombok.extern.slf4j.Slf4j; -import java.io.IOException; import java.util.Optional; @Slf4j @@ -19,8 +18,7 @@ public boolean isValid(String s, ConstraintValidatorContext constraintValidatorC .map(url -> { try { return HttpRequestUtil.isAccessible(url); - } catch (IOException e) { - // 重定向次数过多也判定为无法访问 + } catch (Exception e) { log.warn(e.getMessage()); return Boolean.FALSE; } diff --git a/src/main/java/com/achobeta/common/annotation/handler/HttpUrlValidator.java b/src/main/java/com/achobeta/common/annotation/handler/HttpUrlValidator.java index cec25d8b..e5f10de3 100644 --- a/src/main/java/com/achobeta/common/annotation/handler/HttpUrlValidator.java +++ b/src/main/java/com/achobeta/common/annotation/handler/HttpUrlValidator.java @@ -1,11 +1,11 @@ package com.achobeta.common.annotation.handler; import com.achobeta.common.annotation.HttpUrl; +import com.achobeta.util.HttpRequestUtil; import jakarta.validation.ConstraintValidator; import jakarta.validation.ConstraintValidatorContext; import java.util.Optional; -import java.util.regex.Pattern; /** * Created With Intellij IDEA @@ -16,12 +16,10 @@ */ public class HttpUrlValidator implements ConstraintValidator { - private static final Pattern HTTP_URL_PATTERN = Pattern.compile("^(?i)(http|https):(//(([^@\\[/?#]*)@)?(\\[[\\p{XDigit}:.]*[%\\p{Alnum}]*]|[^\\[/?#:]*)(:(\\{[^}]+\\}?|[^/?#]*))?)?([^?#]*)(\\?([^#]*))?(#(.*))?"); - @Override public boolean isValid(String url, ConstraintValidatorContext constraintValidatorContext) { return Optional.ofNullable(url) - .map(s -> HTTP_URL_PATTERN.matcher(s).matches()) + .map(s -> HttpRequestUtil.HTTP_URL_PATTERN.matcher(s).matches()) .orElse(Boolean.TRUE); } } diff --git a/src/main/java/com/achobeta/domain/evaluate/model/dto/InterviewSummaryDTO.java b/src/main/java/com/achobeta/domain/evaluate/model/dto/InterviewSummaryDTO.java index 9da9e592..083f6dd8 100644 --- a/src/main/java/com/achobeta/domain/evaluate/model/dto/InterviewSummaryDTO.java +++ b/src/main/java/com/achobeta/domain/evaluate/model/dto/InterviewSummaryDTO.java @@ -1,7 +1,6 @@ package com.achobeta.domain.evaluate.model.dto; import com.achobeta.common.annotation.Accessible; -import com.achobeta.common.annotation.HttpUrl; import com.achobeta.common.annotation.IntRange; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; @@ -45,7 +44,7 @@ public class InterviewSummaryDTO { private String suggest; // @NotBlank(message = "回放不能为空") - @HttpUrl + @Accessible private String playback; } diff --git a/src/main/java/com/achobeta/util/HttpRequestUtil.java b/src/main/java/com/achobeta/util/HttpRequestUtil.java index 34e6675f..5d65271d 100644 --- a/src/main/java/com/achobeta/util/HttpRequestUtil.java +++ b/src/main/java/com/achobeta/util/HttpRequestUtil.java @@ -1,6 +1,7 @@ package com.achobeta.util; import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; import cn.hutool.http.Method; import com.achobeta.common.enums.HttpRequestEnum; @@ -10,8 +11,6 @@ import org.springframework.web.util.UriComponentsBuilder; import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URL; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.List; @@ -33,24 +32,30 @@ public class HttpRequestUtil { public static final Pattern HTTP_URL_PATTERN = Pattern.compile("^(?i)(http|https):(//(([^@\\[/?#]*)@)?(\\[[\\p{XDigit}:.]*[%\\p{Alnum}]*]|[^\\[/?#:]*)(:(\\{[^}]+\\}?|[^/?#]*))?)?([^?#]*)(\\?([^#]*))?(#(.*))?"); + private static final int MAX_RECURSION_COUNT = 10; + public static boolean isHttpUrl(String url) { return StringUtils.hasText(url) && HTTP_URL_PATTERN.matcher(url).matches(); } - public static boolean isAccessible(HttpURLConnection connection) throws IOException { - return Objects.nonNull(connection) && connection.getResponseCode() / 100 == 2; + public static boolean isAccessible(HttpResponse response) throws IOException { + return Objects.nonNull(response) && response.getStatus() / 100 == 2; } public static boolean isAccessible(String url) throws IOException { - return isAccessible(openConnection(url)); + return isAccessible(getRequestAndExecute(url)); + } + + public static HttpResponse getRequestAndExecute(String url) { + return getRequestAndExecute(url, 1); } - public static HttpURLConnection openConnection(String url) throws IOException { - HttpURLConnection connection = isHttpUrl(url) ? (HttpURLConnection) new URL(url).openConnection() : null; - if(Objects.nonNull(connection) && connection.getResponseCode() / 100 == 3) { - return openConnection(connection.getHeaderField("Location")); // Location 就是最深的那个地址了 + public static HttpResponse getRequestAndExecute(String url, int count) { + HttpResponse response = isHttpUrl(url) ? HttpUtil.createRequest(Method.GET, url).execute() : null; + if(Objects.nonNull(response) && response.getStatus() / 100 == 3 && count <= MAX_RECURSION_COUNT) { + return getRequestAndExecute(response.header("Location"), count + 1); // Location 就是最深的那个地址了 } else { - return connection; + return response; } } diff --git a/src/main/java/com/achobeta/util/MediaUtil.java b/src/main/java/com/achobeta/util/MediaUtil.java index 3c4c0e18..11435df1 100644 --- a/src/main/java/com/achobeta/util/MediaUtil.java +++ b/src/main/java/com/achobeta/util/MediaUtil.java @@ -1,5 +1,6 @@ package com.achobeta.util; +import cn.hutool.http.HttpResponse; import com.achobeta.common.enums.GlobalServiceStatusCode; import com.achobeta.exception.GlobalServiceException; import lombok.extern.slf4j.Slf4j; @@ -8,7 +9,6 @@ import org.springframework.web.multipart.MultipartFile; import java.io.*; -import java.net.HttpURLConnection; import java.util.Objects; import java.util.function.Function; import java.util.zip.Adler32; @@ -51,8 +51,8 @@ public static byte[] compressImage(byte[] bytes) { } public static InputStream getInputStream(String url) throws IOException { - HttpURLConnection connection = HttpRequestUtil.openConnection(url); - return HttpRequestUtil.isAccessible(connection) ? connection.getInputStream() : null; + HttpResponse response = HttpRequestUtil.getRequestAndExecute(url); + return HttpRequestUtil.isAccessible(response) ? response.bodyStream() : null; } public static InputStream getInputStream(byte[] bytes) { From 73ec72d75ff82adf166c9174c7a59704a9ecab0a Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sat, 19 Oct 2024 23:04:12 +0800 Subject: [PATCH 100/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/achobeta/util/HttpRequestUtil.java | 34 +++++++++++++++++-- .../java/com/achobeta/util/MediaUtil.java | 15 ++++++-- .../ext/InterviewQuestionScoreExtMapper.xml | 3 +- .../ext/ActivityParticipationExtMapper.xml | 2 +- 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/achobeta/util/HttpRequestUtil.java b/src/main/java/com/achobeta/util/HttpRequestUtil.java index 5d65271d..fd4eef6e 100644 --- a/src/main/java/com/achobeta/util/HttpRequestUtil.java +++ b/src/main/java/com/achobeta/util/HttpRequestUtil.java @@ -5,12 +5,18 @@ import cn.hutool.http.HttpUtil; import cn.hutool.http.Method; import com.achobeta.common.enums.HttpRequestEnum; +import lombok.extern.slf4j.Slf4j; +import org.apache.http.client.HttpClient; +import org.apache.http.impl.client.HttpClientBuilder; import org.springframework.http.HttpHeaders; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.StringUtils; import org.springframework.web.util.UriComponentsBuilder; import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.List; @@ -26,24 +32,46 @@ * Time: 7:41 * Description: 用 Gson 序列化,已有业务依赖 Gson,不建议修改为其他序列化器 */ +@Slf4j public class HttpRequestUtil { public final static Map JSON_CONTENT_TYPE_HEADER = Map.of(HttpHeaders.CONTENT_TYPE, "application/json; charset=utf-8"); public static final Pattern HTTP_URL_PATTERN = Pattern.compile("^(?i)(http|https):(//(([^@\\[/?#]*)@)?(\\[[\\p{XDigit}:.]*[%\\p{Alnum}]*]|[^\\[/?#:]*)(:(\\{[^}]+\\}?|[^/?#]*))?)?([^?#]*)(\\?([^#]*))?(#(.*))?"); - private static final int MAX_RECURSION_COUNT = 10; + private static final int MAX_REDIRECT_COUNT = 30; public static boolean isHttpUrl(String url) { return StringUtils.hasText(url) && HTTP_URL_PATTERN.matcher(url).matches(); } + public static boolean isAccessible(HttpURLConnection connection) throws IOException { + return Objects.nonNull(connection) && connection.getResponseCode() / 100 == 2; + } + public static boolean isAccessible(HttpResponse response) throws IOException { return Objects.nonNull(response) && response.getStatus() / 100 == 2; } public static boolean isAccessible(String url) throws IOException { - return isAccessible(getRequestAndExecute(url)); + // 尝试两种方式去校验 + try { + if(isAccessible(getRequestAndExecute(url))) { + return Boolean.TRUE; + } + } catch (Exception e) { + log.warn(e.getMessage()); + } + return isAccessible(openConnection(url)); + } + + public static HttpURLConnection openConnection(String url) throws IOException { + HttpURLConnection connection = isHttpUrl(url) ? (HttpURLConnection) new URL(url).openConnection() : null; + if(Objects.nonNull(connection) && connection.getResponseCode() / 100 == 3) { + return openConnection(connection.getHeaderField("Location")); // Location 就是最深的那个地址了 + } else { + return connection; + } } public static HttpResponse getRequestAndExecute(String url) { @@ -52,7 +80,7 @@ public static HttpResponse getRequestAndExecute(String url) { public static HttpResponse getRequestAndExecute(String url, int count) { HttpResponse response = isHttpUrl(url) ? HttpUtil.createRequest(Method.GET, url).execute() : null; - if(Objects.nonNull(response) && response.getStatus() / 100 == 3 && count <= MAX_RECURSION_COUNT) { + if(Objects.nonNull(response) && response.getStatus() / 100 == 3 && count <= MAX_REDIRECT_COUNT) { return getRequestAndExecute(response.header("Location"), count + 1); // Location 就是最深的那个地址了 } else { return response; diff --git a/src/main/java/com/achobeta/util/MediaUtil.java b/src/main/java/com/achobeta/util/MediaUtil.java index 11435df1..335a83e1 100644 --- a/src/main/java/com/achobeta/util/MediaUtil.java +++ b/src/main/java/com/achobeta/util/MediaUtil.java @@ -9,6 +9,7 @@ import org.springframework.web.multipart.MultipartFile; import java.io.*; +import java.net.HttpURLConnection; import java.util.Objects; import java.util.function.Function; import java.util.zip.Adler32; @@ -51,8 +52,18 @@ public static byte[] compressImage(byte[] bytes) { } public static InputStream getInputStream(String url) throws IOException { - HttpResponse response = HttpRequestUtil.getRequestAndExecute(url); - return HttpRequestUtil.isAccessible(response) ? response.bodyStream() : null; + // 尝试两次去获取 + try { + HttpResponse response = HttpRequestUtil.getRequestAndExecute(url); + InputStream inputStream = HttpRequestUtil.isAccessible(response) ? response.bodyStream() : null; + if(Objects.nonNull(inputStream)) { + return inputStream; + } + } catch (Exception e) { + log.warn(e.getMessage()); + } + HttpURLConnection connection = HttpRequestUtil.openConnection(url); + return HttpRequestUtil.isAccessible(connection) ? connection.getInputStream() : null; } public static InputStream getInputStream(byte[] bytes) { diff --git a/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml b/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml index 97c36ea7..afb0e0c5 100644 --- a/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml +++ b/src/main/resources/mapper/evaluate/ext/InterviewQuestionScoreExtMapper.xml @@ -15,8 +15,9 @@ q.id, q.title, q.standard, q.create_time, q.update_time, avg(s.score) average from question q left join interview_question_score s on q.id = s.question_id and s.is_deleted = 0 and q.is_deleted = 0 and s.score >= 0 + left join interview i on i.id = s.interview_id and s.is_deleted = 0 and i.is_deleted = 0 - q.id is not null and q.is_deleted = 0 + q.id is not null and q.is_deleted = 0 and i.id is not null #{questionId,jdbcType=BIGINT} diff --git a/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml b/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml index 463b2720..d167e22c 100644 --- a/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml +++ b/src/main/resources/mapper/recruit/ext/ActivityParticipationExtMapper.xml @@ -72,7 +72,7 @@ ap.id, q.id q_id, q.title q_title, pq.answer q_answer, pq.create_time pq_create_time, from - activity_participation ap + activity_participation ap left join recruitment_activity a on a.id = ap.act_id and a.is_deleted = 0 and ap.is_deleted = 0 left join recruitment_batch b on b.id = a.batch_id and b.is_deleted = 0 and a.is_deleted = 0 left join stu_resume r on r.batch_id = b.id and r.user_id = ap.stu_id and b.is_deleted = 0 and r.is_deleted = 0 From a9497530ac6902571089103d784578d09b6cb79e Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 20 Oct 2024 00:15:46 +0800 Subject: [PATCH 101/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feishu/service/impl/FeishuServiceImpl.java | 12 +++++++----- src/main/java/com/achobeta/util/HttpRequestUtil.java | 5 +---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuServiceImpl.java b/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuServiceImpl.java index 497e208f..52cb8674 100644 --- a/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuServiceImpl.java +++ b/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuServiceImpl.java @@ -23,10 +23,7 @@ import com.lark.oapi.service.drive.v1.enums.UploadAllMediaParentTypeEnum; import com.lark.oapi.service.drive.v1.model.*; import com.lark.oapi.service.vc.v1.enums.ApplyReserveUserIdTypeEnum; -import com.lark.oapi.service.vc.v1.model.ApplyReserveReqBody; -import com.lark.oapi.service.vc.v1.model.ApplyReserveResp; -import com.lark.oapi.service.vc.v1.model.ApplyReserveRespBody; -import com.lark.oapi.service.vc.v1.model.ReserveMeetingSetting; +import com.lark.oapi.service.vc.v1.model.*; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.InitializingBean; @@ -145,10 +142,15 @@ public ApplyReserveRespBody reserveApply(ApplyReserveReqBody applyReserveReqBody @Override public ApplyReserveRespBody reserveApplyBriefly(String ownerId, Long endTime, String topic) { + // 这里预约的会议不会出现在日历里 + // 其中,是否自动录制(云录制,无法自动本地录制),不会根据飞书管理后台的全局配置中的是否自动录制,在飞书网页/软件申请的会议根据的才会用到这个全局配置 + // 而我们这次的请求参数若不设置,默认为 false(局部优先),设置为 true 后,若允许云录制会议有若的时候就会自动录制 ApplyReserveReqBody reserveReqBody = ApplyReserveReqBody.newBuilder() .endTime(String.valueOf(TimeUtil.millisToSecond(endTime))) .ownerId(ownerId) - .meetingSettings(ReserveMeetingSetting.newBuilder().topic(topic).meetingInitialType(GROUP_MEETING).build()) + .meetingSettings(ReserveMeetingSetting.newBuilder().topic(topic) +// .autoRecord(Boolean.TRUE) + .meetingInitialType(GROUP_MEETING).build()) .build(); return reserveApply(reserveReqBody); } diff --git a/src/main/java/com/achobeta/util/HttpRequestUtil.java b/src/main/java/com/achobeta/util/HttpRequestUtil.java index fd4eef6e..4888050b 100644 --- a/src/main/java/com/achobeta/util/HttpRequestUtil.java +++ b/src/main/java/com/achobeta/util/HttpRequestUtil.java @@ -6,8 +6,6 @@ import cn.hutool.http.Method; import com.achobeta.common.enums.HttpRequestEnum; import lombok.extern.slf4j.Slf4j; -import org.apache.http.client.HttpClient; -import org.apache.http.impl.client.HttpClientBuilder; import org.springframework.http.HttpHeaders; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.StringUtils; @@ -15,7 +13,6 @@ import java.io.IOException; import java.net.HttpURLConnection; -import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; @@ -39,7 +36,7 @@ public class HttpRequestUtil { public static final Pattern HTTP_URL_PATTERN = Pattern.compile("^(?i)(http|https):(//(([^@\\[/?#]*)@)?(\\[[\\p{XDigit}:.]*[%\\p{Alnum}]*]|[^\\[/?#:]*)(:(\\{[^}]+\\}?|[^/?#]*))?)?([^?#]*)(\\?([^#]*))?(#(.*))?"); - private static final int MAX_REDIRECT_COUNT = 30; + private static final int MAX_REDIRECT_COUNT = 10; public static boolean isHttpUrl(String url) { return StringUtils.hasText(url) && HTTP_URL_PATTERN.matcher(url).matches(); From 018be69aac86072f565c32d4771c91d06ef0553a Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Sun, 20 Oct 2024 00:16:13 +0800 Subject: [PATCH 102/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/feishu/service/impl/FeishuServiceImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuServiceImpl.java b/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuServiceImpl.java index 52cb8674..0bbd10e8 100644 --- a/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuServiceImpl.java +++ b/src/main/java/com/achobeta/domain/feishu/service/impl/FeishuServiceImpl.java @@ -23,7 +23,10 @@ import com.lark.oapi.service.drive.v1.enums.UploadAllMediaParentTypeEnum; import com.lark.oapi.service.drive.v1.model.*; import com.lark.oapi.service.vc.v1.enums.ApplyReserveUserIdTypeEnum; -import com.lark.oapi.service.vc.v1.model.*; +import com.lark.oapi.service.vc.v1.model.ApplyReserveReqBody; +import com.lark.oapi.service.vc.v1.model.ApplyReserveResp; +import com.lark.oapi.service.vc.v1.model.ApplyReserveRespBody; +import com.lark.oapi.service.vc.v1.model.ReserveMeetingSetting; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.InitializingBean; From 018383db659872cb0db78a325a34b9722fbe7438 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Mon, 21 Oct 2024 22:04:56 +0800 Subject: [PATCH 103/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../achobeta/template/util/MarkdownUtil.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/achobeta/template/util/MarkdownUtil.java b/src/main/java/com/achobeta/template/util/MarkdownUtil.java index 413bbbbe..1dcacfde 100644 --- a/src/main/java/com/achobeta/template/util/MarkdownUtil.java +++ b/src/main/java/com/achobeta/template/util/MarkdownUtil.java @@ -22,6 +22,7 @@ import com.vladsch.flexmark.ext.toc.TocExtension; import com.vladsch.flexmark.ext.typographic.TypographicExtension; import com.vladsch.flexmark.ext.wikilink.WikiLinkExtension; +import com.vladsch.flexmark.formatter.Formatter; import com.vladsch.flexmark.html.HtmlRenderer; import com.vladsch.flexmark.html2md.converter.FlexmarkHtmlConverter; import com.vladsch.flexmark.parser.Parser; @@ -29,7 +30,7 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.MutableDataSet; -import java.util.List; +import java.util.Arrays; /** * Created With Intellij IDEA @@ -48,16 +49,18 @@ public class MarkdownUtil { private final static FlexmarkHtmlConverter HTML_CONVERTER; + private final static Formatter MARKDOWN_FORMATTER; + static { OPTIONS = new MutableDataSet() // 指定 Markdown 标准为 COMMONMARK(使用 ParserEmulationProfile.MARKDOWN 可能会有一些语法失效!) .setFrom(ParserEmulationProfile.COMMONMARK) - .set(Parser.EXTENSIONS, List.of(new Parser.ParserExtension[]{ + .set(Parser.EXTENSIONS, Arrays.asList(new Parser.ParserExtension[]{ // 设置一些常扩展 TocExtension.create(), TablesExtension.create(), AbbreviationExtension.create(), - AutolinkExtension.create(), +// AutolinkExtension.create(), AnchorLinkExtension.create(), AsideExtension.create(), AdmonitionExtension.create(), @@ -80,6 +83,7 @@ public class MarkdownUtil { PARSER = Parser.builder(OPTIONS).build(); HTML_RENDERER = HtmlRenderer.builder(OPTIONS).build(); HTML_CONVERTER = FlexmarkHtmlConverter.builder(OPTIONS).build(); + MARKDOWN_FORMATTER = Formatter.builder(OPTIONS).build(); } public static String markdownToHtml(String markdown) { @@ -94,4 +98,12 @@ public static String htmlToMarkdown(String html) { return HTML_CONVERTER.convert(html); } + public static String markdownPrettyUp(String markdown) { + + // 解析 Markdown 文本为节点 + Node document = PARSER.parse(markdown); + // 格式化 Markdown + return MARKDOWN_FORMATTER.render(document); + } + } From 4d1410ecc080ca1ac508ca7868d0a656ae252918 Mon Sep 17 00:00:00 2001 From: "s:103" <2040484356@qq.com> Date: Mon, 21 Oct 2024 22:16:14 +0800 Subject: [PATCH 104/104] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/interview/controller/InterviewController.java | 7 ------- .../domain/interview/service/InterviewService.java | 2 -- .../interview/service/impl/InterviewServiceImpl.java | 6 ------ src/main/java/com/achobeta/template/util/MarkdownUtil.java | 1 - 4 files changed, 16 deletions(-) diff --git a/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java b/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java index e6538a24..4e0a4337 100644 --- a/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java +++ b/src/main/java/com/achobeta/domain/interview/controller/InterviewController.java @@ -34,9 +34,6 @@ import java.util.Objects; import java.util.Optional; -import static com.achobeta.domain.interview.enums.InterviewStatus.ENDED; -import static com.achobeta.domain.interview.enums.InterviewStatus.NOT_STARTED; - /** * Created With Intellij IDEA * Description: @@ -70,8 +67,6 @@ public SystemJsonResponse createInterview(@Valid @RequestBody InterviewCreateDTO @PostMapping("/update") public SystemJsonResponse updateInterview(@Valid @RequestBody InterviewUpdateDTO interviewUpdateDTO) { - // 未开始才能修改 - interviewService.checkInterviewStatus(interviewUpdateDTO.getInterviewId(), List.of(NOT_STARTED, ENDED)); // 更新 interviewService.updateInterview(interviewUpdateDTO); return SystemJsonResponse.SYSTEM_SUCCESS(); @@ -117,8 +112,6 @@ public SystemJsonResponse setPaperForInterview(@Valid @RequestBody InterviewPape // 检查 Long interviewId = interviewPaperDTO.getInterviewId(); Interview interview = interviewService.checkAndGetInterviewExists(interviewId); - // 检查面试是否未开始 - interview.getStatus().check(List.of(NOT_STARTED, ENDED)); Long paperId = interviewPaperDTO.getPaperId(); if(!Objects.equals(interview.getPaperId(), paperId)) { // 检查试卷是否存在 diff --git a/src/main/java/com/achobeta/domain/interview/service/InterviewService.java b/src/main/java/com/achobeta/domain/interview/service/InterviewService.java index d5171e83..17374b1e 100644 --- a/src/main/java/com/achobeta/domain/interview/service/InterviewService.java +++ b/src/main/java/com/achobeta/domain/interview/service/InterviewService.java @@ -57,6 +57,4 @@ public interface InterviewService extends IService { Interview checkAndGetInterviewExists(Long interviewId); - void checkInterviewStatus(Long interviewId, List interviewStatus); - } diff --git a/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java b/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java index e6e883ea..38104fce 100644 --- a/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java +++ b/src/main/java/com/achobeta/domain/interview/service/impl/InterviewServiceImpl.java @@ -188,10 +188,4 @@ public Interview checkAndGetInterviewExists(Long interviewId) { new GlobalServiceException(GlobalServiceStatusCode.INTERVIEW_NOT_EXISTS)); } - @Override - public void checkInterviewStatus(Long interviewId, List interviewStatus) { - checkAndGetInterviewExists(interviewId) - .getStatus() - .check(interviewStatus); - } } diff --git a/src/main/java/com/achobeta/template/util/MarkdownUtil.java b/src/main/java/com/achobeta/template/util/MarkdownUtil.java index 1dcacfde..cbcf394b 100644 --- a/src/main/java/com/achobeta/template/util/MarkdownUtil.java +++ b/src/main/java/com/achobeta/template/util/MarkdownUtil.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.ext.admonition.AdmonitionExtension; import com.vladsch.flexmark.ext.anchorlink.AnchorLinkExtension; import com.vladsch.flexmark.ext.aside.AsideExtension; -import com.vladsch.flexmark.ext.autolink.AutolinkExtension; import com.vladsch.flexmark.ext.definition.DefinitionExtension; import com.vladsch.flexmark.ext.emoji.EmojiExtension; import com.vladsch.flexmark.ext.footnotes.FootnoteExtension;