index.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. // 通用响应类型
  2. export interface ApiResponse<T = any> {
  3. success: boolean;
  4. data?: T;
  5. message?: string;
  6. error?: string;
  7. }
  8. // 分页类型
  9. export interface Pagination {
  10. page: number;
  11. pageSize: number;
  12. total: number;
  13. totalPages: number;
  14. }
  15. // 分页响应类型
  16. export interface PaginatedResponse<T = any> extends ApiResponse<T[]> {
  17. pagination: Pagination;
  18. }
  19. // 查询参数类型
  20. export interface QueryParams {
  21. page?: number;
  22. pageSize?: number;
  23. sortBy?: string;
  24. sortOrder?: 'ASC' | 'DESC';
  25. [key: string]: any;
  26. }
  27. // 启用/禁用状态枚举
  28. export enum EnableStatus {
  29. DISABLED = 0, // 禁用
  30. ENABLED = 1 // 启用
  31. }
  32. // 启用/禁用状态中文映射
  33. export const EnableStatusNameMap: Record<EnableStatus, string> = {
  34. [EnableStatus.DISABLED]: '禁用',
  35. [EnableStatus.ENABLED]: '启用'
  36. };
  37. // 删除状态枚举
  38. export enum DeleteStatus {
  39. NOT_DELETED = 0, // 未删除
  40. DELETED = 1 // 已删除
  41. }
  42. // 删除状态中文映射
  43. export const DeleteStatusNameMap: Record<DeleteStatus, string> = {
  44. [DeleteStatus.NOT_DELETED]: '未删除',
  45. [DeleteStatus.DELETED]: '已删除'
  46. };
  47. // 用户类型枚举
  48. export enum UserType {
  49. ADMIN = 'admin', // 管理员
  50. EMPLOYER = 'employer', // 企业用户
  51. TALENT = 'talent' // 人才用户
  52. }
  53. // 用户类型中文映射
  54. export const TypeNameMap: Record<UserType, string> = {
  55. [UserType.ADMIN]: '管理员',
  56. [UserType.EMPLOYER]: '企业用户',
  57. [UserType.TALENT]: '人才用户'
  58. };
  59. // 启用/禁用状态枚举(反向定义)
  60. export enum DisabledStatus {
  61. DISABLED = 1, // 禁用
  62. ENABLED = 0 // 启用
  63. }
  64. // 启用/禁用状态中文映射
  65. export const DisabledStatusNameMap: Record<DisabledStatus, string> = {
  66. [DisabledStatus.DISABLED]: '禁用',
  67. [DisabledStatus.ENABLED]: '启用'
  68. };
  69. // 认证上下文类型
  70. export interface AuthContextType<T> {
  71. user: T | null;
  72. token: string | null;
  73. login: (username: string, password: string, latitude?: number, longitude?: number) => Promise<void>;
  74. logout: () => Promise<void>;
  75. isAuthenticated: boolean;
  76. isLoading: boolean;
  77. }
  78. // 全局配置常量
  79. export interface GlobalConfig {
  80. OSS_BASE_URL: string;
  81. APP_NAME: string;
  82. }
  83. // JWT Payload 类型
  84. export interface JWTPayload {
  85. id: number;
  86. username: string;
  87. roles?: string[];
  88. openid?: string;
  89. tenantId?: number; // 租户ID,用于多租户场景
  90. personId?: number; // 关联人员ID(如残疾人ID)
  91. userType?: UserType; // 用户类型
  92. }
  93. // Hono 认证上下文类型
  94. export type AuthContext = {
  95. Variables: {
  96. user: any; // 用户类型将在具体模块中定义
  97. token: string;
  98. tenantId?: number; // 租户ID,用于多租户场景
  99. }
  100. };
  101. // 企业用户基本信息接口
  102. export interface EnterpriseUserBase {
  103. id: number;
  104. username: string;
  105. email?: string | null;
  106. phone?: string | null;
  107. realName?: string | null;
  108. status?: number;
  109. roles?: any[];
  110. companyId?: number | null;
  111. company?: {
  112. id: number;
  113. companyName: string;
  114. contactPerson?: string | null;
  115. contactPhone?: string | null;
  116. contactEmail?: string | null;
  117. address?: string | null;
  118. status: number;
  119. createTime: Date;
  120. updateTime: Date;
  121. } | null;
  122. }
  123. // 企业认证上下文类型
  124. export type EnterpriseAuthContext = {
  125. Variables: {
  126. user: EnterpriseUserBase;
  127. token: string;
  128. }
  129. };
  130. // 人才用户基本信息接口
  131. export interface TalentUserBase {
  132. id: number;
  133. username: string;
  134. userType: UserType.TALENT;
  135. personId: number | null;
  136. phone?: string | null;
  137. nickname?: string | null;
  138. name?: string | null;
  139. avatarFileId?: number | null;
  140. isDisabled?: number | null;
  141. createdAt?: Date;
  142. updatedAt?: Date;
  143. personInfo?: {
  144. id: number;
  145. name: string;
  146. gender: string;
  147. idCard: string;
  148. disabilityId: string;
  149. disabilityType: string;
  150. disabilityLevel: string;
  151. phone: string;
  152. province: string;
  153. city: string;
  154. district: string | null;
  155. detailedAddress: string | null;
  156. birthDate: Date | null;
  157. idAddress: string;
  158. idValidDate: Date | null;
  159. disabilityValidDate: Date | null;
  160. canDirectContact: number;
  161. isMarried: number | null;
  162. nation: string | null;
  163. jobStatus: number;
  164. specificDisability: string | null;
  165. isInBlackList: number;
  166. createTime: Date;
  167. updateTime: Date;
  168. } | null;
  169. }
  170. // 人才认证上下文类型
  171. export type TalentAuthContext = {
  172. Variables: {
  173. user: TalentUserBase;
  174. token: string;
  175. }
  176. };