Browse Source

Merge remote-tracking branch 'origin/master' into master

yangyj 1 year ago
parent
commit
2fcab65ce2
16 changed files with 852 additions and 0 deletions
  1. 24 0
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/dto/PolicyInfoDTO.java
  2. 37 0
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/dto/PolicyInfoSearchDTO.java
  3. 36 0
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/AttachmentInfo.java
  4. 45 0
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/PolicyInfo.java
  5. 29 0
      blade-service/blade-land/pom.xml
  6. 75 0
      blade-service/blade-land/src/main/java/org/springblade/land/controller/AttachmentInfoController.java
  7. 92 0
      blade-service/blade-land/src/main/java/org/springblade/land/controller/PolicyInfoController.java
  8. 40 0
      blade-service/blade-land/src/main/java/org/springblade/land/mapper/AttachmentInfoMapper.java
  9. 21 0
      blade-service/blade-land/src/main/java/org/springblade/land/mapper/AttachmentInfoMapper.xml
  10. 35 0
      blade-service/blade-land/src/main/java/org/springblade/land/mapper/PolicyInfoMapper.java
  11. 19 0
      blade-service/blade-land/src/main/java/org/springblade/land/mapper/PolicyInfoMapper.xml
  12. 44 0
      blade-service/blade-land/src/main/java/org/springblade/land/service/IAttachmentInfoService.java
  13. 49 0
      blade-service/blade-land/src/main/java/org/springblade/land/service/IPolicyInfoService.java
  14. 98 0
      blade-service/blade-land/src/main/java/org/springblade/land/service/impl/AttachmentInfoServiceImpl.java
  15. 134 0
      blade-service/blade-land/src/main/java/org/springblade/land/service/impl/PolicyInfoServiceImpl.java
  16. 74 0
      blade-service/blade-land/src/main/java/org/springblade/land/utils/FileUtils.java

+ 24 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/dto/PolicyInfoDTO.java

@@ -0,0 +1,24 @@
+package org.springblade.land.dto;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+import org.springblade.land.entity.AttachmentInfo;
+import org.springblade.land.entity.PolicyInfo;
+
+import java.util.List;
+
+/**
+ * @Param  政策法规-附件表
+ * @Author wangwl
+ * @Date 2023/9/12 11:47
+ **/
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class PolicyInfoDTO extends PolicyInfo {
+
+    @ApiModelProperty(value = "附件集合")
+    private List<AttachmentInfo> list;
+}

+ 37 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/dto/PolicyInfoSearchDTO.java

@@ -0,0 +1,37 @@
+package org.springblade.land.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.land.entity.AttachmentInfo;
+import org.springblade.land.entity.PolicyInfo;
+
+import java.time.LocalDate;
+import java.util.List;
+
+/**
+ * @Param  政策法规-附件表
+ * @Author wangwl
+ * @Date 2023/9/12 11:47
+ **/
+@Data
+public class PolicyInfoSearchDTO {
+
+    @ApiModelProperty(value = "项目id")
+    private Long projectId;
+
+    @ApiModelProperty(value = "名称")
+    private String name;
+
+    @ApiModelProperty(value = "区域id")
+    private Long areaId;
+
+    @ApiModelProperty(value = "1政策法规2双方协议")
+    private Integer type;
+
+    @ApiModelProperty(value = "开始时间")
+    private LocalDate startDate;
+
+    @ApiModelProperty(value = "结束时间")
+    private LocalDate endDate;
+}

+ 36 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/AttachmentInfo.java

@@ -0,0 +1,36 @@
+package org.springblade.land.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+/**
+ * @Param  政策法规-附件表
+ * @Author wangwl
+ * @Date 2023/9/12 11:47
+ **/
+@Data
+@TableName("l_attachment_info")
+@EqualsAndHashCode(callSuper = true)
+public class AttachmentInfo extends BaseEntity {
+
+    @ApiModelProperty(value = "项目id")
+    private Long projectId;
+
+    @ApiModelProperty(value = "主键id")
+    private Long masterId;
+
+    @ApiModelProperty(value = "附件名称")
+    private String name;
+
+    @ApiModelProperty(value = "附件路径")
+    private String domainUrl;
+
+    @ApiModelProperty(value = "附件后缀")
+    private String extension;
+
+    @ApiModelProperty(value = "附件PDF路径")
+    private String domainPdfUrl;
+}

+ 45 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/PolicyInfo.java

@@ -0,0 +1,45 @@
+package org.springblade.land.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+import java.time.LocalDate;
+
+/**
+ * @Param  政策法规,双方协议表
+ * @Author wangwl
+ * @Date 2023/9/12 11:03
+ **/
+@Data
+@TableName("l_policy_info")
+@EqualsAndHashCode(callSuper = true)
+public class PolicyInfo extends BaseEntity {
+
+    @ApiModelProperty(value = "项目id")
+    private Long projectId;
+
+    @ApiModelProperty(value = "业务编号")
+    private String number;
+
+    @ApiModelProperty(value = "名称")
+    private String name;
+
+    @ApiModelProperty(value = "区域id")
+    private Long areaId;
+
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    @ApiModelProperty(value = "附件pdf路径")
+    private String pdfUrl;
+
+    @ApiModelProperty(value = "类型1政策法规2双方协议")
+    private Integer type;
+
+    @ApiModelProperty(value = "类型1政策法规2双方协议")
+    private LocalDate uploadDate;
+
+}

+ 29 - 0
blade-service/blade-land/pom.xml

@@ -28,6 +28,35 @@
             <artifactId>blade-land-api</artifactId>
             <version>${bladex.project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.springblade</groupId>
+            <artifactId>blade-starter-oss</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springblade</groupId>
+            <artifactId>blade-resource-api</artifactId>
+            <version>2.9.1.RELEASE</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.itextpdf</groupId>
+            <artifactId>itextpdf</artifactId>
+            <version>5.5.13</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.itextpdf</groupId>
+            <artifactId>itextpdf</artifactId>
+            <version>5.5.13</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springblade</groupId>
+            <artifactId>blade-system-api</artifactId>
+            <version>2.9.1.RELEASE</version>
+            <scope>compile</scope>
+        </dependency>
+
     </dependencies>
 
     <properties>

+ 75 - 0
blade-service/blade-land/src/main/java/org/springblade/land/controller/AttachmentInfoController.java

@@ -0,0 +1,75 @@
+package org.springblade.land.controller;
+
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import lombok.SneakyThrows;
+import org.springblade.common.constant.CommonConstant;
+import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.oss.model.BladeFile;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.FileUtil;
+import org.springblade.land.entity.AttachmentInfo;
+import org.springblade.land.entity.PolicyInfo;
+import org.springblade.land.service.IAttachmentInfoService;
+import org.springblade.land.service.IPolicyInfoService;
+import org.springblade.resource.feign.IOSSClient;
+import org.springblade.resource.feign.NewIOSSClient;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.validation.Valid;
+
+/**
+ * @author yangyj
+ * @Date 2023/2/17 10:40
+ * @description TODO
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/attachmentInfo")
+@Api(value = "政策法规-附件", tags = "政策法规-附件")
+public class AttachmentInfoController extends BladeController {
+
+
+    private final IAttachmentInfoService attachmentInfoService;
+    /**
+     * 上传文件
+     *
+     * @param file 文件
+     * @return ObjectStat
+     */
+    @SneakyThrows
+    @PostMapping("/add-file")
+    @ApiOperationSupport(order = 1)
+    @ApiOperation(value = "附件上传", notes = "附件上传")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "file", value = "文件", required = true),
+            @ApiImplicitParam(name = "projectId", value = "projectId", required = true)
+    })
+    public R<AttachmentInfo> addFile(@RequestParam("file") MultipartFile file, Long projectId) {
+       return attachmentInfoService.addFile(file,projectId);
+
+    }
+
+    /**
+     * 删除文件
+     */
+    @GetMapping("delete")
+    @ApiOperationSupport(order = 2)
+    @ApiOperation(value = "删除文件", notes = "传入文件id")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "id", value = "文件id", required = true)
+    })
+    public R delete(Long id){
+        attachmentInfoService.delete(id);
+        return R.success("删除成功");
+    }
+
+
+
+
+}

+ 92 - 0
blade-service/blade-land/src/main/java/org/springblade/land/controller/PolicyInfoController.java

@@ -0,0 +1,92 @@
+package org.springblade.land.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.*;
+import lombok.AllArgsConstructor;
+import org.springblade.core.boot.ctrl.BladeController;
+
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.land.dto.PolicyInfoDTO;
+import org.springblade.land.dto.PolicyInfoSearchDTO;
+import org.springblade.land.entity.PolicyInfo;
+import org.springblade.land.service.IPolicyInfoService;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.io.FileNotFoundException;
+import java.util.List;
+
+/**
+ * @author yangyj
+ * @Date 2023/2/17 10:40
+ * @description TODO
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/policyInfo")
+@Api(value = "政策法规-双方协议", tags = "政策法规-双方协议")
+public class PolicyInfoController extends BladeController {
+
+    private final IPolicyInfoService policyInfoService;
+
+    /**
+     * 新增或修改
+     */
+    @PostMapping("/addOrUpdate")
+    @ApiOperationSupport(order = 1)
+    @ApiOperation(value = "新增或修改", notes = "传入对象")
+    public R add(@Valid @RequestBody PolicyInfoDTO dto) throws FileNotFoundException {
+        policyInfoService.add(dto);
+        return R.success("操作成功");
+    }
+
+    /**
+     * 分页
+     */
+    @GetMapping("page")
+    @ApiOperationSupport(order = 2)
+    @ApiOperation(value = "分页", notes = "传入搜索值")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "projectId", value = "项目id", required = true),
+            @ApiImplicitParam(name = "type", value = "1政策法规2双方协议", required = true),
+            @ApiImplicitParam(name = "current", value = "当前页", required = true),
+            @ApiImplicitParam(name = "size", value = "每页的数量", required = true),
+            @ApiImplicitParam(name = "name", value = "名称", required = false),
+            @ApiImplicitParam(name = "areaId", value = "区域id", required = false),
+            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false),
+            @ApiImplicitParam(name = "endDate", value = "结束时间", required = false)
+    })
+    public R<IPage<PolicyInfo>> page(Query query, PolicyInfoSearchDTO dto){
+        IPage<PolicyInfo> iPage = policyInfoService.page(query, dto);
+        return R.data(iPage);
+    }
+
+    /**
+     * 查询
+     */
+    @GetMapping("detail")
+    @ApiOperationSupport(order = 3)
+    @ApiOperation(value = "查询", notes = "传入单个id")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", required = true)
+    })
+    public R<PolicyInfoDTO> detail(Long id){
+        return R.data(policyInfoService.detail(id));
+    }
+
+
+    /**
+     * 批量删除
+     */
+    @PostMapping("/remove")
+    @ApiOperationSupport(order = 4)
+    @ApiOperation(value = "批量逻辑删除", notes = "传入ids")
+    public R remove(@ApiParam(value = "主键集合", required = true) @RequestBody List<Long> ids) {
+        policyInfoService.remove(ids);
+        return R.success("删除成功");
+    }
+
+}

+ 40 - 0
blade-service/blade-land/src/main/java/org/springblade/land/mapper/AttachmentInfoMapper.java

@@ -0,0 +1,40 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.land.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.springblade.land.entity.AttachmentInfo;
+import org.springblade.land.entity.PolicyInfo;
+
+import java.util.List;
+
+
+/**
+ *  Mapper 接口
+ *
+ * @author BladeX
+ * @since 2023-02-17
+ */
+public interface AttachmentInfoMapper extends BaseMapper<AttachmentInfo> {
+
+    void deleteByMasterId(@Param("masterId") Long masterId);
+
+    void deleteByMasterIds(@Param("masterIds") List<Long> masterIds);
+
+    void delete(@Param("id") Long id);
+}

+ 21 - 0
blade-service/blade-land/src/main/java/org/springblade/land/mapper/AttachmentInfoMapper.xml

@@ -0,0 +1,21 @@
+<?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 namespace="org.springblade.land.mapper.AttachmentInfoMapper">
+
+
+    <delete id="deleteByMasterId">
+        delete from l_attachment_info
+        where master_id = #{masterId}
+    </delete>
+    <delete id="deleteByMasterIds">
+        delete from l_attachment_info
+        where master_id in
+        <foreach collection="masterIds" item="masterId" open="(" separator="," close=")">
+            #{masterId}
+        </foreach>
+    </delete>
+    <delete id="delete">
+        delete from l_attachment_info
+        where id = #{id}
+    </delete>
+</mapper>

+ 35 - 0
blade-service/blade-land/src/main/java/org/springblade/land/mapper/PolicyInfoMapper.java

@@ -0,0 +1,35 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.land.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.apache.ibatis.annotations.Param;
+import org.springblade.land.dto.PolicyInfoSearchDTO;
+import org.springblade.land.entity.PolicyInfo;
+
+
+/**
+ *  Mapper 接口
+ *
+ * @author BladeX
+ * @since 2023-02-17
+ */
+public interface PolicyInfoMapper extends BaseMapper<PolicyInfo> {
+
+    IPage<PolicyInfo> page(IPage<PolicyInfo> iPage,@Param("dto") PolicyInfoSearchDTO dto);
+}

+ 19 - 0
blade-service/blade-land/src/main/java/org/springblade/land/mapper/PolicyInfoMapper.xml

@@ -0,0 +1,19 @@
+<?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 namespace="org.springblade.land.mapper.PolicyInfoMapper">
+
+
+    <select id="page" resultType="org.springblade.land.entity.PolicyInfo">
+        select * from l_policy_info
+        where is_deleted = 0
+        <if test="dto.areaId != null and dto.areaId != ''">
+            and area_id = #{dto.areaId}
+        </if>
+        <if test="dto.name != null and dto.name != ''">
+            and name like concat('%',#{dto.name},'%')
+        </if>
+        <if test="dto.startDate != null and dto.startDate != '' and dto.endDate != null and dto.endDate != '' ">
+            and upload_date between #{dto.startDate} and #{dto.endDate}
+        </if>
+    </select>
+</mapper>

+ 44 - 0
blade-service/blade-land/src/main/java/org/springblade/land/service/IAttachmentInfoService.java

@@ -0,0 +1,44 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.land.service;
+
+
+import org.springblade.core.mp.base.BaseService;
+import org.springblade.core.tool.api.R;
+import org.springblade.land.entity.AttachmentInfo;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+
+public interface IAttachmentInfoService extends BaseService<AttachmentInfo> {
+
+    //新增附件
+    R<AttachmentInfo> addFile(MultipartFile file, Long projectId);
+
+    //根据主件id查询所有附件
+    List<AttachmentInfo> getAllFile(Long masterId);
+
+    //根据主件id删除附件
+    void deleteByMasterId(Long id);
+
+    //根据主件id批量删除附件
+    void deleteByMasterIds(List<Long> ids);
+
+    //根据附件id删除附件
+    void delete(Long id);
+}

+ 49 - 0
blade-service/blade-land/src/main/java/org/springblade/land/service/IPolicyInfoService.java

@@ -0,0 +1,49 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.land.service;
+
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.core.mp.base.BaseService;
+import org.springblade.core.mp.support.Query;
+import org.springblade.land.dto.PolicyInfoDTO;
+import org.springblade.land.dto.PolicyInfoSearchDTO;
+import org.springblade.land.entity.PolicyInfo;
+
+import java.io.FileNotFoundException;
+import java.util.List;
+
+
+/**
+ *  服务类
+ *
+ * @author BladeX
+ * @since 2023-02-17
+ */
+public interface IPolicyInfoService extends BaseService<PolicyInfo> {
+
+    //新增或修改
+    void add(PolicyInfoDTO dto) throws FileNotFoundException;
+
+    //分页查询
+    IPage<PolicyInfo> page(Query page, PolicyInfoSearchDTO dto);
+
+    //批量删除
+    void remove(List<Long> ids);
+
+    PolicyInfoDTO detail(Long id);
+}

+ 98 - 0
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/AttachmentInfoServiceImpl.java

@@ -0,0 +1,98 @@
+package org.springblade.land.service.impl;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import lombok.AllArgsConstructor;
+import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.core.oss.model.BladeFile;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.FileUtil;
+import org.springblade.land.entity.AttachmentInfo;
+import org.springblade.land.entity.PolicyInfo;
+import org.springblade.land.mapper.AttachmentInfoMapper;
+import org.springblade.land.mapper.PolicyInfoMapper;
+import org.springblade.land.service.IAttachmentInfoService;
+import org.springblade.land.service.IPolicyInfoService;
+import org.springblade.resource.feign.CommonFileClient;
+import org.springblade.resource.feign.IOSSClient;
+import org.springblade.resource.feign.NewIOSSClient;
+import org.springblade.resource.vo.NewBladeFile;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+@Service
+@AllArgsConstructor
+public class AttachmentInfoServiceImpl extends BaseServiceImpl<AttachmentInfoMapper, AttachmentInfo> implements IAttachmentInfoService {
+
+    //上传文件
+    private final IOSSClient iossClient;
+
+
+    // pdf转换
+    private final CommonFileClient commonFileClient;
+
+    @Override
+    public R<AttachmentInfo> addFile(MultipartFile file, Long projectId) {
+        if (file.getSize() > 52428800L){
+            throw new ServiceException("上传失败,文件大小超过50MB");
+        }
+        String fileExtension = FileUtil.getFileExtension(file.getOriginalFilename()).toLowerCase();
+        if (fileExtension.contains("doc") || fileExtension.contains("pdf")) {
+            R<BladeFile> bladeFile = iossClient.addFileInfo(file);
+            BladeFile bladeFile1 = bladeFile.getData();
+            AttachmentInfo info = new AttachmentInfo();
+            info.setId(SnowFlakeUtil.getId());
+            info.setName(file.getOriginalFilename());
+            info.setDomainUrl(bladeFile1.getLink());
+            info.setMasterId(-1L);
+            info.setProjectId(projectId);
+            if (fileExtension.contains("doc")){
+                NewBladeFile newBladeFile = this.commonFileClient.wordToPdf(file);
+                info.setDomainPdfUrl(newBladeFile.getPdfUrl());
+            }else {
+                info.setDomainPdfUrl(bladeFile1.getLink());
+            }
+            this.save(info);
+            return R.data(info);
+        }else {
+            throw new ServiceException("上传失败,只能上传doc或pdf文件");
+        }
+    }
+
+    /**
+     * 根据主件id获取所有附件
+     * @param masterId
+     * @return
+     */
+    @Override
+    public List<AttachmentInfo> getAllFile(Long masterId) {
+        return this.list(new LambdaQueryWrapper<AttachmentInfo>().eq(AttachmentInfo::getMasterId,masterId));
+    }
+
+    /**
+     * 根据主件删除附件
+     * @param masterId
+     */
+    @Override
+    public void deleteByMasterId(Long masterId) {
+        baseMapper.deleteByMasterId(masterId);
+    }
+
+    /**
+     * 根据主件删除附件
+     * @param masterIds
+     */
+    @Override
+    public void deleteByMasterIds(List<Long> masterIds) {
+        baseMapper.deleteByMasterIds(masterIds);
+    }
+
+    @Override
+    public void delete(Long id) {
+        baseMapper.delete(id);
+    }
+}

+ 134 - 0
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/PolicyInfoServiceImpl.java

@@ -0,0 +1,134 @@
+package org.springblade.land.service.impl;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.AllArgsConstructor;
+import net.bytebuddy.asm.Advice;
+import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.oss.model.BladeFile;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.ResourceUtil;
+import org.springblade.land.dto.PolicyInfoDTO;
+import org.springblade.land.dto.PolicyInfoSearchDTO;
+import org.springblade.land.entity.AttachmentInfo;
+import org.springblade.land.entity.PolicyInfo;
+import org.springblade.land.mapper.PolicyInfoMapper;
+import org.springblade.land.service.IAttachmentInfoService;
+import org.springblade.land.service.IPolicyInfoService;
+import org.springblade.land.utils.FileUtils;
+import org.springblade.resource.feign.NewIOSSClient;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+@AllArgsConstructor
+public class PolicyInfoServiceImpl extends BaseServiceImpl<PolicyInfoMapper, PolicyInfo> implements IPolicyInfoService {
+
+    private final IAttachmentInfoService attachmentInfoService;
+
+    private final NewIOSSClient newIOSSClient;
+
+    /**
+     * 新增法律法规
+     * @param dto
+     */
+    @Override
+    @Transactional
+    public void add(PolicyInfoDTO dto) throws FileNotFoundException {
+        String file_path = FileUtils.getSysLocalFileUrl();
+        PolicyInfo policyInfo = new PolicyInfo();
+        BeanUtils.copyProperties(dto,policyInfo);
+        Boolean isExist = true;
+        if (policyInfo.getId() == null){
+            isExist = false;
+            policyInfo.setId(SnowFlakeUtil.getId());
+            policyInfo.setUploadDate(LocalDate.now());
+            //删除之前的附件
+            attachmentInfoService.deleteByMasterId(-1L);
+        }else {
+            //删除之前的附件
+            attachmentInfoService.deleteByMasterId(policyInfo.getId());
+        }
+        List<AttachmentInfo> list = dto.getList();
+        if (list == null || list.size() == 0){
+            throw new ServiceException("请上传附件");
+        }
+        List<String> data = new ArrayList<>();
+        for (AttachmentInfo info : list) {
+            info.setMasterId(policyInfo.getId());
+            data.add(info.getDomainPdfUrl());
+        }
+        if (data.size() < 1){
+            throw new ServiceException("附件信息错误");
+        }
+        String listPdf = file_path + "/pdf/" + policyInfo.getId() + ".pdf";
+        File pdf2 = ResourceUtil.getFile(listPdf);
+        if (pdf2.exists()) {
+            pdf2.delete();
+        }
+        //pdf合并
+        FileUtils.mergePdfPublicMethods(data, listPdf);
+        BladeFile bladeFile = this.newIOSSClient.uploadFile( policyInfo.getId() + ".pdf", listPdf);
+        policyInfo.setPdfUrl(bladeFile.getLink());
+        if (isExist){
+            this.updateById(policyInfo);
+        }else {
+            this.save(policyInfo);
+        }
+        //修改附件的主件id
+        attachmentInfoService.saveBatch(list);
+    }
+
+    /**
+     * 分页查询
+     * @param page
+     * @param dto
+     * @return
+     */
+    @Override
+    public IPage<PolicyInfo> page(Query page, PolicyInfoSearchDTO dto) {
+        IPage<PolicyInfo> iPage = new Page<>(page.getCurrent(),page.getSize());
+        return baseMapper.page(iPage,dto);
+    }
+
+    /**
+     * 批量删除
+     * @param ids
+     */
+    @Override
+    public void remove(List<Long> ids) {
+        //删除附件
+        attachmentInfoService.deleteByMasterIds(ids);
+        //删除主件
+        baseMapper.deleteBatchIds(ids);
+    }
+
+    /**
+     * 根据id查询
+     * @param id
+     * @return
+     */
+    @Override
+    public PolicyInfoDTO detail(Long id) {
+        PolicyInfoDTO dto = new PolicyInfoDTO();
+        PolicyInfo info = this.getById(id);
+        BeanUtils.copyProperties(info,dto);
+        List<AttachmentInfo> list = attachmentInfoService.getAllFile(id);
+        dto.setList(list);
+        return dto;
+    }
+
+}

+ 74 - 0
blade-service/blade-land/src/main/java/org/springblade/land/utils/FileUtils.java

@@ -0,0 +1,74 @@
+package org.springblade.land.utils;
+
+
+import com.itextpdf.text.Document;
+import com.itextpdf.text.pdf.PdfCopy;
+import com.itextpdf.text.pdf.PdfReader;
+import lombok.extern.slf4j.Slf4j;
+import org.springblade.common.constant.CommonConstant;
+import org.springblade.common.utils.CommonUtil;
+import org.springblade.common.utils.SystemUtils;
+import org.springblade.system.cache.ParamCache;
+
+import java.io.FileOutputStream;
+import java.util.List;
+
+@Slf4j
+public class FileUtils {
+
+    /**
+     * 合并方法
+     */
+    public static void mergePdfPublicMethods(List<String> urlList, String localImgUrl) {
+        PdfReader reader = null;
+
+        Document doc = new Document();
+        PdfCopy pdfCopy = null;
+        try {
+            pdfCopy = new PdfCopy(doc, new FileOutputStream(localImgUrl));
+            int pageCount;
+            doc.open();
+
+            for (String urlStr : urlList) {
+                try {
+                    //获取OSS文件输入流
+                    reader = new PdfReader(CommonUtil.getOSSInputStream(urlStr));
+
+                    pageCount = reader.getNumberOfPages();
+
+                    for (int i = 0; i < pageCount; ++i) {
+                        int is = i + 1;
+                        pdfCopy.addPage(pdfCopy.getImportedPage(reader, is));
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                } finally {
+                    if (reader != null) {
+                        reader.close();
+                    }
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (pdfCopy != null) {
+                pdfCopy.flush();
+                pdfCopy.close();
+            }
+            doc.close();
+        }
+    }
+
+    public static String getSysLocalFileUrl() {
+        String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+        if (SystemUtils.isMacOs()) {
+            file_path = "/Users/hongchuangyanfa/Desktop/";
+        } else if (SystemUtils.isWindows()) {
+            file_path = "C://upload";
+        }
+        return file_path;
+    }
+
+
+}