feat(SPG-320) REST API CUD User Privileges
parent
c0b0ffa8fa
commit
240bbf4c2e
|
@ -0,0 +1,7 @@
|
||||||
|
import { UserPrivilegeConfigurationModel } from './data/models/user-privilege-configuration.model';
|
||||||
|
import { UserPrivilegeModel } from './data/models/user-privilege.model';
|
||||||
|
|
||||||
|
export const UserPrivilegeModels = [
|
||||||
|
UserPrivilegeModel,
|
||||||
|
UserPrivilegeConfigurationModel,
|
||||||
|
];
|
|
@ -1,10 +0,0 @@
|
||||||
import { BaseStatusModel } from "src/core/modules/data/model/base-status.model";
|
|
||||||
import { TABLE_NAME } from "src/core/strings/constants/table.constants";
|
|
||||||
import { Column, Entity } from "typeorm";
|
|
||||||
import { UserPrivilegeEntity } from "../../domain/entities/user-privilege.entity";
|
|
||||||
|
|
||||||
@Entity(TABLE_NAME.USER_PRIVILEGE)
|
|
||||||
export class UserPrivilegeModel extends BaseStatusModel<UserPrivilegeEntity> implements UserPrivilegeEntity {
|
|
||||||
@Column('varchar', { name: 'name', length: 125 })
|
|
||||||
name: string;
|
|
||||||
}
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
import { BaseCoreModel } from 'src/core/modules/data/model/base-core.model';
|
||||||
|
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||||
|
import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
|
||||||
|
import { UserPrivilegeConfigurationEntity } from '../../domain/entities/user-privilege-configuration.entity';
|
||||||
|
import { UserPrivilegeModel } from './user-privilege.model';
|
||||||
|
|
||||||
|
@Entity(TABLE_NAME.USER_PRIVILEGE_CONFIGURATION)
|
||||||
|
export class UserPrivilegeConfigurationModel
|
||||||
|
extends BaseCoreModel<UserPrivilegeConfigurationEntity>
|
||||||
|
implements UserPrivilegeConfigurationEntity
|
||||||
|
{
|
||||||
|
@Column('varchar', { name: 'module', length: 125 })
|
||||||
|
module: string;
|
||||||
|
|
||||||
|
@Column('varchar', { name: 'module_label', length: 125, nullable: true })
|
||||||
|
module_label: string;
|
||||||
|
|
||||||
|
@Column('varchar', { name: 'menu', length: 125 })
|
||||||
|
menu: string;
|
||||||
|
|
||||||
|
@Column('varchar', { name: 'menu_label', length: 125, nullable: true })
|
||||||
|
menu_label: string;
|
||||||
|
|
||||||
|
@Column('varchar', { name: 'sub_menu', length: 125, nullable: true })
|
||||||
|
sub_menu: string;
|
||||||
|
|
||||||
|
@Column('varchar', { name: 'sub_menu_label', length: 125, nullable: true })
|
||||||
|
sub_menu_label: string;
|
||||||
|
|
||||||
|
@Column('boolean', { nullable: true })
|
||||||
|
view: boolean;
|
||||||
|
|
||||||
|
@Column('boolean', { nullable: true })
|
||||||
|
create: boolean;
|
||||||
|
|
||||||
|
@Column('boolean', { nullable: true })
|
||||||
|
edit: boolean;
|
||||||
|
|
||||||
|
@Column('boolean', { nullable: true })
|
||||||
|
delete: boolean;
|
||||||
|
|
||||||
|
@Column('boolean', { nullable: true })
|
||||||
|
cancel: boolean;
|
||||||
|
|
||||||
|
@Column('boolean', { nullable: true })
|
||||||
|
confirm: boolean;
|
||||||
|
|
||||||
|
@Column('integer', { nullable: true, default: 0 })
|
||||||
|
index: number;
|
||||||
|
|
||||||
|
@Column('varchar', { name: 'user_privilege_id', nullable: true })
|
||||||
|
user_privilege_id: string;
|
||||||
|
@ManyToOne(
|
||||||
|
() => UserPrivilegeModel,
|
||||||
|
(model) => model.user_privilege_configurations,
|
||||||
|
{
|
||||||
|
onUpdate: 'CASCADE',
|
||||||
|
onDelete: 'CASCADE',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
@JoinColumn({ name: 'user_privilege_id' })
|
||||||
|
user_privilege: UserPrivilegeModel;
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
|
||||||
|
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||||
|
import { Column, Entity, OneToMany } from 'typeorm';
|
||||||
|
import { UserPrivilegeEntity } from '../../domain/entities/user-privilege.entity';
|
||||||
|
import { UserPrivilegeConfigurationModel } from './user-privilege-configuration.model';
|
||||||
|
import { UserModel } from 'src/modules/user-related/user/data/models/user.model';
|
||||||
|
|
||||||
|
@Entity(TABLE_NAME.USER_PRIVILEGE)
|
||||||
|
export class UserPrivilegeModel
|
||||||
|
extends BaseStatusModel<UserPrivilegeEntity>
|
||||||
|
implements UserPrivilegeEntity
|
||||||
|
{
|
||||||
|
@Column('varchar', { name: 'name', length: 125 })
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => UserPrivilegeConfigurationModel,
|
||||||
|
(model) => model.user_privilege,
|
||||||
|
{
|
||||||
|
cascade: true,
|
||||||
|
onDelete: 'CASCADE',
|
||||||
|
onUpdate: 'CASCADE',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
user_privilege_configurations: UserPrivilegeConfigurationModel[];
|
||||||
|
|
||||||
|
@OneToMany(() => UserModel, (model) => model.user_privilege, {
|
||||||
|
onDelete: 'CASCADE',
|
||||||
|
onUpdate: 'CASCADE',
|
||||||
|
})
|
||||||
|
users: UserModel[];
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
||||||
|
import { UserPrivilegeConfigurationEntity } from '../../domain/entities/user-privilege-configuration.entity';
|
||||||
|
import { UserPrivilegeConfigurationModel } from '../models/user-privilege-configuration.model';
|
||||||
|
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||||
|
import { Repository, SelectQueryBuilder } from 'typeorm';
|
||||||
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
|
import { FilterUserPrivilegeEntity } from '../../domain/entities/filter-user-privilege.entity';
|
||||||
|
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class UserPrivilegeConfigurationService extends BaseDataService<UserPrivilegeConfigurationEntity> {
|
||||||
|
constructor(
|
||||||
|
@InjectRepository(UserPrivilegeConfigurationModel, CONNECTION_NAME.DEFAULT)
|
||||||
|
private repo: Repository<UserPrivilegeConfigurationModel>,
|
||||||
|
) {
|
||||||
|
super(repo);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getIndex(
|
||||||
|
queryBuilder: SelectQueryBuilder<UserPrivilegeConfigurationEntity>,
|
||||||
|
params: FilterUserPrivilegeEntity,
|
||||||
|
): Promise<PaginationResponse<UserPrivilegeConfigurationEntity>> {
|
||||||
|
const [data, total] = await queryBuilder
|
||||||
|
.take(+params.limit)
|
||||||
|
.skip(+params.limit * +params.page - +params.limit)
|
||||||
|
.getManyAndCount();
|
||||||
|
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
total,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,19 +1,17 @@
|
||||||
import { Injectable } from "@nestjs/common";
|
import { Injectable } from '@nestjs/common';
|
||||||
import { BaseDataService } from "src/core/modules/data/service/base-data.service";
|
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
||||||
import { UserPrivilegeEntity } from "../../domain/entities/user-privilege.entity";
|
import { UserPrivilegeEntity } from '../../domain/entities/user-privilege.entity';
|
||||||
import { InjectRepository } from "@nestjs/typeorm";
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { UserPrivilegeModel } from "../model/user-privilege.model";
|
import { UserPrivilegeModel } from '../models/user-privilege.model';
|
||||||
import { CONNECTION_NAME } from "src/core/strings/constants/base.constants";
|
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||||
import { Repository } from "typeorm";
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserPrivilegeDataService extends BaseDataService<UserPrivilegeEntity> {
|
export class UserPrivilegeDataService extends BaseDataService<UserPrivilegeEntity> {
|
||||||
|
constructor(
|
||||||
constructor(
|
@InjectRepository(UserPrivilegeModel, CONNECTION_NAME.DEFAULT)
|
||||||
@InjectRepository(UserPrivilegeModel, CONNECTION_NAME.DEFAULT)
|
private repo: Repository<UserPrivilegeModel>,
|
||||||
private repo: Repository<UserPrivilegeModel>,
|
) {
|
||||||
) {
|
|
||||||
super(repo);
|
super(repo);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { IEvent } from "@nestjs/cqrs";
|
import { IEvent } from '@nestjs/cqrs';
|
||||||
|
|
||||||
export class UserPrivilegeChangeStatusEvent {
|
export class UserPrivilegeChangeStatusEvent {
|
||||||
constructor(public readonly data: IEvent) {}
|
constructor(public readonly data: IEvent) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { IEvent } from "@nestjs/cqrs";
|
import { IEvent } from '@nestjs/cqrs';
|
||||||
|
|
||||||
export class UserPrivilegeCreatedEvent {
|
export class UserPrivilegeCreatedEvent {
|
||||||
constructor(public readonly data: IEvent) {}
|
constructor(public readonly data: IEvent) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { IEvent } from "@nestjs/cqrs";
|
import { IEvent } from '@nestjs/cqrs';
|
||||||
|
|
||||||
export class UserPrivilegeDeletedEvent {
|
export class UserPrivilegeDeletedEvent {
|
||||||
constructor(public readonly data: IEvent) {}
|
constructor(public readonly data: IEvent) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { IEvent } from "@nestjs/cqrs";
|
import { IEvent } from '@nestjs/cqrs';
|
||||||
|
|
||||||
export class UserPrivilegeUpdatedEvent {
|
export class UserPrivilegeUpdatedEvent {
|
||||||
constructor(public readonly data: IEvent) {}
|
constructor(public readonly data: IEvent) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { BaseCoreEntity } from 'src/core/modules/domain/entities/base-core.entity';
|
||||||
|
|
||||||
|
export interface UserPrivilegeConfigurationEntity extends BaseCoreEntity {
|
||||||
|
module: string;
|
||||||
|
module_label: string;
|
||||||
|
menu: string;
|
||||||
|
menu_label: string;
|
||||||
|
sub_menu: string;
|
||||||
|
sub_menu_label: string;
|
||||||
|
view: boolean;
|
||||||
|
create: boolean;
|
||||||
|
edit: boolean;
|
||||||
|
delete: boolean;
|
||||||
|
cancel: boolean;
|
||||||
|
confirm: boolean;
|
||||||
|
index: number;
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
import { BaseStatusEntity } from "src/core/modules/domain/entities/base-status.entity";
|
import { BaseStatusEntity } from 'src/core/modules/domain/entities/base-status.entity';
|
||||||
|
|
||||||
export interface UserPrivilegeEntity extends BaseStatusEntity {
|
export interface UserPrivilegeEntity extends BaseStatusEntity {
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
import { Injectable } from "@nestjs/common";
|
|
||||||
import { BaseUpdateStatusManager } from "src/core/modules/domain/usecase/managers/base-update-status.manager";
|
|
||||||
import { UserPrivilegeEntity } from "../../entities/user-privilege.entity";
|
|
||||||
import { EventTopics } from "src/core/strings/constants/interface.constants";
|
|
||||||
import { UserPrivilegeModel } from "../../../data/model/user-privilege.model";
|
|
||||||
import { UserPrivilegeChangeStatusEvent } from "../../entities/event/user-privilege-change-status.event";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ActiveUserPrivilegeManager extends BaseUpdateStatusManager<UserPrivilegeEntity> {
|
|
||||||
|
|
||||||
getResult(): string {
|
|
||||||
return `Success active data ${this.result.name}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return UserPrivilegeModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
topic: UserPrivilegeChangeStatusEvent,
|
|
||||||
data: this.data,
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
import { Injectable } from "@nestjs/common";
|
|
||||||
import { BaseUpdateStatusManager } from "src/core/modules/domain/usecase/managers/base-update-status.manager";
|
|
||||||
import { UserPrivilegeEntity } from "../../entities/user-privilege.entity";
|
|
||||||
import { EventTopics } from "src/core/strings/constants/interface.constants";
|
|
||||||
import { UserPrivilegeModel } from "../../../data/model/user-privilege.model";
|
|
||||||
import { UserPrivilegeChangeStatusEvent } from "../../entities/event/user-privilege-change-status.event";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ConfirmUserPrivilegeManager extends BaseUpdateStatusManager<UserPrivilegeEntity> {
|
|
||||||
|
|
||||||
getResult(): string {
|
|
||||||
return `Success active data ${this.result.name}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return UserPrivilegeModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
topic: UserPrivilegeChangeStatusEvent,
|
|
||||||
data: this.data,
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
import { BaseCreateManager } from "src/core/modules/domain/usecase/managers/base-create.manager";
|
|
||||||
import { UserPrivilegeEntity } from "../../entities/user-privilege.entity";
|
|
||||||
import { Injectable } from "@nestjs/common";
|
|
||||||
import { UserPrivilegeModel } from "../../../data/model/user-privilege.model";
|
|
||||||
import { EventTopics } from "src/core/strings/constants/interface.constants";
|
|
||||||
import { UserPrivilegeCreatedEvent } from "../../entities/event/user-privilege-created.event";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class CreateUserPrivilegeManager extends BaseCreateManager<UserPrivilegeEntity> {
|
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
topic: UserPrivilegeCreatedEvent,
|
|
||||||
data: this.data,
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return UserPrivilegeModel;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
import { Injectable } from "@nestjs/common";
|
|
||||||
import { BaseDeleteManager } from "src/core/modules/domain/usecase/managers/base-delete.manager";
|
|
||||||
import { UserPrivilegeEntity } from "../../entities/user-privilege.entity";
|
|
||||||
import { EventTopics } from "src/core/strings/constants/interface.constants";
|
|
||||||
import { UserPrivilegeModel } from "../../../data/model/user-privilege.model";
|
|
||||||
import { UserPrivilegeDeletedEvent } from "../../entities/event/user-privilege-deleted.event";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class DeleteUserPrivilegeManager extends BaseDeleteManager<UserPrivilegeEntity> {
|
|
||||||
|
|
||||||
getResult(): string {
|
|
||||||
return `Success`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return UserPrivilegeModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
topic: UserPrivilegeDeletedEvent,
|
|
||||||
data: this.data,
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
import { Injectable } from "@nestjs/common";
|
|
||||||
import { BaseDetailManager } from "src/core/modules/domain/usecase/managers/base-detail.manager";
|
|
||||||
import { UserPrivilegeEntity } from "../../entities/user-privilege.entity";
|
|
||||||
import { FindOneOptions } from "typeorm";
|
|
||||||
import { TABLE_NAME } from "src/core/strings/constants/table.constants";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class DetailUserPrivilegeManager extends BaseDetailManager<UserPrivilegeEntity> {
|
|
||||||
|
|
||||||
get setFindProperties(): any {
|
|
||||||
return {
|
|
||||||
id: this.dataId
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get selectData(): string[] {
|
|
||||||
return [
|
|
||||||
'id',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
get relationData(): string[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async prepareData(): Promise<void> {
|
|
||||||
this.tableName = TABLE_NAME.USER_PRIVILEGE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
import { Injectable } from "@nestjs/common";
|
|
||||||
import { BaseUpdateStatusManager } from "src/core/modules/domain/usecase/managers/base-update-status.manager";
|
|
||||||
import { UserPrivilegeEntity } from "../../entities/user-privilege.entity";
|
|
||||||
import { EventTopics } from "src/core/strings/constants/interface.constants";
|
|
||||||
import { UserPrivilegeModel } from "../../../data/model/user-privilege.model";
|
|
||||||
import { UserPrivilegeChangeStatusEvent } from "../../entities/event/user-privilege-change-status.event";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class InactiveUserPrivilegeManager extends BaseUpdateStatusManager<UserPrivilegeEntity> {
|
|
||||||
|
|
||||||
getResult(): string {
|
|
||||||
return `Success inactive data ${this.result.name}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return UserPrivilegeModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
topic: UserPrivilegeChangeStatusEvent,
|
|
||||||
data: this.data,
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
import { Injectable } from "@nestjs/common";
|
|
||||||
import { BaseIndexManager } from "src/core/modules/domain/usecase/managers/base-index.manager";
|
|
||||||
import { UserPrivilegeEntity } from "../../entities/user-privilege.entity";
|
|
||||||
import { SelectQueryBuilder } from "typeorm";
|
|
||||||
import { BaseFilterEntity } from "src/core/modules/domain/entities/base-filter.entity";
|
|
||||||
import { TABLE_NAME } from "src/core/strings/constants/table.constants";
|
|
||||||
import { Param } from "src/core/helpers/query/specific-search.helper";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class IndexUserPrivilegeManager extends BaseIndexManager<UserPrivilegeEntity> {
|
|
||||||
|
|
||||||
async prepareData(): Promise<void> {
|
|
||||||
this.tableName = TABLE_NAME.USER_PRIVILEGE;
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
get specificFilter(): Param[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
setQueryFilter(
|
|
||||||
queryBuilder: SelectQueryBuilder<UserPrivilegeEntity>
|
|
||||||
): SelectQueryBuilder<UserPrivilegeEntity> {
|
|
||||||
|
|
||||||
if (this.filterParam.q) {
|
|
||||||
queryBuilder.andWhere('status = :q', {
|
|
||||||
q: this.filterParam.q
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return queryBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
setFilterSearch(): string[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
import { Injectable } from "@nestjs/common";
|
|
||||||
import { BaseUpdateManager } from "src/core/modules/domain/usecase/managers/base-update.manager";
|
|
||||||
import { UserPrivilegeEntity } from "../../entities/user-privilege.entity";
|
|
||||||
import { EventTopics } from "src/core/strings/constants/interface.constants";
|
|
||||||
import { UserPrivilegeModel } from "../../../data/model/user-privilege.model";
|
|
||||||
import { UserPrivilegeUpdatedEvent } from "../../entities/event/user-privilege-updated.event";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class UpdateUserPrivilegeManager extends BaseUpdateManager<UserPrivilegeEntity> {
|
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return UserPrivilegeModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
topic: UserPrivilegeUpdatedEvent,
|
|
||||||
data: this.data,
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
import {
|
||||||
|
PrivilegeAdminConstant,
|
||||||
|
PrivilegePOSConstant,
|
||||||
|
} from 'src/core/strings/constants/privilege.constants';
|
||||||
|
|
||||||
|
export class UserPrivilegeConfigurationHelper {
|
||||||
|
static createConfigurations() {
|
||||||
|
const privilege = [
|
||||||
|
...PrivilegeAdminConstant.map((item) => {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
module: 'ADMIN_PAGE',
|
||||||
|
module_label: 'Admin Page',
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
...PrivilegePOSConstant.map((item) => {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
module: 'POS',
|
||||||
|
module_label: 'Point of Sales',
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
|
||||||
|
privilege?.forEach((item) => {
|
||||||
|
item.actions?.forEach((element) => {
|
||||||
|
item[element] = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return privilege;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { UserPrivilegeConfigurationEntity } from '../../../entities/user-privilege-configuration.entity';
|
||||||
|
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { BaseCustomManager } from 'src/core/modules/domain/usecase/managers/base-custom.manager';
|
||||||
|
import { UserPrivilegeConfigurationModel } from 'src/modules/user-related/user-privilege/data/models/user-privilege-configuration.model';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class UpdateUserPrivilegeConfigurationManager extends BaseCustomManager<UserPrivilegeConfigurationEntity> {
|
||||||
|
async validateProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async process(): Promise<void> {
|
||||||
|
this.result = await this.dataService.update(
|
||||||
|
this.queryRunner,
|
||||||
|
this.entityTarget,
|
||||||
|
{ id: this.data.id },
|
||||||
|
this.data,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
getResult() {
|
||||||
|
return this.result;
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return UserPrivilegeConfigurationModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { UpdateUserPrivilegeConfigurationManager } from './managers/update-user-privilege-configuration.manager';
|
||||||
|
import { UserPrivilegeConfigurationEntity } from '../../entities/user-privilege-configuration.entity';
|
||||||
|
import { UserPrivilegeConfigurationService } from '../../../data/service/user-privilege-configuration.service';
|
||||||
|
import { IndexUserPrivilegeConfigurationManager } from './managers/index-user-privilege-configuration.manager';
|
||||||
|
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class UserPrivilegeConfigurationDataOrchestrator {
|
||||||
|
constructor(
|
||||||
|
private updateManager: UpdateUserPrivilegeConfigurationManager,
|
||||||
|
private indexManager: IndexUserPrivilegeConfigurationManager,
|
||||||
|
private serviceData: UserPrivilegeConfigurationService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
async update(data): Promise<UserPrivilegeConfigurationEntity> {
|
||||||
|
this.updateManager.setData(data);
|
||||||
|
this.updateManager.setService(this.serviceData);
|
||||||
|
await this.updateManager.execute();
|
||||||
|
return this.updateManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async index(
|
||||||
|
params,
|
||||||
|
): Promise<PaginationResponse<UserPrivilegeConfigurationEntity>> {
|
||||||
|
this.indexManager.setFilterParam(params);
|
||||||
|
this.indexManager.setService(this.serviceData);
|
||||||
|
await this.indexManager.execute();
|
||||||
|
return this.indexManager.getResult();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,69 +0,0 @@
|
||||||
import { Injectable } from "@nestjs/common";
|
|
||||||
import { CreateUserPrivilegeManager } from "./managers/create-user-privilege.manager";
|
|
||||||
import { UserPrivilegeDataService } from "../../data/service/user-privilege-data.service";
|
|
||||||
import { UserPrivilegeEntity } from "../entities/user-privilege.entity";
|
|
||||||
import { DeleteUserPrivilegeManager } from "./managers/delete-user-privilege.manager";
|
|
||||||
import { UpdateUserPrivilegeManager } from "./managers/update-user-privilege.manager";
|
|
||||||
import { BaseDataTransactionOrchestrator } from "src/core/modules/domain/usecase/orchestrators/base-data-transaction.orchestrator";
|
|
||||||
import { ActiveUserPrivilegeManager } from "./managers/active-user-privilege.manager";
|
|
||||||
import { InactiveUserPrivilegeManager } from "./managers/inactive-user-privilege.manager";
|
|
||||||
import { ConfirmUserPrivilegeManager } from "./managers/confirm-user-privilege.manager";
|
|
||||||
import { STATUS } from "src/core/strings/constants/base.constants";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class UserPrivilegeDataOrchestrator extends BaseDataTransactionOrchestrator<UserPrivilegeEntity> {
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private createManager: CreateUserPrivilegeManager,
|
|
||||||
private updateManager: UpdateUserPrivilegeManager,
|
|
||||||
private deleteManager: DeleteUserPrivilegeManager,
|
|
||||||
private activeManager: ActiveUserPrivilegeManager,
|
|
||||||
private confirmManager: ConfirmUserPrivilegeManager,
|
|
||||||
private inactiveManager: InactiveUserPrivilegeManager,
|
|
||||||
private serviceData: UserPrivilegeDataService,
|
|
||||||
) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
async create(data): Promise<UserPrivilegeEntity> {
|
|
||||||
this.createManager.setData(data);
|
|
||||||
this.createManager.setService(this.serviceData);
|
|
||||||
await this.createManager.execute()
|
|
||||||
return this.createManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async update(dataId, data): Promise<UserPrivilegeEntity> {
|
|
||||||
this.updateManager.setData(dataId, data);
|
|
||||||
this.updateManager.setService(this.serviceData);
|
|
||||||
await this.updateManager.execute();
|
|
||||||
return this.updateManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async delete(dataId): Promise<String> {
|
|
||||||
this.deleteManager.setData(dataId);
|
|
||||||
this.deleteManager.setService(this.serviceData);
|
|
||||||
await this.deleteManager.execute();
|
|
||||||
return this.deleteManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async active(dataId): Promise<String> {
|
|
||||||
this.activeManager.setData(dataId, STATUS.ACTIVE)
|
|
||||||
this.activeManager.setService(this.serviceData);
|
|
||||||
await this.activeManager.execute();
|
|
||||||
return this.activeManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async confirm(dataId): Promise<String> {
|
|
||||||
this.confirmManager.setData(dataId, STATUS.ACTIVE)
|
|
||||||
this.confirmManager.setService(this.serviceData);
|
|
||||||
await this.confirmManager.execute();
|
|
||||||
return this.confirmManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async inactive(dataId): Promise<String> {
|
|
||||||
this.inactiveManager.setData(dataId, STATUS.INACTIVE)
|
|
||||||
this.inactiveManager.setService(this.serviceData);
|
|
||||||
await this.inactiveManager.execute();
|
|
||||||
return this.inactiveManager.getResult();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
import { Injectable } from "@nestjs/common";
|
|
||||||
import { IndexUserPrivilegeManager } from "./managers/index-user-privilege.manager";
|
|
||||||
import { UserPrivilegeReadService } from "../../data/service/user-privilege-read.service";
|
|
||||||
import { UserPrivilegeEntity } from "../entities/user-privilege.entity";
|
|
||||||
import { PaginationResponse } from "src/core/response/domain/ok-response.interface";
|
|
||||||
import { BaseReadOrchestrator } from "src/core/modules/domain/usecase/orchestrators/base-read.orchestrator";
|
|
||||||
import { DetailUserPrivilegeManager } from "./managers/detail-user-privilege.manager";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class UserPrivilegeReadOrchestrator extends BaseReadOrchestrator<UserPrivilegeEntity> {
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private indexManager: IndexUserPrivilegeManager,
|
|
||||||
private detailManager: DetailUserPrivilegeManager,
|
|
||||||
private serviceData: UserPrivilegeReadService,
|
|
||||||
) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
async index(params): Promise<PaginationResponse<UserPrivilegeEntity>> {
|
|
||||||
this.indexManager.setFilterParam(params)
|
|
||||||
this.indexManager.setService(this.serviceData)
|
|
||||||
await this.indexManager.execute()
|
|
||||||
return this.indexManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async detail(dataId: string): Promise<UserPrivilegeEntity> {
|
|
||||||
this.detailManager.setData(dataId);
|
|
||||||
this.detailManager.setService(this.serviceData);
|
|
||||||
await this.detailManager.execute();
|
|
||||||
return this.detailManager.getResult();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||||
|
import { UserPrivilegeEntity } from '../../../entities/user-privilege.entity';
|
||||||
|
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { UserPrivilegeModel } from '../../../../data/models/user-privilege.model';
|
||||||
|
import { UserPrivilegeChangeStatusEvent } from '../../../entities/event/user-privilege-change-status.event';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ActiveUserPrivilegeManager extends BaseUpdateStatusManager<UserPrivilegeEntity> {
|
||||||
|
getResult(): string {
|
||||||
|
return `Success active data ${this.result.name}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async validateProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return UserPrivilegeModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: UserPrivilegeChangeStatusEvent,
|
||||||
|
data: this.data,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||||
|
import { UserPrivilegeEntity } from '../../../entities/user-privilege.entity';
|
||||||
|
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { UserPrivilegeModel } from '../../../../data/models/user-privilege.model';
|
||||||
|
import { UserPrivilegeChangeStatusEvent } from '../../../entities/event/user-privilege-change-status.event';
|
||||||
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
|
|
||||||
|
export class BatchActiveUserPrivilegeManager extends BaseBatchUpdateStatusManager<UserPrivilegeEntity> {
|
||||||
|
validateData(data: UserPrivilegeEntity): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return UserPrivilegeModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: UserPrivilegeChangeStatusEvent,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
getResult(): BatchResult {
|
||||||
|
return this.result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||||
|
import { UserPrivilegeEntity } from '../../../entities/user-privilege.entity';
|
||||||
|
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { UserPrivilegeModel } from '../../../../data/models/user-privilege.model';
|
||||||
|
import { UserPrivilegeChangeStatusEvent } from '../../../entities/event/user-privilege-change-status.event';
|
||||||
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
|
|
||||||
|
export class BatchConfirmUserPrivilegeManager extends BaseBatchUpdateStatusManager<UserPrivilegeEntity> {
|
||||||
|
validateData(data: UserPrivilegeEntity): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return UserPrivilegeModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: UserPrivilegeChangeStatusEvent,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
getResult(): BatchResult {
|
||||||
|
return this.result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
import { BaseBatchDeleteManager } from 'src/core/modules/domain/usecase/managers/base-batch-delete.manager';
|
||||||
|
import { UserPrivilegeEntity } from '../../../entities/user-privilege.entity';
|
||||||
|
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { UserPrivilegeModel } from '../../../../data/models/user-privilege.model';
|
||||||
|
import { UserPrivilegeDeletedEvent } from '../../../entities/event/user-privilege-deleted.event';
|
||||||
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
|
|
||||||
|
export class BatchDeleteUserPrivilegeManager extends BaseBatchDeleteManager<UserPrivilegeEntity> {
|
||||||
|
async beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async validateData(data: UserPrivilegeEntity): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return UserPrivilegeModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: UserPrivilegeDeletedEvent,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
getResult(): BatchResult {
|
||||||
|
return this.result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||||
|
import { UserPrivilegeEntity } from '../../../entities/user-privilege.entity';
|
||||||
|
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { UserPrivilegeModel } from '../../../../data/models/user-privilege.model';
|
||||||
|
import { UserPrivilegeChangeStatusEvent } from '../../../entities/event/user-privilege-change-status.event';
|
||||||
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
|
|
||||||
|
export class BatchInactiveUserPrivilegeManager extends BaseBatchUpdateStatusManager<UserPrivilegeEntity> {
|
||||||
|
validateData(data: UserPrivilegeEntity): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return UserPrivilegeModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: UserPrivilegeChangeStatusEvent,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
getResult(): BatchResult {
|
||||||
|
return this.result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||||
|
import { UserPrivilegeEntity } from '../../../entities/user-privilege.entity';
|
||||||
|
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { UserPrivilegeModel } from '../../../../data/models/user-privilege.model';
|
||||||
|
import { UserPrivilegeChangeStatusEvent } from '../../../entities/event/user-privilege-change-status.event';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ConfirmUserPrivilegeManager extends BaseUpdateStatusManager<UserPrivilegeEntity> {
|
||||||
|
getResult(): string {
|
||||||
|
return `Success active data ${this.result.name}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async validateProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return UserPrivilegeModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: UserPrivilegeChangeStatusEvent,
|
||||||
|
data: this.data,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
import { BaseCreateManager } from 'src/core/modules/domain/usecase/managers/base-create.manager';
|
||||||
|
import { UserPrivilegeEntity } from '../../../entities/user-privilege.entity';
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { UserPrivilegeModel } from '../../../../data/models/user-privilege.model';
|
||||||
|
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { UserPrivilegeCreatedEvent } from '../../../entities/event/user-privilege-created.event';
|
||||||
|
import { UserPrivilegeConfigurationHelper } from '../../user-privilege-configuration/helpers/generate-user-privilege-configuration.helper';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class CreateUserPrivilegeManager extends BaseCreateManager<UserPrivilegeEntity> {
|
||||||
|
async beforeProcess(): Promise<void> {
|
||||||
|
const configs = UserPrivilegeConfigurationHelper.createConfigurations();
|
||||||
|
Object.assign(this.data, {
|
||||||
|
user_privilege_configurations: configs,
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async generateConfig(): Promise<void> {}
|
||||||
|
|
||||||
|
get uniqueColumns(): string[] {
|
||||||
|
return ['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: UserPrivilegeCreatedEvent,
|
||||||
|
data: this.data,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return UserPrivilegeModel;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-delete.manager';
|
||||||
|
import { UserPrivilegeEntity } from '../../../entities/user-privilege.entity';
|
||||||
|
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { UserPrivilegeModel } from '../../../../data/models/user-privilege.model';
|
||||||
|
import { UserPrivilegeDeletedEvent } from '../../../entities/event/user-privilege-deleted.event';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class DeleteUserPrivilegeManager extends BaseDeleteManager<UserPrivilegeEntity> {
|
||||||
|
getResult(): string {
|
||||||
|
return `Success`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async validateProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return UserPrivilegeModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: UserPrivilegeDeletedEvent,
|
||||||
|
data: this.data,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||||
|
import { UserPrivilegeEntity } from '../../../entities/user-privilege.entity';
|
||||||
|
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { UserPrivilegeModel } from '../../../../data/models/user-privilege.model';
|
||||||
|
import { UserPrivilegeChangeStatusEvent } from '../../../entities/event/user-privilege-change-status.event';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class InactiveUserPrivilegeManager extends BaseUpdateStatusManager<UserPrivilegeEntity> {
|
||||||
|
getResult(): string {
|
||||||
|
return `Success inactive data ${this.result.name}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async validateProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return UserPrivilegeModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: UserPrivilegeChangeStatusEvent,
|
||||||
|
data: this.data,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { BaseUpdateManager } from 'src/core/modules/domain/usecase/managers/base-update.manager';
|
||||||
|
import { UserPrivilegeEntity } from '../../../entities/user-privilege.entity';
|
||||||
|
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { UserPrivilegeModel } from '../../../../data/models/user-privilege.model';
|
||||||
|
import { UserPrivilegeUpdatedEvent } from '../../../entities/event/user-privilege-updated.event';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class UpdateUserPrivilegeManager extends BaseUpdateManager<UserPrivilegeEntity> {
|
||||||
|
async validateProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get uniqueColumns(): string[] {
|
||||||
|
return ['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return UserPrivilegeModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: UserPrivilegeUpdatedEvent,
|
||||||
|
data: this.data,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,106 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { CreateUserPrivilegeManager } from './managers/create-user-privilege.manager';
|
||||||
|
import { UserPrivilegeDataService } from '../../../data/service/user-privilege-data.service';
|
||||||
|
import { UserPrivilegeEntity } from '../../entities/user-privilege.entity';
|
||||||
|
import { DeleteUserPrivilegeManager } from './managers/delete-user-privilege.manager';
|
||||||
|
import { UpdateUserPrivilegeManager } from './managers/update-user-privilege.manager';
|
||||||
|
import { BaseDataTransactionOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-data-transaction.orchestrator';
|
||||||
|
import { ActiveUserPrivilegeManager } from './managers/active-user-privilege.manager';
|
||||||
|
import { InactiveUserPrivilegeManager } from './managers/inactive-user-privilege.manager';
|
||||||
|
import { ConfirmUserPrivilegeManager } from './managers/confirm-user-privilege.manager';
|
||||||
|
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||||
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
|
import { BatchConfirmUserPrivilegeManager } from './managers/batch-confirm-user-privilege.manager';
|
||||||
|
import { BatchInactiveUserPrivilegeManager } from './managers/batch-inactive-user-privilege.manager';
|
||||||
|
import { BatchActiveUserPrivilegeManager } from './managers/batch-active-user-privilege.manager';
|
||||||
|
import { BatchDeleteUserPrivilegeManager } from './managers/batch-delete-user-privilege.manager';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class UserPrivilegeDataOrchestrator extends BaseDataTransactionOrchestrator<UserPrivilegeEntity> {
|
||||||
|
constructor(
|
||||||
|
private createManager: CreateUserPrivilegeManager,
|
||||||
|
private updateManager: UpdateUserPrivilegeManager,
|
||||||
|
private deleteManager: DeleteUserPrivilegeManager,
|
||||||
|
private activeManager: ActiveUserPrivilegeManager,
|
||||||
|
private confirmManager: ConfirmUserPrivilegeManager,
|
||||||
|
private inactiveManager: InactiveUserPrivilegeManager,
|
||||||
|
private batchDeleteManager: BatchDeleteUserPrivilegeManager,
|
||||||
|
private batchActiveManager: BatchActiveUserPrivilegeManager,
|
||||||
|
private batchConfirmManager: BatchConfirmUserPrivilegeManager,
|
||||||
|
private batchInactiveManager: BatchInactiveUserPrivilegeManager,
|
||||||
|
private serviceData: UserPrivilegeDataService,
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data): Promise<UserPrivilegeEntity> {
|
||||||
|
this.createManager.setData(data);
|
||||||
|
this.createManager.setService(this.serviceData);
|
||||||
|
await this.createManager.execute();
|
||||||
|
await this.createManager.generateConfig();
|
||||||
|
return this.createManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(dataId, data): Promise<UserPrivilegeEntity> {
|
||||||
|
this.updateManager.setData(dataId, data);
|
||||||
|
this.updateManager.setService(this.serviceData);
|
||||||
|
await this.updateManager.execute();
|
||||||
|
return this.updateManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(dataId): Promise<String> {
|
||||||
|
this.deleteManager.setData(dataId);
|
||||||
|
this.deleteManager.setService(this.serviceData);
|
||||||
|
await this.deleteManager.execute();
|
||||||
|
return this.deleteManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async batchDelete(dataIds: string[]): Promise<BatchResult> {
|
||||||
|
this.batchDeleteManager.setData(dataIds);
|
||||||
|
this.batchDeleteManager.setService(this.serviceData);
|
||||||
|
await this.batchDeleteManager.execute();
|
||||||
|
return this.batchDeleteManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async active(dataId): Promise<String> {
|
||||||
|
this.activeManager.setData(dataId, STATUS.ACTIVE);
|
||||||
|
this.activeManager.setService(this.serviceData);
|
||||||
|
await this.activeManager.execute();
|
||||||
|
return this.activeManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async batchActive(dataIds: string[]): Promise<BatchResult> {
|
||||||
|
this.batchActiveManager.setData(dataIds, STATUS.ACTIVE);
|
||||||
|
this.batchActiveManager.setService(this.serviceData);
|
||||||
|
await this.batchActiveManager.execute();
|
||||||
|
return this.batchActiveManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async confirm(dataId): Promise<String> {
|
||||||
|
this.confirmManager.setData(dataId, STATUS.ACTIVE);
|
||||||
|
this.confirmManager.setService(this.serviceData);
|
||||||
|
await this.confirmManager.execute();
|
||||||
|
return this.confirmManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async batchConfirm(dataIds: string[]): Promise<BatchResult> {
|
||||||
|
this.batchConfirmManager.setData(dataIds, STATUS.ACTIVE);
|
||||||
|
this.batchConfirmManager.setService(this.serviceData);
|
||||||
|
await this.batchConfirmManager.execute();
|
||||||
|
return this.batchConfirmManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async inactive(dataId): Promise<String> {
|
||||||
|
this.inactiveManager.setData(dataId, STATUS.INACTIVE);
|
||||||
|
this.inactiveManager.setService(this.serviceData);
|
||||||
|
await this.inactiveManager.execute();
|
||||||
|
return this.inactiveManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async batchInactive(dataIds: string[]): Promise<BatchResult> {
|
||||||
|
this.batchInactiveManager.setData(dataIds, STATUS.INACTIVE);
|
||||||
|
this.batchInactiveManager.setService(this.serviceData);
|
||||||
|
await this.batchInactiveManager.execute();
|
||||||
|
return this.batchInactiveManager.getResult();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,13 @@
|
||||||
import { BaseStatusDto } from "src/core/modules/infrastructure/dto/base-status.dto";
|
import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.dto';
|
||||||
import { UserPrivilegeEntity } from "../../domain/entities/user-privilege.entity";
|
import { UserPrivilegeEntity } from '../../domain/entities/user-privilege.entity';
|
||||||
import { ApiProperty } from "@nestjs/swagger";
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
import { IsString } from "class-validator";
|
import { IsString } from 'class-validator';
|
||||||
|
|
||||||
export class CreateUserPrivilegeDto extends BaseStatusDto implements UserPrivilegeEntity {
|
export class CreateUserPrivilegeDto
|
||||||
@ApiProperty({ name: 'name', required: true })
|
extends BaseStatusDto
|
||||||
@IsString()
|
implements UserPrivilegeEntity
|
||||||
name: string;
|
{
|
||||||
}
|
@ApiProperty({ name: 'name', required: true })
|
||||||
|
@IsString()
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
import { BaseCoreDto } from 'src/core/modules/infrastructure/dto/base-core.dto';
|
||||||
|
import { UserPrivilegeConfigurationEntity } from '../../domain/entities/user-privilege-configuration.entity';
|
||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsBoolean, IsString, ValidateIf } from 'class-validator';
|
||||||
|
import { Exclude } from 'class-transformer';
|
||||||
|
|
||||||
|
export class UserPrivilegeConfigurationDto
|
||||||
|
extends BaseCoreDto
|
||||||
|
implements UserPrivilegeConfigurationEntity
|
||||||
|
{
|
||||||
|
@ApiProperty({ type: String, required: true, example: 'ADMIN_PAGE' })
|
||||||
|
@IsString()
|
||||||
|
module: string;
|
||||||
|
|
||||||
|
@ApiProperty({ type: String, required: true, example: 'admin page' })
|
||||||
|
@IsString()
|
||||||
|
module_label: string;
|
||||||
|
|
||||||
|
@ApiProperty({ type: String, required: true, example: 'DASHBOARD' })
|
||||||
|
@IsString()
|
||||||
|
menu: string;
|
||||||
|
|
||||||
|
@ApiProperty({ type: String, required: true, example: 'dashboard' })
|
||||||
|
@IsString()
|
||||||
|
menu_label: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
sub_menu: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
sub_menu_label: string;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
})
|
||||||
|
@ValidateIf((body) => body.view)
|
||||||
|
@IsBoolean()
|
||||||
|
view: boolean;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
})
|
||||||
|
@ValidateIf((body) => body.create)
|
||||||
|
@IsBoolean()
|
||||||
|
create: boolean;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
})
|
||||||
|
@ValidateIf((body) => body.edit)
|
||||||
|
@IsBoolean()
|
||||||
|
edit: boolean;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
})
|
||||||
|
@ValidateIf((body) => body.delete)
|
||||||
|
@IsBoolean()
|
||||||
|
delete: boolean;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
})
|
||||||
|
@ValidateIf((body) => body.cancel)
|
||||||
|
@IsBoolean()
|
||||||
|
cancel: boolean;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
})
|
||||||
|
@ValidateIf((body) => body.confirm)
|
||||||
|
@IsBoolean()
|
||||||
|
confirm: boolean;
|
||||||
|
|
||||||
|
@Exclude()
|
||||||
|
index: number;
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
import { Body, Controller, Get, Param, Put, Query } from '@nestjs/common';
|
||||||
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
|
import { Public } from 'src/core/guards';
|
||||||
|
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||||
|
import { UserPrivilegeConfigurationDataOrchestrator } from '../domain/usecases/user-privilege-configuration/user-privilege-configuration-data.orchestrator';
|
||||||
|
import { UserPrivilegeConfigurationDto } from './dto/user-privilege-configuration.dto';
|
||||||
|
import { UserPrivilegeConfigurationEntity } from '../domain/entities/user-privilege-configuration.entity';
|
||||||
|
import { Pagination } from 'src/core/response';
|
||||||
|
import { FilterUserPrivilegeConfigurationDto } from './dto/filter-user-privilege-configuration.dto';
|
||||||
|
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
||||||
|
|
||||||
|
@ApiTags(
|
||||||
|
`${MODULE_NAME.USER_PRIVILEGE_CONFIGURATION.split('-').join(' ')} - data`,
|
||||||
|
)
|
||||||
|
@Controller(MODULE_NAME.USER_PRIVILEGE_CONFIGURATION)
|
||||||
|
@Public(false)
|
||||||
|
export class UserPrivilegeConfigurationController {
|
||||||
|
constructor(
|
||||||
|
private orchestrator: UserPrivilegeConfigurationDataOrchestrator,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
@Put()
|
||||||
|
async update(
|
||||||
|
@Body() data: UserPrivilegeConfigurationDto,
|
||||||
|
): Promise<UserPrivilegeConfigurationEntity> {
|
||||||
|
return await this.orchestrator.update(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
async index(
|
||||||
|
@Query() params: FilterUserPrivilegeConfigurationDto,
|
||||||
|
): Promise<PaginationResponse<UserPrivilegeConfigurationEntity>> {
|
||||||
|
return await this.orchestrator.index(params);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,102 +1,79 @@
|
||||||
import { Body, Controller, Delete, Param, Patch, Post, Put } from "@nestjs/common";
|
import {
|
||||||
import { UserPrivilegeDataOrchestrator } from "../domain/usecases/user-privilege-data.orchestrator";
|
Body,
|
||||||
import { CreateUserPrivilegeDto } from "./dto/create-user-privilege.dto";
|
Controller,
|
||||||
import { MODULE_NAME } from "src/core/strings/constants/module.constants";
|
Delete,
|
||||||
import { ApiTags } from "@nestjs/swagger";
|
Param,
|
||||||
import { Unprotected } from "src/core/guards";
|
Patch,
|
||||||
import * as Nano from 'nano'
|
Post,
|
||||||
import { UserPrivilegeEntity } from "../domain/entities/user-privilege.entity";
|
Put,
|
||||||
|
} from '@nestjs/common';
|
||||||
|
import { UserPrivilegeDataOrchestrator } from '../domain/usecases/user-privilege/user-privilege-data.orchestrator';
|
||||||
|
import { CreateUserPrivilegeDto } from './dto/create-user-privilege.dto';
|
||||||
|
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||||
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
|
import { UserPrivilegeEntity } from '../domain/entities/user-privilege.entity';
|
||||||
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
|
import { BatchIdsDto } from 'src/core/modules/infrastructure/dto/base-batch.dto';
|
||||||
|
import { Public } from 'src/core/guards';
|
||||||
|
|
||||||
@ApiTags(`${MODULE_NAME.USER_PRIVILEGE.split('-').join(' ')} - data`)
|
@ApiTags(`${MODULE_NAME.USER_PRIVILEGE.split('-').join(' ')} - data`)
|
||||||
@Controller(MODULE_NAME.USER_PRIVILEGE)
|
@Controller(MODULE_NAME.USER_PRIVILEGE)
|
||||||
@Unprotected()
|
@Public(false)
|
||||||
export class UserPrivilegeDataController {
|
export class UserPrivilegeDataController {
|
||||||
constructor(
|
constructor(private orchestrator: UserPrivilegeDataOrchestrator) {}
|
||||||
private orchestrator: UserPrivilegeDataOrchestrator
|
|
||||||
) {}
|
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
async create(
|
async create(
|
||||||
@Body() data: CreateUserPrivilegeDto,
|
@Body() data: CreateUserPrivilegeDto,
|
||||||
): Promise<UserPrivilegeEntity> {
|
): Promise<UserPrivilegeEntity> {
|
||||||
return await this.orchestrator.create(data);
|
return await this.orchestrator.create(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put(':id')
|
@Put('/batch-delete')
|
||||||
async update(
|
async batchDeleted(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
||||||
@Param('id') dataId: string,
|
return await this.orchestrator.batchDelete(body.ids);
|
||||||
@Body() data: CreateUserPrivilegeDto,
|
}
|
||||||
): Promise<UserPrivilegeEntity> {
|
|
||||||
return await this.orchestrator.update(dataId, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Delete(':id')
|
@Patch(':id/active')
|
||||||
async delete(
|
async active(@Param('id') dataId: string): Promise<String> {
|
||||||
@Param('id') dataId: string,
|
return await this.orchestrator.active(dataId);
|
||||||
): Promise<String> {
|
}
|
||||||
return await this.orchestrator.delete(dataId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Patch(':id/active')
|
@Put('/batch-active')
|
||||||
async active(
|
async batchActive(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
||||||
@Param('id') dataId: string,
|
return await this.orchestrator.batchActive(body.ids);
|
||||||
): Promise<String> {
|
}
|
||||||
return await this.orchestrator.active(dataId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Patch(':id/confirm')
|
|
||||||
async confirm(
|
|
||||||
@Param('id') dataId: string,
|
|
||||||
): Promise<String> {
|
|
||||||
return await this.orchestrator.confirm(dataId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Patch(':id/inactive')
|
@Patch(':id/confirm')
|
||||||
async inactive(
|
async confirm(@Param('id') dataId: string): Promise<String> {
|
||||||
@Param('id') dataId: string,
|
return await this.orchestrator.confirm(dataId);
|
||||||
): Promise<String> {
|
}
|
||||||
return await this.orchestrator.inactive(dataId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Put('/batch-confirm')
|
||||||
|
async batchConfirm(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
||||||
|
return await this.orchestrator.batchConfirm(body.ids);
|
||||||
|
}
|
||||||
|
|
||||||
// @Post('pouch')
|
@Patch(':id/inactive')
|
||||||
// async createDoc(
|
async inactive(@Param('id') dataId: string): Promise<String> {
|
||||||
// @Body() entity: CreateUserPrivilegeDto
|
return await this.orchestrator.inactive(dataId);
|
||||||
// ) {
|
}
|
||||||
// try {
|
|
||||||
// let n = Nano('http://admin:secret@127.0.0.1:5984')
|
|
||||||
// let db = await n.db.create('people')
|
|
||||||
// } catch (error) {
|
|
||||||
// console.log(error, 'dsa')
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Post('pouch/doc')
|
@Put('/batch-inactive')
|
||||||
// async createDocs(
|
async batchInactive(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
||||||
// @Body() entity: CreateUserPrivilegeDto
|
return await this.orchestrator.batchInactive(body.ids);
|
||||||
// ) {
|
}
|
||||||
// try {
|
|
||||||
// let n = Nano('http://admin:secret@127.0.0.1:5984')
|
|
||||||
// const people = n.use('people');
|
|
||||||
// const data = {
|
|
||||||
// id: '1212',
|
|
||||||
// name: 'dsadas'
|
|
||||||
// }
|
|
||||||
// return await people.insert({'_id': 'dsa', '_rev': JSON.stringify({'dsa': 'dsa'})})
|
|
||||||
// } catch (error) {
|
|
||||||
// console.log(error, 'dsa')
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Get('pouch')
|
@Put(':id')
|
||||||
// async getDoc(
|
async update(
|
||||||
// ) {
|
@Param('id') dataId: string,
|
||||||
// try {
|
@Body() data: CreateUserPrivilegeDto,
|
||||||
// let n = Nano('http://admin:secret@127.0.0.1:5984')
|
): Promise<UserPrivilegeEntity> {
|
||||||
// const people = n.use('people');
|
return await this.orchestrator.update(dataId, data);
|
||||||
// // return people.get();
|
}
|
||||||
// } catch (error) {
|
|
||||||
// console.log(error, 'dsa')
|
@Delete(':id')
|
||||||
// }
|
async delete(@Param('id') dataId: string): Promise<String> {
|
||||||
// }
|
return await this.orchestrator.delete(dataId);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,34 +1,30 @@
|
||||||
import { Controller, Get, Param, Query, Req } from "@nestjs/common";
|
import { Controller, Get, Param, Query } from '@nestjs/common';
|
||||||
import { FilterUserPrivilegeDto } from "./dto/filter-user-privilege.dto";
|
import { FilterUserPrivilegeDto } from './dto/filter-user-privilege.dto';
|
||||||
import { Pagination } from "src/core/response";
|
import { Pagination } from 'src/core/response';
|
||||||
import { PaginationResponse } from "src/core/response/domain/ok-response.interface";
|
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
||||||
import { UserPrivilegeEntity } from "../domain/entities/user-privilege.entity";
|
import { UserPrivilegeEntity } from '../domain/entities/user-privilege.entity';
|
||||||
import { UserPrivilegeReadOrchestrator } from "../domain/usecases/user-privilege-read.orchestrator";
|
import { UserPrivilegeReadOrchestrator } from '../domain/usecases/user-privilege/user-privilege-read.orchestrator';
|
||||||
import { ApiTags } from "@nestjs/swagger";
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import { MODULE_NAME } from "src/core/strings/constants/module.constants";
|
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||||
import { Unprotected } from "src/core/guards";
|
import { ExcludePrivilege, Public } from 'src/core/guards';
|
||||||
|
|
||||||
@ApiTags(`${MODULE_NAME.USER_PRIVILEGE.split('-').join(' ')} - read`)
|
@ApiTags(`${MODULE_NAME.USER_PRIVILEGE.split('-').join(' ')} - read`)
|
||||||
@Controller(MODULE_NAME.USER_PRIVILEGE)
|
@Controller(MODULE_NAME.USER_PRIVILEGE)
|
||||||
@Unprotected()
|
@Public(false)
|
||||||
export class UserPrivilegeReadController {
|
export class UserPrivilegeReadController {
|
||||||
constructor(
|
constructor(private orchestrator: UserPrivilegeReadOrchestrator) {}
|
||||||
private orchestrator: UserPrivilegeReadOrchestrator
|
|
||||||
) {}
|
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@Pagination()
|
@Pagination()
|
||||||
async index(
|
@ExcludePrivilege()
|
||||||
@Query() params: FilterUserPrivilegeDto
|
async index(
|
||||||
): Promise<PaginationResponse<UserPrivilegeEntity>> {
|
@Query() params: FilterUserPrivilegeDto,
|
||||||
return await this.orchestrator.index(params);
|
): Promise<PaginationResponse<UserPrivilegeEntity>> {
|
||||||
}
|
return await this.orchestrator.index(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
@Get(':id')
|
async detail(@Param('id') id: string): Promise<UserPrivilegeEntity> {
|
||||||
async detail(
|
return await this.orchestrator.detail(id);
|
||||||
@Param('id') id: string,
|
}
|
||||||
): Promise<UserPrivilegeEntity> {
|
}
|
||||||
return await this.orchestrator.detail(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,49 +1,68 @@
|
||||||
import { Module } from "@nestjs/common";
|
import { Module } from '@nestjs/common';
|
||||||
import { UserPrivilegeModel } from "./data/model/user-privilege.model";
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { ConfigModule } from "@nestjs/config";
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
import { TypeOrmModule } from "@nestjs/typeorm";
|
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||||
import { CONNECTION_NAME } from "src/core/strings/constants/base.constants";
|
import { UserPrivilegeDataService } from './data/service/user-privilege-data.service';
|
||||||
import { UserPrivilegeDataService } from "./data/service/user-privilege-data.service";
|
import { UserPrivilegeReadService } from './data/service/user-privilege-read.service';
|
||||||
import { UserPrivilegeReadService } from "./data/service/user-privilege-read.service";
|
import { UserPrivilegeReadController } from './infrastructure/user-privilege-read.controller';
|
||||||
import { UserPrivilegeReadController } from "./infrastructure/user-privilege-read.controller";
|
import { UserPrivilegeReadOrchestrator } from './domain/usecases/user-privilege/user-privilege-read.orchestrator';
|
||||||
import { UserPrivilegeReadOrchestrator } from "./domain/usecases/user-privilege-read.orchestrator";
|
import { UserPrivilegeDataController } from './infrastructure/user-privilege-data.controller';
|
||||||
import { UserPrivilegeDataController } from "./infrastructure/user-privilege-data.controller";
|
import { UserPrivilegeDataOrchestrator } from './domain/usecases/user-privilege/user-privilege-data.orchestrator';
|
||||||
import { UserPrivilegeDataOrchestrator } from "./domain/usecases/user-privilege-data.orchestrator";
|
import { CreateUserPrivilegeManager } from './domain/usecases/user-privilege/managers/create-user-privilege.manager';
|
||||||
import { CreateUserPrivilegeManager } from "./domain/usecases/managers/create-user-privilege.manager";
|
import { CqrsModule } from '@nestjs/cqrs';
|
||||||
import { CqrsModule } from "@nestjs/cqrs";
|
import { IndexUserPrivilegeManager } from './domain/usecases/user-privilege/managers/index-user-privilege.manager';
|
||||||
import { IndexUserPrivilegeManager } from "./domain/usecases/managers/index-user-privilege.manager";
|
import { DeleteUserPrivilegeManager } from './domain/usecases/user-privilege/managers/delete-user-privilege.manager';
|
||||||
import { DeleteUserPrivilegeManager } from "./domain/usecases/managers/delete-user-privilege.manager";
|
import { UpdateUserPrivilegeManager } from './domain/usecases/user-privilege/managers/update-user-privilege.manager';
|
||||||
import { UpdateUserPrivilegeManager } from "./domain/usecases/managers/update-user-privilege.manager";
|
import { ActiveUserPrivilegeManager } from './domain/usecases/user-privilege/managers/active-user-privilege.manager';
|
||||||
import { ActiveUserPrivilegeManager } from "./domain/usecases/managers/active-user-privilege.manager";
|
import { ConfirmUserPrivilegeManager } from './domain/usecases/user-privilege/managers/confirm-user-privilege.manager';
|
||||||
import { ConfirmUserPrivilegeManager } from "./domain/usecases/managers/confirm-user-privilege.manager";
|
import { InactiveUserPrivilegeManager } from './domain/usecases/user-privilege/managers/inactive-user-privilege.manager';
|
||||||
import { InactiveUserPrivilegeManager } from "./domain/usecases/managers/inactive-user-privilege.manager";
|
import { DetailUserPrivilegeManager } from './domain/usecases/user-privilege/managers/detail-user-privilege.manager';
|
||||||
import { DetailUserPrivilegeManager } from "./domain/usecases/managers/detail-user-privilege.manager";
|
import { BatchDeleteUserPrivilegeManager } from './domain/usecases/user-privilege/managers/batch-delete-user-privilege.manager';
|
||||||
|
import { BatchActiveUserPrivilegeManager } from './domain/usecases/user-privilege/managers/batch-active-user-privilege.manager';
|
||||||
|
import { BatchConfirmUserPrivilegeManager } from './domain/usecases/user-privilege/managers/batch-confirm-user-privilege.manager';
|
||||||
|
import { BatchInactiveUserPrivilegeManager } from './domain/usecases/user-privilege/managers/batch-inactive-user-privilege.manager';
|
||||||
|
import { UserPrivilegeConfigurationService } from './data/service/user-privilege-configuration.service';
|
||||||
|
import { UpdateUserPrivilegeConfigurationManager } from './domain/usecases/user-privilege-configuration/managers/update-user-privilege-configuration.manager';
|
||||||
|
import { UserPrivilegeConfigurationController } from './infrastructure/user-privilege-configuration.controller';
|
||||||
|
import { UserPrivilegeConfigurationDataOrchestrator } from './domain/usecases/user-privilege-configuration/user-privilege-configuration-data.orchestrator';
|
||||||
|
import { IndexUserPrivilegeConfigurationManager } from './domain/usecases/user-privilege-configuration/managers/index-user-privilege-configuration.manager';
|
||||||
|
import { UserPrivilegeModels } from './constants';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot(),
|
ConfigModule.forRoot(),
|
||||||
TypeOrmModule.forFeature([UserPrivilegeModel], CONNECTION_NAME.DEFAULT),
|
TypeOrmModule.forFeature(UserPrivilegeModels, CONNECTION_NAME.DEFAULT),
|
||||||
CqrsModule,
|
CqrsModule,
|
||||||
],
|
],
|
||||||
controllers: [
|
controllers: [
|
||||||
UserPrivilegeDataController,
|
UserPrivilegeDataController,
|
||||||
UserPrivilegeReadController
|
UserPrivilegeReadController,
|
||||||
],
|
UserPrivilegeConfigurationController,
|
||||||
providers: [
|
],
|
||||||
IndexUserPrivilegeManager,
|
providers: [
|
||||||
DetailUserPrivilegeManager,
|
IndexUserPrivilegeManager,
|
||||||
CreateUserPrivilegeManager,
|
DetailUserPrivilegeManager,
|
||||||
DeleteUserPrivilegeManager,
|
CreateUserPrivilegeManager,
|
||||||
UpdateUserPrivilegeManager,
|
DeleteUserPrivilegeManager,
|
||||||
ActiveUserPrivilegeManager,
|
UpdateUserPrivilegeManager,
|
||||||
ConfirmUserPrivilegeManager,
|
ActiveUserPrivilegeManager,
|
||||||
InactiveUserPrivilegeManager,
|
ConfirmUserPrivilegeManager,
|
||||||
|
InactiveUserPrivilegeManager,
|
||||||
|
BatchDeleteUserPrivilegeManager,
|
||||||
|
BatchActiveUserPrivilegeManager,
|
||||||
|
BatchConfirmUserPrivilegeManager,
|
||||||
|
BatchInactiveUserPrivilegeManager,
|
||||||
|
|
||||||
UserPrivilegeDataService,
|
IndexUserPrivilegeConfigurationManager,
|
||||||
UserPrivilegeReadService,
|
UpdateUserPrivilegeConfigurationManager,
|
||||||
|
|
||||||
UserPrivilegeDataOrchestrator,
|
UserPrivilegeDataService,
|
||||||
UserPrivilegeReadOrchestrator,
|
UserPrivilegeReadService,
|
||||||
],
|
UserPrivilegeConfigurationService,
|
||||||
})
|
|
||||||
export class UserPrivilegeModule {}
|
UserPrivilegeDataOrchestrator,
|
||||||
|
UserPrivilegeReadOrchestrator,
|
||||||
|
UserPrivilegeConfigurationDataOrchestrator,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class UserPrivilegeModule {}
|
||||||
|
|
Loading…
Reference in New Issue