🐛 add service
This commit is contained in:
parent
6ed1044432
commit
97d08c4c7e
57
src/main/java/com/rymcu/forest/entity/ForestFile.java
Normal file
57
src/main/java/com/rymcu/forest/entity/ForestFile.java
Normal file
@ -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;
|
||||
|
||||
|
||||
}
|
30
src/main/java/com/rymcu/forest/mapper/ForestFileMapper.java
Normal file
30
src/main/java/com/rymcu/forest/mapper/ForestFileMapper.java
Normal file
@ -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<ForestFile> {
|
||||
|
||||
/**
|
||||
* 通过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);
|
||||
}
|
@ -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<ForestFile> {
|
||||
|
||||
/**
|
||||
* 通过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);
|
||||
}
|
@ -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<ForestFile> 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);
|
||||
}
|
||||
}
|
24
src/main/java/mapper/ForestFileMapper.xml
Normal file
24
src/main/java/mapper/ForestFileMapper.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?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.rymcu.forest.mapper.ForestFileMapper">
|
||||
<resultMap id="BaseResultMap" type="com.rymcu.forest.entity.ForestFile">
|
||||
<id column="id" property="id"/>
|
||||
<result column="md5_value" property="md5Value"/>
|
||||
<result column="upload_path" property="uploadPath"/>
|
||||
<result column="web_path" property="webPath"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert">
|
||||
insert into forest_user_role (md5, upload_path, web_path, created_time)
|
||||
values (#{md5Value}, #{uploadPath}, #{webPath}, sysdate())
|
||||
</insert>
|
||||
|
||||
<select id="getByMd5" resultMap="BaseResultMap">
|
||||
select *
|
||||
from forest_file
|
||||
where md5_value = #{md5Value}
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user