| @ -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; | |||
| } | |||
| } | |||
| @ -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; | |||
| } | |||
| @ -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; | |||
| } | |||
| } | |||
| @ -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); | |||
| // } | |||
| } | |||
| @ -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; | |||
| } | |||
| } | |||
| @ -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; | |||
| } | |||
| } | |||
| @ -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> { | |||
| } | |||
| @ -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> { | |||
| } | |||
| @ -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); | |||
| } | |||
| @ -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> { | |||
| } | |||
| @ -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> { | |||
| } | |||
| @ -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; | |||
| } | |||
| @ -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; | |||
| } | |||
| @ -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; | |||
| } | |||
| @ -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; | |||
| } | |||
| @ -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; | |||
| } | |||
| @ -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); | |||
| } | |||
| @ -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); | |||
| } | |||
| @ -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); | |||
| } | |||
| @ -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); | |||
| } | |||
| @ -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); | |||
| } | |||
| @ -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; | |||
| } | |||
| } | |||
| @ -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; | |||
| } | |||
| } | |||
| @ -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; | |||
| } | |||
| } | |||
| @ -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; | |||
| } | |||
| } | |||
| @ -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; | |||
| } | |||
| } | |||
| @ -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> | |||