11 changed files with 335 additions and 19 deletions
			
			
		| @ -0,0 +1,106 @@ | |||||
|  | 'use strict' | ||||
|  | //查询路政
 | ||||
|  | async function getRoadadministration(ctx, next) { | ||||
|  |     try { | ||||
|  |          | ||||
|  |         const { limit = 10, page,keyword,startTime,endTime} = ctx.query; | ||||
|  |         // const distinct = 'false' == includeCount ? false : true//gis大屏需要总设备,后台管理不需要include的统计
 | ||||
|  |         const models = ctx.fs.dc.models; | ||||
|  |         let where = {}; | ||||
|  |        | ||||
|  |         if(startTime && endTime){ | ||||
|  |            where.enforcementdate = { | ||||
|  |             where: { enforcementdate: { $between: [moment(startTime).format('YYYY-MM-DD'), moment(endTime).format('YYYY-MM-DD')] } }, | ||||
|  |             } | ||||
|  |             | ||||
|  |         } | ||||
|  |         let findObj = { | ||||
|  |             order: [["id", "desc"]], | ||||
|  |             where: where,  | ||||
|  |         | ||||
|  |         }; | ||||
|  |         if (page && limit) { | ||||
|  |             findObj.limit = Number(limit) | ||||
|  |             findObj.offset = Number(page - 1) * Number(limit) | ||||
|  |         } | ||||
|  |         let rslt = await models.Roadadministration.findAndCountAll(findObj); | ||||
|  |         ctx.body = rslt; | ||||
|  |         ctx.status = 200; | ||||
|  |     } catch (error) { | ||||
|  |         ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); | ||||
|  |         ctx.status = 400; | ||||
|  |         ctx.body = { | ||||
|  |             "message": "获取路政数据失败" | ||||
|  |         } | ||||
|  |     } | ||||
|  | 
 | ||||
|  | } | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | // 新增路政
 | ||||
|  | function addRoadadministration(opts) { | ||||
|  |     return async function (ctx, next) { | ||||
|  |         const models = ctx.fs.dc.models; | ||||
|  |         try { | ||||
|  |             let rslt = ctx.request.body; | ||||
|  |             await models.Roadadministration.create(rslt) | ||||
|  | 
 | ||||
|  |             ctx.status = 204; | ||||
|  |             ctx.body = { message: '添加路政数据成功' } | ||||
|  |         } catch (error) { | ||||
|  |             ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); | ||||
|  |             ctx.status = 400; | ||||
|  |             ctx.body = { message: '添加路政失败' } | ||||
|  |         } | ||||
|  |     } | ||||
|  | } | ||||
|  | 
 | ||||
|  | // 删除路政
 | ||||
|  | function delRoadadministration(opts) { | ||||
|  |     return async function (ctx, next) { | ||||
|  |         try { | ||||
|  |             const models = ctx.fs.dc.models; | ||||
|  |             const { id } = ctx.params; | ||||
|  |             await models.Roadadministration.destroy({ | ||||
|  |                 where: { | ||||
|  |                     id: id | ||||
|  |                 } | ||||
|  |             }) | ||||
|  |             ctx.status = 204; | ||||
|  |             ctx.body = { message: '删除路政信息' } | ||||
|  |         } catch (error) { | ||||
|  |             ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); | ||||
|  |             ctx.status = 400; | ||||
|  |             ctx.body = { message: '删除健康体检' } | ||||
|  |         } | ||||
|  |     } | ||||
|  | } | ||||
|  | 
 | ||||
|  | // 修改路政
 | ||||
|  | function editRoadadministration(opts) { | ||||
|  |     return async function (ctx, next) { | ||||
|  | 
 | ||||
|  |         try { | ||||
|  |             const models = ctx.fs.dc.models; | ||||
|  |             const { id } = ctx.params; | ||||
|  |             const body = ctx.request.body; | ||||
|  |             await models.Roadadministration.update( | ||||
|  |                 body, | ||||
|  |                 { where: { id: id, } } | ||||
|  |             ) | ||||
|  |             ctx.status = 204; | ||||
|  |             ctx.body = { message: '修改健康体检数据成功' } | ||||
|  |         } catch (error) { | ||||
|  |             ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); | ||||
|  |             ctx.status = 400; | ||||
|  |             ctx.body = { message: '修改健康体检数据失败' } | ||||
|  |         } | ||||
|  |     } | ||||
|  | } | ||||
|  | 
 | ||||
|  | module.exports = { | ||||
|  |     getRoadadministration, | ||||
|  |     addRoadadministration, | ||||
|  |     delRoadadministration, | ||||
|  |     editRoadadministration | ||||
|  | } | ||||
| @ -0,0 +1,65 @@ | |||||
|  | /* eslint-disable*/ | ||||
|  | 'use strict'; | ||||
|  | 
 | ||||
|  | module.exports = dc => { | ||||
|  |     const DataTypes = dc.ORM; | ||||
|  |     const sequelize = dc.orm; | ||||
|  |     const Roadadministration = sequelize.define("roadadministration", { | ||||
|  |         id: { | ||||
|  |             index: 1, | ||||
|  |             type: DataTypes.INTEGER, | ||||
|  |             allowNull: false, | ||||
|  |             defaultValue: null, | ||||
|  |             comment: null, | ||||
|  |             primaryKey: true, | ||||
|  |             field: "id", | ||||
|  |             autoIncrement: true | ||||
|  |         }, | ||||
|  |         enforcementdate: { | ||||
|  |             index: 2, | ||||
|  |             type: DataTypes.DATE, | ||||
|  |             allowNull: true, | ||||
|  |             defaultValue: null, | ||||
|  |             comment: '执法日期', | ||||
|  |             primaryKey: false, | ||||
|  |             field: "enforcementdate", | ||||
|  |             autoIncrement: false | ||||
|  |         }, | ||||
|  |         roadname: { | ||||
|  |             index: 3, | ||||
|  |             type: DataTypes.STRING, | ||||
|  |             allowNull: true, | ||||
|  |             defaultValue: null, | ||||
|  |             comment: '道路名称', | ||||
|  |             primaryKey: false, | ||||
|  |             field: "roadname", | ||||
|  |             autoIncrement: false | ||||
|  |         }, | ||||
|  |         enforcementreslt: { | ||||
|  |             index: 4, | ||||
|  |             type: DataTypes.STRING, | ||||
|  |             allowNull: true, | ||||
|  |             defaultValue: null, | ||||
|  |             comment: '执法结果', | ||||
|  |             primaryKey: false, | ||||
|  |             field: "enforcementreslt", | ||||
|  |             autoIncrement: false | ||||
|  |         }, | ||||
|  |         picfile: { | ||||
|  |             index: 4, | ||||
|  |             type: DataTypes.JSON, | ||||
|  |             allowNull: true, | ||||
|  |             defaultValue: null, | ||||
|  |             comment: '执法图片', | ||||
|  |             primaryKey: false, | ||||
|  |             field: "picfile", | ||||
|  |             autoIncrement: false | ||||
|  |         } | ||||
|  |     }, { | ||||
|  |         tableName: "roadadministration", | ||||
|  |         comment: "路政管理", | ||||
|  |         indexes: [] | ||||
|  |     }); | ||||
|  |     dc.models.Roadadministration = Roadadministration; | ||||
|  |     return Roadadministration; | ||||
|  | }; | ||||
| @ -0,0 +1,21 @@ | |||||
|  | 
 | ||||
|  | 
 | ||||
|  | 'use strict'; | ||||
|  | 
 | ||||
|  | const Roadadministration = require('../../controllers/luzheng') | ||||
|  | 
 | ||||
|  | module.exports = function (app, router, opts) { | ||||
|  |     app.fs.api.logAttr['GET/getRoadadministration'] = { content: '获取路政数据', visible: false }; | ||||
|  |     router.get('/getRoadadministration', Roadadministration.getRoadadministration); | ||||
|  | 
 | ||||
|  | 
 | ||||
|  |     app.fs.api.logAttr['POST/addRoadadministration'] = { content: '增加路政数据', visible: true }; | ||||
|  |     router.post('/addRoadadministration', Roadadministration.addRoadadministration(opts)); | ||||
|  | 
 | ||||
|  |         app.fs.api.logAttr['DEL/delRoadadministration/:id'] = { content: '删除路政数据', visible: true }; | ||||
|  |     router.del('/delRoadadministration/:id', Roadadministration.delRoadadministration(opts)) | ||||
|  | 
 | ||||
|  |          // // 修改健康体检
 | ||||
|  |      app.fs.api.logAttr['PUT/editRoadadministration/:id'] = { content: '修改路政数据', visible: true }; | ||||
|  |      router.put('/editRoadadministration/:id', Roadadministration.editRoadadministration(opts)) | ||||
|  | }; | ||||
| @ -0,0 +1,8 @@ | |||||
|  | create table if not exists roadadministration | ||||
|  | ( | ||||
|  |     id serial  not null primary key, | ||||
|  |     enforcementdate timestamp, | ||||
|  |     roadname varchar(255), | ||||
|  |     enforcementreslt varchar(255), | ||||
|  |     picfile jsonb | ||||
|  | ); | ||||
| @ -0,0 +1,51 @@ | |||||
|  | 'use strict'; | ||||
|  | 
 | ||||
|  | import { basicAction } from '@peace/utils' | ||||
|  | import { ApiTable } from '$utils' | ||||
|  | export function getRoadadministration (query) { | ||||
|  |     return dispatch => basicAction({ | ||||
|  |         type: 'get', | ||||
|  |         dispatch: dispatch, | ||||
|  |         query: query, | ||||
|  |         actionType: 'GET_LU_ZHENG', | ||||
|  |         url: ApiTable.getRoadadministration, | ||||
|  |         msg: { option: '获取路政信息' }, | ||||
|  |         // reducer: { name: 'chcekList' }
 | ||||
|  |     }); | ||||
|  | } | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | export function addRoadadministration (params) { | ||||
|  |     return dispatch => basicAction({ | ||||
|  |         type: 'post', | ||||
|  |         data: params, | ||||
|  |         dispatch: dispatch, | ||||
|  |         actionType: 'ADD_LU_ZHENG', | ||||
|  |         url: ApiTable.addRoadadministration, | ||||
|  |         msg: { option: '新增路政信息' }, | ||||
|  |     }); | ||||
|  | } | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | export function delRoadadministration (id) { | ||||
|  |     return dispatch => basicAction({ | ||||
|  |         type: 'delete', | ||||
|  |         dispatch: dispatch, | ||||
|  |         actionType: 'DEL_LU_ZHENG', | ||||
|  |         url: ApiTable.delRoadadministration.replace(':id', id), | ||||
|  |         msg: { option: '删除路政信息' }, | ||||
|  |     }) | ||||
|  | } | ||||
|  | export function modifyRoadadministration (id, params) { | ||||
|  |     return dispatch => basicAction({ | ||||
|  |         type: 'put', | ||||
|  |         data: params, | ||||
|  |         dispatch: dispatch, | ||||
|  |         actionType: 'EDIT_LU_ZHENG', | ||||
|  |         url: ApiTable.modifyRoadadministration.replace(':id', id), | ||||
|  |         msg: { option: '修改路政信息' }, | ||||
|  |     }); | ||||
|  | } | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | 
 | ||||
					Loading…
					
					
				
		Reference in new issue