有关用户、文件等的基本信息建立

2021SC@SDUSC

项目实体分为事务,资料节点记录,用户和文件多个实体类,他们的建立如下。

1.事务

是整个项目的核心。

在该类中,事务id为主键,还有事务名、事务类型、事务创建时间、结束时间等

@Data public class Affair
{ 
	@JsonSerialize(using=ToStringSerializer.class) 
	private Long id; 
	private String name; 
	private String remark; 
	private Integer kind;
	private Integer state; 
	private Date startTime;
	private Date endTime; 
	@JsonSerialize(using=ToStringSerializer.class) 
	private Long promoterId;
	private Integer approverPost;
	}

2.用户

对于用户也有其用户id作为主键,其中用户id也为long类型。同时有用户名、用户密码、用户姓名等,为用户分配不同的权限,如单纯的柜子端用户、还有后台管理用户等。在本项目中用户信息建立这个事务的重点在于用户id的确认。在本项目中用户id的类型为long类型,使用雪花算法生成。

@Data 
@AllArgsConstructor 
@NoArgsConstructor public class User 
{ 
	@JsonSerialize(using= ToStringSerializer.class) 
	private Long id; 
	private String username;
	@JsonIgnore private String password;
	private String name;
	private Integer post;
	@JsonIgnore private Set<String> permissions; 
	@JsonIgnore private Set<String> roles; 
	}

3.文件信息

文件信息储存在 mogodb 中,文件 id 使用生成的 GUID,确保每次上传文件唯一存在content储存文件内容,contentType 存储 http传输类型,gridfsId 用于查询文件在 gridfs 中的数据。
在文件的建立类中,有文件id、文件名称、文件大小、文件上传时间、文件描述等。对于大型文件使用dridfs管理。
@Data 
@AllArgsConstructor 
@NoArgsConstructor public class FileDocument 
{ 
	@Id
	private String id; 
	private String name;
	private long size;
	private Date uploadDate;
	private String md5;
	@JsonIgnore private byte[] content;
	private String contentType;
	private String suffix;
	@JsonIgnore private String description;
	@JsonIgnore private String gridfsId;
	@JsonIgnore private String about; 
	@JsonIgnore private Long aboutId; 
	private Boolean ifPrint;
    private Boolean ifHire; private Long hirerId;
    private Long storageId; 
    @Override public int hashCode() 
    { int result = Objects.hash(id, name, size, uploadDate, md5, contentType, suffix, description, gridfsId, aboutId, about);
     result = 31 * result + Arrays.hashCode(content); 
     return result; } }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值