实名认证
This commit is contained in:
		@ -42,6 +42,9 @@ public class AnnexQueryBo extends BaseEntity {
 | 
			
		||||
	/** 唯一标识 */
 | 
			
		||||
	@ApiModelProperty("唯一标识")
 | 
			
		||||
	private Long userId;
 | 
			
		||||
	/** 用户类型 */
 | 
			
		||||
	@ApiModelProperty("用户类型")
 | 
			
		||||
	private String userType;
 | 
			
		||||
	/** 附件类型 */
 | 
			
		||||
	@ApiModelProperty("附件类型")
 | 
			
		||||
	private String annexType;
 | 
			
		||||
 | 
			
		||||
@ -21,6 +21,9 @@ public class AnnexDTO {
 | 
			
		||||
	/** 唯一标识 */
 | 
			
		||||
	@ApiModelProperty("唯一标识")
 | 
			
		||||
	private Long userId;
 | 
			
		||||
	/** 用户类型 */
 | 
			
		||||
	@ApiModelProperty("用户类型")
 | 
			
		||||
	private String userType;
 | 
			
		||||
	/** 附件类型 */
 | 
			
		||||
	@ApiModelProperty("附件类型")
 | 
			
		||||
	private String annexType;
 | 
			
		||||
 | 
			
		||||
@ -69,4 +69,9 @@ public interface IAnnexService extends IServicePlus<Annex> {
 | 
			
		||||
	 */
 | 
			
		||||
	void insertBatch(List<AnnexDTO> annexList);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 根据表自增ID来删除指定附件数据,并删除对应的资源
 | 
			
		||||
	 */
 | 
			
		||||
	Boolean deleteByIds(Long id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -4,9 +4,11 @@ import cn.hutool.core.bean.BeanUtil;
 | 
			
		||||
import cn.hutool.core.util.StrUtil;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
			
		||||
import com.ruoyi.common.domain.dto.AnnexDTO;
 | 
			
		||||
import com.ruoyi.common.tool.FileDeletionService;
 | 
			
		||||
import com.ruoyi.common.utils.PageUtils;
 | 
			
		||||
import com.ruoyi.common.core.page.PagePlus;
 | 
			
		||||
import com.ruoyi.common.core.page.TableDataInfo;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
			
		||||
@ -15,7 +17,9 @@ import com.ruoyi.common.bo.AnnexQueryBo;
 | 
			
		||||
import com.ruoyi.common.domain.Annex;
 | 
			
		||||
import com.ruoyi.common.mapper.AnnexMapper;
 | 
			
		||||
import com.ruoyi.common.service.IAnnexService;
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
 | 
			
		||||
import javax.tools.Tool;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
@ -30,6 +34,9 @@ import java.util.stream.Collectors;
 | 
			
		||||
@Service
 | 
			
		||||
public class AnnexServiceImpl extends ServicePlusImpl<AnnexMapper, Annex> implements IAnnexService {
 | 
			
		||||
 | 
			
		||||
	@Autowired
 | 
			
		||||
	private FileDeletionService fileDeletionService;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Annex queryById(String id){
 | 
			
		||||
        return getById(id);
 | 
			
		||||
@ -103,4 +110,21 @@ public class AnnexServiceImpl extends ServicePlusImpl<AnnexMapper, Annex> implem
 | 
			
		||||
			.collect(Collectors.toList());
 | 
			
		||||
		baseMapper.insertAll(annexes);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	@Transactional
 | 
			
		||||
	public Boolean deleteByIds(Long id) {
 | 
			
		||||
		//1、查询数据
 | 
			
		||||
		Annex annex = baseMapper.selectById(id);
 | 
			
		||||
		//2、删除对应的数据,并删除相对应的资源
 | 
			
		||||
		if (baseMapper.deleteById(id)>0){
 | 
			
		||||
			boolean b = fileDeletionService.deleteFileByPath(annex.getAnnexUrl());
 | 
			
		||||
			if(!b){
 | 
			
		||||
				throw new RuntimeException("附件删除失败!");
 | 
			
		||||
			}
 | 
			
		||||
		}else{
 | 
			
		||||
			throw new RuntimeException("数据删除失败!");
 | 
			
		||||
		}
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,32 @@
 | 
			
		||||
package com.ruoyi.common.tool;
 | 
			
		||||
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
 | 
			
		||||
@Service
 | 
			
		||||
public class FileDeletionService {
 | 
			
		||||
	/**
 | 
			
		||||
	 * 根据文件路径删除文件
 | 
			
		||||
	 * @param filePath 文件的完整路径
 | 
			
		||||
	 * @return 如果文件删除成功返回 true,否则返回 false
 | 
			
		||||
	 */
 | 
			
		||||
	public boolean deleteFileByPath(String filePath) {
 | 
			
		||||
		if (filePath == null || filePath.isEmpty()) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		File file = new File(filePath);
 | 
			
		||||
		// 检查文件是否存在并且是一个普通文件
 | 
			
		||||
		if (file.exists() && file.isFile()) {
 | 
			
		||||
			try {
 | 
			
		||||
				// 执行删除操作
 | 
			
		||||
				return file.delete();
 | 
			
		||||
			} catch (SecurityException e) {
 | 
			
		||||
				// 处理没有权限删除文件的异常
 | 
			
		||||
				System.err.println("没有权限删除文件: " + filePath);
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user