From a4e23b1e68ade3afe35b7d3b9063916e4a8ab504 Mon Sep 17 00:00:00 2001 From: wxc <191104855@qq.com> Date: Thu, 22 Feb 2024 14:09:54 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=B1=80=E9=95=BF=E4=BF=A1=E7=AE=B1(?= =?UTF-8?q?=E5=86=85=E7=BD=91=E7=AB=AF)=20=E8=87=AA=E5=BB=BA=E4=BF=A1?= =?UTF-8?q?=E4=BB=B6=202.=20=E5=AE=8C=E5=96=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/biutag/config/Minio.java | 2 ++ .../biutag/lan/controller/MailController.java | 5 +++-- .../com/biutag/lan/domain/MailSource.java | 18 ++++++++++++++- .../com/biutag/lan/domain/bo/MailOuter.java | 16 +++++++++++++- .../com/biutag/lan/mapper/MailMapper.java | 5 +++++ .../com/biutag/lan/service/MailService.java | 22 ++++++++++++++++--- .../src/main/resources/application.yml | 2 +- .../com/biutag/outer/domain/bo/MailBo.java | 2 +- .../com/biutag/outer/service/MailService.java | 3 ++- 9 files changed, 65 insertions(+), 10 deletions(-) diff --git a/mailbox-common/src/main/java/com/biutag/config/Minio.java b/mailbox-common/src/main/java/com/biutag/config/Minio.java index 82e145d..ab6e46b 100644 --- a/mailbox-common/src/main/java/com/biutag/config/Minio.java +++ b/mailbox-common/src/main/java/com/biutag/config/Minio.java @@ -6,6 +6,7 @@ import com.biutag.exception.MinioOperateException; import com.biutag.util.IOUtil; import io.minio.*; import io.minio.errors.*; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import java.io.IOException; import java.io.InputStream; @@ -16,6 +17,7 @@ import java.security.NoSuchAlgorithmException; import java.util.Date; import java.util.Optional; +@ConditionalOnProperty(value = "oss.minio.enable") public class Minio { private final MinioClient minioClient; diff --git a/mailbox-lan/src/main/java/com/biutag/lan/controller/MailController.java b/mailbox-lan/src/main/java/com/biutag/lan/controller/MailController.java index f6faf83..5ab9583 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/controller/MailController.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/controller/MailController.java @@ -6,6 +6,7 @@ import com.biutag.core.AjaxResult; import com.biutag.lan.domain.MailSource; import com.biutag.lan.domain.bo.FlowAction; import com.biutag.lan.domain.bo.InvalidCompletion; +import com.biutag.lan.domain.bo.MailOuter; import com.biutag.lan.domain.bo.MailSourceBo; import com.biutag.lan.domain.vo.MailFlowDetail; import com.biutag.lan.service.MailService; @@ -30,8 +31,8 @@ public class MailController { @NotPower @PostMapping("add") - public AjaxResult add(@RequestBody @Valid MailSourceBo mailBo) { - return AjaxResult.success(mailService.save(mailBo)); + public AjaxResult add(@RequestBody @Valid MailOuter mail) { + return AjaxResult.success(mailService.save(mail)); } @NotPower diff --git a/mailbox-lan/src/main/java/com/biutag/lan/domain/MailSource.java b/mailbox-lan/src/main/java/com/biutag/lan/domain/MailSource.java index 1019bc4..d2feafa 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/domain/MailSource.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/domain/MailSource.java @@ -87,10 +87,26 @@ public class MailSource { @AllArgsConstructor public enum Source { - MAILBOX("mailbox"); + MAILBOX("mailbox", "XXWW"), + REPORT_COMPLAINTS("110_report_complaints", "JBTS"), + HOTLINE("12345_mayor's_hotline", "SZRX"), + RED_NETWORK_POLITICS("red_network_politics", "HWWZ"), + CREATE_YOUR_OWN_LETTERS("create_your_own_letters", "ZJXJ"); @Getter private String value; + + @Getter + private String key; + + public static Source get(String value) { + for (Source source : values()) { + if (source.getValue().equals(value)) { + return source; + } + } + return null; + } } } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/MailOuter.java b/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/MailOuter.java index 324f536..9b753f4 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/MailOuter.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/MailOuter.java @@ -1,8 +1,12 @@ package com.biutag.lan.domain.bo; import com.biutag.lan.domain.MailSource; +import com.biutag.validator.annotation.IdCard; +import com.biutag.validator.annotation.Phone; +import jakarta.validation.constraints.NotBlank; import lombok.Getter; import lombok.Setter; +import org.hibernate.validator.constraints.Length; import org.springframework.beans.BeanUtils; import java.time.LocalDateTime; @@ -19,21 +23,25 @@ public class MailOuter { /** * 联系人姓名 */ + @NotBlank(message = "请输入联系人姓名") private String contactName; /** * 联系人性别 M / F */ + @NotBlank(message = "请选择联系人性别") private String contactSex; /** * 联系人身份证号 */ + @IdCard private String contactIdCard; /** * 联系人手机号 */ + @Phone private String contactPhone; /** @@ -44,6 +52,8 @@ public class MailOuter { /** * 内容 */ + @Length(min= 10, max = 300, message = "信件内容不符合规范(不少于10字,不多于300字)") + @NotBlank(message = "请输入信件内容") private String content; /** @@ -60,20 +70,24 @@ public class MailOuter { * 来信时间 */ private LocalDateTime mailTime; + /** * 涉及单位ID */ private Integer involvedDeptId; + /** * 涉及单位名称 */ private String involvedDeptName; + + private String source = MailSource.Source.MAILBOX.getValue(); + public MailSource toMailSource() { MailSource mailSource = new MailSource(); BeanUtils.copyProperties(this, mailSource); mailSource.setMailTime(createTime); - mailSource.setSource(MailSource.Source.MAILBOX.getValue()); mailSource.setCreateTime(LocalDateTime.now()); mailSource.setSignFlag(false); return mailSource; diff --git a/mailbox-lan/src/main/java/com/biutag/lan/mapper/MailMapper.java b/mailbox-lan/src/main/java/com/biutag/lan/mapper/MailMapper.java index 18902ad..719f1a7 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/mapper/MailMapper.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/mapper/MailMapper.java @@ -2,6 +2,11 @@ package com.biutag.lan.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.biutag.lan.domain.Mail; +import org.apache.ibatis.annotations.Select; public interface MailMapper extends BaseMapper { + + @Select("SELECT nextval('mail_id_seq') ") + Integer getMailIdSeqVal(); + } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/MailService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/MailService.java index ac4d47b..d279e53 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/MailService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/MailService.java @@ -13,7 +13,7 @@ import com.biutag.lan.AdminThreadLocal; import com.biutag.lan.domain.*; import com.biutag.lan.domain.bo.FlowAction; import com.biutag.lan.domain.bo.InvalidCompletion; -import com.biutag.lan.domain.bo.MailSourceBo; +import com.biutag.lan.domain.bo.MailOuter; import com.biutag.lan.domain.vo.MailApprovalVo; import com.biutag.lan.domain.vo.MailFlowDetail; import com.biutag.lan.domain.vo.MailVo; @@ -291,7 +291,23 @@ public class MailService extends ServiceImpl { return true; } - public boolean save(MailSourceBo mailBo) { - return false; + public boolean save(MailOuter mail) { + LocalDateTime now = LocalDateTime.now(); + mail.setId(generateMailId(mail.getSource())); + mail.setMailTime(now); + mail.setCreateTime(now); + return mailSourceService.saveBatch(Collections.singletonList(mail)); } + + public String generateMailId(String source) { + Integer seqVal = baseMapper.getMailIdSeqVal(); + int length = 6 - seqVal.toString().length(); + StringBuilder zeroString = new StringBuilder(); + for (int i = 0; i < length; i++) { + zeroString.append('0'); + } + // XXWW 信箱外网 + return DateUtil.format(new Date(), "yyyyMMddHHMM") + MailSource.Source.get(source).getKey() + zeroString + seqVal; + } + } diff --git a/mailbox-outer-admin/src/main/resources/application.yml b/mailbox-outer-admin/src/main/resources/application.yml index 42eedf8..fee53c0 100644 --- a/mailbox-outer-admin/src/main/resources/application.yml +++ b/mailbox-outer-admin/src/main/resources/application.yml @@ -9,4 +9,4 @@ spring: driver-class-name: org.postgresql.Driver url: jdbc:postgresql://172.31.217.20:32378/mailbox?currentSchema=mailbox-outer username: vbadmin - password: Ip12341234 \ No newline at end of file + password: Ip12341234 diff --git a/mailbox-outer/src/main/java/com/biutag/outer/domain/bo/MailBo.java b/mailbox-outer/src/main/java/com/biutag/outer/domain/bo/MailBo.java index dbc6618..e8d299d 100644 --- a/mailbox-outer/src/main/java/com/biutag/outer/domain/bo/MailBo.java +++ b/mailbox-outer/src/main/java/com/biutag/outer/domain/bo/MailBo.java @@ -29,7 +29,7 @@ public class MailBo { /** * 联系人性别 */ - @NotBlank(message = "请选择联系人称呼") + @NotBlank(message = "请选择联系人性别") private String contactSex; /** diff --git a/mailbox-outer/src/main/java/com/biutag/outer/service/MailService.java b/mailbox-outer/src/main/java/com/biutag/outer/service/MailService.java index e72b61e..b543010 100644 --- a/mailbox-outer/src/main/java/com/biutag/outer/service/MailService.java +++ b/mailbox-outer/src/main/java/com/biutag/outer/service/MailService.java @@ -62,7 +62,8 @@ public class MailService extends ServiceImpl { for (int i = 0; i < length; i++) { zeroString.append('0'); } - return DateUtil.format(new Date(), "yyyyMMddHHMM") + zeroString + seqVal; + // XXWW 信箱外网 + return DateUtil.format(new Date(), "yyyyMMddHHMM") + "XXWW" + zeroString + seqVal; } public Page pageByCurrentUserId(Page page) {