Khởi tạo ban đầu
This commit is contained in:
6
controller/AuthController.ts
Normal file
6
controller/AuthController.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { api } from "@/config";
|
||||
import { API_PATH_LOGIN } from "@/constants";
|
||||
|
||||
export async function queryLogin(body: Model.LoginRequestBody) {
|
||||
return api.post<Model.LoginResponse>(API_PATH_LOGIN, body);
|
||||
}
|
||||
37
controller/DeviceController.ts
Normal file
37
controller/DeviceController.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { api } from "@/config";
|
||||
import {
|
||||
API_GET_ALARMS,
|
||||
API_GET_GPS,
|
||||
API_PATH_ENTITIES,
|
||||
API_PATH_SHIP_TRACK_POINTS,
|
||||
API_SOS,
|
||||
} from "@/constants";
|
||||
import { transformEntityResponse } from "@/utils/tranform";
|
||||
|
||||
export async function queryGpsData() {
|
||||
return api.get<Model.GPSResponse>(API_GET_GPS);
|
||||
}
|
||||
|
||||
export async function queryAlarm() {
|
||||
return api.get<Model.AlarmResponse>(API_GET_ALARMS);
|
||||
}
|
||||
|
||||
export async function queryTrackPoints() {
|
||||
return api.get<Model.ShipTrackPoint[]>(API_PATH_SHIP_TRACK_POINTS);
|
||||
}
|
||||
|
||||
export async function queryEntities(): Promise<Model.TransformedEntity[]> {
|
||||
const response = await api.get<Model.EntityResponse[]>(API_PATH_ENTITIES);
|
||||
return response.data.map(transformEntityResponse);
|
||||
}
|
||||
|
||||
export async function queryGetSos() {
|
||||
return await api.get<Model.SosResponse>(API_SOS);
|
||||
}
|
||||
export async function queryDeleteSos() {
|
||||
return await api.delete<Model.SosResponse>(API_SOS);
|
||||
}
|
||||
|
||||
export async function querySendSosMessage(message: string) {
|
||||
return await api.put<Model.SosRequest>(API_SOS, { message });
|
||||
}
|
||||
6
controller/FishController.ts
Normal file
6
controller/FishController.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { api } from "@/config";
|
||||
import { API_GET_FISH } from "@/constants";
|
||||
|
||||
export async function queryFish() {
|
||||
return api.get<Model.FishSpeciesResponse[]>(API_GET_FISH);
|
||||
}
|
||||
6
controller/MapController.ts
Normal file
6
controller/MapController.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { api } from "@/config";
|
||||
import { API_GET_ALL_BANZONES } from "@/constants";
|
||||
|
||||
export async function queryBanzones() {
|
||||
return api.get<Model.Zone[]>(API_GET_ALL_BANZONES);
|
||||
}
|
||||
23
controller/TripController.ts
Normal file
23
controller/TripController.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { api } from "@/config";
|
||||
import {
|
||||
API_GET_TRIP,
|
||||
API_HAUL_HANDLE,
|
||||
API_UPDATE_FISHING_LOGS,
|
||||
API_UPDATE_TRIP_STATUS,
|
||||
} from "@/constants";
|
||||
|
||||
export async function queryTrip() {
|
||||
return api.get<Model.Trip>(API_GET_TRIP);
|
||||
}
|
||||
|
||||
export async function queryUpdateTripState(body: Model.TripUpdateStateRequest) {
|
||||
return api.put(API_UPDATE_TRIP_STATUS, body);
|
||||
}
|
||||
|
||||
export async function queryStartNewHaul(body: Model.NewFishingLogRequest) {
|
||||
return api.put(API_HAUL_HANDLE, body);
|
||||
}
|
||||
|
||||
export async function queryUpdateFishingLogs(body: Model.FishingLog) {
|
||||
return api.put(API_UPDATE_FISHING_LOGS, body);
|
||||
}
|
||||
5
controller/index.ts
Normal file
5
controller/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import * as AuthController from "./AuthController";
|
||||
import * as DeviceController from "./DeviceController";
|
||||
import * as MapController from "./MapController";
|
||||
import * as TripController from "./TripController";
|
||||
export { AuthController, DeviceController, MapController, TripController };
|
||||
214
controller/typings.d.ts
vendored
Normal file
214
controller/typings.d.ts
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
declare namespace Model {
|
||||
interface LoginRequestBody {
|
||||
guid: string;
|
||||
email: string;
|
||||
password: string;
|
||||
}
|
||||
interface LoginResponse {
|
||||
enabled2fa: boolean;
|
||||
token?: string;
|
||||
}
|
||||
|
||||
interface GPSResponse {
|
||||
lat: number;
|
||||
lon: number;
|
||||
s: number;
|
||||
h: number;
|
||||
fishing: boolean;
|
||||
}
|
||||
interface Alarm {
|
||||
name: string;
|
||||
t: number; // timestamp (epoch seconds)
|
||||
level: number;
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface AlarmResponse {
|
||||
alarms: Alarm[];
|
||||
level: number;
|
||||
}
|
||||
|
||||
interface ShipTrackPoint {
|
||||
time: number;
|
||||
lon: number;
|
||||
lat: number;
|
||||
s: number;
|
||||
h: number;
|
||||
}
|
||||
interface EntityResponse {
|
||||
id: string;
|
||||
v: number;
|
||||
vs: string;
|
||||
t: number;
|
||||
type: string;
|
||||
}
|
||||
interface TransformedEntity {
|
||||
id: string;
|
||||
value: number;
|
||||
valueString: string;
|
||||
time: number;
|
||||
type: string;
|
||||
}
|
||||
|
||||
// Banzones
|
||||
// Banzone
|
||||
export interface Zone {
|
||||
id?: string;
|
||||
name?: string;
|
||||
type?: number;
|
||||
conditions?: Condition[];
|
||||
enabled?: boolean;
|
||||
updated_at?: Date;
|
||||
geom?: Geom;
|
||||
}
|
||||
|
||||
export interface Condition {
|
||||
max?: number;
|
||||
min?: number;
|
||||
type?: Type;
|
||||
to?: number;
|
||||
from?: number;
|
||||
}
|
||||
|
||||
export enum Type {
|
||||
LengthLimit = "length_limit",
|
||||
MonthRange = "month_range",
|
||||
}
|
||||
|
||||
export interface Geom {
|
||||
geom_type?: number;
|
||||
geom_poly?: string;
|
||||
geom_lines?: string;
|
||||
geom_point?: string;
|
||||
geom_radius?: number;
|
||||
}
|
||||
|
||||
interface SosRequest {
|
||||
message?: string;
|
||||
}
|
||||
|
||||
interface SosResponse {
|
||||
active: boolean;
|
||||
message?: string;
|
||||
started_at?: number;
|
||||
}
|
||||
// Trip
|
||||
interface Trip {
|
||||
id: string;
|
||||
ship_id: string;
|
||||
ship_length: number;
|
||||
vms_id: string;
|
||||
name: string;
|
||||
fishing_gears: FishingGear[]; // Dụng cụ đánh cá
|
||||
crews?: TripCrews[]; // Thuyền viên
|
||||
departure_time: string; // ISO datetime string
|
||||
departure_port_id: number;
|
||||
arrival_time: string; // ISO datetime string
|
||||
arrival_port_id: number;
|
||||
fishing_ground_codes: number[];
|
||||
total_catch_weight: number | null;
|
||||
total_species_caught: number | null;
|
||||
trip_cost: TripCost[]; // Chi phí chuyến đi
|
||||
trip_status: number;
|
||||
approved_by: string;
|
||||
notes: string | null;
|
||||
fishing_logs: FishingLog[] | null; // tuỳ dữ liệu chi tiết có thể định nghĩa thêm
|
||||
sync: boolean;
|
||||
}
|
||||
|
||||
// Dụng cụ đánh cá
|
||||
interface FishingGear {
|
||||
name: string;
|
||||
number: string;
|
||||
}
|
||||
// Thuyền viên
|
||||
interface TripCrews {
|
||||
TripID: string;
|
||||
PersonalID: string;
|
||||
role: string;
|
||||
joined_at: Date;
|
||||
left_at: Date | null;
|
||||
note: string | null;
|
||||
Person: TripCrewPerson;
|
||||
}
|
||||
interface TripCrewPerson {
|
||||
personal_id: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
email: string;
|
||||
birth_date: Date; // ISO string (có thể chuyển sang Date nếu parse trước)
|
||||
note: string;
|
||||
address: string;
|
||||
created_at: Date;
|
||||
updated_at: Date;
|
||||
}
|
||||
// Chi phí chuyến đi
|
||||
interface TripCost {
|
||||
type: string;
|
||||
unit: string;
|
||||
amount: number;
|
||||
total_cost: number;
|
||||
cost_per_unit: number;
|
||||
}
|
||||
// Thông tin mẻ lưới
|
||||
interface FishingLog {
|
||||
fishing_log_id: string;
|
||||
trip_id: string;
|
||||
start_at: Date; // ISO datetime
|
||||
end_at: Date; // ISO datetime
|
||||
start_lat: number;
|
||||
start_lon: number;
|
||||
haul_lat: number;
|
||||
haul_lon: number;
|
||||
status: number;
|
||||
weather_description: string;
|
||||
info?: FishingLogInfo[]; // Thông tin cá
|
||||
sync: boolean;
|
||||
}
|
||||
// Thông tin cá
|
||||
interface FishingLogInfo {
|
||||
fish_species_id?: number;
|
||||
fish_name?: string;
|
||||
catch_number?: number;
|
||||
catch_unit?: string;
|
||||
fish_size?: number;
|
||||
fish_rarity?: number;
|
||||
fish_condition?: string;
|
||||
gear_usage?: string;
|
||||
}
|
||||
interface NewFishingLogRequest {
|
||||
trip_id: string;
|
||||
start_at: Date; // ISO datetime
|
||||
start_lat: number;
|
||||
start_lon: number;
|
||||
weather_description: string;
|
||||
}
|
||||
|
||||
interface TripUpdateStateRequest {
|
||||
status: number;
|
||||
note?: string;
|
||||
}
|
||||
//Fish
|
||||
interface FishSpeciesResponse {
|
||||
id: number;
|
||||
name: string;
|
||||
scientific_name: string;
|
||||
group_name: string;
|
||||
species_code: string;
|
||||
note: string;
|
||||
default_unit: string;
|
||||
rarity_level: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
is_deleted: boolean;
|
||||
}
|
||||
interface FishRarity {
|
||||
id: number;
|
||||
code: string;
|
||||
label: string;
|
||||
description: string;
|
||||
iucn_code: any;
|
||||
cites_appendix: any;
|
||||
vn_law: boolean;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user