diff --git a/ktg-admin/src/main/java/com/ktg/web/controller/system/SysAttachmentController.java b/ktg-admin/src/main/java/com/ktg/web/controller/system/SysAttachmentController.java new file mode 100644 index 0000000..d19b5ae --- /dev/null +++ b/ktg-admin/src/main/java/com/ktg/web/controller/system/SysAttachmentController.java @@ -0,0 +1,104 @@ +package com.ktg.web.controller.system; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ktg.common.annotation.Log; +import com.ktg.common.core.controller.BaseController; +import com.ktg.common.core.domain.AjaxResult; +import com.ktg.common.enums.BusinessType; +import com.ktg.system.domain.SysAttachment; +import com.ktg.system.service.ISysAttachmentService; +import com.ktg.common.utils.poi.ExcelUtil; +import com.ktg.common.core.page.TableDataInfo; + +/** + * 附件Controller + * + * @author yinjinlu + * @date 2022-07-26 + */ +@RestController +@RequestMapping("/system/attachment") +public class SysAttachmentController extends BaseController +{ + @Autowired + private ISysAttachmentService sysAttachmentService; + + /** + * 查询附件列表 + */ + @PreAuthorize("@ss.hasPermi('system:attachment:list')") + @GetMapping("/list") + public TableDataInfo list(SysAttachment sysAttachment) + { + startPage(); + List list = sysAttachmentService.selectSysAttachmentList(sysAttachment); + return getDataTable(list); + } + + /** + * 导出附件列表 + */ + @PreAuthorize("@ss.hasPermi('system:attachment:export')") + @Log(title = "附件", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, SysAttachment sysAttachment) + { + List list = sysAttachmentService.selectSysAttachmentList(sysAttachment); + ExcelUtil util = new ExcelUtil(SysAttachment.class); + util.exportExcel(response, list, "附件数据"); + } + + /** + * 获取附件详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:attachment:query')") + @GetMapping(value = "/{attachmentId}") + public AjaxResult getInfo(@PathVariable("attachmentId") Long attachmentId) + { + return AjaxResult.success(sysAttachmentService.selectSysAttachmentByAttachmentId(attachmentId)); + } + + /** + * 新增附件 + */ + @PreAuthorize("@ss.hasPermi('system:attachment:add')") + @Log(title = "附件", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysAttachment sysAttachment) + { + return toAjax(sysAttachmentService.insertSysAttachment(sysAttachment)); + } + + /** + * 修改附件 + */ + @PreAuthorize("@ss.hasPermi('system:attachment:edit')") + @Log(title = "附件", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SysAttachment sysAttachment) + { + return toAjax(sysAttachmentService.updateSysAttachment(sysAttachment)); + } + + /** + * 删除附件 + */ + @PreAuthorize("@ss.hasPermi('system:attachment:remove')") + @Log(title = "附件", businessType = BusinessType.DELETE) + @DeleteMapping("/{attachmentIds}") + public AjaxResult remove(@PathVariable Long[] attachmentIds) + { + return toAjax(sysAttachmentService.deleteSysAttachmentByAttachmentIds(attachmentIds)); + } +} diff --git a/ktg-system/src/main/java/com/ktg/system/domain/SysAttachment.java b/ktg-system/src/main/java/com/ktg/system/domain/SysAttachment.java new file mode 100644 index 0000000..1bc8f90 --- /dev/null +++ b/ktg-system/src/main/java/com/ktg/system/domain/SysAttachment.java @@ -0,0 +1,207 @@ +package com.ktg.system.domain; + +import java.math.BigDecimal; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ktg.common.annotation.Excel; +import com.ktg.common.core.domain.BaseEntity; + +/** + * 附件对象 sys_attachment + * + * @author yinjinlu + * @date 2022-07-26 + */ +public class SysAttachment extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 附件ID */ + private Long attachmentId; + + /** 关联的业务单据ID */ + @Excel(name = "关联的业务单据ID") + private Long sourceDocId; + + /** 业务单据类型 */ + @Excel(name = "业务单据类型") + private String sourceDocType; + + /** 访问URL */ + @Excel(name = "访问URL") + private String fileUrl; + + /** 域名 */ + @Excel(name = "域名") + private String basePath; + + /** 文件名 */ + @Excel(name = "文件名") + private String fileName; + + /** 原来的文件名 */ + @Excel(name = "原来的文件名") + private String orignalName; + + /** 文件类型 */ + @Excel(name = "文件类型") + private String fileType; + + /** 文件大小 */ + @Excel(name = "文件大小") + private BigDecimal fileSize; + + /** 预留字段1 */ + private String attr1; + + /** 预留字段2 */ + private String attr2; + + /** 预留字段3 */ + private Long attr3; + + /** 预留字段4 */ + private Long attr4; + + public void setAttachmentId(Long attachmentId) + { + this.attachmentId = attachmentId; + } + + public Long getAttachmentId() + { + return attachmentId; + } + public void setSourceDocId(Long sourceDocId) + { + this.sourceDocId = sourceDocId; + } + + public Long getSourceDocId() + { + return sourceDocId; + } + public void setSourceDocType(String sourceDocType) + { + this.sourceDocType = sourceDocType; + } + + public String getSourceDocType() + { + return sourceDocType; + } + public void setFileUrl(String fileUrl) + { + this.fileUrl = fileUrl; + } + + public String getFileUrl() + { + return fileUrl; + } + public void setBasePath(String basePath) + { + this.basePath = basePath; + } + + public String getBasePath() + { + return basePath; + } + public void setFileName(String fileName) + { + this.fileName = fileName; + } + + public String getFileName() + { + return fileName; + } + public void setOrignalName(String orignalName) + { + this.orignalName = orignalName; + } + + public String getOrignalName() + { + return orignalName; + } + public void setFileType(String fileType) + { + this.fileType = fileType; + } + + public String getFileType() + { + return fileType; + } + public void setFileSize(BigDecimal fileSize) + { + this.fileSize = fileSize; + } + + public BigDecimal getFileSize() + { + return fileSize; + } + public void setAttr1(String attr1) + { + this.attr1 = attr1; + } + + public String getAttr1() + { + return attr1; + } + public void setAttr2(String attr2) + { + this.attr2 = attr2; + } + + public String getAttr2() + { + return attr2; + } + public void setAttr3(Long attr3) + { + this.attr3 = attr3; + } + + public Long getAttr3() + { + return attr3; + } + public void setAttr4(Long attr4) + { + this.attr4 = attr4; + } + + public Long getAttr4() + { + return attr4; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("attachmentId", getAttachmentId()) + .append("sourceDocId", getSourceDocId()) + .append("sourceDocType", getSourceDocType()) + .append("fileUrl", getFileUrl()) + .append("basePath", getBasePath()) + .append("fileName", getFileName()) + .append("orignalName", getOrignalName()) + .append("fileType", getFileType()) + .append("fileSize", getFileSize()) + .append("remark", getRemark()) + .append("attr1", getAttr1()) + .append("attr2", getAttr2()) + .append("attr3", getAttr3()) + .append("attr4", getAttr4()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/ktg-system/src/main/java/com/ktg/system/mapper/SysAttachmentMapper.java b/ktg-system/src/main/java/com/ktg/system/mapper/SysAttachmentMapper.java new file mode 100644 index 0000000..f112c9e --- /dev/null +++ b/ktg-system/src/main/java/com/ktg/system/mapper/SysAttachmentMapper.java @@ -0,0 +1,61 @@ +package com.ktg.system.mapper; + +import java.util.List; +import com.ktg.system.domain.SysAttachment; + +/** + * 附件Mapper接口 + * + * @author yinjinlu + * @date 2022-07-26 + */ +public interface SysAttachmentMapper +{ + /** + * 查询附件 + * + * @param attachmentId 附件主键 + * @return 附件 + */ + public SysAttachment selectSysAttachmentByAttachmentId(Long attachmentId); + + /** + * 查询附件列表 + * + * @param sysAttachment 附件 + * @return 附件集合 + */ + public List selectSysAttachmentList(SysAttachment sysAttachment); + + /** + * 新增附件 + * + * @param sysAttachment 附件 + * @return 结果 + */ + public int insertSysAttachment(SysAttachment sysAttachment); + + /** + * 修改附件 + * + * @param sysAttachment 附件 + * @return 结果 + */ + public int updateSysAttachment(SysAttachment sysAttachment); + + /** + * 删除附件 + * + * @param attachmentId 附件主键 + * @return 结果 + */ + public int deleteSysAttachmentByAttachmentId(Long attachmentId); + + /** + * 批量删除附件 + * + * @param attachmentIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteSysAttachmentByAttachmentIds(Long[] attachmentIds); +} diff --git a/ktg-system/src/main/java/com/ktg/system/service/ISysAttachmentService.java b/ktg-system/src/main/java/com/ktg/system/service/ISysAttachmentService.java new file mode 100644 index 0000000..1e6501d --- /dev/null +++ b/ktg-system/src/main/java/com/ktg/system/service/ISysAttachmentService.java @@ -0,0 +1,61 @@ +package com.ktg.system.service; + +import java.util.List; +import com.ktg.system.domain.SysAttachment; + +/** + * 附件Service接口 + * + * @author yinjinlu + * @date 2022-07-26 + */ +public interface ISysAttachmentService +{ + /** + * 查询附件 + * + * @param attachmentId 附件主键 + * @return 附件 + */ + public SysAttachment selectSysAttachmentByAttachmentId(Long attachmentId); + + /** + * 查询附件列表 + * + * @param sysAttachment 附件 + * @return 附件集合 + */ + public List selectSysAttachmentList(SysAttachment sysAttachment); + + /** + * 新增附件 + * + * @param sysAttachment 附件 + * @return 结果 + */ + public int insertSysAttachment(SysAttachment sysAttachment); + + /** + * 修改附件 + * + * @param sysAttachment 附件 + * @return 结果 + */ + public int updateSysAttachment(SysAttachment sysAttachment); + + /** + * 批量删除附件 + * + * @param attachmentIds 需要删除的附件主键集合 + * @return 结果 + */ + public int deleteSysAttachmentByAttachmentIds(Long[] attachmentIds); + + /** + * 删除附件信息 + * + * @param attachmentId 附件主键 + * @return 结果 + */ + public int deleteSysAttachmentByAttachmentId(Long attachmentId); +} diff --git a/ktg-system/src/main/java/com/ktg/system/service/impl/SysAttachmentServiceImpl.java b/ktg-system/src/main/java/com/ktg/system/service/impl/SysAttachmentServiceImpl.java new file mode 100644 index 0000000..8fbe5b0 --- /dev/null +++ b/ktg-system/src/main/java/com/ktg/system/service/impl/SysAttachmentServiceImpl.java @@ -0,0 +1,96 @@ +package com.ktg.system.service.impl; + +import java.util.List; +import com.ktg.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ktg.system.mapper.SysAttachmentMapper; +import com.ktg.system.domain.SysAttachment; +import com.ktg.system.service.ISysAttachmentService; + +/** + * 附件Service业务层处理 + * + * @author yinjinlu + * @date 2022-07-26 + */ +@Service +public class SysAttachmentServiceImpl implements ISysAttachmentService +{ + @Autowired + private SysAttachmentMapper sysAttachmentMapper; + + /** + * 查询附件 + * + * @param attachmentId 附件主键 + * @return 附件 + */ + @Override + public SysAttachment selectSysAttachmentByAttachmentId(Long attachmentId) + { + return sysAttachmentMapper.selectSysAttachmentByAttachmentId(attachmentId); + } + + /** + * 查询附件列表 + * + * @param sysAttachment 附件 + * @return 附件 + */ + @Override + public List selectSysAttachmentList(SysAttachment sysAttachment) + { + return sysAttachmentMapper.selectSysAttachmentList(sysAttachment); + } + + /** + * 新增附件 + * + * @param sysAttachment 附件 + * @return 结果 + */ + @Override + public int insertSysAttachment(SysAttachment sysAttachment) + { + sysAttachment.setCreateTime(DateUtils.getNowDate()); + return sysAttachmentMapper.insertSysAttachment(sysAttachment); + } + + /** + * 修改附件 + * + * @param sysAttachment 附件 + * @return 结果 + */ + @Override + public int updateSysAttachment(SysAttachment sysAttachment) + { + sysAttachment.setUpdateTime(DateUtils.getNowDate()); + return sysAttachmentMapper.updateSysAttachment(sysAttachment); + } + + /** + * 批量删除附件 + * + * @param attachmentIds 需要删除的附件主键 + * @return 结果 + */ + @Override + public int deleteSysAttachmentByAttachmentIds(Long[] attachmentIds) + { + return sysAttachmentMapper.deleteSysAttachmentByAttachmentIds(attachmentIds); + } + + /** + * 删除附件信息 + * + * @param attachmentId 附件主键 + * @return 结果 + */ + @Override + public int deleteSysAttachmentByAttachmentId(Long attachmentId) + { + return sysAttachmentMapper.deleteSysAttachmentByAttachmentId(attachmentId); + } +} diff --git a/ktg-system/src/main/resources/mapper/system/SysAttachmentMapper.xml b/ktg-system/src/main/resources/mapper/system/SysAttachmentMapper.xml new file mode 100644 index 0000000..5fab075 --- /dev/null +++ b/ktg-system/src/main/resources/mapper/system/SysAttachmentMapper.xml @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + select attachment_id, source_doc_id, source_doc_type, file_url, base_path, file_name, orignal_name, file_type, file_size, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from sys_attachment + + + + + + + + insert into sys_attachment + + source_doc_id, + source_doc_type, + file_url, + base_path, + file_name, + orignal_name, + file_type, + file_size, + remark, + attr1, + attr2, + attr3, + attr4, + create_by, + create_time, + update_by, + update_time, + + + #{sourceDocId}, + #{sourceDocType}, + #{fileUrl}, + #{basePath}, + #{fileName}, + #{orignalName}, + #{fileType}, + #{fileSize}, + #{remark}, + #{attr1}, + #{attr2}, + #{attr3}, + #{attr4}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update sys_attachment + + source_doc_id = #{sourceDocId}, + source_doc_type = #{sourceDocType}, + file_url = #{fileUrl}, + base_path = #{basePath}, + file_name = #{fileName}, + orignal_name = #{orignalName}, + file_type = #{fileType}, + file_size = #{fileSize}, + remark = #{remark}, + attr1 = #{attr1}, + attr2 = #{attr2}, + attr3 = #{attr3}, + attr4 = #{attr4}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where attachment_id = #{attachmentId} + + + + delete from sys_attachment where attachment_id = #{attachmentId} + + + + delete from sys_attachment where attachment_id in + + #{attachmentId} + + + \ No newline at end of file