Property system: - Rename belonging → property throughout (model, controller, routes, service) - Add property sub-models: buildingModel, landModel, belongingModel - Add property lifecycle events: createProperty, deleteProperty - Add propertyStatus component (model, controller, routes, service, seeder) - Add commodity and commodityTransaction model stubs Infrastructure: - Update transactionModel and transactionService - Update events/index.js for new property events - Update seeder (seederDBConnection, seederRunner) - Update typesense client configuration - Update upload utilities (bucket, minio) - Update featureModel and featureSeeder - Update categorySeeder - Update TsApiFeatures utility - Remove docker-compose.yml (moved to root) - Remove legacy belonging component files
43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
const PropertyStatus = require('./propertyStatusModel')
|
|
const AppError = require('../../globalErrorHandler/AppError')
|
|
|
|
const getAllStatuses = async () => {
|
|
return PropertyStatus.find({})
|
|
}
|
|
|
|
const getStatus = async (statusId) => {
|
|
const status = await PropertyStatus.findById(statusId)
|
|
|
|
if (!status) {
|
|
throw new AppError('NoPropertyStatusFound', 404, {})
|
|
}
|
|
|
|
return status
|
|
}
|
|
|
|
const createStatus = async (data) => {
|
|
return PropertyStatus.create(data)
|
|
}
|
|
|
|
const updateStatus = async (statusId, data) => {
|
|
const status = await PropertyStatus.findByIdAndUpdate(statusId, data, { new: true, runValidators: true })
|
|
|
|
if (!status) {
|
|
throw new AppError('NoPropertyStatusFound', 404, {})
|
|
}
|
|
|
|
return status
|
|
}
|
|
|
|
const deleteStatus = async (statusId) => {
|
|
const status = await PropertyStatus.findByIdAndDelete(statusId)
|
|
|
|
if (!status) {
|
|
throw new AppError('NoPropertyStatusFound', 404, {})
|
|
}
|
|
|
|
return null
|
|
}
|
|
|
|
module.exports = { getAllStatuses, getStatus, createStatus, updateStatus, deleteStatus }
|