Merge pull request #7 from Danakcorp/mrtz

add: pricing detail
This commit is contained in:
morteza-mortezai
2025-09-30 15:53:05 +03:30
committed by GitHub
2 changed files with 21 additions and 0 deletions
@@ -111,6 +111,16 @@ export class AdminFinancialController extends BaseController {
return this.response(data); return this.response(data);
} }
@ApiOperation("get pricing detail")
@ApiResponse("successful", HttpStatus.Ok)
@ApiAuth()
@ApiParam("id", "id of pricing", true)
@httpGet("/pricing/:id", Guard.authAdmin())
public async getPricingDetail(@requestParam("id") id: string) {
const data = await this.pricingService.getPricingDetail(id);
return this.response(data);
}
@ApiOperation("create pricing") @ApiOperation("create pricing")
@ApiResponse("successful", HttpStatus.Created) @ApiResponse("successful", HttpStatus.Created)
@ApiModel(CreatePricingDTO) @ApiModel(CreatePricingDTO)
+11
View File
@@ -35,6 +35,17 @@ export class PricingService {
}; };
} }
//#######################################################
async getPricingDetail(id: string) {
const pricing = await this.pricingRepo.model.findById(id);
if (!pricing) throw new BadRequestError(PricingMessage.NotFound);
return {
pricing,
};
}
//####################################################### //#######################################################
async updatePricing(id: string, updateDto: UpdatePricingDTO) { async updatePricing(id: string, updateDto: UpdatePricingDTO) {
const existType = await this.pricingRepo.model.findOne({ type: updateDto.type, _id: { $ne: id } }); const existType = await this.pricingRepo.model.findOne({ type: updateDto.type, _id: { $ne: id } });