feat: 新增license

This commit is contained in:
小蟑螂
2026-07-06 19:34:53 +08:00
parent 8a6cb23c07
commit ac890dcc5c
110 changed files with 10678 additions and 1368 deletions
@@ -0,0 +1,33 @@
import {
Column,
CreateDateColumn,
Entity,
PrimaryGeneratedColumn,
} from 'typeorm';
@Entity('lc_activation_log')
export class LcActivationLog {
@PrimaryGeneratedColumn({ type: 'bigint', unsigned: true })
id!: number;
@Column({ name: 'license_id', type: 'bigint', unsigned: true })
licenseId!: number;
@Column({ name: 'machine_fingerprint', length: 100 })
machineFingerprint!: string;
@Column({ name: 'installation_id', type: 'varchar', length: 64, nullable: true })
installationId!: string | null;
@Column({ type: 'varchar', length: 200, nullable: true })
hostname!: string | null;
@Column({ type: 'varchar', length: 50, nullable: true })
ip!: string | null;
@Column({ length: 20 })
action!: string;
@CreateDateColumn({ name: 'created_at' })
createdAt!: Date;
}
@@ -0,0 +1,31 @@
import {
Column,
CreateDateColumn,
Entity,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
@Entity('lc_admin')
export class LcAdmin {
@PrimaryGeneratedColumn({ type: 'bigint', unsigned: true })
id!: number;
@Column({ length: 50, unique: true })
username!: string;
@Column({ length: 255 })
password!: string;
@Column({ type: 'varchar', length: 50, nullable: true })
nickname!: string | null;
@Column({ type: 'tinyint', default: 1 })
status!: number;
@CreateDateColumn({ name: 'created_at' })
createdAt!: Date;
@UpdateDateColumn({ name: 'updated_at' })
updatedAt!: Date;
}
@@ -0,0 +1,45 @@
import {
Column,
CreateDateColumn,
Entity,
OneToMany,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { LcLicense } from './lc-license.entity';
@Entity('lc_customer')
export class LcCustomer {
@PrimaryGeneratedColumn({ type: 'bigint', unsigned: true })
id!: number;
@Column({ length: 50, unique: true })
code!: string;
@Column({ length: 200 })
name!: string;
@Column({ name: 'contact_name', type: 'varchar', length: 50, nullable: true })
contactName!: string | null;
@Column({ name: 'contact_phone', type: 'varchar', length: 20, nullable: true })
contactPhone!: string | null;
@Column({ name: 'contact_email', type: 'varchar', length: 100, nullable: true })
contactEmail!: string | null;
@Column({ type: 'tinyint', default: 1 })
status!: number;
@Column({ type: 'text', nullable: true })
remark!: string | null;
@OneToMany(() => LcLicense, (license) => license.customer)
licenses!: LcLicense[];
@CreateDateColumn({ name: 'created_at' })
createdAt!: Date;
@UpdateDateColumn({ name: 'updated_at' })
updatedAt!: Date;
}
@@ -0,0 +1,62 @@
import {
Column,
CreateDateColumn,
Entity,
JoinColumn,
ManyToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { LcCustomer } from './lc-customer.entity';
@Entity('lc_license')
export class LcLicense {
@PrimaryGeneratedColumn({ type: 'bigint', unsigned: true })
id!: number;
@Column({ name: 'customer_id', type: 'bigint', unsigned: true })
customerId!: number;
@ManyToOne(() => LcCustomer, (customer) => customer.licenses)
@JoinColumn({ name: 'customer_id' })
customer!: LcCustomer;
@Column({ name: 'license_key', type: 'text' })
licenseKey!: string;
@Column({ length: 64, unique: true })
jti!: string;
@Column({ length: 20 })
edition!: string;
@Column({ name: 'machine_fingerprint', length: 100 })
machineFingerprint!: string;
@Column({ type: 'json' })
features!: string[];
@Column({ length: 20, default: 'active' })
status!: string;
@Column({ name: 'issued_at', type: 'timestamp' })
issuedAt!: Date;
@Column({ name: 'expires_at', type: 'timestamp' })
expiresAt!: Date;
@Column({ name: 'revoked_at', type: 'timestamp', nullable: true })
revokedAt!: Date | null;
@Column({ name: 'max_activations', type: 'int', nullable: true })
maxActivations!: number | null;
@Column({ name: 'activation_count', type: 'int', default: 0 })
activationCount!: number;
@CreateDateColumn({ name: 'created_at' })
createdAt!: Date;
@UpdateDateColumn({ name: 'updated_at' })
updatedAt!: Date;
}
@@ -0,0 +1,33 @@
import {
Column,
CreateDateColumn,
Entity,
PrimaryGeneratedColumn,
} from 'typeorm';
@Entity('lc_oper_log')
export class LcOperLog {
@PrimaryGeneratedColumn({ type: 'bigint', unsigned: true })
id!: number;
@Column({ name: 'admin_id', type: 'bigint', unsigned: true, nullable: true })
adminId!: number | null;
@Column({ length: 50 })
action!: string;
@Column({ name: 'target_type', type: 'varchar', length: 50, nullable: true })
targetType!: string | null;
@Column({ name: 'target_id', type: 'bigint', unsigned: true, nullable: true })
targetId!: number | null;
@Column({ type: 'json', nullable: true })
detail!: Record<string, unknown> | null;
@Column({ type: 'varchar', length: 50, nullable: true })
ip!: string | null;
@CreateDateColumn({ name: 'created_at' })
createdAt!: Date;
}