Browse Source

Merge branch 'master' into dev_ycq

dev_ycq
21819 2 years ago
parent
commit
cd19bb1c26
  1. 5
      mailbox-common/pom.xml
  2. 54
      mailbox-common/src/main/java/com/biutag/constants/AppConstants.java
  3. 9
      mailbox-common/src/main/java/com/biutag/constants/Constants.java
  4. 7
      mailbox-common/src/main/java/com/biutag/entity/system/Dept.java
  5. 27
      mailbox-common/src/main/java/com/biutag/entity/system/PoliceDepart.java
  6. 27
      mailbox-common/src/main/java/com/biutag/entity/system/PolicePosition.java
  7. 27
      mailbox-common/src/main/java/com/biutag/entity/system/PoliceRole.java
  8. 1
      mailbox-common/src/main/java/com/biutag/enums/ErrorEnum.java
  9. 8
      mailbox-common/src/main/java/com/biutag/exception/AuthException.java
  10. 4
      mailbox-common/src/main/java/com/biutag/exception/BusinessException.java
  11. 33
      mailbox-common/src/main/java/com/biutag/exception/GlobalException.java
  12. 15
      mailbox-common/src/main/java/com/biutag/mapper/system/PoliceDepartMapper.java
  13. 18
      mailbox-common/src/main/java/com/biutag/mapper/system/PolicePositionMapper.java
  14. 15
      mailbox-common/src/main/java/com/biutag/mapper/system/PoliceRoleMapper.java
  15. 18
      mailbox-common/src/main/java/com/biutag/util/IOUtil.java
  16. 46
      mailbox-common/src/main/java/com/biutag/util/MinioUtil.java
  17. 22
      mailbox-common/src/main/java/com/biutag/validator/IdCardValidator.java
  18. 22
      mailbox-common/src/main/java/com/biutag/validator/PhoneValidator.java
  19. 21
      mailbox-common/src/main/java/com/biutag/validator/annotation/IdCard.java
  20. 21
      mailbox-common/src/main/java/com/biutag/validator/annotation/Phone.java
  21. 1
      mailbox-common/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
  22. 82
      mailbox-lan/src/main/java/com/biutag/lan/service/IPoliceUserService.java
  23. 92
      mailbox-lan/src/main/java/com/biutag/lan/service/impl/DeptServiceImpl.java
  24. 4
      mailbox-lan/src/main/java/com/biutag/lan/service/impl/DutyServiceImpl.java
  25. 24
      mailbox-lan/src/main/java/com/biutag/lan/service/impl/IndexServiceImpl.java
  26. 93
      mailbox-lan/src/main/java/com/biutag/lan/service/impl/PoliceUserServiceImpl.java
  27. 5
      mailbox-lan/src/main/java/com/biutag/lan/validate/system/DeptCreateValidate.java
  28. 5
      mailbox-lan/src/main/java/com/biutag/lan/validate/system/DeptUpdateValidate.java
  29. 2
      mailbox-lan/src/main/java/com/biutag/lan/validate/system/PoliceUserCreateValidate.java
  30. 7
      mailbox-lan/src/main/java/com/biutag/lan/vo/system/DeptVo.java
  31. 49
      mailbox-outer/pom.xml
  32. 41
      mailbox-outer/src/main/java/com/biutag/outer/config/InterceptorConfig.java
  33. 89
      mailbox-outer/src/main/java/com/biutag/outer/config/Minio.java
  34. 21
      mailbox-outer/src/main/java/com/biutag/outer/config/MinioProperties.java
  35. 23
      mailbox-outer/src/main/java/com/biutag/outer/config/MybatisPlusConfig.java
  36. 94
      mailbox-outer/src/main/java/com/biutag/outer/controller/AuthController.java
  37. 45
      mailbox-outer/src/main/java/com/biutag/outer/controller/FileController.java
  38. 37
      mailbox-outer/src/main/java/com/biutag/outer/controller/MailController.java
  39. 46
      mailbox-outer/src/main/java/com/biutag/outer/controller/MailDraftController.java
  40. 30
      mailbox-outer/src/main/java/com/biutag/outer/controller/SmsController.java
  41. 32
      mailbox-outer/src/main/java/com/biutag/outer/domain/FaceAuth.java
  42. 15
      mailbox-outer/src/main/java/com/biutag/outer/domain/Mail.java
  43. 71
      mailbox-outer/src/main/java/com/biutag/outer/domain/MailDraft.java
  44. 26
      mailbox-outer/src/main/java/com/biutag/outer/domain/MailEvaluate.java
  45. 33
      mailbox-outer/src/main/java/com/biutag/outer/domain/User.java
  46. 41
      mailbox-outer/src/main/java/com/biutag/outer/domain/bo/FaceAuthBo.java
  47. 104
      mailbox-outer/src/main/java/com/biutag/outer/domain/bo/MailBo.java
  48. 26
      mailbox-outer/src/main/java/com/biutag/outer/domain/bo/MailEvaluateBo.java
  49. 76
      mailbox-outer/src/main/java/com/biutag/outer/domain/vo/MailDraftVo.java
  50. 89
      mailbox-outer/src/main/java/com/biutag/outer/domain/vo/MailVo.java
  51. 9
      mailbox-outer/src/main/java/com/biutag/outer/mapper/FaceAuthMapper.java
  52. 11
      mailbox-outer/src/main/java/com/biutag/outer/mapper/MailDraftMapper.java
  53. 9
      mailbox-outer/src/main/java/com/biutag/outer/mapper/MailEvaluateMapper.java
  54. 5
      mailbox-outer/src/main/java/com/biutag/outer/mapper/MailMapper.java
  55. 9
      mailbox-outer/src/main/java/com/biutag/outer/mapper/UserMapper.java
  56. 34
      mailbox-outer/src/main/java/com/biutag/outer/service/FaceAuthService.java
  57. 46
      mailbox-outer/src/main/java/com/biutag/outer/service/MailDraftService.java
  58. 10
      mailbox-outer/src/main/java/com/biutag/outer/service/MailEvaluateService.java
  59. 72
      mailbox-outer/src/main/java/com/biutag/outer/service/MailService.java
  60. 30
      mailbox-outer/src/main/java/com/biutag/outer/service/UserService.java
  61. 28
      mailbox-outer/src/main/java/com/biutag/outer/util/CodeUtil.java
  62. 62
      mailbox-outer/src/main/java/com/biutag/outer/util/Sms.java
  63. 32
      mailbox-outer/src/main/java/com/biutag/outer/util/TokenUtil.java
  64. 33
      mailbox-outer/src/main/java/com/biutag/outer/util/UserHelper.java
  65. 86
      mailbox-outer/src/main/java/com/biutag/outer/util/Weixin.java
  66. 90
      mailbox-outer/src/main/java/com/biutag/outer/util/Weixin2.java
  67. 42
      mailbox-outer/src/main/resources/application-bak.yml
  68. 53
      mailbox-outer/src/main/resources/application.yml
  69. 1
      mailbox-outer/src/main/resources/license/license.dat
  70. 58
      mailbox-outer/src/test/java/com/biutag/outer/SmsTest.java
  71. 22
      mailbox-outer/src/test/java/com/biutag/outer/UploadTest.java
  72. 76
      mailbox-outer/src/test/java/com/biutag/outer/WeixinTest.java
  73. 16
      pom.xml

5
mailbox-common/pom.xml

@ -16,11 +16,6 @@
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>

54
mailbox-common/src/main/java/com/biutag/constants/AppConstants.java

@ -0,0 +1,54 @@
package com.biutag.constants;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* Created by oumyye on 2019/1/18.
*/
public class AppConstants {
public static final String DEPT_TYPE_CATEGORY="6"; //是机构类型 数据字段 类型为6
static class Entity {
private String name;
private String age;
public Entity(String name, String age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public String getAge() {
return age;
}
}
public static void main(String[] args) {
List<Entity> entityList = new ArrayList<>();
entityList.add(new Entity("Alice", "20"));
entityList.add(new Entity("Bob", "25"));
entityList.add(new Entity("Charlie", "30"));
String targetAge = "25";
String matchedNames = entityList.stream()
.filter(entity -> entity.getAge() .equals(targetAge))
.map(Entity::getName).findFirst().get();
System.out.println("Found matching names:"+matchedNames);
}
}

9
mailbox-common/src/main/java/com/biutag/constants/Constants.java

@ -0,0 +1,9 @@
package com.biutag.constants;
public class Constants {
public static final String DELETED = "Y";
public static final String UNDELETED = "N";
}

7
mailbox-common/src/main/java/com/biutag/entity/system/Dept.java

@ -27,8 +27,9 @@ public class Dept implements Serializable {
@ApiModelProperty("部门全称")
private String fullName;
@ApiModelProperty("负责人名")
private String duty;
@ApiModelProperty("唯一id")
private String uuid;
@ApiModelProperty("联系电话")
private String mobile;
@ -41,7 +42,7 @@ public class Dept implements Serializable {
private String category;
@ApiModelProperty("层级")
private String level;
private Integer level;
@ApiModelProperty("部门路径")
private String pathTrace;

27
mailbox-common/src/main/java/com/biutag/entity/system/PoliceDepart.java

@ -0,0 +1,27 @@
package com.biutag.entity.system;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("警员部门关联表")
public class PoliceDepart implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value="id", type= IdType.AUTO)
@ApiModelProperty("ID")
private Integer id;
@ApiModelProperty("警号")
private String empNo;
@ApiModelProperty("部门id")
private String departId;
}

27
mailbox-common/src/main/java/com/biutag/entity/system/PolicePosition.java

@ -0,0 +1,27 @@
package com.biutag.entity.system;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("警员角色关联表")
public class PolicePosition implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value="id", type= IdType.AUTO)
@ApiModelProperty("ID")
private Integer id;
@ApiModelProperty("警号")
private String empNo;
@ApiModelProperty("岗位id")
private String positionId;
}

27
mailbox-common/src/main/java/com/biutag/entity/system/PoliceRole.java

@ -0,0 +1,27 @@
package com.biutag.entity.system;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("警员角色关联表")
public class PoliceRole implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value="id", type= IdType.AUTO)
@ApiModelProperty("ID")
private Integer id;
@ApiModelProperty("警号")
private String empNo;
@ApiModelProperty("角色id")
private String roleId;
}

1
mailbox-common/src/main/java/com/biutag/enums/ErrorEnum.java

@ -17,6 +17,7 @@ public enum ErrorEnum {
CAPTCHA_ERROR(334, "验证码错误"),
PAYMENT_ERROR(335, "发起支付失败"),
UNAUTHORIZED(401, "unAuthorized"),
NO_PERMISSION(403, "无相关权限"),
REQUEST_404_ERROR(404, "请求接口不存在"),

8
mailbox-common/src/main/java/com/biutag/exception/AuthException.java

@ -0,0 +1,8 @@
package com.biutag.exception;
/**
* @author wxc
* @date 2024/1/9
*/
public class AuthException extends RuntimeException {
}

4
mailbox-common/src/main/java/com/biutag/exception/BusinessException.java

@ -5,4 +5,8 @@ public class BusinessException extends RuntimeException {
public BusinessException(String message) {
super(message);
}
public BusinessException(Throwable cause) {
super(cause);
}
}

33
mailbox-common/src/main/java/com/biutag/exception/GlobalException.java

@ -47,7 +47,7 @@ public class GlobalException {
@ResponseStatus(HttpStatus.OK)
@ExceptionHandler(NoHandlerFoundException.class)
@ResponseBody
public AjaxResult<Object> handleNoHandlerFoundException(NoHandlerFoundException e){
public AjaxResult<Object> handleNoHandlerFoundException(NoHandlerFoundException e) {
return AjaxResult.failed(ErrorEnum.REQUEST_404_ERROR.getCode(), e.getMessage());
}
@ -72,7 +72,7 @@ public class GlobalException {
public AjaxResult<Object> handleBindException(BindException e) {
BindingResult bindingResult = e.getBindingResult();
Integer code = ErrorEnum.PARAMS_VALID_ERROR.getCode();
String msg = Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage();
String msg = Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage();
return AjaxResult.failed(code, msg);
}
@ -84,7 +84,7 @@ public class GlobalException {
@ResponseBody
public AjaxResult<Object> handlePathException(MissingServletRequestParameterException e) {
Integer code = ErrorEnum.PARAMS_VALID_ERROR.getCode();
String msg = Objects.requireNonNull(e.getMessage());
String msg = Objects.requireNonNull(e.getMessage());
return AjaxResult.failed(code, msg);
}
@ -97,7 +97,7 @@ public class GlobalException {
public AjaxResult<Object> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
BindingResult bindingResult = e.getBindingResult();
Integer code = ErrorEnum.PARAMS_VALID_ERROR.getCode();
String msg = Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage();
String msg = Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage();
return AjaxResult.failed(code, msg);
}
@ -109,7 +109,7 @@ public class GlobalException {
@ResponseBody
public AjaxResult<Object> handleHttpMessageNotReadableException(HttpMessageNotReadableException e) {
Integer code = ErrorEnum.PARAMS_TYPE_ERROR.getCode();
String msg = Objects.requireNonNull(e.getMessage());
String msg = Objects.requireNonNull(e.getMessage());
return AjaxResult.failed(code, msg.split(";")[0]);
}
@ -121,7 +121,7 @@ public class GlobalException {
@ResponseBody
public AjaxResult<Object> handleRequestMethodException(HttpRequestMethodNotSupportedException e) {
Integer code = ErrorEnum.REQUEST_METHOD_ERROR.getCode();
String msg = Objects.requireNonNull(e.getMessage());
String msg = Objects.requireNonNull(e.getMessage());
return AjaxResult.failed(code, msg);
}
@ -133,7 +133,8 @@ public class GlobalException {
@ResponseBody
public AjaxResult<Object> handleIllegalArgumentException(IllegalArgumentException e) {
Integer code = ErrorEnum.ASSERT_ARGUMENT_ERROR.getCode();
String msg = Objects.requireNonNull(e.getMessage());
String msg = Objects.requireNonNull(e.getMessage());
log.error(e.getMessage(), e);
return AjaxResult.failed(code, msg);
}
@ -145,8 +146,24 @@ public class GlobalException {
@ResponseBody
public AjaxResult<Object> handleMybatisPlusException(MybatisPlusException e) {
Integer code = ErrorEnum.ASSERT_MYBATIS_ERROR.getCode();
String msg = Objects.requireNonNull(e.getMessage());
String msg = Objects.requireNonNull(e.getMessage());
return AjaxResult.failed(code, msg);
}
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(MinioOperateException.class)
@ResponseBody
public AjaxResult<Object> handleMinioOperateException(MinioOperateException e) {
Integer code = ErrorEnum.SYSTEM_ERROR.getCode();
return AjaxResult.failed(code, String.format("Minio 操作异常:%s", e.getMessage()));
}
@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ExceptionHandler(AuthException.class)
@ResponseBody
public AjaxResult<Object> handleAuthException(AuthException e) {
Integer code = ErrorEnum.UNAUTHORIZED.getCode();
return AjaxResult.failed(code, "unauthorized");
}
}

15
mailbox-common/src/main/java/com/biutag/mapper/system/PoliceDepartMapper.java

@ -0,0 +1,15 @@
package com.biutag.mapper.system;
import com.biutag.core.basics.IBaseMapper;
import com.biutag.entity.system.PoliceDepart;
import com.biutag.entity.system.PolicePosition;
import org.apache.ibatis.annotations.Mapper;
/**
* 系统岗位Mapper
*/
@Mapper
public interface PoliceDepartMapper extends IBaseMapper<PoliceDepart> {
}

18
mailbox-common/src/main/java/com/biutag/mapper/system/PolicePositionMapper.java

@ -0,0 +1,18 @@
package com.biutag.mapper.system;
import com.biutag.core.basics.IBaseMapper;
import com.biutag.entity.system.Dept;
import com.biutag.entity.system.PolicePosition;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 系统岗位Mapper
*/
@Mapper
public interface PolicePositionMapper extends IBaseMapper<PolicePosition> {
}

15
mailbox-common/src/main/java/com/biutag/mapper/system/PoliceRoleMapper.java

@ -0,0 +1,15 @@
package com.biutag.mapper.system;
import com.biutag.core.basics.IBaseMapper;
import com.biutag.entity.system.PoliceDepart;
import com.biutag.entity.system.PoliceRole;
import org.apache.ibatis.annotations.Mapper;
/**
* 系统岗位Mapper
*/
@Mapper
public interface PoliceRoleMapper extends IBaseMapper<PoliceRole> {
}

18
mailbox-common/src/main/java/com/biutag/util/IOUtil.java

@ -0,0 +1,18 @@
package com.biutag.util;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Base64;
public class IOUtil {
/**
* 将base64 stream
* @param base64
* @return
*/
public static InputStream base64ToStream(String base64) {
byte[] decodedBytes = Base64.getDecoder().decode(base64);
return new ByteArrayInputStream(decodedBytes);
}
}

46
mailbox-common/src/main/java/com/biutag/util/MinioUtil.java

@ -1,46 +0,0 @@
package com.biutag.util;
import com.biutag.exception.MinioOperateException;
import io.minio.BucketExistsArgs;
import io.minio.MakeBucketArgs;
import io.minio.MinioClient;
import io.minio.UploadObjectArgs;
import io.minio.errors.MinioException;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
public class MinioUtil {
public static void main(String[] args) {
// 设置MinIO服务器的端点、Access Key和Secret Key
String endpoint = "http://172.31.217.20:31813";
String accessKey = "your-access-key";
String secretKey = "your-secret-key";
try {
// 创建MinIO客户端
MinioClient minioClient = MinioClient.builder()
.endpoint(endpoint)
.credentials(accessKey, secretKey)
.build();
// 检查存储桶是否存在,如果不存在则创建
String bucketName = "mailbox";
BucketExistsArgs bucketExistsArgs = BucketExistsArgs.builder()
.bucket(bucketName)
// 添加额外的选项
.build();
if (!minioClient.bucketExists(bucketExistsArgs)) {
MakeBucketArgs makeBucketArgs = MakeBucketArgs.builder().bucket(bucketName).build();
minioClient.makeBucket(makeBucketArgs);
}
// 上传文件到MinIO服务器
String objectName = "your-object-name";
String filePath = "path/to/your/file.txt";
UploadObjectArgs uploadObjectArgs = UploadObjectArgs.builder().bucket(bucketName).object(objectName).filename(filePath).build();
minioClient.uploadObject(uploadObjectArgs);
} catch (MinioException | IOException | NoSuchAlgorithmException | InvalidKeyException e) {
throw new MinioOperateException(e.getCause());
}
}
}

22
mailbox-common/src/main/java/com/biutag/validator/IdCardValidator.java

@ -0,0 +1,22 @@
package com.biutag.validator;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.PhoneUtil;
import com.biutag.validator.annotation.IdCard;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class IdCardValidator implements ConstraintValidator<IdCard, String> {
@Override
public void initialize(IdCard constraintAnnotation) {
ConstraintValidator.super.initialize(constraintAnnotation);
}
@Override
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
return IdcardUtil.isValidCard(value);
}
}

22
mailbox-common/src/main/java/com/biutag/validator/PhoneValidator.java

@ -0,0 +1,22 @@
package com.biutag.validator;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.PhoneUtil;
import com.biutag.validator.annotation.IdCard;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class PhoneValidator implements ConstraintValidator<IdCard, String> {
@Override
public void initialize(IdCard constraintAnnotation) {
ConstraintValidator.super.initialize(constraintAnnotation);
}
@Override
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
return PhoneUtil.isPhone(value);
}
}

21
mailbox-common/src/main/java/com/biutag/validator/annotation/IdCard.java

@ -0,0 +1,21 @@
package com.biutag.validator.annotation;
import com.biutag.validator.IdCardValidator;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
@Documented
@Constraint(validatedBy = IdCardValidator.class)
@Target({ ElementType.PARAMETER,ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
public @interface IdCard {
String message() default "证件非法";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default { };
}

21
mailbox-common/src/main/java/com/biutag/validator/annotation/Phone.java

@ -0,0 +1,21 @@
package com.biutag.validator.annotation;
import com.biutag.validator.PhoneValidator;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
@Documented
@Constraint(validatedBy = PhoneValidator.class)
@Target({ ElementType.PARAMETER,ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
public @interface Phone {
String message() default "手机号码错误";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default { };
}

1
mailbox-common/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@ -0,0 +1 @@
com.biutag.exception.GlobalException

82
mailbox-lan/src/main/java/com/biutag/lan/service/IPoliceUserService.java

@ -21,79 +21,131 @@ public interface IPoliceUserService {
/**
* 当前管理员
*
* @author
* @return SystemSelfVo
* @author
*/
PoliceUserSelvesVo self(Integer adminId);
/**
* 管理员详情
*
* @author
* @param id 主键参数
* @return PoliceUserDetailVo
* @author
*/
PoliceUserDetailVo detail(Integer id);
/**
* 管理员列表
*
* @author
* @param pageValidate 分页参数
* @param pageValidate 分页参数
* @param searchValidate 搜索参数
* @return PageResult<PoliceUserListedVo>
* @author
*/
PageResult<PoliceUserListedVo> list(PageValidate pageValidate, PoliceUserSearchValidate searchValidate);
List<PoliceUser> all(PoliceUserSearchValidate searchValidate);
List<PoliceUser> searchPoliceUserList(String searchName);
List<PoliceUser> searchPoliceUserList(String searchName);
/**
* 管理员新增
*
* @author
* @param createValidate 参数
* @author
*/
void add(PoliceUserCreateValidate createValidate);
/**
* 管理员编辑
*
* @author
* @param updateValidate 参数
* @param adminId 管理员ID
* @param adminId 管理员ID
* @author
*/
void edit(PoliceUserUpdateValidate updateValidate, Integer adminId);
/**
* 当前管理员更新
*
* @author
* @param upInfoValidate 参数
* @param adminId 管理员ID
* @param adminId 管理员ID
* @author
*/
void upInfo(PoliceUserUpInfoValidate upInfoValidate, Integer adminId);
/**
* 管理员删除
*
* @author
* @param id 主键参数
* @param id 主键参数
* @param adminId 管理员ID
* @author
*/
void del(Integer id, Integer adminId);
/**
* 管理员状态切换
*
* @author
* @param id 主键参数
* @author
*/
void disable(Integer id, Integer adminId);
/**
* 批量写入警员部门关联表
*
* @param empNo 警警号
* @param departIds 部门ID组
* @author
*/
void batchSaveDepartByEmpNo(String empNo, List<Integer> departIds);
/**
* 批量写入警员岗位关联表
*
* @param empNo 警警号
* @param positionIds 部门ID组
* @author
*/
void batchSavePositionByEmpNo(String empNo, List<Integer> positionIds);
/**
* 批量写入警员角色关联表
*
* @param empNo 警警号
* @param roleIds 角色组
* @author
*/
void batchSaveRoleByEmpNo(String empNo, List<Integer> roleIds);
/**
* 根据角色ID批量删除角色
*
* @param empNo 角色ID
* @author
*/
void batchDeletePositionsByEmpNo(String empNo);
/**
* 根据角色ID批量删除角色
*
* @param empNo 角色ID
* @author
*/
void batchDeleteDepartByEmpNo(String empNo);
/**
* 根据角色ID批量删除角色
*
* @param empNo 角色ID
* @author
*/
void batchDeleteRoleByEmpNo(String empNo);
}

92
mailbox-lan/src/main/java/com/biutag/lan/service/impl/DeptServiceImpl.java

@ -3,6 +3,8 @@ package com.biutag.lan.service.impl;
import com.alibaba.fastjson2.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.biutag.constants.AppConstants;
import com.biutag.entity.setting.DictData;
import com.biutag.lan.service.IDeptService;
import com.biutag.lan.validate.system.DeptCreateValidate;
import com.biutag.lan.validate.system.DeptSearchValidate;
@ -10,10 +12,13 @@ import com.biutag.lan.validate.system.DeptUpdateValidate;
import com.biutag.lan.vo.system.DeptVo;
import com.biutag.entity.system.PoliceUser;
import com.biutag.entity.system.Dept;
import com.biutag.mapper.setting.DictDataMapper;
import com.biutag.mapper.system.PoliceUserMapper;
import com.biutag.mapper.system.DeptMapper;
import com.biutag.util.ListUtils;
import com.biutag.util.StringUtils;
import com.biutag.util.TimeUtils;
import com.biutag.util.ToolUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@ -32,6 +37,11 @@ class DeptServiceImpl implements IDeptService {
@Resource
PoliceUserMapper policeUserMapper;
@Resource
DictDataMapper dictDataMapper;
/**
* 岗位所有
*
@ -46,12 +56,12 @@ class DeptServiceImpl implements IDeptService {
.orderByDesc((Arrays.asList("sort", "id"))));
List<DeptVo> list = new ArrayList<>();
for (Dept Dept : DeptList) {
for (Dept dept : DeptList) {
DeptVo vo = new DeptVo();
BeanUtils.copyProperties(Dept, vo);
BeanUtils.copyProperties(dept, vo);
vo.setUpdateTime(TimeUtils.timestampToDate(Dept.getUpdateTime()));
vo.setCreateTime(TimeUtils.timestampToDate(Dept.getCreateTime()));
vo.setUpdateTime(TimeUtils.timestampToDate(dept.getUpdateTime()));
vo.setCreateTime(TimeUtils.timestampToDate(dept.getCreateTime()));
list.add(vo);
}
@ -80,14 +90,21 @@ class DeptServiceImpl implements IDeptService {
});
List<Dept> DeptList = deptMapper.selectList(queryWrapper);
List<DictData> dictDataList = dictDataMapper.selectList(new QueryWrapper<DictData>()
.select("id,type_id,name,value,remark,sort,status,create_time,update_time")
.eq("type_id", AppConstants.DEPT_TYPE_CATEGORY)//机构类型
.eq("is_delete", 0).orderByDesc("sort"));
List<DeptVo> list = new LinkedList<>();
for (Dept Dept : DeptList) {
for (Dept dept : DeptList) {
DeptVo vo = new DeptVo();
BeanUtils.copyProperties(Dept, vo);
vo.setCreateTime(TimeUtils.timestampToDate(Dept.getCreateTime()));
vo.setUpdateTime(TimeUtils.timestampToDate(Dept.getUpdateTime()));
BeanUtils.copyProperties(dept, vo);
if(StringUtils.isNotEmpty(dept.getCategory()) ){
vo.setCategoryName(dictDataList.stream().filter(entity ->
entity.getValue().equals(dept.getCategory())).findFirst().get().getName()); ;
}
vo.setCreateTime(TimeUtils.timestampToDate(dept.getCreateTime()));
vo.setUpdateTime(TimeUtils.timestampToDate(dept.getUpdateTime()));
list.add(vo);
}
@ -104,7 +121,7 @@ class DeptServiceImpl implements IDeptService {
*/
@Override
public DeptVo detail(Integer id) {
Dept Dept = deptMapper.selectOne(
Dept dept = deptMapper.selectOne(
new QueryWrapper<Dept>()
.select(Dept.class, info ->
!info.getColumn().equals("is_delete") &&
@ -113,12 +130,12 @@ class DeptServiceImpl implements IDeptService {
.eq("is_delete", 0)
.last("limit 1"));
Assert.notNull(Dept, "部门已不存在!");
Assert.notNull(dept, "部门已不存在!");
DeptVo vo = new DeptVo();
BeanUtils.copyProperties(Dept, vo);
vo.setCreateTime(TimeUtils.timestampToDate(Dept.getCreateTime()));
vo.setUpdateTime(TimeUtils.timestampToDate(Dept.getUpdateTime()));
BeanUtils.copyProperties(dept, vo);
vo.setCreateTime(TimeUtils.timestampToDate(dept.getCreateTime()));
vo.setUpdateTime(TimeUtils.timestampToDate(dept.getUpdateTime()));
return vo;
}
@ -141,17 +158,41 @@ class DeptServiceImpl implements IDeptService {
Assert.isNull(Dept, "顶级部门只允许有一个");
}
Dept pDept = deptMapper.selectOne(
new QueryWrapper<Dept>()
.select("id,pid,name,level,path_trace")
.eq("id", createValidate.getPid())
.eq("is_delete", 0)
.last("limit 1"));
Assert.notNull(pDept, "上级部门不存在");
Dept model = new Dept();
model.setPid(createValidate.getPid());
model.setName(createValidate.getName());
model.setDuty(createValidate.getDuty());
model.setLevel(pDept.getLevel()+1);
String uuid=ToolUtils.makeUUID();
model.setUuid(uuid);
model.setMobile(createValidate.getMobile());
model.setCategory(createValidate.getCategory());
model.setSort(createValidate.getSort());
model.setIsStop(createValidate.getIsStop());
model.setCreateTime(System.currentTimeMillis() / 1000);
model.setUpdateTime(System.currentTimeMillis() / 1000);
if(model.getLevel()>=2){
model.setFullName(pDept.getName()+createValidate.getName());
}else {
model.setFullName(createValidate.getName());
}
deptMapper.insert(model);
Dept insertDept = deptMapper.selectOne(
new QueryWrapper<Dept>()
.select(Dept.class, info ->
!info.getColumn().equals("is_delete") &&
!info.getColumn().equals("delete_time"))
.eq("uuid",uuid)
.eq("is_delete", 0)
.last("limit 1"));
insertDept.setPathTrace(pDept.getPathTrace()+","+insertDept.getId());
deptMapper.updateById(insertDept);
}
/**
@ -172,12 +213,25 @@ class DeptServiceImpl implements IDeptService {
.last("limit 1"));
Assert.notNull(model, "部门不存在");
Dept pDept = deptMapper.selectOne(
new QueryWrapper<Dept>()
.select("id,pid,name,level,path_trace")
.eq("id", updateValidate.getPid())
.eq("is_delete", 0)
.last("limit 1"));
Assert.notNull(pDept, "上级部门不存在");
Assert.isFalse((model.getPid().equals(0) && updateValidate.getPid()>0), "顶级部门不能修改上级");
Assert.isFalse(updateValidate.getId().equals(updateValidate.getPid()), "上级部门不能是自己");
model.setLevel(pDept.getLevel()+1);
if(model.getLevel()>=2){
model.setFullName(pDept.getName()+updateValidate.getName());
}else {
model.setFullName(updateValidate.getName());
}
model.setPathTrace(pDept.getPathTrace()+","+updateValidate.getId());
model.setPid(updateValidate.getPid());
model.setName(updateValidate.getName());
model.setDuty(updateValidate.getDuty());
model.setCategory(updateValidate.getCategory());
model.setMobile(updateValidate.getMobile());
model.setSort(updateValidate.getSort());
model.setIsStop(updateValidate.getIsStop());
@ -214,7 +268,7 @@ class DeptServiceImpl implements IDeptService {
PoliceUser PoliceUser = policeUserMapper.selectOne(new QueryWrapper<PoliceUser>()
.select("id,nickname")
.eq("dept_id", id)
.eq("dept_ids", id)
.eq("is_delete", 0)
.last("limit 1"));

4
mailbox-lan/src/main/java/com/biutag/lan/service/impl/DutyServiceImpl.java

@ -3,6 +3,7 @@ package com.biutag.lan.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.constants.AppConstants;
import com.biutag.entity.setting.DictData;
import com.biutag.entity.system.Dept;
import com.biutag.entity.system.PoliceUser;
@ -131,8 +132,9 @@ public class DutyServiceImpl implements IDutyService {
model.setEmpNo(createValidate.getEmpNo());
DictData dictData = dictDataMapper.selectOne(new QueryWrapper<DictData>()
.select("id,type_id,name,value,remark,sort,status,create_time,update_time")
.eq("type_id", "6")//机构类型
.eq("type_id", AppConstants.DEPT_TYPE_CATEGORY)//机构类型
.eq("is_delete", 0)
.eq("value",createValidate.getDeptType())
.last("limit 1"));
Assert.notNull(dictData, "机构类型不存在");

24
mailbox-lan/src/main/java/com/biutag/lan/service/impl/IndexServiceImpl.java

@ -25,34 +25,20 @@ public class IndexServiceImpl implements IIndexService {
// 版本信息
Map<String, Object> version = new LinkedHashMap<>();
version.put("name", ConfigUtils.get("website", "name", "oumyye-Java"));
version.put("version", GlobalConfig.version);
version.put("website", "www.oumyye.cn");
version.put("based", "Vue3.x、ElementUI、MySQL");
Map<String, String> channel = new LinkedHashMap<>();
channel.put("gitee", "https://gitee.com/oumyye/oumyye_java");
channel.put("website", "https://www.oumyye.cn");
version.put("channel", channel);
console.put("version", version);
// 今日数据
Map<String, Object> today = new LinkedHashMap<>();
today.put("time", "2022-08-11 15:08:29");
today.put("todayVisits", 10); // 访问量(人)
today.put("totalVisits", 100); // 总访问量
today.put("todaySales", 30); // 销售额(元)
today.put("totalSales", 65); // 总销售额
today.put("todayOrder", 12); // 订单量(笔)
today.put("totalOrder", 255); // 总订单量
today.put("todayUsers", 120); // 新增用户
today.put("totalUsers", 360); // 总访用户
console.put("today", today);
// 访客图表
Map<String, Object> visitor = new LinkedHashMap<>();
visitor.put("date", TimeUtils.daysAgoDate(15));
visitor.put("list", Arrays.asList(12,13,11,5,8,22,14,9,456,62,78,12,18,22,46));
console.put("visitor", visitor);
return console;
}
@ -79,10 +65,10 @@ public class IndexServiceImpl implements IIndexService {
map.put("ossDomain", UrlUtils.domain());
map.put("copyright", ListUtils.stringToListAsMapStr(copyright));
map.put("webName", "局长信箱后台管理");
map.put("webLogo", "http://localhost:8082/api/static/backend_logo.png");
map.put("webFavicon", "http://localhost:8082/api/static/backend_favicon.ico");
map.put("webLogo", "");
/* map.put("webFavicon", "http://localhost:8082/api/static/backend_favicon.ico");
map.put("webBackdrop", "http://localhost:8082/api/static/backend_backdrop.png");
map.put("ossDomain", "http://localhost:8080/");
map.put("ossDomain", "http://localhost:8080/");*/
// "webName": "oumyye开源后台",
// "webLogo": ,

93
mailbox-lan/src/main/java/com/biutag/lan/service/impl/PoliceUserServiceImpl.java

@ -45,6 +45,14 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
@Resource
RoleMapper roleMapper;
@Resource
PolicePositionMapper policePositionMapper;
@Resource
PoliceDepartMapper policeDepartMapper;
@Resource
PoliceRoleMapper policeRoleMapper;
@Resource
IPermService iPermService;
@ -303,12 +311,12 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
*/
@Override
public void add(PoliceUserCreateValidate createValidate) {
String[] field = {"id", "username", "nickname"};
String[] field = {"id", "emp_no","username", "id_code"};
Assert.isNull(policeUserMapper.selectOne(new QueryWrapper<PoliceUser>()
.select(field)
.eq("is_delete", 0)
.eq("emp_no", createValidate.getEmpNo())
.last("limit 1")), "号已存在换一个吧!");
.last("limit 1")), "号已存在换一个吧!");
Assert.isNull(policeUserMapper.selectOne(new QueryWrapper<PoliceUser>()
.select(field)
@ -326,8 +334,11 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
PoliceUser model = new PoliceUser();
model.setRoleIds(ListUtils.listToStringByInt(createValidate.getRoleIds(), ","));
this.batchSaveRoleByEmpNo(createValidate.getEmpNo(),createValidate.getRoleIds());
model.setDeptIds(ListUtils.listToStringByInt(createValidate.getDeptIds(), ","));
this.batchSaveDepartByEmpNo(createValidate.getEmpNo(),createValidate.getDeptIds());
model.setPostIds(ListUtils.listToStringByInt(createValidate.getPostIds(), ","));
this.batchSavePositionByEmpNo(createValidate.getEmpNo(),createValidate.getPostIds());
model.setEmpNo(createValidate.getEmpNo());
model.setName(createValidate.getName());
model.setAvatar(avatar);
@ -356,19 +367,14 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
throw new OperateException("您无权限编辑系统管理员!");
}
String[] field = {"id", "name", "emp_no"};
String[] field = {"id", "id_code", "emp_no, role_ids, post_ids, dept_ids"};
Assert.notNull(policeUserMapper.selectOne(new QueryWrapper<PoliceUser>()
.select(field)
.eq("id", updateValidate.getId())
.eq("is_delete", 0)
.last("limit 1")), "账号不存在了!");
Assert.isNull(policeUserMapper.selectOne(new QueryWrapper<PoliceUser>()
.select(field)
.eq("is_delete", 0)
.eq("emp_no", updateValidate.getEmpNo())
.ne("id", updateValidate.getId())
.last("limit 1")), "警号已存在换一个吧!");
Assert.isNull(policeUserMapper.selectOne(new QueryWrapper<PoliceUser>()
.select(field)
@ -376,17 +382,33 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
.eq("id_code", updateValidate.getIdCode())
.ne("id", updateValidate.getId())
.last("limit 1")), "身份证已存在换一个吧!");
PoliceUser policeUser =policeUserMapper.selectOne(new QueryWrapper<PoliceUser>()
.select(field)
.eq("is_delete", 0)
.eq("emp_no", updateValidate.getEmpNo())
.eq("id", updateValidate.getId())
.last("limit 1"));
Assert.notNull(policeUser, "警号已存在换一个吧!");
PoliceUser model = new PoliceUser();
model.setId(updateValidate.getId());
if(StringUtils.isNotNull(updateValidate.getRoleIds())) {
model.setRoleIds(ListUtils.listToStringByInt(updateValidate.getRoleIds(), ","));
if(!policeUser.getRoleIds().equals(model.getRoleIds())){
this.batchSaveRoleByEmpNo(updateValidate.getEmpNo(),updateValidate.getRoleIds());
}
}
if(StringUtils.isNotNull(updateValidate.getDeptIds())) {
model.setDeptIds(ListUtils.listToStringByInt(updateValidate.getDeptIds(), ","));
if(!policeUser.getDeptIds().equals(model.getDeptIds())){
this.batchSaveDepartByEmpNo(updateValidate.getEmpNo(),updateValidate.getDeptIds());
}
}
if(StringUtils.isNotNull(updateValidate.getPostIds())) {
model.setPostIds(ListUtils.listToStringByInt(updateValidate.getPostIds(), ","));
if(!policeUser.getPostIds().equals(model.getPostIds())){
this.batchSavePositionByEmpNo(updateValidate.getEmpNo(),updateValidate.getPostIds());
}
}
model.setName(updateValidate.getName());
@ -509,4 +531,55 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
}
}
@Override
public void batchSaveDepartByEmpNo(String empNo, List<Integer> departIds) {
this.batchDeleteDepartByEmpNo(empNo);
for (Integer departId : departIds) {
PoliceDepart model = new PoliceDepart();
model.setEmpNo(empNo);
model.setDepartId(departId.toString());
policeDepartMapper.insert(model);
}
}
@Override
public void batchSavePositionByEmpNo(String empNo, List<Integer> positionIds) {
this.batchDeletePositionsByEmpNo(empNo);
for (Integer positionId : positionIds) {
PolicePosition model = new PolicePosition();
model.setEmpNo(empNo);
model.setPositionId(positionId.toString());
policePositionMapper.insert(model);
}
}
@Override
public void batchSaveRoleByEmpNo(String empNo, List<Integer> roleIds) {
this.batchDeleteRoleByEmpNo(empNo);
for (Integer roleId : roleIds) {
PoliceRole model = new PoliceRole();
model.setEmpNo(empNo);
model.setRoleId(roleId.toString());
policeRoleMapper.insert(model);
}
}
@Override
public void batchDeletePositionsByEmpNo(String empNo) {
policePositionMapper.delete(new QueryWrapper<PolicePosition>().eq("emp_no", empNo));
}
@Override
public void batchDeleteDepartByEmpNo(String empNo) {
policeDepartMapper.delete(new QueryWrapper<PoliceDepart>().eq("emp_no", empNo));
}
@Override
public void batchDeleteRoleByEmpNo(String empNo) {
policeRoleMapper.delete(new QueryWrapper<PoliceRole>().eq("emp_no", empNo));
}
}

5
mailbox-lan/src/main/java/com/biutag/lan/validate/system/DeptCreateValidate.java

@ -28,8 +28,9 @@ public class DeptCreateValidate implements Serializable {
@ApiModelProperty(value = "部门名称", required = true)
private String name;
@Length(min = 1, max = 30, message = "负责人名称必须在1~30个字符内")
private String duty = "";
@NotNull(message = "请选择状态")
@ApiModelProperty(value = "类别", required = true)
private String category;
@Length(min = 11, max = 11, message = "手机号只能为11位")
@Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "手机号格式有误")

5
mailbox-lan/src/main/java/com/biutag/lan/validate/system/DeptUpdateValidate.java

@ -33,8 +33,9 @@ public class DeptUpdateValidate implements Serializable {
@ApiModelProperty(value = "部门名称")
private String name;
@Length(min = 1, max = 30, message = "负责人名称必须在1~30个字符内")
private String duty = "";
@NotNull(message = "请选择状态")
@ApiModelProperty(value = "类别", required = true)
private String category;
@Length(min = 11, max = 11, message = "手机号只能为11位")
@Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "手机号格式有误")

2
mailbox-lan/src/main/java/com/biutag/lan/validate/system/PoliceUserCreateValidate.java

@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
@ -32,6 +33,7 @@ public class PoliceUserCreateValidate implements Serializable {
@NotEmpty(message = "手机号不能为空")
@Length(min = 2, max = 30, message = "手机号必须在2~30个字符内")
@Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "手机号格式有误")
@ApiModelProperty(value = "手机号", required = true)
private String mobile;

7
mailbox-lan/src/main/java/com/biutag/lan/vo/system/DeptVo.java

@ -24,8 +24,8 @@ public class DeptVo implements Serializable {
@ApiModelProperty(value = "部门全称")
private String fullName;
@ApiModelProperty(value = "负责人")
private String duty;
@ApiModelProperty(value = "随机id")
private String uuid;
@ApiModelProperty(value = "联系电话")
private String mobile;
@ -35,6 +35,9 @@ public class DeptVo implements Serializable {
@ApiModelProperty("类别")
private String category;
@ApiModelProperty("类别名称")
private String categoryName;
@ApiModelProperty("层级")
private String level;

49
mailbox-outer/pom.xml

@ -60,7 +60,7 @@
</dependency>
<dependency>
<groupId>${groupId}</groupId>
<groupId>com.biutag</groupId>
<artifactId>mailbox-common</artifactId>
</dependency>
<dependency>
@ -68,6 +68,53 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>3.1.8</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>alibabacloud-dysmsapi20170525</artifactId>
<version>2.0.24</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>15</source>
<target>15</target>
</configuration>
</plugin>
</plugins>
<finalName>mailbox-outer</finalName>
</build>
</project>

41
mailbox-outer/src/main/java/com/biutag/outer/config/InterceptorConfig.java

@ -0,0 +1,41 @@
package com.biutag.outer.config;
import cn.hutool.core.util.StrUtil;
import com.biutag.exception.AuthException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author wxc
* @date 2024/1/8
*/
@Slf4j
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new AuthInterceptor()).addPathPatterns("/**").excludePathPatterns("/auth", "/auth/openid", "/auth/wx/faceAuth", "/file/stream/**");
}
static class AuthInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
log.info("请求地址:{}", request.getRequestURI());
String authorization = request.getHeader("Authorization");
if (StrUtil.isBlank(authorization)) {
throw new AuthException();
}
System.out.println(authorization);
return true;
}
}
}

89
mailbox-outer/src/main/java/com/biutag/outer/config/Minio.java

@ -0,0 +1,89 @@
package com.biutag.outer.config;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.biutag.exception.MinioOperateException;
import com.biutag.util.IOUtil;
import io.minio.*;
import io.minio.errors.*;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLDecoder;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.Optional;
@Component
public class Minio {
private final MinioClient minioClient;
public final MinioProperties properties;
public Minio(MinioProperties properties) {
this.properties = properties;
// 创建MinIO客户端
this.minioClient = MinioClient.builder()
.endpoint(properties.getEndpoint())
.credentials(properties.getAccessKey(), properties.getSecretKey())
.build();
BucketExistsArgs bucketExistsArgs = BucketExistsArgs.builder()
.bucket(properties.getBucketName())
.build();
try {
if (!minioClient.bucketExists(bucketExistsArgs)) {
MakeBucketArgs makeBucketArgs = MakeBucketArgs.builder().bucket(properties.getBucketName()).build();
minioClient.makeBucket(makeBucketArgs);
}
} catch (IOException | ServerException | InsufficientDataException | ErrorResponseException | NoSuchAlgorithmException |
InvalidKeyException | InvalidResponseException | XmlParserException | InternalException e) {
throw new MinioOperateException(e);
}
}
public String upload(InputStream is, String originName) {
try {
String filepath = DateUtil.format(new Date(), "YYMMdd") + "/" + IdUtil.nanoId(8) +
Optional.ofNullable(originName).map(item -> "_" + item).orElse("");
PutObjectArgs putObjectArgs = PutObjectArgs.builder()
.object(filepath)
.bucket(properties.getBucketName())
.stream(is, is.available(), -1).build();
minioClient.putObject(putObjectArgs);
return filepath;
} catch (IOException | ServerException | InsufficientDataException | ErrorResponseException | NoSuchAlgorithmException |
InvalidKeyException | InvalidResponseException | XmlParserException | InternalException e) {
throw new MinioOperateException(e);
}
}
public String upload(String base64) {
return upload(IOUtil.base64ToStream(base64), null);
}
public void get(String filepath, OutputStream os) {
try {
GetObjectArgs getObjectArgs = GetObjectArgs.builder()
.bucket(properties.getBucketName())
.object(URLDecoder.decode(filepath))
.build();
GetObjectResponse response = minioClient.getObject(getObjectArgs);
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = response.read(buffer, 0, buffer.length)) != -1) {
// 处理读取的数据,例如写入到其他流或进行其他操作
// 这里只是简单的打印数据
os.write(buffer, 0, bytesRead);
}
response.close();
os.close();
} catch (IOException | ServerException | InsufficientDataException | ErrorResponseException | NoSuchAlgorithmException |
InvalidKeyException | InvalidResponseException | XmlParserException | InternalException e) {
throw new MinioOperateException(e);
}
}
}

21
mailbox-outer/src/main/java/com/biutag/outer/config/MinioProperties.java

@ -0,0 +1,21 @@
package com.biutag.outer.config;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Setter
@Getter
@Configuration
@ConfigurationProperties(
prefix = "oss.minio"
)
public class MinioProperties {
private String endpoint;
private String accessKey;
private String secretKey;
private String bucketName;
}

23
mailbox-outer/src/main/java/com/biutag/outer/config/MybatisPlusConfig.java

@ -0,0 +1,23 @@
package com.biutag.outer.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MybatisPlusConfig {
/**
* 新增分页拦截器并设置数据库类型为mysql
* @return
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL));
return interceptor;
}
}

94
mailbox-outer/src/main/java/com/biutag/outer/controller/AuthController.java

@ -0,0 +1,94 @@
package com.biutag.outer.controller;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.biutag.core.AjaxResult;
import com.biutag.exception.AuthException;
import com.biutag.outer.domain.User;
import com.biutag.outer.domain.bo.FaceAuthBo;
import com.biutag.outer.service.FaceAuthService;
import com.biutag.outer.service.UserService;
import com.biutag.outer.util.TokenUtil;
import com.biutag.outer.util.UserHelper;
import com.biutag.outer.util.Weixin;
import com.biutag.outer.util.Weixin2;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.Date;
@Validated
@Slf4j
@RequiredArgsConstructor
@RequestMapping("auth")
@RestController
public class AuthController {
private final UserService userService;
private final FaceAuthService faceAuthService;
@PostMapping
public AjaxResult<JSONObject> code(@RequestParam String code) {
JSONObject result = Weixin.getAccessToken(code);
String openid = result.getString("openid");
if (StrUtil.isBlank(openid)) {
throw new AuthException();
}
User user = userService.getByOpenid(openid);
if (user == null) {
user = new User();
user.setOpenid(openid);
user.setCreateTime(LocalDateTime.now());
userService.save(user);
}
return AjaxResult.success(JSONObject.of("token", TokenUtil.set(user), "user", user));
}
@PostMapping("openid")
public AjaxResult<JSONObject> openid(@RequestParam String openid) {
User user = userService.getByOpenid(openid);
return AjaxResult.success(JSONObject.of("token", TokenUtil.set(user), "user", user));
}
@GetMapping("user")
public AjaxResult<User> user() {
return AjaxResult.success(UserHelper.getCurrentUser());
}
@GetMapping("realUser")
public AjaxResult<User> realUser(@RequestParam Integer userId) {
log.info("请求 realUser: {}", userId);
User user = userService.getById(userId);
if (StrUtil.isNotBlank(user.getIdCard())) {
log.info("用户信息:{}", JSON.toJSONString(user));
// 更新用户信息
UserHelper.update(user);
}
return AjaxResult.success(user);
}
@GetMapping("wx/sign")
public AjaxResult<JSONObject> sign(@RequestParam String url) {
String noncestr = IdUtil.nanoId(16);
String jsapiTicket = Weixin2.getTicket();
log.info("jsapiTicket: {}", jsapiTicket);
long timestamp = new Date().getTime() / 1000;
String sign = Weixin.sign(noncestr, jsapiTicket, timestamp, url);
JSONObject result = JSONObject.of("timestamp", timestamp, "nonceStr", noncestr, "signature", sign);
return AjaxResult.success(result);
}
@PostMapping("wx/faceAuth")
public AjaxResult<Boolean> faceAuth(@RequestBody @Valid FaceAuthBo faceAuth) {
log.info("人身认证结果:{}", JSON.toJSONString(faceAuth));
return AjaxResult.success(faceAuthService.save(faceAuth));
}
}

45
mailbox-outer/src/main/java/com/biutag/outer/controller/FileController.java

@ -0,0 +1,45 @@
package com.biutag.outer.controller;
import com.alibaba.fastjson2.JSONObject;
import com.biutag.core.AjaxResult;
import com.biutag.outer.config.Minio;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
@Slf4j
@RequiredArgsConstructor
@RequestMapping("file")
@Controller
public class FileController {
private final Minio minio;
@ResponseBody
@PostMapping("upload")
public AjaxResult<JSONObject> 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<JSONObject> upload(@RequestBody JSONObject file) {
log.info("文件上传 base64: {}", file.toJSONString());
String filepath = minio.upload(file.getString("base64"));
return AjaxResult.success(JSONObject.of("filepath", filepath));
}
@GetMapping("stream/**")
public void download(HttpServletRequest request, HttpServletResponse response) throws IOException {
String requestURI = request.getRequestURI();
minio.get(requestURI.substring("/file/stream/".length()), response.getOutputStream());
}
}

37
mailbox-outer/src/main/java/com/biutag/outer/controller/MailController.java

@ -1,14 +1,22 @@
package com.biutag.outer.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.core.AjaxResult;
import com.biutag.exception.BusinessException;
import com.biutag.outer.domain.Mail;
import com.biutag.outer.domain.bo.MailBo;
import com.biutag.outer.domain.bo.MailEvaluateBo;
import com.biutag.outer.domain.vo.MailVo;
import com.biutag.outer.service.MailService;
import com.biutag.outer.util.CodeUtil;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Validated
@RequiredArgsConstructor
@RequestMapping("mail")
@RestController
@ -17,7 +25,26 @@ public class MailController {
private final MailService mailService;
@GetMapping
public List<Mail> list() {
return mailService.list();
public AjaxResult<Page<MailVo>> list(Page<Mail> page) {
return AjaxResult.success(mailService.listByCurrentUserId(page));
}
@GetMapping("{id}")
public AjaxResult<MailVo> get(@PathVariable String id) {
return AjaxResult.success(MailVo.of(mailService.getById(id)));
}
@PostMapping
public AjaxResult<Boolean> add(@RequestBody @Valid MailBo mailBo) {
if (!mailBo.getCode().equals(CodeUtil.get(mailBo.getSmsRequestId()))) {
throw new BusinessException("验证码错误");
}
return AjaxResult.success(mailService.save(mailBo));
}
@PutMapping("evaluate")
public AjaxResult<Boolean> evaluate(@RequestBody MailEvaluateBo evaluateBo) {
return AjaxResult.success(mailService.evaluate(evaluateBo));
}
}

46
mailbox-outer/src/main/java/com/biutag/outer/controller/MailDraftController.java

@ -0,0 +1,46 @@
package com.biutag.outer.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.core.AjaxResult;
import com.biutag.outer.domain.MailDraft;
import com.biutag.outer.domain.bo.MailBo;
import com.biutag.outer.domain.vo.MailDraftVo;
import com.biutag.outer.service.MailDraftService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RequiredArgsConstructor
@RequestMapping("mail/draft")
@RestController
public class MailDraftController {
private final MailDraftService mailDraftService;
/**
* 存草稿
* @param mailBo
* @return
*/
@PostMapping
public AjaxResult<MailDraft> draft(@RequestBody MailBo mailBo) {
return AjaxResult.success(mailDraftService.save(mailBo));
}
@GetMapping
public AjaxResult<Page<MailDraftVo>> list(Page<MailDraft> page) {
return AjaxResult.success(mailDraftService.listByCurrentUserId(page));
}
@GetMapping("{id}")
public AjaxResult<MailDraftVo> get(@PathVariable String id) {
return AjaxResult.success(MailDraftVo.of(mailDraftService.getById(id)));
}
@DeleteMapping("{id}")
public AjaxResult<Boolean> del(@PathVariable String id) {
return AjaxResult.success(mailDraftService.removeById(id));
}
}

30
mailbox-outer/src/main/java/com/biutag/outer/controller/SmsController.java

@ -0,0 +1,30 @@
package com.biutag.outer.controller;
import com.alibaba.fastjson2.JSONObject;
import com.biutag.core.AjaxResult;
import com.biutag.outer.util.CodeUtil;
import com.biutag.outer.util.Sms;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Random;
@RequiredArgsConstructor
@RequestMapping("sms")
@RestController
public class SmsController {
private static final Random random = new Random();
@PostMapping("send")
public AjaxResult<JSONObject> sendCode(@RequestParam String phone) {
String code = String.valueOf(1000 + random.nextInt(9000));
// 发送短信
Sms.send(phone, code);
// 设置缓存
return AjaxResult.success(JSONObject.of("requestId", CodeUtil.set(code)));
}
}

32
mailbox-outer/src/main/java/com/biutag/outer/domain/FaceAuth.java

@ -0,0 +1,32 @@
package com.biutag.outer.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.Date;
@Setter
@Getter
public class FaceAuth {
@TableId(type = IdType.AUTO)
private Integer id;
private Integer userId;
private String realName;
private String idCard;
private String errMsg;
private Integer errCode;
private String verifyResult;
private LocalDateTime createTime;
}

15
mailbox-outer/src/main/java/com/biutag/outer/domain/Mail.java

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.Date;
@Setter
@ -56,21 +57,21 @@ public class Mail {
/**
* 创建时间
*/
private Date createTime;
private LocalDateTime createTime;
/**
* 更新时间
* 满意读
*/
private Date updateTime;
private String satisfaction;
/**
* 评价
* 涉及单位ID
*/
private String evaluate;
private Integer involvedDeptId;
/**
* 是否满意
* 涉及单位名称
*/
private String satisfiedFlag;
private String involvedDeptName;
}

71
mailbox-outer/src/main/java/com/biutag/outer/domain/MailDraft.java

@ -0,0 +1,71 @@
package com.biutag.outer.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.biutag.constants.Constants;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
@Setter
@Getter
public class MailDraft {
@TableId
private String id;
/**
* 联系人姓名
*/
private String contactName;
/**
* 联系人性别
*/
private String contactSex;
/**
* 联系人身份证号码
*/
private String contactIdCard;
/**
*
*/
private String contactPhone;
/**
* 案件编号
*/
private String caseNumber;
/**
* 内容
*/
private String content;
/**
* 附件
*/
private String attachments;
/**
* 用户ID
*/
private Integer userId;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
@TableLogic(value = Constants.UNDELETED, delval = Constants.DELETED)
private String delFlag;
}

26
mailbox-outer/src/main/java/com/biutag/outer/domain/MailEvaluate.java

@ -0,0 +1,26 @@
package com.biutag.outer.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.Date;
@Setter
@Getter
public class MailEvaluate {
@TableId(type = IdType.AUTO)
private Integer id;
private Integer userId;
private String mailId;
private String satisfaction;
private LocalDateTime createTime;
}

33
mailbox-outer/src/main/java/com/biutag/outer/domain/User.java

@ -0,0 +1,33 @@
package com.biutag.outer.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
@Setter
@Getter
@TableName("\"user\"")
public class User {
@TableId(type = IdType.AUTO)
private Integer id;
private String openid;
private String phone;
private String realName;
private String idCard;
private LocalDateTime createTime;
private LocalDateTime updateTime;
private LocalDateTime faceAuthTime;
}

41
mailbox-outer/src/main/java/com/biutag/outer/domain/bo/FaceAuthBo.java

@ -0,0 +1,41 @@
package com.biutag.outer.domain.bo;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson2.JSON;
import com.biutag.outer.domain.FaceAuth;
import com.biutag.outer.domain.Mail;
import com.biutag.validator.annotation.IdCard;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class FaceAuthBo {
@NotNull
private Integer userId;
@NotBlank
private String realName;
@IdCard
private String idCard;
@NotBlank
private String errMsg;
@NotNull
private Integer errCode;
@NotBlank
private String verifyResult;
public FaceAuth toEntity() {
FaceAuth faceAuth = new FaceAuth();
BeanUtil.copyProperties(this, faceAuth);
return faceAuth;
}
}

104
mailbox-outer/src/main/java/com/biutag/outer/domain/bo/MailBo.java

@ -0,0 +1,104 @@
package com.biutag.outer.domain.bo;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson2.JSON;
import com.biutag.outer.domain.Mail;
import com.biutag.outer.domain.MailDraft;
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 = "请输入联系人姓名")
private String contactName;
/**
* 联系人性别
*/
@NotBlank(message = "请选择联系人称呼")
private String contactSex;
/**
* 联系人身份证号码
*/
@IdCard
private String contactIdCard;
/**
*
*/
@Phone
private String contactPhone;
@NotBlank(message = "短信验证码不能为空")
@Length(max = 4)
private String code;
@NotBlank(message = "短信验证码错误或已失效")
private String smsRequestId;
/**
* 案件编号
*/
private String caseNumber;
/**
* 内容
*/
@Length(min= 10, max = 300, message = "信件内容不符合规范(不少于10字,不多于300字)")
@NotBlank(message = "请输入信件内容")
private String content;
/**
* 附件
*/
@Size(max = 20, message = "附件数量不能超过20")
private List<Attachment> attachments;
/**
* 涉及单位ID
*/
private Integer involvedDeptId;
/**
* 涉及单位名称
*/
private String involvedDeptName;
public Mail toEntity() {
Mail mail = new Mail();
BeanUtil.copyProperties(this, mail);
mail.setAttachments(JSON.toJSONString(attachments));
return mail;
}
public MailDraft toMailDraft() {
MailDraft mailDraft = new MailDraft();
BeanUtil.copyProperties(this, mailDraft);
mailDraft.setAttachments(JSON.toJSONString(attachments));
return mailDraft;
}
@Setter
@Getter
public static class Attachment {
private String filepath;
private String filetype;
private String originFilename;
}
}

26
mailbox-outer/src/main/java/com/biutag/outer/domain/bo/MailEvaluateBo.java

@ -0,0 +1,26 @@
package com.biutag.outer.domain.bo;
import cn.hutool.core.bean.BeanUtil;
import com.biutag.outer.domain.MailEvaluate;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import org.apache.logging.log4j.core.config.plugins.validation.constraints.NotBlank;
@Setter
@Getter
public class MailEvaluateBo {
@NotNull
private String mailId;
@NotBlank
private String satisfaction;
public MailEvaluate toEntity() {
MailEvaluate evaluate = new MailEvaluate();
BeanUtil.copyProperties(this, evaluate);
return evaluate;
}
}

76
mailbox-outer/src/main/java/com/biutag/outer/domain/vo/MailDraftVo.java

@ -0,0 +1,76 @@
package com.biutag.outer.domain.vo;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.biutag.outer.domain.MailDraft;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.Date;
@Setter
@Getter
public class MailDraftVo {
private String id;
/**
* 联系人姓名
*/
private String contactName;
/**
* 联系人性别
*/
private String contactSex;
/**
* 联系人身份证号码
*/
private String contactIdCard;
/**
*
*/
private String contactPhone;
/**
* 案件编号
*/
private String caseNumber;
/**
* 内容
*/
private String content;
/**
* 附件
*/
private String attachments;
/**
* 用户ID
*/
private Integer userId;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
private String title;
public static MailDraftVo of(MailDraft draft) {
MailDraftVo vo = new MailDraftVo();
BeanUtil.copyProperties(draft, vo);
if (draft != null) {
vo.setTitle(String.format("%s我写的信", DateUtil.format(draft.getCreateTime(), "yyyy年MM月dd日HH时")));
}
return vo;
}
}

89
mailbox-outer/src/main/java/com/biutag/outer/domain/vo/MailVo.java

@ -0,0 +1,89 @@
package com.biutag.outer.domain.vo;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.biutag.outer.domain.Mail;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.Date;
@Setter
@Getter
public class MailVo {
private String id;
/**
* 联系人姓名
*/
private String contactName;
/**
* 联系人性别
*/
private String contactSex;
/**
* 联系人身份证号码
*/
private String contactIdCard;
/**
*
*/
private String contactPhone;
/**
* 案件编号
*/
private String caseNumber;
/**
* 内容
*/
private String content;
/**
* 附件
*/
private String attachments;
/**
* 用户ID
*/
private Integer userId;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
/**
* 是否满意
*/
private String satisfaction;
private String title;
/**
* 涉及单位ID
*/
private Integer involvedDeptId;
/**
* 涉及单位名称
*/
private String involvedDeptName;
public static MailVo of(Mail mail) {
MailVo vo = new MailVo();
BeanUtil.copyProperties(mail, vo);
vo.setTitle(String.format("%s我写的信", DateUtil.format(mail.getCreateTime(), "yyyy年MM月dd日HH时")));
return vo;
}
}

9
mailbox-outer/src/main/java/com/biutag/outer/mapper/FaceAuthMapper.java

@ -0,0 +1,9 @@
package com.biutag.outer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.outer.domain.FaceAuth;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface FaceAuthMapper extends BaseMapper<FaceAuth> {
}

11
mailbox-outer/src/main/java/com/biutag/outer/mapper/MailDraftMapper.java

@ -0,0 +1,11 @@
package com.biutag.outer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.outer.domain.Mail;
import com.biutag.outer.domain.MailDraft;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface MailDraftMapper extends BaseMapper<MailDraft> {
}

9
mailbox-outer/src/main/java/com/biutag/outer/mapper/MailEvaluateMapper.java

@ -0,0 +1,9 @@
package com.biutag.outer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.outer.domain.MailEvaluate;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MailEvaluateMapper extends BaseMapper<MailEvaluate> {
}

5
mailbox-outer/src/main/java/com/biutag/outer/mapper/MailMapper.java

@ -3,7 +3,12 @@ package com.biutag.outer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.outer.domain.Mail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface MailMapper extends BaseMapper<Mail> {
@Select("SELECT nextval('mail_id_seq') ")
Integer getMailIdSeqVal();
}

9
mailbox-outer/src/main/java/com/biutag/outer/mapper/UserMapper.java

@ -0,0 +1,9 @@
package com.biutag.outer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.outer.domain.User;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UserMapper extends BaseMapper<User> {
}

34
mailbox-outer/src/main/java/com/biutag/outer/service/FaceAuthService.java

@ -0,0 +1,34 @@
package com.biutag.outer.service;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.outer.domain.FaceAuth;
import com.biutag.outer.domain.User;
import com.biutag.outer.domain.bo.FaceAuthBo;
import com.biutag.outer.mapper.FaceAuthMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
@RequiredArgsConstructor
@Service
public class FaceAuthService extends ServiceImpl<FaceAuthMapper, FaceAuth> {
private final UserService userService;
@Transactional(rollbackFor = Exception.class)
public boolean save(FaceAuthBo faceAuthBo) {
LocalDateTime now = LocalDateTime.now();
FaceAuth faceAuth = faceAuthBo.toEntity();
faceAuth.setCreateTime(now);
save(faceAuth);
return userService.update(new LambdaUpdateWrapper<User>()
.eq(User::getId, faceAuth.getUserId())
.set(User::getRealName, faceAuth.getRealName())
.set(User::getIdCard, faceAuth.getIdCard())
.set(User::getFaceAuthTime, now)
.set(User::getUpdateTime, now));
}
}

46
mailbox-outer/src/main/java/com/biutag/outer/service/MailDraftService.java

@ -0,0 +1,46 @@
package com.biutag.outer.service;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.outer.domain.MailDraft;
import com.biutag.outer.domain.bo.MailBo;
import com.biutag.outer.domain.vo.MailDraftVo;
import com.biutag.outer.mapper.MailDraftMapper;
import com.biutag.outer.util.UserHelper;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.Date;
import static java.util.stream.Collectors.toList;
@Service
public class MailDraftService extends ServiceImpl<MailDraftMapper, MailDraft> {
public MailDraft save(MailBo mailBo) {
MailDraft mailDraft = mailBo.toMailDraft();
if (StrUtil.isBlank(mailDraft.getId())) {
mailDraft.setId(IdUtil.simpleUUID());
}
mailDraft.setCreateTime(LocalDateTime.now());
mailDraft.setUpdateTime(mailDraft.getCreateTime());
mailDraft.setUserId(UserHelper.getCurrentUserId());
saveOrUpdate(mailDraft);
return mailDraft;
}
public Page<MailDraftVo> listByCurrentUserId(Page<MailDraft> page) {
LambdaQueryWrapper<MailDraft> queryWrapper = new LambdaQueryWrapper<MailDraft>()
.eq(MailDraft::getUserId, UserHelper.getCurrentUserId())
.orderByDesc(MailDraft::getCreateTime);
Page<MailDraft> mailDraftPage = page(page, queryWrapper);
Page<MailDraftVo> voPage = new Page<>();
voPage.setTotal(mailDraftPage.getTotal())
.setRecords(mailDraftPage.getRecords().stream().map(MailDraftVo::of).collect(toList()));
return voPage;
}
}

10
mailbox-outer/src/main/java/com/biutag/outer/service/MailEvaluateService.java

@ -0,0 +1,10 @@
package com.biutag.outer.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.outer.domain.MailEvaluate;
import com.biutag.outer.mapper.MailEvaluateMapper;
import org.springframework.stereotype.Service;
@Service
public class MailEvaluateService extends ServiceImpl<MailEvaluateMapper, MailEvaluate> {
}

72
mailbox-outer/src/main/java/com/biutag/outer/service/MailService.java

@ -1,10 +1,82 @@
package com.biutag.outer.service;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.outer.domain.Mail;
import com.biutag.outer.domain.MailDraft;
import com.biutag.outer.domain.MailEvaluate;
import com.biutag.outer.domain.bo.MailBo;
import com.biutag.outer.domain.bo.MailEvaluateBo;
import com.biutag.outer.domain.vo.MailDraftVo;
import com.biutag.outer.domain.vo.MailVo;
import com.biutag.outer.mapper.MailMapper;
import com.biutag.outer.util.UserHelper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import static java.util.stream.Collectors.toList;
@RequiredArgsConstructor
@Service
public class MailService extends ServiceImpl<MailMapper, Mail> {
public final MailEvaluateService mailEvaluateService;
public final MailDraftService mailDraftService;
public final UserService userService;
@Transactional(rollbackFor = Exception.class)
public boolean save(MailBo mailBo) {
Mail mail = mailBo.toEntity();
mail.setId(generateMailId());
mail.setCreateTime(LocalDateTime.now());
mail.setUserId(UserHelper.getCurrentUserId());
boolean save = save(mail);
if (save) {
userService.updatePhoneByCurrent(mailBo.getContactPhone());
}
return save;
}
@Transactional(rollbackFor = Exception.class)
public boolean evaluate(MailEvaluateBo evaluateBo) {
MailEvaluate evaluate = evaluateBo.toEntity();
evaluate.setCreateTime(LocalDateTime.now());
evaluate.setUserId(UserHelper.getCurrentUserId());
mailEvaluateService.save(evaluate);
Mail mail = new Mail();
mail.setId(evaluateBo.getMailId());
mail.setSatisfaction(evaluateBo.getSatisfaction());
return updateById(mail);
}
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');
}
return DateUtil.format(new Date(), "yyyyMMddHHMM") + zeroString + seqVal;
}
public Page<MailVo> listByCurrentUserId(Page<Mail> page) {
LambdaQueryWrapper<Mail> queryWrapper = new LambdaQueryWrapper<Mail>()
.eq(Mail::getUserId, UserHelper.getCurrentUserId())
.orderByDesc(Mail::getCreateTime);
Page<Mail> mailPage = page(page, queryWrapper);
Page<MailVo> voPage = new Page<>();
voPage.setTotal(mailPage.getTotal())
.setRecords(mailPage.getRecords().stream().map(MailVo::of).collect(toList()));
return voPage;
}
}

30
mailbox-outer/src/main/java/com/biutag/outer/service/UserService.java

@ -0,0 +1,30 @@
package com.biutag.outer.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.outer.domain.User;
import com.biutag.outer.mapper.UserMapper;
import com.biutag.outer.util.UserHelper;
import org.springframework.stereotype.Service;
@Service
public class UserService extends ServiceImpl<UserMapper, User> {
public User getByOpenid(String openid) {
return getOne(new LambdaQueryWrapper<User>().eq(User::getOpenid, openid));
}
public boolean updatePhoneByCurrent(String phone) {
User currentUser = UserHelper.getCurrentUser();
boolean updated = update(new LambdaUpdateWrapper<User>().eq(User::getId, currentUser.getId()).set(User::getPhone, phone));
if (updated) {
currentUser.setPhone(phone);
// 更新缓存
UserHelper.update(currentUser);
}
return updated;
}
}

28
mailbox-outer/src/main/java/com/biutag/outer/util/CodeUtil.java

@ -0,0 +1,28 @@
package com.biutag.outer.util;
import cn.hutool.core.util.IdUtil;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import java.util.concurrent.TimeUnit;
public class CodeUtil {
private static final Cache<String, String> cache = Caffeine.newBuilder()
.expireAfterWrite(5, TimeUnit.MINUTES) // 设置写入后过期时间
.maximumSize(1000) // 最多1000人
.build();
public static String set(String code) {
String key = IdUtil.fastSimpleUUID();
cache.put(key, code);
return key;
}
public static String get(String key) {
return cache.getIfPresent(key);
}
}

62
mailbox-outer/src/main/java/com/biutag/outer/util/Sms.java

@ -0,0 +1,62 @@
package com.biutag.outer.util;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.aliyun.auth.credentials.Credential;
import com.aliyun.auth.credentials.provider.StaticCredentialProvider;
import com.aliyun.sdk.service.dysmsapi20170525.AsyncClient;
import com.aliyun.sdk.service.dysmsapi20170525.models.SendSmsRequest;
import com.aliyun.sdk.service.dysmsapi20170525.models.SendSmsResponse;
import darabonba.core.client.ClientOverrideConfiguration;
import lombok.extern.slf4j.Slf4j;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@Slf4j
public class Sms {
public static void send(String phoneNumber, String code) {
log.info("手机号:{}, 短信验证码:{}", phoneNumber, code);
String accessKeyId = "LTAI5tS4QJAGMqNCYvsGkXs6";
String accessKeySecret = "PGN12Bm5LYihcC5j3dzIqDdvssJ7XY";
StaticCredentialProvider provider = StaticCredentialProvider.create(Credential.builder()
// Please ensure that the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set.
.accessKeyId(accessKeyId)
.accessKeySecret(accessKeySecret)
//.securityToken(System.getenv("ALIBABA_CLOUD_SECURITY_TOKEN")) // use STS token
.build());
// Configure the Client
AsyncClient client = AsyncClient.builder()
//.httpClient(httpClient) // Use the configured HttpClient, otherwise use the default HttpClient (Apache HttpClient)
.credentialsProvider(provider)
//.serviceConfiguration(Configuration.create()) // Service-level configuration
// Client-level configuration rewrite, can set Endpoint, Http request parameters, etc.
.overrideConfiguration(
ClientOverrideConfiguration.create()
// Endpoint 请参考 https://api.aliyun.com/product/Dysmsapi
.setEndpointOverride("dysmsapi.aliyuncs.com")
//.setConnectTimeout(Duration.ofSeconds(30))
)
.build();
// Parameter settings for API request
SendSmsRequest sendSmsRequest = SendSmsRequest.builder()
.phoneNumbers(phoneNumber)
.signName("长沙创客软件")
.templateCode("SMS_294115479")
.templateParam(JSONObject.of("code", code).toJSONString())
// Request-level configuration rewrite, can set Http request parameters, etc.
// .requestConfiguration(RequestConfiguration.create().setHttpHeaders(new HttpHeaders()))
.build();
// Asynchronously get the return value of the API request
CompletableFuture<SendSmsResponse> response = client.sendSms(sendSmsRequest);
try {
log.info("手机号:{}, 发送短信结果:{}", phoneNumber, JSON.toJSONString(response.get()));
} catch (ExecutionException | InterruptedException e) {
log.error(e.getMessage(), e);
}
}
}

32
mailbox-outer/src/main/java/com/biutag/outer/util/TokenUtil.java

@ -0,0 +1,32 @@
package com.biutag.outer.util;
import cn.hutool.core.util.IdUtil;
import com.biutag.outer.domain.User;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.util.Assert;
import java.util.concurrent.TimeUnit;
public class TokenUtil {
private static final Cache<String, User> cache = Caffeine.newBuilder()
.expireAfterWrite(60, TimeUnit.MINUTES) // 设置写入后过期时间
.maximumSize(1000) // 最多1000人
.build();
public static String set(User user) {
Assert.notNull(user, "未找到该用户");
String key = IdUtil.fastSimpleUUID();
cache.put(key, user);
return key;
}
public static User update(String key, User user) {
cache.put(key, user);
return user;
}
public static User get(String key) {
return cache.getIfPresent(key);
}
}

33
mailbox-outer/src/main/java/com/biutag/outer/util/UserHelper.java

@ -0,0 +1,33 @@
package com.biutag.outer.util;
import com.biutag.exception.AuthException;
import com.biutag.outer.domain.User;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
public class UserHelper {
public static User getCurrentUser() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
// 获取请求头的值
String authorization = request.getHeader("Authorization");
User user = TokenUtil.get(authorization);
if (user == null) {
throw new AuthException();
}
return user;
}
public static User update(User user) {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
// 获取请求头的值
String authorization = request.getHeader("Authorization");
return TokenUtil.update(authorization, user);
}
public static Integer getCurrentUserId() {
return getCurrentUser().getId();
}
}

86
mailbox-outer/src/main/java/com/biutag/outer/util/Weixin.java

@ -0,0 +1,86 @@
package com.biutag.outer.util;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.biutag.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@Slf4j
public class Weixin {
// 优客智能家
private static final String APP_ID = "wx795f76e4bc3b0062";
public static final String SECRET = "7596544a77776be53d10fd78a7b4a441";
public static JSONObject getAccessToken(String code) {
// https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=SECRET&code=%s&grant_type=authorization_code
String url = String.format("https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code",
APP_ID,
SECRET,
code);
HttpResponse httpResponse = HttpUtil.createGet(url)
.execute();
JSONObject data = JSON.parseObject(httpResponse.body());
if (StrUtil.isBlank(data.getString("access_token"))) {
log.error("response: {}", JSON.toJSONString(data));
throw new BusinessException("微信授权失败,code: " + data.getInteger("errcode"));
}
return data;
}
public static JSONObject getAccessToken() {
String url = String.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s",
APP_ID,
SECRET);
HttpResponse httpResponse = HttpUtil.createGet(url)
.execute();
JSONObject data = JSON.parseObject(httpResponse.body());
if (StrUtil.isBlank(data.getString("access_token"))) {
log.error("response: {}", JSON.toJSONString(data));
throw new BusinessException("微信获取 access_token 异常,code: " + data.getInteger("errcode"));
}
return data;
}
public static String getTicket() {
JSONObject result = getAccessToken();
String url = String.format("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%s&type=jsapi",
result.getString("access_token"));
HttpResponse httpResponse = HttpUtil.createGet(url)
.execute();
JSONObject data = JSON.parseObject(httpResponse.body());
String ticket = data.getString("ticket");
if (StrUtil.isBlank(ticket)) {
log.error("response: {}", JSON.toJSONString(data));
throw new BusinessException("微信获取 tiket 异常,code: " + data.getInteger("errcode"));
}
return ticket;
}
public static String sign(String noncestr, String jsapiTicket, long timestamp, String url) {
String input = String.format("jsapi_ticket=%s&noncestr=%s&timestamp=%s&url=%s", jsapiTicket, noncestr, timestamp, url);
try {
String sign = generateSHA1(input);
return sign;
} catch (NoSuchAlgorithmException e) {
throw new BusinessException(e.getCause());
}
}
public static String generateSHA1(String input) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] digest = md.digest(input.getBytes());
StringBuilder hexString = new StringBuilder();
for (byte b : digest) {
hexString.append(String.format("%02x", b));
}
return hexString.toString();
}
}

90
mailbox-outer/src/main/java/com/biutag/outer/util/Weixin2.java

@ -0,0 +1,90 @@
package com.biutag.outer.util;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.biutag.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@Slf4j
public class Weixin2 {
// 优客智能家
// private static final String APP_ID = "wx795f76e4bc3b0062";
// public static final String SECRET = "7596544a77776be53d10fd78a7b4a441";
// 博麟智渊
private static final String APP_ID = "wx03c2abbf3291a7c7";
public static final String SECRET = "4d6bc9ab9821f642d185b353893b44ea";
public static JSONObject getAccessToken(String code) {
// https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=SECRET&code=%s&grant_type=authorization_code
String url = String.format("https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code",
APP_ID,
SECRET,
code);
HttpResponse httpResponse = HttpUtil.createGet(url)
.execute();
JSONObject data = JSON.parseObject(httpResponse.body());
if (StrUtil.isBlank(data.getString("access_token"))) {
log.error("response: {}", JSON.toJSONString(data));
throw new BusinessException("微信授权失败,code: " + data.getInteger("errcode"));
}
return data;
}
public static JSONObject getAccessToken() {
String url = String.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s",
APP_ID,
SECRET);
HttpResponse httpResponse = HttpUtil.createGet(url)
.execute();
JSONObject data = JSON.parseObject(httpResponse.body());
if (StrUtil.isBlank(data.getString("access_token"))) {
log.error("response: {}", JSON.toJSONString(data));
throw new BusinessException("微信获取 access_token 异常,code: " + data.getInteger("errcode"));
}
return data;
}
public static String getTicket() {
JSONObject result = getAccessToken();
String url = String.format("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%s&type=jsapi",
result.getString("access_token"));
HttpResponse httpResponse = HttpUtil.createGet(url)
.execute();
JSONObject data = JSON.parseObject(httpResponse.body());
String ticket = data.getString("ticket");
if (StrUtil.isBlank(ticket)) {
log.error("response: {}", JSON.toJSONString(data));
throw new BusinessException("微信获取 tiket 异常,code: " + data.getInteger("errcode"));
}
return ticket;
}
public static String sign(String noncestr, String jsapiTicket, long timestamp, String url) {
String input = String.format("jsapi_ticket=%s&noncestr=%s&timestamp=%s&url=%s", jsapiTicket, noncestr, timestamp, url);
try {
String sign = generateSHA1(input);
return sign;
} catch (NoSuchAlgorithmException e) {
throw new BusinessException(e.getCause());
}
}
public static String generateSHA1(String input) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] digest = md.digest(input.getBytes());
StringBuilder hexString = new StringBuilder();
for (byte b : digest) {
hexString.append(String.format("%02x", b));
}
return hexString.toString();
}
}

42
mailbox-outer/src/main/resources/application-bak.yml

@ -0,0 +1,42 @@
server:
port: 8081
tongweb:
license:
path: license/license.dat
spring:
profiles:
active: dev
mvc:
static-path-pattern: /api/static/**
throw-exception-if-no-handler-found: true
pathmatch:
matching-strategy: ant_path_matcher
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://172.31.217.20:32378/mailbox?currentSchema=mailbox
username: mailbox
password: Ip12341234
hikari:
connection-timeout: 30000 # 等待连接分配连接的最大时长(毫秒),超出时长还没可用连接则发送SQLException,默认30秒
minimum-idle: 5 # 最小连接数
maximum-pool-size: 20 # 最大连接数
auto-commit: true # 自动提交
idle-timeout: 600000 # 连接超时的最大时长(毫秒),超时则被释放(retired),默认10分钟
pool-name: DateSourceHikariCP # 连接池名称
max-lifetime: 1800000 # 连接的生命时长(毫秒),超时而且没被使用则被释放,默认30分钟(1800000ms)
connection-init-sql: SELECT 1 # 连接时发起SQL测试脚本
# 限制配置
servlet:
multipart:
max-file-size: 100MB # 文件上传大小限制
max-request-size: 100MB # 文件最大请求限制
enabled: true
# Redis配置
data:
redis:
timeout: 5000
host: 192.168.48.231
port: 6379
password: yuanian
database: 100

53
mailbox-outer/src/main/resources/application.yml

@ -1,42 +1,27 @@
server:
port: 8081
port: 8080
tongweb:
license:
path: license/license.dat
path: classpath:license/license.dat
spring:
profiles:
active: dev
mvc:
static-path-pattern: /api/static/**
throw-exception-if-no-handler-found: true
pathmatch:
matching-strategy: ant_path_matcher
servlet:
multipart:
max-file-size: 10MB
max-request-size: 10MB
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://172.31.217.20:32378/mailbox?currentSchema=mailbox
username: mailbox
url: jdbc:postgresql://172.31.217.20:32378/mailbox?currentSchema=mailbox-outer
username: vbadmin
password: Ip12341234
hikari:
connection-timeout: 30000 # 等待连接分配连接的最大时长(毫秒),超出时长还没可用连接则发送SQLException,默认30秒
minimum-idle: 5 # 最小连接数
maximum-pool-size: 20 # 最大连接数
auto-commit: true # 自动提交
idle-timeout: 600000 # 连接超时的最大时长(毫秒),超时则被释放(retired),默认10分钟
pool-name: DateSourceHikariCP # 连接池名称
max-lifetime: 1800000 # 连接的生命时长(毫秒),超时而且没被使用则被释放,默认30分钟(1800000ms)
connection-init-sql: SELECT 1 # 连接时发起SQL测试脚本
# 限制配置
servlet:
multipart:
max-file-size: 100MB # 文件上传大小限制
max-request-size: 100MB # 文件最大请求限制
enabled: true
# Redis配置
data:
redis:
timeout: 5000
host: 192.168.48.231
port: 6379
password: yuanian
database: 100
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
oss:
minio:
endpoint: http://172.31.217.20:31401
accessKey: n8yPVAJk4yw879zi
secretKey: eElQ7gCwuNxaFhKEbtRRq0lsovoOTgI1
bucketName: mailbox

1
mailbox-outer/src/main/resources/license/license.dat

@ -0,0 +1 @@
uc3Y29XJfVtZtZTbmFsTP26/w7Lzq+nBy7WClY3b2pmFtRfb6/sZT2+7ETPzKxev8rGljQKbzZVZW5D039pZxMwNjYWNlpsalX3bnNGU9R5cpYWdHJ3JlwKYlX2YXRGU9RhdyMyMjAi0w0xMlbmNQpGF0RfZyMDZT0TAzI0L1ClLTA1ByRXX1Y3b2RmFtRfTUb2ZT12Vi5nVXX1ClRnNpZlcfTnb25mVyVtYuMCPTclRX5FCQVVX0N1VO9DTKYmVD0GlwluZUV1PQpXJk9IYyZVd2FD0K9JZfTWVFd051F4XlcjbWJQpU0tMMaWV19nNlNlblcnX1Nl9WZlczaWZXJTQu9uPwClMi419QRIUkdWcm905hN0X9VGbWU0h09uZTZXdHBXIKJ2ZTX1VEhnNpZlcfTnb25mVyVtYuMAPTY19FpUV0aWZGlUVt9uPkCkYmV19W5FVTSURVJ0xJ9OXOQ0Q0VFJGU9UYSkS1hzlWJUKLOHZ0pllDBHZ2aDdEdVllZTW0d2RlRXpxpTTkZTNzZ2ladVKjN0UmNjRKJvdJd0K0hDI2tzNBOEcG1EtFVFZvQ3NWkDlrhWW0OXVnkS9BVYTIT2VmdmROxJRjemeC9UZZ9FcXeFV0h0YzdXYKOXL2xVAKowWXX1TkVlNJZFUfTET05U5DlDRIQ0RT10d3tRKGY2OGVHVRdkb3VXSUIXp1NTTyc0WVk3BxpMNhZkOXhGNSE2VDMEUnBjNk1EWiaEUDN1dYplLLYVdm51VtpkVsMmZi9GE5E3cyZEZjkWlQ9McCRlbENTFDhydwdEdGM2hGNqdzOWWncEFqg5MGUHbDRVowNxapbAY3ZVdfpORSU0VkVl9MlPTFTkSUNWNyNFPaM1T0llQ1BjTaM2OW5jJUw4W4ZGYk5Xd392bsMHV3NGVRNGWwTDeTlEsyJYVyVkUUx21j5Dd2QlWFcjdDNOepb3SUlTArhpeLTVMFFVlMNLNpS3ek9Uhah1VEOUb2lmx242VRcVWW92dUl6cTZUMlFmVp5XTMb0MlRmpmtOVFV1Ck5VJT9WROX0SU90VOxJQ9aiQ0UFlltjdPSDSUtGpKR1SiZlVWVEpGpIdiQ0WCtzlU5LVyakdjFE9TJuRwcFK0EUpQQ4YwRTUEpjMrFITIejQm11VxVoZ1NEcS9DZ5xQMzTlUFInZ1l3dIeXdjd2ZwI5QDSGbzl1dKZDL0aTQ1M2MylyZtWlZnlEl0JpSnZkQjJkVXsKTFUlX1Z05fNJTDRUTElV9T5DR9V2VU40o4txMjWkL1l3ZZVvVvMjUmQWhidjQ2bDOTdkNucvamNkS0xTZEYwVaVkTEFnIztPMxdkK2lHZM9jM2RTeUoXlzZma0NEMjU3VNJqazMFQXAys4B5ZNV3WGtDh4dxR6TEcHdlFUplduaET2hXVphTemZGWnlHdPR1O0c2ckZkVX8KTFUlX1Z05fNJTDRUTElV9T5DR9MjVU4m1jl5Q6RSTnd0lv94dYNkaEFm1hxuThR0T1BGNFtzaYc3cGlFVBh1dCWlZkJmhFBHeFdDemtjh6dCd0RmQ24jdjFyZwVHU0Z3NQVKb3U3RFFUhaFuTxYWRnZlRuVlWkMGZVVUxY5hYRSGcEhlF2MrWwUTZGxW5tczdONHdmNkVXAKTFUlX1Z05fNJTDRUTElV9T5DR9TkVU4zJOZYZMK1cUNldSc1dNQ3M29GNQdFZvUHemY1MxJFY3dFZ2UjZDlEQzeCM2QXZ2t6YWbkNjNkdEZUd3ajVkRzBhJ5QGeUOC9GFok1TsT2TWFVIvV1ZLMVUHJXZpBCM4b3MnN0MwJEY2akaFIVYyVLWyNzRGIVVYhoZhUiZTBkVX8KTFUlX1Z05fNJTDRUTElV9T5DR9aTVU4zNUlNUVSUajdG5SZVOOMGcmVCt6lWeLS1d1lnk4VTbFOWWmlWQ0E4UIOUME9EdHdWOScTYlJ1MvUyR0NmZW8kFvZ3S0ZmMDQ2xH1UT6V1VlFHk3Qwd1UDTlgkppB3WwVULzBVZrowOtWFaUVFJ0dDaTZWS3p1RXVVQOdTSld YK

58
mailbox-outer/src/test/java/com/biutag/outer/SmsTest.java

@ -0,0 +1,58 @@
package com.biutag.outer;
import com.alibaba.fastjson2.JSONObject;
import com.aliyun.auth.credentials.Credential;
import com.aliyun.auth.credentials.provider.StaticCredentialProvider;
import com.aliyun.sdk.service.dysmsapi20170525.AsyncClient;
import com.aliyun.sdk.service.dysmsapi20170525.models.SendSmsRequest;
import com.aliyun.sdk.service.dysmsapi20170525.models.SendSmsResponse;
import darabonba.core.client.ClientOverrideConfiguration;
import org.junit.jupiter.api.Test;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
public class SmsTest {
@Test
public void testSend() throws ExecutionException, InterruptedException {
String accessKeyId = "LTAI5tS4QJAGMqNCYvsGkXs6";
String accessKeySecret = "PGN12Bm5LYihcC5j3dzIqDdvssJ7XY";
StaticCredentialProvider provider = StaticCredentialProvider.create(Credential.builder()
// Please ensure that the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set.
.accessKeyId(accessKeyId)
.accessKeySecret(accessKeySecret)
//.securityToken(System.getenv("ALIBABA_CLOUD_SECURITY_TOKEN")) // use STS token
.build());
// Configure the Client
AsyncClient client = AsyncClient.builder()
//.httpClient(httpClient) // Use the configured HttpClient, otherwise use the default HttpClient (Apache HttpClient)
.credentialsProvider(provider)
//.serviceConfiguration(Configuration.create()) // Service-level configuration
// Client-level configuration rewrite, can set Endpoint, Http request parameters, etc.
.overrideConfiguration(
ClientOverrideConfiguration.create()
// Endpoint 请参考 https://api.aliyun.com/product/Dysmsapi
.setEndpointOverride("dysmsapi.aliyuncs.com")
//.setConnectTimeout(Duration.ofSeconds(30))
)
.build();
// Parameter settings for API request
SendSmsRequest sendSmsRequest = SendSmsRequest.builder()
.phoneNumbers("15608487213")
.signName("长沙创客软件")
.templateCode("SMS_294115479")
.templateParam(JSONObject.of("code", "1234").toJSONString())
// Request-level configuration rewrite, can set Http request parameters, etc.
// .requestConfiguration(RequestConfiguration.create().setHttpHeaders(new HttpHeaders()))
.build();
// Asynchronously get the return value of the API request
CompletableFuture<SendSmsResponse> response = client.sendSms(sendSmsRequest);
SendSmsResponse resp = response.get();
System.out.println(resp);
}
}

22
mailbox-outer/src/test/java/com/biutag/outer/UploadTest.java

File diff suppressed because one or more lines are too long

76
mailbox-outer/src/test/java/com/biutag/outer/WeixinTest.java

@ -0,0 +1,76 @@
package com.biutag.outer;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson2.JSONObject;
import com.biutag.outer.util.Weixin;
import com.biutag.outer.util.Weixin2;
import org.junit.jupiter.api.Test;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
public class WeixinTest {
@Test
public void testGetAccessToken() {
JSONObject accessToken = Weixin.getAccessToken("051H1lGa1iJiLG0SfyIa1r1e7D1H1lGd");
System.out.println(accessToken);
// {"access_token":"76_06xHwWwv5Uh0kL9rS4XlIo6zUnTR8UTQPkgqCudq0CCWKIHWKtm1ZTt2gjL0UFhIu5nRz_fbj3K8FU3cP_KV7BvYj10klyzGwo3SfH9J2C8","expires_in":7200,"refresh_token":"76_NTEKzhqkR8r4DHIrNHjqdf_op1WO45S-9hXZUudVa9AIpWVtrOeI9GjtrRRv9li1eW42HEhZlWywUeNU3-PQ5eax1HuDoSjmIf-ryr6b1ho","openid":"oXI846jfRZAqNG1MifdS6BUEVQBo","scope":"snsapi_userinfo"}
}
@Test
public void testGetAccessToken2() {
// 47.104.162.76
JSONObject accessToken = Weixin.getAccessToken();
System.out.println(accessToken);
// 76_G7arjUsJjMcy1aTZsnEDwha4omw5DMoIy6fdeBCwrT0mRB9UFdEsOPo0v_NI2tA_GQepSf5ci5ywEswAp3SXfY-wG98vyvbFpYgYbnFkioIIn7IQJv9sKvBqQPgXHGjACAPZY
}
@Test
public void testGetTicket() {
String ticket = Weixin.getTicket();
// ticket -> kgt8ON7yVITDhtdwci0qeQqMEspVxlvdU-9lgGDo9a9am_7XqzZHlyJqkuAvhu422wxs1VRgcuXvKhmYwdYMmQ
}
@Test
public void testSignature() {
// noncestr=Wm3WZYTPz0wzccnW
// jsapi_ticket=sM4AOVdWfPE4DxkXGEs8VMCPGGVi4C3VM0P37wVUCFvkVAy_90u5h9nbSlYy3-Sl-HhTdfl2fzFy1AOcHKP7qg
// timestamp=1414587457
// url=http://mp.weixin.qq.com?params=value
String input = "jsapi_ticket=sM4AOVdWfPE4DxkXGEs8VMCPGGVi4C3VM0P37wVUCFvkVAy_90u5h9nbSlYy3-Sl-HhTdfl2fzFy1AOcHKP7qg&noncestr=Wm3WZYTPz0wzccnW&timestamp=1414587457&url=http://mp.weixin.qq.com?params=value";
try {
String sha1Hash = generateSHA1(input);
System.out.println(sha1Hash);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
public static String generateSHA1(String input) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] digest = md.digest(input.getBytes());
StringBuilder hexString = new StringBuilder();
for (byte b : digest) {
hexString.append(String.format("%02x", b));
}
return hexString.toString();
}
@Test
public void testSign() {
String noncestr = IdUtil.nanoId(16);
String jsapiTicket = Weixin2.getTicket();
System.out.println(jsapiTicket);
long timestamp = new Date().getTime() / 1000;
String sign = Weixin2.sign(noncestr, jsapiTicket, timestamp, "https://mailbox.biutag.com/open.html");
System.out.println("noncestr: " + noncestr);
System.out.println("timestamp: " + timestamp);
System.out.println("sign: " + sign);
}
}

16
pom.xml

@ -75,6 +75,13 @@
<version>8.5.7</version>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>3.1.8</version>
</dependency>
</dependencies>
</dependencyManagement>
@ -102,6 +109,15 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>-parameters</compilerArgument>
</configuration>
</plugin>
</plugins>
</build>

Loading…
Cancel
Save