@tomei/sso 0.56.1 → 0.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/components/login-user/login-user.d.ts +4 -0
- package/dist/src/components/login-user/login-user.js +61 -0
- package/dist/src/components/login-user/login-user.js.map +1 -1
- package/dist/src/components/login-user/user.d.ts +12 -4
- package/dist/src/components/login-user/user.js +34 -53
- package/dist/src/components/login-user/user.js.map +1 -1
- package/dist/src/components/user-reporting-hierarchy/index.d.ts +2 -0
- package/dist/src/components/user-reporting-hierarchy/index.js +19 -0
- package/dist/src/components/user-reporting-hierarchy/index.js.map +1 -0
- package/dist/src/components/user-reporting-hierarchy/user-reporting-hierarchy.d.ts +25 -0
- package/dist/src/components/user-reporting-hierarchy/user-reporting-hierarchy.js +70 -0
- package/dist/src/components/user-reporting-hierarchy/user-reporting-hierarchy.js.map +1 -0
- package/dist/src/components/user-reporting-hierarchy/user-reporting-hierarchy.repository.d.ts +7 -0
- package/dist/src/components/user-reporting-hierarchy/user-reporting-hierarchy.repository.js +36 -0
- package/dist/src/components/user-reporting-hierarchy/user-reporting-hierarchy.repository.js.map +1 -0
- package/dist/src/interfaces/user-reporting-hierarchy.interface.d.ts +11 -0
- package/dist/src/interfaces/user-reporting-hierarchy.interface.js +3 -0
- package/dist/src/interfaces/user-reporting-hierarchy.interface.js.map +1 -0
- package/dist/src/models/user-reporting-hierarchy.entity.d.ts +18 -0
- package/dist/src/models/user-reporting-hierarchy.entity.js +116 -0
- package/dist/src/models/user-reporting-hierarchy.entity.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/migrations/20250210115636-create-user-reporting-hierarchy.js +76 -0
- package/package.json +1 -1
- package/src/components/index.ts +1 -0
- package/src/components/login-user/login-user.ts +70 -0
- package/src/components/login-user/user.ts +44 -76
- package/src/components/user-reporting-hierarchy/index.ts +2 -0
- package/src/components/user-reporting-hierarchy/user-reporting-hierarchy.repository.ts +30 -0
- package/src/components/user-reporting-hierarchy/user-reporting-hierarchy.ts +90 -0
- package/src/interfaces/user-reporting-hierarchy.interface.ts +11 -0
- package/src/models/user-reporting-hierarchy.entity.ts +102 -0
@@ -0,0 +1,76 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
/** @type {import('sequelize-cli').Migration} */
|
4
|
+
module.exports = {
|
5
|
+
async up(queryInterface, Sequelize) {
|
6
|
+
await queryInterface.createTable('sso_UserReportingHierarchy', {
|
7
|
+
UserReportingHierarchyId: {
|
8
|
+
type: Sequelize.INTEGER,
|
9
|
+
allowNull: false,
|
10
|
+
primaryKey: true,
|
11
|
+
autoIncrement: true,
|
12
|
+
},
|
13
|
+
ReportingUserId: {
|
14
|
+
type: Sequelize.INTEGER,
|
15
|
+
allowNull: false,
|
16
|
+
references: {
|
17
|
+
model: 'sso_User',
|
18
|
+
key: 'UserId',
|
19
|
+
},
|
20
|
+
onUpdate: 'CASCADE',
|
21
|
+
onDelete: 'CASCADE',
|
22
|
+
},
|
23
|
+
UserId: {
|
24
|
+
type: Sequelize.INTEGER,
|
25
|
+
allowNull: false,
|
26
|
+
references: {
|
27
|
+
model: 'sso_User',
|
28
|
+
key: 'UserId',
|
29
|
+
},
|
30
|
+
onUpdate: 'CASCADE',
|
31
|
+
onDelete: 'CASCADE',
|
32
|
+
},
|
33
|
+
Rank: {
|
34
|
+
type: Sequelize.TINYINT,
|
35
|
+
allowNull: false,
|
36
|
+
},
|
37
|
+
Status: {
|
38
|
+
type: Sequelize.STRING(10),
|
39
|
+
allowNull: false,
|
40
|
+
defaultValue: 'Active',
|
41
|
+
},
|
42
|
+
CreatedById: {
|
43
|
+
type: Sequelize.INTEGER,
|
44
|
+
allowNull: false,
|
45
|
+
references: {
|
46
|
+
model: 'sso_User',
|
47
|
+
key: 'UserId',
|
48
|
+
},
|
49
|
+
onUpdate: 'CASCADE',
|
50
|
+
onDelete: 'CASCADE',
|
51
|
+
},
|
52
|
+
CreatedAt: {
|
53
|
+
type: Sequelize.DATE,
|
54
|
+
allowNull: false,
|
55
|
+
},
|
56
|
+
UpdatedById: {
|
57
|
+
type: Sequelize.INTEGER,
|
58
|
+
allowNull: false,
|
59
|
+
references: {
|
60
|
+
model: 'sso_User',
|
61
|
+
key: 'UserId',
|
62
|
+
},
|
63
|
+
onUpdate: 'CASCADE',
|
64
|
+
onDelete: 'CASCADE',
|
65
|
+
},
|
66
|
+
UpdatedAt: {
|
67
|
+
type: Sequelize.DATE,
|
68
|
+
allowNull: false,
|
69
|
+
},
|
70
|
+
});
|
71
|
+
},
|
72
|
+
|
73
|
+
async down(queryInterface) {
|
74
|
+
await queryInterface.dropTable('sso_UserReportingHierarchy');
|
75
|
+
},
|
76
|
+
};
|
package/package.json
CHANGED
package/src/components/index.ts
CHANGED
@@ -7,6 +7,7 @@ import { RedisService } from '../../redis-client/redis.service';
|
|
7
7
|
import { UserRepository } from './user.repository';
|
8
8
|
import { IUserAttr, IUserInfo } from './interfaces/user-info.interface';
|
9
9
|
import Staff from '../../models/staff.entity';
|
10
|
+
import UserModel from '../../models/user.entity';
|
10
11
|
import { createHash, randomBytes } from 'crypto';
|
11
12
|
|
12
13
|
export class LoginUser extends User implements ILoginUser {
|
@@ -157,4 +158,73 @@ export class LoginUser extends User implements ILoginUser {
|
|
157
158
|
throw error;
|
158
159
|
}
|
159
160
|
}
|
161
|
+
|
162
|
+
async getProfile(dbTransaction: any) {
|
163
|
+
const user = await User._Repository.findOne({
|
164
|
+
where: {
|
165
|
+
UserId: this.UserId,
|
166
|
+
Status: 'Active',
|
167
|
+
},
|
168
|
+
include: [
|
169
|
+
{
|
170
|
+
model: Staff,
|
171
|
+
},
|
172
|
+
],
|
173
|
+
transaction: dbTransaction,
|
174
|
+
});
|
175
|
+
return user;
|
176
|
+
}
|
177
|
+
|
178
|
+
public static async getGroups(loginUser: User, dbTransaction: any) {
|
179
|
+
// This method will retrieve all user groups.
|
180
|
+
|
181
|
+
// Part 2: Retrieve User Groups & Returns
|
182
|
+
const userGroups = await User._UserGroupRepo.findAll({
|
183
|
+
where: {
|
184
|
+
UserId: loginUser.ObjectId,
|
185
|
+
Status: 'Active',
|
186
|
+
},
|
187
|
+
include: [{ model: UserModel, as: 'User' }, { model: GroupModel }],
|
188
|
+
transaction: dbTransaction,
|
189
|
+
});
|
190
|
+
|
191
|
+
return userGroups;
|
192
|
+
}
|
193
|
+
|
194
|
+
public static async getSystems(loginUser: User, dbTransaction: any) {
|
195
|
+
// This method will retrieve all system records which user has accessed to.
|
196
|
+
|
197
|
+
// Part 2: Retrieve System Access
|
198
|
+
const groups = await this.getGroups(loginUser, dbTransaction);
|
199
|
+
const systemAccess = await User.combineSystemAccess(
|
200
|
+
loginUser,
|
201
|
+
dbTransaction,
|
202
|
+
groups,
|
203
|
+
);
|
204
|
+
const output = [];
|
205
|
+
if (systemAccess) {
|
206
|
+
for (let i = 0; i < systemAccess.length; i++) {
|
207
|
+
const system = await User._SystemRepository.findOne({
|
208
|
+
where: {
|
209
|
+
SystemCode: systemAccess[i].SystemCode,
|
210
|
+
Status: 'Active',
|
211
|
+
},
|
212
|
+
});
|
213
|
+
output.push({
|
214
|
+
UserSystemAccessId: systemAccess[i].UserSystemAccessId,
|
215
|
+
UserId: systemAccess[i].UserId,
|
216
|
+
SystemCode: systemAccess[i].SystemCode,
|
217
|
+
Status: systemAccess[i].Status,
|
218
|
+
CreatedById: systemAccess[i].CreatedById,
|
219
|
+
UpdatedById: systemAccess[i].UpdatedById,
|
220
|
+
CreatedAt: systemAccess[i].CreatedAt,
|
221
|
+
UpdatedAt: systemAccess[i].UpdatedAt,
|
222
|
+
System: system,
|
223
|
+
});
|
224
|
+
}
|
225
|
+
}
|
226
|
+
|
227
|
+
// Part 3: Map Result to System Object
|
228
|
+
return output;
|
229
|
+
}
|
160
230
|
}
|
@@ -15,7 +15,6 @@ import { ApplicationConfig, ComponentConfig } from '@tomei/config';
|
|
15
15
|
import { ICheckUserInfoDuplicatedQuery } from './interfaces/check-user-info-duplicated.interface';
|
16
16
|
import { Op, where } from 'sequelize';
|
17
17
|
import { ActionEnum, Activity } from '@tomei/activity-history';
|
18
|
-
import UserModel from '../../models/user.entity';
|
19
18
|
import GroupModel from '../../models/group.entity';
|
20
19
|
import { GroupSystemAccessRepository } from '../group-system-access/group-system-access.repository';
|
21
20
|
import { GroupRepository } from '../group/group.repository';
|
@@ -34,6 +33,8 @@ import { LoginUser } from './login-user';
|
|
34
33
|
import { SessionService } from '../../session/session.service';
|
35
34
|
import { createHash, randomBytes, randomUUID } from 'crypto';
|
36
35
|
import { AuthContext } from 'types';
|
36
|
+
import UserModel from '../../models/user.entity';
|
37
|
+
import { UserReportingHierarchyRepository } from '../user-reporting-hierarchy/user-reporting-hierarchy.repository';
|
37
38
|
|
38
39
|
export class User extends UserBase {
|
39
40
|
ObjectId: string;
|
@@ -74,10 +75,12 @@ export class User extends UserBase {
|
|
74
75
|
private static _GroupObjectPrivilegeRepo =
|
75
76
|
new GroupObjectPrivilegeRepository();
|
76
77
|
|
77
|
-
|
78
|
+
protected static _SystemRepository = new SystemRepository();
|
78
79
|
protected static _UserSystemAccessRepo = new UserSystemAccessRepository();
|
79
80
|
private static _GroupSystemAccessRepo = new GroupSystemAccessRepository();
|
80
81
|
private static _GroupRepo = new GroupRepository();
|
82
|
+
protected static _UserReportingHierarchyRepo =
|
83
|
+
new UserReportingHierarchyRepository();
|
81
84
|
|
82
85
|
private _dbTransaction: any;
|
83
86
|
|
@@ -1738,32 +1741,6 @@ export class User extends UserBase {
|
|
1738
1741
|
);
|
1739
1742
|
}
|
1740
1743
|
|
1741
|
-
public static async getGroups(loginUser: User, dbTransaction: any) {
|
1742
|
-
// This method will retrieve all user groups.
|
1743
|
-
|
1744
|
-
// Part 1: Privilege Checking
|
1745
|
-
const systemCode = ApplicationConfig.getComponentConfigValue('system-code');
|
1746
|
-
const isPrivileged = await loginUser.checkPrivileges(
|
1747
|
-
systemCode,
|
1748
|
-
'UserGroup - List Own',
|
1749
|
-
);
|
1750
|
-
if (!isPrivileged) {
|
1751
|
-
throw new Error('You do not have permission to list UserGroup.');
|
1752
|
-
}
|
1753
|
-
|
1754
|
-
// Part 2: Retrieve User Groups & Returns
|
1755
|
-
const userGroups = await User._UserGroupRepo.findAll({
|
1756
|
-
where: {
|
1757
|
-
UserId: loginUser.ObjectId,
|
1758
|
-
Status: 'Active',
|
1759
|
-
},
|
1760
|
-
include: [{ model: UserModel, as: 'User' }, { model: GroupModel }],
|
1761
|
-
transaction: dbTransaction,
|
1762
|
-
});
|
1763
|
-
|
1764
|
-
return userGroups;
|
1765
|
-
}
|
1766
|
-
|
1767
1744
|
protected static async getInheritedSystemAccess(
|
1768
1745
|
dbTransaction: any,
|
1769
1746
|
group: GroupModel,
|
@@ -1801,7 +1778,7 @@ export class User extends UserBase {
|
|
1801
1778
|
return systemAccesses;
|
1802
1779
|
}
|
1803
1780
|
|
1804
|
-
|
1781
|
+
protected static async combineSystemAccess(
|
1805
1782
|
loginUser: User,
|
1806
1783
|
dbTransaction: any,
|
1807
1784
|
groups: any,
|
@@ -1839,53 +1816,6 @@ export class User extends UserBase {
|
|
1839
1816
|
return Array.from(uniqueAccess) as ISystemAccess[];
|
1840
1817
|
}
|
1841
1818
|
|
1842
|
-
public static async getSystems(loginUser: User, dbTransaction: any) {
|
1843
|
-
// This method will retrieve all system records which user has accessed to.
|
1844
|
-
|
1845
|
-
// Part 1: Privilege Checking
|
1846
|
-
const systemCode = ApplicationConfig.getComponentConfigValue('system-code');
|
1847
|
-
const isPrivileged = await loginUser.checkPrivileges(
|
1848
|
-
systemCode,
|
1849
|
-
'System – List Own',
|
1850
|
-
);
|
1851
|
-
if (!isPrivileged) {
|
1852
|
-
throw new Error('You do not have permission to list UserGroup.');
|
1853
|
-
}
|
1854
|
-
|
1855
|
-
// Part 2: Retrieve System Access
|
1856
|
-
const groups = await User.getGroups(loginUser, dbTransaction);
|
1857
|
-
const systemAccess = await User.combineSystemAccess(
|
1858
|
-
loginUser,
|
1859
|
-
dbTransaction,
|
1860
|
-
groups,
|
1861
|
-
);
|
1862
|
-
const output = [];
|
1863
|
-
if (systemAccess) {
|
1864
|
-
for (let i = 0; i < systemAccess.length; i++) {
|
1865
|
-
const system = await User._SystemRepository.findOne({
|
1866
|
-
where: {
|
1867
|
-
SystemCode: systemAccess[i].SystemCode,
|
1868
|
-
Status: 'Active',
|
1869
|
-
},
|
1870
|
-
});
|
1871
|
-
output.push({
|
1872
|
-
UserSystemAccessId: systemAccess[i].UserSystemAccessId,
|
1873
|
-
UserId: systemAccess[i].UserId,
|
1874
|
-
SystemCode: systemAccess[i].SystemCode,
|
1875
|
-
Status: systemAccess[i].Status,
|
1876
|
-
CreatedById: systemAccess[i].CreatedById,
|
1877
|
-
UpdatedById: systemAccess[i].UpdatedById,
|
1878
|
-
CreatedAt: systemAccess[i].CreatedAt,
|
1879
|
-
UpdatedAt: systemAccess[i].UpdatedAt,
|
1880
|
-
System: system,
|
1881
|
-
});
|
1882
|
-
}
|
1883
|
-
}
|
1884
|
-
|
1885
|
-
// Part 3: Map Result to System Object
|
1886
|
-
return output;
|
1887
|
-
}
|
1888
|
-
|
1889
1819
|
//This method will check if user enable 2FA or not.
|
1890
1820
|
private static async check2FA(loginUser: User, dbTransaction: any) {
|
1891
1821
|
try {
|
@@ -2908,4 +2838,42 @@ export class User extends UserBase {
|
|
2908
2838
|
throw error;
|
2909
2839
|
}
|
2910
2840
|
}
|
2841
|
+
|
2842
|
+
public async getReportingUser(dbTransaction: any): Promise<
|
2843
|
+
{
|
2844
|
+
Email: string;
|
2845
|
+
ContactNo: string;
|
2846
|
+
Name: string;
|
2847
|
+
Rank: number;
|
2848
|
+
}[]
|
2849
|
+
> {
|
2850
|
+
try {
|
2851
|
+
const data = await User._UserReportingHierarchyRepo.findAll({
|
2852
|
+
where: {
|
2853
|
+
ReportingUserId: this.UserId,
|
2854
|
+
},
|
2855
|
+
include: [
|
2856
|
+
{
|
2857
|
+
model: UserModel,
|
2858
|
+
as: 'User',
|
2859
|
+
attributes: ['Email', 'ContactNo', 'FullName'],
|
2860
|
+
},
|
2861
|
+
],
|
2862
|
+
transaction: dbTransaction,
|
2863
|
+
});
|
2864
|
+
|
2865
|
+
//format the data
|
2866
|
+
const result = data.map((item) => {
|
2867
|
+
return {
|
2868
|
+
Email: item.User.Email,
|
2869
|
+
ContactNo: item.User.ContactNo,
|
2870
|
+
Name: item.User.FullName,
|
2871
|
+
Rank: item.Rank,
|
2872
|
+
};
|
2873
|
+
});
|
2874
|
+
return result;
|
2875
|
+
} catch (error) {
|
2876
|
+
throw error;
|
2877
|
+
}
|
2878
|
+
}
|
2911
2879
|
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import UserReportingHierarchyModel from '../../models/user-reporting-hierarchy.entity';
|
2
|
+
import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
3
|
+
|
4
|
+
export class UserReportingHierarchyRepository
|
5
|
+
extends RepositoryBase<UserReportingHierarchyModel>
|
6
|
+
implements IRepositoryBase<UserReportingHierarchyModel>
|
7
|
+
{
|
8
|
+
constructor() {
|
9
|
+
super(UserReportingHierarchyModel);
|
10
|
+
}
|
11
|
+
|
12
|
+
async findByPk(
|
13
|
+
id: string,
|
14
|
+
options?: any,
|
15
|
+
): Promise<UserReportingHierarchyModel> {
|
16
|
+
return await UserReportingHierarchyModel.findByPk(parseInt(id), options);
|
17
|
+
}
|
18
|
+
|
19
|
+
async destroy(
|
20
|
+
UserReportingHierarchyId: number,
|
21
|
+
dbTransaction: any,
|
22
|
+
): Promise<void> {
|
23
|
+
await UserReportingHierarchyModel.destroy({
|
24
|
+
where: {
|
25
|
+
UserReportingHierarchyId: UserReportingHierarchyId,
|
26
|
+
},
|
27
|
+
transaction: dbTransaction,
|
28
|
+
});
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,90 @@
|
|
1
|
+
import { ClassError, ObjectBase } from '@tomei/general';
|
2
|
+
import { IUserReportingHierarchyAttr } from '../../interfaces/user-reporting-hierarchy.interface';
|
3
|
+
import { UserReportingHierarchyRepository } from './user-reporting-hierarchy.repository';
|
4
|
+
|
5
|
+
export class UserReportingHierarchy
|
6
|
+
extends ObjectBase
|
7
|
+
implements IUserReportingHierarchyAttr
|
8
|
+
{
|
9
|
+
ObjectId: string;
|
10
|
+
ObjectName: string;
|
11
|
+
ObjectType = 'UserReportingHierarchy';
|
12
|
+
TableName = 'sso_UserReportingHierarchy';
|
13
|
+
ReportingUserId: number;
|
14
|
+
UserId: number;
|
15
|
+
Rank: number;
|
16
|
+
Status: string;
|
17
|
+
private _CreatedById: number;
|
18
|
+
private _CreatedAt: Date;
|
19
|
+
private _UpdatedById: number;
|
20
|
+
private _UpdatedAt: Date;
|
21
|
+
|
22
|
+
private static _Repo = new UserReportingHierarchyRepository();
|
23
|
+
|
24
|
+
get UserReportingHierarchyId(): number {
|
25
|
+
return parseInt(this.ObjectId);
|
26
|
+
}
|
27
|
+
|
28
|
+
set UserReportingHierarchyId(value: number) {
|
29
|
+
this.ObjectId = value.toString();
|
30
|
+
}
|
31
|
+
|
32
|
+
get CreatedById(): number {
|
33
|
+
return this._CreatedById;
|
34
|
+
}
|
35
|
+
|
36
|
+
get CreatedAt(): Date {
|
37
|
+
return this._CreatedAt;
|
38
|
+
}
|
39
|
+
|
40
|
+
get UpdatedById(): number {
|
41
|
+
return this._UpdatedById;
|
42
|
+
}
|
43
|
+
|
44
|
+
get UpdatedAt(): Date {
|
45
|
+
return this._UpdatedAt;
|
46
|
+
}
|
47
|
+
|
48
|
+
private constructor(params?: IUserReportingHierarchyAttr) {
|
49
|
+
super();
|
50
|
+
if (params) {
|
51
|
+
this.ObjectId = params.UserReportingHierarchyId.toString();
|
52
|
+
this.ReportingUserId = params.ReportingUserId;
|
53
|
+
this.UserId = params.UserId;
|
54
|
+
this.Rank = params.Rank;
|
55
|
+
this.Status = params.Status;
|
56
|
+
this._CreatedById = params.CreatedById;
|
57
|
+
this._CreatedAt = params.CreatedAt;
|
58
|
+
this._UpdatedById = params.UpdatedById;
|
59
|
+
this._UpdatedAt = params.UpdatedAt;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
public static async init(
|
64
|
+
userReportingHierarchyId: number,
|
65
|
+
dbTransaction?: any,
|
66
|
+
): Promise<UserReportingHierarchy> {
|
67
|
+
try {
|
68
|
+
if (userReportingHierarchyId) {
|
69
|
+
const data = await UserReportingHierarchy._Repo.findByPk(
|
70
|
+
userReportingHierarchyId.toString(),
|
71
|
+
dbTransaction,
|
72
|
+
);
|
73
|
+
if (!data) {
|
74
|
+
throw new ClassError(
|
75
|
+
'UserReportingHierarchy',
|
76
|
+
'UserReportingHierarchyErrMsg01',
|
77
|
+
'UserReportingHierarchy not found',
|
78
|
+
'init',
|
79
|
+
400,
|
80
|
+
);
|
81
|
+
}
|
82
|
+
|
83
|
+
return new UserReportingHierarchy(data.get({ plain: true }));
|
84
|
+
}
|
85
|
+
return new UserReportingHierarchy();
|
86
|
+
} catch (error) {
|
87
|
+
throw error;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import {
|
2
|
+
BelongsTo,
|
3
|
+
Column,
|
4
|
+
CreatedAt,
|
5
|
+
DataType,
|
6
|
+
ForeignKey,
|
7
|
+
Model,
|
8
|
+
Table,
|
9
|
+
UpdatedAt,
|
10
|
+
} from 'sequelize-typescript';
|
11
|
+
import User from './user.entity';
|
12
|
+
import GroupModel from './group.entity';
|
13
|
+
import { IUserReportingHierarchyAttr } from '../interfaces/user-reporting-hierarchy.interface';
|
14
|
+
|
15
|
+
@Table({
|
16
|
+
tableName: 'sso_UserReportingHierarchy',
|
17
|
+
timestamps: true,
|
18
|
+
createdAt: 'CreatedAt',
|
19
|
+
updatedAt: 'UpdatedAt',
|
20
|
+
})
|
21
|
+
export default class UserReportingHierarchyModel
|
22
|
+
extends Model
|
23
|
+
implements IUserReportingHierarchyAttr
|
24
|
+
{
|
25
|
+
@Column({
|
26
|
+
primaryKey: true,
|
27
|
+
allowNull: false,
|
28
|
+
type: DataType.INTEGER,
|
29
|
+
autoIncrement: true,
|
30
|
+
})
|
31
|
+
UserReportingHierarchyId: number;
|
32
|
+
|
33
|
+
@ForeignKey(() => User)
|
34
|
+
@Column({
|
35
|
+
allowNull: false,
|
36
|
+
type: DataType.INTEGER,
|
37
|
+
})
|
38
|
+
UserId: number;
|
39
|
+
|
40
|
+
@ForeignKey(() => User)
|
41
|
+
@Column({
|
42
|
+
allowNull: false,
|
43
|
+
type: DataType.INTEGER,
|
44
|
+
})
|
45
|
+
ReportingUserId: number;
|
46
|
+
|
47
|
+
@Column({
|
48
|
+
allowNull: false,
|
49
|
+
type: DataType.TINYINT,
|
50
|
+
})
|
51
|
+
Rank: number;
|
52
|
+
|
53
|
+
@Column({
|
54
|
+
allowNull: false,
|
55
|
+
type: DataType.CHAR(10),
|
56
|
+
})
|
57
|
+
Status: string;
|
58
|
+
|
59
|
+
@ForeignKey(() => User)
|
60
|
+
@Column({
|
61
|
+
allowNull: false,
|
62
|
+
type: DataType.INTEGER,
|
63
|
+
})
|
64
|
+
CreatedById: number;
|
65
|
+
|
66
|
+
@ForeignKey(() => User)
|
67
|
+
@Column({
|
68
|
+
allowNull: false,
|
69
|
+
type: DataType.INTEGER,
|
70
|
+
})
|
71
|
+
UpdatedById: number;
|
72
|
+
|
73
|
+
@CreatedAt
|
74
|
+
CreatedAt: Date;
|
75
|
+
|
76
|
+
@UpdatedAt
|
77
|
+
UpdatedAt: Date;
|
78
|
+
|
79
|
+
@BelongsTo(() => User, {
|
80
|
+
as: 'CreatedByUser',
|
81
|
+
foreignKey: 'CreatedById',
|
82
|
+
})
|
83
|
+
CreatedByUser: User;
|
84
|
+
|
85
|
+
@BelongsTo(() => User, {
|
86
|
+
as: 'ReportingUser',
|
87
|
+
foreignKey: 'ReportingUserId',
|
88
|
+
})
|
89
|
+
ReportingUser: User;
|
90
|
+
|
91
|
+
@BelongsTo(() => User, {
|
92
|
+
as: 'UpdatedByUser',
|
93
|
+
foreignKey: 'UpdatedById',
|
94
|
+
})
|
95
|
+
UpdatedByUser: User;
|
96
|
+
|
97
|
+
@BelongsTo(() => User, {
|
98
|
+
as: 'User',
|
99
|
+
foreignKey: 'UserId',
|
100
|
+
})
|
101
|
+
User: User;
|
102
|
+
}
|