- restore generic signatures, scoped variables and missing code from original bytecode - remove decompiler artifacts and document classes, methods, fields and packages - restore resources, add Batik/BouncyCastle dependencies and build/runtime docs
129 lines
3.2 KiB
Java
129 lines
3.2 KiB
Java
package com.midm.model.battery;
|
||
|
||
import com.mitac.cell.db.DbObject;
|
||
import java.util.Date;
|
||
import java.util.UUID;
|
||
import org.springframework.data.annotation.Id;
|
||
import org.springframework.data.mongodb.core.index.CompoundIndex;
|
||
import org.springframework.data.mongodb.core.index.Indexed;
|
||
import org.springframework.data.mongodb.core.mapping.Document;
|
||
|
||
/**
|
||
* 【MongoDB 文档实体】{@code BatteryLog}
|
||
*
|
||
* 类职责:
|
||
* <ul>
|
||
* <li>作为 MongoDB 集合文档,承载该领域对象的持久化字段与索引。</li>
|
||
* <li>通过字段/依赖注入持有运行期状态,字段含义见下方“核心字段”。</li>
|
||
* </ul>
|
||
*
|
||
* 核心字段(按声明顺序):
|
||
* <ul>
|
||
* <li>{@code uuid}(UUID):对象唯一标识(MongoDB 主键)</li>
|
||
* <li>{@code batterySerial}(String):电池序列</li>
|
||
* <li>{@code category}(String):字段 category</li>
|
||
* <li>{@code log}(String):日志</li>
|
||
* <li>{@code reportedAt}(Date):时间字段</li>
|
||
* <li>{@code states}(DbObject):字段 states</li>
|
||
* </ul>
|
||
*
|
||
* 协作对象:{@code DbObject}。
|
||
*
|
||
* 持久化/框架标记:{@code @Document} 映射为 MongoDB 集合。
|
||
*
|
||
* 学习提示:先看字段与 @Field/@Indexed,再看对应 Service/Repository 如何构造查询条件。
|
||
*/
|
||
@Document
|
||
@CompoundIndex(
|
||
def = "{batterySerial: 1, reportedAt: 1}"
|
||
)
|
||
public class BatteryLog {
|
||
/**
|
||
* 对象唯一标识(MongoDB 主键);MongoDB 主键。
|
||
*
|
||
* 注解:{@code @Id}。
|
||
*/
|
||
@Id
|
||
private UUID uuid = UUID.randomUUID();
|
||
/**
|
||
* 电池序列;建有索引,常用于查询条件。
|
||
*
|
||
* 注解:{@code @Indexed}。
|
||
*/
|
||
@Indexed
|
||
private String batterySerial;
|
||
/**
|
||
* 字段 category;建有索引,常用于查询条件。
|
||
*
|
||
* 注解:{@code @Indexed}。
|
||
*/
|
||
@Indexed
|
||
private String category;
|
||
/**
|
||
* 日志。
|
||
*/
|
||
private String log;
|
||
/**
|
||
* 时间字段;建有索引,常用于查询条件。
|
||
*
|
||
* 注解:{@code @Indexed}。
|
||
*/
|
||
@Indexed
|
||
private Date reportedAt;
|
||
/**
|
||
* 字段 states。
|
||
*/
|
||
private DbObject states;
|
||
/**
|
||
* 时间字段。
|
||
*/
|
||
private Date recordedAt = new Date();
|
||
|
||
/**
|
||
* 获取 {@code uuid}。
|
||
* @return UUID
|
||
*/
|
||
public UUID getUuid() {
|
||
return this.uuid;
|
||
}
|
||
|
||
/**
|
||
* 获取 {@code batterySerial}。
|
||
* @return 字符串结果
|
||
*/
|
||
public String getBatterySerial() {
|
||
return this.batterySerial;
|
||
}
|
||
|
||
/**
|
||
* 设置 {@code category}。
|
||
*
|
||
* @param category 分类(app/ota/other/report 等)({@code String})
|
||
*/
|
||
public void setCategory(String category) {
|
||
this.category = category;
|
||
}
|
||
|
||
/**
|
||
* 获取 {@code states}。
|
||
*
|
||
* 实现要点:包含 1 个条件分支、0 个循环;主要调用:new DbObject。
|
||
* @return MongoDB 文档扩展对象
|
||
*/
|
||
public DbObject getStates() {
|
||
if (this.states == null) {
|
||
this.states = new DbObject();
|
||
}
|
||
|
||
return this.states;
|
||
}
|
||
|
||
/**
|
||
* 获取 {@code reportedAt}。
|
||
* @return 字段/派生属性 {@code reportedAt} 的值
|
||
*/
|
||
public Date getReportedAt() {
|
||
return this.reportedAt;
|
||
}
|
||
}
|