mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-11 15:48:09 +00:00
Compare commits
1 Commits
fix/integr
...
task/sort-
Author | SHA1 | Date | |
---|---|---|---|
9176fe779e |
@ -397,11 +397,6 @@ export class ControllerRoute {
|
|||||||
public static readonly DELETE_USER_SUMMARY = 'Delete user by UUID';
|
public static readonly DELETE_USER_SUMMARY = 'Delete user by UUID';
|
||||||
public static readonly DELETE_USER_DESCRIPTION =
|
public static readonly DELETE_USER_DESCRIPTION =
|
||||||
'This endpoint deletes a user identified by their UUID. Accessible only by users with the Super Admin role.';
|
'This endpoint deletes a user identified by their UUID. Accessible only by users with the Super Admin role.';
|
||||||
|
|
||||||
public static readonly DELETE_USER_PROFILE_SUMMARY =
|
|
||||||
'Delete user profile by UUID';
|
|
||||||
public static readonly DELETE_USER_PROFILE_DESCRIPTION =
|
|
||||||
'This endpoint deletes a user profile identified by their UUID. Accessible only by users with the Super Admin role.';
|
|
||||||
public static readonly UPDATE_USER_WEB_AGREEMENT_SUMMARY =
|
public static readonly UPDATE_USER_WEB_AGREEMENT_SUMMARY =
|
||||||
'Update user web agreement by user UUID';
|
'Update user web agreement by user UUID';
|
||||||
public static readonly UPDATE_USER_WEB_AGREEMENT_DESCRIPTION =
|
public static readonly UPDATE_USER_WEB_AGREEMENT_DESCRIPTION =
|
||||||
|
@ -15,7 +15,6 @@ export enum ProductType {
|
|||||||
WL = 'WL',
|
WL = 'WL',
|
||||||
GD = 'GD',
|
GD = 'GD',
|
||||||
CUR = 'CUR',
|
CUR = 'CUR',
|
||||||
CUR_2 = 'CUR_2',
|
|
||||||
PC = 'PC',
|
PC = 'PC',
|
||||||
FOUR_S = '4S',
|
FOUR_S = '4S',
|
||||||
SIX_S = '6S',
|
SIX_S = '6S',
|
||||||
|
@ -8,14 +8,14 @@ import {
|
|||||||
Unique,
|
Unique,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
|
|
||||||
import { RoleType } from '@app/common/constants/role.type.enum';
|
|
||||||
import { UserStatusEnum } from '@app/common/constants/user-status.enum';
|
|
||||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
import { ProjectEntity } from '../../project/entities';
|
|
||||||
import { RoleTypeEntity } from '../../role-type/entities';
|
import { RoleTypeEntity } from '../../role-type/entities';
|
||||||
import { SpaceEntity } from '../../space/entities/space.entity';
|
import { UserStatusEnum } from '@app/common/constants/user-status.enum';
|
||||||
import { UserEntity } from '../../user/entities';
|
import { UserEntity } from '../../user/entities';
|
||||||
|
import { RoleType } from '@app/common/constants/role.type.enum';
|
||||||
import { InviteUserDto, InviteUserSpaceDto } from '../dtos';
|
import { InviteUserDto, InviteUserSpaceDto } from '../dtos';
|
||||||
|
import { ProjectEntity } from '../../project/entities';
|
||||||
|
import { SpaceEntity } from '../../space/entities/space.entity';
|
||||||
|
|
||||||
@Entity({ name: 'invite-user' })
|
@Entity({ name: 'invite-user' })
|
||||||
@Unique(['email', 'project'])
|
@Unique(['email', 'project'])
|
||||||
@ -82,10 +82,7 @@ export class InviteUserEntity extends AbstractEntity<InviteUserDto> {
|
|||||||
onDelete: 'CASCADE',
|
onDelete: 'CASCADE',
|
||||||
})
|
})
|
||||||
public roleType: RoleTypeEntity;
|
public roleType: RoleTypeEntity;
|
||||||
@OneToOne(() => UserEntity, (user) => user.inviteUser, {
|
@OneToOne(() => UserEntity, (user) => user.inviteUser, { nullable: true })
|
||||||
nullable: true,
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
})
|
|
||||||
@JoinColumn({ name: 'user_uuid' })
|
@JoinColumn({ name: 'user_uuid' })
|
||||||
user: UserEntity;
|
user: UserEntity;
|
||||||
@OneToMany(
|
@OneToMany(
|
||||||
@ -115,9 +112,7 @@ export class InviteUserSpaceEntity extends AbstractEntity<InviteUserSpaceDto> {
|
|||||||
})
|
})
|
||||||
public uuid: string;
|
public uuid: string;
|
||||||
|
|
||||||
@ManyToOne(() => InviteUserEntity, (inviteUser) => inviteUser.spaces, {
|
@ManyToOne(() => InviteUserEntity, (inviteUser) => inviteUser.spaces)
|
||||||
onDelete: 'CASCADE',
|
|
||||||
})
|
|
||||||
@JoinColumn({ name: 'invite_user_uuid' })
|
@JoinColumn({ name: 'invite_user_uuid' })
|
||||||
public inviteUser: InviteUserEntity;
|
public inviteUser: InviteUserEntity;
|
||||||
|
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
import {
|
import {
|
||||||
Column,
|
Column,
|
||||||
Entity,
|
Entity,
|
||||||
Index,
|
|
||||||
JoinColumn,
|
|
||||||
ManyToOne,
|
ManyToOne,
|
||||||
OneToMany,
|
OneToMany,
|
||||||
Unique,
|
Unique,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
import { PermissionTypeEntity } from '../../permission/entities';
|
import { DeviceDto, DeviceUserPermissionDto } from '../dtos/device.dto';
|
||||||
import { PowerClampHourlyEntity } from '../../power-clamp/entities/power-clamp.entity';
|
|
||||||
import { PresenceSensorDailyDeviceEntity } from '../../presence-sensor/entities';
|
|
||||||
import { ProductEntity } from '../../product/entities';
|
import { ProductEntity } from '../../product/entities';
|
||||||
|
import { UserEntity } from '../../user/entities';
|
||||||
|
import { DeviceNotificationDto } from '../dtos';
|
||||||
|
import { PermissionTypeEntity } from '../../permission/entities';
|
||||||
import { SceneDeviceEntity } from '../../scene-device/entities';
|
import { SceneDeviceEntity } from '../../scene-device/entities';
|
||||||
import { SpaceEntity } from '../../space/entities/space.entity';
|
import { SpaceEntity } from '../../space/entities/space.entity';
|
||||||
import { SubspaceEntity } from '../../space/entities/subspace/subspace.entity';
|
import { SubspaceEntity } from '../../space/entities/subspace/subspace.entity';
|
||||||
import { NewTagEntity } from '../../tag';
|
import { NewTagEntity } from '../../tag';
|
||||||
import { UserEntity } from '../../user/entities';
|
import { PowerClampHourlyEntity } from '../../power-clamp/entities/power-clamp.entity';
|
||||||
import { DeviceNotificationDto } from '../dtos';
|
import { PresenceSensorDailyDeviceEntity } from '../../presence-sensor/entities';
|
||||||
import { DeviceDto, DeviceUserPermissionDto } from '../dtos/device.dto';
|
|
||||||
|
|
||||||
@Entity({ name: 'device' })
|
@Entity({ name: 'device' })
|
||||||
@Unique(['deviceTuyaUuid'])
|
@Unique(['deviceTuyaUuid'])
|
||||||
@ -111,7 +111,6 @@ export class DeviceNotificationEntity extends AbstractEntity<DeviceNotificationD
|
|||||||
|
|
||||||
@ManyToOne(() => UserEntity, (user) => user.userPermission, {
|
@ManyToOne(() => UserEntity, (user) => user.userPermission, {
|
||||||
nullable: false,
|
nullable: false,
|
||||||
onDelete: 'CASCADE',
|
|
||||||
})
|
})
|
||||||
user: UserEntity;
|
user: UserEntity;
|
||||||
|
|
||||||
@ -150,7 +149,6 @@ export class DeviceUserPermissionEntity extends AbstractEntity<DeviceUserPermiss
|
|||||||
|
|
||||||
@ManyToOne(() => UserEntity, (user) => user.userPermission, {
|
@ManyToOne(() => UserEntity, (user) => user.userPermission, {
|
||||||
nullable: false,
|
nullable: false,
|
||||||
onDelete: 'CASCADE',
|
|
||||||
})
|
})
|
||||||
user: UserEntity;
|
user: UserEntity;
|
||||||
constructor(partial: Partial<DeviceUserPermissionEntity>) {
|
constructor(partial: Partial<DeviceUserPermissionEntity>) {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { defaultProfilePicture } from '@app/common/constants/default.profile.picture';
|
|
||||||
import {
|
import {
|
||||||
Column,
|
Column,
|
||||||
DeleteDateColumn,
|
DeleteDateColumn,
|
||||||
@ -9,26 +8,27 @@ import {
|
|||||||
OneToOne,
|
OneToOne,
|
||||||
Unique,
|
Unique,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
import { OtpType } from '../../../../src/constants/otp-type.enum';
|
|
||||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
|
||||||
import { ClientEntity } from '../../client/entities';
|
|
||||||
import {
|
|
||||||
DeviceNotificationEntity,
|
|
||||||
DeviceUserPermissionEntity,
|
|
||||||
} from '../../device/entities';
|
|
||||||
import { InviteUserEntity } from '../../Invite-user/entities';
|
|
||||||
import { ProjectEntity } from '../../project/entities';
|
|
||||||
import { RegionEntity } from '../../region/entities';
|
|
||||||
import { RoleTypeEntity } from '../../role-type/entities';
|
|
||||||
import { SpaceEntity } from '../../space/entities/space.entity';
|
|
||||||
import { TimeZoneEntity } from '../../timezone/entities';
|
|
||||||
import { VisitorPasswordEntity } from '../../visitor-password/entities';
|
|
||||||
import {
|
import {
|
||||||
UserDto,
|
UserDto,
|
||||||
UserNotificationDto,
|
UserNotificationDto,
|
||||||
UserOtpDto,
|
UserOtpDto,
|
||||||
UserSpaceDto,
|
UserSpaceDto,
|
||||||
} from '../dtos';
|
} from '../dtos';
|
||||||
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
|
import {
|
||||||
|
DeviceNotificationEntity,
|
||||||
|
DeviceUserPermissionEntity,
|
||||||
|
} from '../../device/entities';
|
||||||
|
import { defaultProfilePicture } from '@app/common/constants/default.profile.picture';
|
||||||
|
import { RegionEntity } from '../../region/entities';
|
||||||
|
import { TimeZoneEntity } from '../../timezone/entities';
|
||||||
|
import { OtpType } from '../../../../src/constants/otp-type.enum';
|
||||||
|
import { RoleTypeEntity } from '../../role-type/entities';
|
||||||
|
import { VisitorPasswordEntity } from '../../visitor-password/entities';
|
||||||
|
import { InviteUserEntity } from '../../Invite-user/entities';
|
||||||
|
import { ProjectEntity } from '../../project/entities';
|
||||||
|
import { SpaceEntity } from '../../space/entities/space.entity';
|
||||||
|
import { ClientEntity } from '../../client/entities';
|
||||||
|
|
||||||
@Entity({ name: 'user' })
|
@Entity({ name: 'user' })
|
||||||
export class UserEntity extends AbstractEntity<UserDto> {
|
export class UserEntity extends AbstractEntity<UserDto> {
|
||||||
@ -94,9 +94,7 @@ export class UserEntity extends AbstractEntity<UserDto> {
|
|||||||
@Column({ type: 'timestamp', nullable: true })
|
@Column({ type: 'timestamp', nullable: true })
|
||||||
appAgreementAcceptedAt: Date;
|
appAgreementAcceptedAt: Date;
|
||||||
|
|
||||||
@OneToMany(() => UserSpaceEntity, (userSpace) => userSpace.user, {
|
@OneToMany(() => UserSpaceEntity, (userSpace) => userSpace.user)
|
||||||
onDelete: 'CASCADE',
|
|
||||||
})
|
|
||||||
userSpaces: UserSpaceEntity[];
|
userSpaces: UserSpaceEntity[];
|
||||||
|
|
||||||
@OneToMany(
|
@OneToMany(
|
||||||
@ -160,7 +158,6 @@ export class UserEntity extends AbstractEntity<UserDto> {
|
|||||||
export class UserNotificationEntity extends AbstractEntity<UserNotificationDto> {
|
export class UserNotificationEntity extends AbstractEntity<UserNotificationDto> {
|
||||||
@ManyToOne(() => UserEntity, (user) => user.roleType, {
|
@ManyToOne(() => UserEntity, (user) => user.roleType, {
|
||||||
nullable: false,
|
nullable: false,
|
||||||
onDelete: 'CASCADE',
|
|
||||||
})
|
})
|
||||||
user: UserEntity;
|
user: UserEntity;
|
||||||
@Column({
|
@Column({
|
||||||
@ -222,10 +219,7 @@ export class UserSpaceEntity extends AbstractEntity<UserSpaceDto> {
|
|||||||
})
|
})
|
||||||
public uuid: string;
|
public uuid: string;
|
||||||
|
|
||||||
@ManyToOne(() => UserEntity, (user) => user.userSpaces, {
|
@ManyToOne(() => UserEntity, (user) => user.userSpaces, { nullable: false })
|
||||||
nullable: false,
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
})
|
|
||||||
user: UserEntity;
|
user: UserEntity;
|
||||||
|
|
||||||
@ManyToOne(() => SpaceEntity, (space) => space.userSpaces, {
|
@ManyToOne(() => SpaceEntity, (space) => space.userSpaces, {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm';
|
import { Column, Entity, ManyToOne, JoinColumn, Index } from 'typeorm';
|
||||||
|
import { VisitorPasswordDto } from '../dtos';
|
||||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
import { UserEntity } from '../../user/entities/user.entity';
|
import { UserEntity } from '../../user/entities/user.entity';
|
||||||
import { VisitorPasswordDto } from '../dtos';
|
|
||||||
|
|
||||||
@Entity({ name: 'visitor-password' })
|
@Entity({ name: 'visitor-password' })
|
||||||
@Index('IDX_PASSWORD_TUYA_UUID', ['passwordTuyaUuid'])
|
@Index('IDX_PASSWORD_TUYA_UUID', ['passwordTuyaUuid'])
|
||||||
@ -14,7 +14,6 @@ export class VisitorPasswordEntity extends AbstractEntity<VisitorPasswordDto> {
|
|||||||
|
|
||||||
@ManyToOne(() => UserEntity, (user) => user.visitorPasswords, {
|
@ManyToOne(() => UserEntity, (user) => user.visitorPasswords, {
|
||||||
nullable: false,
|
nullable: false,
|
||||||
onDelete: 'CASCADE',
|
|
||||||
})
|
})
|
||||||
@JoinColumn({ name: 'authorizer_uuid' })
|
@JoinColumn({ name: 'authorizer_uuid' })
|
||||||
public user: UserEntity;
|
public user: UserEntity;
|
||||||
|
@ -276,11 +276,9 @@ SELECT
|
|||||||
p.good_ch2o_percentage, p.moderate_ch2o_percentage, p.unhealthy_sensitive_ch2o_percentage, p.unhealthy_ch2o_percentage, p.very_unhealthy_ch2o_percentage, p.hazardous_ch2o_percentage,
|
p.good_ch2o_percentage, p.moderate_ch2o_percentage, p.unhealthy_sensitive_ch2o_percentage, p.unhealthy_ch2o_percentage, p.very_unhealthy_ch2o_percentage, p.hazardous_ch2o_percentage,
|
||||||
a.daily_avg_ch2o,a.daily_max_ch2o, a.daily_min_ch2o
|
a.daily_avg_ch2o,a.daily_max_ch2o, a.daily_min_ch2o
|
||||||
FROM daily_percentages p
|
FROM daily_percentages p
|
||||||
LEFT JOIN daily_averages a
|
LEFT JOIN daily_averages a
|
||||||
ON p.space_id = a.space_id AND p.event_date = a.event_date
|
ON p.space_id = a.space_id AND p.event_date = a.event_date
|
||||||
WHERE p.space_id = (SELECT space_id FROM params)
|
ORDER BY p.space_id, p.event_date)
|
||||||
AND p.event_date = (SELECT event_date FROM params)
|
|
||||||
ORDER BY p.space_id, p.event_date)
|
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO public."space-daily-pollutant-stats" (
|
INSERT INTO public."space-daily-pollutant-stats" (
|
||||||
|
@ -111,7 +111,6 @@ export class InviteUserService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const invitedUser = await queryRunner.manager.save(inviteUser);
|
const invitedUser = await queryRunner.manager.save(inviteUser);
|
||||||
const invitedRoleType = await this.getRoleTypeByUuid(roleUuid);
|
|
||||||
|
|
||||||
// Link user to spaces
|
// Link user to spaces
|
||||||
const spacePromises = validSpaces.map(async (space) => {
|
const spacePromises = validSpaces.map(async (space) => {
|
||||||
@ -129,7 +128,7 @@ export class InviteUserService {
|
|||||||
await this.emailService.sendEmailWithInvitationTemplate(email, {
|
await this.emailService.sendEmailWithInvitationTemplate(email, {
|
||||||
name: firstName,
|
name: firstName,
|
||||||
invitationCode,
|
invitationCode,
|
||||||
role: invitedRoleType.replace(/_/g, ' '),
|
role: roleType,
|
||||||
spacesList: spaceNames,
|
spacesList: spaceNames,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
import { Injectable, HttpException, HttpStatus } from '@nestjs/common';
|
||||||
import { ConfigService } from '@nestjs/config';
|
|
||||||
import { TuyaContext } from '@tuya/tuya-connector-nodejs';
|
import { TuyaContext } from '@tuya/tuya-connector-nodejs';
|
||||||
|
import { ConfigService } from '@nestjs/config';
|
||||||
import {
|
import {
|
||||||
AddScheduleDto,
|
AddScheduleDto,
|
||||||
EnableScheduleDto,
|
EnableScheduleDto,
|
||||||
@ -11,14 +11,14 @@ import {
|
|||||||
getDeviceScheduleInterface,
|
getDeviceScheduleInterface,
|
||||||
} from '../interfaces/get.schedule.interface';
|
} from '../interfaces/get.schedule.interface';
|
||||||
|
|
||||||
import { ProductType } from '@app/common/constants/product-type.enum';
|
|
||||||
import { convertKeysToCamelCase } from '@app/common/helper/camelCaseConverter';
|
import { convertKeysToCamelCase } from '@app/common/helper/camelCaseConverter';
|
||||||
|
import { DeviceRepository } from '@app/common/modules/device/repositories';
|
||||||
|
import { ProductType } from '@app/common/constants/product-type.enum';
|
||||||
import { convertTimestampToDubaiTime } from '@app/common/helper/convertTimestampToDubaiTime';
|
import { convertTimestampToDubaiTime } from '@app/common/helper/convertTimestampToDubaiTime';
|
||||||
import {
|
import {
|
||||||
getEnabledDays,
|
getEnabledDays,
|
||||||
getScheduleStatus,
|
getScheduleStatus,
|
||||||
} from '@app/common/helper/getScheduleStatus';
|
} from '@app/common/helper/getScheduleStatus';
|
||||||
import { DeviceRepository } from '@app/common/modules/device/repositories';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ScheduleService {
|
export class ScheduleService {
|
||||||
@ -57,8 +57,7 @@ export class ScheduleService {
|
|||||||
deviceDetails.productDevice.prodType !== ProductType.ONE_1TG &&
|
deviceDetails.productDevice.prodType !== ProductType.ONE_1TG &&
|
||||||
deviceDetails.productDevice.prodType !== ProductType.TWO_2TG &&
|
deviceDetails.productDevice.prodType !== ProductType.TWO_2TG &&
|
||||||
deviceDetails.productDevice.prodType !== ProductType.THREE_3TG &&
|
deviceDetails.productDevice.prodType !== ProductType.THREE_3TG &&
|
||||||
deviceDetails.productDevice.prodType !== ProductType.GD &&
|
deviceDetails.productDevice.prodType !== ProductType.GD
|
||||||
deviceDetails.productDevice.prodType !== ProductType.CUR_2
|
|
||||||
) {
|
) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
'This device is not supported for schedule',
|
'This device is not supported for schedule',
|
||||||
@ -116,8 +115,7 @@ export class ScheduleService {
|
|||||||
deviceDetails.productDevice.prodType !== ProductType.ONE_1TG &&
|
deviceDetails.productDevice.prodType !== ProductType.ONE_1TG &&
|
||||||
deviceDetails.productDevice.prodType !== ProductType.TWO_2TG &&
|
deviceDetails.productDevice.prodType !== ProductType.TWO_2TG &&
|
||||||
deviceDetails.productDevice.prodType !== ProductType.THREE_3TG &&
|
deviceDetails.productDevice.prodType !== ProductType.THREE_3TG &&
|
||||||
deviceDetails.productDevice.prodType !== ProductType.GD &&
|
deviceDetails.productDevice.prodType !== ProductType.GD
|
||||||
deviceDetails.productDevice.prodType !== ProductType.CUR_2
|
|
||||||
) {
|
) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
'This device is not supported for schedule',
|
'This device is not supported for schedule',
|
||||||
@ -162,16 +160,6 @@ export class ScheduleService {
|
|||||||
throw new HttpException('Device Not Found', HttpStatus.NOT_FOUND);
|
throw new HttpException('Device Not Found', HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
deviceDetails.productDevice.prodType == ProductType.CUR_2 &&
|
|
||||||
addScheduleDto.category != 'Timer'
|
|
||||||
) {
|
|
||||||
throw new HttpException(
|
|
||||||
'Invalid category for CUR_2 devices',
|
|
||||||
HttpStatus.BAD_REQUEST,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Corrected condition for supported device types
|
// Corrected condition for supported device types
|
||||||
if (
|
if (
|
||||||
deviceDetails.productDevice.prodType !== ProductType.THREE_G &&
|
deviceDetails.productDevice.prodType !== ProductType.THREE_G &&
|
||||||
@ -181,8 +169,7 @@ export class ScheduleService {
|
|||||||
deviceDetails.productDevice.prodType !== ProductType.ONE_1TG &&
|
deviceDetails.productDevice.prodType !== ProductType.ONE_1TG &&
|
||||||
deviceDetails.productDevice.prodType !== ProductType.TWO_2TG &&
|
deviceDetails.productDevice.prodType !== ProductType.TWO_2TG &&
|
||||||
deviceDetails.productDevice.prodType !== ProductType.THREE_3TG &&
|
deviceDetails.productDevice.prodType !== ProductType.THREE_3TG &&
|
||||||
deviceDetails.productDevice.prodType !== ProductType.GD &&
|
deviceDetails.productDevice.prodType !== ProductType.GD
|
||||||
deviceDetails.productDevice.prodType !== ProductType.CUR_2
|
|
||||||
) {
|
) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
'This device is not supported for schedule',
|
'This device is not supported for schedule',
|
||||||
@ -192,7 +179,6 @@ export class ScheduleService {
|
|||||||
await this.addScheduleDeviceInTuya(
|
await this.addScheduleDeviceInTuya(
|
||||||
deviceDetails.deviceTuyaUuid,
|
deviceDetails.deviceTuyaUuid,
|
||||||
addScheduleDto,
|
addScheduleDto,
|
||||||
deviceDetails.productDevice.prodType as ProductType,
|
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
@ -204,7 +190,6 @@ export class ScheduleService {
|
|||||||
async addScheduleDeviceInTuya(
|
async addScheduleDeviceInTuya(
|
||||||
deviceId: string,
|
deviceId: string,
|
||||||
addScheduleDto: AddScheduleDto,
|
addScheduleDto: AddScheduleDto,
|
||||||
deviceType: ProductType,
|
|
||||||
): Promise<addScheduleDeviceInterface> {
|
): Promise<addScheduleDeviceInterface> {
|
||||||
try {
|
try {
|
||||||
const convertedTime = convertTimestampToDubaiTime(addScheduleDto.time);
|
const convertedTime = convertTimestampToDubaiTime(addScheduleDto.time);
|
||||||
@ -224,10 +209,7 @@ export class ScheduleService {
|
|||||||
value: addScheduleDto.function.value,
|
value: addScheduleDto.function.value,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
category:
|
category: `category_${addScheduleDto.category}`,
|
||||||
deviceType == ProductType.CUR_2
|
|
||||||
? addScheduleDto.category
|
|
||||||
: `category_${addScheduleDto.category}`,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -255,8 +237,7 @@ export class ScheduleService {
|
|||||||
deviceDetails.productDevice.prodType !== ProductType.ONE_1TG &&
|
deviceDetails.productDevice.prodType !== ProductType.ONE_1TG &&
|
||||||
deviceDetails.productDevice.prodType !== ProductType.TWO_2TG &&
|
deviceDetails.productDevice.prodType !== ProductType.TWO_2TG &&
|
||||||
deviceDetails.productDevice.prodType !== ProductType.THREE_3TG &&
|
deviceDetails.productDevice.prodType !== ProductType.THREE_3TG &&
|
||||||
deviceDetails.productDevice.prodType !== ProductType.GD &&
|
deviceDetails.productDevice.prodType !== ProductType.GD
|
||||||
deviceDetails.productDevice.prodType !== ProductType.CUR_2
|
|
||||||
) {
|
) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
'This device is not supported for schedule',
|
'This device is not supported for schedule',
|
||||||
@ -269,10 +250,7 @@ export class ScheduleService {
|
|||||||
);
|
);
|
||||||
const result = schedules.result.map((schedule: any) => {
|
const result = schedules.result.map((schedule: any) => {
|
||||||
return {
|
return {
|
||||||
category:
|
category: schedule.category.replace('category_', ''),
|
||||||
deviceDetails.productDevice.prodType == ProductType.CUR_2
|
|
||||||
? schedule.category
|
|
||||||
: schedule.category.replace('category_', ''),
|
|
||||||
enable: schedule.enable,
|
enable: schedule.enable,
|
||||||
function: {
|
function: {
|
||||||
code: schedule.functions[0].code,
|
code: schedule.functions[0].code,
|
||||||
@ -336,16 +314,6 @@ export class ScheduleService {
|
|||||||
throw new HttpException('Device Not Found', HttpStatus.NOT_FOUND);
|
throw new HttpException('Device Not Found', HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
deviceDetails.productDevice.prodType == ProductType.CUR_2 &&
|
|
||||||
updateScheduleDto.category != 'Timer'
|
|
||||||
) {
|
|
||||||
throw new HttpException(
|
|
||||||
'Invalid category for CUR_2 devices',
|
|
||||||
HttpStatus.BAD_REQUEST,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Corrected condition for supported device types
|
// Corrected condition for supported device types
|
||||||
if (
|
if (
|
||||||
deviceDetails.productDevice.prodType !== ProductType.THREE_G &&
|
deviceDetails.productDevice.prodType !== ProductType.THREE_G &&
|
||||||
@ -355,8 +323,7 @@ export class ScheduleService {
|
|||||||
deviceDetails.productDevice.prodType !== ProductType.ONE_1TG &&
|
deviceDetails.productDevice.prodType !== ProductType.ONE_1TG &&
|
||||||
deviceDetails.productDevice.prodType !== ProductType.TWO_2TG &&
|
deviceDetails.productDevice.prodType !== ProductType.TWO_2TG &&
|
||||||
deviceDetails.productDevice.prodType !== ProductType.THREE_3TG &&
|
deviceDetails.productDevice.prodType !== ProductType.THREE_3TG &&
|
||||||
deviceDetails.productDevice.prodType !== ProductType.GD &&
|
deviceDetails.productDevice.prodType !== ProductType.GD
|
||||||
deviceDetails.productDevice.prodType !== ProductType.CUR_2
|
|
||||||
) {
|
) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
'This device is not supported for schedule',
|
'This device is not supported for schedule',
|
||||||
@ -366,7 +333,6 @@ export class ScheduleService {
|
|||||||
await this.updateScheduleDeviceInTuya(
|
await this.updateScheduleDeviceInTuya(
|
||||||
deviceDetails.deviceTuyaUuid,
|
deviceDetails.deviceTuyaUuid,
|
||||||
updateScheduleDto,
|
updateScheduleDto,
|
||||||
deviceDetails.productDevice.prodType as ProductType,
|
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
@ -378,7 +344,6 @@ export class ScheduleService {
|
|||||||
async updateScheduleDeviceInTuya(
|
async updateScheduleDeviceInTuya(
|
||||||
deviceId: string,
|
deviceId: string,
|
||||||
updateScheduleDto: UpdateScheduleDto,
|
updateScheduleDto: UpdateScheduleDto,
|
||||||
deviceType: ProductType,
|
|
||||||
): Promise<addScheduleDeviceInterface> {
|
): Promise<addScheduleDeviceInterface> {
|
||||||
try {
|
try {
|
||||||
const convertedTime = convertTimestampToDubaiTime(updateScheduleDto.time);
|
const convertedTime = convertTimestampToDubaiTime(updateScheduleDto.time);
|
||||||
@ -399,10 +364,7 @@ export class ScheduleService {
|
|||||||
value: updateScheduleDto.function.value,
|
value: updateScheduleDto.function.value,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
category:
|
category: `category_${updateScheduleDto.category}`,
|
||||||
deviceType == ProductType.CUR_2
|
|
||||||
? updateScheduleDto.category
|
|
||||||
: `category_${updateScheduleDto.category.replace('category_', '')}`,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
import { ControllerRoute } from '@app/common/constants/controller-route';
|
|
||||||
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
|
|
||||||
import { RoleType } from '@app/common/constants/role.type.enum';
|
|
||||||
import { BaseResponseDto } from '@app/common/dto/base.response.dto';
|
|
||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
@ -11,12 +7,10 @@ import {
|
|||||||
Param,
|
Param,
|
||||||
Patch,
|
Patch,
|
||||||
Put,
|
Put,
|
||||||
Req,
|
|
||||||
UseGuards,
|
UseGuards,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
import { UserService } from '../services/user.service';
|
||||||
import { CheckProfilePictureGuard } from 'src/guards/profile.picture.guard';
|
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
|
||||||
import { SuperAdminRoleGuard } from 'src/guards/super.admin.role.guard';
|
|
||||||
import { JwtAuthGuard } from '../../../libs/common/src/guards/jwt.auth.guard';
|
import { JwtAuthGuard } from '../../../libs/common/src/guards/jwt.auth.guard';
|
||||||
import {
|
import {
|
||||||
UpdateNameDto,
|
UpdateNameDto,
|
||||||
@ -24,7 +18,11 @@ import {
|
|||||||
UpdateRegionDataDto,
|
UpdateRegionDataDto,
|
||||||
UpdateTimezoneDataDto,
|
UpdateTimezoneDataDto,
|
||||||
} from '../dtos';
|
} from '../dtos';
|
||||||
import { UserService } from '../services/user.service';
|
import { CheckProfilePictureGuard } from 'src/guards/profile.picture.guard';
|
||||||
|
import { SuperAdminRoleGuard } from 'src/guards/super.admin.role.guard';
|
||||||
|
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
|
||||||
|
import { ControllerRoute } from '@app/common/constants/controller-route';
|
||||||
|
import { BaseResponseDto } from '@app/common/dto/base.response.dto';
|
||||||
|
|
||||||
@ApiTags('User Module')
|
@ApiTags('User Module')
|
||||||
@Controller({
|
@Controller({
|
||||||
@ -156,32 +154,6 @@ export class UserController {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiBearerAuth()
|
|
||||||
@UseGuards(JwtAuthGuard)
|
|
||||||
@Delete('')
|
|
||||||
@ApiOperation({
|
|
||||||
summary: ControllerRoute.USER.ACTIONS.DELETE_USER_PROFILE_SUMMARY,
|
|
||||||
description: ControllerRoute.USER.ACTIONS.DELETE_USER_PROFILE_DESCRIPTION,
|
|
||||||
})
|
|
||||||
async deleteUserProfile(@Req() req: Request) {
|
|
||||||
const userUuid = req['user']?.userUuid;
|
|
||||||
const userRole = req['user']?.role;
|
|
||||||
if (!userUuid || (userRole && userRole == RoleType.SUPER_ADMIN)) {
|
|
||||||
throw {
|
|
||||||
statusCode: HttpStatus.UNAUTHORIZED,
|
|
||||||
message: 'Unauthorized',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
await this.userService.deleteUserProfile(userUuid);
|
|
||||||
return {
|
|
||||||
statusCode: HttpStatus.OK,
|
|
||||||
data: {
|
|
||||||
userId: userUuid,
|
|
||||||
},
|
|
||||||
message: 'User deleted successfully',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiBearerAuth()
|
@ApiBearerAuth()
|
||||||
@UseGuards(JwtAuthGuard)
|
@UseGuards(JwtAuthGuard)
|
||||||
@Patch('agreements/web/:userUuid')
|
@Patch('agreements/web/:userUuid')
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
import { SuccessResponseDto } from '@app/common/dto/success.response.dto';
|
|
||||||
import { removeBase64Prefix } from '@app/common/helper/removeBase64Prefix';
|
|
||||||
import { RegionRepository } from '@app/common/modules/region/repositories';
|
|
||||||
import { TimeZoneRepository } from '@app/common/modules/timezone/repositories';
|
|
||||||
import { UserEntity } from '@app/common/modules/user/entities';
|
|
||||||
import { UserRepository } from '@app/common/modules/user/repositories';
|
|
||||||
import {
|
|
||||||
BadRequestException,
|
|
||||||
HttpException,
|
|
||||||
HttpStatus,
|
|
||||||
Injectable,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import {
|
import {
|
||||||
UpdateNameDto,
|
UpdateNameDto,
|
||||||
UpdateProfilePictureDataDto,
|
UpdateProfilePictureDataDto,
|
||||||
UpdateRegionDataDto,
|
UpdateRegionDataDto,
|
||||||
UpdateTimezoneDataDto,
|
UpdateTimezoneDataDto,
|
||||||
} from './../dtos/update.user.dto';
|
} from './../dtos/update.user.dto';
|
||||||
|
import {
|
||||||
|
BadRequestException,
|
||||||
|
HttpException,
|
||||||
|
HttpStatus,
|
||||||
|
Injectable,
|
||||||
|
} from '@nestjs/common';
|
||||||
|
import { UserRepository } from '@app/common/modules/user/repositories';
|
||||||
|
import { RegionRepository } from '@app/common/modules/region/repositories';
|
||||||
|
import { TimeZoneRepository } from '@app/common/modules/timezone/repositories';
|
||||||
|
import { removeBase64Prefix } from '@app/common/helper/removeBase64Prefix';
|
||||||
|
import { UserEntity } from '@app/common/modules/user/entities';
|
||||||
|
import { SuccessResponseDto } from '@app/common/dto/success.response.dto';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserService {
|
export class UserService {
|
||||||
@ -269,12 +269,4 @@ export class UserService {
|
|||||||
}
|
}
|
||||||
return await this.userRepository.update({ uuid }, { isActive: false });
|
return await this.userRepository.update({ uuid }, { isActive: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteUserProfile(uuid: string) {
|
|
||||||
const user = await this.findOneById(uuid);
|
|
||||||
if (!user) {
|
|
||||||
throw new BadRequestException('User not found');
|
|
||||||
}
|
|
||||||
return this.userRepository.delete({ uuid });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user