Browse Source

添加路政接口

dev
dengyinhuan 1 year ago
parent
commit
588a674075
  1. 2
      api/.vscode/launch.json
  2. 106
      api/app/lib/controllers/luzheng/index.js
  3. 65
      api/app/lib/models/roadadministration.js
  4. 21
      api/app/lib/routes/luzheng/index.js
  5. 26
      api/log/development.log
  6. 8
      scripts/1.3.0/schema/6.roadadministration.sql
  7. 51
      web/client/src/sections/fillion/actions/luzheng.js
  8. 4
      web/client/src/sections/fillion/nav-item.js
  9. 12
      web/client/src/sections/fillion/routes.js
  10. 2
      web/log/development.txt
  11. 2
      web/package.json

2
api/.vscode/launch.json

@ -15,7 +15,7 @@
"args": [
"-p 13400",
"-f http://localhost:13400",
"-g postgres://postgres:123@10.8.30.32:5432/highways4good",
"-g postgres://FashionAdmin:123456@10.8.16.184:5432/sihaogonglu",
// "-g postgres://FashionAdmin:123456@10.8.30.156:5432/highway4goodn0728",
"--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5",
"--qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa",

106
api/app/lib/controllers/luzheng/index.js

@ -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
}

65
api/app/lib/models/roadadministration.js

@ -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;
};

21
api/app/lib/routes/luzheng/index.js

@ -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))
};

26
api/log/development.log

@ -11221,3 +11221,29 @@ headers: {}
2023-07-12 14:02:42.806 - debug: [FS-LOGGER] Init.
2023-07-12 14:02:45.494 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-07-12 14:02:45.494 - info: [FS-AUTH] Inject auth and api mv into router.
2023-08-04 10:30:41.781 - debug: [FS-LOGGER] Init.
2023-08-04 10:30:41.927 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-08-04 10:30:41.927 - info: [FS-AUTH] Inject auth and api mv into router.
2023-08-04 11:23:09.113 - debug: [FS-LOGGER] Init.
2023-08-04 11:23:09.402 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-08-04 11:23:09.403 - info: [FS-AUTH] Inject auth and api mv into router.
2023-08-04 11:30:31.013 - error: path: /getRoadadministration, error: TypeError: Cannot read property 'getTableName' of undefined
2023-08-04 11:30:56.286 - error: path: /getRoadadministration, error: TypeError: Cannot read property 'getTableName' of undefined
2023-08-04 11:31:35.771 - error: path: /getRoadadministration, error: TypeError: Cannot read property 'getTableName' of undefined
2023-08-04 11:31:46.650 - error: path: /getRoadadministration, error: TypeError: Cannot read property 'getTableName' of undefined
2023-08-04 11:32:58.510 - error: path: /getRoadadministration, error: TypeError: Cannot read property 'getTableName' of undefined
2023-08-04 11:33:37.236 - debug: [FS-LOGGER] Init.
2023-08-04 11:33:37.408 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-08-04 11:33:37.408 - info: [FS-AUTH] Inject auth and api mv into router.
2023-08-04 11:33:52.890 - debug: [FS-LOGGER] Init.
2023-08-04 11:33:53.087 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-08-04 11:33:53.088 - info: [FS-AUTH] Inject auth and api mv into router.
2023-08-04 11:38:00.767 - debug: [FS-LOGGER] Init.
2023-08-04 11:38:00.925 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-08-04 11:38:00.925 - info: [FS-AUTH] Inject auth and api mv into router.
2023-08-04 11:40:41.185 - debug: [FS-LOGGER] Init.
2023-08-04 11:40:41.345 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-08-04 11:40:41.345 - info: [FS-AUTH] Inject auth and api mv into router.
2023-08-04 11:41:27.071 - debug: [FS-LOGGER] Init.
2023-08-04 11:41:27.232 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-08-04 11:41:27.233 - info: [FS-AUTH] Inject auth and api mv into router.

8
scripts/1.3.0/schema/6.roadadministration.sql

@ -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
);

51
web/client/src/sections/fillion/actions/luzheng.js

@ -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: '修改路政信息' },
});
}

4
web/client/src/sections/fillion/nav-item.js

@ -33,6 +33,10 @@ export function getNavItem(user, dispatch) {
{/* <Menu.Item key="filliontask">
<Link to="/fillion/task">任务管理</Link>
</Menu.Item> */}
{user?.username == 'SuperAdmin' || user?.userResources?.some(i => i.resourceId === 'OVERLOADMANAGE') ?
<Menu.Item key="luzheng">
<Link to="/fillion/luzheng">路政管理</Link>
</Menu.Item> : ''}
{user?.username == 'SuperAdmin' || user?.userResources?.some(i => i.resourceId === 'ROADMANAGE') ?
<Menu.Item key="filliontransportation">
<Link to="/fillion/transportation">道路管理</Link>

12
web/client/src/sections/fillion/routes.js

@ -15,6 +15,7 @@ import { Jiekouguanli } from './containers'
import { Task, Assess, VideoCenter, } from './containers'
import { Building } from './containers'
import { MaintenanceSpotCheck } from './containers'
import Luzheng from './containers/luzheng';
export default [{
type: 'inner',
route: {
@ -30,7 +31,16 @@ export default [{
component: Infor,
breadcrumb: '治超管理',
authCode: 'OVERLOADMANAGE'
}, {
},
{
path: '/luzheng',
key: 'luzheng',
menuSelectKeys: ['luzheng'],
component: Luzheng,
breadcrumb: '路政管理',
authCode: 'OVERLOADMANAGE'
},
{
path: '/task',
key: 'filliontask',
menuSelectKeys: ['filliontask'],

2
web/log/development.txt

@ -30381,3 +30381,5 @@
2022-09-01 18:26:45.562 - info: [Router] Inject api: attachment/index
2022-09-05 14:03:41.310 - debug: [FS-LOGGER] Init.
2022-09-05 14:03:41.810 - info: [Router] Inject api: attachment/index
2023-08-04 10:24:58.335 - debug: [FS-LOGGER] Init.
2023-08-04 10:24:58.408 - info: [Router] Inject api: attachment/index

2
web/package.json

@ -95,4 +95,4 @@
"webpack-dev-server": "^3.11.2",
"xlsx": "^0.16.9"
}
}
}

Loading…
Cancel
Save