mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 17:15:03 -07:00
msic
This commit is contained in:
@@ -1,29 +1,32 @@
|
||||
import { Column, Entity, OneToMany, PrimaryColumn } from 'typeorm';
|
||||
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
||||
|
||||
import { ClientStatisticsEntity } from '../client-statistics/client-statistics.entity';
|
||||
import { TrackedEntity } from '../utils/TrackedEntity.entity';
|
||||
|
||||
@Entity()
|
||||
export class ClientEntity extends TrackedEntity {
|
||||
@PrimaryColumn({ length: 8, type: 'varchar' })
|
||||
id: string;
|
||||
|
||||
@Column({ type: 'datetime' })
|
||||
startTime: Date;
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
clientName: string;
|
||||
|
||||
@Column({ length: 62, type: 'varchar' })
|
||||
address: string;
|
||||
|
||||
@Column()
|
||||
clientName: string;
|
||||
|
||||
@Column({ length: 8, type: 'varchar' })
|
||||
sessionId: string;
|
||||
|
||||
@Column({ type: 'datetime' })
|
||||
startTime: Date;
|
||||
|
||||
|
||||
|
||||
@Column({ default: 0 })
|
||||
bestDifficulty: number
|
||||
|
||||
@OneToMany(
|
||||
() => ClientStatisticsEntity,
|
||||
clientStatistic => clientStatistic.client
|
||||
)
|
||||
clientStatistics?: ClientStatisticsEntity[];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@ export class ClientService {
|
||||
return await this.clientRepository.save(client);
|
||||
}
|
||||
|
||||
public async delete(id: string) {
|
||||
return await this.clientRepository.softDelete({ id });
|
||||
public async delete(sessionId: string) {
|
||||
return await this.clientRepository.softDelete({ sessionId });
|
||||
}
|
||||
|
||||
public async updateBestDifficulty(id: string, bestDifficulty: number) {
|
||||
return await this.clientRepository.update(id, { bestDifficulty });
|
||||
public async updateBestDifficulty(sessionId: string, bestDifficulty: number) {
|
||||
return await this.clientRepository.update({ sessionId }, { bestDifficulty });
|
||||
}
|
||||
public async connectedClientCount(): Promise<number> {
|
||||
return await this.clientRepository.count();
|
||||
@@ -40,12 +40,17 @@ export class ClientService {
|
||||
})
|
||||
}
|
||||
|
||||
public async getByAddressAndName(address: string, id: string): Promise<ClientEntity> {
|
||||
public async getById(address: string, clientName: string, sessionId: string): Promise<ClientEntity> {
|
||||
return await this.clientRepository.findOne({
|
||||
where: {
|
||||
address,
|
||||
id
|
||||
clientName,
|
||||
sessionId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
public async deleteAll() {
|
||||
return await this.clientRepository.softDelete({})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user