{"_id":"@aoss-comm/service-module-common","_rev":"1-abf7688289f7dae23acfb2e34bc7cf3b","name":"@aoss-comm/service-module-common","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@aoss-comm/service-module-common","version":"0.0.1","_id":"@aoss-comm/service-module-common@0.0.1","maintainers":[{"name":"henry.feng","email":"huili.feng@outlook.com"}],"dist":{"shasum":"886ed682d098ea372bffc6508d9104802899ea4d","tarball":"https://registry.npmjs.org/@aoss-comm/service-module-common/-/service-module-common-0.0.1.tgz","fileCount":62,"integrity":"sha512-SVyTQXw7H5DjEVcIXmngxICl9RkyX4qtxWgzxEXTZ2AYpGpHg4GAIDzUdHRqII/v28mPqH/j9BejjoeTDBVv/w==","signatures":[{"sig":"MEQCIGH47/IOevtoY9ynPPkYNMdBG+2xmRiWDFnPg+Z+mblpAiB6YuIhWV0T0vbUcJTlfHRzZiM2tiqEgrvPa/QdpsJseA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":51412},"gitHead":"d360f4f877c2f5db806240f5d96a385a5804101c","private":false,"scripts":{"build":"tsc","clean":"rm -rf ./package","package":"npm run clean && npm run build && cp ./package.json ./package/ && cp README.md ./package/","public-publish":"npm run package  && cd ./package && npm publish  --access public"},"_npmUser":{"name":"henry.feng","email":"huili.feng@outlook.com"},"_npmVersion":"10.8.2","description":"AOSS 共享基础类","directories":{},"_nodeVersion":"20.18.1","dependencies":{"md5":"^2.3.0","express":"^4.21.1","@ticatec/bean-validator":"^0.0.1","@ticatec/singleton-log4js":"^0.0.5","@ticatec/express-exception":"^1.1.1","@ticatec/node-common-library":"^2.0.18"},"_hasShrinkwrap":false,"devDependencies":{"@types/md5":"^2.3.5","typescript":"^5.7.2","@types/node":"^20.11.30","@types/express":"^4.17.21","@ticatec/redis-client":"^0.0.6"},"peerDependencies":{"@ticatec/node-common-library":"^2.0.18"},"_npmOperationalInternal":{"tmp":"tmp/service-module-common_0.0.1_1736107764373_0.35871158082357146","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@aoss-comm/service-module-common","version":"0.0.2","private":false,"description":"AOSS 共享基础类","scripts":{"build":"tsc","clean":"rm -rf ./package","package":"npm run clean && npm run build && cp ./package.json ./package/ && cp README.md ./package/","public-publish":"npm run package  && cd ./package && npm publish  --access public"},"devDependencies":{"@ticatec/redis-client":"^0.0.6","@types/express":"^4.17.21","@types/md5":"^2.3.5","@types/node":"^20.11.30","typescript":"^5.7.2"},"dependencies":{"@ticatec/bean-validator":"^0.0.1","@ticatec/express-exception":"^1.1.1","@ticatec/singleton-log4js":"^0.0.5","@ticatec/node-common-library":"^2.0.18","express":"^4.21.1","md5":"^2.3.0"},"peerDependencies":{"@ticatec/node-common-library":"^2.0.18"},"_id":"@aoss-comm/service-module-common@0.0.2","gitHead":"77bdd89371acc74f7927762e9b7816875c10ad32","_nodeVersion":"20.18.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-NPYDJk08lLoL+Fck7KVlUbNtrnEoFMLFKk6DJE6kZVnGkIrzJceqyIX48YEYvfu2nvqrOkbJWQMFCKFDu7ar/A==","shasum":"c6d906c32223ee4dd3b0ddc69022ee7330d3a02a","tarball":"https://registry.npmjs.org/@aoss-comm/service-module-common/-/service-module-common-0.0.2.tgz","fileCount":68,"unpackedSize":59339,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDxycr6mQOB783rh8nZV5rrx5pyaDOdgx+LXBwXAEjC7gIgGw6vT/wedCOiImAjdMKg+g0Zo6uiDcih351MgWy6QsE="}]},"_npmUser":{"name":"henry.feng","email":"huili.feng@outlook.com"},"directories":{},"maintainers":[{"name":"henry.feng","email":"huili.feng@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/service-module-common_0.0.2_1736115139114_0.7347386248592127"},"_hasShrinkwrap":false}},"time":{"created":"2025-01-05T20:09:24.286Z","modified":"2025-01-05T22:12:19.491Z","0.0.1":"2025-01-05T20:09:24.576Z","0.0.2":"2025-01-05T22:12:19.291Z"},"description":"AOSS 共享基础类","maintainers":[{"name":"henry.feng","email":"huili.feng@outlook.com"}],"readme":"# Core Modules\n\nThis is the foundational library of the entire application support system. It serves as the base common library to avoid version conflicts by including `@ticatec/node-common-library` via `peerDependencies`.\n\n## Installation\n\n```shell\nnpm i @aoss-comm/service-module-common\n```\n\n## Entity Class `CommonUser`\n\nThe `CommonUser` interface represents a generic user object that includes essential user details such as ID, code, name, department, and tenant.\n\n### Property Details\n\n| Property   | Type   | Description                                                                                        |\n|--------|--------|----------------------------------------------------------------------------------------------------|\n| `id`   | string | Unique identifier for the user                                                                     |\n| `code` | string | Code representing the user                                                                         |\n| `name` | string | User’s name                                                                                        |\n| `dept` | object | User’s department information:<br> `id: string` - Department ID<br>`name: string`- Department name |\n| `tenant` | object | User’s tenant information:code：<br>`code: string` - Tenant code<br>`name: string` - Tenant name    |\n\n\n## Entity Class `LoggedUser`\n\n\nThe `LoggedUser` interface extends `CommonUser`, representing the currently logged-in user. It adds an optional property `actAs` for scenarios where the user operates as another user.\n\n### Property Details\n\n| Property     | Type       | Description             |\n|----------|------------|------------------|\n| `actAs`  | CommonUser | (Optional) Represents the user being impersonated |\n\n---\n\n## `Controller` Abstract Controller Classes\n\nThis set of controller classes provides an abstract implementation for service-layer-based controllers, mainly used for managing entities (create, update, delete) and performing queries. The classes have an inheritance hierarchy, and developers can override or extend methods to implement specific business logic.\n\n---\n\n### 1. BaseController\n\n#### Features\n`BaseController` is the base class for all controllers, responsible for initializing the service and logging functionalities.\n\n#### Properties\n| Property         | Type | Description                       |\n|--------------|------|----------------------------|\n| `service`    | T    | Injected service instance             |\n| `logger`     | any  | Logger, based on log4js  |\n\n#### Constructor\n| Parameter      | Type | Description             |\n|-----------|------|------------------|\n| `service` | T    | Injected service instance   |\n\n---\n\n### 2. CommonController\n\n#### Features\n\n`CommonController` extends `BaseController`, adding entity validation and implementing basic CRUD operation interfaces.\n\n#### New Properties\n| Property    | Type              | Description             |\n|---------|-------------------|------------------|\n| `rules` | `ValidationRules` | Validation rules for entities, optional|\n\n#### Methods\n\n| Method Name                   | Return Type             | Description                                   |\n|--------------------------|----------------------|----------------------------------------|\n| `validateEntity(data)`   | void                | Validates entity data against rules               |\n| `createNew()`            | `RestfulFunction`   | Provides an interface for creating entities                |\n| `update()`               | `RestfulFunction`   | Provides an interface for updating entities                |\n| `del()`                  | `RestfulFunction`   | Provides an interface for deleting entities  |\n| `checkInterface(name)`   | void                | Verifies the existence of a service interface                  |\n| `invokeServiceInterface(name, args)` | Promise<any> | Calls a service interface method                 |\n| `_createNew(req)`        | Promise<any>        | Implements the logic for creating entities                |\n| `_update(req)`           | Promise<any>        | Implements the logic for updating entities                |\n| `_del(req)`              | Promise<any>        | Implements the logic for deleting entities (requires subclass implementation)              |\n| `getCreateNewArguments(req)` | `Array<any>`     | Abstract method, must be implemented by subclass to extract arguments for creation   |\n| `getUpdateArguments(req)` | `Array<any>`       | Abstract method, must be implemented by subclass to extract arguments for update   |\n\n---\n\n### 3. AdminBaseController\n\n#### Features\n`AdminBaseController` is a foundational class for platform management controllers unrelated to tenants. It provides default logic for extracting arguments for creating and updating entities.\n\n#### Methods\n| Method Name                   | Return Type         | Description                     |\n|--------------------------|------------------|--------------------------|\n| `getCreateNewArguments(req)` | `Array<any>` | Default implementation extracts creation arguments from the request body |\n| `getUpdateArguments(req)`    | `Array<any>` | Default implementation extracts update arguments from the request body |\n\n---\n\n### 4. AdminSearchController\n\n#### Features\n`AdminSearchController` extends `AdminBaseController`, adding functionality for conditional queries.\n\n#### Methods\n| Method Name                   | Return Type         | Description                     |\n|-------------|------------------|------------------------|\n| `search()`  | `(req) => any`   | Provides an interface for querying entities |\n\n---\n\n### 5. TenantBaseController\n\n#### Features\n`TenantBaseController`  is designed for managing tenant-related entities. It provides default logic for extracting arguments for creating and updating entities and supports scenarios where the user operates as another user.\n\n#### Methods\n| Method Name                   | Return Type         | Description                     |\n|--------------------------|------------------|--------------------------|\n| `getLoggedUser(req)`          | `CommonUser`    | Retrieves the current user, including impersonated users     |\n| `getCreateNewArguments(req)` | `Array<any>` | Extracts creation arguments, including the logged-in user |\n| `getUpdateArguments(req)`    | `Array<any>` | Extracts update arguments, including the logged-in user |\n\n---\n\n### 6. TenantSearchController\n\n#### Features\n`TenantSearchController` extends `TenantBaseController`, adding functionality for tenant-related conditional queries.\n\n#### Methods\n| Method Name                   | Return Type         | Description                     |\n|-------------|------------------|------------------------|\n| `search()`  | `(req) => any`   | Provides an interface for querying entities |\n\n---","readmeFilename":"README.md"}