From 9954e993440932a0f34d8f6047f1eb36b38b750c Mon Sep 17 00:00:00 2001 From: XuYuqi Date: Fri, 11 Jul 2025 18:30:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ApiResponse.java | 61 +++++++++++++++++ AudioEntity.java | 98 +++++++++++++++++++++++++++ ImageEntity.java | 57 ++++++++++++++++ ImageInfo.java | 169 +++++++++++++++++++++++++++++++++++++++++++++++ TurbineDao.java | 24 +++++++ 5 files changed, 409 insertions(+) create mode 100644 ApiResponse.java create mode 100644 AudioEntity.java create mode 100644 ImageEntity.java create mode 100644 ImageInfo.java create mode 100644 TurbineDao.java diff --git a/ApiResponse.java b/ApiResponse.java new file mode 100644 index 0000000..75089e0 --- /dev/null +++ b/ApiResponse.java @@ -0,0 +1,61 @@ +package com.example.myapplication.model; + +import com.google.gson.annotations.SerializedName; + +public class ApiResponse { + + + + @SerializedName("code") + private int code; + + @SerializedName("msg") + private String msg; // 严格匹配服务器字段名 "msg" + + @SerializedName("data") + private T data; + + @SerializedName("status") + private int status; + + @SerializedName("success") + private boolean success; + + // Getters + public int getCode() { + return code; + } + + public String getMsg() { // 方法名改为 getMsg() 与字段名一致 + return msg; + } + + public T getData() { + return data; + } + + public int getStatus() { + return status; + } + + public boolean isSuccess() { + return success; + } + + // Setters(按需添加) + public void setData(T data) { + this.data = data; + } + + @Override + public String toString() { + return "ApiResponse{" + + "code=" + code + + ", msg='" + msg + '\'' + + ", data=" + data + + ", status=" + status + + ", success=" + success + + '}'; + } + +} \ No newline at end of file diff --git a/AudioEntity.java b/AudioEntity.java new file mode 100644 index 0000000..748abbb --- /dev/null +++ b/AudioEntity.java @@ -0,0 +1,98 @@ +package com.example.myapplication.model; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +@Entity(tableName = "audio_entities") +public class AudioEntity { + @PrimaryKey(autoGenerate = true) + private int id; + + private String fileName; + public String AudioPath; + + public AudioEntity() { + } + + public String ImagePath; + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + private long fileSize; + public String time; + + public AudioEntity(String audioPath, String imagePath,String time) { + this.AudioPath = audioPath; + this.ImagePath = imagePath; + this.time=time; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getAudioPath() { + return AudioPath; + } + + public void setAudioPath(String audioPath) { + AudioPath = audioPath; + } + + public String getImagePath() { + return ImagePath; + } + + public void setImagePath(String imagePath) { + ImagePath = imagePath; + } + + public long getFileSize() { + return fileSize; + } + + public void setFileSize(long fileSize) { + this.fileSize = fileSize; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public long getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(long createdAt) { + this.createdAt = createdAt; + } + + private long duration; // 音频时长(毫秒) + private long createdAt; // 创建时间戳 + + // 构造方法、getter 和 setter + + +} \ No newline at end of file diff --git a/ImageEntity.java b/ImageEntity.java new file mode 100644 index 0000000..45da439 --- /dev/null +++ b/ImageEntity.java @@ -0,0 +1,57 @@ +package com.example.myapplication.model; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + + +@Entity(tableName = "images") + public class ImageEntity { + @PrimaryKey(autoGenerate = true) + public int id; + public String path; + public long time; + public double latitude; + public double longitude; + public double altitude; + public String user; + public String audioPath; + public int blade; + public String unit; + public String unitName; + public String project; + public boolean b; + public String temperature="0"; // 温度 + public String humidity="0"; // 湿度 + public String weather="0"; // 天气状况 + public String imageSource="-1"; + + public ImageEntity(String path, long time, double latitude, double longitude, double altitude, String user, String audioPath, String project, String unit, int blade, boolean b,String unitName,String temperature,String humidity,String weather,String imageSource) { + + this.path = path; + this.time = time; + this.latitude = latitude; + this.longitude = longitude; + this.altitude = altitude; + this.user = user; + this.audioPath = audioPath; + this.project=project; + this.unit=unit; + this.blade=blade; + this.b=b; + this.weather=weather; + this.temperature=temperature; + this.humidity=humidity; + this.unitName=unitName; + this.imageSource=imageSource; + } + + + + // 构造方法 + + + +} + + // ImageDao.java + diff --git a/ImageInfo.java b/ImageInfo.java new file mode 100644 index 0000000..0cbfb7f --- /dev/null +++ b/ImageInfo.java @@ -0,0 +1,169 @@ +package com.example.myapplication.model; + +import android.graphics.Bitmap; + +public class ImageInfo { + private String path; // 图片路径 + private long time; // 时间戳(单位:秒) + private Bitmap bitmap; // 图片缩略图 + private double latitude; + private double longitude; + private double altitude; + private String user; + + public boolean isB() { + return b; + } + + public void setB(boolean b) { + this.b = b; + } + + public ImageInfo(String path, long time, Bitmap bitmap, double latitude, double longitude, double altitude, String user, String audioPath, boolean b, Bitmap thumbnail, String unit, String project, int blade) { + this.path = path; + this.time = time; + this.bitmap = bitmap; + this.latitude = latitude; + this.longitude = longitude; + this.altitude = altitude; + this.user = user; + this.audioPath = audioPath; + this.b = b; + this.thumbnail = thumbnail; + this.unit = unit; + this.project = project; + this.blade = blade; + } + + boolean b; + + public Bitmap getThumbnail() { + return thumbnail; + } + + public void setThumbnail(Bitmap thumbnail) { + this.thumbnail = thumbnail; + } + + public String getProject() { + return project; + } + + public void setProject(String project) { + this.project = project; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public int getBlade() { + return blade; + } + + public void setBlade(int blade) { + this.blade = blade; + } + + private String audioPath; + public Bitmap thumbnail; + private String project; + private String unit; + private int blade; + public void setPath(String path) { + this.path = path; + } + + public void setTime(long time) { + this.time = time; + } + + public void setBitmap(Bitmap bitmap) { + this.bitmap = bitmap; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public void setAltitude(double altitude) { + this.altitude = altitude; + } + + public void setUser(String user) { + this.user = user; + } + + public String getAudioPath() { + return audioPath; + } + + public void setAudioPath(String audioPath) { + this.audioPath = audioPath; + } + + // 修改构造函数 + public ImageInfo(String path, long time, Bitmap thumbnail, double latitude, double longitude, double altitude, String user, String audioPath) { + this.path = path; + this.time = time; + this.bitmap = bitmap; + this.latitude = latitude; + this.longitude = longitude; + this.altitude=altitude; + this.user=user; + this.audioPath=audioPath; + } + + public ImageInfo(String path, long time, Bitmap bitmap, double latitude, double longitude, double altitude, String user, String audioPath, Bitmap thumbnail, String project, String unit, int blade) { + this.path = path; + this.time = time; + this.bitmap = bitmap; + this.latitude = latitude; + this.longitude = longitude; + this.altitude = altitude; + this.user = user; + this.audioPath = audioPath; + this.thumbnail = thumbnail; + this.project = project; + this.unit = unit; + this.blade = blade; + } + + public double getLongitude() { + return longitude; + } + + public double getLatitude() { + return latitude; + } + + public String getUser() { + return user; + } + + + public double getAltitude() { + return altitude; + } + + public ImageInfo(String path, long time, Bitmap bitmap) { + this.path = path; + this.time = time; + this.bitmap = bitmap; + } + + // Getter 方法 + public String getPath() { return path; } + public long getTime() { return time; } + public Bitmap getBitmap() { return bitmap; } + + } + diff --git a/TurbineDao.java b/TurbineDao.java new file mode 100644 index 0000000..df75aa4 --- /dev/null +++ b/TurbineDao.java @@ -0,0 +1,24 @@ +package com.example.myapplication.DataBase; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.OnConflictStrategy; +import androidx.room.Query; + +import com.example.myapplication.model.Turbine; + +import java.util.List; + +@Dao +public interface TurbineDao { + @Insert(onConflict = OnConflictStrategy.REPLACE) + void insertAll(List turbines); + + @Query("SELECT * FROM turbines WHERE projectId = :projectId") + List getTurbinesByProject(String projectId); + @Query("DELETE FROM turbines WHERE projectId = :projectId") + void deleteByProjectId(String projectId); + @Query("SELECT * FROM turbines WHERE projectId = :projectId AND " + + "(turbineId LIKE :query OR turbineName LIKE :query)") + List searchTurbines(String projectId, String query); +} \ No newline at end of file