首次提交
This commit is contained in:
56
.gitignore
vendored
Normal file
56
.gitignore
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# compiled output
|
||||||
|
/dist
|
||||||
|
/node_modules
|
||||||
|
/build
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Tests
|
||||||
|
/coverage
|
||||||
|
/.nyc_output
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
/.idea
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.c9/
|
||||||
|
*.launch
|
||||||
|
.settings/
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# IDE - VSCode
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
|
||||||
|
# dotenv environment variable files
|
||||||
|
.env
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
.env.local
|
||||||
|
|
||||||
|
# temp directory
|
||||||
|
.temp
|
||||||
|
.tmp
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
4
.prettierrc
Normal file
4
.prettierrc
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "all"
|
||||||
|
}
|
||||||
98
README.md
Normal file
98
README.md
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
<p align="center">
|
||||||
|
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||||
|
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||||
|
|
||||||
|
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
||||||
|
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
||||||
|
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||||
|
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||||
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||||
|
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
|
||||||
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
||||||
|
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
|
||||||
|
</p>
|
||||||
|
<!--[](https://opencollective.com/nest#backer)
|
||||||
|
[](https://opencollective.com/nest#sponsor)-->
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
||||||
|
|
||||||
|
## Project setup
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Compile and run the project
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# development
|
||||||
|
$ npm run start
|
||||||
|
|
||||||
|
# watch mode
|
||||||
|
$ npm run start:dev
|
||||||
|
|
||||||
|
# production mode
|
||||||
|
$ npm run start:prod
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# unit tests
|
||||||
|
$ npm run test
|
||||||
|
|
||||||
|
# e2e tests
|
||||||
|
$ npm run test:e2e
|
||||||
|
|
||||||
|
# test coverage
|
||||||
|
$ npm run test:cov
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information.
|
||||||
|
|
||||||
|
If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install -g @nestjs/mau
|
||||||
|
$ mau deploy
|
||||||
|
```
|
||||||
|
|
||||||
|
With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
|
||||||
|
|
||||||
|
## Resources
|
||||||
|
|
||||||
|
Check out a few resources that may come in handy when working with NestJS:
|
||||||
|
|
||||||
|
- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
|
||||||
|
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
|
||||||
|
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
|
||||||
|
- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
|
||||||
|
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
|
||||||
|
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
|
||||||
|
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
|
||||||
|
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
||||||
|
|
||||||
|
## Stay in touch
|
||||||
|
|
||||||
|
- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
|
||||||
|
- Website - [https://nestjs.com](https://nestjs.com/)
|
||||||
|
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).
|
||||||
34
eslint.config.mjs
Normal file
34
eslint.config.mjs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
// @ts-check
|
||||||
|
import eslint from '@eslint/js';
|
||||||
|
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
||||||
|
import globals from 'globals';
|
||||||
|
import tseslint from 'typescript-eslint';
|
||||||
|
|
||||||
|
export default tseslint.config(
|
||||||
|
{
|
||||||
|
ignores: ['eslint.config.mjs'],
|
||||||
|
},
|
||||||
|
eslint.configs.recommended,
|
||||||
|
...tseslint.configs.recommendedTypeChecked,
|
||||||
|
eslintPluginPrettierRecommended,
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.node,
|
||||||
|
...globals.jest,
|
||||||
|
},
|
||||||
|
sourceType: 'commonjs',
|
||||||
|
parserOptions: {
|
||||||
|
projectService: false,
|
||||||
|
tsconfigRootDir: import.meta.dirname,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
'@typescript-eslint/no-floating-promises': 'warn',
|
||||||
|
'@typescript-eslint/no-unsafe-argument': 'warn'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
8
nest-cli.json
Normal file
8
nest-cli.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/nest-cli",
|
||||||
|
"collection": "@nestjs/schematics",
|
||||||
|
"sourceRoot": "src",
|
||||||
|
"compilerOptions": {
|
||||||
|
"deleteOutDir": true
|
||||||
|
}
|
||||||
|
}
|
||||||
10367
package-lock.json
generated
Normal file
10367
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
80
package.json
Normal file
80
package.json
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
{
|
||||||
|
"name": "program_back",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "",
|
||||||
|
"author": "",
|
||||||
|
"private": true,
|
||||||
|
"license": "UNLICENSED",
|
||||||
|
"scripts": {
|
||||||
|
"build": "nest build",
|
||||||
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||||
|
"start": "nest start",
|
||||||
|
"start:dev": "nest start --watch",
|
||||||
|
"start:debug": "nest start --debug --watch",
|
||||||
|
"start:prod": "node dist/main",
|
||||||
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||||
|
"test": "jest",
|
||||||
|
"test:watch": "jest --watch",
|
||||||
|
"test:cov": "jest --coverage",
|
||||||
|
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||||
|
"test:e2e": "jest --config ./test/jest-e2e.json",
|
||||||
|
"generator:db": "typeorm-model-generator -h 192.168.0.4 -d test -p 3306 -u test -x n6M2XrssM2YpM5Mi -e mysql -o ./src/generator_entity"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@nestjs/common": "^11.0.1",
|
||||||
|
"@nestjs/core": "^11.0.1",
|
||||||
|
"@nestjs/platform-express": "^11.0.1",
|
||||||
|
"@nestjs/platform-socket.io": "^11.1.6",
|
||||||
|
"@nestjs/typeorm": "^11.0.0",
|
||||||
|
"@nestjs/websockets": "^11.1.6",
|
||||||
|
"cors": "^2.8.5",
|
||||||
|
"mysql2": "^3.15.0",
|
||||||
|
"reflect-metadata": "^0.2.2",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
|
"socket.io": "^4.8.1",
|
||||||
|
"typeorm": "^0.3.27"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@eslint/eslintrc": "^3.2.0",
|
||||||
|
"@eslint/js": "^9.18.0",
|
||||||
|
"@nestjs/cli": "^11.0.0",
|
||||||
|
"@nestjs/schematics": "^11.0.0",
|
||||||
|
"@nestjs/testing": "^11.0.1",
|
||||||
|
"@types/cors": "^2.8.19",
|
||||||
|
"@types/express": "^5.0.0",
|
||||||
|
"@types/jest": "^30.0.0",
|
||||||
|
"@types/node": "^22.10.7",
|
||||||
|
"@types/supertest": "^6.0.2",
|
||||||
|
"eslint": "^9.18.0",
|
||||||
|
"eslint-config-prettier": "^10.0.1",
|
||||||
|
"eslint-plugin-prettier": "^5.2.2",
|
||||||
|
"globals": "^16.0.0",
|
||||||
|
"jest": "^30.0.0",
|
||||||
|
"prettier": "^3.4.2",
|
||||||
|
"source-map-support": "^0.5.21",
|
||||||
|
"supertest": "^7.0.0",
|
||||||
|
"ts-jest": "^29.2.5",
|
||||||
|
"ts-loader": "^9.5.2",
|
||||||
|
"ts-node": "^10.9.2",
|
||||||
|
"tsconfig-paths": "^4.2.0",
|
||||||
|
"typescript": "^5.7.3",
|
||||||
|
"typescript-eslint": "^8.20.0"
|
||||||
|
},
|
||||||
|
"jest": {
|
||||||
|
"moduleFileExtensions": [
|
||||||
|
"js",
|
||||||
|
"json",
|
||||||
|
"ts"
|
||||||
|
],
|
||||||
|
"rootDir": "src",
|
||||||
|
"testRegex": ".*\\.spec\\.ts$",
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.(t|j)s$": "ts-jest"
|
||||||
|
},
|
||||||
|
"collectCoverageFrom": [
|
||||||
|
"**/*.(t|j)s"
|
||||||
|
],
|
||||||
|
"coverageDirectory": "../coverage",
|
||||||
|
"testEnvironment": "node"
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/app.module.ts
Normal file
25
src/app.module.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import {Module} from '@nestjs/common';
|
||||||
|
import * as controller from './controller'
|
||||||
|
import * as service from './service'
|
||||||
|
import {TypeOrmModule} from "@nestjs/typeorm";
|
||||||
|
import * as entity from './entity'
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
TypeOrmModule.forRoot({
|
||||||
|
type: 'mysql',
|
||||||
|
host: '192.168.0.4',
|
||||||
|
port: 3306,
|
||||||
|
username: 'test',
|
||||||
|
password: 'n6M2XrssM2YpM5Mi',
|
||||||
|
database: 'test',
|
||||||
|
synchronize: false,
|
||||||
|
entities: Object.values(entity),
|
||||||
|
}),
|
||||||
|
TypeOrmModule.forFeature(Object.values(entity))
|
||||||
|
],
|
||||||
|
controllers: Object.values(controller),
|
||||||
|
providers: Object.values(service),
|
||||||
|
})
|
||||||
|
export class AppModule {
|
||||||
|
}
|
||||||
21
src/const/result.ts
Normal file
21
src/const/result.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { HttpStatus } from '@nestjs/common';
|
||||||
|
|
||||||
|
export class ResultData {
|
||||||
|
constructor(
|
||||||
|
public code = HttpStatus.OK,
|
||||||
|
public msg?: string,
|
||||||
|
public data?: any,
|
||||||
|
) {
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg || '操作成功';
|
||||||
|
this.data = data || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static success(data?: any, msg?: string) {
|
||||||
|
return new ResultData(HttpStatus.OK, msg, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static fail(code = HttpStatus.BAD_REQUEST, msg?: string, data?: any) {
|
||||||
|
return new ResultData(code, msg, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/controller/index.ts
Normal file
1
src/controller/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './programGroup.controller';
|
||||||
24
src/controller/programGroup.controller.ts
Normal file
24
src/controller/programGroup.controller.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import {Body, Controller, Delete, Get, Param, Patch, Post, Query} from '@nestjs/common';
|
||||||
|
import {ProgramGroupEntity} from "../entity";
|
||||||
|
import {ProgramGroupService} from "../service";
|
||||||
|
|
||||||
|
@Controller('group')
|
||||||
|
export class ProgramGroupController {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private programGroupService: ProgramGroupService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/** 创建群组 */
|
||||||
|
@Post()
|
||||||
|
async add(@Body() programGroup: ProgramGroupEntity) {
|
||||||
|
return await this.programGroupService.add(programGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看群聊列表 */
|
||||||
|
@Get("list")
|
||||||
|
async getList(@Query() programGroup: ProgramGroupEntity) {
|
||||||
|
return await this.programGroupService.getList(programGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
4
src/entity/index.ts
Normal file
4
src/entity/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export * from './program.entity';
|
||||||
|
export * from './users.entity';
|
||||||
|
export * from './programGroup.entity';
|
||||||
|
export * from './programGroupMessage.entity';
|
||||||
74
src/entity/program.entity.ts
Normal file
74
src/entity/program.entity.ts
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
import {Column, Entity, ManyToOne, PrimaryGeneratedColumn} from "typeorm";
|
||||||
|
|
||||||
|
@Entity("program", {schema: "test"})
|
||||||
|
export class ProgramEntity {
|
||||||
|
@PrimaryGeneratedColumn({type: "int", name: "id", comment: "项目id"})
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("varchar", {name: "name", comment: "项目名称", length: 255})
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "linkman_id",
|
||||||
|
comment: "联系人userid",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
linkmanId: number;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "company",
|
||||||
|
nullable: true,
|
||||||
|
comment: "公司名称",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
company: string | null;
|
||||||
|
|
||||||
|
@Column("text", {name: "introduction", nullable: true, comment: "简介"})
|
||||||
|
introduction: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "address",
|
||||||
|
nullable: true,
|
||||||
|
comment: "项目地点",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
address: string | null;
|
||||||
|
|
||||||
|
@Column("datetime", {
|
||||||
|
name: "start_date",
|
||||||
|
nullable: true,
|
||||||
|
comment: "开始时间",
|
||||||
|
})
|
||||||
|
startDate: Date | null;
|
||||||
|
|
||||||
|
@Column("datetime", {name: "end_date", nullable: true, comment: "结束时间"})
|
||||||
|
endDate: Date | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "payment_method",
|
||||||
|
nullable: true,
|
||||||
|
comment: "结算方式?",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
paymentMethod: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "remark",
|
||||||
|
nullable: true,
|
||||||
|
comment: "其他",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
remark: string | null;
|
||||||
|
|
||||||
|
@Column("datetime", {
|
||||||
|
name: "create_date",
|
||||||
|
nullable: true,
|
||||||
|
comment: "发布时间",
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createDate: Date | null;
|
||||||
|
|
||||||
|
|
||||||
|
page: number = 1;
|
||||||
|
size: number = 10;
|
||||||
|
}
|
||||||
32
src/entity/programGroup.entity.ts
Normal file
32
src/entity/programGroup.entity.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import {ProgramEntity} from "./program.entity";
|
||||||
|
|
||||||
|
@Entity("program_group", { schema: "test" })
|
||||||
|
export class ProgramGroupEntity {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "group_id", comment: "群组ID" })
|
||||||
|
groupId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "program_id", comment: "项目ID" })
|
||||||
|
programId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "charge_id", comment: "负责人ID" })
|
||||||
|
chargeId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "customer_id", comment: "客服ID" })
|
||||||
|
customerId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "user_id", comment: "用户ID" })
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column("datetime", {
|
||||||
|
name: "create_time",
|
||||||
|
comment: "创建时间",
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createTime: Date;
|
||||||
|
|
||||||
|
program: ProgramEntity;
|
||||||
|
|
||||||
|
page: number = 1;
|
||||||
|
size: number = 10;
|
||||||
|
}
|
||||||
41
src/entity/programGroupMessage.entity.ts
Normal file
41
src/entity/programGroupMessage.entity.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import {Column, Entity, PrimaryGeneratedColumn} from "typeorm";
|
||||||
|
import {UsersEntity} from "./users.entity";
|
||||||
|
|
||||||
|
@Entity("program_group_message", {schema: "test"})
|
||||||
|
export class ProgramGroupMessageEntity {
|
||||||
|
@PrimaryGeneratedColumn({
|
||||||
|
type: "int",
|
||||||
|
name: "message_id",
|
||||||
|
comment: "消息ID",
|
||||||
|
})
|
||||||
|
messageId: number;
|
||||||
|
|
||||||
|
@Column("int", {name: "create_id", comment: "发送人ID"})
|
||||||
|
createId: number;
|
||||||
|
|
||||||
|
@Column("int", {name: "group_id", comment: "群聊ID"})
|
||||||
|
groupId: number;
|
||||||
|
|
||||||
|
@Column("text", {name: "content", comment: "内容"})
|
||||||
|
content: string;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "type",
|
||||||
|
comment: "消息类型",
|
||||||
|
enum: ["text", "img", "mp3"],
|
||||||
|
default: () => "'text'",
|
||||||
|
})
|
||||||
|
type: "text" | "img" | "mp3";
|
||||||
|
|
||||||
|
@Column("datetime", {
|
||||||
|
name: "create_time",
|
||||||
|
comment: "发送时间",
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createTime: Date;
|
||||||
|
|
||||||
|
width?: number;
|
||||||
|
height?: number;
|
||||||
|
|
||||||
|
userInfo: UsersEntity | null;
|
||||||
|
}
|
||||||
35
src/entity/users.entity.ts
Normal file
35
src/entity/users.entity.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import {Column, Entity, ManyToOne, PrimaryGeneratedColumn} from "typeorm";
|
||||||
|
import {ProgramGroup} from "../generator_entity/entities/ProgramGroup";
|
||||||
|
|
||||||
|
@Entity("users", {schema: "test"})
|
||||||
|
export class UsersEntity {
|
||||||
|
|
||||||
|
@PrimaryGeneratedColumn({type: "int", name: "id", comment: "id"})
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("varchar", {name: "username", comment: "用户名", length: 50})
|
||||||
|
username: string;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "user_type",
|
||||||
|
nullable: true,
|
||||||
|
comment: "用户类型",
|
||||||
|
enum: ["user", "directly_operated", "agent", "agent_directly"],
|
||||||
|
default: () => "'user'",
|
||||||
|
})
|
||||||
|
userType: "user" | "directly_operated" | "agent" | "agent_directly" | "customer" | null;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_system_account",
|
||||||
|
nullable: true,
|
||||||
|
width: 1,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
isSystemAccount: boolean | null;
|
||||||
|
|
||||||
|
|
||||||
|
@Column("varchar", { name: "avatar", nullable: true, length: 255 })
|
||||||
|
avatar: string | null;
|
||||||
|
|
||||||
|
groups: [ProgramGroup]
|
||||||
|
}
|
||||||
59
src/generator_entity/entities/AddressLabels.ts
Normal file
59
src/generator_entity/entities/AddressLabels.ts
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
|
||||||
|
@Index("unique_user_label", ["userId", "name"], { unique: true })
|
||||||
|
@Entity("address_labels", { schema: "test" })
|
||||||
|
export class AddressLabels {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "user_id", nullable: true })
|
||||||
|
userId: number | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "name", length: 50 })
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_system",
|
||||||
|
nullable: true,
|
||||||
|
width: 1,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
isSystem: boolean | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "color",
|
||||||
|
nullable: true,
|
||||||
|
length: 20,
|
||||||
|
default: () => "'#1890ff'",
|
||||||
|
})
|
||||||
|
color: string | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.addressLabels, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "user_id", referencedColumnName: "id" }])
|
||||||
|
user: Users;
|
||||||
|
}
|
||||||
45
src/generator_entity/entities/AdminOperationLogs.ts
Normal file
45
src/generator_entity/entities/AdminOperationLogs.ts
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
|
||||||
|
@Index("admin_id", ["adminId"], {})
|
||||||
|
@Entity("admin_operation_logs", { schema: "test" })
|
||||||
|
export class AdminOperationLogs {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "admin_id" })
|
||||||
|
adminId: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "operation_type", length: 50 })
|
||||||
|
operationType: string;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "target_type", length: 50 })
|
||||||
|
targetType: string;
|
||||||
|
|
||||||
|
@Column("int", { name: "target_id" })
|
||||||
|
targetId: number;
|
||||||
|
|
||||||
|
@Column("text", { name: "description", nullable: true })
|
||||||
|
description: string | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.adminOperationLogs, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "admin_id", referencedColumnName: "id" }])
|
||||||
|
admin: Users;
|
||||||
|
}
|
||||||
73
src/generator_entity/entities/AgentCommissionRecords.ts
Normal file
73
src/generator_entity/entities/AgentCommissionRecords.ts
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { RegionalAgents } from "./RegionalAgents";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
import { MatchingOrders } from "./MatchingOrders";
|
||||||
|
|
||||||
|
@Index("agent_id", ["agentId"], {})
|
||||||
|
@Index("merchant_id", ["merchantId"], {})
|
||||||
|
@Index("order_id", ["orderId"], {})
|
||||||
|
@Entity("agent_commission_records", { schema: "test" })
|
||||||
|
export class AgentCommissionRecords {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "agent_id" })
|
||||||
|
agentId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "merchant_id" })
|
||||||
|
merchantId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "order_id", nullable: true })
|
||||||
|
orderId: number | null;
|
||||||
|
|
||||||
|
@Column("decimal", { name: "commission_amount", precision: 10, scale: 2 })
|
||||||
|
commissionAmount: string;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "commission_type",
|
||||||
|
nullable: true,
|
||||||
|
enum: ["registration", "matching"],
|
||||||
|
default: () => "'matching'",
|
||||||
|
})
|
||||||
|
commissionType: "registration" | "matching" | null;
|
||||||
|
|
||||||
|
@Column("text", { name: "description", nullable: true })
|
||||||
|
description: string | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(
|
||||||
|
() => RegionalAgents,
|
||||||
|
(regionalAgents) => regionalAgents.agentCommissionRecords,
|
||||||
|
{ onDelete: "CASCADE", onUpdate: "RESTRICT" }
|
||||||
|
)
|
||||||
|
@JoinColumn([{ name: "agent_id", referencedColumnName: "id" }])
|
||||||
|
agent: RegionalAgents;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.agentCommissionRecords, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "merchant_id", referencedColumnName: "id" }])
|
||||||
|
merchant: Users;
|
||||||
|
|
||||||
|
@ManyToOne(
|
||||||
|
() => MatchingOrders,
|
||||||
|
(matchingOrders) => matchingOrders.agentCommissionRecords,
|
||||||
|
{ onDelete: "SET NULL", onUpdate: "RESTRICT" }
|
||||||
|
)
|
||||||
|
@JoinColumn([{ name: "order_id", referencedColumnName: "id" }])
|
||||||
|
order: MatchingOrders;
|
||||||
|
}
|
||||||
93
src/generator_entity/entities/AgentMerchants.ts
Normal file
93
src/generator_entity/entities/AgentMerchants.ts
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { RegionalAgents } from "./RegionalAgents";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
import { RegistrationCodes } from "./RegistrationCodes";
|
||||||
|
|
||||||
|
@Index("merchant_id", ["merchantId"], {})
|
||||||
|
@Index("registration_code_id", ["registrationCodeId"], {})
|
||||||
|
@Index("unique_agent_merchant", ["agentId", "merchantId"], { unique: true })
|
||||||
|
@Entity("agent_merchants", { schema: "test" })
|
||||||
|
export class AgentMerchants {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "agent_id" })
|
||||||
|
agentId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "merchant_id" })
|
||||||
|
merchantId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "registration_code_id", nullable: true })
|
||||||
|
registrationCodeId: number | null;
|
||||||
|
|
||||||
|
@Column("int", {
|
||||||
|
name: "matching_count",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
matchingCount: number | null;
|
||||||
|
|
||||||
|
@Column("decimal", {
|
||||||
|
name: "commission_earned",
|
||||||
|
nullable: true,
|
||||||
|
precision: 10,
|
||||||
|
scale: 2,
|
||||||
|
default: () => "'0.00'",
|
||||||
|
})
|
||||||
|
commissionEarned: string | null;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_qualified",
|
||||||
|
nullable: true,
|
||||||
|
width: 1,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
isQualified: boolean | null;
|
||||||
|
|
||||||
|
@Column("timestamp", { name: "qualified_at", nullable: true })
|
||||||
|
qualifiedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(
|
||||||
|
() => RegionalAgents,
|
||||||
|
(regionalAgents) => regionalAgents.agentMerchants,
|
||||||
|
{ onDelete: "CASCADE", onUpdate: "RESTRICT" }
|
||||||
|
)
|
||||||
|
@JoinColumn([{ name: "agent_id", referencedColumnName: "id" }])
|
||||||
|
agent: RegionalAgents;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.agentMerchants, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "merchant_id", referencedColumnName: "id" }])
|
||||||
|
merchant: Users;
|
||||||
|
|
||||||
|
@ManyToOne(
|
||||||
|
() => RegistrationCodes,
|
||||||
|
(registrationCodes) => registrationCodes.agentMerchants,
|
||||||
|
{ onDelete: "SET NULL", onUpdate: "RESTRICT" }
|
||||||
|
)
|
||||||
|
@JoinColumn([{ name: "registration_code_id", referencedColumnName: "id" }])
|
||||||
|
registrationCode: RegistrationCodes;
|
||||||
|
}
|
||||||
122
src/generator_entity/entities/AgentWithdrawals.ts
Normal file
122
src/generator_entity/entities/AgentWithdrawals.ts
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { RegionalAgents } from "./RegionalAgents";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
|
||||||
|
@Index("agent_id", ["agentId"], {})
|
||||||
|
@Index("processed_by", ["processedBy"], {})
|
||||||
|
@Entity("agent_withdrawals", { schema: "test" })
|
||||||
|
export class AgentWithdrawals {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "agent_id" })
|
||||||
|
agentId: number;
|
||||||
|
|
||||||
|
@Column("decimal", { name: "amount", precision: 10, scale: 2 })
|
||||||
|
amount: string;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "payment_type",
|
||||||
|
nullable: true,
|
||||||
|
comment: "收款方式类型",
|
||||||
|
enum: ["bank", "wechat", "alipay", "unionpay"],
|
||||||
|
default: () => "'bank'",
|
||||||
|
})
|
||||||
|
paymentType: "bank" | "wechat" | "alipay" | "unionpay" | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "bank_name",
|
||||||
|
nullable: true,
|
||||||
|
comment: "银行名称",
|
||||||
|
length: 100,
|
||||||
|
})
|
||||||
|
bankName: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "account_number",
|
||||||
|
nullable: true,
|
||||||
|
comment: "账号/银行账号",
|
||||||
|
length: 50,
|
||||||
|
})
|
||||||
|
accountNumber: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "account_holder",
|
||||||
|
nullable: true,
|
||||||
|
comment: "持有人姓名",
|
||||||
|
length: 100,
|
||||||
|
})
|
||||||
|
accountHolder: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "qr_code_url",
|
||||||
|
nullable: true,
|
||||||
|
comment: "收款码图片URL",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
qrCodeUrl: string | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "status",
|
||||||
|
nullable: true,
|
||||||
|
enum: ["pending", "approved", "rejected", "completed"],
|
||||||
|
default: () => "'pending'",
|
||||||
|
})
|
||||||
|
status: "pending" | "approved" | "rejected" | "completed" | null;
|
||||||
|
|
||||||
|
@Column("text", { name: "apply_note", nullable: true })
|
||||||
|
applyNote: string | null;
|
||||||
|
|
||||||
|
@Column("text", { name: "admin_note", nullable: true })
|
||||||
|
adminNote: string | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "processed_by", nullable: true })
|
||||||
|
processedBy: number | null;
|
||||||
|
|
||||||
|
@Column("timestamp", { name: "processed_at", nullable: true })
|
||||||
|
processedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "bank_account",
|
||||||
|
nullable: true,
|
||||||
|
comment: "银行账号(兼容旧版本)",
|
||||||
|
length: 50,
|
||||||
|
})
|
||||||
|
bankAccount: string | null;
|
||||||
|
|
||||||
|
@ManyToOne(
|
||||||
|
() => RegionalAgents,
|
||||||
|
(regionalAgents) => regionalAgents.agentWithdrawals,
|
||||||
|
{ onDelete: "CASCADE", onUpdate: "RESTRICT" }
|
||||||
|
)
|
||||||
|
@JoinColumn([{ name: "agent_id", referencedColumnName: "id" }])
|
||||||
|
agent: RegionalAgents;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.agentWithdrawals, {
|
||||||
|
onDelete: "SET NULL",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "processed_by", referencedColumnName: "id" }])
|
||||||
|
processedBy2: Users;
|
||||||
|
}
|
||||||
110
src/generator_entity/entities/Announcements.ts
Normal file
110
src/generator_entity/entities/Announcements.ts
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
OneToMany,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
import { UserAnnouncementReads } from "./UserAnnouncementReads";
|
||||||
|
|
||||||
|
@Index("created_by", ["createdBy"], {})
|
||||||
|
@Index("idx_created_at", ["createdAt"], {})
|
||||||
|
@Index("idx_publish_time", ["publishTime"], {})
|
||||||
|
@Index("idx_status", ["status"], {})
|
||||||
|
@Index("idx_type", ["type"], {})
|
||||||
|
@Entity("announcements", { schema: "test" })
|
||||||
|
export class Announcements {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "title", comment: "公告标题", length: 255 })
|
||||||
|
title: string;
|
||||||
|
|
||||||
|
@Column("text", { name: "content", comment: "公告内容" })
|
||||||
|
content: string;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "type",
|
||||||
|
nullable: true,
|
||||||
|
comment: "公告类型",
|
||||||
|
enum: ["system", "maintenance", "promotion", "warning"],
|
||||||
|
default: () => "'system'",
|
||||||
|
})
|
||||||
|
type: "system" | "maintenance" | "promotion" | "warning" | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "priority",
|
||||||
|
nullable: true,
|
||||||
|
comment: "优先级",
|
||||||
|
enum: ["low", "medium", "high", "urgent"],
|
||||||
|
default: () => "'medium'",
|
||||||
|
})
|
||||||
|
priority: "low" | "medium" | "high" | "urgent" | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "status",
|
||||||
|
nullable: true,
|
||||||
|
comment: "状态",
|
||||||
|
enum: ["draft", "published", "archived"],
|
||||||
|
default: () => "'draft'",
|
||||||
|
})
|
||||||
|
status: "draft" | "published" | "archived" | null;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_pinned",
|
||||||
|
nullable: true,
|
||||||
|
comment: "是否置顶",
|
||||||
|
width: 1,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
isPinned: boolean | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "publish_time",
|
||||||
|
nullable: true,
|
||||||
|
comment: "发布时间",
|
||||||
|
})
|
||||||
|
publishTime: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "expire_time",
|
||||||
|
nullable: true,
|
||||||
|
comment: "过期时间",
|
||||||
|
})
|
||||||
|
expireTime: Date | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "created_by", comment: "创建者ID" })
|
||||||
|
createdBy: number;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
comment: "创建时间",
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
comment: "更新时间",
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.announcements, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "created_by", referencedColumnName: "id" }])
|
||||||
|
createdBy2: Users;
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => UserAnnouncementReads,
|
||||||
|
(userAnnouncementReads) => userAnnouncementReads.announcement
|
||||||
|
)
|
||||||
|
userAnnouncementReads: UserAnnouncementReads[];
|
||||||
|
}
|
||||||
57
src/generator_entity/entities/Articles.ts
Normal file
57
src/generator_entity/entities/Articles.ts
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
|
||||||
|
@Index("author_id", ["authorId"], {})
|
||||||
|
@Entity("articles", { schema: "test" })
|
||||||
|
export class Articles {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "title", length: 255 })
|
||||||
|
title: string;
|
||||||
|
|
||||||
|
@Column("text", { name: "content", nullable: true })
|
||||||
|
content: string | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "author_id", nullable: true })
|
||||||
|
authorId: number | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "status",
|
||||||
|
nullable: true,
|
||||||
|
enum: ["draft", "published"],
|
||||||
|
default: () => "'draft'",
|
||||||
|
})
|
||||||
|
status: "draft" | "published" | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "views", nullable: true, default: () => "'0'" })
|
||||||
|
views: number | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.articles, {
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "author_id", referencedColumnName: "id" }])
|
||||||
|
author: Users;
|
||||||
|
}
|
||||||
28
src/generator_entity/entities/BalanceFixLog.ts
Normal file
28
src/generator_entity/entities/BalanceFixLog.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
|
||||||
|
@Index("idx_created_at", ["createdAt"], {})
|
||||||
|
@Index("idx_user_id", ["userId"], {})
|
||||||
|
@Entity("balance_fix_log", { schema: "test" })
|
||||||
|
export class BalanceFixLog {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "user_id" })
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column("decimal", { name: "amount_deducted", precision: 10, scale: 2 })
|
||||||
|
amountDeducted: string;
|
||||||
|
|
||||||
|
@Column("int", { name: "transfer_count" })
|
||||||
|
transferCount: number;
|
||||||
|
|
||||||
|
@Column("text", { name: "fix_reason", nullable: true })
|
||||||
|
fixReason: string | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
}
|
||||||
38
src/generator_entity/entities/CartItems.ts
Normal file
38
src/generator_entity/entities/CartItems.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
|
||||||
|
@Index("product_id", ["productId"], {})
|
||||||
|
@Index("specification_id", ["specificationId"], {})
|
||||||
|
@Index("unique_user_product_spec", ["userId", "productId", "specificationId"], {
|
||||||
|
unique: true,
|
||||||
|
})
|
||||||
|
@Entity("cart_items", { schema: "test" })
|
||||||
|
export class CartItems {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "user_id" })
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "product_id" })
|
||||||
|
productId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "quantity", default: () => "'1'" })
|
||||||
|
quantity: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "specification_id", nullable: true })
|
||||||
|
specificationId: number | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
}
|
||||||
32
src/generator_entity/entities/ChinaRegions.ts
Normal file
32
src/generator_entity/entities/ChinaRegions.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
|
||||||
|
@Index("code", ["code"], { unique: true })
|
||||||
|
@Index("idx_level", ["level"], {})
|
||||||
|
@Index("idx_parent_code", ["parentCode"], {})
|
||||||
|
@Entity("china_regions", { schema: "test" })
|
||||||
|
export class ChinaRegions {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "code", unique: true, length: 20 })
|
||||||
|
code: string;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "name", length: 100 })
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "parent_code", nullable: true, length: 20 })
|
||||||
|
parentCode: string | null;
|
||||||
|
|
||||||
|
@Column("tinyint", { name: "level", comment: "1:省 2:市 3:区" })
|
||||||
|
level: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "sort_order", nullable: true, default: () => "'0'" })
|
||||||
|
sortOrder: number | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
}
|
||||||
39
src/generator_entity/entities/Distribution.ts
Normal file
39
src/generator_entity/entities/Distribution.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
|
||||||
|
@Entity("distribution", { schema: "test" })
|
||||||
|
export class Distribution {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "user_id", comment: "用户id" })
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "agent_id", nullable: true, comment: "上级id" })
|
||||||
|
agentId: number | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "amount", comment: "融豆数量" })
|
||||||
|
amount: number;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
comment: "创建时间",
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_offline",
|
||||||
|
nullable: true,
|
||||||
|
comment: "是否是线下交款0为fasle1为true",
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
isOffline: number | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "type",
|
||||||
|
comment: "代理或直营代理或直营或系统",
|
||||||
|
enum: ["agent", "direct_agent", "directly_operated", "user", "system"],
|
||||||
|
})
|
||||||
|
type: "agent" | "direct_agent" | "directly_operated" | "user" | "system";
|
||||||
|
}
|
||||||
95
src/generator_entity/entities/MatchingOrders.ts
Normal file
95
src/generator_entity/entities/MatchingOrders.ts
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
OneToMany,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { AgentCommissionRecords } from "./AgentCommissionRecords";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
import { MatchingRecords } from "./MatchingRecords";
|
||||||
|
import { OrderAllocations } from "./OrderAllocations";
|
||||||
|
|
||||||
|
@Index("initiator_id", ["initiatorId"], {})
|
||||||
|
@Entity("matching_orders", { schema: "test" })
|
||||||
|
export class MatchingOrders {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "initiator_id" })
|
||||||
|
initiatorId: number;
|
||||||
|
|
||||||
|
@Column("decimal", { name: "amount", precision: 10, scale: 2 })
|
||||||
|
amount: string;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "status",
|
||||||
|
nullable: true,
|
||||||
|
enum: ["pending", "matching", "completed", "cancelled", "failed"],
|
||||||
|
default: () => "'pending'",
|
||||||
|
})
|
||||||
|
status: "pending" | "matching" | "completed" | "cancelled" | "failed" | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "cycle_count", nullable: true, default: () => "'0'" })
|
||||||
|
cycleCount: number | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "max_cycles", nullable: true, default: () => "'3'" })
|
||||||
|
maxCycles: number | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "matching_type",
|
||||||
|
nullable: true,
|
||||||
|
enum: ["small", "large"],
|
||||||
|
default: () => "'small'",
|
||||||
|
})
|
||||||
|
matchingType: "small" | "large" | null;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_system_reverse",
|
||||||
|
nullable: true,
|
||||||
|
width: 1,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
isSystemReverse: boolean | null;
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => AgentCommissionRecords,
|
||||||
|
(agentCommissionRecords) => agentCommissionRecords.order
|
||||||
|
)
|
||||||
|
agentCommissionRecords: AgentCommissionRecords[];
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.matchingOrders, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "initiator_id", referencedColumnName: "id" }])
|
||||||
|
initiator: Users;
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => MatchingRecords,
|
||||||
|
(matchingRecords) => matchingRecords.matchingOrder
|
||||||
|
)
|
||||||
|
matchingRecords: MatchingRecords[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => OrderAllocations,
|
||||||
|
(orderAllocations) => orderAllocations.matchingOrder
|
||||||
|
)
|
||||||
|
orderAllocations: OrderAllocations[];
|
||||||
|
}
|
||||||
63
src/generator_entity/entities/MatchingRecords.ts
Normal file
63
src/generator_entity/entities/MatchingRecords.ts
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { MatchingOrders } from "./MatchingOrders";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
|
||||||
|
@Index("matching_order_id", ["matchingOrderId"], {})
|
||||||
|
@Index("user_id", ["userId"], {})
|
||||||
|
@Entity("matching_records", { schema: "test" })
|
||||||
|
export class MatchingRecords {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "matching_order_id" })
|
||||||
|
matchingOrderId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "user_id" })
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "action",
|
||||||
|
enum: ["join", "confirm", "reject", "complete"],
|
||||||
|
})
|
||||||
|
action: "join" | "confirm" | "reject" | "complete";
|
||||||
|
|
||||||
|
@Column("decimal", {
|
||||||
|
name: "amount",
|
||||||
|
nullable: true,
|
||||||
|
precision: 10,
|
||||||
|
scale: 2,
|
||||||
|
})
|
||||||
|
amount: string | null;
|
||||||
|
|
||||||
|
@Column("text", { name: "note", nullable: true })
|
||||||
|
note: string | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(
|
||||||
|
() => MatchingOrders,
|
||||||
|
(matchingOrders) => matchingOrders.matchingRecords,
|
||||||
|
{ onDelete: "CASCADE", onUpdate: "RESTRICT" }
|
||||||
|
)
|
||||||
|
@JoinColumn([{ name: "matching_order_id", referencedColumnName: "id" }])
|
||||||
|
matchingOrder: MatchingOrders;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.matchingRecords, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "user_id", referencedColumnName: "id" }])
|
||||||
|
user: Users;
|
||||||
|
}
|
||||||
102
src/generator_entity/entities/OrderAllocations.ts
Normal file
102
src/generator_entity/entities/OrderAllocations.ts
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { MatchingOrders } from "./MatchingOrders";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
import { Transfers } from "./Transfers";
|
||||||
|
|
||||||
|
@Index("from_user_id", ["fromUserId"], {})
|
||||||
|
@Index("matching_order_id", ["matchingOrderId"], {})
|
||||||
|
@Index("to_user_id", ["toUserId"], {})
|
||||||
|
@Index("transfer_id", ["transferId"], {})
|
||||||
|
@Entity("order_allocations", { schema: "test" })
|
||||||
|
export class OrderAllocations {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "matching_order_id" })
|
||||||
|
matchingOrderId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "from_user_id" })
|
||||||
|
fromUserId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "to_user_id" })
|
||||||
|
toUserId: number;
|
||||||
|
|
||||||
|
@Column("decimal", { name: "amount", precision: 10, scale: 2 })
|
||||||
|
amount: string;
|
||||||
|
|
||||||
|
@Column("int", { name: "cycle_number" })
|
||||||
|
cycleNumber: number;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "status",
|
||||||
|
nullable: true,
|
||||||
|
enum: ["pending", "confirmed", "rejected", "completed"],
|
||||||
|
default: () => "'pending'",
|
||||||
|
})
|
||||||
|
status: "pending" | "confirmed" | "rejected" | "completed" | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "transfer_id", nullable: true })
|
||||||
|
transferId: number | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", { name: "confirmed_at", nullable: true })
|
||||||
|
confirmedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("date", { name: "outbound_date", nullable: true })
|
||||||
|
outboundDate: string | null;
|
||||||
|
|
||||||
|
@Column("date", { name: "return_date", nullable: true })
|
||||||
|
returnDate: string | null;
|
||||||
|
|
||||||
|
@Column("timestamp", { name: "can_return_after", nullable: true })
|
||||||
|
canReturnAfter: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(
|
||||||
|
() => MatchingOrders,
|
||||||
|
(matchingOrders) => matchingOrders.orderAllocations,
|
||||||
|
{ onDelete: "CASCADE", onUpdate: "RESTRICT" }
|
||||||
|
)
|
||||||
|
@JoinColumn([{ name: "matching_order_id", referencedColumnName: "id" }])
|
||||||
|
matchingOrder: MatchingOrders;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.orderAllocations, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "from_user_id", referencedColumnName: "id" }])
|
||||||
|
fromUser: Users;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.orderAllocations2, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "to_user_id", referencedColumnName: "id" }])
|
||||||
|
toUser: Users;
|
||||||
|
|
||||||
|
@ManyToOne(() => Transfers, (transfers) => transfers.orderAllocations, {
|
||||||
|
onDelete: "SET NULL",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "transfer_id", referencedColumnName: "id" }])
|
||||||
|
transfer: Transfers;
|
||||||
|
}
|
||||||
59
src/generator_entity/entities/OrderAllocationsBackup.ts
Normal file
59
src/generator_entity/entities/OrderAllocationsBackup.ts
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import { Column, Entity } from "typeorm";
|
||||||
|
|
||||||
|
@Entity("order_allocations_backup", { schema: "test" })
|
||||||
|
export class OrderAllocationsBackup {
|
||||||
|
@Column("int", { name: "id", default: () => "'0'" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "matching_order_id" })
|
||||||
|
matchingOrderId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "from_user_id" })
|
||||||
|
fromUserId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "to_user_id" })
|
||||||
|
toUserId: number;
|
||||||
|
|
||||||
|
@Column("decimal", { name: "amount", precision: 10, scale: 2 })
|
||||||
|
amount: string;
|
||||||
|
|
||||||
|
@Column("int", { name: "cycle_number" })
|
||||||
|
cycleNumber: number;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "status",
|
||||||
|
nullable: true,
|
||||||
|
enum: ["pending", "confirmed", "rejected", "completed"],
|
||||||
|
default: () => "'pending'",
|
||||||
|
})
|
||||||
|
status: "pending" | "confirmed" | "rejected" | "completed" | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "transfer_id", nullable: true })
|
||||||
|
transferId: number | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", { name: "confirmed_at", nullable: true })
|
||||||
|
confirmedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("date", { name: "outbound_date", nullable: true })
|
||||||
|
outboundDate: string | null;
|
||||||
|
|
||||||
|
@Column("date", { name: "return_date", nullable: true })
|
||||||
|
returnDate: string | null;
|
||||||
|
|
||||||
|
@Column("timestamp", { name: "can_return_after", nullable: true })
|
||||||
|
canReturnAfter: Date | null;
|
||||||
|
}
|
||||||
70
src/generator_entity/entities/OrderItems.ts
Normal file
70
src/generator_entity/entities/OrderItems.ts
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { Orders } from "./Orders";
|
||||||
|
import { Products } from "./Products";
|
||||||
|
|
||||||
|
@Index("order_id", ["orderId"], {})
|
||||||
|
@Index("product_id", ["productId"], {})
|
||||||
|
@Entity("order_items", { schema: "test" })
|
||||||
|
export class OrderItems {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "order_id" })
|
||||||
|
orderId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "product_id" })
|
||||||
|
productId: number;
|
||||||
|
|
||||||
|
@Column("int", {
|
||||||
|
name: "spec_combination_id",
|
||||||
|
nullable: true,
|
||||||
|
comment: "规格组合ID",
|
||||||
|
})
|
||||||
|
specCombinationId: number | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "quantity" })
|
||||||
|
quantity: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "price" })
|
||||||
|
price: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "points" })
|
||||||
|
points: number;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "points_price", default: () => "'0'" })
|
||||||
|
pointsPrice: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "rongdou_price", default: () => "'0'" })
|
||||||
|
rongdouPrice: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "rongdou", nullable: true, default: () => "'0'" })
|
||||||
|
rongdou: number | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => Orders, (orders) => orders.orderItems, {
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "order_id", referencedColumnName: "id" }])
|
||||||
|
order: Orders;
|
||||||
|
|
||||||
|
@ManyToOne(() => Products, (products) => products.orderItems, {
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "product_id", referencedColumnName: "id" }])
|
||||||
|
product: Products;
|
||||||
|
}
|
||||||
97
src/generator_entity/entities/Orders.ts
Normal file
97
src/generator_entity/entities/Orders.ts
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
OneToMany,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { OrderItems } from "./OrderItems";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
import { PointsHistory } from "./PointsHistory";
|
||||||
|
import { ProductReviews } from "./ProductReviews";
|
||||||
|
import { RongdouHistory } from "./RongdouHistory";
|
||||||
|
|
||||||
|
@Index("order_no", ["orderNo"], { unique: true })
|
||||||
|
@Index("user_id", ["userId"], {})
|
||||||
|
@Entity("orders", { schema: "test" })
|
||||||
|
export class Orders {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "user_id" })
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "order_no", unique: true, length: 50 })
|
||||||
|
orderNo: string;
|
||||||
|
|
||||||
|
@Column("int", { name: "total_amount" })
|
||||||
|
totalAmount: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "total_points" })
|
||||||
|
totalPoints: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "total_rongdou", default: () => "'0'" })
|
||||||
|
totalRongdou: number;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "status",
|
||||||
|
nullable: true,
|
||||||
|
enum: [
|
||||||
|
"pending",
|
||||||
|
"paid",
|
||||||
|
"shipped",
|
||||||
|
"delivered",
|
||||||
|
"cancelled",
|
||||||
|
"pre_order",
|
||||||
|
"completed",
|
||||||
|
],
|
||||||
|
default: () => "'pending'",
|
||||||
|
})
|
||||||
|
status:
|
||||||
|
| "pending"
|
||||||
|
| "paid"
|
||||||
|
| "shipped"
|
||||||
|
| "delivered"
|
||||||
|
| "cancelled"
|
||||||
|
| "pre_order"
|
||||||
|
| "completed"
|
||||||
|
| null;
|
||||||
|
|
||||||
|
@Column("json", { name: "address", nullable: true })
|
||||||
|
address: object | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@OneToMany(() => OrderItems, (orderItems) => orderItems.order)
|
||||||
|
orderItems: OrderItems[];
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.orders, {
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "user_id", referencedColumnName: "id" }])
|
||||||
|
user: Users;
|
||||||
|
|
||||||
|
@OneToMany(() => PointsHistory, (pointsHistory) => pointsHistory.order)
|
||||||
|
pointsHistories: PointsHistory[];
|
||||||
|
|
||||||
|
@OneToMany(() => ProductReviews, (productReviews) => productReviews.order)
|
||||||
|
productReviews: ProductReviews[];
|
||||||
|
|
||||||
|
@OneToMany(() => RongdouHistory, (rongdouHistory) => rongdouHistory.order)
|
||||||
|
rongdouHistories: RongdouHistory[];
|
||||||
|
}
|
||||||
80
src/generator_entity/entities/PaymentOrders.ts
Normal file
80
src/generator_entity/entities/PaymentOrders.ts
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
|
||||||
|
@Index("idx_created_at", ["createdAt"], {})
|
||||||
|
@Index("idx_status", ["status"], {})
|
||||||
|
@Index("idx_user_id", ["userId"], {})
|
||||||
|
@Index("uk_out_trade_no", ["outTradeNo"], { unique: true })
|
||||||
|
@Entity("payment_orders", { schema: "test" })
|
||||||
|
export class PaymentOrders {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id", comment: "订单ID" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "user_id", comment: "用户ID" })
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "out_trade_no",
|
||||||
|
unique: true,
|
||||||
|
comment: "商户订单号",
|
||||||
|
length: 64,
|
||||||
|
})
|
||||||
|
outTradeNo: string;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "transaction_id",
|
||||||
|
nullable: true,
|
||||||
|
comment: "微信支付订单号",
|
||||||
|
length: 64,
|
||||||
|
})
|
||||||
|
transactionId: string | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "total_fee", comment: "订单金额(分)" })
|
||||||
|
totalFee: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "body", comment: "商品描述", length: 128 })
|
||||||
|
body: string;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "trade_type", comment: "交易类型", length: 16 })
|
||||||
|
tradeType: string;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "prepay_id",
|
||||||
|
nullable: true,
|
||||||
|
comment: "预支付交易会话标识",
|
||||||
|
length: 64,
|
||||||
|
})
|
||||||
|
prepayId: string | null;
|
||||||
|
|
||||||
|
@Column("text", {
|
||||||
|
name: "mweb_url",
|
||||||
|
nullable: true,
|
||||||
|
comment: "H5支付跳转链接",
|
||||||
|
})
|
||||||
|
mwebUrl: string | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "status",
|
||||||
|
comment: "支付状态",
|
||||||
|
enum: ["pending", "paid", "failed", "cancelled"],
|
||||||
|
default: () => "'pending'",
|
||||||
|
})
|
||||||
|
status: "pending" | "paid" | "failed" | "cancelled";
|
||||||
|
|
||||||
|
@Column("datetime", {
|
||||||
|
name: "paid_at",
|
||||||
|
nullable: true,
|
||||||
|
comment: "支付完成时间",
|
||||||
|
})
|
||||||
|
paidAt: Date | null;
|
||||||
|
|
||||||
|
@Column("datetime", { name: "created_at", comment: "创建时间" })
|
||||||
|
createdAt: Date;
|
||||||
|
|
||||||
|
@Column("datetime", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
comment: "更新时间",
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
}
|
||||||
57
src/generator_entity/entities/PointsHistory.ts
Normal file
57
src/generator_entity/entities/PointsHistory.ts
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
import { Orders } from "./Orders";
|
||||||
|
|
||||||
|
@Index("order_id", ["orderId"], {})
|
||||||
|
@Index("user_id", ["userId"], {})
|
||||||
|
@Entity("points_history", { schema: "test" })
|
||||||
|
export class PointsHistory {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "user_id" })
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "type",
|
||||||
|
enum: ["earn", "spend", "admin_adjust", "refund"],
|
||||||
|
})
|
||||||
|
type: "earn" | "spend" | "admin_adjust" | "refund";
|
||||||
|
|
||||||
|
@Column("int", { name: "amount" })
|
||||||
|
amount: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "description", nullable: true, length: 255 })
|
||||||
|
description: string | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "order_id", nullable: true })
|
||||||
|
orderId: number | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.pointsHistories, {
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "user_id", referencedColumnName: "id" }])
|
||||||
|
user: Users;
|
||||||
|
|
||||||
|
@ManyToOne(() => Orders, (orders) => orders.pointsHistories, {
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "order_id", referencedColumnName: "id" }])
|
||||||
|
order: Orders;
|
||||||
|
}
|
||||||
49
src/generator_entity/entities/ProductAttributes.ts
Normal file
49
src/generator_entity/entities/ProductAttributes.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { Products } from "./Products";
|
||||||
|
|
||||||
|
@Index("product_id", ["productId"], {})
|
||||||
|
@Entity("product_attributes", { schema: "test" })
|
||||||
|
export class ProductAttributes {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "product_id" })
|
||||||
|
productId: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "attribute_key", length: 100 })
|
||||||
|
attributeKey: string;
|
||||||
|
|
||||||
|
@Column("text", { name: "attribute_value" })
|
||||||
|
attributeValue: string;
|
||||||
|
|
||||||
|
@Column("int", { name: "sort_order", nullable: true, default: () => "'0'" })
|
||||||
|
sortOrder: number | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => Products, (products) => products.productAttributes, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "product_id", referencedColumnName: "id" }])
|
||||||
|
product: Products;
|
||||||
|
}
|
||||||
45
src/generator_entity/entities/ProductFavorites.ts
Normal file
45
src/generator_entity/entities/ProductFavorites.ts
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
import { Products } from "./Products";
|
||||||
|
|
||||||
|
@Index("product_id", ["productId"], {})
|
||||||
|
@Index("unique_user_product", ["userId", "productId"], { unique: true })
|
||||||
|
@Entity("product_favorites", { schema: "test" })
|
||||||
|
export class ProductFavorites {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "user_id" })
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "product_id" })
|
||||||
|
productId: number;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.productFavorites, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "user_id", referencedColumnName: "id" }])
|
||||||
|
user: Users;
|
||||||
|
|
||||||
|
@ManyToOne(() => Products, (products) => products.productFavorites, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "product_id", referencedColumnName: "id" }])
|
||||||
|
product: Products;
|
||||||
|
}
|
||||||
66
src/generator_entity/entities/ProductReviews.ts
Normal file
66
src/generator_entity/entities/ProductReviews.ts
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { Products } from "./Products";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
import { Orders } from "./Orders";
|
||||||
|
|
||||||
|
@Index("order_id", ["orderId"], {})
|
||||||
|
@Index("product_id", ["productId"], {})
|
||||||
|
@Index("user_id", ["userId"], {})
|
||||||
|
@Entity("product_reviews", { schema: "test" })
|
||||||
|
export class ProductReviews {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "product_id" })
|
||||||
|
productId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "user_id" })
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "order_id" })
|
||||||
|
orderId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "rating" })
|
||||||
|
rating: number;
|
||||||
|
|
||||||
|
@Column("text", { name: "comment", nullable: true })
|
||||||
|
comment: string | null;
|
||||||
|
|
||||||
|
@Column("json", { name: "images", nullable: true })
|
||||||
|
images: object | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => Products, (products) => products.productReviews, {
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "product_id", referencedColumnName: "id" }])
|
||||||
|
product: Products;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.productReviews, {
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "user_id", referencedColumnName: "id" }])
|
||||||
|
user: Users;
|
||||||
|
|
||||||
|
@ManyToOne(() => Orders, (orders) => orders.productReviews, {
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "order_id", referencedColumnName: "id" }])
|
||||||
|
order: Orders;
|
||||||
|
}
|
||||||
131
src/generator_entity/entities/ProductSpecCombinations.ts
Normal file
131
src/generator_entity/entities/ProductSpecCombinations.ts
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { Products } from "./Products";
|
||||||
|
|
||||||
|
@Index("idx_product_status", ["productId", "status"], {})
|
||||||
|
@Index("idx_sku_code", ["skuCode"], {})
|
||||||
|
@Index("unique_product_combination", ["productId", "combinationKey"], {
|
||||||
|
unique: true,
|
||||||
|
})
|
||||||
|
@Entity("product_spec_combinations", { schema: "test" })
|
||||||
|
export class ProductSpecCombinations {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "product_id", comment: "商品ID" })
|
||||||
|
productId: number;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "combination_key",
|
||||||
|
comment: "组合键,如:color_1-size_2-material_3",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
combinationKey: string;
|
||||||
|
|
||||||
|
@Column("json", {
|
||||||
|
name: "spec_values",
|
||||||
|
comment: "规格值组合,存储spec_value_id数组",
|
||||||
|
})
|
||||||
|
specValues: object;
|
||||||
|
|
||||||
|
@Column("int", {
|
||||||
|
name: "price_adjustment",
|
||||||
|
nullable: true,
|
||||||
|
comment: "价格调整",
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
priceAdjustment: number | null;
|
||||||
|
|
||||||
|
@Column("int", {
|
||||||
|
name: "points_adjustment",
|
||||||
|
nullable: true,
|
||||||
|
comment: "积分调整",
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
pointsAdjustment: number | null;
|
||||||
|
|
||||||
|
@Column("int", {
|
||||||
|
name: "rongdou_adjustment",
|
||||||
|
nullable: true,
|
||||||
|
comment: "融豆调整",
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
rongdouAdjustment: number | null;
|
||||||
|
|
||||||
|
@Column("int", {
|
||||||
|
name: "stock",
|
||||||
|
nullable: true,
|
||||||
|
comment: "库存",
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
stock: number | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "sku_code",
|
||||||
|
nullable: true,
|
||||||
|
comment: "SKU编码",
|
||||||
|
length: 100,
|
||||||
|
})
|
||||||
|
skuCode: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "barcode",
|
||||||
|
nullable: true,
|
||||||
|
comment: "条形码",
|
||||||
|
length: 100,
|
||||||
|
})
|
||||||
|
barcode: string | null;
|
||||||
|
|
||||||
|
@Column("decimal", {
|
||||||
|
name: "weight",
|
||||||
|
nullable: true,
|
||||||
|
comment: "重量(kg)",
|
||||||
|
precision: 8,
|
||||||
|
scale: 3,
|
||||||
|
})
|
||||||
|
weight: string | null;
|
||||||
|
|
||||||
|
@Column("decimal", {
|
||||||
|
name: "volume",
|
||||||
|
nullable: true,
|
||||||
|
comment: "体积(cm³)",
|
||||||
|
precision: 10,
|
||||||
|
scale: 3,
|
||||||
|
})
|
||||||
|
volume: string | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "status",
|
||||||
|
nullable: true,
|
||||||
|
enum: ["active", "inactive"],
|
||||||
|
default: () => "'active'",
|
||||||
|
})
|
||||||
|
status: "active" | "inactive" | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => Products, (products) => products.productSpecCombinations, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "product_id", referencedColumnName: "id" }])
|
||||||
|
product: Products;
|
||||||
|
}
|
||||||
64
src/generator_entity/entities/ProductSpecNames.ts
Normal file
64
src/generator_entity/entities/ProductSpecNames.ts
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { Products } from "./Products";
|
||||||
|
import { SpecNames } from "./SpecNames";
|
||||||
|
|
||||||
|
@Index("spec_name_id", ["specNameId"], {})
|
||||||
|
@Index("unique_product_spec_name", ["productId", "specNameId"], {
|
||||||
|
unique: true,
|
||||||
|
})
|
||||||
|
@Entity("product_spec_names", { schema: "test" })
|
||||||
|
export class ProductSpecNames {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "product_id", comment: "商品ID" })
|
||||||
|
productId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "spec_name_id", comment: "规格名称ID" })
|
||||||
|
specNameId: number;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_required",
|
||||||
|
nullable: true,
|
||||||
|
comment: "是否必选规格",
|
||||||
|
width: 1,
|
||||||
|
default: () => "'1'",
|
||||||
|
})
|
||||||
|
isRequired: boolean | null;
|
||||||
|
|
||||||
|
@Column("int", {
|
||||||
|
name: "sort_order",
|
||||||
|
nullable: true,
|
||||||
|
comment: "排序",
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
sortOrder: number | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => Products, (products) => products.productSpecNames, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "product_id", referencedColumnName: "id" }])
|
||||||
|
product: Products;
|
||||||
|
|
||||||
|
@ManyToOne(() => SpecNames, (specNames) => specNames.productSpecNames, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "spec_name_id", referencedColumnName: "id" }])
|
||||||
|
specName: SpecNames;
|
||||||
|
}
|
||||||
81
src/generator_entity/entities/ProductSpecifications.ts
Normal file
81
src/generator_entity/entities/ProductSpecifications.ts
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { Products } from "./Products";
|
||||||
|
|
||||||
|
@Index("product_id", ["productId"], {})
|
||||||
|
@Entity("product_specifications", { schema: "test" })
|
||||||
|
export class ProductSpecifications {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "product_id" })
|
||||||
|
productId: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "spec_name", length: 100 })
|
||||||
|
specName: string;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "spec_value", length: 100 })
|
||||||
|
specValue: string;
|
||||||
|
|
||||||
|
@Column("int", {
|
||||||
|
name: "price_adjustment",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
priceAdjustment: number | null;
|
||||||
|
|
||||||
|
@Column("int", {
|
||||||
|
name: "points_adjustment",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
pointsAdjustment: number | null;
|
||||||
|
|
||||||
|
@Column("int", {
|
||||||
|
name: "rongdou_adjustment",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
rongdouAdjustment: number | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "stock", nullable: true, default: () => "'0'" })
|
||||||
|
stock: number | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "sku_code", nullable: true, length: 100 })
|
||||||
|
skuCode: string | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "status",
|
||||||
|
nullable: true,
|
||||||
|
enum: ["active", "inactive"],
|
||||||
|
default: () => "'active'",
|
||||||
|
})
|
||||||
|
status: "active" | "inactive" | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => Products, (products) => products.productSpecifications, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "product_id", referencedColumnName: "id" }])
|
||||||
|
product: Products;
|
||||||
|
}
|
||||||
129
src/generator_entity/entities/Products.ts
Normal file
129
src/generator_entity/entities/Products.ts
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { OrderItems } from "./OrderItems";
|
||||||
|
import { ProductAttributes } from "./ProductAttributes";
|
||||||
|
import { ProductFavorites } from "./ProductFavorites";
|
||||||
|
import { ProductReviews } from "./ProductReviews";
|
||||||
|
import { ProductSpecCombinations } from "./ProductSpecCombinations";
|
||||||
|
import { ProductSpecNames } from "./ProductSpecNames";
|
||||||
|
import { ProductSpecifications } from "./ProductSpecifications";
|
||||||
|
|
||||||
|
@Entity("products", { schema: "test" })
|
||||||
|
export class Products {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "name", length: 255 })
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Column("text", { name: "description", nullable: true })
|
||||||
|
description: string | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "price" })
|
||||||
|
price: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "original_price", nullable: true })
|
||||||
|
originalPrice: number | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "stock", nullable: true, default: () => "'0'" })
|
||||||
|
stock: number | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "sales", nullable: true, default: () => "'0'" })
|
||||||
|
sales: number | null;
|
||||||
|
|
||||||
|
@Column("decimal", {
|
||||||
|
name: "rating",
|
||||||
|
nullable: true,
|
||||||
|
precision: 3,
|
||||||
|
scale: 2,
|
||||||
|
default: () => "'5.00'",
|
||||||
|
})
|
||||||
|
rating: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "category", nullable: true, length: 100 })
|
||||||
|
category: string | null;
|
||||||
|
|
||||||
|
@Column("json", { name: "images", nullable: true })
|
||||||
|
images: object | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "status",
|
||||||
|
nullable: true,
|
||||||
|
enum: ["active", "inactive"],
|
||||||
|
default: () => "'active'",
|
||||||
|
})
|
||||||
|
status: "active" | "inactive" | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "points_price", default: () => "'0'" })
|
||||||
|
pointsPrice: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "image_url", nullable: true, length: 500 })
|
||||||
|
imageUrl: string | null;
|
||||||
|
|
||||||
|
@Column("text", { name: "details", nullable: true })
|
||||||
|
details: string | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "rongdou_price", default: () => "'0'" })
|
||||||
|
rongdouPrice: number;
|
||||||
|
|
||||||
|
@Column("json", { name: "videos", nullable: true })
|
||||||
|
videos: object | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "shop_name", nullable: true, length: 255 })
|
||||||
|
shopName: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "shop_avatar", nullable: true, length: 500 })
|
||||||
|
shopAvatar: string | null;
|
||||||
|
|
||||||
|
@Column("json", { name: "payment_methods", nullable: true })
|
||||||
|
paymentMethods: object | null;
|
||||||
|
|
||||||
|
@OneToMany(() => OrderItems, (orderItems) => orderItems.product)
|
||||||
|
orderItems: OrderItems[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => ProductAttributes,
|
||||||
|
(productAttributes) => productAttributes.product
|
||||||
|
)
|
||||||
|
productAttributes: ProductAttributes[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => ProductFavorites,
|
||||||
|
(productFavorites) => productFavorites.product
|
||||||
|
)
|
||||||
|
productFavorites: ProductFavorites[];
|
||||||
|
|
||||||
|
@OneToMany(() => ProductReviews, (productReviews) => productReviews.product)
|
||||||
|
productReviews: ProductReviews[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => ProductSpecCombinations,
|
||||||
|
(productSpecCombinations) => productSpecCombinations.product
|
||||||
|
)
|
||||||
|
productSpecCombinations: ProductSpecCombinations[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => ProductSpecNames,
|
||||||
|
(productSpecNames) => productSpecNames.product
|
||||||
|
)
|
||||||
|
productSpecNames: ProductSpecNames[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => ProductSpecifications,
|
||||||
|
(productSpecifications) => productSpecifications.product
|
||||||
|
)
|
||||||
|
productSpecifications: ProductSpecifications[];
|
||||||
|
}
|
||||||
70
src/generator_entity/entities/Program.ts
Normal file
70
src/generator_entity/entities/Program.ts
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
|
||||||
|
@Entity("program", { schema: "test" })
|
||||||
|
export class Program {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id", comment: "项目id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "name", comment: "项目名称", length: 255 })
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "linkman_id",
|
||||||
|
comment: "联系人userid",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
linkmanId: string;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "company",
|
||||||
|
nullable: true,
|
||||||
|
comment: "公司名称",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
company: string | null;
|
||||||
|
|
||||||
|
@Column("text", { name: "introduction", nullable: true, comment: "简介" })
|
||||||
|
introduction: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "address",
|
||||||
|
nullable: true,
|
||||||
|
comment: "项目地点",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
address: string | null;
|
||||||
|
|
||||||
|
@Column("datetime", {
|
||||||
|
name: "start_date",
|
||||||
|
nullable: true,
|
||||||
|
comment: "开始时间",
|
||||||
|
})
|
||||||
|
startDate: Date | null;
|
||||||
|
|
||||||
|
@Column("datetime", { name: "end_date", nullable: true, comment: "结束时间" })
|
||||||
|
endDate: Date | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "payment_method",
|
||||||
|
nullable: true,
|
||||||
|
comment: "结算方式?",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
paymentMethod: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "remark",
|
||||||
|
nullable: true,
|
||||||
|
comment: "其他",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
remark: string | null;
|
||||||
|
|
||||||
|
@Column("datetime", {
|
||||||
|
name: "create_date",
|
||||||
|
nullable: true,
|
||||||
|
comment: "发布时间",
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createDate: Date | null;
|
||||||
|
}
|
||||||
29
src/generator_entity/entities/ProgramGroup.ts
Normal file
29
src/generator_entity/entities/ProgramGroup.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
|
||||||
|
@Entity("program_group", { schema: "test" })
|
||||||
|
export class ProgramGroup {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "group_id", comment: "群组ID" })
|
||||||
|
groupId: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "group_name", comment: "群组名", length: 255 })
|
||||||
|
groupName: string;
|
||||||
|
|
||||||
|
@Column("int", { name: "program_id", comment: "项目ID" })
|
||||||
|
programId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "charge_id", comment: "负责人ID" })
|
||||||
|
chargeId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "customer_id", comment: "客服ID" })
|
||||||
|
customerId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "user_id", comment: "用户ID" })
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column("datetime", {
|
||||||
|
name: "create_time",
|
||||||
|
comment: "创建时间",
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createTime: Date;
|
||||||
|
}
|
||||||
35
src/generator_entity/entities/ProgramGroupMessage.ts
Normal file
35
src/generator_entity/entities/ProgramGroupMessage.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
|
||||||
|
@Entity("program_group_message", { schema: "test" })
|
||||||
|
export class ProgramGroupMessage {
|
||||||
|
@PrimaryGeneratedColumn({
|
||||||
|
type: "int",
|
||||||
|
name: "message_id",
|
||||||
|
comment: "消息ID",
|
||||||
|
})
|
||||||
|
messageId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "create_id", comment: "发送人ID" })
|
||||||
|
createId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "group_id", comment: "群聊ID" })
|
||||||
|
groupId: number;
|
||||||
|
|
||||||
|
@Column("text", { name: "content", comment: "内容" })
|
||||||
|
content: string;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "type",
|
||||||
|
comment: "消息类型",
|
||||||
|
enum: ["text", "img", "mp3"],
|
||||||
|
default: () => "'text'",
|
||||||
|
})
|
||||||
|
type: "text" | "img" | "mp3";
|
||||||
|
|
||||||
|
@Column("datetime", {
|
||||||
|
name: "create_time",
|
||||||
|
comment: "发送时间",
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createTime: Date;
|
||||||
|
}
|
||||||
184
src/generator_entity/entities/RegionalAgents.ts
Normal file
184
src/generator_entity/entities/RegionalAgents.ts
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
OneToMany,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { AgentCommissionRecords } from "./AgentCommissionRecords";
|
||||||
|
import { AgentMerchants } from "./AgentMerchants";
|
||||||
|
import { AgentWithdrawals } from "./AgentWithdrawals";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
|
||||||
|
@Index("agent_code", ["agentCode"], { unique: true })
|
||||||
|
@Index("region_id", ["regionId"], {})
|
||||||
|
@Index("unique_agent_region", ["userId", "regionId"], { unique: true })
|
||||||
|
@Entity("regional_agents", { schema: "test" })
|
||||||
|
export class RegionalAgents {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "user_id" })
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "region_id", length: 20 })
|
||||||
|
regionId: string;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "agent_code", unique: true, length: 20 })
|
||||||
|
agentCode: string;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "status",
|
||||||
|
nullable: true,
|
||||||
|
enum: ["pending", "active", "suspended", "terminated"],
|
||||||
|
default: () => "'pending'",
|
||||||
|
})
|
||||||
|
status: "pending" | "active" | "suspended" | "terminated" | null;
|
||||||
|
|
||||||
|
@Column("decimal", {
|
||||||
|
name: "commission_rate",
|
||||||
|
nullable: true,
|
||||||
|
precision: 5,
|
||||||
|
scale: 4,
|
||||||
|
default: () => "'0.0500'",
|
||||||
|
})
|
||||||
|
commissionRate: string | null;
|
||||||
|
|
||||||
|
@Column("decimal", {
|
||||||
|
name: "total_earnings",
|
||||||
|
nullable: true,
|
||||||
|
precision: 10,
|
||||||
|
scale: 2,
|
||||||
|
default: () => "'0.00'",
|
||||||
|
})
|
||||||
|
totalEarnings: string | null;
|
||||||
|
|
||||||
|
@Column("int", {
|
||||||
|
name: "recruited_merchants",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
recruitedMerchants: number | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", { name: "approved_at", nullable: true })
|
||||||
|
approvedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "approved_by_admin_id", nullable: true })
|
||||||
|
approvedByAdminId: number | null;
|
||||||
|
|
||||||
|
@Column("decimal", {
|
||||||
|
name: "withdrawn_amount",
|
||||||
|
nullable: true,
|
||||||
|
comment: "已提现金额",
|
||||||
|
precision: 10,
|
||||||
|
scale: 2,
|
||||||
|
default: () => "'0.00'",
|
||||||
|
})
|
||||||
|
withdrawnAmount: string | null;
|
||||||
|
|
||||||
|
@Column("decimal", {
|
||||||
|
name: "pending_withdrawal",
|
||||||
|
nullable: true,
|
||||||
|
comment: "待审核提现金额",
|
||||||
|
precision: 10,
|
||||||
|
scale: 2,
|
||||||
|
default: () => "'0.00'",
|
||||||
|
})
|
||||||
|
pendingWithdrawal: string | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "payment_type",
|
||||||
|
nullable: true,
|
||||||
|
comment: "收款方式类型",
|
||||||
|
enum: ["bank", "wechat", "alipay", "unionpay"],
|
||||||
|
default: () => "'bank'",
|
||||||
|
})
|
||||||
|
paymentType: "bank" | "wechat" | "alipay" | "unionpay" | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "account_number",
|
||||||
|
nullable: true,
|
||||||
|
comment: "账号/银行账号",
|
||||||
|
length: 50,
|
||||||
|
})
|
||||||
|
accountNumber: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "account_holder",
|
||||||
|
nullable: true,
|
||||||
|
comment: "持有人姓名",
|
||||||
|
length: 100,
|
||||||
|
})
|
||||||
|
accountHolder: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "qr_code_url",
|
||||||
|
nullable: true,
|
||||||
|
comment: "收款码图片URL",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
qrCodeUrl: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "bank_account",
|
||||||
|
nullable: true,
|
||||||
|
comment: "银行账号(兼容旧版本)",
|
||||||
|
length: 50,
|
||||||
|
})
|
||||||
|
bankAccount: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "bank_name",
|
||||||
|
nullable: true,
|
||||||
|
comment: "银行名称",
|
||||||
|
length: 100,
|
||||||
|
})
|
||||||
|
bankName: string | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "type",
|
||||||
|
nullable: true,
|
||||||
|
comment: "直营或者代理",
|
||||||
|
enum: ["agent", "direct_agent"],
|
||||||
|
default: () => "'agent'",
|
||||||
|
})
|
||||||
|
type: "agent" | "direct_agent" | null;
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => AgentCommissionRecords,
|
||||||
|
(agentCommissionRecords) => agentCommissionRecords.agent
|
||||||
|
)
|
||||||
|
agentCommissionRecords: AgentCommissionRecords[];
|
||||||
|
|
||||||
|
@OneToMany(() => AgentMerchants, (agentMerchants) => agentMerchants.agent)
|
||||||
|
agentMerchants: AgentMerchants[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => AgentWithdrawals,
|
||||||
|
(agentWithdrawals) => agentWithdrawals.agent
|
||||||
|
)
|
||||||
|
agentWithdrawals: AgentWithdrawals[];
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.regionalAgents, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "user_id", referencedColumnName: "id" }])
|
||||||
|
user: Users;
|
||||||
|
}
|
||||||
98
src/generator_entity/entities/RegistrationCodes.ts
Normal file
98
src/generator_entity/entities/RegistrationCodes.ts
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
OneToMany,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { AgentMerchants } from "./AgentMerchants";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
|
||||||
|
@Index("code", ["code"], { unique: true })
|
||||||
|
@Index("created_by_admin_id", ["createdByAdminId"], {})
|
||||||
|
@Index("fk_registration_codes_agent_id", ["agentId"], {})
|
||||||
|
@Index("idx_code", ["code"], {})
|
||||||
|
@Index("idx_expires_at", ["expiresAt"], {})
|
||||||
|
@Index("idx_is_used", ["isUsed"], {})
|
||||||
|
@Index("used_by_user_id", ["usedByUserId"], {})
|
||||||
|
@Entity("registration_codes", { schema: "test" })
|
||||||
|
export class RegistrationCodes {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "code",
|
||||||
|
unique: true,
|
||||||
|
comment: "注册码",
|
||||||
|
length: 32,
|
||||||
|
})
|
||||||
|
code: string;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
comment: "创建时间",
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", { name: "expires_at", comment: "过期时间" })
|
||||||
|
expiresAt: Date;
|
||||||
|
|
||||||
|
@Column("timestamp", { name: "used_at", nullable: true, comment: "使用时间" })
|
||||||
|
usedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("int", {
|
||||||
|
name: "used_by_user_id",
|
||||||
|
nullable: true,
|
||||||
|
comment: "使用该注册码的用户ID",
|
||||||
|
})
|
||||||
|
usedByUserId: number | null;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_used",
|
||||||
|
nullable: true,
|
||||||
|
comment: "是否已使用",
|
||||||
|
width: 1,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
isUsed: boolean | null;
|
||||||
|
|
||||||
|
@Column("int", {
|
||||||
|
name: "created_by_admin_id",
|
||||||
|
comment: "创建该注册码的管理员ID",
|
||||||
|
})
|
||||||
|
createdByAdminId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "agent_id", nullable: true })
|
||||||
|
agentId: number | null;
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => AgentMerchants,
|
||||||
|
(agentMerchants) => agentMerchants.registrationCode
|
||||||
|
)
|
||||||
|
agentMerchants: AgentMerchants[];
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.registrationCodes, {
|
||||||
|
onDelete: "SET NULL",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "agent_id", referencedColumnName: "id" }])
|
||||||
|
agent: Users;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.registrationCodes2, {
|
||||||
|
onDelete: "SET NULL",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "used_by_user_id", referencedColumnName: "id" }])
|
||||||
|
usedByUser: Users;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.registrationCodes3, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "created_by_admin_id", referencedColumnName: "id" }])
|
||||||
|
createdByAdmin: Users;
|
||||||
|
}
|
||||||
54
src/generator_entity/entities/RongdouHistory.ts
Normal file
54
src/generator_entity/entities/RongdouHistory.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
import { Orders } from "./Orders";
|
||||||
|
|
||||||
|
@Index("order_id", ["orderId"], {})
|
||||||
|
@Index("user_id", ["userId"], {})
|
||||||
|
@Entity("rongdou_history", { schema: "test" })
|
||||||
|
export class RongdouHistory {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "user_id" })
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column("enum", { name: "type", enum: ["earn", "spend"] })
|
||||||
|
type: "earn" | "spend";
|
||||||
|
|
||||||
|
@Column("int", { name: "amount" })
|
||||||
|
amount: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "description", nullable: true, length: 255 })
|
||||||
|
description: string | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "order_id", nullable: true })
|
||||||
|
orderId: number | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.rongdouHistories, {
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "user_id", referencedColumnName: "id" }])
|
||||||
|
user: Users;
|
||||||
|
|
||||||
|
@ManyToOne(() => Orders, (orders) => orders.rongdouHistories, {
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "order_id", referencedColumnName: "id" }])
|
||||||
|
order: Orders;
|
||||||
|
}
|
||||||
66
src/generator_entity/entities/SpecNames.ts
Normal file
66
src/generator_entity/entities/SpecNames.ts
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
OneToMany,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { ProductSpecNames } from "./ProductSpecNames";
|
||||||
|
import { SpecValues } from "./SpecValues";
|
||||||
|
|
||||||
|
@Index("unique_name", ["name"], { unique: true })
|
||||||
|
@Entity("spec_names", { schema: "test" })
|
||||||
|
export class SpecNames {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "name",
|
||||||
|
unique: true,
|
||||||
|
comment: "规格名称,如:颜色、尺寸、材质",
|
||||||
|
length: 100,
|
||||||
|
})
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "display_name", comment: "显示名称", length: 100 })
|
||||||
|
displayName: string;
|
||||||
|
|
||||||
|
@Column("int", {
|
||||||
|
name: "sort_order",
|
||||||
|
nullable: true,
|
||||||
|
comment: "排序",
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
sortOrder: number | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "status",
|
||||||
|
nullable: true,
|
||||||
|
enum: ["active", "inactive"],
|
||||||
|
default: () => "'active'",
|
||||||
|
})
|
||||||
|
status: "active" | "inactive" | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => ProductSpecNames,
|
||||||
|
(productSpecNames) => productSpecNames.specName
|
||||||
|
)
|
||||||
|
productSpecNames: ProductSpecNames[];
|
||||||
|
|
||||||
|
@OneToMany(() => SpecValues, (specValues) => specValues.specName)
|
||||||
|
specValues: SpecValues[];
|
||||||
|
}
|
||||||
82
src/generator_entity/entities/SpecValues.ts
Normal file
82
src/generator_entity/entities/SpecValues.ts
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { SpecNames } from "./SpecNames";
|
||||||
|
|
||||||
|
@Index("unique_spec_value", ["specNameId", "value"], { unique: true })
|
||||||
|
@Entity("spec_values", { schema: "test" })
|
||||||
|
export class SpecValues {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "spec_name_id", comment: "规格名称ID" })
|
||||||
|
specNameId: number;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "value",
|
||||||
|
comment: "规格值,如:红色、XL、棉质",
|
||||||
|
length: 100,
|
||||||
|
})
|
||||||
|
value: string;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "display_value", comment: "显示值", length: 100 })
|
||||||
|
displayValue: string;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "color_code",
|
||||||
|
nullable: true,
|
||||||
|
comment: "颜色代码(仅颜色规格使用)",
|
||||||
|
length: 20,
|
||||||
|
})
|
||||||
|
colorCode: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "image_url",
|
||||||
|
nullable: true,
|
||||||
|
comment: "规格图片",
|
||||||
|
length: 500,
|
||||||
|
})
|
||||||
|
imageUrl: string | null;
|
||||||
|
|
||||||
|
@Column("int", {
|
||||||
|
name: "sort_order",
|
||||||
|
nullable: true,
|
||||||
|
comment: "排序",
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
sortOrder: number | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "status",
|
||||||
|
nullable: true,
|
||||||
|
enum: ["active", "inactive"],
|
||||||
|
default: () => "'active'",
|
||||||
|
})
|
||||||
|
status: "active" | "inactive" | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => SpecNames, (specNames) => specNames.specValues, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "spec_name_id", referencedColumnName: "id" }])
|
||||||
|
specName: SpecNames;
|
||||||
|
}
|
||||||
31
src/generator_entity/entities/SystemSettings.ts
Normal file
31
src/generator_entity/entities/SystemSettings.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
|
||||||
|
@Index("setting_key", ["settingKey"], { unique: true })
|
||||||
|
@Entity("system_settings", { schema: "test" })
|
||||||
|
export class SystemSettings {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "setting_key", unique: true, length: 100 })
|
||||||
|
settingKey: string;
|
||||||
|
|
||||||
|
@Column("text", { name: "setting_value", nullable: true })
|
||||||
|
settingValue: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "description", nullable: true, length: 255 })
|
||||||
|
description: string | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
}
|
||||||
23
src/generator_entity/entities/TestUsers.ts
Normal file
23
src/generator_entity/entities/TestUsers.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
|
||||||
|
@Entity("test_users", { schema: "test" })
|
||||||
|
export class TestUsers {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "username", length: 50 })
|
||||||
|
username: string;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "email", length: 100 })
|
||||||
|
email: string;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", { name: "updated_at", nullable: true })
|
||||||
|
updatedAt: Date | null;
|
||||||
|
}
|
||||||
51
src/generator_entity/entities/TransferConfirmations.ts
Normal file
51
src/generator_entity/entities/TransferConfirmations.ts
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { Transfers } from "./Transfers";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
|
||||||
|
@Index("confirmer_id", ["confirmerId"], {})
|
||||||
|
@Index("transfer_id", ["transferId"], {})
|
||||||
|
@Entity("transfer_confirmations", { schema: "test" })
|
||||||
|
export class TransferConfirmations {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "transfer_id" })
|
||||||
|
transferId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "confirmer_id" })
|
||||||
|
confirmerId: number;
|
||||||
|
|
||||||
|
@Column("enum", { name: "action", enum: ["confirm", "reject"] })
|
||||||
|
action: "confirm" | "reject";
|
||||||
|
|
||||||
|
@Column("text", { name: "note", nullable: true })
|
||||||
|
note: string | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => Transfers, (transfers) => transfers.transferConfirmations, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "transfer_id", referencedColumnName: "id" }])
|
||||||
|
transfer: Transfers;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.transferConfirmations, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "confirmer_id", referencedColumnName: "id" }])
|
||||||
|
confirmer: Users;
|
||||||
|
}
|
||||||
256
src/generator_entity/entities/Transfers.ts
Normal file
256
src/generator_entity/entities/Transfers.ts
Normal file
@@ -0,0 +1,256 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
OneToMany,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { OrderAllocations } from "./OrderAllocations";
|
||||||
|
import { TransferConfirmations } from "./TransferConfirmations";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
|
||||||
|
@Index("from_user_id", ["fromUserId"], {})
|
||||||
|
@Index("to_user_id", ["toUserId"], {})
|
||||||
|
@Entity("transfers", { schema: "test" })
|
||||||
|
export class Transfers {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "from_user_id", nullable: true })
|
||||||
|
fromUserId: number | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "to_user_id" })
|
||||||
|
toUserId: number;
|
||||||
|
|
||||||
|
@Column("decimal", { name: "amount", precision: 10, scale: 2 })
|
||||||
|
amount: string;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "transfer_type",
|
||||||
|
nullable: true,
|
||||||
|
enum: [
|
||||||
|
"initial",
|
||||||
|
"return",
|
||||||
|
"user_to_user",
|
||||||
|
"system_to_user",
|
||||||
|
"user_to_system",
|
||||||
|
"user_to_agent",
|
||||||
|
"user_to_operated",
|
||||||
|
"agent_to_operated",
|
||||||
|
"user_to_regional",
|
||||||
|
],
|
||||||
|
default: () => "'user_to_user'",
|
||||||
|
})
|
||||||
|
transferType:
|
||||||
|
| "initial"
|
||||||
|
| "return"
|
||||||
|
| "user_to_user"
|
||||||
|
| "system_to_user"
|
||||||
|
| "user_to_system"
|
||||||
|
| "user_to_agent"
|
||||||
|
| "user_to_operated"
|
||||||
|
| "agent_to_operated"
|
||||||
|
| "user_to_regional"
|
||||||
|
| null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "status",
|
||||||
|
nullable: true,
|
||||||
|
enum: [
|
||||||
|
"pending",
|
||||||
|
"confirmed",
|
||||||
|
"rejected",
|
||||||
|
"received",
|
||||||
|
"not_received",
|
||||||
|
"cancelled",
|
||||||
|
],
|
||||||
|
default: () => "'pending'",
|
||||||
|
})
|
||||||
|
status:
|
||||||
|
| "pending"
|
||||||
|
| "confirmed"
|
||||||
|
| "rejected"
|
||||||
|
| "received"
|
||||||
|
| "not_received"
|
||||||
|
| "cancelled"
|
||||||
|
| null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "voucher_url", nullable: true, length: 500 })
|
||||||
|
voucherUrl: string | null;
|
||||||
|
|
||||||
|
@Column("text", { name: "description", nullable: true })
|
||||||
|
description: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "batch_id", nullable: true, length: 50 })
|
||||||
|
batchId: string | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "deadline_at",
|
||||||
|
nullable: true,
|
||||||
|
comment: "转账截止时间",
|
||||||
|
})
|
||||||
|
deadlineAt: Date | null;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_overdue",
|
||||||
|
nullable: true,
|
||||||
|
comment: "是否超时",
|
||||||
|
width: 1,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
isOverdue: boolean | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "overdue_at",
|
||||||
|
nullable: true,
|
||||||
|
comment: "超时时间",
|
||||||
|
})
|
||||||
|
overdueAt: Date | null;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_bad_debt",
|
||||||
|
nullable: true,
|
||||||
|
width: 1,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
isBadDebt: boolean | null;
|
||||||
|
|
||||||
|
@Column("timestamp", { name: "confirmed_at", nullable: true })
|
||||||
|
confirmedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("text", { name: "admin_note", nullable: true })
|
||||||
|
adminNote: string | null;
|
||||||
|
|
||||||
|
@Column("timestamp", { name: "admin_modified_at", nullable: true })
|
||||||
|
adminModifiedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "admin_modified_by", nullable: true })
|
||||||
|
adminModifiedBy: number | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "source_type",
|
||||||
|
nullable: true,
|
||||||
|
comment: "转账来源类型",
|
||||||
|
enum: [
|
||||||
|
"manual",
|
||||||
|
"allocation",
|
||||||
|
"system",
|
||||||
|
"agent",
|
||||||
|
"directly_operated",
|
||||||
|
"agent_operated",
|
||||||
|
"operated_agent",
|
||||||
|
"withdraw",
|
||||||
|
"operated",
|
||||||
|
],
|
||||||
|
default: () => "'manual'",
|
||||||
|
})
|
||||||
|
sourceType:
|
||||||
|
| "manual"
|
||||||
|
| "allocation"
|
||||||
|
| "system"
|
||||||
|
| "agent"
|
||||||
|
| "directly_operated"
|
||||||
|
| "agent_operated"
|
||||||
|
| "operated_agent"
|
||||||
|
| "withdraw"
|
||||||
|
| "operated"
|
||||||
|
| null;
|
||||||
|
|
||||||
|
@Column("int", { name: "matching_order_id", nullable: true })
|
||||||
|
matchingOrderId: number | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "cycle_number", nullable: true })
|
||||||
|
cycleNumber: number | null;
|
||||||
|
|
||||||
|
@Column("date", { name: "outbound_date", nullable: true })
|
||||||
|
outboundDate: string | null;
|
||||||
|
|
||||||
|
@Column("date", { name: "return_date", nullable: true })
|
||||||
|
returnDate: string | null;
|
||||||
|
|
||||||
|
@Column("timestamp", { name: "can_return_after", nullable: true })
|
||||||
|
canReturnAfter: Date | null;
|
||||||
|
|
||||||
|
@Column("decimal", {
|
||||||
|
name: "from_user_balance",
|
||||||
|
nullable: true,
|
||||||
|
precision: 10,
|
||||||
|
scale: 2,
|
||||||
|
default: () => "'0.00'",
|
||||||
|
})
|
||||||
|
fromUserBalance: string | null;
|
||||||
|
|
||||||
|
@Column("decimal", {
|
||||||
|
name: "to_user_balance",
|
||||||
|
nullable: true,
|
||||||
|
precision: 10,
|
||||||
|
scale: 2,
|
||||||
|
default: () => "'0.00'",
|
||||||
|
})
|
||||||
|
toUserBalance: string | null;
|
||||||
|
|
||||||
|
@Column("decimal", {
|
||||||
|
name: "balance_diff",
|
||||||
|
nullable: true,
|
||||||
|
precision: 10,
|
||||||
|
scale: 2,
|
||||||
|
default: () => "'0.00'",
|
||||||
|
})
|
||||||
|
balanceDiff: string | null;
|
||||||
|
|
||||||
|
@Column("decimal", {
|
||||||
|
name: "near_payment",
|
||||||
|
nullable: true,
|
||||||
|
precision: 10,
|
||||||
|
scale: 2,
|
||||||
|
})
|
||||||
|
nearPayment: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "pay_method", nullable: true, length: 255 })
|
||||||
|
payMethod: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "describe_orc", nullable: true, length: 9064 })
|
||||||
|
describeOrc: string | null;
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => OrderAllocations,
|
||||||
|
(orderAllocations) => orderAllocations.transfer
|
||||||
|
)
|
||||||
|
orderAllocations: OrderAllocations[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => TransferConfirmations,
|
||||||
|
(transferConfirmations) => transferConfirmations.transfer
|
||||||
|
)
|
||||||
|
transferConfirmations: TransferConfirmations[];
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.transfers, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "from_user_id", referencedColumnName: "id" }])
|
||||||
|
fromUser: Users;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.transfers2, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "to_user_id", referencedColumnName: "id" }])
|
||||||
|
toUser: Users;
|
||||||
|
}
|
||||||
77
src/generator_entity/entities/UserAddresses.ts
Normal file
77
src/generator_entity/entities/UserAddresses.ts
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
|
||||||
|
@Index("user_id", ["userId"], {})
|
||||||
|
@Entity("user_addresses", { schema: "test" })
|
||||||
|
export class UserAddresses {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "user_id" })
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "receiver_name", length: 100 })
|
||||||
|
receiverName: string;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "receiver_phone", length: 20 })
|
||||||
|
receiverPhone: string;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "province", length: 50 })
|
||||||
|
province: string;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "city", length: 50 })
|
||||||
|
city: string;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "district", length: 50 })
|
||||||
|
district: string;
|
||||||
|
|
||||||
|
@Column("text", { name: "detailed_address" })
|
||||||
|
detailedAddress: string;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "postal_code", nullable: true, length: 10 })
|
||||||
|
postalCode: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "label",
|
||||||
|
nullable: true,
|
||||||
|
length: 50,
|
||||||
|
default: () => "'家'",
|
||||||
|
})
|
||||||
|
label: string | null;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_default",
|
||||||
|
nullable: true,
|
||||||
|
width: 1,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
isDefault: boolean | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.userAddresses, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "user_id", referencedColumnName: "id" }])
|
||||||
|
user: Users;
|
||||||
|
}
|
||||||
71
src/generator_entity/entities/UserAnnouncementReads.ts
Normal file
71
src/generator_entity/entities/UserAnnouncementReads.ts
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
import { Announcements } from "./Announcements";
|
||||||
|
|
||||||
|
@Index("idx_announcement_id", ["announcementId"], {})
|
||||||
|
@Index("idx_is_read", ["isRead"], {})
|
||||||
|
@Index("idx_user_id", ["userId"], {})
|
||||||
|
@Index("unique_user_announcement", ["userId", "announcementId"], {
|
||||||
|
unique: true,
|
||||||
|
})
|
||||||
|
@Entity("user_announcement_reads", { schema: "test" })
|
||||||
|
export class UserAnnouncementReads {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "user_id", comment: "用户ID" })
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "announcement_id", comment: "公告ID" })
|
||||||
|
announcementId: number;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_read",
|
||||||
|
nullable: true,
|
||||||
|
comment: "是否已读",
|
||||||
|
width: 1,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
isRead: boolean | null;
|
||||||
|
|
||||||
|
@Column("timestamp", { name: "read_at", nullable: true, comment: "阅读时间" })
|
||||||
|
readAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
comment: "创建时间",
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
comment: "更新时间",
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, (users) => users.userAnnouncementReads, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "user_id", referencedColumnName: "id" }])
|
||||||
|
user: Users;
|
||||||
|
|
||||||
|
@ManyToOne(
|
||||||
|
() => Announcements,
|
||||||
|
(announcements) => announcements.userAnnouncementReads,
|
||||||
|
{ onDelete: "CASCADE", onUpdate: "RESTRICT" }
|
||||||
|
)
|
||||||
|
@JoinColumn([{ name: "announcement_id", referencedColumnName: "id" }])
|
||||||
|
announcement: Announcements;
|
||||||
|
}
|
||||||
60
src/generator_entity/entities/UserMatchingPool.ts
Normal file
60
src/generator_entity/entities/UserMatchingPool.ts
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
OneToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { Users } from "./Users";
|
||||||
|
|
||||||
|
@Index("unique_user", ["userId"], { unique: true })
|
||||||
|
@Entity("user_matching_pool", { schema: "test" })
|
||||||
|
export class UserMatchingPool {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("int", { name: "user_id", unique: true })
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column("decimal", {
|
||||||
|
name: "available_amount",
|
||||||
|
nullable: true,
|
||||||
|
precision: 10,
|
||||||
|
scale: 2,
|
||||||
|
default: () => "'0.00'",
|
||||||
|
})
|
||||||
|
availableAmount: string | null;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_active",
|
||||||
|
nullable: true,
|
||||||
|
width: 1,
|
||||||
|
default: () => "'1'",
|
||||||
|
})
|
||||||
|
isActive: boolean | null;
|
||||||
|
|
||||||
|
@Column("timestamp", { name: "last_matched_at", nullable: true })
|
||||||
|
lastMatchedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@OneToOne(() => Users, (users) => users.userMatchingPool, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
@JoinColumn([{ name: "user_id", referencedColumnName: "id" }])
|
||||||
|
user: Users;
|
||||||
|
}
|
||||||
356
src/generator_entity/entities/Users.ts
Normal file
356
src/generator_entity/entities/Users.ts
Normal file
@@ -0,0 +1,356 @@
|
|||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
OneToMany,
|
||||||
|
OneToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from "typeorm";
|
||||||
|
import { AddressLabels } from "./AddressLabels";
|
||||||
|
import { AdminOperationLogs } from "./AdminOperationLogs";
|
||||||
|
import { AgentCommissionRecords } from "./AgentCommissionRecords";
|
||||||
|
import { AgentMerchants } from "./AgentMerchants";
|
||||||
|
import { AgentWithdrawals } from "./AgentWithdrawals";
|
||||||
|
import { Announcements } from "./Announcements";
|
||||||
|
import { Articles } from "./Articles";
|
||||||
|
import { MatchingOrders } from "./MatchingOrders";
|
||||||
|
import { MatchingRecords } from "./MatchingRecords";
|
||||||
|
import { OrderAllocations } from "./OrderAllocations";
|
||||||
|
import { Orders } from "./Orders";
|
||||||
|
import { PointsHistory } from "./PointsHistory";
|
||||||
|
import { ProductFavorites } from "./ProductFavorites";
|
||||||
|
import { ProductReviews } from "./ProductReviews";
|
||||||
|
import { RegionalAgents } from "./RegionalAgents";
|
||||||
|
import { RegistrationCodes } from "./RegistrationCodes";
|
||||||
|
import { RongdouHistory } from "./RongdouHistory";
|
||||||
|
import { TransferConfirmations } from "./TransferConfirmations";
|
||||||
|
import { Transfers } from "./Transfers";
|
||||||
|
import { UserAddresses } from "./UserAddresses";
|
||||||
|
import { UserAnnouncementReads } from "./UserAnnouncementReads";
|
||||||
|
import { UserMatchingPool } from "./UserMatchingPool";
|
||||||
|
|
||||||
|
@Index("email", ["email"], { unique: true })
|
||||||
|
@Index("idx_payment_status", ["paymentStatus"], {})
|
||||||
|
@Index("phone", ["phone"], { unique: true })
|
||||||
|
@Index("username", ["username"], { unique: true })
|
||||||
|
@Entity("users", { schema: "test" })
|
||||||
|
export class Users {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "username", unique: true, length: 50 })
|
||||||
|
username: string;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "email",
|
||||||
|
nullable: true,
|
||||||
|
unique: true,
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
email: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "password", length: 255 })
|
||||||
|
password: string;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "role",
|
||||||
|
nullable: true,
|
||||||
|
enum: ["user", "admin"],
|
||||||
|
default: () => "'user'",
|
||||||
|
})
|
||||||
|
role: "user" | "admin" | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "avatar", nullable: true, length: 255 })
|
||||||
|
avatar: string | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "updated_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
updatedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "points", nullable: true, default: () => "'0'" })
|
||||||
|
points: number | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "real_name", nullable: true, length: 100 })
|
||||||
|
realName: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "id_card", nullable: true, length: 18 })
|
||||||
|
idCard: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "wechat_qr", nullable: true, length: 255 })
|
||||||
|
wechatQr: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "alipay_qr", nullable: true, length: 255 })
|
||||||
|
alipayQr: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "bank_card", nullable: true, length: 30 })
|
||||||
|
bankCard: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "unionpay_qr", nullable: true, length: 255 })
|
||||||
|
unionpayQr: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "phone",
|
||||||
|
nullable: true,
|
||||||
|
unique: true,
|
||||||
|
length: 20,
|
||||||
|
})
|
||||||
|
phone: string | null;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_system_account",
|
||||||
|
nullable: true,
|
||||||
|
width: 1,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
isSystemAccount: boolean | null;
|
||||||
|
|
||||||
|
@Column("int", {
|
||||||
|
name: "completed_withdrawals",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
completedWithdrawals: number | null;
|
||||||
|
|
||||||
|
@Column("decimal", {
|
||||||
|
name: "balance",
|
||||||
|
nullable: true,
|
||||||
|
precision: 10,
|
||||||
|
scale: 2,
|
||||||
|
default: () => "'0.00'",
|
||||||
|
})
|
||||||
|
balance: string | null;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_risk_user",
|
||||||
|
nullable: true,
|
||||||
|
comment: "是否为风险用户",
|
||||||
|
width: 1,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
isRiskUser: boolean | null;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_blacklisted",
|
||||||
|
nullable: true,
|
||||||
|
comment: "是否被拉黑",
|
||||||
|
width: 1,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
isBlacklisted: boolean | null;
|
||||||
|
|
||||||
|
@Column("text", { name: "risk_reason", nullable: true, comment: "风险原因" })
|
||||||
|
riskReason: string | null;
|
||||||
|
|
||||||
|
@Column("text", {
|
||||||
|
name: "blacklist_reason",
|
||||||
|
nullable: true,
|
||||||
|
comment: "拉黑原因",
|
||||||
|
})
|
||||||
|
blacklistReason: string | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "blacklisted_at",
|
||||||
|
nullable: true,
|
||||||
|
comment: "拉黑时间",
|
||||||
|
})
|
||||||
|
blacklistedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "business_license", nullable: true, length: 500 })
|
||||||
|
businessLicense: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "id_card_front", nullable: true, length: 500 })
|
||||||
|
idCardFront: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "id_card_back", nullable: true, length: 500 })
|
||||||
|
idCardBack: string | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "audit_status",
|
||||||
|
nullable: true,
|
||||||
|
enum: ["pending", "approved", "rejected"],
|
||||||
|
default: () => "'pending'",
|
||||||
|
})
|
||||||
|
auditStatus: "pending" | "approved" | "rejected" | null;
|
||||||
|
|
||||||
|
@Column("text", { name: "audit_note", nullable: true })
|
||||||
|
auditNote: string | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "audited_by", nullable: true })
|
||||||
|
auditedBy: number | null;
|
||||||
|
|
||||||
|
@Column("timestamp", { name: "audited_at", nullable: true })
|
||||||
|
auditedAt: Date | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "city",
|
||||||
|
nullable: true,
|
||||||
|
comment: "城市",
|
||||||
|
length: 50,
|
||||||
|
})
|
||||||
|
city: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "district_id",
|
||||||
|
nullable: true,
|
||||||
|
comment: "区县",
|
||||||
|
length: 50,
|
||||||
|
})
|
||||||
|
districtId: string | null;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_distribute",
|
||||||
|
nullable: true,
|
||||||
|
width: 1,
|
||||||
|
default: () => "'0'",
|
||||||
|
})
|
||||||
|
isDistribute: boolean | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "payment_status",
|
||||||
|
comment: "支付状态",
|
||||||
|
enum: ["unpaid", "paid"],
|
||||||
|
default: () => "'unpaid'",
|
||||||
|
})
|
||||||
|
paymentStatus: "unpaid" | "paid";
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
name: "province",
|
||||||
|
nullable: true,
|
||||||
|
comment: "省",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
province: string | null;
|
||||||
|
|
||||||
|
@Column("int", { name: "inviter", nullable: true, comment: "分销上级id" })
|
||||||
|
inviter: number | null;
|
||||||
|
|
||||||
|
@Column("enum", {
|
||||||
|
name: "user_type",
|
||||||
|
nullable: true,
|
||||||
|
comment: "用户类型",
|
||||||
|
enum: ["user", "directly_operated", "agent", "agent_directly"],
|
||||||
|
default: () => "'user'",
|
||||||
|
})
|
||||||
|
userType: "user" | "directly_operated" | "agent" | "agent_directly" | null;
|
||||||
|
|
||||||
|
@OneToMany(() => AddressLabels, (addressLabels) => addressLabels.user)
|
||||||
|
addressLabels: AddressLabels[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => AdminOperationLogs,
|
||||||
|
(adminOperationLogs) => adminOperationLogs.admin
|
||||||
|
)
|
||||||
|
adminOperationLogs: AdminOperationLogs[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => AgentCommissionRecords,
|
||||||
|
(agentCommissionRecords) => agentCommissionRecords.merchant
|
||||||
|
)
|
||||||
|
agentCommissionRecords: AgentCommissionRecords[];
|
||||||
|
|
||||||
|
@OneToMany(() => AgentMerchants, (agentMerchants) => agentMerchants.merchant)
|
||||||
|
agentMerchants: AgentMerchants[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => AgentWithdrawals,
|
||||||
|
(agentWithdrawals) => agentWithdrawals.processedBy2
|
||||||
|
)
|
||||||
|
agentWithdrawals: AgentWithdrawals[];
|
||||||
|
|
||||||
|
@OneToMany(() => Announcements, (announcements) => announcements.createdBy2)
|
||||||
|
announcements: Announcements[];
|
||||||
|
|
||||||
|
@OneToMany(() => Articles, (articles) => articles.author)
|
||||||
|
articles: Articles[];
|
||||||
|
|
||||||
|
@OneToMany(() => MatchingOrders, (matchingOrders) => matchingOrders.initiator)
|
||||||
|
matchingOrders: MatchingOrders[];
|
||||||
|
|
||||||
|
@OneToMany(() => MatchingRecords, (matchingRecords) => matchingRecords.user)
|
||||||
|
matchingRecords: MatchingRecords[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => OrderAllocations,
|
||||||
|
(orderAllocations) => orderAllocations.fromUser
|
||||||
|
)
|
||||||
|
orderAllocations: OrderAllocations[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => OrderAllocations,
|
||||||
|
(orderAllocations) => orderAllocations.toUser
|
||||||
|
)
|
||||||
|
orderAllocations2: OrderAllocations[];
|
||||||
|
|
||||||
|
@OneToMany(() => Orders, (orders) => orders.user)
|
||||||
|
orders: Orders[];
|
||||||
|
|
||||||
|
@OneToMany(() => PointsHistory, (pointsHistory) => pointsHistory.user)
|
||||||
|
pointsHistories: PointsHistory[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => ProductFavorites,
|
||||||
|
(productFavorites) => productFavorites.user
|
||||||
|
)
|
||||||
|
productFavorites: ProductFavorites[];
|
||||||
|
|
||||||
|
@OneToMany(() => ProductReviews, (productReviews) => productReviews.user)
|
||||||
|
productReviews: ProductReviews[];
|
||||||
|
|
||||||
|
@OneToMany(() => RegionalAgents, (regionalAgents) => regionalAgents.user)
|
||||||
|
regionalAgents: RegionalAgents[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => RegistrationCodes,
|
||||||
|
(registrationCodes) => registrationCodes.agent
|
||||||
|
)
|
||||||
|
registrationCodes: RegistrationCodes[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => RegistrationCodes,
|
||||||
|
(registrationCodes) => registrationCodes.usedByUser
|
||||||
|
)
|
||||||
|
registrationCodes2: RegistrationCodes[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => RegistrationCodes,
|
||||||
|
(registrationCodes) => registrationCodes.createdByAdmin
|
||||||
|
)
|
||||||
|
registrationCodes3: RegistrationCodes[];
|
||||||
|
|
||||||
|
@OneToMany(() => RongdouHistory, (rongdouHistory) => rongdouHistory.user)
|
||||||
|
rongdouHistories: RongdouHistory[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => TransferConfirmations,
|
||||||
|
(transferConfirmations) => transferConfirmations.confirmer
|
||||||
|
)
|
||||||
|
transferConfirmations: TransferConfirmations[];
|
||||||
|
|
||||||
|
@OneToMany(() => Transfers, (transfers) => transfers.fromUser)
|
||||||
|
transfers: Transfers[];
|
||||||
|
|
||||||
|
@OneToMany(() => Transfers, (transfers) => transfers.toUser)
|
||||||
|
transfers2: Transfers[];
|
||||||
|
|
||||||
|
@OneToMany(() => UserAddresses, (userAddresses) => userAddresses.user)
|
||||||
|
userAddresses: UserAddresses[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => UserAnnouncementReads,
|
||||||
|
(userAnnouncementReads) => userAnnouncementReads.user
|
||||||
|
)
|
||||||
|
userAnnouncementReads: UserAnnouncementReads[];
|
||||||
|
|
||||||
|
@OneToOne(() => UserMatchingPool, (userMatchingPool) => userMatchingPool.user)
|
||||||
|
userMatchingPool: UserMatchingPool;
|
||||||
|
}
|
||||||
33
src/generator_entity/entities/ZhejiangRegions.ts
Normal file
33
src/generator_entity/entities/ZhejiangRegions.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
|
||||||
|
@Index("region_code", ["regionCode"], { unique: true })
|
||||||
|
@Index("unique_region", ["cityName", "districtName"], { unique: true })
|
||||||
|
@Entity("zhejiang_regions", { schema: "test" })
|
||||||
|
export class ZhejiangRegions {
|
||||||
|
@PrimaryGeneratedColumn({ type: "int", name: "id" })
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "city_name", length: 50 })
|
||||||
|
cityName: string;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "district_name", length: 50 })
|
||||||
|
districtName: string;
|
||||||
|
|
||||||
|
@Column("varchar", { name: "region_code", unique: true, length: 20 })
|
||||||
|
regionCode: string;
|
||||||
|
|
||||||
|
@Column("tinyint", {
|
||||||
|
name: "is_available",
|
||||||
|
nullable: true,
|
||||||
|
width: 1,
|
||||||
|
default: () => "'1'",
|
||||||
|
})
|
||||||
|
isAvailable: boolean | null;
|
||||||
|
|
||||||
|
@Column("timestamp", {
|
||||||
|
name: "created_at",
|
||||||
|
nullable: true,
|
||||||
|
default: () => "CURRENT_TIMESTAMP",
|
||||||
|
})
|
||||||
|
createdAt: Date | null;
|
||||||
|
}
|
||||||
13
src/generator_entity/ormconfig.json
Normal file
13
src/generator_entity/ormconfig.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "default",
|
||||||
|
"type": "mysql",
|
||||||
|
"host": "192.168.0.4",
|
||||||
|
"port": 3306,
|
||||||
|
"username": "test",
|
||||||
|
"password": "n6M2XrssM2YpM5Mi",
|
||||||
|
"database": "",
|
||||||
|
"synchronize": false,
|
||||||
|
"entities": ["entities/*.js"]
|
||||||
|
}
|
||||||
|
]
|
||||||
10
src/generator_entity/tsconfig.json
Normal file
10
src/generator_entity/tsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es2017",
|
||||||
|
"module": "commonjs",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"sourceMap": true
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/main.ts
Normal file
25
src/main.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { NestFactory } from '@nestjs/core';
|
||||||
|
import { AppModule } from './app.module';
|
||||||
|
import cors from 'cors';
|
||||||
|
|
||||||
|
async function bootstrap() {
|
||||||
|
const app = await NestFactory.create(AppModule);
|
||||||
|
app.use(cors({
|
||||||
|
origin: [
|
||||||
|
'http://localhost:5173',
|
||||||
|
'http://localhost:5176',
|
||||||
|
'http://localhost:5175',
|
||||||
|
'http://localhost:5174',
|
||||||
|
'http://localhost:3001',
|
||||||
|
'http://localhost:3006',
|
||||||
|
'http://localhost:3007',
|
||||||
|
'https://www.zrbjr.com',
|
||||||
|
'https://zrbjr.com'
|
||||||
|
],
|
||||||
|
credentials: true,
|
||||||
|
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
|
||||||
|
allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With']
|
||||||
|
}));
|
||||||
|
await app.listen(process.env.PORT ?? 3007);
|
||||||
|
}
|
||||||
|
bootstrap();
|
||||||
70
src/service/chat.gateway.ts
Normal file
70
src/service/chat.gateway.ts
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import {
|
||||||
|
MessageBody,
|
||||||
|
SubscribeMessage,
|
||||||
|
WebSocketGateway,
|
||||||
|
WebSocketServer,
|
||||||
|
ConnectedSocket, OnGatewayInit
|
||||||
|
} from '@nestjs/websockets';
|
||||||
|
|
||||||
|
import {Server, Socket} from 'socket.io';
|
||||||
|
import {ProgramGroupEntity, ProgramGroupMessageEntity, UsersEntity} from "../entity";
|
||||||
|
import {InjectRepository} from "@nestjs/typeorm";
|
||||||
|
import {Repository} from "typeorm";
|
||||||
|
|
||||||
|
@WebSocketGateway({
|
||||||
|
cors: {
|
||||||
|
origin: '*',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
export class ChatGateway implements OnGatewayInit {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@InjectRepository(ProgramGroupMessageEntity) private readonly messageRepository: Repository<ProgramGroupMessageEntity>,
|
||||||
|
@InjectRepository(ProgramGroupEntity) private readonly groupRepository: Repository<ProgramGroupEntity>,
|
||||||
|
@InjectRepository(UsersEntity) private readonly usersRepository: Repository<UsersEntity>,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@WebSocketServer()
|
||||||
|
server: Server;
|
||||||
|
|
||||||
|
afterInit(server: any) {
|
||||||
|
console.log("ChatGateway === 初始化成功")
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加入群组
|
||||||
|
* @param groupEntity
|
||||||
|
*/
|
||||||
|
@SubscribeMessage('addGroup')
|
||||||
|
async createGroup(@ConnectedSocket() client: Socket, @MessageBody() groupEntity: ProgramGroupEntity): Promise<any> {
|
||||||
|
// 查找群组信息
|
||||||
|
let group = await this.groupRepository.findOne({
|
||||||
|
where: {
|
||||||
|
groupId: groupEntity.groupId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (group != null) {
|
||||||
|
client.join(group.groupId.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接收客户端消息
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
@SubscribeMessage('clientMsg')
|
||||||
|
async clientMessage(@MessageBody() data: ProgramGroupMessageEntity): Promise<any> {
|
||||||
|
// 保存记录
|
||||||
|
let saveMessage = await this.messageRepository.save(data)
|
||||||
|
|
||||||
|
saveMessage.userInfo = await this.usersRepository.findOne({
|
||||||
|
where: {
|
||||||
|
id: saveMessage.createId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.server.to(data.groupId.toString()).emit('serverMsg', saveMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
2
src/service/index.ts
Normal file
2
src/service/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './programGroupService.service'
|
||||||
|
export * from './chat.gateway'
|
||||||
122
src/service/programGroupService.service.ts
Normal file
122
src/service/programGroupService.service.ts
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
import {Injectable} from '@nestjs/common';
|
||||||
|
import {InjectRepository} from "@nestjs/typeorm";
|
||||||
|
import {ProgramEntity, ProgramGroupEntity, UsersEntity} from "../entity";
|
||||||
|
import {Repository} from "typeorm";
|
||||||
|
import {ResultData} from "../const/result";
|
||||||
|
import {isEmptyString} from "../utils/common";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ProgramGroupService {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@InjectRepository(ProgramGroupEntity) private readonly programGroupRepository: Repository<ProgramGroupEntity>,
|
||||||
|
@InjectRepository(ProgramEntity) private readonly programRepository: Repository<ProgramEntity>,
|
||||||
|
@InjectRepository(UsersEntity) private readonly usersRepository: Repository<UsersEntity>,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async add(programGroup: ProgramGroupEntity) {
|
||||||
|
try {
|
||||||
|
// 前置判断
|
||||||
|
// 判断是否为空
|
||||||
|
if (isEmptyString(programGroup.programId) || isEmptyString(programGroup.userId)) {
|
||||||
|
return ResultData.fail(500, "参数不能为空")
|
||||||
|
}
|
||||||
|
// 查找program信息
|
||||||
|
let program = await this.programRepository.findOne({
|
||||||
|
where: {
|
||||||
|
id: programGroup.programId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (program == null) {
|
||||||
|
return ResultData.fail(500, "未找到项目信息")
|
||||||
|
}
|
||||||
|
// 用户是否有权限发起群组(本人不行,系统用户不行,创建过同样会话不行)
|
||||||
|
if (programGroup.userId == program.linkmanId) {
|
||||||
|
return ResultData.fail(500, "不能创建自己的项目群组")
|
||||||
|
}
|
||||||
|
let user = await this.usersRepository.findOne({
|
||||||
|
where: {
|
||||||
|
id: programGroup.userId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (user?.isSystemAccount) {
|
||||||
|
return ResultData.fail(500, "系统用户不能创建群组")
|
||||||
|
}
|
||||||
|
let groups = await this.programGroupRepository.find({
|
||||||
|
where: {
|
||||||
|
programId: programGroup.programId,
|
||||||
|
userId: programGroup.userId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (groups.length > 0) {
|
||||||
|
return ResultData.fail(500, "已经创建过群组")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 匹配客服
|
||||||
|
let customers = await this.usersRepository.findBy({userType: "customer"});
|
||||||
|
if (customers.length == 0) {
|
||||||
|
return ResultData.fail(500, "没有客服人员")
|
||||||
|
}
|
||||||
|
|
||||||
|
let customerList = await this.usersRepository.createQueryBuilder("users")
|
||||||
|
.leftJoinAndMapMany("users.groups", "program_group", "group", "users.id = group.customer_id")
|
||||||
|
.where("users.user_type = :type", {type: "customer"})
|
||||||
|
.getMany()
|
||||||
|
|
||||||
|
// 客服分配任务量
|
||||||
|
var index = 0 // 任务最小值
|
||||||
|
for (let i = 0; i < customerList.length - 1; i++) {
|
||||||
|
if (customerList[i].groups.length > customerList[i + 1].groups.length) {
|
||||||
|
index = i + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
programGroup.customerId = customerList[index].id
|
||||||
|
|
||||||
|
// 创建聊天
|
||||||
|
programGroup.chargeId = program.linkmanId
|
||||||
|
|
||||||
|
let result = await this.programGroupRepository.save(programGroup)
|
||||||
|
return result != null ? ResultData.success("创建群组成功") : ResultData.fail(500, "创建群组失败");
|
||||||
|
} catch (err) {
|
||||||
|
return ResultData.fail(500, err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async getList(programGroup: ProgramGroupEntity) {
|
||||||
|
try {
|
||||||
|
programGroup.page = programGroup.page || 1;
|
||||||
|
programGroup.size = programGroup.size || 10;
|
||||||
|
const offset = (programGroup.page - 1) * programGroup.size;
|
||||||
|
|
||||||
|
const queryBuilder = this.programGroupRepository.createQueryBuilder("group")
|
||||||
|
queryBuilder.leftJoinAndMapOne(
|
||||||
|
"group.program",
|
||||||
|
ProgramEntity,
|
||||||
|
"program",
|
||||||
|
"group.program_id = program.id"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
queryBuilder
|
||||||
|
.orderBy('program.id', 'DESC')
|
||||||
|
.take(programGroup.size || 10)
|
||||||
|
.skip(offset || 0);
|
||||||
|
|
||||||
|
const [items, total] = await queryBuilder.getManyAndCount();
|
||||||
|
|
||||||
|
let data = {
|
||||||
|
list: items,
|
||||||
|
total,
|
||||||
|
page: programGroup.page || 1,
|
||||||
|
size: programGroup.size || 10,
|
||||||
|
pages: Math.ceil(total / (programGroup.size || 10))
|
||||||
|
}
|
||||||
|
return ResultData.success(data);
|
||||||
|
} catch (err) {
|
||||||
|
return ResultData.fail(500, err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
src/utils/common.ts
Normal file
3
src/utils/common.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export function isEmptyString(str) {
|
||||||
|
return str === null || str === '';
|
||||||
|
}
|
||||||
25
test/app.e2e-spec.ts
Normal file
25
test/app.e2e-spec.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { INestApplication } from '@nestjs/common';
|
||||||
|
import * as request from 'supertest';
|
||||||
|
import { App } from 'supertest/types';
|
||||||
|
import { AppModule } from './../src/app.module';
|
||||||
|
|
||||||
|
describe('AppController (e2e)', () => {
|
||||||
|
let app: INestApplication<App>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||||
|
imports: [AppModule],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
app = moduleFixture.createNestApplication();
|
||||||
|
await app.init();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('/ (GET)', () => {
|
||||||
|
return request(app.getHttpServer())
|
||||||
|
.get('/')
|
||||||
|
.expect(200)
|
||||||
|
.expect('Hello World!');
|
||||||
|
});
|
||||||
|
});
|
||||||
9
test/jest-e2e.json
Normal file
9
test/jest-e2e.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"moduleFileExtensions": ["js", "json", "ts"],
|
||||||
|
"rootDir": ".",
|
||||||
|
"testEnvironment": "node",
|
||||||
|
"testRegex": ".e2e-spec.ts$",
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.(t|j)s$": "ts-jest"
|
||||||
|
}
|
||||||
|
}
|
||||||
4
tsconfig.build.json
Normal file
4
tsconfig.build.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
||||||
|
}
|
||||||
25
tsconfig.json
Normal file
25
tsconfig.json
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "nodenext",
|
||||||
|
"moduleResolution": "nodenext",
|
||||||
|
"resolvePackageJsonExports": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"declaration": true,
|
||||||
|
"removeComments": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"target": "ES2023",
|
||||||
|
"sourceMap": true,
|
||||||
|
"outDir": "./dist",
|
||||||
|
"baseUrl": "./",
|
||||||
|
"incremental": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"strictBindCallApply": false,
|
||||||
|
"noFallthroughCasesInSwitch": false
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user