Ver Fonte

feat: 新增 product、dept、perm 三个模块的服务层

新增 product/dept/perm 服务的 typings.d.ts 和 index.ts,
复用已有 API.Result / API.SvrResultList 全局类型,所有接口统一使用 POST 方法。

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
BaiLuoYan há 3 dias atrás
pai
commit
4c8e78346a

+ 17 - 0
src/services/dept/index.ts

@@ -0,0 +1,17 @@
+import { request } from '@umijs/max';
+
+export async function fetchDeptTree() {
+  return request<API.DeptTreeResult>('/dept/tree', { method: 'POST' });
+}
+
+export async function fetchCreateDept(body: API.CreateDeptReq) {
+  return request<API.DeptCreateResult>('/dept/create', { method: 'POST', data: body });
+}
+
+export async function fetchUpdateDept(body: API.UpdateDeptReq) {
+  return request<API.Result>('/dept/update', { method: 'POST', data: body });
+}
+
+export async function fetchDeleteDept(body: { id: number }) {
+  return request<API.Result>('/dept/delete', { method: 'POST', data: body });
+}

+ 34 - 0
src/services/dept/typings.d.ts

@@ -0,0 +1,34 @@
+declare namespace API {
+  interface DeptItem {
+    id: number;
+    parentId: number;
+    name: string;
+    path: string;
+    sort: number;
+    deptType: string;
+    remark: string;
+    status: number;
+    createTime: number;
+    children?: DeptItem[];
+  }
+
+  interface CreateDeptReq {
+    parentId: number;
+    name: string;
+    sort?: number;
+    deptType?: string;
+    remark?: string;
+  }
+
+  interface UpdateDeptReq {
+    id: number;
+    name: string;
+    sort?: number;
+    deptType?: string;
+    remark?: string;
+    status?: number;
+  }
+
+  type DeptTreeResult = Result<DeptItem[]>;
+  type DeptCreateResult = Result<{ id: number }>;
+}

+ 5 - 0
src/services/perm/index.ts

@@ -0,0 +1,5 @@
+import { request } from '@umijs/max';
+
+export async function fetchPermList(body: API.PermListReq) {
+  return request<API.PermListResult>('/perm/list', { method: 'POST', data: body });
+}

+ 19 - 0
src/services/perm/typings.d.ts

@@ -0,0 +1,19 @@
+declare namespace API {
+  interface PermItem {
+    id: number;
+    productCode: string;
+    name: string;
+    code: string;
+    remark: string;
+    status: number;
+    createTime: number;
+  }
+
+  interface PermListReq {
+    productCode: string;
+    page?: number;
+    pageSize?: number;
+  }
+
+  type PermListResult = SvrResultList<PermItem>;
+}

+ 24 - 0
src/services/product/index.ts

@@ -0,0 +1,24 @@
+import { request } from '@umijs/max';
+
+export async function fetchCreateProduct(body: API.CreateProductReq) {
+  return request<API.CreateProductResult>('/product/create', { method: 'POST', data: body });
+}
+
+export async function fetchInitialCredentials(body: { ticket: string }) {
+  return request<API.FetchCredentialsResult>('/product/fetchInitialCredentials', {
+    method: 'POST',
+    data: body,
+  });
+}
+
+export async function fetchUpdateProduct(body: API.UpdateProductReq) {
+  return request<API.Result>('/product/update', { method: 'POST', data: body });
+}
+
+export async function fetchProductList(body: API.ProductListReq) {
+  return request<API.ProductListResult>('/product/list', { method: 'POST', data: body });
+}
+
+export async function fetchProductDetail(body: { id: number }) {
+  return request<API.ProductDetailResult>('/product/detail', { method: 'POST', data: body });
+}

+ 51 - 0
src/services/product/typings.d.ts

@@ -0,0 +1,51 @@
+declare namespace API {
+  interface ProductItem {
+    id: number;
+    code: string;
+    name: string;
+    appKey: string;
+    remark: string;
+    status: number;
+    createTime: number;
+  }
+
+  interface CreateProductReq {
+    code: string;
+    name: string;
+    adminDeptId: number;
+    remark?: string;
+  }
+
+  interface CreateProductResp {
+    id: number;
+    code: string;
+    appKey: string;
+    adminUser: string;
+    credentialsTicket: string;
+    credentialsExpiresAt: number;
+  }
+
+  interface FetchInitialCredentialsResp {
+    appKey: string;
+    appSecret: string;
+    adminUser: string;
+    adminPassword: string;
+  }
+
+  interface UpdateProductReq {
+    id: number;
+    name: string;
+    remark?: string;
+    status?: number;
+  }
+
+  interface ProductListReq {
+    page?: number;
+    pageSize?: number;
+  }
+
+  type CreateProductResult = Result<CreateProductResp>;
+  type FetchCredentialsResult = Result<FetchInitialCredentialsResp>;
+  type ProductDetailResult = Result<ProductItem>;
+  type ProductListResult = SvrResultList<ProductItem>;
+}