youjianchi
1 year ago
28 changed files with 13463 additions and 30 deletions
@ -0,0 +1,21 @@ |
|||
package com.ruoyi.common.service; |
|||
|
|||
import com.ruoyi.common.core.domain.AjaxResult; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description 公共服务 |
|||
* @Author youjianchi |
|||
* @Date 2023/11/13 14:23 |
|||
*/ |
|||
public interface ICommonService { |
|||
AjaxResult uploadFile(MultipartFile file,String sourceType,String sourceSubType,Long attachId) throws Exception; |
|||
|
|||
AjaxResult uploadSingleFile(MultipartFile file); |
|||
|
|||
AjaxResult delete(Long id); |
|||
|
|||
void deleteByIds(List<String> ids); |
|||
} |
@ -0,0 +1,141 @@ |
|||
package com.ruoyi.common.service.impl; |
|||
|
|||
import com.ruoyi.common.config.RuoYiConfig; |
|||
import com.ruoyi.common.config.ServerConfig; |
|||
import com.ruoyi.common.core.domain.AjaxResult; |
|||
import com.ruoyi.common.service.ICommonService; |
|||
import com.ruoyi.common.utils.file.FileUploadUtils; |
|||
import com.ruoyi.common.utils.file.FileUtils; |
|||
import com.ruoyi.system.domain.SysAttach; |
|||
import com.ruoyi.system.domain.SysAttachFile; |
|||
import com.ruoyi.system.service.ISysAttachFileService; |
|||
import com.ruoyi.system.service.ISysAttachService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description 公共服务实现 |
|||
* @Author youjianchi |
|||
* @Date 2023/11/13 14:25 |
|||
*/ |
|||
@Service |
|||
public class CommonServiceImpl implements ICommonService { |
|||
|
|||
@Autowired |
|||
private ServerConfig serverConfig; |
|||
|
|||
@Autowired |
|||
private ISysAttachService attachService; |
|||
|
|||
@Autowired |
|||
private ISysAttachFileService attachFileService; |
|||
|
|||
private static final String FILE_DELIMETER = ","; |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public AjaxResult uploadFile(MultipartFile file, String sourceType, String sourceSubType,Long attachId) throws Exception { |
|||
// 上传文件路径
|
|||
String filePath = RuoYiConfig.getUploadPath(); |
|||
// 上传并返回新文件名称
|
|||
String fileName = null; |
|||
try { |
|||
fileName = FileUploadUtils.upload(filePath, file); |
|||
} catch (Exception e) { |
|||
throw new Exception("文件上传失败"); |
|||
} |
|||
String url = serverConfig.getUrl() + fileName; |
|||
String originalFilename = file.getOriginalFilename(); |
|||
String fileExt = originalFilename.substring(originalFilename.lastIndexOf(".")+1); |
|||
Long fileSize = file.getSize(); |
|||
if(attachId==null){ |
|||
SysAttach attach = new SysAttach(); |
|||
attach.setCreateBy("admin"); |
|||
attach.setCreateTime(new Date()); |
|||
attach.setSourceType(sourceType); |
|||
attach.setSourceSubType(sourceSubType); |
|||
attachService.insertSysAttach(attach); |
|||
attachId = attach.getId(); |
|||
} |
|||
SysAttachFile sysAttachFile = new SysAttachFile(); |
|||
sysAttachFile.setAttachId(attachId); |
|||
sysAttachFile.setName(originalFilename); |
|||
sysAttachFile.setUrl(url); |
|||
sysAttachFile.setSize(fileSize); |
|||
sysAttachFile.setExt(fileExt); |
|||
attachFileService.insertSysAttachFile(sysAttachFile); |
|||
Long fileId = sysAttachFile.getId(); |
|||
AjaxResult ajax = AjaxResult.success(); |
|||
ajax.put("attachId", attachId); |
|||
ajax.put("fileId", fileId); |
|||
ajax.put("url", url); |
|||
ajax.put("fileName", fileName); |
|||
ajax.put("newFileName", FileUtils.getName(fileName)); |
|||
ajax.put("originalFilename", originalFilename); |
|||
return ajax; |
|||
} |
|||
|
|||
@Override |
|||
public AjaxResult uploadSingleFile(MultipartFile file) { |
|||
try |
|||
{ |
|||
// 上传文件路径
|
|||
String filePath = RuoYiConfig.getUploadPath(); |
|||
// 上传并返回新文件名称
|
|||
String fileName = FileUploadUtils.upload(filePath, file); |
|||
String url = serverConfig.getUrl() + fileName; |
|||
String originalFilename = file.getOriginalFilename(); |
|||
String fileExt = originalFilename.substring(originalFilename.lastIndexOf(".")+1); |
|||
Long fileSize = file.getSize(); |
|||
// 保存文件信息
|
|||
SysAttachFile sysAttachFile = new SysAttachFile(); |
|||
sysAttachFile.setName(originalFilename); |
|||
sysAttachFile.setUrl(url); |
|||
sysAttachFile.setSize(fileSize); |
|||
sysAttachFile.setExt(fileExt); |
|||
sysAttachFile.setPath(fileName); |
|||
attachFileService.insertSysAttachFile(sysAttachFile); |
|||
AjaxResult ajax = AjaxResult.success(sysAttachFile); |
|||
return ajax; |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
return AjaxResult.error(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public AjaxResult delete(Long id) { |
|||
SysAttachFile attachFile = attachFileService.selectSysAttachFileById(id); |
|||
if(attachFile!=null){ |
|||
String path = attachFile.getPath(); |
|||
String actualPath = RuoYiConfig.getProfile()+ path.replace("/profile",""); |
|||
// 删除文件
|
|||
FileUtils.deleteFile(actualPath); |
|||
// 删除文件信息
|
|||
attachFileService.deleteSysAttachFileById(id); |
|||
} |
|||
return AjaxResult.success(); |
|||
} |
|||
|
|||
@Override |
|||
public void deleteByIds(List<String> ids) { |
|||
ids.forEach(idStr->{ |
|||
Long id = Long.parseLong(idStr); |
|||
SysAttachFile attachFile = attachFileService.selectSysAttachFileById(id); |
|||
if(attachFile!=null){ |
|||
String path = attachFile.getPath(); |
|||
String actualPath = RuoYiConfig.getProfile()+ path.replace("/profile",""); |
|||
// 删除文件
|
|||
FileUtils.deleteFile(actualPath); |
|||
// 删除文件信息
|
|||
attachFileService.deleteSysAttachFileById(id); |
|||
} |
|||
}); |
|||
} |
|||
} |
@ -0,0 +1,48 @@ |
|||
package com.ruoyi.system.controller; |
|||
|
|||
import com.ruoyi.common.core.controller.BaseController; |
|||
import com.ruoyi.common.core.domain.AjaxResult; |
|||
import com.ruoyi.system.domain.SysAttachFile; |
|||
import com.ruoyi.system.service.ISysAttachFileService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 附件文件Controller |
|||
* |
|||
* @author ruoyi |
|||
* @date 2023-11-13 |
|||
*/ |
|||
@Controller |
|||
@RequestMapping("/system/attach/file") |
|||
public class SysAttachFileController extends BaseController |
|||
{ |
|||
private String prefix = "system/attach/file"; |
|||
|
|||
@Autowired |
|||
private ISysAttachFileService sysAttachFileService; |
|||
|
|||
@GetMapping( "/getListByAttachId") |
|||
@ResponseBody |
|||
public AjaxResult getListByAttachId(@RequestParam("attachId")Long attachId){ |
|||
List<SysAttachFile> attachFileList = sysAttachFileService.getListByAttachId(attachId); |
|||
return AjaxResult.success(attachFileList); |
|||
} |
|||
@GetMapping( "/delFileAndAttachById") |
|||
@ResponseBody |
|||
public AjaxResult delFileAndAttachById(Long id) |
|||
{ |
|||
return toAjax(sysAttachFileService.delFileAndAttachById(id)); |
|||
} |
|||
|
|||
@PostMapping( "/delFileAndAttachByKey") |
|||
@ResponseBody |
|||
public AjaxResult delFileAndAttachByKey(Long key) |
|||
{ |
|||
return toAjax(sysAttachFileService.delFileAndAttachById(key)); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,97 @@ |
|||
package com.ruoyi.system.domain; |
|||
|
|||
import com.ruoyi.common.annotation.Excel; |
|||
import com.ruoyi.common.core.domain.BaseEntity; |
|||
import org.apache.commons.lang3.builder.ToStringBuilder; |
|||
import org.apache.commons.lang3.builder.ToStringStyle; |
|||
|
|||
/** |
|||
* 附件业务关联对象 sys_attach |
|||
* |
|||
* @author ruoyi |
|||
* @date 2023-11-13 |
|||
*/ |
|||
public class SysAttach extends BaseEntity |
|||
{ |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** 主键ID */ |
|||
private Long id; |
|||
|
|||
/** 删除标志(0代表存在 2代表删除) */ |
|||
private String delFlag; |
|||
|
|||
/** 关联记录ID */ |
|||
@Excel(name = "关联记录ID") |
|||
private Long relId; |
|||
|
|||
/** 附件业务类型 */ |
|||
@Excel(name = "附件业务类型") |
|||
private String sourceType; |
|||
|
|||
/** 附件业务子类型 */ |
|||
@Excel(name = "附件业务子类型") |
|||
private String sourceSubType; |
|||
|
|||
public void setId(Long id) |
|||
{ |
|||
this.id = id; |
|||
} |
|||
|
|||
public Long getId() |
|||
{ |
|||
return id; |
|||
} |
|||
public void setDelFlag(String delFlag) |
|||
{ |
|||
this.delFlag = delFlag; |
|||
} |
|||
|
|||
public String getDelFlag() |
|||
{ |
|||
return delFlag; |
|||
} |
|||
public void setRelId(Long relId) |
|||
{ |
|||
this.relId = relId; |
|||
} |
|||
|
|||
public Long getRelId() |
|||
{ |
|||
return relId; |
|||
} |
|||
public void setSourceType(String sourceType) |
|||
{ |
|||
this.sourceType = sourceType; |
|||
} |
|||
|
|||
public String getSourceType() |
|||
{ |
|||
return sourceType; |
|||
} |
|||
public void setSourceSubType(String sourceSubType) |
|||
{ |
|||
this.sourceSubType = sourceSubType; |
|||
} |
|||
|
|||
public String getSourceSubType() |
|||
{ |
|||
return sourceSubType; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
|||
.append("id", getId()) |
|||
.append("delFlag", getDelFlag()) |
|||
.append("createBy", getCreateBy()) |
|||
.append("createTime", getCreateTime()) |
|||
.append("updateBy", getUpdateBy()) |
|||
.append("updateTime", getUpdateTime()) |
|||
.append("remark", getRemark()) |
|||
.append("relId", getRelId()) |
|||
.append("sourceType", getSourceType()) |
|||
.append("sourceSubType", getSourceSubType()) |
|||
.toString(); |
|||
} |
|||
} |
@ -0,0 +1,138 @@ |
|||
package com.ruoyi.system.domain; |
|||
|
|||
import com.ruoyi.common.annotation.Excel; |
|||
import com.ruoyi.common.core.domain.BaseEntity; |
|||
import org.apache.commons.lang3.builder.ToStringBuilder; |
|||
import org.apache.commons.lang3.builder.ToStringStyle; |
|||
|
|||
/** |
|||
* 附件文件对象 sys_attach_file |
|||
* |
|||
* @author ruoyi |
|||
* @date 2023-11-13 |
|||
*/ |
|||
public class SysAttachFile extends BaseEntity |
|||
{ |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** 主键ID */ |
|||
private Long id; |
|||
|
|||
/** 删除标志(0代表存在 2代表删除) */ |
|||
private String delFlag; |
|||
|
|||
/** 附件业务id */ |
|||
@Excel(name = "附件业务id") |
|||
private Long attachId; |
|||
|
|||
/** 文件名称 */ |
|||
@Excel(name = "文件名称") |
|||
private String name; |
|||
|
|||
/** 文件后缀 */ |
|||
@Excel(name = "文件后缀") |
|||
private String ext; |
|||
|
|||
/** 文件大小 */ |
|||
@Excel(name = "文件大小") |
|||
private Long size; |
|||
|
|||
/** 文件url */ |
|||
@Excel(name = "文件url") |
|||
private String url; |
|||
|
|||
/** 文件路径 */ |
|||
@Excel(name = "文件路径") |
|||
private String path; |
|||
|
|||
public void setId(Long id) |
|||
{ |
|||
this.id = id; |
|||
} |
|||
|
|||
public Long getId() |
|||
{ |
|||
return id; |
|||
} |
|||
public void setDelFlag(String delFlag) |
|||
{ |
|||
this.delFlag = delFlag; |
|||
} |
|||
|
|||
public String getDelFlag() |
|||
{ |
|||
return delFlag; |
|||
} |
|||
public void setAttachId(Long attachId) |
|||
{ |
|||
this.attachId = attachId; |
|||
} |
|||
|
|||
public Long getAttachId() |
|||
{ |
|||
return attachId; |
|||
} |
|||
public void setName(String name) |
|||
{ |
|||
this.name = name; |
|||
} |
|||
|
|||
public String getName() |
|||
{ |
|||
return name; |
|||
} |
|||
public void setExt(String ext) |
|||
{ |
|||
this.ext = ext; |
|||
} |
|||
|
|||
public String getExt() |
|||
{ |
|||
return ext; |
|||
} |
|||
public void setSize(Long size) |
|||
{ |
|||
this.size = size; |
|||
} |
|||
|
|||
public Long getSize() |
|||
{ |
|||
return size; |
|||
} |
|||
public void setUrl(String url) |
|||
{ |
|||
this.url = url; |
|||
} |
|||
|
|||
public String getUrl() |
|||
{ |
|||
return url; |
|||
} |
|||
|
|||
public String getPath() { |
|||
return path; |
|||
} |
|||
|
|||
public void setPath(String path) { |
|||
this.path = path; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
|||
.append("id", getId()) |
|||
.append("delFlag", getDelFlag()) |
|||
.append("createBy", getCreateBy()) |
|||
.append("createTime", getCreateTime()) |
|||
.append("updateBy", getUpdateBy()) |
|||
.append("updateTime", getUpdateTime()) |
|||
.append("remark", getRemark()) |
|||
.append("attachId", getAttachId()) |
|||
.append("name", getName()) |
|||
.append("ext", getExt()) |
|||
.append("size", getSize()) |
|||
.append("url", getUrl()) |
|||
.append("path", getPath()) |
|||
.toString(); |
|||
} |
|||
} |
@ -0,0 +1,67 @@ |
|||
package com.ruoyi.system.mapper; |
|||
|
|||
import com.ruoyi.system.domain.SysAttachFile; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 附件文件Mapper接口 |
|||
* |
|||
* @author ruoyi |
|||
* @date 2023-11-13 |
|||
*/ |
|||
public interface SysAttachFileMapper |
|||
{ |
|||
/** |
|||
* 查询附件文件 |
|||
* |
|||
* @param id 附件文件ID |
|||
* @return 附件文件 |
|||
*/ |
|||
public SysAttachFile selectSysAttachFileById(Long id); |
|||
|
|||
/** |
|||
* 查询附件文件列表 |
|||
* |
|||
* @param sysAttachFile 附件文件 |
|||
* @return 附件文件集合 |
|||
*/ |
|||
public List<SysAttachFile> selectSysAttachFileList(SysAttachFile sysAttachFile); |
|||
|
|||
/** |
|||
* 新增附件文件 |
|||
* |
|||
* @param sysAttachFile 附件文件 |
|||
* @return 结果 |
|||
*/ |
|||
public int insertSysAttachFile(SysAttachFile sysAttachFile); |
|||
|
|||
/** |
|||
* 修改附件文件 |
|||
* |
|||
* @param sysAttachFile 附件文件 |
|||
* @return 结果 |
|||
*/ |
|||
public int updateSysAttachFile(SysAttachFile sysAttachFile); |
|||
|
|||
/** |
|||
* 删除附件文件 |
|||
* |
|||
* @param id 附件文件ID |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteSysAttachFileById(Long id); |
|||
|
|||
/** |
|||
* 批量删除附件文件 |
|||
* |
|||
* @param ids 需要删除的数据ID |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteSysAttachFileByIds(String[] ids); |
|||
|
|||
List<SysAttachFile> selectListByAttachId(Long attachId); |
|||
|
|||
int updateAttachIdByIdList(@Param("attachId")Long attachId,@Param("idList")List<String> idList); |
|||
} |
@ -0,0 +1,62 @@ |
|||
package com.ruoyi.system.mapper; |
|||
|
|||
import com.ruoyi.system.domain.SysAttach; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 附件业务关联Mapper接口 |
|||
* |
|||
* @author ruoyi |
|||
* @date 2023-11-13 |
|||
*/ |
|||
public interface SysAttachMapper |
|||
{ |
|||
/** |
|||
* 查询附件业务关联 |
|||
* |
|||
* @param id 附件业务关联ID |
|||
* @return 附件业务关联 |
|||
*/ |
|||
public SysAttach selectSysAttachById(Long id); |
|||
|
|||
/** |
|||
* 查询附件业务关联列表 |
|||
* |
|||
* @param sysAttach 附件业务关联 |
|||
* @return 附件业务关联集合 |
|||
*/ |
|||
public List<SysAttach> selectSysAttachList(SysAttach sysAttach); |
|||
|
|||
/** |
|||
* 新增附件业务关联 |
|||
* |
|||
* @param sysAttach 附件业务关联 |
|||
* @return 结果 |
|||
*/ |
|||
public int insertSysAttach(SysAttach sysAttach); |
|||
|
|||
/** |
|||
* 修改附件业务关联 |
|||
* |
|||
* @param sysAttach 附件业务关联 |
|||
* @return 结果 |
|||
*/ |
|||
public int updateSysAttach(SysAttach sysAttach); |
|||
|
|||
/** |
|||
* 删除附件业务关联 |
|||
* |
|||
* @param id 附件业务关联ID |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteSysAttachById(Long id); |
|||
|
|||
/** |
|||
* 批量删除附件业务关联 |
|||
* |
|||
* @param ids 需要删除的数据ID |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteSysAttachByIds(String[] ids); |
|||
} |
@ -0,0 +1,68 @@ |
|||
package com.ruoyi.system.service; |
|||
|
|||
import com.ruoyi.system.domain.SysAttachFile; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 附件文件Service接口 |
|||
* |
|||
* @author ruoyi |
|||
* @date 2023-11-13 |
|||
*/ |
|||
public interface ISysAttachFileService |
|||
{ |
|||
/** |
|||
* 查询附件文件 |
|||
* |
|||
* @param id 附件文件ID |
|||
* @return 附件文件 |
|||
*/ |
|||
public SysAttachFile selectSysAttachFileById(Long id); |
|||
|
|||
/** |
|||
* 查询附件文件列表 |
|||
* |
|||
* @param sysAttachFile 附件文件 |
|||
* @return 附件文件集合 |
|||
*/ |
|||
public List<SysAttachFile> selectSysAttachFileList(SysAttachFile sysAttachFile); |
|||
|
|||
/** |
|||
* 新增附件文件 |
|||
* |
|||
* @param sysAttachFile 附件文件 |
|||
* @return 结果 |
|||
*/ |
|||
public int insertSysAttachFile(SysAttachFile sysAttachFile); |
|||
|
|||
/** |
|||
* 修改附件文件 |
|||
* |
|||
* @param sysAttachFile 附件文件 |
|||
* @return 结果 |
|||
*/ |
|||
public int updateSysAttachFile(SysAttachFile sysAttachFile); |
|||
|
|||
/** |
|||
* 批量删除附件文件 |
|||
* |
|||
* @param ids 需要删除的数据ID |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteSysAttachFileByIds(String ids); |
|||
|
|||
/** |
|||
* 删除附件文件信息 |
|||
* |
|||
* @param id 附件文件ID |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteSysAttachFileById(Long id); |
|||
|
|||
List<SysAttachFile> getListByAttachId(Long attachId); |
|||
|
|||
int delFileAndAttachById(Long id); |
|||
|
|||
int updateAttachIdByIdList(Long attachId,List<String> idList); |
|||
} |
@ -0,0 +1,63 @@ |
|||
package com.ruoyi.system.service; |
|||
|
|||
import com.ruoyi.system.domain.SysAttach; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 附件业务关联Service接口 |
|||
* |
|||
* @author ruoyi |
|||
* @date 2023-11-13 |
|||
*/ |
|||
public interface ISysAttachService |
|||
{ |
|||
/** |
|||
* 查询附件业务关联 |
|||
* |
|||
* @param id 附件业务关联ID |
|||
* @return 附件业务关联 |
|||
*/ |
|||
public SysAttach selectSysAttachById(Long id); |
|||
|
|||
/** |
|||
* 查询附件业务关联列表 |
|||
* |
|||
* @param sysAttach 附件业务关联 |
|||
* @return 附件业务关联集合 |
|||
*/ |
|||
public List<SysAttach> selectSysAttachList(SysAttach sysAttach); |
|||
|
|||
/** |
|||
* 新增附件业务关联 |
|||
* |
|||
* @param sysAttach 附件业务关联 |
|||
* @return 结果 |
|||
*/ |
|||
public int insertSysAttach(SysAttach sysAttach); |
|||
|
|||
/** |
|||
* 修改附件业务关联 |
|||
* |
|||
* @param sysAttach 附件业务关联 |
|||
* @return 结果 |
|||
*/ |
|||
public int updateSysAttach(SysAttach sysAttach); |
|||
|
|||
/** |
|||
* 批量删除附件业务关联 |
|||
* |
|||
* @param ids 需要删除的数据ID |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteSysAttachByIds(String ids); |
|||
|
|||
/** |
|||
* 删除附件业务关联信息 |
|||
* |
|||
* @param id 附件业务关联ID |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteSysAttachById(Long id); |
|||
|
|||
} |
@ -0,0 +1,130 @@ |
|||
package com.ruoyi.system.service.impl; |
|||
|
|||
import com.ruoyi.common.core.text.Convert; |
|||
import com.ruoyi.common.utils.DateUtils; |
|||
import com.ruoyi.system.domain.SysAttachFile; |
|||
import com.ruoyi.system.mapper.SysAttachFileMapper; |
|||
import com.ruoyi.system.service.ISysAttachFileService; |
|||
import com.ruoyi.system.service.ISysAttachService; |
|||
import org.apache.commons.collections.CollectionUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 附件文件Service业务层处理 |
|||
* |
|||
* @author ruoyi |
|||
* @date 2023-11-13 |
|||
*/ |
|||
@Service |
|||
public class SysAttachFileServiceImpl implements ISysAttachFileService |
|||
{ |
|||
@Autowired |
|||
private SysAttachFileMapper sysAttachFileMapper; |
|||
|
|||
@Autowired |
|||
private ISysAttachService attachService; |
|||
|
|||
/** |
|||
* 查询附件文件 |
|||
* |
|||
* @param id 附件文件ID |
|||
* @return 附件文件 |
|||
*/ |
|||
@Override |
|||
public SysAttachFile selectSysAttachFileById(Long id) |
|||
{ |
|||
return sysAttachFileMapper.selectSysAttachFileById(id); |
|||
} |
|||
|
|||
/** |
|||
* 查询附件文件列表 |
|||
* |
|||
* @param sysAttachFile 附件文件 |
|||
* @return 附件文件 |
|||
*/ |
|||
@Override |
|||
public List<SysAttachFile> selectSysAttachFileList(SysAttachFile sysAttachFile) |
|||
{ |
|||
return sysAttachFileMapper.selectSysAttachFileList(sysAttachFile); |
|||
} |
|||
|
|||
/** |
|||
* 新增附件文件 |
|||
* |
|||
* @param sysAttachFile 附件文件 |
|||
* @return 结果 |
|||
*/ |
|||
@Override |
|||
public int insertSysAttachFile(SysAttachFile sysAttachFile) |
|||
{ |
|||
sysAttachFile.setCreateTime(DateUtils.getNowDate()); |
|||
return sysAttachFileMapper.insertSysAttachFile(sysAttachFile); |
|||
} |
|||
|
|||
/** |
|||
* 修改附件文件 |
|||
* |
|||
* @param sysAttachFile 附件文件 |
|||
* @return 结果 |
|||
*/ |
|||
@Override |
|||
public int updateSysAttachFile(SysAttachFile sysAttachFile) |
|||
{ |
|||
sysAttachFile.setUpdateTime(DateUtils.getNowDate()); |
|||
return sysAttachFileMapper.updateSysAttachFile(sysAttachFile); |
|||
} |
|||
|
|||
/** |
|||
* 删除附件文件对象 |
|||
* |
|||
* @param ids 需要删除的数据ID |
|||
* @return 结果 |
|||
*/ |
|||
@Override |
|||
public int deleteSysAttachFileByIds(String ids) |
|||
{ |
|||
return sysAttachFileMapper.deleteSysAttachFileByIds(Convert.toStrArray(ids)); |
|||
} |
|||
|
|||
/** |
|||
* 删除附件文件信息 |
|||
* |
|||
* @param id 附件文件ID |
|||
* @return 结果 |
|||
*/ |
|||
@Override |
|||
public int deleteSysAttachFileById(Long id) |
|||
{ |
|||
return sysAttachFileMapper.deleteSysAttachFileById(id); |
|||
} |
|||
|
|||
@Override |
|||
public List<SysAttachFile> getListByAttachId(Long attachId) { |
|||
SysAttachFile attachFile = new SysAttachFile(); |
|||
attachFile.setAttachId(attachId); |
|||
List<SysAttachFile> sysAttachFiles = selectSysAttachFileList(attachFile); |
|||
return sysAttachFiles; |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public int delFileAndAttachById(Long id) { |
|||
SysAttachFile attachFile = sysAttachFileMapper.selectSysAttachFileById(id); |
|||
Long attachId = attachFile.getAttachId(); |
|||
int i = sysAttachFileMapper.deleteSysAttachFileById(id); |
|||
List<SysAttachFile> attachFileList = sysAttachFileMapper.selectListByAttachId(attachId); |
|||
if(CollectionUtils.isEmpty(attachFileList)){ |
|||
attachService.deleteSysAttachById(attachId); |
|||
} |
|||
return i; |
|||
} |
|||
|
|||
@Override |
|||
public int updateAttachIdByIdList(Long attachId,List<String> idList) { |
|||
return sysAttachFileMapper.updateAttachIdByIdList(attachId,idList); |
|||
} |
|||
} |
@ -0,0 +1,103 @@ |
|||
package com.ruoyi.system.service.impl; |
|||
|
|||
import com.ruoyi.common.core.text.Convert; |
|||
import com.ruoyi.common.utils.DateUtils; |
|||
import com.ruoyi.system.domain.SysAttach; |
|||
import com.ruoyi.system.mapper.SysAttachMapper; |
|||
import com.ruoyi.system.service.ISysAttachFileService; |
|||
import com.ruoyi.system.service.ISysAttachService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 附件业务关联Service业务层处理 |
|||
* |
|||
* @author ruoyi |
|||
* @date 2023-11-13 |
|||
*/ |
|||
@Service |
|||
public class SysAttachServiceImpl implements ISysAttachService |
|||
{ |
|||
@Autowired |
|||
private SysAttachMapper sysAttachMapper; |
|||
|
|||
@Autowired |
|||
private ISysAttachFileService attachFileService; |
|||
|
|||
/** |
|||
* 查询附件业务关联 |
|||
* |
|||
* @param id 附件业务关联ID |
|||
* @return 附件业务关联 |
|||
*/ |
|||
@Override |
|||
public SysAttach selectSysAttachById(Long id) |
|||
{ |
|||
return sysAttachMapper.selectSysAttachById(id); |
|||
} |
|||
|
|||
/** |
|||
* 查询附件业务关联列表 |
|||
* |
|||
* @param sysAttach 附件业务关联 |
|||
* @return 附件业务关联 |
|||
*/ |
|||
@Override |
|||
public List<SysAttach> selectSysAttachList(SysAttach sysAttach) |
|||
{ |
|||
return sysAttachMapper.selectSysAttachList(sysAttach); |
|||
} |
|||
|
|||
/** |
|||
* 新增附件业务关联 |
|||
* |
|||
* @param sysAttach 附件业务关联 |
|||
* @return 结果 |
|||
*/ |
|||
@Override |
|||
public int insertSysAttach(SysAttach sysAttach) |
|||
{ |
|||
sysAttach.setCreateTime(DateUtils.getNowDate()); |
|||
return sysAttachMapper.insertSysAttach(sysAttach); |
|||
} |
|||
|
|||
/** |
|||
* 修改附件业务关联 |
|||
* |
|||
* @param sysAttach 附件业务关联 |
|||
* @return 结果 |
|||
*/ |
|||
@Override |
|||
public int updateSysAttach(SysAttach sysAttach) |
|||
{ |
|||
sysAttach.setUpdateTime(DateUtils.getNowDate()); |
|||
return sysAttachMapper.updateSysAttach(sysAttach); |
|||
} |
|||
|
|||
/** |
|||
* 删除附件业务关联对象 |
|||
* |
|||
* @param ids 需要删除的数据ID |
|||
* @return 结果 |
|||
*/ |
|||
@Override |
|||
public int deleteSysAttachByIds(String ids) |
|||
{ |
|||
return sysAttachMapper.deleteSysAttachByIds(Convert.toStrArray(ids)); |
|||
} |
|||
|
|||
/** |
|||
* 删除附件业务关联信息 |
|||
* |
|||
* @param id 附件业务关联ID |
|||
* @return 结果 |
|||
*/ |
|||
@Override |
|||
public int deleteSysAttachById(Long id) |
|||
{ |
|||
return sysAttachMapper.deleteSysAttachById(id); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,117 @@ |
|||
<?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="com.ruoyi.system.mapper.SysAttachFileMapper"> |
|||
|
|||
<resultMap type="SysAttachFile" id="SysAttachFileResult"> |
|||
<result property="id" column="id" /> |
|||
<result property="delFlag" column="del_flag" /> |
|||
<result property="createBy" column="create_by" /> |
|||
<result property="createTime" column="create_time" /> |
|||
<result property="updateBy" column="update_by" /> |
|||
<result property="updateTime" column="update_time" /> |
|||
<result property="remark" column="remark" /> |
|||
<result property="attachId" column="attach_id" /> |
|||
<result property="name" column="name" /> |
|||
<result property="ext" column="ext" /> |
|||
<result property="size" column="size" /> |
|||
<result property="url" column="url" /> |
|||
<result property="path" column="path" /> |
|||
</resultMap> |
|||
|
|||
<sql id="selectSysAttachFileVo"> |
|||
select id, del_flag, create_by, create_time, update_by, update_time, remark, attach_id, name, ext, size, url,path from sys_attach_file |
|||
</sql> |
|||
|
|||
<select id="selectSysAttachFileList" parameterType="SysAttachFile" resultMap="SysAttachFileResult"> |
|||
<include refid="selectSysAttachFileVo"/> |
|||
<where> |
|||
<if test="attachId != null "> and attach_id = #{attachId}</if> |
|||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> |
|||
<if test="ext != null and ext != ''"> and ext = #{ext}</if> |
|||
<if test="size != null "> and size = #{size}</if> |
|||
<if test="url != null and url != ''"> and url = #{url}</if> |
|||
</where> |
|||
</select> |
|||
|
|||
<select id="selectSysAttachFileById" parameterType="Long" resultMap="SysAttachFileResult"> |
|||
<include refid="selectSysAttachFileVo"/> |
|||
where id = #{id} |
|||
</select> |
|||
<select id="selectListByAttachId" resultMap="SysAttachFileResult"> |
|||
<include refid="selectSysAttachFileVo"/> |
|||
where attach_id = #{attachId} |
|||
</select> |
|||
|
|||
<insert id="insertSysAttachFile" parameterType="SysAttachFile" useGeneratedKeys="true" keyProperty="id"> |
|||
insert into sys_attach_file |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="delFlag != null and delFlag != ''">del_flag,</if> |
|||
<if test="createBy != null and createBy != ''">create_by,</if> |
|||
<if test="createTime != null ">create_time,</if> |
|||
<if test="updateBy != null and updateBy != ''">update_by,</if> |
|||
<if test="updateTime != null ">update_time,</if> |
|||
<if test="remark != null and remark != ''">remark,</if> |
|||
<if test="attachId != null ">attach_id,</if> |
|||
<if test="name != null and name != ''">name,</if> |
|||
<if test="ext != null and ext != ''">ext,</if> |
|||
<if test="size != null ">size,</if> |
|||
<if test="url != null and url != ''">url,</if> |
|||
<if test="path != null and path != ''">path,</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="delFlag != null and delFlag != ''">#{delFlag},</if> |
|||
<if test="createBy != null and createBy != ''">#{createBy},</if> |
|||
<if test="createTime != null ">#{createTime},</if> |
|||
<if test="updateBy != null and updateBy != ''">#{updateBy},</if> |
|||
<if test="updateTime != null ">#{updateTime},</if> |
|||
<if test="remark != null and remark != ''">#{remark},</if> |
|||
<if test="attachId != null ">#{attachId},</if> |
|||
<if test="name != null and name != ''">#{name},</if> |
|||
<if test="ext != null and ext != ''">#{ext},</if> |
|||
<if test="size != null ">#{size},</if> |
|||
<if test="url != null and url != ''">#{url},</if> |
|||
<if test="path != null and path != ''">#{path},</if> |
|||
</trim> |
|||
</insert> |
|||
|
|||
<update id="updateSysAttachFile" parameterType="SysAttachFile"> |
|||
update sys_attach_file |
|||
<trim prefix="SET" suffixOverrides=","> |
|||
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if> |
|||
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if> |
|||
<if test="createTime != null ">create_time = #{createTime},</if> |
|||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
|||
<if test="updateTime != null ">update_time = #{updateTime},</if> |
|||
<if test="remark != null and remark != ''">remark = #{remark},</if> |
|||
<if test="attachId != null ">attach_id = #{attachId},</if> |
|||
<if test="name != null and name != ''">name = #{name},</if> |
|||
<if test="ext != null and ext != ''">ext = #{ext},</if> |
|||
<if test="size != null ">size = #{size},</if> |
|||
<if test="url != null and url != ''">url = #{url},</if> |
|||
<if test="path != null and path != ''">path = #{path},</if> |
|||
</trim> |
|||
where id = #{id} |
|||
</update> |
|||
|
|||
<update id="updateAttachIdByIdList"> |
|||
update sys_attach_file set attach_id = #{attachId} |
|||
where id in |
|||
<foreach item="id" collection="idList" open="(" separator="," close=")"> |
|||
#{id} |
|||
</foreach> |
|||
</update> |
|||
|
|||
<delete id="deleteSysAttachFileById" parameterType="Long"> |
|||
delete from sys_attach_file where id = #{id} |
|||
</delete> |
|||
|
|||
<delete id="deleteSysAttachFileByIds" parameterType="String"> |
|||
delete from sys_attach_file where id in |
|||
<foreach item="id" collection="array" open="(" separator="," close=")"> |
|||
#{id} |
|||
</foreach> |
|||
</delete> |
|||
|
|||
</mapper> |
@ -0,0 +1,91 @@ |
|||
<?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="com.ruoyi.system.mapper.SysAttachMapper"> |
|||
|
|||
<resultMap type="SysAttach" id="SysAttachResult"> |
|||
<result property="id" column="id" /> |
|||
<result property="delFlag" column="del_flag" /> |
|||
<result property="createBy" column="create_by" /> |
|||
<result property="createTime" column="create_time" /> |
|||
<result property="updateBy" column="update_by" /> |
|||
<result property="updateTime" column="update_time" /> |
|||
<result property="remark" column="remark" /> |
|||
<result property="relId" column="rel_id" /> |
|||
<result property="sourceType" column="source_type" /> |
|||
<result property="sourceSubType" column="source_sub_type" /> |
|||
</resultMap> |
|||
|
|||
<sql id="selectSysAttachVo"> |
|||
select id, del_flag, create_by, create_time, update_by, update_time, remark, rel_id, source_type, source_sub_type from sys_attach |
|||
</sql> |
|||
|
|||
<select id="selectSysAttachList" parameterType="SysAttach" resultMap="SysAttachResult"> |
|||
<include refid="selectSysAttachVo"/> |
|||
<where> |
|||
<if test="relId != null "> and rel_id = #{relId}</if> |
|||
<if test="sourceType != null and sourceType != ''"> and source_type = #{sourceType}</if> |
|||
<if test="sourceSubType != null and sourceSubType != ''"> and source_sub_type = #{sourceSubType}</if> |
|||
</where> |
|||
</select> |
|||
|
|||
<select id="selectSysAttachById" parameterType="Long" resultMap="SysAttachResult"> |
|||
<include refid="selectSysAttachVo"/> |
|||
where id = #{id} |
|||
</select> |
|||
|
|||
<insert id="insertSysAttach" parameterType="SysAttach" useGeneratedKeys="true" keyProperty="id"> |
|||
insert into sys_attach |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="delFlag != null and delFlag != ''">del_flag,</if> |
|||
<if test="createBy != null and createBy != ''">create_by,</if> |
|||
<if test="createTime != null ">create_time,</if> |
|||
<if test="updateBy != null and updateBy != ''">update_by,</if> |
|||
<if test="updateTime != null ">update_time,</if> |
|||
<if test="remark != null and remark != ''">remark,</if> |
|||
<if test="relId != null ">rel_id,</if> |
|||
<if test="sourceType != null and sourceType != ''">source_type,</if> |
|||
<if test="sourceSubType != null and sourceSubType != ''">source_sub_type,</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="delFlag != null and delFlag != ''">#{delFlag},</if> |
|||
<if test="createBy != null and createBy != ''">#{createBy},</if> |
|||
<if test="createTime != null ">#{createTime},</if> |
|||
<if test="updateBy != null and updateBy != ''">#{updateBy},</if> |
|||
<if test="updateTime != null ">#{updateTime},</if> |
|||
<if test="remark != null and remark != ''">#{remark},</if> |
|||
<if test="relId != null ">#{relId},</if> |
|||
<if test="sourceType != null and sourceType != ''">#{sourceType},</if> |
|||
<if test="sourceSubType != null and sourceSubType != ''">#{sourceSubType},</if> |
|||
</trim> |
|||
</insert> |
|||
|
|||
<update id="updateSysAttach" parameterType="SysAttach"> |
|||
update sys_attach |
|||
<trim prefix="SET" suffixOverrides=","> |
|||
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if> |
|||
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if> |
|||
<if test="createTime != null ">create_time = #{createTime},</if> |
|||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
|||
<if test="updateTime != null ">update_time = #{updateTime},</if> |
|||
<if test="remark != null and remark != ''">remark = #{remark},</if> |
|||
<if test="relId != null ">rel_id = #{relId},</if> |
|||
<if test="sourceType != null and sourceType != ''">source_type = #{sourceType},</if> |
|||
<if test="sourceSubType != null and sourceSubType != ''">source_sub_type = #{sourceSubType},</if> |
|||
</trim> |
|||
where id = #{id} |
|||
</update> |
|||
|
|||
<delete id="deleteSysAttachById" parameterType="Long"> |
|||
delete from sys_attach where id = #{id} |
|||
</delete> |
|||
|
|||
<delete id="deleteSysAttachByIds" parameterType="String"> |
|||
delete from sys_attach where id in |
|||
<foreach item="id" collection="array" open="(" separator="," close=")"> |
|||
#{id} |
|||
</foreach> |
|||
</delete> |
|||
|
|||
</mapper> |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue