User + UserGroup
This commit is contained in:
parent
5bf978d32d
commit
48e28e7b7a
100
src/models/User.ts
Normal file
100
src/models/User.ts
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
import { Entity, Column, OneToMany, ManyToOne, PrimaryGeneratedColumn, Generated, Unique } from "typeorm";
|
||||||
|
import { IsBoolean, IsEmail, IsInt, IsNotEmpty, IsOptional, IsString, isUUID, } from "class-validator";
|
||||||
|
import { UserGroup } from './UserGroup';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a admin user.
|
||||||
|
*/
|
||||||
|
@Entity()
|
||||||
|
export class User {
|
||||||
|
/**
|
||||||
|
* autogenerated unique id (primary key).
|
||||||
|
*/
|
||||||
|
@PrimaryGeneratedColumn()
|
||||||
|
@IsOptional()
|
||||||
|
@IsInt()
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* autogenerated uuid
|
||||||
|
*/
|
||||||
|
@PrimaryGeneratedColumn()
|
||||||
|
@IsOptional()
|
||||||
|
@IsInt()
|
||||||
|
@Generated("uuid")
|
||||||
|
uuid: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* user email
|
||||||
|
*/
|
||||||
|
@IsEmail()
|
||||||
|
email: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* username
|
||||||
|
*/
|
||||||
|
@IsString()
|
||||||
|
username: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* firstname
|
||||||
|
*/
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
firstname: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* middlename
|
||||||
|
*/
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
middlename: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lastname
|
||||||
|
*/
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
lastname: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* password
|
||||||
|
*/
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
password: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* userpermissions
|
||||||
|
*/
|
||||||
|
// TODO: UserPermission implementation
|
||||||
|
// @OneToMany(() => UserPermission,userpermission=>)
|
||||||
|
// userpermissions: UserPermission[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* groups
|
||||||
|
*/
|
||||||
|
// TODO: UserGroup implementation
|
||||||
|
// @OneToMany(() => UserGroup, usergroup => usergroup.)
|
||||||
|
@IsOptional()
|
||||||
|
groups: UserGroup[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is user enabled?
|
||||||
|
*/
|
||||||
|
@IsBoolean()
|
||||||
|
enabled: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* jwt refresh count
|
||||||
|
*/
|
||||||
|
@IsInt()
|
||||||
|
@Column({ default: 1 })
|
||||||
|
refreshTokenCount: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* profilepic
|
||||||
|
*/
|
||||||
|
@IsString()
|
||||||
|
profilepic: string;
|
||||||
|
}
|
44
src/models/UserGroup.ts
Normal file
44
src/models/UserGroup.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import { PrimaryGeneratedColumn, Column, OneToMany, Entity } from "typeorm";
|
||||||
|
import {
|
||||||
|
IsInt,
|
||||||
|
IsNotEmpty,
|
||||||
|
IsOptional,
|
||||||
|
IsString,
|
||||||
|
} from "class-validator";
|
||||||
|
import { User } from "./User";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the UserGroup interface.
|
||||||
|
*/
|
||||||
|
@Entity()
|
||||||
|
export abstract class UserGroup {
|
||||||
|
/**
|
||||||
|
* Autogenerated unique id (primary key).
|
||||||
|
*/
|
||||||
|
@PrimaryGeneratedColumn()
|
||||||
|
@IsOptional()
|
||||||
|
@IsInt()
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The group's name
|
||||||
|
*/
|
||||||
|
@Column()
|
||||||
|
@IsNotEmpty()
|
||||||
|
@IsString()
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The group's description
|
||||||
|
*/
|
||||||
|
@Column()
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
description: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to link users to a user group.
|
||||||
|
*/
|
||||||
|
// TODO:
|
||||||
|
// grouppermissions: GroupPermissions[];
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user