clean
This commit is contained in:
@@ -1,199 +1,209 @@
|
||||
import { Controller, Get, Post, Body, Delete, Param, Query, Patch } from '@nestjs/common';
|
||||
import { ResellerService } from './reseller.service';
|
||||
import { ApiOperation } from '@nestjs/swagger';
|
||||
import { PermissionsDec } from '../../common/decorators/permission.decorator';
|
||||
import { PermissionEnum } from '../users/enums/permission.enum';
|
||||
import { CreateResellerDto } from './dto/create-reseller.dto';
|
||||
import { AuthGuards } from '../../common/decorators/auth-guard.decorator';
|
||||
import { AdminRoute } from '../../common/decorators/admin.decorator';
|
||||
import { ResellerRoute } from '../../common/decorators/reseller.decorator';
|
||||
import { UserDec } from '../../common/decorators/user.decorator';
|
||||
import { CreateResellerAgentDto } from './dto/create-reseller-agent.dto';
|
||||
import { SearchWithdrawRequestQueryDto } from './dto/search-withdraw-requests.dto';
|
||||
import { SearchCustomersDto } from '../users/DTO/search-customers.dto';
|
||||
import { SearchResellerInvoicesQueryDto } from './dto/search-reseller-invoices.dto';
|
||||
import { PaginationDto } from '../../common/DTO/pagination.dto';
|
||||
import { WalletsService } from '../wallets/providers/wallets.service';
|
||||
import { CreateWithdrawRequestDto } from './dto/create-withdraw-request.dto';
|
||||
import { CreateUserBankAccountDto } from './dto/create-user-bank-account.dto';
|
||||
import { ResellerType } from '../auth/DTO/verify-reseller-otp.dto';
|
||||
import { ConfirmwithdrawRequestDto } from './dto/confirm-withdraw-request.dto';
|
||||
import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from "@nestjs/common";
|
||||
import { ApiOperation, ApiTags } from "@nestjs/swagger";
|
||||
|
||||
@Controller('reseller')
|
||||
import { ConfirmwithdrawRequestDto } from "./dto/confirm-withdraw-request.dto";
|
||||
import { CreateResellerAgentDto } from "./dto/create-reseller-agent.dto";
|
||||
import { CreateResellerDto } from "./dto/create-reseller.dto";
|
||||
import { CreateUserBankAccountDto } from "./dto/create-user-bank-account.dto";
|
||||
import { CreateWithdrawRequestDto } from "./dto/create-withdraw-request.dto";
|
||||
import { SearchResellerInvoicesQueryDto } from "./dto/search-reseller-invoices.dto";
|
||||
import { SearchWithdrawRequestQueryDto } from "./dto/search-withdraw-requests.dto";
|
||||
import { ResellerService } from "./reseller.service";
|
||||
import { AdminRoute } from "../../common/decorators/admin.decorator";
|
||||
import { AuthGuards } from "../../common/decorators/auth-guard.decorator";
|
||||
import { Pagination } from "../../common/decorators/pagination.decorator";
|
||||
import { PermissionsDec } from "../../common/decorators/permission.decorator";
|
||||
import { ResellerRoute } from "../../common/decorators/reseller.decorator";
|
||||
import { UserDec } from "../../common/decorators/user.decorator";
|
||||
import { PaginationDto } from "../../common/DTO/pagination.dto";
|
||||
import { ParamDto } from "../../common/DTO/param.dto";
|
||||
import { ResellerType } from "../auth/DTO/verify-reseller-otp.dto";
|
||||
import { SearchCustomersDto } from "../users/DTO/search-customers.dto";
|
||||
import { PermissionEnum } from "../users/enums/permission.enum";
|
||||
import { WalletsService } from "../wallets/providers/wallets.service";
|
||||
|
||||
@Controller("reseller")
|
||||
@AuthGuards()
|
||||
@ApiTags("reseller")
|
||||
export class ResellerController {
|
||||
constructor(
|
||||
private readonly resellerService: ResellerService,
|
||||
private readonly walletsService: WalletsService,
|
||||
) { }
|
||||
) {}
|
||||
|
||||
//***************** DSC Endpoints **************** */
|
||||
@ApiOperation({ summary: "create Reseller ==> admin route" })
|
||||
@ApiOperation({ summary: "Create reseller ==> admin route" })
|
||||
@AdminRoute()
|
||||
@PermissionsDec(PermissionEnum.RESELLER)
|
||||
@Post()
|
||||
createReseller(@Body() dto: CreateResellerDto) {
|
||||
return this.resellerService.create(dto)
|
||||
return this.resellerService.create(dto);
|
||||
}
|
||||
|
||||
@ApiOperation({ summary: "get Resellers ==> admin route" })
|
||||
@ApiOperation({ summary: "Get resellers ==> admin route" })
|
||||
@AdminRoute()
|
||||
@PermissionsDec(PermissionEnum.RESELLER)
|
||||
@Get()
|
||||
getResellers() {
|
||||
return this.resellerService.findAll()
|
||||
return this.resellerService.findAll();
|
||||
}
|
||||
|
||||
//=========== Reward Requests =========
|
||||
|
||||
@ApiOperation({ summary: "get withdraw requests ==> admin route" })
|
||||
@ApiOperation({ summary: "Get withdraw requests ==> admin route" })
|
||||
@AdminRoute()
|
||||
@PermissionsDec(PermissionEnum.RESELLER)
|
||||
@Get('withdraw-request/admin')
|
||||
@Pagination()
|
||||
@Get("withdraw-request/admin")
|
||||
getRewardRequests(@Query() query: SearchWithdrawRequestQueryDto) {
|
||||
return this.resellerService.getwithdrawRequestsForAdmin(query)
|
||||
return this.resellerService.getwithdrawRequestsForAdmin(query);
|
||||
}
|
||||
|
||||
@ApiOperation({ summary: "get withdraw requests ==> admin route" })
|
||||
@ApiOperation({ summary: "Confirm withdraw request ==> admin route" })
|
||||
@AdminRoute()
|
||||
@PermissionsDec(PermissionEnum.RESELLER)
|
||||
@Patch('withdraw-request/:id')
|
||||
confirmWithdrawRequests(@Param('id') requestId: string, @Body() dto: ConfirmwithdrawRequestDto) {
|
||||
return this.resellerService.confirmWithdrawRequest(requestId, dto.transactionId)
|
||||
@Patch("withdraw-request/:id")
|
||||
confirmWithdrawRequests(@Param() paramDto: ParamDto, @Body() dto: ConfirmwithdrawRequestDto) {
|
||||
return this.resellerService.confirmWithdrawRequest(paramDto.id, dto.transactionId);
|
||||
}
|
||||
|
||||
// ************** Reseller Panel Endpoints ***********
|
||||
|
||||
// =========== Reseller-->Agent =============
|
||||
|
||||
@ApiOperation({ summary: "get Reseller agents ==> reseller route" })
|
||||
@ApiOperation({ summary: "Get reseller agents ==> reseller route" })
|
||||
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
|
||||
@Get('agents')
|
||||
@Get("agents")
|
||||
getResellerAgents(@UserDec("id") userId: string) {
|
||||
return this.resellerService.finResellerAgents(userId)
|
||||
return this.resellerService.finResellerAgents(userId);
|
||||
}
|
||||
|
||||
@ApiOperation({ summary: "Create Reseller agent ==> reseller route" })
|
||||
@ApiOperation({ summary: "Create reseller agent ==> reseller route" })
|
||||
@ResellerRoute([ResellerType.reseller])
|
||||
@Post('agents')
|
||||
@Post("agents")
|
||||
createResellerAgent(@UserDec("id") userId: string, @Body() dto: CreateResellerAgentDto) {
|
||||
return this.resellerService.createResellerAgent(userId, dto.phone)
|
||||
return this.resellerService.createResellerAgent(userId, dto.phone);
|
||||
}
|
||||
|
||||
@ApiOperation({ summary: "Remove Reseller agent ==> reseller route" })
|
||||
@ApiOperation({ summary: "Remove reseller agent ==> reseller route" })
|
||||
@ResellerRoute([ResellerType.reseller])
|
||||
@Delete('agents/:agentId')
|
||||
deleteResellerAgent(@UserDec("id") userId: string, @Param('agentId') agentId: string) {
|
||||
return this.resellerService.removeResellerAgent(userId, agentId)
|
||||
@Delete("agents/:id")
|
||||
deleteResellerAgent(@UserDec("id") userId: string, @Param() paramDto: ParamDto) {
|
||||
return this.resellerService.removeResellerAgent(userId, paramDto.id);
|
||||
}
|
||||
|
||||
// ============ Customers =============
|
||||
@ApiOperation({ summary: "get Reseller Customers ==> reseller route" })
|
||||
@ApiOperation({ summary: "Get reseller customers ==> reseller route" })
|
||||
@ResellerRoute([ResellerType.reseller])
|
||||
@Get('customers')
|
||||
@Pagination()
|
||||
@Get("customers")
|
||||
getCustomers(@UserDec("id") userId: string, @Query() dto: SearchCustomersDto) {
|
||||
return this.resellerService.findResellerCustomers(userId, dto)
|
||||
return this.resellerService.findResellerCustomers(userId, dto);
|
||||
}
|
||||
|
||||
// ============ Invoice =============ok
|
||||
@ApiOperation({ summary: "get Reseller Customers Invoices==> reseller route" })
|
||||
@ApiOperation({ summary: "Get reseller customer invoices ==> reseller route" })
|
||||
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
|
||||
@Get('invoices')
|
||||
@Pagination()
|
||||
@Get("invoices")
|
||||
getCustomerInvoices(
|
||||
@UserDec("id") userId: string,
|
||||
@Query() query: SearchResellerInvoicesQueryDto,
|
||||
@UserDec("resellerType") type: ResellerType
|
||||
@UserDec("resellerType") type: ResellerType,
|
||||
) {
|
||||
return this.resellerService.findInvoices(userId, type, query)
|
||||
return this.resellerService.findInvoices(userId, type, query);
|
||||
}
|
||||
|
||||
// ============ Rewards =============
|
||||
@ApiOperation({ summary: "get Reseller Agents Rewards==> reseller route" })
|
||||
@ApiOperation({ summary: "Get reseller agent rewards ==> reseller route" })
|
||||
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
|
||||
@Get('rewards')
|
||||
@Pagination()
|
||||
@Get("rewards")
|
||||
getResellerAgentsRewards(
|
||||
@UserDec("id") userId: string,
|
||||
@Query() query: SearchWithdrawRequestQueryDto,
|
||||
@UserDec("resellerType") type: ResellerType
|
||||
@UserDec("resellerType") type: ResellerType,
|
||||
) {
|
||||
return this.resellerService.findRewards(userId, type, query)
|
||||
return this.resellerService.findRewards(userId, type, query);
|
||||
}
|
||||
|
||||
// ============ Wallet Transactions =============
|
||||
@ApiOperation({ summary: "get Reseller/Agent Wallet Transactions ==> reseller route" })
|
||||
@ApiOperation({ summary: "Get reseller or agent wallet transactions ==> reseller route" })
|
||||
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
|
||||
@Get('wallet/transaction')
|
||||
getWalletTransactionss(@UserDec("id") userId: string, @Query() query: PaginationDto) {
|
||||
@Pagination()
|
||||
@Get("wallet/transaction")
|
||||
getWalletTransactions(@UserDec("id") userId: string, @Query() query: PaginationDto) {
|
||||
return this.walletsService.getTransaction(userId, query);
|
||||
}
|
||||
|
||||
// ============ Wallet Balance =============
|
||||
|
||||
@ApiOperation({ summary: "get Reseller/Agent Wallet Balance ==> reseller route" })
|
||||
@ApiOperation({ summary: "Get reseller or agent wallet balance ==> reseller route" })
|
||||
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
|
||||
@Get('wallet/balance')
|
||||
@Get("wallet/balance")
|
||||
getWalletBalance(@UserDec("id") userId: string) {
|
||||
return this.walletsService.getBalance(userId)
|
||||
return this.walletsService.getBalance(userId);
|
||||
}
|
||||
|
||||
// ============Create WithDraw Request =============
|
||||
@ApiOperation({ summary: "Create Reseller/Agent withdraw request ==> reseller route" })
|
||||
@ApiOperation({ summary: "Create reseller or agent withdraw request ==> reseller route" })
|
||||
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
|
||||
@Post('withdraw-request')
|
||||
@Post("withdraw-request")
|
||||
withdrawRequest(@UserDec("id") userId: string, @Body() dto: CreateWithdrawRequestDto) {
|
||||
return this.resellerService.createWithdrawRequest(userId, dto.amount)
|
||||
return this.resellerService.createWithdrawRequest(userId, dto.amount);
|
||||
}
|
||||
|
||||
// ============ Remove WithDraw Request =============
|
||||
@ApiOperation({ summary: "remove Reseller/Agent withdraw request ==> reseller route" })
|
||||
@ApiOperation({ summary: "Remove reseller or agent withdraw request ==> reseller route" })
|
||||
@ResellerRoute([ResellerType.agent])
|
||||
@Delete('withdraw-request/:id')
|
||||
removeWithdrawRequest(@UserDec("id") userId: string, @Param('id') id: string) {
|
||||
return this.resellerService.removeWithdrawRequest(userId, id)
|
||||
@Delete("withdraw-request/:id")
|
||||
removeWithdrawRequest(@UserDec("id") userId: string, @Param() paramDto: ParamDto) {
|
||||
return this.resellerService.removeWithdrawRequest(userId, paramDto.id);
|
||||
}
|
||||
|
||||
// ============ withdraw list=============
|
||||
@ApiOperation({ summary: "Get withdraw-request list ==> reseller route" })
|
||||
@ApiOperation({ summary: "Get withdraw request list ==> reseller route" })
|
||||
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
|
||||
@Get('withdraw-request')
|
||||
getPayments(@UserDec("id") userId: string, @Body() dto: SearchWithdrawRequestQueryDto) {
|
||||
return this.resellerService.getWithdrawRequests(userId, dto)
|
||||
@Pagination()
|
||||
@Get("withdraw-request")
|
||||
getWithdrawRequests(@UserDec("id") userId: string, @Query() query: SearchWithdrawRequestQueryDto) {
|
||||
return this.resellerService.getWithdrawRequests(userId, query);
|
||||
}
|
||||
|
||||
// ============ Create Bank Account =============
|
||||
@ApiOperation({ summary: "Create Bank Account ==> reseller route" })
|
||||
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
|
||||
@Post('bank-account')
|
||||
@Post("bank-account")
|
||||
createBankAccount(@UserDec("id") userId: string, @Body() dto: CreateUserBankAccountDto) {
|
||||
return this.resellerService.createUserBankAccount(userId, dto)
|
||||
return this.resellerService.createUserBankAccount(userId, dto);
|
||||
}
|
||||
|
||||
// ============ Get Bank Account =============
|
||||
@ApiOperation({ summary: "Get Bank Account ==> reseller route" })
|
||||
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
|
||||
@Get('bank-account')
|
||||
@Get("bank-account")
|
||||
getBankAccount(@UserDec("id") userId: string) {
|
||||
return this.resellerService.getUserBankAccount(userId)
|
||||
return this.resellerService.getUserBankAccount(userId);
|
||||
}
|
||||
|
||||
// ============ Remove Bank Account =============
|
||||
@ApiOperation({ summary: "remove User Bank account ==> reseller route" })
|
||||
@ApiOperation({ summary: "Remove user bank account ==> reseller route" })
|
||||
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
|
||||
@Delete('bank-account/:id')
|
||||
removeBankAccount(@UserDec("id") userId: string, @Param('id') id: string) {
|
||||
return this.resellerService.deleteUserBankAccount(userId, id)
|
||||
@Delete("bank-account/:id")
|
||||
removeBankAccount(@UserDec("id") userId: string, @Param() paramDto: ParamDto) {
|
||||
return this.resellerService.deleteUserBankAccount(userId, paramDto.id);
|
||||
}
|
||||
|
||||
// ============ Get Referral Codes =============
|
||||
@ApiOperation({ summary: "Get Referral codes List ==> reseller route" })
|
||||
@ApiOperation({ summary: "Get referral codes list ==> reseller route" })
|
||||
@ResellerRoute([ResellerType.agent, ResellerType.reseller])
|
||||
@Get('referral-codes')
|
||||
getReferalCodesList(
|
||||
@Pagination()
|
||||
@Get("referral-codes")
|
||||
getReferralCodesList(
|
||||
@UserDec("id") userId: string,
|
||||
@UserDec("resellerType") type: ResellerType,
|
||||
@Query() query: PaginationDto
|
||||
@Query() query: PaginationDto,
|
||||
) {
|
||||
return this.resellerService.getReferralCodes(userId, type, query)
|
||||
return this.resellerService.getReferralCodes(userId, type, query);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user