feat: complete reverse engineering, standard Maven structure, detailed code annotations and IoT-M platform architecture

This commit is contained in:
rick committed 2026-11-16 14:35:53 +08:00
1 parent e8dc09fb3c
commit cd6a4c70e7
3045 files changed
+566733 -1

No files matched your search

@@ -0,0 +1,142 @@
package com.midm.model.log;
import com.google.common.base.Strings;
import com.midm.model.org.User;
import com.mitac.cell.db.DbObject;
import com.mitac.cell.internet.http.UserAgent;
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.CompoundIndexes;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;
@Document
@CompoundIndexes({@CompoundIndex(
def = "{'category':1, 'loggedAt':1}"
), @CompoundIndex(
def = "{'forWhat':1, 'loggedAt': -1}"
), @CompoundIndex(
def = "{'forWhat':1, 'log': 1}"
)})
public class MidmLog {
@Id
private UUID uuid;
private UUID forWhat;
private String category;
private String log;
private DbObject reference;
private Date loggedAt;
@DBRef
private User logger;
public MidmLog() {
this.setUuid(UUID.randomUUID());
this.setLoggedAt(new Date());
}
public MidmLog(User user, UUID forWhat, String category, String log) {
this();
if (user != null) {
this.setLogger(user);
}
this.setForWhat(forWhat);
this.setCategory(category);
this.setLog(log);
}
public UUID getUuid() {
return this.uuid;
}
public void setUuid(UUID uuid) {
this.uuid = uuid;
}
public UUID getForWhat() {
return this.forWhat;
}
public void setForWhat(UUID forWhat) {
this.forWhat = forWhat;
}
public String getCategory() {
return this.category;
}
public void setCategory(String category) {
this.category = category;
}
public String getLog() {
return this.log;
}
public void setLog(String log) {
this.log = log;
}
public DbObject getReference() {
if (this.reference == null) {
this.reference = new DbObject();
}
return this.reference;
}
public boolean hasReference() {
return this.reference != null && this.reference.size() > 0;
}
public void setReference(DbObject reference) {
this.reference = reference;
}
public void setReference(UserAgent agent, String sessionId, String remoteIp) {
if (agent != null) {
this.addReference("browser", agent.agentFamily());
this.addReference("os", agent.osFamily());
this.addReference("device", agent.deviceFamily());
}
if (!Strings.isNullOrEmpty(sessionId)) {
this.addReference("sessionId", sessionId);
}
if (!Strings.isNullOrEmpty(remoteIp)) {
this.addReference("remoteIp", remoteIp);
}
}
public void addReference(String key, Object value) {
this.getReference().put(key, value);
}
public UUID getLoggerUuid() {
return this.logger != null ? this.logger.getUuid() : null;
}
public Date getLoggedAt() {
return this.loggedAt;
}
public void setLoggedAt(Date loggedAt) {
this.loggedAt = loggedAt;
}
public void setLoggedAt(long loggedAt) {
this.loggedAt = new Date(loggedAt);
}
public User getLogger() {
return this.logger;
}
public void setLogger(User logger) {
this.logger = logger;
}
}