浏览代码

文件上传

rainwer 7 月之前
父节点
当前提交
b633e0c5ed

+ 107 - 0
src/main/java/cn/ezhizao/project/business/fileUpload/controller/BizFileUploadController.java

@@ -0,0 +1,107 @@
+package cn.ezhizao.project.business.fileUpload.controller;
+
+import cn.ezhizao.common.utils.poi.ExcelUtil;
+import cn.ezhizao.framework.aspectj.lang.annotation.Log;
+import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
+import cn.ezhizao.framework.web.controller.BaseController;
+import cn.ezhizao.framework.web.domain.AjaxResult;
+import cn.ezhizao.framework.web.page.TableDataInfo;
+import cn.ezhizao.project.business.fileUpload.domain.BizFileUpload;
+import cn.ezhizao.project.business.fileUpload.service.IBizFileUploadService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 企业文件Controller
+ *
+ * @author ruoyi
+ * @date 2025-02-21
+ */
+@RestController
+@RequestMapping("/business/upload")
+public class BizFileUploadController extends BaseController {
+    @Resource
+    private IBizFileUploadService bizFileUploadService;
+
+    /**
+     * 查询企业文件列表
+     */
+    @PreAuthorize("@ss.hasPermi('business:upload:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(BizFileUpload bizFileUpload) throws NoSuchFieldException, IllegalAccessException {
+        setTenantId(bizFileUpload);
+        startPage();
+        List<BizFileUpload> list = bizFileUploadService.getList(bizFileUpload);
+        return getDataTable(list);
+    }
+
+    @PostMapping("/save")
+    @ApiOperation(value = "保存", notes = "保存")
+    @Transactional(rollbackFor = Exception.class)
+    @ResponseBody
+    public AjaxResult save(@RequestBody BizFileUpload bizFileUpload) throws NoSuchFieldException, IllegalAccessException {
+        setTenantId(bizFileUpload);
+        boolean res = bizFileUploadService.saveFiles(bizFileUpload);
+        return toAjax(res);
+    }
+
+    /**
+     * 导出企业文件列表
+     */
+    @PreAuthorize("@ss.hasPermi('business:upload:export')")
+    @Log(title = "企业文件", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, BizFileUpload bizFileUpload) throws NoSuchFieldException, IllegalAccessException {
+        setTenantId(bizFileUpload);
+        List<BizFileUpload> list = bizFileUploadService.getList(bizFileUpload);
+        ExcelUtil<BizFileUpload> util = new ExcelUtil<BizFileUpload>(BizFileUpload.class);
+        util.exportExcel(response, list, "企业文件数据");
+    }
+
+    /**
+     * 获取企业文件详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('business:upload:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
+        return success(bizFileUploadService.getById(id));
+    }
+
+    /**
+     * 新增企业文件
+     */
+    @PreAuthorize("@ss.hasPermi('business:upload:add')")
+    @Log(title = "企业文件", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody BizFileUpload bizFileUpload) throws NoSuchFieldException, IllegalAccessException {
+        setTenantId(bizFileUpload);
+        return toAjax(bizFileUploadService.save(bizFileUpload));
+    }
+
+    /**
+     * 修改企业文件
+     */
+    @PreAuthorize("@ss.hasPermi('business:upload:edit')")
+    @Log(title = "企业文件", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody BizFileUpload bizFileUpload) throws NoSuchFieldException, IllegalAccessException {
+        setTenantId(bizFileUpload);
+        return toAjax(bizFileUploadService.updateById(bizFileUpload));
+    }
+
+    /**
+     * 删除企业文件
+     */
+    @PreAuthorize("@ss.hasPermi('business:upload:remove')")
+    @Log(title = "企业文件", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable List<Long> ids) {
+        return toAjax(bizFileUploadService.removeBatchByIds(ids));
+    }
+}

+ 80 - 0
src/main/java/cn/ezhizao/project/business/fileUpload/domain/BizFileUpload.java

@@ -0,0 +1,80 @@
+package cn.ezhizao.project.business.fileUpload.domain;
+
+import cn.ezhizao.framework.aspectj.lang.annotation.Excel;
+import cn.ezhizao.framework.web.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 企业租户对象 biz_file_upload
+ *
+ * @author ruoyi
+ * @date 2025-02-21
+ */
+@Data
+@TableName(value = "biz_file_upload")
+public class BizFileUpload extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 客户外键
+     */
+    @ApiModelProperty(value = "${comment}")
+    private Long companyId;
+
+    /**
+     * 租户外键
+     */
+    @ApiModelProperty(value = "${comment}")
+    private Long tenantId;
+
+    /**
+     * 租户外键
+     */
+    @TableField(exist = false)
+    @ApiModelProperty(value = "${comment}")
+    private List<Long> tenantIds;
+
+    /**
+     * 附件类型
+     */
+    @Excel(name = "附件类型")
+    @ApiModelProperty(value = "附件类型")
+    private Long type;
+
+    /**
+     * 文件地址
+     */
+    @Excel(name = "文件地址")
+    @ApiModelProperty(value = "文件地址")
+    private String fileUrl;
+
+    /**
+     * 文件名
+     */
+    @Excel(name = "文件名")
+    @ApiModelProperty(value = "文件名")
+    private String fileName;
+
+    private List<BizFileUpload> files;
+
+    @TableField(exist = false)
+    @Excel(name = "门店名称")
+    private String accountName;
+    @TableField(exist = false)
+    @Excel(name = "公司名称")
+    private String companyName;
+    @TableField(exist = false)
+    @Excel(name = "用户名称")
+    private String userName;
+    @TableField(exist = false)
+    private List<String> dateFilterFinish;
+
+    @TableField(exist = false)
+    @Excel(name = "租户版本Id")
+    private Integer tenantVersionId;
+}

+ 30 - 0
src/main/java/cn/ezhizao/project/business/fileUpload/mapper/BizFileUploadMapper.java

@@ -0,0 +1,30 @@
+package cn.ezhizao.project.business.fileUpload.mapper;
+
+import java.util.List;
+
+import cn.ezhizao.project.business.fileUpload.domain.BizFileUpload;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 企业租户Mapper接口
+ *
+ * @author ruoyi
+ * @date 2025-02-21
+ */
+public interface BizFileUploadMapper extends BaseMapper<BizFileUpload>
+{
+    /**
+     * 查询企业租户列表
+     *
+     * @param bizFileUpload 企业租户
+     * @return 企业租户集合
+     */
+    public List<BizFileUpload> getList(BizFileUpload bizFileUpload);
+
+    /**
+     * 物理删除
+     * @param bizFileUpload
+     * @return 删除结果
+    */
+    public int physicalDelete(BizFileUpload bizFileUpload);
+}

+ 33 - 0
src/main/java/cn/ezhizao/project/business/fileUpload/service/IBizFileUploadService.java

@@ -0,0 +1,33 @@
+package cn.ezhizao.project.business.fileUpload.service;
+
+import java.util.List;
+
+import cn.ezhizao.project.business.fileUpload.domain.BizFileUpload;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 企业租户Service接口
+ *
+ * @author ruoyi
+ * @date 2025-02-21
+ */
+public interface IBizFileUploadService extends IService<BizFileUpload>
+{
+    /**
+     * 查询企业租户列表
+     *
+     * @param bizFileUpload 企业租户
+     * @return 企业租户集合
+     */
+    public List<BizFileUpload> getList(BizFileUpload bizFileUpload);
+
+    /**
+     * 物理删除
+     * @param bizFileUpload
+     * @return 删除结果
+     */
+    public int physicalDelete(BizFileUpload bizFileUpload);
+
+    boolean saveFiles(BizFileUpload bizFileUpload);
+
+}

+ 75 - 0
src/main/java/cn/ezhizao/project/business/fileUpload/service/impl/BizFileUploadServiceImpl.java

@@ -0,0 +1,75 @@
+package cn.ezhizao.project.business.fileUpload.service.impl;
+
+import cn.ezhizao.project.business.fileUpload.domain.BizFileUpload;
+import cn.ezhizao.project.business.fileUpload.mapper.BizFileUploadMapper;
+import cn.ezhizao.project.business.fileUpload.service.IBizFileUploadService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.Resource;
+import java.util.Collection;
+import java.util.List;
+
+
+/**
+ * 企业租户Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2025-02-21
+ */
+@Service
+public class BizFileUploadServiceImpl extends ServiceImpl<BizFileUploadMapper, BizFileUpload> implements IBizFileUploadService {
+    @Resource
+    private BizFileUploadMapper bizFileUploadMapper;
+
+    /**
+     * 查询企业租户列表
+     *
+     * @param bizFileUpload 企业租户
+     * @return 企业租户
+     */
+    @Override
+    public List<BizFileUpload> getList(BizFileUpload bizFileUpload) {
+        return bizFileUploadMapper.getList(bizFileUpload);
+    }
+
+    /**
+     * 物理删除
+     *
+     * @param bizFileUpload
+     * @return 删除结果
+     */
+    @Override
+    public int physicalDelete(BizFileUpload bizFileUpload) {
+        return bizFileUploadMapper.physicalDelete(bizFileUpload);
+    }
+
+    /**
+     * 批量上传
+     *
+     * @param bizFileUpload
+     * @return
+     */
+    @Override
+    public boolean saveFiles(BizFileUpload bizFileUpload) {
+        if (!CollectionUtils.isEmpty(bizFileUpload.getFiles())) {
+            for (BizFileUpload file : bizFileUpload.getFiles()) {
+                file.setCompanyId(bizFileUpload.getCompanyId());
+                file.setType(bizFileUpload.getType());
+                file.setTenantId(bizFileUpload.getTenantId());
+            }
+            return super.saveBatch(bizFileUpload.getFiles());
+        }
+
+        return false;
+    }
+
+    ;
+
+    @Override
+    public boolean saveBatch(Collection<BizFileUpload> entityList) {
+        return super.saveBatch(entityList);
+    }
+
+}

+ 0 - 1
src/main/java/cn/ezhizao/project/business/salary/controller/BizFinancialSalaryController.java

@@ -75,7 +75,6 @@ import org.apache.poi.ss.usermodel.CellStyle;
 import org.apache.poi.ss.usermodel.Font;
 import org.apache.poi.ss.usermodel.HorizontalAlignment;
 import org.apache.poi.ss.usermodel.VerticalAlignment;
-import org.omg.CORBA.PRIVATE_MEMBER;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;

+ 49 - 0
src/main/resources/mybatis/business/BizFileUploadMapper.xml

@@ -0,0 +1,49 @@
+<?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="cn.ezhizao.project.business.fileUpload.mapper.BizFileUploadMapper">
+
+    <resultMap type="cn.ezhizao.project.business.fileUpload.domain.BizFileUpload" id="BizFileUploadResult">
+        <id column="id" property="id"/>
+    </resultMap>
+
+
+    <select id="getList" parameterType="BizFileUpload" resultMap="BizFileUploadResult">
+        select
+            bfu.*,
+            bt.account_name,
+            bc.name as company_name,
+            su.nick_name user_name
+            from
+            biz_file_upload bfu
+            left join biz_tenant bt on
+            bt.id = bfu.tenant_id
+            left join biz_company bc  on
+            bc.id = bfu.company_id
+            left join sys_user su on su.user_id = bfu.creator_id
+            <if test="tenantVersionId == 4 "> left join biz_entrust_order beo on beo.from_tenant_id = bfu.tenant_id and beo.deleted = 0 </if>
+        <trim prefix=" WHERE" suffix="" prefixOverrides="AND" suffixOverrides="AND">
+            <if test="deleted != null "> AND bfu.deleted = #{deleted}</if>
+            <if test="type != null "> AND bfu.type = #{type}</if>
+            <if test="tenantVersionId == 4 "> and beo.tenant_id = #{tenantId} </if>
+            <if test="tenantVersionId != 4 and tenantId != null "> AND bfu.tenant_id = #{tenantId}</if>
+            <if test="fileName != null  and fileName != ''"> AND bfu.file_name like concat('%', #{fileName}, '%')</if>
+            <if test="companyName != null  and companyName != ''"> AND bc.name like concat('%', #{companyName}, '%')</if>
+            <if test="userName != null  and userName != ''"> AND su.nick_name like concat('%', #{userName}, '%')</if>
+            <if test="dateFilterFinish != null and dateFilterFinish.size()>0 ">
+                AND  bfu.create_time between  STR_TO_DATE(#{dateFilterFinish[0]}, '%Y-%m-%d') and STR_TO_DATE(#{dateFilterFinish[1]}, '%Y-%m-%d')
+            </if>
+        </trim>
+    </select>
+
+    <delete id="physicalDelete">
+        DELETE FROM biz_file_upload
+        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
+            <if test="id != null">
+                id = #{id} AND
+            </if>
+       <!-- 删除条件为其他外键可以在这里加 -->
+        </trim>
+    </delete>
+</mapper>