上传文件至 /
This commit is contained in:
parent
5300b098d5
commit
9954e99344
|
@ -0,0 +1,61 @@
|
|||
package com.example.myapplication.model;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class ApiResponse<T> {
|
||||
|
||||
|
||||
|
||||
@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 +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
||||
|
||||
|
||||
}
|
|
@ -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
|
||||
|
|
@ -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; }
|
||||
|
||||
}
|
||||
|
|
@ -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<Turbine> turbines);
|
||||
|
||||
@Query("SELECT * FROM turbines WHERE projectId = :projectId")
|
||||
List<Turbine> 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<Turbine> searchTurbines(String projectId, String query);
|
||||
}
|
Loading…
Reference in New Issue