diff --git a/mailbox-outer-admin/pom.xml b/mailbox-outer-admin/pom.xml
index 505b054..d70f4df 100644
--- a/mailbox-outer-admin/pom.xml
+++ b/mailbox-outer-admin/pom.xml
@@ -73,6 +73,14 @@
jjwt
0.12.3
+
+ com.github.ben-manes.caffeine
+ caffeine
+
+
+ com.github.ben-manes.caffeine
+ caffeine
+
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/config/LoginConfig.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/config/LoginConfig.java
index 1ad0832..f460b9e 100644
--- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/config/LoginConfig.java
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/config/LoginConfig.java
@@ -18,7 +18,8 @@ public class LoginConfig implements WebMvcConfigurer {
interceptorRegistration.excludePathPatterns(
"/login",
"/captcha",
- "/refresh-token"
+ "/refresh-token",
+ "/file/stream/**"
);
}
}
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/FileController.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/FileController.java
new file mode 100644
index 0000000..c84fc89
--- /dev/null
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/FileController.java
@@ -0,0 +1,82 @@
+package com.biutag.outeradmin.controller;
+
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson2.JSONObject;
+import com.biutag.config.Minio;
+import com.biutag.core.AjaxResult;
+import com.biutag.util.IOUtil;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+@Slf4j
+@RequestMapping("file")
+@Controller
+public class FileController {
+
+ @Autowired(required = false)
+ private Minio minio;
+
+ @ResponseBody
+ @PostMapping("upload")
+ public AjaxResult upload(@RequestPart("file") MultipartFile file) throws IOException {
+ String filepath = minio.upload(file.getInputStream(), file.getOriginalFilename());
+ return AjaxResult.success(JSONObject.of("filepath", filepath));
+ }
+
+ @ResponseBody
+ @PostMapping("upload/base64")
+ public AjaxResult upload(@RequestBody JSONObject file) {
+ long l = System.currentTimeMillis();
+ log.info("文件上传开始----------------------------------------");
+ String base64 = file.getString("base64");
+ if (base64.startsWith("data:image")) {
+ base64 = base64.substring(base64.indexOf(",") + 1);
+ }
+ String filepath = minio.upload(base64);
+ log.info("文件上传耗时:{}ms", System.currentTimeMillis() - l);
+ return AjaxResult.success(JSONObject.of("filepath", filepath));
+ }
+
+ @ResponseBody
+ @PostMapping("upload/base64/test")
+ public AjaxResult uploadTest(@RequestBody JSONObject file) {
+ long l = System.currentTimeMillis();
+ String base64 = file.getString("base64");
+ log.info("test 文件上传 base64: {}", StrUtil.isNotBlank(base64) ? base64.substring(0, Math.min(20, base64.length())) : "");
+ if (base64.startsWith("data:image")) {
+ base64 = base64.substring(base64.indexOf(",") + 1);
+ }
+ InputStream is = IOUtil.base64ToStream(base64);
+ try {
+ FileOutputStream os = new FileOutputStream("/home/jar/files/" + IdUtil.simpleUUID());
+ byte[] buffer = new byte[1024];
+ int bytesRead;
+ while ((bytesRead = is.read(buffer, 0, buffer.length)) != -1) {
+ os.write(buffer, 0, bytesRead);
+ }
+ is.close();
+ os.close();
+ } catch (IOException e) {
+ log.error(e.getMessage(), e);
+ }
+ log.info("文件上传耗时:{}ms", System.currentTimeMillis() - l);
+ return AjaxResult.success(JSONObject.of("filepath", "test"));
+ }
+
+ @GetMapping("stream/**")
+ public void download(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ String requestURI = request.getRequestURI();
+ minio.get(requestURI.substring("/file/stream/".length()), response.getOutputStream());
+ }
+
+}
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/LoginController.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/LoginController.java
index 7fbe212..da2b71a 100644
--- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/LoginController.java
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/LoginController.java
@@ -8,7 +8,6 @@ import com.biutag.outeradmin.dto.TokenDTO;
import com.biutag.outeradmin.entity.User;
import com.biutag.outeradmin.service.UserService;
import com.biutag.outeradmin.util.JwtUtil;
-import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/MailController.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/MailController.java
index 25df790..9e167de 100644
--- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/MailController.java
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/MailController.java
@@ -1,9 +1,12 @@
package com.biutag.outeradmin.controller;
import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.biutag.core.AjaxResult;
+import com.biutag.exception.BusinessException;
import com.biutag.outeradmin.dto.*;
import com.biutag.outeradmin.entity.*;
import com.biutag.outeradmin.mapper.MailMapper;
@@ -12,6 +15,7 @@ import com.biutag.outeradmin.util.DesensitizedUtil;
import com.biutag.outeradmin.util.ExcelUtil;
import com.biutag.util.StringUtils;
import jakarta.servlet.http.HttpServletResponse;
+import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
@@ -42,6 +46,14 @@ public class MailController {
return result;
}
+ @PostMapping("add")
+ public AjaxResult add(@RequestBody String form) {
+ JSONObject jsonObject = JSON.parseObject(form);
+ JSONObject mailBo = jsonObject.getJSONObject("MailBo");
+ return AjaxResult.success(mailService.save(mailBo));
+ }
+
+
/**
* 根据前端表格数据查询指定信件
*
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailBo.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailBo.java
new file mode 100644
index 0000000..385c3c8
--- /dev/null
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailBo.java
@@ -0,0 +1,85 @@
+package com.biutag.outeradmin.dto;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.alibaba.fastjson2.JSON;
+
+import com.biutag.outeradmin.entity.Mail;
+import com.biutag.validator.annotation.IdCard;
+import com.biutag.validator.annotation.Phone;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Size;
+import lombok.Getter;
+import lombok.Setter;
+import org.hibernate.validator.constraints.Length;
+
+import java.util.List;
+
+@Setter
+@Getter
+public class MailBo {
+
+ private String id;
+
+ /**
+ * 联系人姓名
+ */
+ @NotBlank(message = "联系人姓名不能为空")
+ @Length(min = 2, max = 20, message = "联系人姓名不符合规范(2-20字)")
+ private String contactName;
+
+ /**
+ * 联系人性别
+ */
+ @NotBlank(message = "联系人性别不能为空")
+ private String contactSex;
+
+ /**
+ * 联系人身份证号码
+ */
+ @IdCard
+ private String contactIdCard;
+
+ /**
+ *
+ */
+ @Phone
+ private String contactPhone;
+
+
+ /**
+ * 案件编号
+ */
+ private String caseNumber;
+
+ /**
+ * 内容
+ */
+ @Length(min= 10, max = 300, message = "信件内容不符合规范(不少于10字,不多于300字)")
+ @NotBlank(message = "信件内容不能为空")
+ private String content;
+
+ /**
+ * 附件
+ */
+ @Size(max = 5, message = "附件数量不能超过5")
+ private List attachments;
+
+ /**
+ * 涉及单位ID
+ */
+ private Integer involvedDeptId;
+
+ /**
+ * 涉及单位名称
+ */
+ private String involvedDeptName;
+
+ @Setter
+ @Getter
+ public static class Attachment {
+ private String filepath;
+ private String type;
+ private String originFilename;
+ }
+
+}
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/Mail.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/Mail.java
index a5697e3..0405916 100644
--- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/Mail.java
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/Mail.java
@@ -3,6 +3,7 @@ package com.biutag.outeradmin.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
+import java.time.LocalDateTime;
import java.util.Date;
@Data
@@ -53,7 +54,7 @@ public class Mail {
/**
* 创建时间
*/
- private Date createTime;
+ private LocalDateTime createTime;
/**
* 更新时间
@@ -69,4 +70,20 @@ public class Mail {
* 是否满意
*/
private String satisfaction;
+
+ /**
+ * 信件状态
+ */
+ private String mailState;
+
+
+ /**
+ * 涉及单位ID
+ */
+ private Integer involvedDeptId;
+
+ /**
+ * 涉及单位名称
+ */
+ private String involvedDeptName;
}
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/User.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/User.java
index ed1fe55..a23f518 100644
--- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/User.java
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/User.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
+import java.time.LocalDateTime;
import java.util.Date;
@Data
@@ -17,6 +18,6 @@ public class User {
private String idCard;
private String realName;
private String phone;
- private Date updateTime;
- private Date faceAuthTime;
+ private LocalDateTime updateTime;
+ private LocalDateTime faceAuthTime;
}
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/enums/MailStateEnum.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/enums/MailStateEnum.java
new file mode 100644
index 0000000..dda0917
--- /dev/null
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/enums/MailStateEnum.java
@@ -0,0 +1,17 @@
+package com.biutag.outeradmin.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public enum MailStateEnum {
+ processing("processing", "办理中"),
+ terminated("terminated", "已终止"),
+ completion("completion", "已办结");
+
+ private String value;
+
+ private String name;
+
+}
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/mapper/MailMapper.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/mapper/MailMapper.java
index 66b4ba3..f13fe13 100644
--- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/mapper/MailMapper.java
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/mapper/MailMapper.java
@@ -3,7 +3,10 @@ package com.biutag.outeradmin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.outeradmin.entity.Mail;
import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
@Mapper
public interface MailMapper extends BaseMapper {
+ @Select("SELECT nextval('mail_id_seq') ")
+ Integer getMailIdSeqVal();
}
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/MailService.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/MailService.java
index 1ec9275..212ada2 100644
--- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/MailService.java
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/MailService.java
@@ -1,10 +1,75 @@
package com.biutag.outeradmin.service;
+import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.outeradmin.entity.Mail;
+import com.biutag.outeradmin.entity.User;
+import com.biutag.outeradmin.enums.MailStateEnum;
import com.biutag.outeradmin.mapper.MailMapper;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.time.LocalDateTime;
+import java.util.Date;
@Service
public class MailService extends ServiceImpl {
+
+ public final UserService userService;
+
+ public MailService(UserService userService) {
+ this.userService = userService;
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ public boolean save(JSONObject mailBo) {
+ // HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+ // 获取请求头的值
+// String authorization = request.getHeader("Authorization");
+// String jwtToken = null;
+// if (authorization.startsWith("Bearer ")) {
+// // 截取并去掉"Bearer "前缀,得到JWT令牌
+// jwtToken = authorization.substring(7); // 7是"Bearer "的长度
+// }
+// Claims claims = JwtUtil.parsePayload(jwtToken);
+// String phone = claims.get("username").toString();
+ Mail mail = new Mail();
+ mail.setId(generateMailId());
+ mail.setCreateTime(LocalDateTime.now());
+ mail.setContactName(mailBo.getString("contactName"));
+ mail.setAttachments(mailBo.getString("attachments"));
+ mail.setCaseNumber(mailBo.getString("caseNumber"));
+ mail.setContactPhone(mailBo.getString("contactPhone"));
+ mail.setContactIdCard(mailBo.getString("contactIdCard"));
+ mail.setContactSex(mailBo.getString("contactSex"));
+ mail.setContent(mailBo.getString("content"));
+ mail.setInvolvedDeptId(Integer.parseInt(mailBo.getString("involvedDeptId")));
+ mail.setInvolvedDeptName(mailBo.getString("involvedDeptName"));
+ QueryWrapper queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("phone",mailBo.getString("contactPhone"));
+ User user = userService.getOne(queryWrapper, false);
+ if (user == null){
+ return false;
+ }
+ mail.setUserId(user.getId());
+ mail.setMailState(MailStateEnum.processing.getValue());
+ boolean save = save(mail);
+// boolean save = true;
+ return save;
+ }
+
+ public String generateMailId() {
+ 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") + "XXWW" + zeroString + seqVal;
+ }
+
+
}
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/UserService.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/UserService.java
index d6835fe..a0dd94f 100644
--- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/UserService.java
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/UserService.java
@@ -1,5 +1,6 @@
package com.biutag.outeradmin.service;
+
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.outeradmin.entity.User;
import com.biutag.outeradmin.mapper.UserMapper;
@@ -7,4 +8,5 @@ import org.springframework.stereotype.Service;
@Service
public class UserService extends ServiceImpl {
+
}
diff --git a/mailbox-outer-admin/src/main/resources/application.yml b/mailbox-outer-admin/src/main/resources/application.yml
index 42eedf8..3857d98 100644
--- a/mailbox-outer-admin/src/main/resources/application.yml
+++ b/mailbox-outer-admin/src/main/resources/application.yml
@@ -9,4 +9,13 @@ 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
+
+
+oss:
+ minio:
+ enable: true
+ endpoint: http://172.31.217.20:31401
+ accessKey: n8yPVAJk4yw879zi
+ secretKey: eElQ7gCwuNxaFhKEbtRRq0lsovoOTgI1
+ bucketName: mailbox
\ No newline at end of file
diff --git a/mailbox-outer/src/main/java/com/biutag/outer/domain/MailDraft.java b/mailbox-outer/src/main/java/com/biutag/outer/domain/MailDraft.java
index 2063fe5..d217833 100644
--- a/mailbox-outer/src/main/java/com/biutag/outer/domain/MailDraft.java
+++ b/mailbox-outer/src/main/java/com/biutag/outer/domain/MailDraft.java
@@ -68,12 +68,12 @@ public class MailDraft {
/**
* 涉及单位ID
*/
- private Integer involvedDeptId;
+// private Integer involvedDeptId;
/**
* 涉及单位名称
*/
- private String involvedDeptName;
+// private String involvedDeptName;
@TableLogic(value = Constants.UNDELETED, delval = Constants.DELETED)
private String delFlag;