diff --git a/lib/minio-7.0.2-all.jar b/lib/minio-7.0.2-all.jar new file mode 100644 index 0000000..74d1664 Binary files /dev/null and b/lib/minio-7.0.2-all.jar differ diff --git a/pom.xml b/pom.xml index 134163c..0484aed 100644 --- a/pom.xml +++ b/pom.xml @@ -163,7 +163,13 @@ - + + io.minio + minio + 7.0.2-all + system + ${project.basedir}/lib/minio-7.0.2-all.jar + io.netty diff --git a/src/main/java/com/fxzy/warn/common/conf/MinioConfig.java b/src/main/java/com/fxzy/warn/common/conf/MinioConfig.java new file mode 100644 index 0000000..5366b74 --- /dev/null +++ b/src/main/java/com/fxzy/warn/common/conf/MinioConfig.java @@ -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 listBucketNames() + throws Exception { + List bucketList = listBuckets(); + List bucketListName = new ArrayList<>(); + for (Bucket bucket : bucketList) { + bucketListName.add(bucket.name()); + } + return bucketListName; + } + + /** + * 查看所有桶 + * + * @return + * @throws Exception + */ + public List 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> myObjects = listObjects(bucketName); + for (Result 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> listObjects(String bucketName) throws Exception { + boolean flag = bucketExists(bucketName); + if (flag) { + return minioClient.listObjects(bucketName); + } + return null; + } + + /** + * 列出存储桶中的所有对象名称 + * + * @param bucketName 存储桶名称 + * @return + * @throws Exception + */ + public List listObjectNames(String bucketName) throws Exception { + List listObjectNames = new ArrayList<>(); + boolean flag = bucketExists(bucketName); + if (flag) { + Iterable> myObjects = listObjects(bucketName); + for (Result 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 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; + } + +} diff --git a/src/main/java/com/fxzy/warn/common/constants/AuthorizationConstants.java b/src/main/java/com/fxzy/warn/common/constants/AuthorizationConstants.java new file mode 100644 index 0000000..7a3ad95 --- /dev/null +++ b/src/main/java/com/fxzy/warn/common/constants/AuthorizationConstants.java @@ -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; +} diff --git a/src/main/java/com/fxzy/warn/common/constants/EntityConstants.java b/src/main/java/com/fxzy/warn/common/constants/EntityConstants.java index 034625c..68d33c7 100644 --- a/src/main/java/com/fxzy/warn/common/constants/EntityConstants.java +++ b/src/main/java/com/fxzy/warn/common/constants/EntityConstants.java @@ -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; } diff --git a/src/main/java/com/fxzy/warn/common/constants/RedisKeyConstants.java b/src/main/java/com/fxzy/warn/common/constants/RedisKeyConstants.java index 9640bfc..18c6cd3 100644 --- a/src/main/java/com/fxzy/warn/common/constants/RedisKeyConstants.java +++ b/src/main/java/com/fxzy/warn/common/constants/RedisKeyConstants.java @@ -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"; diff --git a/src/main/java/com/fxzy/warn/common/constants/ResponseMsgConstants.java b/src/main/java/com/fxzy/warn/common/constants/ResponseMsgConstants.java index a85c2a3..2bfb39e 100644 --- a/src/main/java/com/fxzy/warn/common/constants/ResponseMsgConstants.java +++ b/src/main/java/com/fxzy/warn/common/constants/ResponseMsgConstants.java @@ -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 = "系统异常"; diff --git a/src/main/java/com/fxzy/warn/common/response/ApiResponse.java b/src/main/java/com/fxzy/warn/common/response/ApiResponse.java index d94bef5..9e2c701 100644 --- a/src/main/java/com/fxzy/warn/common/response/ApiResponse.java +++ b/src/main/java/com/fxzy/warn/common/response/ApiResponse.java @@ -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; } diff --git a/src/main/java/com/fxzy/warn/common/util/JWTUtil.java b/src/main/java/com/fxzy/warn/common/util/JWTUtil.java index f6effe9..9daa9ed 100644 --- a/src/main/java/com/fxzy/warn/common/util/JWTUtil.java +++ b/src/main/java/com/fxzy/warn/common/util/JWTUtil.java @@ -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 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 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 createPayloadMap(WxUserVO user) { -// Map 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 createPayloadMap(User user) { + Map 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; + } diff --git a/src/main/java/com/fxzy/warn/controller/AuthorizationController.java b/src/main/java/com/fxzy/warn/controller/AuthorizationController.java new file mode 100644 index 0000000..5ee2ecb --- /dev/null +++ b/src/main/java/com/fxzy/warn/controller/AuthorizationController.java @@ -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; + } + +} diff --git a/src/main/java/com/fxzy/warn/controller/FileController.java b/src/main/java/com/fxzy/warn/controller/FileController.java new file mode 100644 index 0000000..b569d02 --- /dev/null +++ b/src/main/java/com/fxzy/warn/controller/FileController.java @@ -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 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 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); +// } + +} + + diff --git a/src/main/java/com/fxzy/warn/controller/MonitorUsersController.java b/src/main/java/com/fxzy/warn/controller/MonitorUsersController.java new file mode 100644 index 0000000..7b19503 --- /dev/null +++ b/src/main/java/com/fxzy/warn/controller/MonitorUsersController.java @@ -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; + } + +} diff --git a/src/main/java/com/fxzy/warn/controller/PolicyManagementController.java b/src/main/java/com/fxzy/warn/controller/PolicyManagementController.java new file mode 100644 index 0000000..a5d6caf --- /dev/null +++ b/src/main/java/com/fxzy/warn/controller/PolicyManagementController.java @@ -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; + } + +} diff --git a/src/main/java/com/fxzy/warn/mapper/AuditRecordsMapper.java b/src/main/java/com/fxzy/warn/mapper/AuditRecordsMapper.java new file mode 100644 index 0000000..17afb1c --- /dev/null +++ b/src/main/java/com/fxzy/warn/mapper/AuditRecordsMapper.java @@ -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 { +} diff --git a/src/main/java/com/fxzy/warn/mapper/AuthorizationMapper.java b/src/main/java/com/fxzy/warn/mapper/AuthorizationMapper.java new file mode 100644 index 0000000..635cf8a --- /dev/null +++ b/src/main/java/com/fxzy/warn/mapper/AuthorizationMapper.java @@ -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 { +} diff --git a/src/main/java/com/fxzy/warn/mapper/FileMapper.java b/src/main/java/com/fxzy/warn/mapper/FileMapper.java new file mode 100644 index 0000000..b9674ff --- /dev/null +++ b/src/main/java/com/fxzy/warn/mapper/FileMapper.java @@ -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 findFileList(@Param("id") Long appLogoId); + + /** + * 查询附件 + * @param fileIds + * @return + */ + List selectByFileIds(@Param("fileIds") List fileIds); +} \ No newline at end of file diff --git a/src/main/java/com/fxzy/warn/mapper/MonitorUsersMapper.java b/src/main/java/com/fxzy/warn/mapper/MonitorUsersMapper.java new file mode 100644 index 0000000..3a4e74d --- /dev/null +++ b/src/main/java/com/fxzy/warn/mapper/MonitorUsersMapper.java @@ -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 { +} diff --git a/src/main/java/com/fxzy/warn/mapper/PolicyManagementMapper.java b/src/main/java/com/fxzy/warn/mapper/PolicyManagementMapper.java new file mode 100644 index 0000000..d2f251d --- /dev/null +++ b/src/main/java/com/fxzy/warn/mapper/PolicyManagementMapper.java @@ -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 { +} diff --git a/src/main/java/com/fxzy/warn/model/AuditRecords.java b/src/main/java/com/fxzy/warn/model/AuditRecords.java new file mode 100644 index 0000000..9cd307e --- /dev/null +++ b/src/main/java/com/fxzy/warn/model/AuditRecords.java @@ -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 { + /** + * 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; + +} diff --git a/src/main/java/com/fxzy/warn/model/Authorization.java b/src/main/java/com/fxzy/warn/model/Authorization.java index 74e2011..f1db660 100644 --- a/src/main/java/com/fxzy/warn/model/Authorization.java +++ b/src/main/java/com/fxzy/warn/model/Authorization.java @@ -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; } diff --git a/src/main/java/com/fxzy/warn/model/File.java b/src/main/java/com/fxzy/warn/model/File.java new file mode 100644 index 0000000..4e10ddb --- /dev/null +++ b/src/main/java/com/fxzy/warn/model/File.java @@ -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 { + + /** + * 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; +} diff --git a/src/main/java/com/fxzy/warn/model/MonitorUsers.java b/src/main/java/com/fxzy/warn/model/MonitorUsers.java new file mode 100644 index 0000000..4df5375 --- /dev/null +++ b/src/main/java/com/fxzy/warn/model/MonitorUsers.java @@ -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; +} diff --git a/src/main/java/com/fxzy/warn/model/PolicyManagement.java b/src/main/java/com/fxzy/warn/model/PolicyManagement.java new file mode 100644 index 0000000..2040fd4 --- /dev/null +++ b/src/main/java/com/fxzy/warn/model/PolicyManagement.java @@ -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; +} diff --git a/src/main/java/com/fxzy/warn/model/Test.java b/src/main/java/com/fxzy/warn/model/Test.java index 82f1628..9baaa15 100644 --- a/src/main/java/com/fxzy/warn/model/Test.java +++ b/src/main/java/com/fxzy/warn/model/Test.java @@ -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 */ diff --git a/src/main/java/com/fxzy/warn/model/User.java b/src/main/java/com/fxzy/warn/model/User.java index 2aa4123..fe6bd20 100644 --- a/src/main/java/com/fxzy/warn/model/User.java +++ b/src/main/java/com/fxzy/warn/model/User.java @@ -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; } diff --git a/src/main/java/com/fxzy/warn/model/vo/FileVO.java b/src/main/java/com/fxzy/warn/model/vo/FileVO.java new file mode 100644 index 0000000..a39fe11 --- /dev/null +++ b/src/main/java/com/fxzy/warn/model/vo/FileVO.java @@ -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; + +} diff --git a/src/main/java/com/fxzy/warn/service/AuditRecordsService.java b/src/main/java/com/fxzy/warn/service/AuditRecordsService.java new file mode 100644 index 0000000..860c511 --- /dev/null +++ b/src/main/java/com/fxzy/warn/service/AuditRecordsService.java @@ -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 { + + /** + * 保存 + * @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 queryPage(RequestParameter parameter); + + + +} diff --git a/src/main/java/com/fxzy/warn/service/AuthorizationService.java b/src/main/java/com/fxzy/warn/service/AuthorizationService.java new file mode 100644 index 0000000..db31998 --- /dev/null +++ b/src/main/java/com/fxzy/warn/service/AuthorizationService.java @@ -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 { + + /** + * 保存 + * @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 queryPage(RequestParameter parameter); + + /** + * 申请 + * @param jsonObject + * @return + */ + ApiResponse applyFor(JSONObject jsonObject , String ticket); + + /** + * 审批 + * @param jsonObject + * @return + */ + ApiResponse approve(JSONObject jsonObject , String ticket); + +} diff --git a/src/main/java/com/fxzy/warn/service/FileService.java b/src/main/java/com/fxzy/warn/service/FileService.java new file mode 100644 index 0000000..3dd3274 --- /dev/null +++ b/src/main/java/com/fxzy/warn/service/FileService.java @@ -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 { + + + /** + * 附件上传 + */ + ApiResponse uploadFile(MultipartFile file); + + + + /** + * 附件上传 + */ + File uploadFile2File(MultipartFile file); + /** + * 通过附件id查询附件信息 + * + * @param fileIds + * @return + */ + List selectByFileIds(List fileIds); +} diff --git a/src/main/java/com/fxzy/warn/service/MonitorUsersService.java b/src/main/java/com/fxzy/warn/service/MonitorUsersService.java new file mode 100644 index 0000000..3f4fe9a --- /dev/null +++ b/src/main/java/com/fxzy/warn/service/MonitorUsersService.java @@ -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 { + + /** + * 保存 + * @param entity + * @return + */ + ApiResponse saveModel(MonitorUsers entity,String ticket); + + /** + * 修改 + * @param entity + * @return + */ + ApiResponse updateModel(MonitorUsers entity,String ticket); + + /** + * 删除 + * @param ids + * @return + */ + ApiResponse deleteModel(List ids); + + /** + * 分页查询 + * @param parameter + * @return + */ + Page queryPage(RequestParameter parameter); + + + +} diff --git a/src/main/java/com/fxzy/warn/service/PolicyManagementService.java b/src/main/java/com/fxzy/warn/service/PolicyManagementService.java new file mode 100644 index 0000000..eaa5a3f --- /dev/null +++ b/src/main/java/com/fxzy/warn/service/PolicyManagementService.java @@ -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 { + + /** + * 保存 + * @param entity + * @return + */ + ApiResponse saveModel(PolicyManagement entity,String ticket); + + /** + * 修改 + * @param entity + * @return + */ + ApiResponse updateModel(PolicyManagement entity,String ticket); + + /** + * 删除 + * @param ids + * @return + */ + ApiResponse deleteModel(List ids); + + /** + * 当前政策 + * @param contentType + * @return + */ + ApiResponse getPolicy(String contentType); + + /** + * 分页查询 + * @param parameter + * @return + */ + Page queryPage(RequestParameter parameter); + + + +} diff --git a/src/main/java/com/fxzy/warn/service/UserService.java b/src/main/java/com/fxzy/warn/service/UserService.java index 458bb0a..6f03722 100644 --- a/src/main/java/com/fxzy/warn/service/UserService.java +++ b/src/main/java/com/fxzy/warn/service/UserService.java @@ -73,4 +73,12 @@ public interface UserService extends IService { * @return */ Page queryPage(RequestParameter parameter); + + /** + * 获取人员企业,身份 + * + * @param + * @return + */ + User getUserByTicket(String ticket); } diff --git a/src/main/java/com/fxzy/warn/service/impl/AuditRecordsServiceImpl.java b/src/main/java/com/fxzy/warn/service/impl/AuditRecordsServiceImpl.java new file mode 100644 index 0000000..2f6ab19 --- /dev/null +++ b/src/main/java/com/fxzy/warn/service/impl/AuditRecordsServiceImpl.java @@ -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 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 wrapper = new QueryWrapper<>(); + wrapper.eq("business_id", businessId) + .orderByDesc("audit_date") + .last("LIMIT 1"); + return getOne(wrapper); + } + + @Override + public Page queryPage(RequestParameter parameter) { + AuditRecords entity = parameter.getParameter().toJavaObject(AuditRecords.class); + Page page = new Page(parameter.getCurrent(), parameter.getSize()); + page.setSearchCount(true); + page.setOptimizeCountSql(true); + QueryWrapper eWrapper = new QueryWrapper(entity); + Page result = this.page(page, eWrapper); + return result; + } +} diff --git a/src/main/java/com/fxzy/warn/service/impl/AuthorizationServiceImpl.java b/src/main/java/com/fxzy/warn/service/impl/AuthorizationServiceImpl.java new file mode 100644 index 0000000..c773afc --- /dev/null +++ b/src/main/java/com/fxzy/warn/service/impl/AuthorizationServiceImpl.java @@ -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 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 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; + } +} diff --git a/src/main/java/com/fxzy/warn/service/impl/FileServiceImpl.java b/src/main/java/com/fxzy/warn/service/impl/FileServiceImpl.java new file mode 100644 index 0000000..fff97ca --- /dev/null +++ b/src/main/java/com/fxzy/warn/service/impl/FileServiceImpl.java @@ -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 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 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 queryByIds(String ids) { + List fileList = new ArrayList<>(); + if (!StringUtils.isEmpty(ids)) { + String[] idsArray = ids.split(","); + List idsList = Arrays.stream(idsArray) + .map(Long::valueOf) + .collect(Collectors.toList()); + // 创建 QueryWrapper 实例 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("is_del", "0"); + queryWrapper.in("id", idsList); + List list = this.list(queryWrapper); + for (File file : list) { + file.setUrl(url + file.getFilePath()); + } + fileList.addAll(list); + } + return fileList; + } + + @Override + public List selectByFileIds(List fileIds) { + List files = this.baseMapper.selectByFileIds(fileIds); + if (CollectionUtils.isEmpty(files)) { + files = new ArrayList<>(); + } else { + for (FileVO file : files) { + file.setUrl(url + file.getUrl()); + } + } + return files; + } +} \ No newline at end of file diff --git a/src/main/java/com/fxzy/warn/service/impl/MonitorUsersServiceImpl.java b/src/main/java/com/fxzy/warn/service/impl/MonitorUsersServiceImpl.java new file mode 100644 index 0000000..be5d878 --- /dev/null +++ b/src/main/java/com/fxzy/warn/service/impl/MonitorUsersServiceImpl.java @@ -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 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 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 queryPage(RequestParameter parameter) { + MonitorUsers entity = parameter.getParameter().toJavaObject(MonitorUsers.class); + Page page = new Page(parameter.getCurrent(), parameter.getSize()); + page.setSearchCount(true); + page.setOptimizeCountSql(true); + QueryWrapper eWrapper = new QueryWrapper(entity); + Page result = this.page(page, eWrapper); + return result; + } +} diff --git a/src/main/java/com/fxzy/warn/service/impl/PolicyManagementServiceImpl.java b/src/main/java/com/fxzy/warn/service/impl/PolicyManagementServiceImpl.java new file mode 100644 index 0000000..25b2374 --- /dev/null +++ b/src/main/java/com/fxzy/warn/service/impl/PolicyManagementServiceImpl.java @@ -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 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 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 queryPage(RequestParameter parameter) { + PolicyManagement entity = parameter.getParameter().toJavaObject(PolicyManagement.class); + Page page = new Page(parameter.getCurrent(), parameter.getSize()); + page.setSearchCount(true); + page.setOptimizeCountSql(true); + QueryWrapper eWrapper = new QueryWrapper(entity); + Page result = this.page(page, eWrapper); + return result; + } +} diff --git a/src/main/java/com/fxzy/warn/service/impl/UserServiceImpl.java b/src/main/java/com/fxzy/warn/service/impl/UserServiceImpl.java index 4c73756..8284796 100644 --- a/src/main/java/com/fxzy/warn/service/impl/UserServiceImpl.java +++ b/src/main/java/com/fxzy/warn/service/impl/UserServiceImpl.java @@ -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 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 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 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); + } + } + } } } + + } diff --git a/src/main/resources/bootstrap-dev.yml b/src/main/resources/bootstrap-dev.yml index a0a9e69..7e8af5e 100644 --- a/src/main/resources/bootstrap-dev.yml +++ b/src/main/resources/bootstrap-dev.yml @@ -59,7 +59,7 @@ file: #附件上传盘符,liunx服务器需要切换 fileUploadRootPath: D:/ fileUploadPath: /upload/ - + preViewRealPath: http://182.151.8.209:9000/cert/. diff --git a/src/main/resources/mapper/FileMapper.xml b/src/main/resources/mapper/FileMapper.xml new file mode 100644 index 0000000..dca292d --- /dev/null +++ b/src/main/resources/mapper/FileMapper.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + 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); + + + + + + \ No newline at end of file