Browse Source

feat:【用户授权】提交

master
zhangjing 1 year ago
parent
commit
1989a6b6e7
40 changed files with 2160 additions and 142 deletions
  1. BIN
      lib/minio-7.0.2-all.jar
  2. +7
    -1
      pom.xml
  3. +295
    -0
      src/main/java/com/fxzy/warn/common/conf/MinioConfig.java
  4. +30
    -0
      src/main/java/com/fxzy/warn/common/constants/AuthorizationConstants.java
  5. +2
    -13
      src/main/java/com/fxzy/warn/common/constants/EntityConstants.java
  6. +3
    -3
      src/main/java/com/fxzy/warn/common/constants/RedisKeyConstants.java
  7. +2
    -1
      src/main/java/com/fxzy/warn/common/constants/ResponseMsgConstants.java
  8. +4
    -1
      src/main/java/com/fxzy/warn/common/response/ApiResponse.java
  9. +101
    -79
      src/main/java/com/fxzy/warn/common/util/JWTUtil.java
  10. +97
    -0
      src/main/java/com/fxzy/warn/controller/AuthorizationController.java
  11. +99
    -0
      src/main/java/com/fxzy/warn/controller/FileController.java
  12. +101
    -0
      src/main/java/com/fxzy/warn/controller/MonitorUsersController.java
  13. +126
    -0
      src/main/java/com/fxzy/warn/controller/PolicyManagementController.java
  14. +14
    -0
      src/main/java/com/fxzy/warn/mapper/AuditRecordsMapper.java
  15. +14
    -0
      src/main/java/com/fxzy/warn/mapper/AuthorizationMapper.java
  16. +28
    -0
      src/main/java/com/fxzy/warn/mapper/FileMapper.java
  17. +14
    -0
      src/main/java/com/fxzy/warn/mapper/MonitorUsersMapper.java
  18. +14
    -0
      src/main/java/com/fxzy/warn/mapper/PolicyManagementMapper.java
  19. +71
    -0
      src/main/java/com/fxzy/warn/model/AuditRecords.java
  20. +26
    -7
      src/main/java/com/fxzy/warn/model/Authorization.java
  21. +99
    -0
      src/main/java/com/fxzy/warn/model/File.java
  22. +49
    -0
      src/main/java/com/fxzy/warn/model/MonitorUsers.java
  23. +47
    -0
      src/main/java/com/fxzy/warn/model/PolicyManagement.java
  24. +2
    -2
      src/main/java/com/fxzy/warn/model/Test.java
  25. +76
    -14
      src/main/java/com/fxzy/warn/model/User.java
  26. +30
    -0
      src/main/java/com/fxzy/warn/model/vo/FileVO.java
  27. +54
    -0
      src/main/java/com/fxzy/warn/service/AuditRecordsService.java
  28. +60
    -0
      src/main/java/com/fxzy/warn/service/AuthorizationService.java
  29. +39
    -0
      src/main/java/com/fxzy/warn/service/FileService.java
  30. +48
    -0
      src/main/java/com/fxzy/warn/service/MonitorUsersService.java
  31. +55
    -0
      src/main/java/com/fxzy/warn/service/PolicyManagementService.java
  32. +8
    -0
      src/main/java/com/fxzy/warn/service/UserService.java
  33. +65
    -0
      src/main/java/com/fxzy/warn/service/impl/AuditRecordsServiceImpl.java
  34. +100
    -0
      src/main/java/com/fxzy/warn/service/impl/AuthorizationServiceImpl.java
  35. +123
    -0
      src/main/java/com/fxzy/warn/service/impl/FileServiceImpl.java
  36. +58
    -0
      src/main/java/com/fxzy/warn/service/impl/MonitorUsersServiceImpl.java
  37. +69
    -0
      src/main/java/com/fxzy/warn/service/impl/PolicyManagementServiceImpl.java
  38. +95
    -20
      src/main/java/com/fxzy/warn/service/impl/UserServiceImpl.java
  39. +1
    -1
      src/main/resources/bootstrap-dev.yml
  40. +34
    -0
      src/main/resources/mapper/FileMapper.xml

BIN
lib/minio-7.0.2-all.jar View File


+ 7
- 1
pom.xml View File

@ -163,7 +163,13 @@
</dependency>
<!--minio -->
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>7.0.2-all</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/minio-7.0.2-all.jar</systemPath>
</dependency>
<dependency>
<groupId>io.netty</groupId>

+ 295
- 0
src/main/java/com/fxzy/warn/common/conf/MinioConfig.java View File

@ -0,0 +1,295 @@
package com.fxzy.warn.common.conf;
import com.fxzy.warn.common.util.TimeUtil;
import io.minio.MinioClient;
import io.minio.ObjectStat;
import io.minio.PutObjectOptions;
import io.minio.Result;
import io.minio.messages.Bucket;
import io.minio.messages.Item;
import org.apache.commons.lang3.StringUtils;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.util.UriUtils;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@Component
public class MinioConfig implements InitializingBean {
@Value(value = "${minio.bucket}")
private String bucket;
@Value(value = "${minio.host}")
private String host;
@Value(value = "${minio.url}")
private String url;
@Value(value = "${minio.access-key}")
private String accessKey;
@Value(value = "${minio.secret-key}")
private String secretKey;
private MinioClient minioClient;
@Override
public void afterPropertiesSet() throws Exception {
Assert.hasText(url, "Minio url 为空");
Assert.hasText(accessKey, "Minio accessKey为空");
Assert.hasText(secretKey, "Minio secretKey为空");
this.minioClient = new MinioClient(this.host, this.accessKey, this.secretKey);
}
/**
* 上传
*/
public String putObject(MultipartFile multipartFile) throws Exception {
// bucket 不存在创建
if (!minioClient.bucketExists(this.bucket)) {
minioClient.makeBucket(this.bucket);
}
try (InputStream inputStream = multipartFile.getInputStream()) {
// 上传文件的名称
String multipartFileName = StringUtils.isNotBlank(multipartFile.getOriginalFilename()) ? multipartFile.getOriginalFilename() : multipartFile.getName();
String suffix = multipartFileName
.substring(multipartFileName.lastIndexOf("."));//文件后缀
//获取附件上传路径
String fileName = UUID.randomUUID().toString().replace("-", "") + TimeUtil
.formatTimeyyyyMMdd() + suffix;//文件名重新命名避免重复
// PutObjectOptions上传配置(文件大小内存中文件分片大小)
PutObjectOptions putObjectOptions = new PutObjectOptions(multipartFile.getSize(), PutObjectOptions.MIN_MULTIPART_SIZE);
// 文件的ContentType
putObjectOptions.setContentType(multipartFile.getContentType());
minioClient.putObject(this.bucket, fileName, inputStream, putObjectOptions);
// 返回访问路径
return UriUtils.encode(fileName, String.valueOf(StandardCharsets.UTF_8));
}
}
/**
* 上传
*/
public String putObject(MultipartFile multipartFile,String fileName) throws Exception {
// bucket 不存在创建
if (!minioClient.bucketExists(this.bucket)) {
minioClient.makeBucket(this.bucket);
}
try (InputStream inputStream = multipartFile.getInputStream()) {
// 上传文件的名称
String multipartFileName = StringUtils.isNotBlank(multipartFile.getOriginalFilename()) ? multipartFile.getOriginalFilename() : multipartFile.getName();
String suffix = multipartFileName
.substring(multipartFileName.lastIndexOf("."));//文件后缀
//获取附件上传路径
// PutObjectOptions上传配置(文件大小内存中文件分片大小)
PutObjectOptions putObjectOptions = new PutObjectOptions(multipartFile.getSize(), PutObjectOptions.MIN_MULTIPART_SIZE);
// 文件的ContentType
putObjectOptions.setContentType(multipartFile.getContentType());
minioClient.putObject(this.bucket, fileName, inputStream, putObjectOptions);
// 返回访问路径
return UriUtils.encode(fileName, String.valueOf(StandardCharsets.UTF_8));
}
}
/**
* 文件下载
*/
public void download(String fileName, HttpServletResponse response) {
// 从链接中得到文件名
InputStream inputStream;
try {
MinioClient minioClient = new MinioClient(host, accessKey, secretKey);
ObjectStat stat = minioClient.statObject(bucket, fileName);
inputStream = minioClient.getObject(bucket, fileName);
response.setContentType(stat.contentType());
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
IOUtils.copy(inputStream, response.getOutputStream());
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
System.out.println("有异常:" + e);
}
}
/**
* 列出所有存储桶名称
*
* @return
* @throws Exception
*/
public List<String> listBucketNames()
throws Exception {
List<Bucket> bucketList = listBuckets();
List<String> bucketListName = new ArrayList<>();
for (Bucket bucket : bucketList) {
bucketListName.add(bucket.name());
}
return bucketListName;
}
/**
* 查看所有桶
*
* @return
* @throws Exception
*/
public List<Bucket> listBuckets()
throws Exception {
return minioClient.listBuckets();
}
/**
* 检查存储桶是否存在
*
* @param bucketName
* @return
* @throws Exception
*/
public boolean bucketExists(String bucketName) throws Exception {
boolean flag = minioClient.bucketExists(bucketName);
if (flag) {
return true;
}
return false;
}
/**
* 创建存储桶
*
* @param bucketName
* @return
* @throws Exception
*/
public boolean makeBucket(String bucketName)
throws Exception {
boolean flag = bucketExists(bucketName);
if (!flag) {
minioClient.makeBucket(bucketName);
return true;
} else {
return false;
}
}
/**
* 删除桶
*
* @param bucketName
* @return
* @throws Exception
*/
public boolean removeBucket(String bucketName)
throws Exception {
boolean flag = bucketExists(bucketName);
if (flag) {
Iterable<Result<Item>> myObjects = listObjects(bucketName);
for (Result<Item> result : myObjects) {
Item item = result.get();
// 有对象文件则删除失败
if (item.size() > 0) {
return false;
}
}
// 删除存储桶注意只有存储桶为空时才能删除成功
minioClient.removeBucket(bucketName);
flag = bucketExists(bucketName);
if (!flag) {
return true;
}
}
return false;
}
/**
* 列出存储桶中的所有对象
*
* @param bucketName 存储桶名称
* @return
* @throws Exception
*/
public Iterable<Result<Item>> listObjects(String bucketName) throws Exception {
boolean flag = bucketExists(bucketName);
if (flag) {
return minioClient.listObjects(bucketName);
}
return null;
}
/**
* 列出存储桶中的所有对象名称
*
* @param bucketName 存储桶名称
* @return
* @throws Exception
*/
public List<String> listObjectNames(String bucketName) throws Exception {
List<String> listObjectNames = new ArrayList<>();
boolean flag = bucketExists(bucketName);
if (flag) {
Iterable<Result<Item>> myObjects = listObjects(bucketName);
for (Result<Item> result : myObjects) {
Item item = result.get();
listObjectNames.add(item.objectName());
}
}
return listObjectNames;
}
/**
* 删除一个对象
*
* @param bucketName 存储桶名称
* @param objectName 存储桶里的对象名称
* @throws Exception
*/
public boolean removeObject(String bucketName, String objectName) throws Exception {
boolean flag = bucketExists(bucketName);
if (flag) {
List<String> objectList = listObjectNames(bucketName);
for (String s : objectList) {
if (s.equals(objectName)) {
minioClient.removeObject(bucketName, objectName);
return true;
}
}
}
return false;
}
/**
* 文件访问路径
*
* @param bucketName 存储桶名称
* @param objectName 存储桶里的对象名称
* @return
* @throws Exception
*/
public String getObjectUrl(String bucketName, String objectName) throws Exception {
boolean flag = bucketExists(bucketName);
String url = "";
if (flag) {
url = minioClient.getObjectUrl(bucketName, objectName);
}
return url;
}
}

+ 30
- 0
src/main/java/com/fxzy/warn/common/constants/AuthorizationConstants.java View File

@ -0,0 +1,30 @@
package com.fxzy.warn.common.constants;
/**
* @author zhangjing
* @date 2024/12/05 17:35
* @description
*/
public class AuthorizationConstants {
/**
* 用户授权状态常量
*/
// 待申请
public static final int STATUS_PENDING_APPLICATION = 0;
// 待审批
public static final int STATUS_PENDING_APPROVAL = 1;
// 授权有效
public static final int STATUS_AUTHORIZED_VALID = 2;
// 授权过期
public static final int STATUS_AUTHORIZED_EXPIRED = 3;
/**
* 审核状态常量
*/
// 待审核
public static final int AUDIT_STATUS_PENDING = 0;
// 通过
public static final int AUDIT_STATUS_APPROVED = 1;
// 拒绝
public static final int AUDIT_STATUS_REJECTED = 2;
}

+ 2
- 13
src/main/java/com/fxzy/warn/common/constants/EntityConstants.java View File

@ -17,21 +17,10 @@ public class EntityConstants {
public final static Integer DEL = 1;
/**
* 此处为冯海磊设置的常量
* 为状态量时 (0-正常,1-停用)
* 为is开头的是否值时 (0-,1-)
* 是否上架
*/
public final static Integer HL_YES = 0;
public final static Integer HL_NO = 1;
public final static Integer IS_ONLINE = 1;
/**
* 用户类型0默认 1:市级2区县3企业4群众
*/
public final static Integer USER_TYPE_DEFAULT = 0;
public final static Integer USER_TYPE_CITY = 1;
public final static Integer USER_TYPE_AREA = 2;
public final static Integer USER_TYPE_UNIT = 3;
public final static Integer USER_TYPE_PUBLIC = 4;
}

+ 3
- 3
src/main/java/com/fxzy/warn/common/constants/RedisKeyConstants.java View File

@ -9,15 +9,15 @@ package com.fxzy.warn.common.constants;
public class RedisKeyConstants {
/**用户是否锁定key*/
public final static String USER_LOCK_KEY = "gas_apportal:user:lock:";
public final static String USER_LOCK_KEY = "fxzy_warn:user:lock:";
/**登录ST*/
public final static String LOGIN_ST = "gas_wx:login:st:";
public final static String LOGIN_ST = "fxzy_warn:login:st:";
public final static String LOGIN_ST_HEADER = "ST-";
/**登录随机数验证码*/
public final static String LOGIN_RANDOM_CAPTCHA = "gas_apportal:login:random:captcha-";
public final static String LOGIN_RANDOM_CAPTCHA = "fxzy_warn:login:random:captcha-";
/**登录随机数验证码图片类型*/
public final static String LOGIN_RANDOM_CAPTCHA_IMG_TYPE = ".jpg";

+ 2
- 1
src/main/java/com/fxzy/warn/common/constants/ResponseMsgConstants.java View File

@ -30,7 +30,8 @@ public class ResponseMsgConstants {
public final static String OPERATE_FAIL = "操作失败";
public final static String CODE_SENT_SUCCESSFULLY = "验证码已发送";
public final static String CODE_EXPIRED_PLEASE_RESEND = "验证码已失效,请重新发送";
public final static String CODE_EXPIRED_PLEASE_RESEND = "验证码已过期,请重新发送";
public final static String CODE_ERROR = "验证码错误";
public final static String USER_PHONE_EXIST = "该手机号已存在";
public final static String OPERATE_SYS_ERROR = "系统异常";

+ 4
- 1
src/main/java/com/fxzy/warn/common/response/ApiResponse.java View File

@ -51,10 +51,13 @@ public class ApiResponse implements Serializable {
}
public void recordError(String error) {
this.code = 500;
this.message = error;
}
public void recordMsgError(String error) {
this.code = 999;
this.message = error;
}
public int getCode() {
return code;
}

+ 101
- 79
src/main/java/com/fxzy/warn/common/util/JWTUtil.java View File

@ -5,6 +5,7 @@ package com.fxzy.warn.common.util;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.fxzy.warn.model.User;
import com.nimbusds.jose.*;
import com.nimbusds.jose.crypto.MACSigner;
import com.nimbusds.jose.crypto.MACVerifier;
@ -66,38 +67,38 @@ public class JWTUtil {
}
// public String creatToken(WxUserVO user, String publicKey) throws JOSEException {
// if (null == user || StringUtils.isBlank(publicKey)) {
// return null;
// }
// //3.先建立一个头部Header
// /**
// * JWSHeader参数1.加密算法法则,2.类型3.
// * 一般只需要传入加密算法法则就可以
// * 这里则采用HS256
// *
// * JWSAlgorithm类里面有所有的加密算法法则直接调用
// */
// JWSHeader jwsHeader = new JWSHeader(JWSAlgorithm.HS256);
//
// Map<String, Object> payloadMap = createPayloadMap(user);
//
// //建立一个载荷Payload
// Payload payload = new Payload(new JSONObject(payloadMap));
//
// //将头部和载荷结合在一起
// JWSObject jwsObject = new JWSObject(jwsHeader, payload);
//
// //建立一个密匙
//
// JWSSigner jwsSigner = new MACSigner(publicKey.getBytes());
//
// //签名
// jwsObject.sign(jwsSigner);
//
// //生成token
// return jwsObject.serialize();
// }
public String creatToken(User user, String publicKey) throws JOSEException {
if (null == user || StringUtils.isBlank(publicKey)) {
return null;
}
//3.先建立一个头部Header
/**
* JWSHeader参数1.加密算法法则,2.类型3.
* 一般只需要传入加密算法法则就可以
* 这里则采用HS256
*
* JWSAlgorithm类里面有所有的加密算法法则直接调用
*/
JWSHeader jwsHeader = new JWSHeader(JWSAlgorithm.HS256);
Map<String, Object> payloadMap = createPayloadMap(user);
//建立一个载荷Payload
Payload payload = new Payload(new JSONObject(payloadMap));
//将头部和载荷结合在一起
JWSObject jwsObject = new JWSObject(jwsHeader, payload);
//建立一个密匙
JWSSigner jwsSigner = new MACSigner(publicKey.getBytes());
//签名
jwsObject.sign(jwsSigner);
//生成token
return jwsObject.serialize();
}
/**
* 根据token解析当前登陆者信息
@ -105,28 +106,25 @@ public class JWTUtil {
/**
* 根据token解析当前登陆者信息
*/
// public WxUserVO getUserByToken(String token) {
//
// if (StringUtils.isBlank(token)) {
// return null;
// }
// WxUserVO user = null;
// try {
// JWSObject jwsObject = JWSObject.parse(token);
// //获取到载荷
// Payload payload = jwsObject.getPayload();
// JSONObject jsonObject = payload.toJSONObject();
// String result = jsonObject.toString();
// user = com.alibaba.fastjson.JSONObject.parseObject(result, WxUserVO.class);
// if (StringUtils.isNotBlank(user.getId())) {
// String userId = user.getId();
// user.setId(userId.substring(0, userId.length() - 14));
// }
// } catch (ParseException e) {
// e.printStackTrace();
// }
// return user;
// }
public User getUserByToken(String token) {
if (StringUtils.isBlank(token)) {
return null;
}
User user = null;
try {
JWSObject jwsObject = JWSObject.parse(token);
//获取到载荷
Payload payload = jwsObject.getPayload();
JSONObject jsonObject = payload.toJSONObject();
String result = jsonObject.toString();
user = com.alibaba.fastjson.JSONObject.parseObject(result, User.class);
} catch (ParseException e) {
e.printStackTrace();
}
return user;
}
/**
@ -157,31 +155,55 @@ public class JWTUtil {
return success;
}
// public Map<String, Object> createPayloadMap(WxUserVO user) {
// Map<String, Object> payloadMap = new HashMap<>(16);
// if (StringUtils.isNotBlank(user.getId())) {
// payloadMap.put("id", user.getId() + TimeUtil.formatDateToTime(new Date()));
// }
// if (StringUtils.isNotBlank(user.getNodeCode())) {
// payloadMap.put("nodeCode", user.getNodeCode());
// }
// if (StringUtils.isNotBlank(user.getUserName())) {
// payloadMap.put("username", user.getUserName());
// }
// if (StringUtils.isNotBlank(user.getMobilePhone())) {
// payloadMap.put("mobilePhone", user.getMobilePhone());
// }
// if (null!=user.getEnterpriseId()) {
// payloadMap.put("enterpriseId", user.getEnterpriseId());
// }
// if (null!=user.getUserIdentity()) {
// payloadMap.put("userIdentity", user.getUserIdentity());
// }
// if (StringUtils.isNotBlank(user.getOpenId())) {
// payloadMap.put("openId", user.getOpenId());
// }
// return payloadMap;
// }
public Map<String, Object> createPayloadMap(User user) {
Map<String, Object> payloadMap = new HashMap<>(16);
if (user.getId()!=null) {
payloadMap.put("id", user.getId());
}
if (StringUtils.isNotBlank(user.getCompanyName())) {
payloadMap.put("companyName", user.getCompanyName());
}
if (StringUtils.isNotBlank(user.getCreditCode())) {
payloadMap.put("creditCode", user.getCreditCode());
}
if (StringUtils.isNotBlank(user.getLegalPerson())) {
payloadMap.put("legalPerson", user.getLegalPerson());
}
if (StringUtils.isNotBlank(user.getPhoneNumber())) {
payloadMap.put("phoneNumber", user.getPhoneNumber());
}
if (StringUtils.isNotBlank(user.getEmail())) {
payloadMap.put("email", user.getEmail());
}
if (StringUtils.isNotBlank(user.getProvince())) {
payloadMap.put("province", user.getProvince());
}
if (StringUtils.isNotBlank(user.getCity())) {
payloadMap.put("city", user.getCity());
}
if (StringUtils.isNotBlank(user.getDistrict())) {
payloadMap.put("district", user.getDistrict());
}
if (StringUtils.isNotBlank(user.getDetailedAddress())) {
payloadMap.put("detailedAddress", user.getDetailedAddress());
}
if (StringUtils.isNotBlank(user.getBusinessPerson())) {
payloadMap.put("businessPerson", user.getBusinessPerson());
}
if (StringUtils.isNotBlank(user.getRemarks())) {
payloadMap.put("remarks", user.getRemarks());
}
if (user.getAuthorizationId()!=null) {
payloadMap.put("authorizationId", user.getAuthorizationId());
}
if (user.getIsOfficialAccount()!=null) {
payloadMap.put("isOfficialAccount", user.getIsOfficialAccount());
}
if (user.getAuthorizationStatus()!=null) {
payloadMap.put("authorizationStatus", user.getAuthorizationStatus());
}
return payloadMap;
}

+ 97
- 0
src/main/java/com/fxzy/warn/controller/AuthorizationController.java View File

@ -0,0 +1,97 @@
package com.fxzy.warn.controller;
import com.alibaba.fastjson.JSONObject;
import com.fxzy.warn.common.constants.ResponseMsgConstants;
import com.fxzy.warn.common.request.RequestParameter;
import com.fxzy.warn.common.response.ApiResponse;
import com.fxzy.warn.model.Authorization;
import com.fxzy.warn.model.User;
import com.fxzy.warn.service.AuthorizationService;
import com.fxzy.warn.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Objects;
/**
* @author zhangjing
* @date 2024/05/21 11:22
* @description
*/
@Api(tags = "用户授权")
@RestController
@RequestMapping("authorization/")
@Slf4j
public class AuthorizationController {
@Resource
private AuthorizationService authorizationService ;
@RequestMapping(value = "save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ApiOperation(value = "创建授权信息")
public ApiResponse save(@ApiParam("{\n" +
"\"startDate\":\"授权开始日期\",\n" +
"\"endDate\":\"授权截止日期\",\n" +
"\"fileId\":\"授权书id\",\n" +
"\"email\":\"邮箱\"\n" +
"\"queryCount\":\"风险查询次数\"\n" +
"}") @RequestBody Authorization entity, String ticket) {
ApiResponse response = new ApiResponse();
try {
return authorizationService.saveModel(entity,ticket);
} catch (Exception e) {
response.recordError(ResponseMsgConstants.OPERATE_FAIL);
}
return response;
}
@RequestMapping(value = "applyFor", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ApiOperation(value = "申请")
public ApiResponse applyFor(@ApiParam("{\n" +
"\"authorizationId\":\"授权信息id\",\n" +
"\"id\":\"申请的id\",\n" +
"}") @RequestBody JSONObject jsonObject, String ticket) {
ApiResponse response = new ApiResponse();
try {
return authorizationService.applyFor(jsonObject,ticket);
} catch (Exception e) {
response.recordError(ResponseMsgConstants.OPERATE_FAIL);
}
return response;
}
@RequestMapping(value = "approve", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ApiOperation(value = "审批")
public ApiResponse approve(@ApiParam("{\n" +
"\"content\":\"审批内容\",\n" +
"\"statusCode\":\"1通过2拒绝\",\n" +
"}") @RequestBody JSONObject jsonObject, String ticket) {
ApiResponse response = new ApiResponse();
try {
return authorizationService.approve(jsonObject,ticket);
} catch (Exception e) {
response.recordError(ResponseMsgConstants.OPERATE_FAIL);
}
return response;
}
@RequestMapping(value = "queryPage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "授权审批分页查询")
public ApiResponse queryPage(@ApiParam() @RequestBody RequestParameter parameter) {
ApiResponse apiResponse = new ApiResponse();
try {
apiResponse.setData(authorizationService.queryPage(parameter));
apiResponse.setMessage(ResponseMsgConstants.OPERATE_SUCCESS);
} catch (Exception e) {
apiResponse.recordError(ResponseMsgConstants.OPERATE_FAIL);
}
return apiResponse;
}
}

+ 99
- 0
src/main/java/com/fxzy/warn/controller/FileController.java View File

@ -0,0 +1,99 @@
package com.fxzy.warn.controller;
import com.fxzy.warn.common.conf.MinioConfig;
import com.fxzy.warn.common.response.ApiResponse;
import com.fxzy.warn.service.FileService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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 org.springframework.web.multipart.MultipartFile;
@Api(tags = "文件上传")
@RestController
@Slf4j
@RequestMapping("/file")
public class FileController {
@Autowired
MinioConfig minioConfig;
@Autowired
FileService fileService;
/**
* 上传
* @param file
* @return
* @throws Exception
*/
@PostMapping("/upload")
public Object upload(@RequestParam("file") MultipartFile file) throws Exception {
log.info("附件,上传 ==== 参数{" + file + "}");
ApiResponse apiResponse = new ApiResponse();
if (!file.isEmpty()) {
try {
apiResponse = fileService.uploadFile(file);
} catch (Exception e) {
log.error("附件上传失败,errMsg==={" + e.getMessage() + "}");
e.printStackTrace();
}
} else {
apiResponse.recordError("请至少上传一个文件!");
}
return apiResponse;
}
// // 文件访问路径
// @PostMapping("/getObjectUrl")
// public String getObjectUrl(String bucketName, String objectName) throws Exception {
// return this.minioConfig.getObjectUrl(bucketName, objectName);
// }
//
//
// // 下载文件
// @GetMapping("/download")
// public void download(@RequestParam("fileName") String fileName, HttpServletResponse response) {
// this.minioConfig.download(fileName, response);
// }
//
// // 列出所有存储桶名称
// @PostMapping("/list")
// public List<String> list() throws Exception {
// return this.minioConfig.listBucketNames();
// }
//
// // 创建存储桶
// @PostMapping("/createBucket")
// public boolean createBucket(String bucketName) throws Exception {
// return this.minioConfig.makeBucket(bucketName);
// }
//
// // 删除存储桶
// @PostMapping("/deleteBucket")
// public boolean deleteBucket(String bucketName) throws Exception {
// return this.minioConfig.removeBucket(bucketName);
// }
//
// // 列出存储桶中的所有对象名称
// @PostMapping("/listObjectNames")
// public List<String> listObjectNames(String bucketName) throws Exception {
// return this.minioConfig.listObjectNames(bucketName);
// }
//
// // 删除一个对象
// @PostMapping("/removeObject")
// public boolean removeObject(String bucketName, String objectName) throws Exception {
// return this.minioConfig.removeObject(bucketName, objectName);
// }
}

+ 101
- 0
src/main/java/com/fxzy/warn/controller/MonitorUsersController.java View File

@ -0,0 +1,101 @@
package com.fxzy.warn.controller;
import com.alibaba.fastjson.JSONObject;
import com.fxzy.warn.common.constants.ResponseMsgConstants;
import com.fxzy.warn.common.request.RequestParameter;
import com.fxzy.warn.common.response.ApiResponse;
import com.fxzy.warn.model.MonitorUsers;
import com.fxzy.warn.service.MonitorUsersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
/**
* @author zhangjing
* @date 2024/05/21 11:22
* @description
*/
@Api(tags = "监控用户")
@RestController
@RequestMapping("monitorUsers/")
@Slf4j
public class MonitorUsersController {
@Resource
private MonitorUsersService monitorUsersService ;
@RequestMapping(value = "save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ApiOperation(value = "创建用户")
public ApiResponse save(@ApiParam("{\n" +
"\"companyName\":\"企业名称\",\n" +
"\"creditCode\":\"统一社会信用代码\",\n" +
"\"legalPerson\":\"企业法人\",\n" +
"\"address\":\"地址\"\n" +
"\"authorizationId\":\"授权书id\"\n" +
"}") @RequestBody MonitorUsers entity, @RequestHeader String ticket) {
ApiResponse response = new ApiResponse();
try {
return monitorUsersService.saveModel(entity,ticket);
} catch (Exception e) {
response.recordError(ResponseMsgConstants.OPERATE_FAIL);
}
return response;
}
/**
* 修改
*
* @param
* @return
*/
@ResponseBody
@ApiOperation(value = "修改")
@RequestMapping(value = "edit", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ApiResponse edit(@ApiParam() @RequestBody MonitorUsers entity,@RequestHeader String ticket) {
log.info("修改==== 参数{" + entity != null ? entity.toString() : "null" + "}");
ApiResponse response = new ApiResponse();
try {
return monitorUsersService.updateModel(entity,ticket);
} catch (Exception e) {
response.recordError(ResponseMsgConstants.OPERATE_FAIL);
}
return response;
}
/**
* 通过ids删除
*
* @param
* @return
*/
@ResponseBody
@ApiOperation(value = "删除")
@RequestMapping(value = "remove", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ApiResponse remove(@ApiParam("{\"ids\":[\"1\",\"2\"]}") @RequestBody JSONObject jsonObject) {
ApiResponse apiResponse = new ApiResponse();
try {
return monitorUsersService.deleteModel(jsonObject.getJSONArray("ids").toJavaList(String.class));
} catch (Exception e) {
apiResponse.recordError(ResponseMsgConstants.OPERATE_FAIL);
}
return apiResponse;
}
@RequestMapping(value = "queryPage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "分页查询")
public ApiResponse queryPage(@ApiParam() @RequestBody RequestParameter parameter) {
ApiResponse apiResponse = new ApiResponse();
try {
apiResponse.setData(monitorUsersService.queryPage(parameter));
apiResponse.setMessage(ResponseMsgConstants.OPERATE_SUCCESS);
} catch (Exception e) {
apiResponse.recordError(ResponseMsgConstants.OPERATE_FAIL);
}
return apiResponse;
}
}

+ 126
- 0
src/main/java/com/fxzy/warn/controller/PolicyManagementController.java View File

@ -0,0 +1,126 @@
package com.fxzy.warn.controller;
import com.alibaba.fastjson.JSONObject;
import com.fxzy.warn.common.constants.ResponseMsgConstants;
import com.fxzy.warn.common.request.RequestParameter;
import com.fxzy.warn.common.response.ApiResponse;
import com.fxzy.warn.model.PolicyManagement;
import com.fxzy.warn.service.PolicyManagementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @author zhangjing
* @date 2024/05/21 11:22
* @description
*/
@Api(tags = "政策管理:用户协议,隐私,关于我们")
@RestController
@RequestMapping("policyManagement/")
@Slf4j
public class PolicyManagementController {
@Resource
private PolicyManagementService policyManagementService ;
@RequestMapping(value = "save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ApiOperation(value = "创建用户")
public ApiResponse save(@ApiParam("{\n" +
"\"version\":\"政策版本\",\n" +
"\"content\":\"政策内容(富文本)\",\n" +
"\"contentType\":\"政策类型 0用户协议管理1隐私政策管理2关于我们管理\",\n" +
"}") @RequestBody PolicyManagement entity, @RequestHeader String ticket) {
ApiResponse response = new ApiResponse();
try {
return policyManagementService.saveModel(entity,ticket);
} catch (Exception e) {
response.recordError(ResponseMsgConstants.OPERATE_FAIL);
}
return response;
}
/**
* 修改
*
* @param
* @return
*/
@ResponseBody
@ApiOperation(value = "修改")
@RequestMapping(value = "edit", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ApiResponse edit(@ApiParam() @RequestBody PolicyManagement entity,@RequestHeader String ticket) {
log.info("修改==== 参数{" + entity != null ? entity.toString() : "null" + "}");
ApiResponse response = new ApiResponse();
try {
return policyManagementService.updateModel(entity,ticket);
} catch (Exception e) {
response.recordError(ResponseMsgConstants.OPERATE_FAIL);
}
return response;
}
/**
* 通过ids删除
*
* @param
* @return
*/
@ResponseBody
@ApiOperation(value = "删除")
@RequestMapping(value = "remove", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ApiResponse remove(@ApiParam("{\"ids\":[\"1\",\"2\"]}") @RequestBody JSONObject jsonObject) {
ApiResponse apiResponse = new ApiResponse();
try {
return policyManagementService.deleteModel(jsonObject.getJSONArray("ids").toJavaList(String.class));
} catch (Exception e) {
apiResponse.recordError(ResponseMsgConstants.OPERATE_FAIL);
}
return apiResponse;
}
/**
* 通过ids删除
*
* @param
* @return
*/
@RequestMapping(value = "getPolicy", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ApiOperation(value = "获取当前政策")
public ApiResponse getPolicy(String contentType) {
ApiResponse apiResponse = new ApiResponse();
try {
return policyManagementService.getPolicy(contentType);
} catch (Exception e) {
log.error("查询错误,errMsg==={}", e.getMessage());
e.printStackTrace();
apiResponse.recordError(ResponseMsgConstants.OPERATE_FAIL);
}
return apiResponse;
}
/**
* 分页查询
*
* @param
* @return
*/
@RequestMapping(value = "queryPage", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "分页查询")
public ApiResponse queryPage(@ApiParam("{\n" +
"\"contentType\":\"政策类型 0用户协议管理1隐私政策管理2关于我们管理\",\n" +
"}") @RequestBody RequestParameter parameter) {
ApiResponse apiResponse = new ApiResponse();
try {
apiResponse.setData(policyManagementService.queryPage(parameter));
apiResponse.setMessage(ResponseMsgConstants.OPERATE_SUCCESS);
} catch (Exception e) {
apiResponse.recordError(ResponseMsgConstants.OPERATE_FAIL);
}
return apiResponse;
}
}

+ 14
- 0
src/main/java/com/fxzy/warn/mapper/AuditRecordsMapper.java View File

@ -0,0 +1,14 @@
package com.fxzy.warn.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fxzy.warn.model.AuditRecords;
import org.apache.ibatis.annotations.Mapper;
/**
* @author zhangjing
* @date 2024/12/04 14:48
* @description
*/
@Mapper
public interface AuditRecordsMapper extends BaseMapper<AuditRecords> {
}

+ 14
- 0
src/main/java/com/fxzy/warn/mapper/AuthorizationMapper.java View File

@ -0,0 +1,14 @@
package com.fxzy.warn.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fxzy.warn.model.Authorization;
import org.apache.ibatis.annotations.Mapper;
/**
* @author zhangjing
* @date 2024/12/04 14:48
* @description
*/
@Mapper
public interface AuthorizationMapper extends BaseMapper<Authorization> {
}

+ 28
- 0
src/main/java/com/fxzy/warn/mapper/FileMapper.java View File

@ -0,0 +1,28 @@
package com.fxzy.warn.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fxzy.warn.model.File;
import com.fxzy.warn.model.vo.FileVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author yuyantian
* @Date 2021/09/09 14:00
*/
@Mapper
public interface FileMapper extends BaseMapper<File> {
File findFileList(@Param("id") Long appLogoId);
/**
* 查询附件
* @param fileIds
* @return
*/
List<FileVO> selectByFileIds(@Param("fileIds") List<Object> fileIds);
}

+ 14
- 0
src/main/java/com/fxzy/warn/mapper/MonitorUsersMapper.java View File

@ -0,0 +1,14 @@
package com.fxzy.warn.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fxzy.warn.model.MonitorUsers;
import org.apache.ibatis.annotations.Mapper;
/**
* @author zhangjing
* @date 2024/12/04 14:48
* @description
*/
@Mapper
public interface MonitorUsersMapper extends BaseMapper<MonitorUsers> {
}

+ 14
- 0
src/main/java/com/fxzy/warn/mapper/PolicyManagementMapper.java View File

@ -0,0 +1,14 @@
package com.fxzy.warn.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fxzy.warn.model.PolicyManagement;
import org.apache.ibatis.annotations.Mapper;
/**
* @author zhangjing
* @date 2024/12/04 14:48
* @description
*/
@Mapper
public interface PolicyManagementMapper extends BaseMapper<PolicyManagement> {
}

+ 71
- 0
src/main/java/com/fxzy/warn/model/AuditRecords.java View File

@ -0,0 +1,71 @@
package com.fxzy.warn.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author zhangjing
* @date 2024/12/04 20:09
* @description
*/
@Data
@TableName("t_audit_records")
public class AuditRecords extends Model<AuditRecords> {
/**
* id
*/
@ApiModelProperty("id")
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 授权开始日期
*/
@ApiModelProperty("提价和审核时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date auditDate;
/**
* 审核人员id
*/
@ApiModelProperty("审核人员id")
private Integer auditUserId;
/**
* 审核人员名字
*/
@ApiModelProperty("审核人员名字")
private String auditUserName;
/**
* 申请人员id
*/
@ApiModelProperty("申请人员id")
private Integer userId;
/**
* 申请人员名字
*/
@ApiModelProperty("申请人员名字")
private String userName;
/**
* 审批内容
*/
@ApiModelProperty("审批内容")
private String content;
/**
* 业务关联授权书id
*/
@ApiModelProperty("业务关联授权书id")
private Integer businessId;
/**
* 审核状态0待审核1通过2拒绝
*/
@ApiModelProperty("审核状态0待审核1通过2拒绝")
private Integer statusCode;
}

+ 26
- 7
src/main/java/com/fxzy/warn/model/Authorization.java View File

@ -3,9 +3,12 @@ package com.fxzy.warn.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author zhangjing
* @date 2024/12/04 20:09
@ -20,16 +23,32 @@ public class Authorization extends BaseField{
@ApiModelProperty("id")
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 授权开始日期
*/
@ApiModelProperty("授权开始日期")
private String startDate;
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private Date startDate;
/**
* 授权截止日期
*/
@ApiModelProperty("授权截止日期")
private String endDate;
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private Date endDate;
/**
* 授权书id
*/
@ApiModelProperty("授权书id")
private String fileId;
private Integer fileId;
/**
* 风险查询次数
*/
@ApiModelProperty("风险查询次数")
private Integer queryCount;
/**
* 被授权人
*/
@ApiModelProperty("被授权人")
private Integer userId;
}

+ 99
- 0
src/main/java/com/fxzy/warn/model/File.java View File

@ -0,0 +1,99 @@
package com.fxzy.warn.model;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* @author yuyantian
* @Date 2022/06/10 14:00
*/
@ApiModel("附件表")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("t_file")
public class File extends Model<File> {
/**
* id
*/
@ApiModelProperty("id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 物理路径
*/
@ApiModelProperty("物理路径")
@TableField(value = "file_path")
private String filePath;
/**
* 图片类型
*/
@ApiModelProperty("图片类型")
@TableField(value = "image_type")
private String imageType;
/**
* 文件名称
*/
@ApiModelProperty("文件名称")
@TableField(value = "file_name")
private String fileName;
/**
* 文件大小
*/
@ApiModelProperty("文件大小")
@TableField(value = "file_size")
private Integer fileSize;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@ApiModelProperty("创建时间")
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
/**
* 修改时间
*/
@ApiModelProperty("修改时间")
@TableField(value = "update_time", fill = FieldFill.UPDATE)
private Date updateTime;
/**
* 创建人
*/
@ApiModelProperty("创建人")
@TableField(value = "creator_id", fill = FieldFill.INSERT)
private Integer creatorId;
/**
* 修改人
*/
@ApiModelProperty("修改人")
@TableField(value = "updater_id", fill = FieldFill.UPDATE)
private Integer updaterId;
/**
* 是否删除
*/
@ApiModelProperty("是否删除")
@TableField(value = "is_del")
private Integer isDel;
/**
* url
*/
@ApiModelProperty("url")
@TableField(value = "url")
private String url;
@TableField(exist = false)
private String relUrl;
}

+ 49
- 0
src/main/java/com/fxzy/warn/model/MonitorUsers.java View File

@ -0,0 +1,49 @@
package com.fxzy.warn.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 监控用户
* @author zhangjing
* @date 2024/12/05 14:07
* @description
*/
@Data
@TableName("t_monitor_users")
public class MonitorUsers extends BaseField{
/**
* id
*/
@ApiModelProperty("id")
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 企业名称
*/
@ApiModelProperty("企业名称")
private String companyName;
/**
* 统一社会信用代码
*/
@ApiModelProperty("统一社会信用代码")
private String creditCode;
/**
* 企业法人
*/
@ApiModelProperty("企业法人")
private String legalPerson;
/**
* 地址
*/
@ApiModelProperty("地址")
private String address;
/**
* 授权书id
*/
@ApiModelProperty("授权书id")
private Integer authorizationId;
}

+ 47
- 0
src/main/java/com/fxzy/warn/model/PolicyManagement.java View File

@ -0,0 +1,47 @@
package com.fxzy.warn.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author zhangjing
* @date 2024/12/04 20:09
* @description
*/
@Data
@TableName("t_policy_management")
public class PolicyManagement extends BaseField{
/**
* id
*/
@ApiModelProperty("id")
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 政策内容
*/
@ApiModelProperty("政策版本")
private String version;
/**
* 政策内容
*/
@ApiModelProperty("政策内容")
private String content;
/**
* 风险查询次数
*/
@ApiModelProperty("政策类型 0用户协议管理1隐私政策管理2关于我们管理")
private Integer contentType;
/**
* 是否上架
*/
@ApiModelProperty("是否上架 0否1是")
private Integer isOnline;
}

+ 2
- 2
src/main/java/com/fxzy/warn/model/Test.java View File

@ -9,8 +9,8 @@ import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @author yuyantian
* @date 2023/10/16 18:09
* @author zhangjing
* @date 2024/10/16 18:09
* @description
*/

+ 76
- 14
src/main/java/com/fxzy/warn/model/User.java View File

@ -1,11 +1,15 @@
package com.fxzy.warn.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author zhangjing
* @date 2024/12/04 14:27
@ -26,40 +30,98 @@ public class User extends BaseField{
*/
@ApiModelProperty("企业名称")
private String companyName;
/**
* 统一社会信用代码
*/
@ApiModelProperty("统一社会信用代码")
private String creditCode;
/**
* 企业法人
*/
@ApiModelProperty("企业法人")
private String legalPerson;
/**
* 手机号
*/
@ApiModelProperty("手机号")
private String phoneNumber;
/**
* 邮箱
*/
@ApiModelProperty("邮箱")
private String email;
/**
* 所在省
*/
@ApiModelProperty("所在省")
private String province;
/**
* 所在市
*/
@ApiModelProperty("所在市")
private String city;
/**
* 所在区
*/
@ApiModelProperty("所在区")
private String district;
/**
* 详细地址
*/
@ApiModelProperty("详细地址")
private String detailedAddress;
/**
* 商务负责人
*/
@ApiModelProperty("商务负责人")
private String businessPerson;
/**
* 备注
*/
@ApiModelProperty("备注")
private String remarks;
/**
* 授权id
*/
@ApiModelProperty("授权id")
private int authorizationId;
private Integer authorizationId;
/**
* 是否为正式账号
*/
@ApiModelProperty("是否为正式账号")
private int isOfficialAccount;
private Integer isOfficialAccount;
/**
* 密码
*/
@ApiModelProperty("密码")
private String password;
/**
* 授权状态 0待申请1待审批2授权有效3授权过期
*/
@ApiModelProperty("授权状态 0待申请1待审批2授权有效3授权过期")
private Integer authorizationStatus;
/**
* 授权开始日期
*/
@TableField(exist = false)
@ApiModelProperty("授权开始日期")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private Date startDate;
/**
* 授权截止日期
*/
@TableField(exist = false)
@ApiModelProperty("授权截止日期")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private Date endDate;
/**
* 授权书
*/
@TableField(exist = false)
@ApiModelProperty("授权书")
private File file;
}

+ 30
- 0
src/main/java/com/fxzy/warn/model/vo/FileVO.java View File

@ -0,0 +1,30 @@
package com.fxzy.warn.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author yuyantian
* @date 2022/6/10
* @description
*/
@Data
public class FileVO {
/**
* id
*/
@ApiModelProperty("id")
private Integer id;
/**
* 物理路径
*/
@ApiModelProperty("物理路径")
private String url;
/**
* 文件名称
*/
@ApiModelProperty("文件名称")
private String name;
}

+ 54
- 0
src/main/java/com/fxzy/warn/service/AuditRecordsService.java View File

@ -0,0 +1,54 @@
package com.fxzy.warn.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fxzy.warn.common.request.RequestParameter;
import com.fxzy.warn.common.response.ApiResponse;
import com.fxzy.warn.model.AuditRecords;
import java.util.List;
/**
* @author zhangjing
* @date 2023/10/16 18:17
* @description
*/
public interface AuditRecordsService extends IService<AuditRecords> {
/**
* 保存
* @param entity
* @return
*/
void saveModel(AuditRecords entity,String ticket);
/**
* 修改
* @param entity
* @return
*/
void updateModel(AuditRecords entity,String ticket);
/**
* 删除
* @param
* @return
*/
void deleteModel(Integer businessId);
/**
* 获取当前审核状态
* @param
* @return
*/
AuditRecords getNowRecord(Integer businessId);
/**
* 分页查询
* @param parameter
* @return
*/
Page<AuditRecords> queryPage(RequestParameter parameter);
}

+ 60
- 0
src/main/java/com/fxzy/warn/service/AuthorizationService.java View File

@ -0,0 +1,60 @@
package com.fxzy.warn.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fxzy.warn.common.request.RequestParameter;
import com.fxzy.warn.common.response.ApiResponse;
import com.fxzy.warn.model.Authorization;
import com.fxzy.warn.model.User;
/**
* @author zhangjing
* @date 2023/10/16 18:17
* @description
*/
public interface AuthorizationService extends IService<Authorization> {
/**
* 保存
* @param entity
* @return
*/
ApiResponse saveModel(Authorization entity,String ticket);
/**
* 修改
* @param entity
* @return
*/
boolean updateModel(Authorization entity);
/**
* 删除
* @param entity
* @return
*/
boolean deleteModel(Authorization entity);
/**
* 分页查询
* @param parameter
* @return
*/
Page<User> queryPage(RequestParameter parameter);
/**
* 申请
* @param jsonObject
* @return
*/
ApiResponse applyFor(JSONObject jsonObject , String ticket);
/**
* 审批
* @param jsonObject
* @return
*/
ApiResponse approve(JSONObject jsonObject , String ticket);
}

+ 39
- 0
src/main/java/com/fxzy/warn/service/FileService.java View File

@ -0,0 +1,39 @@
package com.fxzy.warn.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fxzy.warn.common.response.ApiResponse;
import com.fxzy.warn.model.File;
import com.fxzy.warn.model.vo.FileVO;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* @author yuyantian
* @Date 2021/09/09 14:00
*/
public interface FileService extends IService<File> {
/**
* 附件上传
*/
ApiResponse uploadFile(MultipartFile file);
/**
* 附件上传
*/
File uploadFile2File(MultipartFile file);
/**
* 通过附件id查询附件信息
*
* @param fileIds
* @return
*/
List<FileVO> selectByFileIds(List<Object> fileIds);
}

+ 48
- 0
src/main/java/com/fxzy/warn/service/MonitorUsersService.java View File

@ -0,0 +1,48 @@
package com.fxzy.warn.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fxzy.warn.common.request.RequestParameter;
import com.fxzy.warn.common.response.ApiResponse;
import com.fxzy.warn.model.MonitorUsers;
import java.util.List;
/**
* @author zhangjing
* @date 2023/10/16 18:17
* @description
*/
public interface MonitorUsersService extends IService<MonitorUsers> {
/**
* 保存
* @param entity
* @return
*/
ApiResponse saveModel(MonitorUsers entity,String ticket);
/**
* 修改
* @param entity
* @return
*/
ApiResponse updateModel(MonitorUsers entity,String ticket);
/**
* 删除
* @param ids
* @return
*/
ApiResponse deleteModel(List<String> ids);
/**
* 分页查询
* @param parameter
* @return
*/
Page<MonitorUsers> queryPage(RequestParameter parameter);
}

+ 55
- 0
src/main/java/com/fxzy/warn/service/PolicyManagementService.java View File

@ -0,0 +1,55 @@
package com.fxzy.warn.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fxzy.warn.common.request.RequestParameter;
import com.fxzy.warn.common.response.ApiResponse;
import com.fxzy.warn.model.PolicyManagement;
import java.util.List;
/**
* @author zhangjing
* @date 2023/10/16 18:17
* @description
*/
public interface PolicyManagementService extends IService<PolicyManagement> {
/**
* 保存
* @param entity
* @return
*/
ApiResponse saveModel(PolicyManagement entity,String ticket);
/**
* 修改
* @param entity
* @return
*/
ApiResponse updateModel(PolicyManagement entity,String ticket);
/**
* 删除
* @param ids
* @return
*/
ApiResponse deleteModel(List<String> ids);
/**
* 当前政策
* @param contentType
* @return
*/
ApiResponse getPolicy(String contentType);
/**
* 分页查询
* @param parameter
* @return
*/
Page<PolicyManagement> queryPage(RequestParameter parameter);
}

+ 8
- 0
src/main/java/com/fxzy/warn/service/UserService.java View File

@ -73,4 +73,12 @@ public interface UserService extends IService {
* @return
*/
Page<User> queryPage(RequestParameter parameter);
/**
* 获取人员企业身份
*
* @param
* @return
*/
User getUserByTicket(String ticket);
}

+ 65
- 0
src/main/java/com/fxzy/warn/service/impl/AuditRecordsServiceImpl.java View File

@ -0,0 +1,65 @@
package com.fxzy.warn.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fxzy.warn.common.constants.EntityConstants;
import com.fxzy.warn.common.request.RequestParameter;
import com.fxzy.warn.common.response.ApiResponse;
import com.fxzy.warn.mapper.AuditRecordsMapper;
import com.fxzy.warn.model.AuditRecords;
import com.fxzy.warn.service.AuditRecordsService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author zhangjing
* @date 2023/10/16 18:17
* @description
*/
@Service
public class AuditRecordsServiceImpl extends ServiceImpl<AuditRecordsMapper, AuditRecords> implements
AuditRecordsService {
@Override
public void saveModel(AuditRecords entity, String ticket) {
save(entity);
}
@Override
public void updateModel(AuditRecords entity,String ticket) {
updateById(entity);
}
@Override
public void deleteModel(Integer businessId) {
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq("business_id", businessId);
remove(wrapper);
}
@Override
public AuditRecords getNowRecord(Integer businessId) {
//查询audit_date 为最新的一条数据
// audit_date 降序排列
// 限制结果为1条
QueryWrapper<AuditRecords> wrapper = new QueryWrapper<>();
wrapper.eq("business_id", businessId)
.orderByDesc("audit_date")
.last("LIMIT 1");
return getOne(wrapper);
}
@Override
public Page<AuditRecords> queryPage(RequestParameter parameter) {
AuditRecords entity = parameter.getParameter().toJavaObject(AuditRecords.class);
Page<AuditRecords> page = new Page<AuditRecords>(parameter.getCurrent(), parameter.getSize());
page.setSearchCount(true);
page.setOptimizeCountSql(true);
QueryWrapper<AuditRecords> eWrapper = new QueryWrapper<AuditRecords>(entity);
Page<AuditRecords> result = this.page(page, eWrapper);
return result;
}
}

+ 100
- 0
src/main/java/com/fxzy/warn/service/impl/AuthorizationServiceImpl.java View File

@ -0,0 +1,100 @@
package com.fxzy.warn.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fxzy.warn.common.constants.AuthorizationConstants;
import com.fxzy.warn.common.request.RequestParameter;
import com.fxzy.warn.common.response.ApiResponse;
import com.fxzy.warn.mapper.AuthorizationMapper;
import com.fxzy.warn.model.AuditRecords;
import com.fxzy.warn.model.Authorization;
import com.fxzy.warn.model.User;
import com.fxzy.warn.service.AuditRecordsService;
import com.fxzy.warn.service.AuthorizationService;
import com.fxzy.warn.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
/**
* @author zhangjing
* @date 2023/10/16 18:17
* @description
*/
@Service
public class AuthorizationServiceImpl extends ServiceImpl<AuthorizationMapper, Authorization> implements
AuthorizationService {
@Autowired
private UserService userService;
@Autowired
private AuditRecordsService auditRecordsService;
@Override
public ApiResponse saveModel(Authorization entity, String ticket) {
ApiResponse apiResponse = new ApiResponse();
save(entity);
User user = new User();
user.setId(entity.getUserId());
user.setAuthorizationStatus(AuthorizationConstants.STATUS_PENDING_APPLICATION);
userService.updateModel(user);
return apiResponse;
}
@Override
public boolean updateModel(Authorization entity) {
boolean result = this.updateById(entity);
return result;
}
@Override
public boolean deleteModel(Authorization entity) {
boolean result = this.removeById(entity);
return result;
}
@Override
public Page<User> queryPage(RequestParameter parameter) {
return userService.queryPage(parameter);
}
@Override
public ApiResponse applyFor(JSONObject jsonObject, String ticket) {
ApiResponse apiResponse = new ApiResponse();
Integer id = jsonObject.getInteger("id");
Integer authorizationId = jsonObject.getInteger("authorizationId");
User sysUser = userService.getUserByTicket(ticket);
AuditRecords auditRecords = new AuditRecords();
auditRecords.setAuditDate(new Date());
auditRecords.setUserId(sysUser!=null?sysUser.getId():null);
auditRecords.setUserName(sysUser!=null?sysUser.getLegalPerson():null);
auditRecords.setBusinessId(authorizationId);
auditRecords.setStatusCode(AuthorizationConstants.AUDIT_STATUS_PENDING);
auditRecordsService.save(auditRecords);
//用户状态
User user = new User();
user.setId(id);
user.setAuthorizationStatus(AuthorizationConstants.STATUS_PENDING_APPROVAL);
userService.updateModel(user);
return apiResponse;
}
@Override
public ApiResponse approve(JSONObject jsonObject, String ticket) {
ApiResponse apiResponse = new ApiResponse();
String content = jsonObject.getString("content");
String statusCode = jsonObject.getString("statusCode");
return apiResponse;
}
}

+ 123
- 0
src/main/java/com/fxzy/warn/service/impl/FileServiceImpl.java View File

@ -0,0 +1,123 @@
package com.fxzy.warn.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fxzy.warn.common.conf.MinioConfig;
import com.fxzy.warn.common.response.ApiResponse;
import com.fxzy.warn.mapper.FileMapper;
import com.fxzy.warn.model.File;
import com.fxzy.warn.model.vo.FileVO;
import com.fxzy.warn.service.FileService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author yuyantian
* @Date 2021/09/09 14:00
*/
@Service
public class FileServiceImpl extends ServiceImpl<FileMapper, File> implements FileService {
private static final Logger logger = LoggerFactory.getLogger(FileServiceImpl.class);
@Autowired
private MinioConfig minioConfig;
@Value(value = "${file.preViewRealPath}")
private String url;
@Override
public ApiResponse uploadFile(MultipartFile multipartFile) {
ApiResponse apiResponse = new ApiResponse();
String fileName = "";
try {
// fileName = minioConfig.putObject(multipartFile, "\\" + TimeUtil.formatTimeyyyyMMdd() + java.io.File.separator);
fileName = minioConfig.putObject(multipartFile);
if (StringUtils.isNotBlank(fileName)) {
File sysAttrFile = new File();
sysAttrFile.setFileName(multipartFile.getOriginalFilename());
sysAttrFile.setFilePath(fileName);//非全路径排除跟目录
sysAttrFile.setFileSize((int) (multipartFile.getSize()));
sysAttrFile.setCreateTime(new Date());
sysAttrFile.setIsDel(0);
sysAttrFile.setUrl(url + fileName);
/**附件表新增数据*/
save(sysAttrFile);
Map<String, Object> result = new HashMap<>();
result.put("file", sysAttrFile);
apiResponse.setData(result);
}
} catch (Exception e) {
apiResponse.recordError("附件上传失败,errMsg{" + e.getMessage() + "}");
}
return apiResponse;
}
@Override
public File uploadFile2File(MultipartFile file) {
File sysAttrFile = null;
String fileName = "";
try {
fileName = minioConfig.putObject(file);
if (StringUtils.isNotBlank(fileName)) {
sysAttrFile=new File();
sysAttrFile.setFileName(file.getOriginalFilename());
sysAttrFile.setFilePath(fileName);//非全路径排除跟目录
sysAttrFile.setFileSize((int) (file.getSize()));
sysAttrFile.setCreateTime(new Date());
sysAttrFile.setIsDel(0);
sysAttrFile.setUrl(url + fileName);
/**附件表新增数据*/
save(sysAttrFile);
}
} catch (Exception e) {
log.error("附件上传失败,errMsg{" + e.getMessage() + "}");
}
return sysAttrFile;
}
public List<File> queryByIds(String ids) {
List<File> fileList = new ArrayList<>();
if (!StringUtils.isEmpty(ids)) {
String[] idsArray = ids.split(",");
List<Long> idsList = Arrays.stream(idsArray)
.map(Long::valueOf)
.collect(Collectors.toList());
// 创建 QueryWrapper 实例
QueryWrapper<File> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("is_del", "0");
queryWrapper.in("id", idsList);
List<File> list = this.list(queryWrapper);
for (File file : list) {
file.setUrl(url + file.getFilePath());
}
fileList.addAll(list);
}
return fileList;
}
@Override
public List<FileVO> selectByFileIds(List<Object> fileIds) {
List<FileVO> files = this.baseMapper.selectByFileIds(fileIds);
if (CollectionUtils.isEmpty(files)) {
files = new ArrayList<>();
} else {
for (FileVO file : files) {
file.setUrl(url + file.getUrl());
}
}
return files;
}
}

+ 58
- 0
src/main/java/com/fxzy/warn/service/impl/MonitorUsersServiceImpl.java View File

@ -0,0 +1,58 @@
package com.fxzy.warn.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fxzy.warn.common.constants.EntityConstants;
import com.fxzy.warn.common.request.RequestParameter;
import com.fxzy.warn.common.response.ApiResponse;
import com.fxzy.warn.mapper.MonitorUsersMapper;
import com.fxzy.warn.model.MonitorUsers;
import com.fxzy.warn.service.MonitorUsersService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author zhangjing
* @date 2023/10/16 18:17
* @description
*/
@Service
public class MonitorUsersServiceImpl extends ServiceImpl<MonitorUsersMapper, MonitorUsers> implements
MonitorUsersService {
@Override
public ApiResponse saveModel(MonitorUsers entity, String ticket) {
save(entity);
return new ApiResponse();
}
@Override
public ApiResponse updateModel(MonitorUsers entity,String ticket) {
this.updateById(entity);
return new ApiResponse();
}
@Override
public ApiResponse deleteModel(List<String> ids) {
MonitorUsers entity = new MonitorUsers();
entity.setIsDel(EntityConstants.DEL);
QueryWrapper wrapper = new QueryWrapper();
wrapper.in("id", ids);
update(entity, wrapper);
return new ApiResponse();
}
@Override
public Page<MonitorUsers> queryPage(RequestParameter parameter) {
MonitorUsers entity = parameter.getParameter().toJavaObject(MonitorUsers.class);
Page<MonitorUsers> page = new Page<MonitorUsers>(parameter.getCurrent(), parameter.getSize());
page.setSearchCount(true);
page.setOptimizeCountSql(true);
QueryWrapper<MonitorUsers> eWrapper = new QueryWrapper<MonitorUsers>(entity);
Page<MonitorUsers> result = this.page(page, eWrapper);
return result;
}
}

+ 69
- 0
src/main/java/com/fxzy/warn/service/impl/PolicyManagementServiceImpl.java View File

@ -0,0 +1,69 @@
package com.fxzy.warn.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fxzy.warn.common.constants.EntityConstants;
import com.fxzy.warn.common.request.RequestParameter;
import com.fxzy.warn.common.response.ApiResponse;
import com.fxzy.warn.mapper.PolicyManagementMapper;
import com.fxzy.warn.model.PolicyManagement;
import com.fxzy.warn.service.PolicyManagementService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author zhangjing
* @date 2023/10/16 18:17
* @description
*/
@Service
public class PolicyManagementServiceImpl extends ServiceImpl<PolicyManagementMapper, PolicyManagement> implements
PolicyManagementService {
@Override
public ApiResponse saveModel(PolicyManagement entity, String ticket) {
save(entity);
return new ApiResponse();
}
@Override
public ApiResponse updateModel(PolicyManagement entity,String ticket) {
this.updateById(entity);
return new ApiResponse();
}
@Override
public ApiResponse deleteModel(List<String> ids) {
PolicyManagement entity = new PolicyManagement();
entity.setIsDel(EntityConstants.DEL);
QueryWrapper wrapper = new QueryWrapper();
wrapper.in("id", ids);
update(entity, wrapper);
return new ApiResponse();
}
@Override
public ApiResponse getPolicy(String contentType) {
ApiResponse response = new ApiResponse();
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq("is_del",EntityConstants.NORMAL);
wrapper.eq("content_type", contentType);
wrapper.eq("is_online", EntityConstants.IS_ONLINE);
response.setData(getOne(wrapper));
return response;
}
@Override
public Page<PolicyManagement> queryPage(RequestParameter parameter) {
PolicyManagement entity = parameter.getParameter().toJavaObject(PolicyManagement.class);
Page<PolicyManagement> page = new Page<PolicyManagement>(parameter.getCurrent(), parameter.getSize());
page.setSearchCount(true);
page.setOptimizeCountSql(true);
QueryWrapper<PolicyManagement> eWrapper = new QueryWrapper<PolicyManagement>(entity);
Page<PolicyManagement> result = this.page(page, eWrapper);
return result;
}
}

+ 95
- 20
src/main/java/com/fxzy/warn/service/impl/UserServiceImpl.java View File

@ -4,20 +4,31 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fxzy.warn.common.constants.AuthorizationConstants;
import com.fxzy.warn.common.constants.RedisKeyConstants;
import com.fxzy.warn.common.constants.ResponseMsgConstants;
import com.fxzy.warn.common.constants.UserConstants;
import com.fxzy.warn.common.request.RequestParameter;
import com.fxzy.warn.common.response.ApiResponse;
import com.fxzy.warn.common.util.JWTUtil;
import com.fxzy.warn.common.util.RedisUtil;
import com.fxzy.warn.common.util.SMSUtils;
import com.fxzy.warn.mapper.UserMapper;
import com.fxzy.warn.model.AuditRecords;
import com.fxzy.warn.model.Authorization;
import com.fxzy.warn.model.User;
import com.fxzy.warn.service.AuditRecordsService;
import com.fxzy.warn.service.AuthorizationService;
import com.fxzy.warn.service.FileService;
import com.fxzy.warn.service.UserService;
import com.nimbusds.jose.JOSEException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.Random;
import java.util.UUID;
/**
* @author zhangjing
@ -30,11 +41,22 @@ public class UserServiceImpl extends ServiceImpl implements
@Autowired
private RedisUtil redisUtil;
@Autowired
private AuthorizationService authorizationService;
@Autowired
private JWTUtil jwtUtil;
@Autowired
private FileService fileService;
@Value("${ali.accessKeyId}")
private String accessKeyId;
@Value("${ali.secret}")
private String secret;
@Override
public ApiResponse sendCode(JSONObject jsonObject) {
ApiResponse response = new ApiResponse();
@ -45,19 +67,19 @@ public class UserServiceImpl extends ServiceImpl implements
//用户是否存在
User user = getOne(queryWrapper);
if (user == null) {
response.recordError(ResponseMsgConstants.USER_NOT_FOUND);
response.recordMsgError(ResponseMsgConstants.USER_NOT_FOUND);
return response;
}
String number = redisUtil.getString("code:"+phoneNumber);
String number = redisUtil.getString("code:" + phoneNumber);
if (number != null) {
response.recordError(ResponseMsgConstants.CODE_SENT_SUCCESSFULLY);
response.recordMsgError(ResponseMsgConstants.CODE_SENT_SUCCESSFULLY);
return response;
}
//生成6为随机验证码
number = String.format("%06d", new Random().nextInt(1000000));
number = String.format("%06d", new Random().nextInt(1000000));
//存Redis
redisUtil.setString("code:"+phoneNumber,number,60*5);
SMSUtils.sendMessage("","","","",accessKeyId,secret);
redisUtil.setString("code:" + phoneNumber, number, 60 * 5);
SMSUtils.sendMessage("", "", "", "", accessKeyId, secret);
return response;
}
@ -72,39 +94,66 @@ public class UserServiceImpl extends ServiceImpl implements
String password = jsonObject.getString("password");
//验证码
String code = jsonObject.getString("code");
if (loginType.equals(UserConstants.SMS_CAPTCHA_LOGIN)){
User user=null;
if (loginType.equals(UserConstants.SMS_CAPTCHA_LOGIN)) {
//验证码登录
String number = redisUtil.getString("code:"+phoneNumber);
String number = redisUtil.getString("code:" + phoneNumber);
if (number == null) {
response.recordError(ResponseMsgConstants.CODE_EXPIRED_PLEASE_RESEND);
response.recordMsgError(ResponseMsgConstants.CODE_EXPIRED_PLEASE_RESEND);
return response;
}
//登录成功
if (number.equals(code)){
if (number.equals(code)) {
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("phone_number", phoneNumber);
User user = getOne(queryWrapper);
user = getOne(queryWrapper);
response.setData(user);
} else {
response.recordMsgError(ResponseMsgConstants.CODE_ERROR);
return response;
}
}else {
} else {
//密码登录
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("phone_number", phoneNumber);
User user = getOne(queryWrapper);
user = getOne(queryWrapper);
if (user == null) {
response.recordError(ResponseMsgConstants.USER_NOT_FOUND);
response.recordMsgError(ResponseMsgConstants.USER_NOT_FOUND);
return response;
}
if (!user.getPassword().equals(password)){
response.recordError(ResponseMsgConstants.PASSWORD_ERROR);
if (!user.getPassword().equals(password)) {
response.recordMsgError(ResponseMsgConstants.PASSWORD_ERROR);
return response;
}
response.setData(user);
}
String token = this.createToken(user);
String ticket = createTicket(token);
redisUtil.setString(RedisKeyConstants.LOGIN_ST + ticket,token , 60 * 60 * 12);
return response;
}
private String createTicket(String token) {
String ticket = RedisKeyConstants.LOGIN_ST_HEADER + UUID.randomUUID().toString().replace("-", "");
try {
redisUtil.setString(RedisKeyConstants.LOGIN_ST + ticket, token, 60 * 60 * 12);
} catch (Exception e) {
log.error("登录,生成token失败,errMsg==={}" + e.getMessage());
return null;
}
return ticket;
}
private String createToken(User user) {
String publicKey = jwtUtil.getPublicKey();
String token = null;
try {
token = jwtUtil.creatToken(user, publicKey);
} catch (JOSEException e) {
log.error("登录,生成token失败,errMsg==={}" + e.getMessage());
}
return token;
}
@Override
public ApiResponse createUser(User entity, String ticket) {
ApiResponse response = new ApiResponse();
@ -112,8 +161,8 @@ public class UserServiceImpl extends ServiceImpl implements
queryWrapper.eq("phone_number", entity.getPhoneNumber());
//用户是否存在
User user = getOne(queryWrapper);
if (user!=null){
response.recordError(ResponseMsgConstants.USER_PHONE_EXIST);
if (user != null) {
response.recordMsgError(ResponseMsgConstants.USER_PHONE_EXIST);
return response;
}
save(entity);
@ -151,11 +200,37 @@ public class UserServiceImpl extends ServiceImpl implements
return result;
}
@Override
public User getUserByTicket(String ticket) {
User user = null;
if (redisUtil.exists(RedisKeyConstants.LOGIN_ST + ticket)) {
user = jwtUtil.getUserByToken(redisUtil.getString(RedisKeyConstants.LOGIN_ST + ticket));
}
return user;
}
private void setInfo(Page<User> result) {
for (User user : result.getRecords()) {
// 这里可以添加需要返回的字段的填充
if (user.getAuthorizationId() == null) {
user.setAuthorizationStatus(AuthorizationConstants.STATUS_PENDING_APPLICATION);
} else {
user.setAuthorizationStatus(AuthorizationConstants.STATUS_AUTHORIZED_VALID);
Authorization authorization = authorizationService.getById(user.getAuthorizationId());
if (authorization != null) {
user.setStartDate(authorization.getStartDate());
user.setEndDate(authorization.getEndDate());
user.setFile(fileService.getById(authorization.getFileId()));
//检查日期
//大于当前时间授权到期
if (authorization.getEndDate().after(new Date())) {
user.setAuthorizationStatus(AuthorizationConstants.STATUS_AUTHORIZED_EXPIRED);
}
}
}
}
}
}

+ 1
- 1
src/main/resources/bootstrap-dev.yml View File

@ -59,7 +59,7 @@ file:
#附件上传盘符,liunx服务器需要切换
fileUploadRootPath: D:/
fileUploadPath: /upload/
preViewRealPath: http://182.151.8.209:9000/cert/.

+ 34
- 0
src/main/resources/mapper/FileMapper.xml View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- 定义mapper接口路径 -->
<mapper namespace="com.lzrq.service.mapper.FileMapper">
<resultMap id="FileVOModel" type="com.fxzy.warn.model.vo.FileVO">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="file_path" property="url" jdbcType="VARCHAR"/>
<result column="file_name" property="name" jdbcType="VARCHAR"/>
</resultMap>
<insert id="saveModel" useGeneratedKeys="true" keyProperty="id" parameterType="com.fxzy.warn.model.File">
INSERT INTO "gas_service_db"."t_sys_file"
("file_path", "file_name", "file_size", "create_time", "creator_id", "is_del")
VALUES (#{filePath}, #{fileName}, #{fileSize}, #{createTime}, #{creatorId}, 0);
</insert>
<select id="selectByFileIds" resultMap="FileVOModel">
select
id,
file_path,
file_name
from t_sys_file
where id in
<foreach collection="fileIds" item="fileId" separator="," open="(" close=")">
${fileId}
</foreach>
and is_del = 0
</select>
</mapper>

Loading…
Cancel
Save