...
This commit is contained in:
@@ -20,7 +20,7 @@ export class Key implements IKey {
|
||||
name: string;
|
||||
|
||||
@Column({ name: 'key_number', unique: false })
|
||||
nr: number;
|
||||
nr: string;
|
||||
|
||||
@Column({ name: 'handed_out', default: false })
|
||||
handedOut: boolean;
|
||||
|
||||
@@ -22,7 +22,7 @@ export class KeyActivity implements IKey {
|
||||
name: string;
|
||||
|
||||
@Column({ name: 'key_number' })
|
||||
nr: number;
|
||||
nr: string;
|
||||
|
||||
@Column({ name: 'handed_out', default: false })
|
||||
handedOut: boolean;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Customer, Cylinder } from '../entitites';
|
||||
export interface IKey {
|
||||
id: string;
|
||||
name: string;
|
||||
nr: number;
|
||||
nr: string;
|
||||
handedOut: boolean;
|
||||
cylinder: Cylinder;
|
||||
customer: Customer;
|
||||
|
||||
@@ -22,7 +22,6 @@ export class AuthController {
|
||||
@Body() authDto: AuthCodeDto,
|
||||
): Promise<User> {
|
||||
const user = await this.authService.registerOrLoginWithAuthCode(authDto);
|
||||
console.log(user)
|
||||
if (user == null) {
|
||||
throw new HttpException('forbidden', HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@@ -131,6 +131,7 @@ export class AuthService {
|
||||
this.generateTokens(user);
|
||||
return user;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
throw new HttpException('invalid token', HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ import {
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
} from 'src/model/repositories';
|
||||
import { KeyHandoutRepository } from 'src/model/repositories/key-handout.repository';
|
||||
import { IsNull, Not } from 'typeorm';
|
||||
import { faker } from '@faker-js/faker';
|
||||
|
||||
@Injectable()
|
||||
export class KeyService {
|
||||
@@ -19,7 +20,27 @@ export class KeyService {
|
||||
private readonly systemRepo: KeySystemRepository,
|
||||
private activityRepo: KeyActivityRepository,
|
||||
private handoverRepo: KeyHandoutRepository,
|
||||
) {}
|
||||
) {
|
||||
this.create()
|
||||
}
|
||||
|
||||
async create() {
|
||||
const c = await this.cylinderRepository.findOneBy({ name: 'DevCylinder1' });
|
||||
|
||||
const keys = [];
|
||||
for (let x = 0; x < 1000; x++) {
|
||||
keys.push(
|
||||
this.keyrepository.create({
|
||||
name: faker.commerce.productName(),
|
||||
nr: faker.commerce.isbn(),
|
||||
cylinder: c,
|
||||
createdAt: new Date(faker.date.past())
|
||||
})
|
||||
);
|
||||
}
|
||||
await this.keyrepository.save(keys);
|
||||
console.log("edn")
|
||||
}
|
||||
|
||||
async getUsersKeys(user: User): Promise<Key[]> {
|
||||
return this.keyrepository.find({
|
||||
|
||||
Reference in New Issue
Block a user