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'; |
'use strict'; |
||||
|
|
||||
async function get (ctx) { |
async function get (ctx) { |
||||
try { |
try { |
||||
const models = ctx.fs.dc.models; |
const models = ctx.fs.dc.models; |
||||
const { type } = ctx.request.body; |
const { type } = ctx.request.body; |
||||
const { name } = ctx.query; |
const { name } = ctx.query; |
||||
|
|
||||
let findOption = { |
let findOption = { |
||||
where: { |
where: { |
||||
type |
type |
||||
}, |
} |
||||
order: [['id', 'DESC']] |
} |
||||
} |
if (name) { |
||||
if (name) { |
findOption.where.name = { |
||||
findOption.where.name = { |
$like: `%${name}%` |
||||
$like: `%${name}%` |
} |
||||
} |
} |
||||
} |
const vehicleRes = await models.Statistic.findAll(findOption) |
||||
const vehicleRes = await models.Statistic.findAll(findOption) |
|
||||
|
ctx.status = 200; |
||||
ctx.status = 200; |
ctx.body = vehicleRes |
||||
ctx.body = vehicleRes |
} catch (error) { |
||||
} catch (error) { |
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
ctx.status = 400; |
||||
ctx.status = 400; |
ctx.body = { |
||||
ctx.body = { |
message: typeof error == 'string' ? error : undefined |
||||
message: typeof error == 'string' ? error : undefined |
} |
||||
} |
} |
||||
} |
|
||||
} |
} |
||||
|
|
||||
async function edit (ctx) { |
async function edit (ctx) { |
||||
try { |
try { |
||||
const models = ctx.fs.dc.models; |
const models = ctx.fs.dc.models; |
||||
const { id, name, count, type } = ctx.request.body; |
const { id, name, count, type } = ctx.request.body; |
||||
|
|
||||
if (!id) { |
if (!id) { |
||||
await models.Statistic.create({ |
await models.Statistic.create({ |
||||
name, count, type: type |
name, count, type: type |
||||
}) |
}) |
||||
} else { |
} else { |
||||
await models.Statistic.update({ |
await models.Statistic.update({ |
||||
name, count, type: type |
name, count, type: type |
||||
}, { |
}, { |
||||
where: { |
where: { |
||||
id: id |
id: id |
||||
} |
} |
||||
}) |
}) |
||||
} |
} |
||||
|
|
||||
ctx.status = 204 |
ctx.status = 204 |
||||
} catch (error) { |
} catch (error) { |
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
ctx.status = 400; |
ctx.status = 400; |
||||
ctx.body = { |
ctx.body = { |
||||
message: typeof error == 'string' ? error : undefined |
message: typeof error == 'string' ? error : undefined |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
async function del (ctx) { |
async function del (ctx) { |
||||
try { |
try { |
||||
const models = ctx.fs.dc.models; |
const models = ctx.fs.dc.models; |
||||
const { id } = ctx.params; |
const { id } = ctx.params; |
||||
|
|
||||
await models.Statistic.destroy({ |
await models.Statistic.destroy({ |
||||
where: { |
where: { |
||||
id: id |
id: id |
||||
} |
} |
||||
}) |
}) |
||||
|
|
||||
ctx.status = 204 |
ctx.status = 204 |
||||
} catch (error) { |
} catch (error) { |
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
ctx.status = 400; |
ctx.status = 400; |
||||
ctx.body = { |
ctx.body = { |
||||
message: typeof error == 'string' ? error : undefined |
message: typeof error == 'string' ? error : undefined |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
async function specificGet (ctx) { |
async function specificGet (ctx) { |
||||
try { |
try { |
||||
const models = ctx.fs.dc.models; |
const models = ctx.fs.dc.models; |
||||
const { type } = ctx.query; |
const { type } = ctx.query; |
||||
const { nameOfBusinessOwner } = ctx.query; |
const { nameOfBusinessOwner } = ctx.query; |
||||
|
|
||||
let findOption = { |
let findOption = { |
||||
where: { |
where: { |
||||
type |
type |
||||
}, |
} |
||||
order: [['id', 'DESC']] |
} |
||||
} |
if (nameOfBusinessOwner) { |
||||
if (nameOfBusinessOwner) { |
findOption.where.nameOfBusinessOwner = { |
||||
findOption.where.nameOfBusinessOwner = { |
$like: `%${nameOfBusinessOwner}%` |
||||
$like: `%${nameOfBusinessOwner}%` |
} |
||||
} |
} |
||||
} |
|
||||
|
const vehicleRes = await models.MunicipalVehicle.findAll(findOption) |
||||
const vehicleRes = await models.MunicipalVehicle.findAll(findOption) |
|
||||
|
ctx.status = 200; |
||||
ctx.status = 200; |
ctx.body = vehicleRes |
||||
ctx.body = vehicleRes |
} catch (error) { |
||||
} catch (error) { |
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
ctx.status = 400; |
||||
ctx.status = 400; |
ctx.body = { |
||||
ctx.body = { |
message: typeof error == 'string' ? error : undefined |
||||
message: typeof error == 'string' ? error : undefined |
} |
||||
} |
} |
||||
} |
|
||||
} |
} |
||||
|
|
||||
async function specificEdit (ctx) { |
async function specificEdit (ctx) { |
||||
try { |
try { |
||||
const models = ctx.fs.dc.models; |
const models = ctx.fs.dc.models; |
||||
const data = ctx.request.body; |
const data = ctx.request.body; |
||||
|
|
||||
if (!data.vehicleId) { |
if (!data.vehicleId) { |
||||
const vehicleRes = await models.MunicipalVehicle.create(data) |
const vehicleRes = await models.Vehicle.create(data) |
||||
} else { |
} else { |
||||
const vehicleRes = await models.MunicipalVehicle.update(data, { |
const vehicleRes = await models.Vehicle.update(data, { |
||||
where: { |
where: { |
||||
id: data.vehicleId |
id: data.vehicleId |
||||
} |
} |
||||
}) |
}) |
||||
} |
} |
||||
|
|
||||
ctx.status = 204 |
ctx.status = 204 |
||||
} catch (error) { |
} catch (error) { |
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
ctx.status = 400; |
ctx.status = 400; |
||||
ctx.body = { |
ctx.body = { |
||||
message: typeof error == 'string' ? error : undefined |
message: typeof error == 'string' ? error : undefined |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
async function specificDel (ctx) { |
async function specificDel (ctx) { |
||||
try { |
try { |
||||
const models = ctx.fs.dc.models; |
const models = ctx.fs.dc.models; |
||||
const { vehicleId } = ctx.params; |
const { vehicleId } = ctx.params; |
||||
|
|
||||
const vehicleRes = await models.MunicipalVehicle.destroy({ |
const vehicleRes = await models.Vehicle.destroy({ |
||||
where: { |
where: { |
||||
id: vehicleId |
id: vehicleId |
||||
} |
} |
||||
}) |
}) |
||||
|
|
||||
ctx.status = 204 |
ctx.status = 204 |
||||
} catch (error) { |
} catch (error) { |
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
ctx.status = 400; |
ctx.status = 400; |
||||
ctx.body = { |
ctx.body = { |
||||
message: typeof error == 'string' ? error : undefined |
message: typeof error == 'string' ? error : undefined |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
async function businessGet (ctx) { |
async function businessGet (ctx) { |
||||
try { |
try { |
||||
const models = ctx.fs.dc.models; |
const models = ctx.fs.dc.models; |
||||
const { nameOfBusinessOwner } = ctx.query; |
const { nameOfBusinessOwner } = ctx.query; |
||||
|
|
||||
let findOption = { |
let findOption = { |
||||
where: { |
where: { |
||||
|
|
||||
}, |
} |
||||
order: [['id', 'DESC']] |
} |
||||
} |
if (nameOfBusinessOwner) { |
||||
if (nameOfBusinessOwner) { |
findOption.where.nameOfBusinessOwner = { |
||||
findOption.where.nameOfBusinessOwner = { |
$like: `%${nameOfBusinessOwner}%` |
||||
$like: `%${nameOfBusinessOwner}%` |
} |
||||
} |
} |
||||
} |
const businessRes = await models.MunicipalBusiness.findAll(findOption) |
||||
const businessRes = await models.MunicipalBusiness.findAll(findOption) |
|
||||
|
ctx.status = 200; |
||||
ctx.status = 200; |
ctx.body = businessRes |
||||
ctx.body = businessRes |
} catch (error) { |
||||
} catch (error) { |
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
ctx.status = 400; |
||||
ctx.status = 400; |
ctx.body = { |
||||
ctx.body = { |
message: typeof error == 'string' ? error : undefined |
||||
message: typeof error == 'string' ? error : undefined |
} |
||||
} |
} |
||||
} |
|
||||
} |
} |
||||
|
|
||||
async function businessEdit (ctx) { |
async function businessEdit (ctx) { |
||||
try { |
try { |
||||
const models = ctx.fs.dc.models; |
const models = ctx.fs.dc.models; |
||||
const data = ctx.request.body; |
const data = ctx.request.body; |
||||
|
|
||||
if (!data.businessId) { |
if (!data.businessId) { |
||||
await models.MunicipalBusiness.create(data) |
await models.MunicipalBusiness.create(data) |
||||
} else { |
} else { |
||||
await models.MunicipalBusiness.update(data, { |
await models.MunicipalBusiness.update(data, { |
||||
where: { |
where: { |
||||
id: data.businessId |
id: data.businessId |
||||
} |
} |
||||
}) |
}) |
||||
} |
} |
||||
|
|
||||
ctx.status = 204 |
ctx.status = 204 |
||||
} catch (error) { |
} catch (error) { |
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
ctx.status = 400; |
ctx.status = 400; |
||||
ctx.body = { |
ctx.body = { |
||||
message: typeof error == 'string' ? error : undefined |
message: typeof error == 'string' ? error : undefined |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
async function businessDel (ctx) { |
async function businessDel (ctx) { |
||||
try { |
try { |
||||
const models = ctx.fs.dc.models; |
const models = ctx.fs.dc.models; |
||||
const { businessId } = ctx.params; |
const { businessId } = ctx.params; |
||||
|
|
||||
await models.MunicipalBusiness.destroy({ |
await models.Vehicle.MunicipalBusiness({ |
||||
where: { |
where: { |
||||
id: businessId |
id: businessId |
||||
} |
} |
||||
}) |
}) |
||||
|
|
||||
ctx.status = 204 |
ctx.status = 204 |
||||
} catch (error) { |
} catch (error) { |
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
ctx.status = 400; |
ctx.status = 400; |
||||
ctx.body = { |
ctx.body = { |
||||
message: typeof error == 'string' ? error : undefined |
message: typeof error == 'string' ? error : undefined |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
get, edit, del, |
get, edit, del, |
||||
specificGet, specificEdit, specificDel, |
specificGet, specificEdit, specificDel, |
||||
businessGet, businessEdit, businessDel |
businessGet, businessEdit, businessDel |
||||
}; |
}; |
@ -1,31 +1,31 @@ |
|||||
'use strict'; |
'use strict'; |
||||
|
|
||||
module.exports = function (dc) { |
module.exports = function (dc) { |
||||
const FileRoad = dc.orm.define( |
const FileRoad = dc.orm.define( |
||||
'fileRoad', |
'fileRoad', |
||||
{ |
{ |
||||
rId: { |
rId: { |
||||
field: 'id', |
field: 'id', |
||||
type: dc.ORM.INTEGER, |
type: dc.ORM.INTEGER, |
||||
primaryKey: true, |
primaryKey: true, |
||||
autoIncrement: true, |
autoIncrement: true, |
||||
allowNull: false |
allowNull: false |
||||
}, |
}, |
||||
roadName: { |
roadName: { |
||||
field: 'road_name', |
field: 'road_name', |
||||
type: dc.ORM.STRING, |
type: dc.ORM.STRING, |
||||
}, |
}, |
||||
originalData: { |
originalData: { |
||||
field: 'original_data', |
field: 'original_data', |
||||
type: dc.ORM.STRING, |
type: dc.ORM.STRING, |
||||
}, |
}, |
||||
}, |
}, |
||||
{ |
{ |
||||
tableName: 'file_road' |
tableName: 'file_road' |
||||
} |
} |
||||
); |
); |
||||
|
|
||||
dc.models.FileRoad = FileRoad; |
dc.models.FileRoad = FileRoad; |
||||
|
|
||||
return FileRoad; |
return FileRoad; |
||||
}; |
}; |
||||
|
@ -1,32 +1,32 @@ |
|||||
'use strict'; |
'use strict'; |
||||
|
|
||||
module.exports = function (dc) { |
module.exports = function (dc) { |
||||
const FileType = dc.orm.define( |
const FileType = dc.orm.define( |
||||
'fileType', |
'fileType', |
||||
{ |
{ |
||||
fId: { |
fId: { |
||||
field: 'id', |
field: 'id', |
||||
type: dc.ORM.INTEGER, |
type: dc.ORM.INTEGER, |
||||
primaryKey: true, |
primaryKey: true, |
||||
autoIncrement: true, |
autoIncrement: true, |
||||
allowNull: false |
allowNull: false |
||||
}, |
}, |
||||
fileType: { |
fileType: { |
||||
field: 'file_type', |
field: 'file_type', |
||||
type: dc.ORM.STRING, |
type: dc.ORM.STRING, |
||||
}, |
}, |
||||
rId: { |
rId: { |
||||
field: 'file_road', |
field: 'file_road', |
||||
type: dc.ORM.INTEGER, |
type: dc.ORM.INTEGER, |
||||
allowNull: false |
allowNull: false |
||||
}, |
}, |
||||
}, |
}, |
||||
{ |
{ |
||||
tableName: 'file_type' |
tableName: 'file_type' |
||||
} |
} |
||||
); |
); |
||||
|
|
||||
dc.models.FileType = FileType; |
dc.models.FileType = FileType; |
||||
|
|
||||
return FileType; |
return FileType; |
||||
}; |
}; |
||||
|
@ -1,73 +1,73 @@ |
|||||
'use strict'; |
'use strict'; |
||||
|
|
||||
module.exports = function (dc) { |
module.exports = function (dc) { |
||||
const Files = dc.orm.define( |
const Files = dc.orm.define( |
||||
'files', |
'files', |
||||
{ |
{ |
||||
id: { |
id: { |
||||
field: 'id', |
field: 'id', |
||||
type: dc.ORM.INTEGER, |
type: dc.ORM.INTEGER, |
||||
primaryKey: true, |
primaryKey: true, |
||||
autoIncrement: true, |
autoIncrement: true, |
||||
allowNull: false |
allowNull: false |
||||
}, |
}, |
||||
fId: { |
fId: { |
||||
field: 'file_type', |
field: 'file_type', |
||||
type: dc.ORM.INTEGER |
type: dc.ORM.INTEGER |
||||
}, |
}, |
||||
roadId: { |
roadId: { |
||||
field: 'road_id', |
field: 'road_id', |
||||
type: dc.ORM.INTEGER |
type: dc.ORM.INTEGER |
||||
}, |
}, |
||||
uploaderId: { |
uploaderId: { |
||||
field: 'uploader_id', |
field: 'uploader_id', |
||||
type: dc.ORM.INTEGER |
type: dc.ORM.INTEGER |
||||
}, |
}, |
||||
uploaderName: { |
uploaderName: { |
||||
field: 'uploader_name', |
field: 'uploader_name', |
||||
type: dc.ORM.INTEGER |
type: dc.ORM.INTEGER |
||||
}, |
}, |
||||
startDate: { |
startDate: { |
||||
field: 'start_date', |
field: 'start_date', |
||||
type: dc.ORM.DATE, |
type: dc.ORM.DATE, |
||||
}, |
}, |
||||
endDate: { |
endDate: { |
||||
field: 'end_date', |
field: 'end_date', |
||||
type: dc.ORM.DATE, |
type: dc.ORM.DATE, |
||||
}, |
}, |
||||
createDate: { |
createDate: { |
||||
field: 'create_date', |
field: 'create_date', |
||||
type: dc.ORM.DATE, |
type: dc.ORM.DATE, |
||||
}, |
}, |
||||
fileSize: { |
fileSize: { |
||||
field: 'file_size', |
field: 'file_size', |
||||
type: dc.ORM.INTEGER, |
type: dc.ORM.INTEGER, |
||||
}, |
}, |
||||
fileName: { |
fileName: { |
||||
field: 'file_name', |
field: 'file_name', |
||||
type: dc.ORM.STRING, |
type: dc.ORM.STRING, |
||||
}, |
}, |
||||
|
|
||||
fileUrl: { |
fileUrl: { |
||||
field: 'file_url', |
field: 'file_url', |
||||
type: dc.ORM.STRING, |
type: dc.ORM.STRING, |
||||
}, |
}, |
||||
fileExt: { |
fileExt: { |
||||
field: 'file_ext', |
field: 'file_ext', |
||||
type: dc.ORM.STRING, |
type: dc.ORM.STRING, |
||||
}, |
}, |
||||
isDelete: { |
isDelete: { |
||||
field: 'is_delete', |
field: 'is_delete', |
||||
type: dc.ORM.BOOLEAN, |
type: dc.ORM.BOOLEAN, |
||||
}, |
}, |
||||
|
|
||||
}, |
}, |
||||
{ |
{ |
||||
tableName: 'files' |
tableName: 'files' |
||||
} |
} |
||||
); |
); |
||||
|
|
||||
dc.models.Files = Files; |
dc.models.Files = Files; |
||||
|
|
||||
return 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