thêm giao diện quản lý thuyền
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import { api } from "@/config";
|
||||
import { API_PATH_LOGIN } from "@/constants";
|
||||
import { API_PATH_GET_PROFILE, API_PATH_LOGIN } from "@/constants";
|
||||
|
||||
export async function queryLogin(body: Model.LoginRequestBody) {
|
||||
return api.post<Model.LoginResponse>(API_PATH_LOGIN, body);
|
||||
}
|
||||
|
||||
export async function queryProfile() {
|
||||
return api.get<Model.ProfileResponse>(API_PATH_GET_PROFILE);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { api } from "@/config";
|
||||
import {
|
||||
API_GET_ALL_SHIP,
|
||||
API_GET_PHOTO,
|
||||
API_GET_SHIP_GROUPS,
|
||||
API_GET_SHIP_TYPES,
|
||||
API_PATH_SEARCH_THINGS,
|
||||
@@ -16,3 +18,22 @@ export async function queryShipTypes() {
|
||||
export async function queryShipGroups() {
|
||||
return await api.get<Model.ShipGroup[]>(API_GET_SHIP_GROUPS);
|
||||
}
|
||||
|
||||
export async function queryAllShips(params: Model.SearchThingBody) {
|
||||
return await api.get<Model.ShipResponse>(API_GET_ALL_SHIP, {
|
||||
params: params,
|
||||
});
|
||||
}
|
||||
|
||||
export async function queryShipsImage(ship_id: string) {
|
||||
return await api.get(`${API_GET_PHOTO}/ship/${ship_id}/main`, {
|
||||
responseType: "arraybuffer",
|
||||
});
|
||||
}
|
||||
|
||||
export async function queryUpdateShip(
|
||||
shipId: string,
|
||||
body: Model.ShipBodyRequest
|
||||
) {
|
||||
return await api.put(`${API_GET_ALL_SHIP}/${shipId}`, body);
|
||||
}
|
||||
|
||||
25
controller/GroupController.ts
Normal file
25
controller/GroupController.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { api } from "@/config";
|
||||
import { UID } from "@/constants";
|
||||
import { getStorageItem } from "@/utils/storage";
|
||||
|
||||
export async function queryUserGroup() {
|
||||
const user_id = await getStorageItem(UID);
|
||||
return api.get<Model.GroupResponse>(`/api/members/${user_id}/groups`);
|
||||
}
|
||||
|
||||
export async function queryChilrentOfGroups(
|
||||
group_id: string,
|
||||
level: number = 5,
|
||||
isTree: boolean = false
|
||||
) {
|
||||
// ensure proper query param values when not provided by caller
|
||||
const lvl = typeof level === "number" ? level : 5;
|
||||
const tree = !!isTree;
|
||||
const params = {
|
||||
level: lvl,
|
||||
tree: tree,
|
||||
};
|
||||
return api.get<Model.GroupResponse>(`/api/groups/${group_id}/children`, {
|
||||
params,
|
||||
});
|
||||
}
|
||||
6
controller/PortController.ts
Normal file
6
controller/PortController.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { api } from "@/config";
|
||||
import { API_GET_ALL_PORT } from "@/constants";
|
||||
|
||||
export async function queryPorts(body?: Model.SearchThingBody) {
|
||||
return api.post<Model.PortResponse>(API_GET_ALL_PORT, body);
|
||||
}
|
||||
@@ -1,5 +1,17 @@
|
||||
import * as AlarmController from "./AlarmController";
|
||||
import * as AuthController from "./AuthController";
|
||||
import * as DeviceController from "./DeviceController";
|
||||
import * as FishController from "./FishController";
|
||||
import * as MapController from "./MapController";
|
||||
import * as PortController from "./PortController";
|
||||
import * as TripController from "./TripController";
|
||||
export { AuthController, DeviceController, MapController, TripController };
|
||||
|
||||
export {
|
||||
AlarmController,
|
||||
AuthController,
|
||||
DeviceController,
|
||||
FishController,
|
||||
MapController,
|
||||
PortController,
|
||||
TripController,
|
||||
};
|
||||
|
||||
122
controller/typings.d.ts
vendored
122
controller/typings.d.ts
vendored
@@ -9,6 +9,20 @@ declare namespace Model {
|
||||
token?: string;
|
||||
}
|
||||
|
||||
interface ProfileResponse {
|
||||
id?: string;
|
||||
email?: string;
|
||||
metadata?: ProfileMetadata;
|
||||
}
|
||||
|
||||
interface ProfileMetadata {
|
||||
frontend_thing_id?: string;
|
||||
frontend_thing_key?: string;
|
||||
full_name?: string;
|
||||
phone_number?: string;
|
||||
user_type?: string;
|
||||
}
|
||||
|
||||
interface GPSResponse {
|
||||
lat: number;
|
||||
lon: number;
|
||||
@@ -336,4 +350,112 @@ declare namespace Model {
|
||||
thing_id: string;
|
||||
time: number;
|
||||
}
|
||||
|
||||
interface ShipBodyRequest {
|
||||
name?: string;
|
||||
reg_number?: string;
|
||||
imo_number?: string;
|
||||
mmsi_number?: string;
|
||||
thing_id?: string;
|
||||
ship_type?: number;
|
||||
owner_id?: string;
|
||||
home_port?: number;
|
||||
ship_length?: number;
|
||||
ship_power?: number;
|
||||
ship_group_id?: string;
|
||||
fishing_license_number?: string;
|
||||
fishing_license_expiry_date?: Date;
|
||||
}
|
||||
interface ShipResponse {
|
||||
ships?: Ship[];
|
||||
}
|
||||
|
||||
interface Ship {
|
||||
id?: string;
|
||||
thing_id?: string;
|
||||
owner_id?: string;
|
||||
name?: string;
|
||||
ship_type?: number;
|
||||
home_port?: number;
|
||||
ship_length?: number;
|
||||
ship_power?: number;
|
||||
reg_number?: string;
|
||||
imo_number?: string;
|
||||
mmsi_number?: string;
|
||||
fishing_license_number?: string;
|
||||
fishing_license_expiry_date?: Date;
|
||||
province_code?: string;
|
||||
ship_group_id?: string;
|
||||
created_at?: Date;
|
||||
updated_at?: Date;
|
||||
}
|
||||
|
||||
interface PortResponse {
|
||||
total?: number;
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
ports?: Port[];
|
||||
}
|
||||
|
||||
interface Port {
|
||||
id?: number;
|
||||
name?: string;
|
||||
type?: Type;
|
||||
classification?: Classification;
|
||||
position_point?: string;
|
||||
has_origin_confirm?: boolean;
|
||||
province_code?: string;
|
||||
updated_at?: Date;
|
||||
is_deleted?: boolean;
|
||||
}
|
||||
|
||||
enum Classification {
|
||||
ChưaXácĐịnh = "Chưa xác định",
|
||||
I = "I",
|
||||
Ii = "II",
|
||||
}
|
||||
|
||||
enum Type {
|
||||
Fishing = "fishing",
|
||||
}
|
||||
|
||||
// Groups
|
||||
interface GroupResponse {
|
||||
total?: number;
|
||||
level?: number;
|
||||
name?: string;
|
||||
groups?: Group[];
|
||||
}
|
||||
|
||||
interface Group {
|
||||
id?: string;
|
||||
name?: string;
|
||||
owner_id?: string;
|
||||
description?: string;
|
||||
metadata?: GroupMetadata;
|
||||
level?: number;
|
||||
path?: string;
|
||||
children?: Child[];
|
||||
created_at?: Date;
|
||||
updated_at?: Date;
|
||||
}
|
||||
|
||||
interface Child {
|
||||
id?: string;
|
||||
name?: string;
|
||||
owner_id?: string;
|
||||
parent_id?: string;
|
||||
description?: string;
|
||||
metadata?: GroupMetadata;
|
||||
level?: number;
|
||||
path?: string;
|
||||
children?: Child[];
|
||||
created_at?: Date;
|
||||
updated_at?: Date;
|
||||
}
|
||||
|
||||
interface GroupMetadata {
|
||||
code?: string;
|
||||
short_name?: string;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user