Compare commits
4 Commits
d8f96cea72
...
0598075d8c
Author | SHA1 | Date |
---|---|---|
wangyue | 0598075d8c | 2 years ago |
wangyue | 9554c96588 | 2 years ago |
yangsen | e36722161d | 2 years ago |
yangsen | 949c2791ed | 2 years ago |
21 changed files with 67900 additions and 912 deletions
@ -1,239 +1,236 @@ |
|||
'use strict'; |
|||
|
|||
async function get (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { type } = ctx.request.body; |
|||
const { name } = ctx.query; |
|||
|
|||
let findOption = { |
|||
where: { |
|||
type |
|||
}, |
|||
order: [['id', 'DESC']] |
|||
} |
|||
if (name) { |
|||
findOption.where.name = { |
|||
$like: `%${name}%` |
|||
} |
|||
} |
|||
const vehicleRes = await models.Statistic.findAll(findOption) |
|||
|
|||
ctx.status = 200; |
|||
ctx.body = vehicleRes |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { type } = ctx.request.body; |
|||
const { name } = ctx.query; |
|||
|
|||
let findOption = { |
|||
where: { |
|||
type |
|||
} |
|||
} |
|||
if (name) { |
|||
findOption.where.name = { |
|||
$like: `%${name}%` |
|||
} |
|||
} |
|||
const vehicleRes = await models.Statistic.findAll(findOption) |
|||
|
|||
ctx.status = 200; |
|||
ctx.body = vehicleRes |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function edit (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { id, name, count, type } = ctx.request.body; |
|||
|
|||
if (!id) { |
|||
await models.Statistic.create({ |
|||
name, count, type: type |
|||
}) |
|||
} else { |
|||
await models.Statistic.update({ |
|||
name, count, type: type |
|||
}, { |
|||
where: { |
|||
id: id |
|||
} |
|||
}) |
|||
} |
|||
|
|||
ctx.status = 204 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { id, name, count, type } = ctx.request.body; |
|||
|
|||
if (!id) { |
|||
await models.Statistic.create({ |
|||
name, count, type: type |
|||
}) |
|||
} else { |
|||
await models.Statistic.update({ |
|||
name, count, type: type |
|||
}, { |
|||
where: { |
|||
id: id |
|||
} |
|||
}) |
|||
} |
|||
|
|||
ctx.status = 204 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function del (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { id } = ctx.params; |
|||
|
|||
await models.Statistic.destroy({ |
|||
where: { |
|||
id: id |
|||
} |
|||
}) |
|||
|
|||
ctx.status = 204 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { id } = ctx.params; |
|||
|
|||
await models.Statistic.destroy({ |
|||
where: { |
|||
id: id |
|||
} |
|||
}) |
|||
|
|||
ctx.status = 204 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function specificGet (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { type } = ctx.query; |
|||
const { nameOfBusinessOwner } = ctx.query; |
|||
|
|||
let findOption = { |
|||
where: { |
|||
type |
|||
}, |
|||
order: [['id', 'DESC']] |
|||
} |
|||
if (nameOfBusinessOwner) { |
|||
findOption.where.nameOfBusinessOwner = { |
|||
$like: `%${nameOfBusinessOwner}%` |
|||
} |
|||
} |
|||
|
|||
const vehicleRes = await models.MunicipalVehicle.findAll(findOption) |
|||
|
|||
ctx.status = 200; |
|||
ctx.body = vehicleRes |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { type } = ctx.query; |
|||
const { nameOfBusinessOwner } = ctx.query; |
|||
|
|||
let findOption = { |
|||
where: { |
|||
type |
|||
} |
|||
} |
|||
if (nameOfBusinessOwner) { |
|||
findOption.where.nameOfBusinessOwner = { |
|||
$like: `%${nameOfBusinessOwner}%` |
|||
} |
|||
} |
|||
|
|||
const vehicleRes = await models.MunicipalVehicle.findAll(findOption) |
|||
|
|||
ctx.status = 200; |
|||
ctx.body = vehicleRes |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function specificEdit (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const data = ctx.request.body; |
|||
|
|||
if (!data.vehicleId) { |
|||
const vehicleRes = await models.MunicipalVehicle.create(data) |
|||
} else { |
|||
const vehicleRes = await models.MunicipalVehicle.update(data, { |
|||
where: { |
|||
id: data.vehicleId |
|||
} |
|||
}) |
|||
} |
|||
|
|||
ctx.status = 204 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const data = ctx.request.body; |
|||
|
|||
if (!data.vehicleId) { |
|||
const vehicleRes = await models.Vehicle.create(data) |
|||
} else { |
|||
const vehicleRes = await models.Vehicle.update(data, { |
|||
where: { |
|||
id: data.vehicleId |
|||
} |
|||
}) |
|||
} |
|||
|
|||
ctx.status = 204 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function specificDel (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { vehicleId } = ctx.params; |
|||
|
|||
const vehicleRes = await models.MunicipalVehicle.destroy({ |
|||
where: { |
|||
id: vehicleId |
|||
} |
|||
}) |
|||
|
|||
ctx.status = 204 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { vehicleId } = ctx.params; |
|||
|
|||
const vehicleRes = await models.Vehicle.destroy({ |
|||
where: { |
|||
id: vehicleId |
|||
} |
|||
}) |
|||
|
|||
ctx.status = 204 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function businessGet (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { nameOfBusinessOwner } = ctx.query; |
|||
|
|||
let findOption = { |
|||
where: { |
|||
|
|||
}, |
|||
order: [['id', 'DESC']] |
|||
} |
|||
if (nameOfBusinessOwner) { |
|||
findOption.where.nameOfBusinessOwner = { |
|||
$like: `%${nameOfBusinessOwner}%` |
|||
} |
|||
} |
|||
const businessRes = await models.MunicipalBusiness.findAll(findOption) |
|||
|
|||
ctx.status = 200; |
|||
ctx.body = businessRes |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { nameOfBusinessOwner } = ctx.query; |
|||
|
|||
let findOption = { |
|||
where: { |
|||
|
|||
} |
|||
} |
|||
if (nameOfBusinessOwner) { |
|||
findOption.where.nameOfBusinessOwner = { |
|||
$like: `%${nameOfBusinessOwner}%` |
|||
} |
|||
} |
|||
const businessRes = await models.MunicipalBusiness.findAll(findOption) |
|||
|
|||
ctx.status = 200; |
|||
ctx.body = businessRes |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function businessEdit (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const data = ctx.request.body; |
|||
|
|||
if (!data.businessId) { |
|||
await models.MunicipalBusiness.create(data) |
|||
} else { |
|||
await models.MunicipalBusiness.update(data, { |
|||
where: { |
|||
id: data.businessId |
|||
} |
|||
}) |
|||
} |
|||
|
|||
ctx.status = 204 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const data = ctx.request.body; |
|||
|
|||
if (!data.businessId) { |
|||
await models.MunicipalBusiness.create(data) |
|||
} else { |
|||
await models.MunicipalBusiness.update(data, { |
|||
where: { |
|||
id: data.businessId |
|||
} |
|||
}) |
|||
} |
|||
|
|||
ctx.status = 204 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function businessDel (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { businessId } = ctx.params; |
|||
|
|||
await models.MunicipalBusiness.destroy({ |
|||
where: { |
|||
id: businessId |
|||
} |
|||
}) |
|||
|
|||
ctx.status = 204 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { businessId } = ctx.params; |
|||
|
|||
await models.Vehicle.MunicipalBusiness({ |
|||
where: { |
|||
id: businessId |
|||
} |
|||
}) |
|||
|
|||
ctx.status = 204 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
module.exports = { |
|||
get, edit, del, |
|||
specificGet, specificEdit, specificDel, |
|||
businessGet, businessEdit, businessDel |
|||
get, edit, del, |
|||
specificGet, specificEdit, specificDel, |
|||
businessGet, businessEdit, businessDel |
|||
}; |
@ -1,31 +1,31 @@ |
|||
'use strict'; |
|||
|
|||
module.exports = function (dc) { |
|||
const FileRoad = dc.orm.define( |
|||
'fileRoad', |
|||
{ |
|||
rId: { |
|||
field: 'id', |
|||
type: dc.ORM.INTEGER, |
|||
primaryKey: true, |
|||
autoIncrement: true, |
|||
allowNull: false |
|||
}, |
|||
roadName: { |
|||
field: 'road_name', |
|||
type: dc.ORM.STRING, |
|||
}, |
|||
originalData: { |
|||
field: 'original_data', |
|||
type: dc.ORM.STRING, |
|||
}, |
|||
}, |
|||
{ |
|||
tableName: 'file_road' |
|||
} |
|||
); |
|||
|
|||
dc.models.FileRoad = FileRoad; |
|||
|
|||
return FileRoad; |
|||
}; |
|||
'use strict'; |
|||
|
|||
module.exports = function (dc) { |
|||
const FileRoad = dc.orm.define( |
|||
'fileRoad', |
|||
{ |
|||
rId: { |
|||
field: 'id', |
|||
type: dc.ORM.INTEGER, |
|||
primaryKey: true, |
|||
autoIncrement: true, |
|||
allowNull: false |
|||
}, |
|||
roadName: { |
|||
field: 'road_name', |
|||
type: dc.ORM.STRING, |
|||
}, |
|||
originalData: { |
|||
field: 'original_data', |
|||
type: dc.ORM.STRING, |
|||
}, |
|||
}, |
|||
{ |
|||
tableName: 'file_road' |
|||
} |
|||
); |
|||
|
|||
dc.models.FileRoad = FileRoad; |
|||
|
|||
return FileRoad; |
|||
}; |
|||
|
@ -1,32 +1,32 @@ |
|||
'use strict'; |
|||
|
|||
module.exports = function (dc) { |
|||
const FileType = dc.orm.define( |
|||
'fileType', |
|||
{ |
|||
fId: { |
|||
field: 'id', |
|||
type: dc.ORM.INTEGER, |
|||
primaryKey: true, |
|||
autoIncrement: true, |
|||
allowNull: false |
|||
}, |
|||
fileType: { |
|||
field: 'file_type', |
|||
type: dc.ORM.STRING, |
|||
}, |
|||
rId: { |
|||
field: 'file_road', |
|||
type: dc.ORM.INTEGER, |
|||
allowNull: false |
|||
}, |
|||
}, |
|||
{ |
|||
tableName: 'file_type' |
|||
} |
|||
); |
|||
|
|||
dc.models.FileType = FileType; |
|||
|
|||
return FileType; |
|||
}; |
|||
'use strict'; |
|||
|
|||
module.exports = function (dc) { |
|||
const FileType = dc.orm.define( |
|||
'fileType', |
|||
{ |
|||
fId: { |
|||
field: 'id', |
|||
type: dc.ORM.INTEGER, |
|||
primaryKey: true, |
|||
autoIncrement: true, |
|||
allowNull: false |
|||
}, |
|||
fileType: { |
|||
field: 'file_type', |
|||
type: dc.ORM.STRING, |
|||
}, |
|||
rId: { |
|||
field: 'file_road', |
|||
type: dc.ORM.INTEGER, |
|||
allowNull: false |
|||
}, |
|||
}, |
|||
{ |
|||
tableName: 'file_type' |
|||
} |
|||
); |
|||
|
|||
dc.models.FileType = FileType; |
|||
|
|||
return FileType; |
|||
}; |
|||
|
@ -1,73 +1,73 @@ |
|||
'use strict'; |
|||
|
|||
module.exports = function (dc) { |
|||
const Files = dc.orm.define( |
|||
'files', |
|||
{ |
|||
id: { |
|||
field: 'id', |
|||
type: dc.ORM.INTEGER, |
|||
primaryKey: true, |
|||
autoIncrement: true, |
|||
allowNull: false |
|||
}, |
|||
fId: { |
|||
field: 'file_type', |
|||
type: dc.ORM.INTEGER |
|||
}, |
|||
roadId: { |
|||
field: 'road_id', |
|||
type: dc.ORM.INTEGER |
|||
}, |
|||
uploaderId: { |
|||
field: 'uploader_id', |
|||
type: dc.ORM.INTEGER |
|||
}, |
|||
uploaderName: { |
|||
field: 'uploader_name', |
|||
type: dc.ORM.INTEGER |
|||
}, |
|||
startDate: { |
|||
field: 'start_date', |
|||
type: dc.ORM.DATE, |
|||
}, |
|||
endDate: { |
|||
field: 'end_date', |
|||
type: dc.ORM.DATE, |
|||
}, |
|||
createDate: { |
|||
field: 'create_date', |
|||
type: dc.ORM.DATE, |
|||
}, |
|||
fileSize: { |
|||
field: 'file_size', |
|||
type: dc.ORM.INTEGER, |
|||
}, |
|||
fileName: { |
|||
field: 'file_name', |
|||
type: dc.ORM.STRING, |
|||
}, |
|||
|
|||
fileUrl: { |
|||
field: 'file_url', |
|||
type: dc.ORM.STRING, |
|||
}, |
|||
fileExt: { |
|||
field: 'file_ext', |
|||
type: dc.ORM.STRING, |
|||
}, |
|||
isDelete: { |
|||
field: 'is_delete', |
|||
type: dc.ORM.BOOLEAN, |
|||
}, |
|||
|
|||
}, |
|||
{ |
|||
tableName: 'files' |
|||
} |
|||
); |
|||
|
|||
dc.models.Files = Files; |
|||
|
|||
return Files; |
|||
}; |
|||
'use strict'; |
|||
|
|||
module.exports = function (dc) { |
|||
const Files = dc.orm.define( |
|||
'files', |
|||
{ |
|||
id: { |
|||
field: 'id', |
|||
type: dc.ORM.INTEGER, |
|||
primaryKey: true, |
|||
autoIncrement: true, |
|||
allowNull: false |
|||
}, |
|||
fId: { |
|||
field: 'file_type', |
|||
type: dc.ORM.INTEGER |
|||
}, |
|||
roadId: { |
|||
field: 'road_id', |
|||
type: dc.ORM.INTEGER |
|||
}, |
|||
uploaderId: { |
|||
field: 'uploader_id', |
|||
type: dc.ORM.INTEGER |
|||
}, |
|||
uploaderName: { |
|||
field: 'uploader_name', |
|||
type: dc.ORM.INTEGER |
|||
}, |
|||
startDate: { |
|||
field: 'start_date', |
|||
type: dc.ORM.DATE, |
|||
}, |
|||
endDate: { |
|||
field: 'end_date', |
|||
type: dc.ORM.DATE, |
|||
}, |
|||
createDate: { |
|||
field: 'create_date', |
|||
type: dc.ORM.DATE, |
|||
}, |
|||
fileSize: { |
|||
field: 'file_size', |
|||
type: dc.ORM.INTEGER, |
|||
}, |
|||
fileName: { |
|||
field: 'file_name', |
|||
type: dc.ORM.STRING, |
|||
}, |
|||
|
|||
fileUrl: { |
|||
field: 'file_url', |
|||
type: dc.ORM.STRING, |
|||
}, |
|||
fileExt: { |
|||
field: 'file_ext', |
|||
type: dc.ORM.STRING, |
|||
}, |
|||
isDelete: { |
|||
field: 'is_delete', |
|||
type: dc.ORM.BOOLEAN, |
|||
}, |
|||
|
|||
}, |
|||
{ |
|||
tableName: 'files' |
|||
} |
|||
); |
|||
|
|||
dc.models.Files = Files; |
|||
|
|||
return Files; |
|||
}; |
|||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 17 KiB |
File diff suppressed because it is too large
Loading…
Reference in new issue