Files
sftp-manager/src/main/java/com/sftp/manager/model/Connection.java

63 lines
1.6 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.sftp.manager.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDateTime;
@Data
@Entity
@Table(name = "connections")
public class Connection {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; // 连接ID主键
@Column(nullable = false)
private String name; // 连接名称(用户自定义)
@Column(nullable = false)
private String host; // SFTP服务器地址
private Integer port; // SFTP端口默认22
@Column(nullable = false)
private String username; // 用户名
@Column(columnDefinition = "TEXT")
@JsonIgnore
private String password; // 密码(加密存储)
private String privateKeyPath; // 私钥路径(可选)
@JsonIgnore
private String passPhrase; // 私钥密码(可选)
private Integer connectTimeout; // 连接超时时间
private String rootPath; // 默认登录后路径
@Column(name = "created_at")
private LocalDateTime createdAt; // 创建时间
@Column(name = "updated_at")
private LocalDateTime updatedAt; // 更新时间
@PrePersist
protected void onCreate() {
createdAt = LocalDateTime.now();
updatedAt = LocalDateTime.now();
if (port == null) {
port = 22;
}
if (connectTimeout == null) {
connectTimeout = 10000;
}
}
@PreUpdate
protected void onUpdate() {
updatedAt = LocalDateTime.now();
}
}