refactor(typings): Refactor user and profile models; update API response types

This commit is contained in:
Tran Anh Tuan
2026-01-24 18:18:16 +07:00
parent 1a06328c77
commit b0b09a86b7
43 changed files with 1035 additions and 967 deletions

View File

@@ -16,13 +16,13 @@ export async function apiLogin(body: MasterModel.LoginRequestBody) {
}
export async function apiQueryProfile() {
return request<MasterModel.ProfileResponse>(API_PATH_GET_PROFILE);
return request<MasterModel.UserResponse>(API_PATH_GET_PROFILE);
}
export async function apiUpdateProfile(
body: Partial<MasterModel.ProfileMetadata>,
body: Partial<MasterModel.UserMetadata>,
) {
return request<MasterModel.ProfileResponse>(API_USERS, {
return request<MasterModel.UserResponse>(API_USERS, {
method: 'PUT',
data: {
metadata: body,

View File

@@ -5,6 +5,19 @@ import {
} from '@/constants/api';
import { request } from '@umijs/max';
export async function apiSearchThings(
body: MasterModel.SearchPaginationBody,
domain: 'spole',
): Promise<SpoleModel.SpoleThingsResponse>;
export async function apiSearchThings(
body: MasterModel.SearchPaginationBody,
domain: 'sgw',
): Promise<SgwModel.SgwThingsResponse>;
export async function apiSearchThings(
body: MasterModel.SearchPaginationBody,
domain?: 'gms',
): Promise<GmsModel.GmsThingsResponse>;
export async function apiSearchThings(
body: MasterModel.SearchPaginationBody,
domain: string = process.env.DOMAIN_ENV || 'gms',

View File

@@ -4,19 +4,21 @@ import { request } from '@umijs/max';
export async function apiQueryUsers(
params: MasterModel.SearchUserPaginationBody,
) {
return request<MasterModel.UserResponse>(API_USERS, {
return request<MasterModel.UserListResponse>(API_USERS, {
params: params,
});
}
export async function apiQueryUserById(userId: string) {
return request<MasterModel.ProfileResponse>(`${API_USERS}/${userId}`);
return request<MasterModel.UserResponse>(`${API_USERS}/${userId}`);
}
export async function apiQueryUsersByGroup(
group_id: string,
): Promise<MasterModel.UserResponse> {
return request<MasterModel.UserResponse>(`${API_USERS_BY_GROUP}/${group_id}`);
): Promise<MasterModel.UserListResponse> {
return request<MasterModel.UserListResponse>(
`${API_USERS_BY_GROUP}/${group_id}`,
);
}
export async function apiCreateUsers(body: MasterModel.CreateUserBodyRequest) {

View File

@@ -8,254 +8,12 @@ declare namespace MasterModel {
limit?: number;
dir?: 'asc' | 'desc';
}
interface SearchThingPaginationBody extends SearchPaginationBody {
order?: string;
metadata?: ThingMetadata;
}
interface ThingMetadata {
group_id?: string;
external_id?: string;
}
interface SearchAlarmPaginationBody extends SearchPaginationBody {
order?: 'name' | undefined;
thing_name?: string;
thing_id?: string;
level?: number;
}
interface SearchUserPaginationBody extends SearchPaginationBody {
order?: 'email' | 'name' | undefined;
email?: string;
metadata?: Partial<ProfileMetadata>;
}
interface SearchLogPaginationBody extends SearchPaginationBody {
from?: number;
to?: number;
publisher?: string;
subtopic?: string;
}
// Auth
interface LoginRequestBody {
guid: string;
email: string;
password: string;
}
interface LoginResponse {
token?: string;
}
interface ChangePasswordRequestBody {
old_password: string;
password: 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;
telegram?: string;
user_type?: 'admin' | 'enduser' | 'sysadmin' | 'users';
}
// User
interface CreateUserMetadata extends ProfileMetadata {
group_id?: string;
}
interface CreateUserBodyRequest extends Partial<ProfileResponse> {
password: string;
full_name?: string;
metadata?: CreateUserMetadata;
}
interface UserResponse {
total?: number;
offset?: number;
limit?: number;
users: ProfileResponse[];
}
interface AlarmsResponse {
total?: number;
limit?: number;
order?: string;
dir?: string;
alarms?: Alarm[];
}
interface ConfirmAlarmRequest {
id?: string;
description?: string;
thing_id?: string;
time?: number;
}
// Alarm
interface Alarm {
name?: string;
time?: number;
level?: number;
id?: string;
confirmed?: boolean;
confirmed_email?: string;
confirmed_time?: number;
confirmed_desc?: string;
thing_id?: string;
thing_name?: string;
thing_type?: string;
}
// Thing
interface ThingMetadata {
address?: string;
alarm_list?: string;
cfg_channel_id?: string;
connected?: boolean;
ctrl_channel_id?: string;
data_channel_id?: string;
enduser?: string;
external_id?: string;
group_id?: string;
req_channel_id?: string;
state?: string;
state_level?: number;
state_updated_time?: number;
type?: string;
updated_time?: number;
}
interface ThingsResponse<T extends ThingMetadata = ThingMetadata> {
interface PaginationReponse {
total?: number;
offset?: number;
limit?: number;
order?: string;
direction?: string;
metadata?: ThingsResponseMetadata;
things?: Thing<T>[];
}
interface ThingsResponseMetadata {
total_connected?: number;
total_filter?: number;
total_sos?: number;
total_state_level_0?: number;
total_state_level_1?: number;
total_state_level_2?: number;
total_thing?: number;
}
interface Thing<T extends ThingMetadata = ThingMetadata> {
id?: string;
name?: string;
key?: string;
metadata?: T;
}
// Thing Policy
interface ThingPolicyResponse {
total?: number;
offset?: number;
limit?: number;
order?: string;
direction?: string;
metadata?: null;
things?: ThingPolicy[];
}
interface ThingPolicy {
policies?: Policy[];
thing_id?: string;
thing_name?: string;
external_id?: string;
}
type Policy = 'read' | 'delete' | 'write';
// Group
interface GroupBodyRequest {
id?: string;
name: string;
parent_id?: string;
description?: string;
metadata?: GroupMetadata;
}
interface AddGroupBodyResponse extends Partial<GroupBodyRequest> {
id: string;
}
interface GroupMetadata {
code?: string;
short_name?: string;
has_thing?: boolean;
[key: string]: unknown;
}
interface GroupResponse {
total?: number;
level?: number;
name?: string;
groups?: GroupNode[];
}
interface GroupNode {
id: string;
name: string;
owner_id: string;
description: string;
metadata: GroupMetadata;
level: number;
path: string;
parent_id?: string;
created_at?: string;
updated_at?: string;
children?: GroupNode[]; // Đệ quy: mỗi node có thể có children là mảng GroupNode
[key: string]: any; // Nếu có thêm trường động
}
interface GroupQueryParams {
level?: number;
tree?: boolean;
[key: string]: any;
}
// Log
type LogTypeRequest = 'user_logs' | undefined;
interface LogResponse {
offset?: number;
limit?: number;
publisher?: string;
from?: number;
to?: number;
format?: string;
total?: number;
messages?: Message[];
}
interface Message {
channel?: string;
subtopic?: string;
publisher?: string;
protocol?: string;
name?: string;
time?: number;
string_value?: string;
}
// User
interface AssignMemberRequest {
group_id: string;
type: 'users' | 'admin' | 'things' | undefined;
members: string[];
}
}

36
src/services/master/typings/alarm.d.ts vendored Normal file
View File

@@ -0,0 +1,36 @@
declare namespace MasterModel {
interface SearchAlarmPaginationBody extends SearchPaginationBody {
order?: 'name' | undefined;
thing_name?: string;
thing_id?: string;
level?: number;
}
interface AlarmsResponse {
total?: number;
limit?: number;
order?: string;
dir?: string;
alarms?: Alarm[];
}
interface ConfirmAlarmRequest {
id?: string;
description?: string;
thing_id?: string;
time?: number;
}
// Alarm
interface Alarm {
name?: string;
time?: number;
level?: number;
id?: string;
confirmed?: boolean;
confirmed_email?: string;
confirmed_time?: number;
confirmed_desc?: string;
thing_id?: string;
thing_name?: string;
thing_type?: string;
}
}

11
src/services/master/typings/auth.d.ts vendored Normal file
View File

@@ -0,0 +1,11 @@
declare namespace MasterModel {
interface LoginRequestBody {
guid: string;
email: string;
password: string;
}
interface LoginResponse {
token?: string;
}
}

52
src/services/master/typings/group.d.ts vendored Normal file
View File

@@ -0,0 +1,52 @@
declare namespace MasterModel {
interface GroupBodyRequest {
id?: string;
name: string;
parent_id?: string;
description?: string;
metadata?: GroupMetadata;
}
interface AddGroupBodyResponse extends Partial<GroupBodyRequest> {
id: string;
}
interface GroupMetadata {
code?: string;
short_name?: string;
has_thing?: boolean;
[key: string]: unknown;
}
interface GroupResponse {
total?: number;
level?: number;
name?: string;
groups?: GroupNode[];
}
interface GroupNode {
id: string;
name: string;
owner_id: string;
description: string;
metadata: GroupMetadata;
level: number;
path: string;
parent_id?: string;
created_at?: string;
updated_at?: string;
children?: GroupNode[]; // Đệ quy: mỗi node có thể có children là mảng GroupNode
[key: string]: any; // Nếu có thêm trường động
}
interface GroupQueryParams {
level?: number;
tree?: boolean;
[key: string]: any;
}
interface AssignMemberRequest {
group_id: string;
type: 'users' | 'admin' | 'things' | undefined;
members: string[];
}
}

31
src/services/master/typings/log.d.ts vendored Normal file
View File

@@ -0,0 +1,31 @@
declare namespace MasterModel {
interface SearchLogPaginationBody extends SearchPaginationBody {
from?: number;
to?: number;
publisher?: string;
subtopic?: string;
}
type LogTypeRequest = 'user_logs' | undefined;
interface LogResponse {
offset?: number;
limit?: number;
publisher?: string;
from?: number;
to?: number;
format?: string;
total?: number;
messages?: Message[];
}
interface Message {
channel?: string;
subtopic?: string;
publisher?: string;
protocol?: string;
name?: string;
time?: number;
string_value?: string;
}
}

73
src/services/master/typings/thing.d.ts vendored Normal file
View File

@@ -0,0 +1,73 @@
declare namespace MasterModel {
interface SearchThingPaginationBody<T = SearchThingMetadata>
extends SearchPaginationBody {
order?: string;
metadata?: T;
}
interface SearchThingMetadata {
external_id?: string;
state_level?: string; // vd: "normal,warning,critical,sos"
/** kết nối */
connected?: boolean;
group_id?: string; // "id1,id2,id3"
}
// Thing
interface ThingReponseMetadata {
address?: string;
alarm_list?: string;
cfg_channel_id?: string;
connected?: boolean;
ctrl_channel_id?: string;
data_channel_id?: string;
enduser?: string;
external_id?: string;
group_id?: string;
req_channel_id?: string;
state?: string;
state_level?: number;
state_updated_time?: number;
type?: string;
updated_time?: number;
}
interface ThingsResponse<
T extends ThingReponseMetadata = ThingReponseMetadata,
> extends PaginationReponse {
metadata?: ThingsResponseMetadata;
things?: Thing<T>[];
}
interface ThingsResponseMetadata {
total_connected?: number;
total_filter?: number;
total_sos?: number;
total_state_level_0?: number;
total_state_level_1?: number;
total_state_level_2?: number;
total_thing?: number;
}
interface Thing<T extends ThingReponseMetadata = ThingReponseMetadata> {
id?: string;
name?: string;
key?: string;
metadata?: T;
}
// Thing Policy
interface ThingPolicyResponse extends PaginationReponse {
metadata?: null;
things?: ThingPolicy[];
}
interface ThingPolicy {
policies?: Policy[];
thing_id?: string;
thing_name?: string;
external_id?: string;
}
type Policy = 'read' | 'delete' | 'write';
}

44
src/services/master/typings/user.d.ts vendored Normal file
View File

@@ -0,0 +1,44 @@
declare namespace MasterModel {
interface SearchUserPaginationBody extends SearchPaginationBody {
order?: 'email' | 'name' | undefined;
email?: string;
metadata?: Partial<UserMetadata>;
}
interface ChangePasswordRequestBody {
old_password: string;
password: string;
}
interface UserResponse {
id?: string;
email?: string;
metadata?: UserMetadata;
}
interface UserMetadata {
frontend_thing_id?: string;
frontend_thing_key?: string;
full_name?: string;
phone_number?: string;
telegram?: string;
user_type?: 'admin' | 'enduser' | 'sysadmin' | 'users';
}
// User
interface CreateUserMetadata extends UserMetadata {
group_id?: string;
}
interface CreateUserBodyRequest extends Partial<UserResponse> {
password: string;
full_name?: string;
metadata?: CreateUserMetadata;
}
interface UserListResponse {
total?: number;
offset?: number;
limit?: number;
users: UserResponse[];
}
}

View File

@@ -42,7 +42,7 @@ export async function apiGetZoneById(
* Create a new banzone
* @param body Banzone data
*/
export async function apiCreateBanzone(body: SgwModel.ZoneBodyRequest) {
export async function apiCreateBanzone(body: SgwModel.ZoneBasicInfo) {
return request(SGW_ROUTE_BANZONES, {
method: 'POST',
data: body,
@@ -56,7 +56,7 @@ export async function apiCreateBanzone(body: SgwModel.ZoneBodyRequest) {
*/
export async function apiUpdateBanzone(
id: string,
body: SgwModel.ZoneBodyRequest,
body: SgwModel.ZoneBasicInfo,
) {
return request(`${SGW_ROUTE_BANZONES}/${id}`, {
method: 'PUT',

View File

@@ -3,7 +3,7 @@
declare namespace SgwModel {
// Thing
interface ThingMedata extends MasterModel.ThingMetadata {
interface ThingMedata extends MasterModel.ThingReponseMetadata {
gps?: string;
gps_time?: string;
ship_group_id?: string;
@@ -23,442 +23,4 @@ declare namespace SgwModel {
type SgwThingsResponse = MasterModel.ThingsResponse<SgwModel.ThingMedata>;
type SgwThing = MasterModel.Thing<SgwModel.ThingMedata>;
// Ship
interface ShipMetadata {
crew_count?: number;
home_port?: string;
home_port_point?: string;
ship_type?: string;
trip_arrival_port?: string;
trip_arrival_port_point?: string;
trip_arrival_time?: Date;
trip_depart_port?: string;
trip_depart_port_point?: string;
trip_departure_time?: Date;
trip_id?: string;
trip_name?: string;
trip_state?: number;
}
interface ShipType {
id?: number;
name?: string;
description?: string;
}
interface ShipDetail {
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 | string;
province_code?: string;
ship_group_id?: string | null;
created_at?: Date | string;
updated_at?: Date | string;
metadata?: ShipMetadata;
}
interface ShipCreateParams {
thing_id?: string;
name?: string;
reg_number?: string;
ship_type?: number;
ship_length?: number;
ship_power?: number;
ship_group_id?: string;
home_port?: number;
fishing_license_number?: string;
fishing_license_expiry_date?: string;
}
interface ShipUpdateParams {
name?: string;
reg_number?: string;
ship_type?: number;
ship_group_id?: string | null;
ship_length?: number;
ship_power?: number;
home_port?: number;
fishing_license_number?: string;
fishing_license_expiry_date?: string;
metadata?: Record<string, unknown>;
}
interface ShipQueryParams {
offset?: number;
limit?: number;
order?: string;
dir?: 'asc' | 'desc';
name?: string;
registration_number?: string;
ship_type?: number;
ship_group_id?: string;
thing_id?: string;
}
interface ShipQueryResponse {
ships: ShipDetail[];
total: number;
offset: number;
limit: number;
}
interface ShipsResponse<T extends ShipMetadata = ShipMetadata> {
total?: number;
offset?: number;
limit?: number;
order?: string;
direction?: string;
Ship?: Ship<T>[];
}
// Ship Group
interface ShipGroup {
id: string;
name: string;
owner_id?: string;
description?: string;
created_at?: Date | string;
updated_at?: Date | string;
metadata?: Record<string, unknown>;
}
interface GroupShipResponse {
id?: string;
name?: string;
owner_id?: string;
description?: string;
}
interface ShipGroupCreateParams {
name: string;
description?: string;
metadata?: Record<string, unknown>;
}
interface ShipGroupUpdateParams {
name?: string;
description?: string;
metadata?: Record<string, unknown>;
}
// Port
interface Port {
id: number;
name: string;
type: string;
classification: string;
position_point: string;
has_origin_confirm: boolean;
province_code: string;
updated_at: string;
is_deleted: boolean;
}
interface PortQueryParams {
name?: string;
order?: string;
dir?: 'asc' | 'desc';
limit?: number;
offset?: number;
metadata?: {
province_code?: string;
};
}
interface PortQueryResponse {
total: number;
offset: number;
limit: number;
ports: Port[];
}
// Trip Management
interface FishingGear {
name: string;
number: string;
}
interface TripCost {
type: string;
unit: string;
amount: string;
total_cost: string;
cost_per_unit: string;
}
interface TripCrewPerson {
personal_id: string;
name: string;
phone: string;
email: string;
birth_date: Date;
note: string;
address: string;
created_at: Date;
updated_at: Date;
}
interface TripCrews {
role: string;
joined_at: Date;
left_at: Date | null;
note: string | null;
Person: TripCrewPerson;
}
interface CrewCreateParams {
personal_id: string;
name: string;
phone?: string;
email?: string;
birth_date?: string;
address?: string;
note?: string;
}
interface CrewUpdateParams {
name?: string;
phone?: string;
email?: string;
birth_date?: string;
address?: string;
note?: string;
}
interface TripCrewCreateParams {
trip_id: string;
personal_id: string;
role: string;
note?: string;
}
interface TripCrewUpdateParams {
trip_id: string;
personal_id: string;
role?: string;
note?: string;
}
interface TripCrewQueryResponse {
trip_crews: TripCrews[];
total?: number;
}
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 FishingLog {
fishing_log_id?: string;
trip_id: string;
start_at: Date;
end_at: Date;
start_lat: number;
start_lon: number;
haul_lat: number;
haul_lon: number;
status: number;
weather_description: string;
info?: FishingLogInfo[];
sync: boolean;
}
interface NewFishingLogRequest {
trip_id: string;
start_at: Date;
start_lat: number;
start_lon: number;
weather_description: string;
}
interface FishSpecies {
id: number;
name: string;
scientific_name?: string;
description?: string;
}
interface FishSpeciesResponse extends FishSpecies {}
interface Trip {
id: string;
ship_id: string;
ship_length: number;
vms_id: string;
name: string;
fishing_gears: FishingGear[];
crews?: TripCrews[];
departure_time: string;
departure_port_id: number;
arrival_time: string;
arrival_port_id: number;
fishing_ground_codes: number[];
total_catch_weight: number | null;
total_species_caught: number | null;
trip_cost: TripCost[];
trip_status: number;
approved_by: string;
notes: string | null;
fishing_logs: FishingLog[] | null;
sync: boolean;
}
interface TripUpdateStateRequest {
status: number;
note?: string;
}
interface TripCreateParams {
name: string;
departure_time: string;
departure_port_id: number;
arrival_time?: string;
arrival_port_id?: number;
fishing_ground_codes?: number[];
fishing_gears?: FishingGear[];
crews?: TripCrews[];
trip_cost?: TripCost[];
notes?: string;
}
interface TripFormValues {
name: string;
departure_time: any; // dayjs object or string
departure_port_id: number;
arrival_time?: any; // dayjs object or string
arrival_port_id?: number;
fishing_ground_codes?: number[];
fishing_gear?: FishingGear[];
trip_cost?: TripCost[];
ship_id?: string;
}
interface TripQueryParams {
name?: string;
order?: string;
dir?: 'asc' | 'desc';
offset?: number;
limit?: number;
metadata?: {
from?: string;
to?: string;
ship_name?: string;
reg_number?: string;
province_code?: string;
owner_id?: string;
ship_id?: string;
status?: string;
};
}
interface TripQueryResponse {
trips: Trip[];
total: number;
offset: number;
limit: number;
}
interface TripUpdateParams {
name?: string;
departure_time?: string;
departure_port_id?: number;
arrival_time?: string;
arrival_port_id?: number;
fishing_ground_codes?: number[];
fishing_gears?: FishingGear[];
crews?: TripCrews[];
trip_cost?: TripCost[];
trip_status?: number;
notes?: string;
}
interface TripDeleteParams {
trip_ids: string[];
}
// Photo Management
interface PhotoGetParams {
type: 'ship' | 'people';
id: string;
}
interface PhotoUploadParams {
type: 'ship' | 'people';
id: string;
file: File;
}
// Banzone Management
interface Banzone {
id?: string;
name?: string;
province_code?: string;
type?: number;
conditions?: Condition[];
description?: string;
geometry?: string;
enabled?: boolean;
created_at?: Date;
updated_at?: Date;
}
interface Condition {
max?: number;
min?: number;
type?: 'length_limit' | 'month_range' | 'date_range';
to?: number;
from?: number;
}
interface Geom {
geom_type?: number;
geom_poly?: string;
geom_lines?: string;
geom_point?: string;
geom_radius?: number;
}
interface ZoneResponse {
total?: number;
offset?: number;
limit?: number;
banzones?: Banzone[];
}
interface ZoneBodyRequest {
name?: string;
province_code?: string;
type?: number;
conditions?: Condition[];
description?: string;
geometry?: string;
enabled?: boolean;
}
}
declare namespace WsTypes {
interface WsThingResponse {
thing_id?: string;
key?: string;
data?: string;
time?: number;
}
}

View File

@@ -0,0 +1,17 @@
declare namespace SgwModel {
interface CrewBaseInfo {
name: string;
phone?: string;
email?: string;
birth_date?: string;
address?: string;
note?: string;
}
interface CrewCreateParams extends CrewBaseInfo {
personal_id?: string;
}
interface CrewUpdateParams extends Partial<CrewBaseInfo> {
personal_id?: string;
}
}

View File

@@ -0,0 +1,8 @@
declare namespace SgwModel {
interface FishSpeciesResponse {
id: number;
name: string;
scientific_name?: string;
description?: string;
}
}

View File

@@ -0,0 +1,35 @@
declare namespace SgwModel {
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 FishingLog {
fishing_log_id?: string;
trip_id: string;
start_at: Date;
end_at: Date;
start_lat: number;
start_lon: number;
haul_lat: number;
haul_lon: number;
status: number;
weather_description: string;
info?: FishingLogInfo[];
sync: boolean;
}
interface NewFishingLogRequest {
trip_id: string;
start_at: Date;
start_lat: number;
start_lon: number;
weather_description: string;
}
}

View File

@@ -0,0 +1,6 @@
declare namespace SgwModel {
interface FishingGear {
name: string;
number: string;
}
}

View File

@@ -0,0 +1,17 @@
declare namespace SgwModel {
// interface PhotoBasicInfo {
// type: 'ship' | 'people';
// id: string;
// }
interface PhotoGetParams {
type: 'ship' | 'people';
id: string;
}
interface PhotoUploadParams {
type: 'ship' | 'people';
id: string;
file: File;
}
}

View File

@@ -0,0 +1,24 @@
declare namespace SgwModel {
interface Port {
id: number;
name: string;
type: string;
classification: string;
position_point: string;
has_origin_confirm: boolean;
province_code: string;
updated_at: string;
is_deleted: boolean;
}
interface PortQueryParams extends MasterModel.SearchPaginationBody {
order?: string;
metadata?: {
province_code?: string;
};
}
interface PortQueryResponse extends MasterModel.PaginationReponse {
ports: Port[];
}
}

View File

@@ -0,0 +1,89 @@
declare namespace SgwModel {
interface ShipBaseInfo {
name?: string;
reg_number?: string;
ship_type?: number;
ship_length?: number;
ship_power?: number;
home_port?: number;
fishing_license_number?: string;
fishing_license_expiry_date?: string;
ship_group_id?: string | null; // Lưu ý: Update có thể cần null để gỡ nhóm
}
interface ShipType {
id?: number;
name?: string;
description?: string;
}
interface ShipMetadata {
crew_count?: number;
home_port?: string;
home_port_point?: string;
ship_type?: string;
trip_arrival_port?: string;
trip_arrival_port_point?: string;
trip_arrival_time?: Date;
trip_depart_port?: string;
trip_depart_port_point?: string;
trip_departure_time?: Date;
trip_id?: string;
trip_name?: string;
trip_state?: number;
}
interface ShipDetail extends ShipBaseInfo {
id?: string;
thing_id?: string;
owner_id?: string;
imo_number?: string;
mmsi_number?: string;
province_code?: string;
created_at?: Date | string;
updated_at?: Date | string;
metadata?: ShipMetadata;
}
interface ShipCreateParams extends ShipBaseInfo {
thing_id?: string;
}
interface ShipUpdateParams {
metadata?: Record<string, unknown>;
}
interface ShipQueryParams extends MasterModel.SearchPaginationBody {
order?: string;
registration_number?: string;
ship_type?: number;
ship_group_id?: string;
thing_id?: string;
}
interface ShipQueryResponse extends MasterModel.PaginationReponse {
ships: ShipDetail[];
}
// Ship Group
interface ShipGroupBaseInfo {
name: string;
owner_id?: string;
description?: string;
}
interface ShipGroup extends ShipGroupBaseInfo {
id: string;
created_at?: Date | string;
updated_at?: Date | string;
metadata?: Record<string, unknown>;
}
interface GroupShipResponse extends ShipGroupBaseInfo {
id?: string;
}
interface ShipGroupCreateParams extends ShipGroupBaseInfo {
metadata?: Record<string, unknown>;
}
interface ShipGroupUpdateParams extends ShipGroupBaseInfo {
metadata?: Record<string, unknown>;
}
}

111
src/services/slave/sgw/typings/trip.d.ts vendored Normal file
View File

@@ -0,0 +1,111 @@
declare namespace SgwModel {
interface TripBasicInfo {
name: string;
departure_time: string;
arrival_time: string;
trip_status: number;
ship_name: string;
departure_port_id: number;
arrival_port_id: number;
fishing_ground_codes: number[];
trip_cost: TripCost[];
notes: string | null;
fishing_gears?: FishingGear[];
}
interface Trip extends TripBasicInfo {
id: string;
ship_id: string;
ship_length: number;
vms_id: string;
crews?: TripCrews[];
total_catch_weight: number | null;
total_species_caught: number | null;
trip_status: number;
approved_by: string;
fishing_logs: FishingLog[] | null;
sync: boolean;
}
interface TripQueryParams extends MasterModel.SearchPaginationBody {
order?: string;
metadata?: {
from?: string;
to?: string;
ship_name?: string;
reg_number?: string;
province_code?: string;
owner_id?: string;
ship_id?: string;
status?: string;
};
}
interface TripQueryResponse extends MasterModel.PaginationReponse {
trips: Trip[];
}
interface TripUpdateParams extends Partial<TripBasicInfo> {
crews?: TripCrews[];
}
interface TripDeleteParams {
trip_ids: string[];
}
interface TripUpdateStateRequest {
status: number;
note?: string;
}
interface TripCreateParams extends Partial<TripBasicInfo> {
crews?: TripCrews[];
}
interface TripCost {
type: string;
unit: string;
amount: string;
total_cost: string;
cost_per_unit: string;
}
// Trip Crews
interface TripCrewPerson {
personal_id: string;
name: string;
phone: string;
email: string;
birth_date: Date;
note: string;
address: string;
created_at: Date;
updated_at: Date;
}
interface TripCrews {
role: string;
joined_at: Date;
left_at: Date | null;
note: string | null;
Person: TripCrewPerson;
}
interface TripCrewBasicInfo {
personal_id: string;
role: string;
note?: string;
}
interface TripCrewCreateParams extends Partial<TripCrewBasicInfo> {
trip_id: string;
}
interface TripCrewUpdateParams extends Partial<TripCrewBasicInfo> {
trip_id: string;
}
interface TripCrewQueryResponse {
trip_crews: TripCrews[];
total?: number;
}
}

View File

@@ -0,0 +1,8 @@
declare namespace WsTypes {
interface WsThingResponse {
thing_id?: string;
key?: string;
data?: string;
time?: number;
}
}

View File

@@ -0,0 +1,38 @@
declare namespace SgwModel {
// Banzone Management
interface ZoneBasicInfo {
name?: string;
province_code?: string;
type?: number;
conditions?: Condition[];
description?: string;
geometry?: string;
enabled?: boolean;
}
interface Banzone extends ZoneBasicInfo {
id?: string;
created_at?: Date;
updated_at?: Date;
}
interface Condition {
max?: number;
min?: number;
type?: 'length_limit' | 'month_range' | 'date_range';
to?: number;
from?: number;
}
interface Geom {
geom_type?: number;
geom_poly?: string;
geom_lines?: string;
geom_point?: string;
geom_radius?: number;
}
interface ZoneResponse extends Partial<MasterModel.PaginationResponse> {
banzones?: Banzone[];
}
}

View File

@@ -2,8 +2,11 @@
// 该文件由 OneAPI 自动生成,请勿手动修改!
declare namespace SpoleModel {
interface ThingMedata extends MasterModel.ThingMetadata {}
interface ThingMetdadata extends MasterModel.ThingReponseMetadata {
uptime?: number;
}
type SpoleThingsResponse = MasterModel.ThingsResponse<SpoleModel.ThingMedata>;
type SpoleThing = MasterModel.Thing<SpoleModel.ThingMedata>;
type SpoleThingsResponse =
MasterModel.ThingsResponse<SpoleModel.ThingMetdadata>;
type SpoleThing = MasterModel.Thing<SpoleModel.ThingMetdadata>;
}