diff --git a/src/main/java/com/rymcu/forest/entity/ForestFile.java b/src/main/java/com/rymcu/forest/entity/ForestFile.java new file mode 100644 index 0000000..d277c71 --- /dev/null +++ b/src/main/java/com/rymcu/forest/entity/ForestFile.java @@ -0,0 +1,57 @@ +package com.rymcu.forest.entity; + +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import java.util.Date; + +/** + * @author caterpillar + */ +@Data +@Table(name = "forest_File") +public class ForestFile { + + /** + * 主键 + */ + @Id + @GeneratedValue(generator = "JDBC") + @Column(name = "id") + private Long id; + + /** + * 访问路径 + */ + @Column(name = "web_path") + private String webPath; + + /** + * 上传路径 + */ + @Column(name = "upload_path") + private String uploadPath; + + /** + * md5 + */ + @Column(name = "md5_value") + private String md5Value; + + /** + * 创建时间 + */ + @Column(name = "create_time") + private Date createTime; + + /** + * 更新时间 + */ + @Column(name = "update_time") + private Date updateTime; + + +} diff --git a/src/main/java/com/rymcu/forest/mapper/ForestFileMapper.java b/src/main/java/com/rymcu/forest/mapper/ForestFileMapper.java new file mode 100644 index 0000000..76a02a9 --- /dev/null +++ b/src/main/java/com/rymcu/forest/mapper/ForestFileMapper.java @@ -0,0 +1,30 @@ +package com.rymcu.forest.mapper; + +import com.rymcu.forest.core.mapper.Mapper; +import com.rymcu.forest.entity.ForestFile; +import org.apache.ibatis.annotations.Param; + +/** + * @author caterpillar + * @date 2022-1-12 22:33:16 + */ +public interface ForestFileMapper extends Mapper { + + /** + * 通过md5获取文件对象 + * + * @param md5Value md5值 + * @return + */ + ForestFile getByMd5(@Param("md5Value") String md5Value); + + /** + * 插入文件对象 + * + * @param webPath 访问路径 + * @param uploadPath 上传路径 + * @param md5Value md5值 + * @return + */ + int insert(@Param("webPath") String webPath, @Param("uploadPath") String uploadPath, @Param("md5Value") String md5Value); +} diff --git a/src/main/java/com/rymcu/forest/service/ForestFileService.java b/src/main/java/com/rymcu/forest/service/ForestFileService.java new file mode 100644 index 0000000..e2e2bac --- /dev/null +++ b/src/main/java/com/rymcu/forest/service/ForestFileService.java @@ -0,0 +1,33 @@ +package com.rymcu.forest.service; + +import com.rymcu.forest.core.service.Service; +import com.rymcu.forest.entity.ForestFile; +import org.apache.ibatis.annotations.Param; + + +/** + * 文件服务记录 + * + * @author caterpillar + * @date 2022-1-12 22:32:49 + */ +public interface ForestFileService extends Service { + + /** + * 通过md5获取文件对象 + * + * @param md5Value md5值 + * @return + */ + ForestFile getByMd5(@Param("md5Value") String md5Value); + + /** + * 插入文件对象 + * + * @param webPath 访问路径 + * @param uploadPath 上传路径 + * @param md5Value md5值 + * @return + */ + int insert(@Param("webPath") String webPath, @Param("uploadPath") String uploadPath, @Param("md5Value") String md5Value); +} diff --git a/src/main/java/com/rymcu/forest/service/impl/ForestFileServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/ForestFileServiceImpl.java new file mode 100644 index 0000000..21f8d52 --- /dev/null +++ b/src/main/java/com/rymcu/forest/service/impl/ForestFileServiceImpl.java @@ -0,0 +1,47 @@ +package com.rymcu.forest.service.impl; + +import com.rymcu.forest.core.service.AbstractService; +import com.rymcu.forest.entity.ForestFile; +import com.rymcu.forest.mapper.ForestFileMapper; +import com.rymcu.forest.service.ForestFileService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * @author caterpillar + * @date 2022-1-12 22:34:55 + */ +@Service +@Slf4j +public class ForestFileServiceImpl extends AbstractService implements ForestFileService { + + @Resource + private ForestFileMapper forestFileMapper; + + + /** + * 通过md5获取文件对象 + * + * @param md5Value md5值 + * @return + */ + @Override + public ForestFile getByMd5(String md5Value) { + return forestFileMapper.getByMd5(md5Value); + } + + /** + * 插入文件对象 + * + * @param webPath 访问路径 + * @param uploadPath 上传路径 + * @param md5Value md5值 + * @return + */ + @Override + public int insert(String webPath, String uploadPath, String md5Value) { + return forestFileMapper.insert(webPath, uploadPath, md5Value); + } +} diff --git a/src/main/java/mapper/ForestFileMapper.xml b/src/main/java/mapper/ForestFileMapper.xml new file mode 100644 index 0000000..0443d01 --- /dev/null +++ b/src/main/java/mapper/ForestFileMapper.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + insert into forest_user_role (md5, upload_path, web_path, created_time) + values (#{md5Value}, #{uploadPath}, #{webPath}, sysdate()) + + + + + \ No newline at end of file