Browse Source

冲突解决

dev
wenlele 1 year ago
parent
commit
673e1a54b4
  1. 90
      api/app/lib/controllers/images/index.js
  2. 44
      api/app/lib/models/car_images.js
  3. 10
      api/app/lib/routes/images/index.js
  4. 1
      api/package.json
  5. 2
      api/sequelize-automate.config.js
  6. 16
      scripts/1.4.2/1.create_car_images.sql
  7. 15
      web/client/src/sections/fillion/actions/carimages.js
  8. 124
      web/client/src/sections/fillion/containers/carimages.js
  9. 17
      web/client/src/sections/fillion/nav-item.js
  10. 35
      web/client/src/sections/fillion/routes.js
  11. 12
      web/client/src/utils/webapi.js
  12. 1
      web/package.json

90
api/app/lib/controllers/images/index.js

@ -0,0 +1,90 @@
'use strict'
const request = require('superagent')
const moment = require('moment')
// function getFileCarImages (opts) {
// return async function (ctx, next) {
// let error = { message: '文件夹名称更新失败' }
// const models = ctx.fs.dc.models
// const { page, limit, } = ctx.query
// try {
// let searchWhere = {}
// let option = {
// where: searchWhere,
// order: [["id", "desc"]],
// }
// option.where = searchWhere
// let limit_ = limit || 10
// let page_ = page || 1
// let offset = (page_ - 1) * limit_
// if (limit && page) {
// option.limit = limit_
// option.offset = offset
// }
// const res = await models.CarImages.findAndCount(option)
// error = null
// } catch (err) {
// ctx.status = 500
// ctx.body = { detail: err, ...error }
// }
// if (error) {
// ctx.status = 400
// ctx.body = { ...error }
// } else {
// ctx.status = 200
// ctx.body = { message: '文件夹名称更新成功' }
// }
// }
// }
function getFileCarImages (opts) {
return async function (ctx, next) {
const models = ctx.fs.dc.models
const { page, limit, } = ctx.query
const Op = ctx.fs.dc.ORM.Op
let errMsg = { message: '获取图片失败' }
try {
let searchWhere = {}
let option = {
where: searchWhere,
order: [["id", "ASC"]],
}
option.where = searchWhere
let limit_ = limit || 10
let page_ = page || 1
let offset = (page_ - 1) * limit_
if (limit && page) {
option.limit = limit_
option.offset = offset
}
const res = await models.CarImages.findAndCount(option)
ctx.status = 200
ctx.body = res
} catch (error) {
ctx.status = 400
ctx.body = errMsg
}
}
}
module.exports = {
getFileCarImages
}

44
api/app/lib/models/car_images.js

@ -0,0 +1,44 @@
/* eslint-disable*/
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const CarImages = sequelize.define("carImages", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "car_images_id_uindex"
},
url: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "图片路径",
primaryKey: false,
field: "url",
autoIncrement: false
},
time: {
type: DataTypes.DATE,
allowNull: true,
defaultValue: null,
comment: "时间",
primaryKey: false,
field: "time",
autoIncrement: false
}
}, {
tableName: "car_images",
comment: "",
indexes: []
});
dc.models.CarImages = CarImages;
return CarImages;
};

10
api/app/lib/routes/images/index.js

@ -0,0 +1,10 @@
'use strict'
const images = require('../../controllers/images')
module.exports = function (app, router, opts, panCode) {
router.get('/car/images', images.getFileCarImages(opts))
}

1
api/package.json

@ -36,6 +36,7 @@
"redis": "^3.1.2", "redis": "^3.1.2",
"request": "^2.88.2", "request": "^2.88.2",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"sequelize-automate-freesun": "^1.2.2",
"superagent": "^3.5.2", "superagent": "^3.5.2",
"swagger-jsdoc": "^6.1.0", "swagger-jsdoc": "^6.1.0",
"uuid": "^3.3.2", "uuid": "^3.3.2",

2
api/sequelize-automate.config.js

@ -35,7 +35,7 @@ module.exports = {
dir: './app/lib/models', // 指定输出 models 文件的目录 dir: './app/lib/models', // 指定输出 models 文件的目录
typesDir: 'models', // 指定输出 TypeScript 类型定义的文件目录,只有 TypeScript / Midway 等会有类型定义 typesDir: 'models', // 指定输出 TypeScript 类型定义的文件目录,只有 TypeScript / Midway 等会有类型定义
emptyDir: false, // !!! 谨慎操作 生成 models 之前是否清空 `dir` 以及 `typesDir` emptyDir: false, // !!! 谨慎操作 生成 models 之前是否清空 `dir` 以及 `typesDir`
tables: ['road_spot_check_preview'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性 tables: ['car_images'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性
skipTables: [], // 指定跳过哪些表的 models,如 ['user'];如果为 null,则忽略改属性 skipTables: [], // 指定跳过哪些表的 models,如 ['user'];如果为 null,则忽略改属性
tsNoCheck: false, // 是否添加 `@ts-nocheck` 注释到 models 文件中 tsNoCheck: false, // 是否添加 `@ts-nocheck` 注释到 models 文件中
ignorePrefix: [], // 生成的模型名称忽略的前缀,因为 项目中有以下表名是以 t_ 开头的,在实际模型中不需要, 可以添加多个 [ 't_data_', 't_',] ,长度较长的 前缀放前面 ignorePrefix: [], // 生成的模型名称忽略的前缀,因为 项目中有以下表名是以 t_ 开头的,在实际模型中不需要, 可以添加多个 [ 't_data_', 't_',] ,长度较长的 前缀放前面

16
scripts/1.4.2/1.create_car_images.sql

@ -0,0 +1,16 @@
create table car_images
(
id serial
constraint car_images_pk
primary key,
url varchar,
time timestamptz
);
comment on column car_images.url is '图片路径';
comment on column car_images.time is '时间';
create unique index car_images_id_uindex
on car_images (id);

15
web/client/src/sections/fillion/actions/carimages.js

@ -0,0 +1,15 @@
import { basicAction } from '@peace/utils'
import { ApiTable } from '$utils'
export function getCarImages (query) {
return dispatch => basicAction({
type: 'get',
dispatch: dispatch,
actionType: 'GET_CAR_IMAGES',
url: ApiTable.getCarImages,
query,
msg: { error: '获取图片失败' },
reducer: { name: 'carimage' }
})
}

124
web/client/src/sections/fillion/containers/carimages.js

@ -0,0 +1,124 @@
// import React, { useState, useEffect } from 'react'
// import { connect } from 'react-redux'
// import { getCarImages } from '../actions/carimages'
// import ProTable from '@ant-design/pro-table'
// import { Form, Space, DatePicker, Button, Select, Popconfirm, Image, Tooltip } from 'antd'
// import moment from 'moment'
// function Carimages (props) {
// const { dispatch, assess, user } = props
// const [query, setQuery] = useState({ page: 1, pageSize: 10, })
// const [loading, setLoading] = useState(false)
// const [datasource, setdatasource] = useState([])
// const [dateRange, setDateRange] = useState(['1970-1-1', '2099-12-31'])
// const { RangePicker } = DatePicker
// const [total, settotal] = useState(0)
// const [editAble, setEditAble] = useState(user?.username !== 'SuperAdmin' && user?.userResources?.find(i => i.resourceId === 'ASSESSMANAGE')?.isshow === "true" ? true : '')
// useEffect(() => {
// return () => { }
// }, [])
// useEffect(() => {
// getData()
// }, [query])
// const getData = () => {
// console.log(query, 'query')
// dispatch(getCarImages({ ...query })).then(res => {
// if (res?.success) {
// setdatasource(res?.payload?.data?.rows)
// settotal(res?.payload?.data?.count)
// }
// })
// }
// return (
// <div>
// <div style={{ marginBottom: '20px', display: 'flex', justifyContent: 'space-between' }}>
// <Form layout="inline" onFinish={(v) => {
// setQuery({
// ...query, page: 1, unit: v.unit, startTime: v?.time && moment(v?.time[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss'),
// endTime: v?.time && moment(v?.time[1]).add(1, 'days').endOf('day').format('YYYY-MM-DD HH:mm:ss')
// })
// }}>
// {/* <Form.Item>
// <Button type="primary" htmlType="submit">搜索</Button>
// </Form.Item> */}
// </Form>
// {/* <Button type="primary" disabled={editAble}
// onClick={() => {
// setAssessModalVisible(true)
// }}>新增</Button> */}
// </div>
// <ProTable
// columns={[
// {
// title: '序号',
// dataIndex: 'id',
// key: 'id',
// defaultSortOrder: 'ascend',
// },
// {
// title: '抓拍图片',
// dataIndex: 'url',
// key: 'url',
// render: (t, r) => {
// if (r?.url && r?.id) {
// return <span style={{ marginRight: 10 }}>
// <Image src={r?.url} width={200} />
// </span>
// } else {
// return '--'
// }
// }
// },
// {
// title: '日期',
// dataIndex: 'time',
// key: 'time',
// render: (t, r) => {
// const localTime = moment.utc(r?.time).format('YYYY-MM-DD HH:mm:ss')
// return r?.time ? localTime : '--'
// }
// },
// ]}
// dataSource={datasource || []}
// loading={loading}
// pagination={{
// total: total || 0,
// pageSize: 10,
// defaultPageSize: 10,
// showSizeChanger: false,
// onChange: (page, pageSize) => {
// setQuery({
// ...query,
// page,
// limit: pageSize
// })
// }
// }}
// rowKey="key"
// toolBarRender={false}
// search={false}
// />
// </div>
// )
// }
// function mapStateToProps (state) {
// const { auth, assess } = state
// return {
// user: auth.user,
// assess: assess.data || [],
// }
// }
// export default connect(mapStateToProps)(Carimages)

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

@ -1,8 +1,8 @@
import React from 'react'; import React from 'react'
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom'
import { Menu } from 'antd'; import { Menu } from 'antd'
import { ReadOutlined } from '@ant-design/icons'; import { ReadOutlined } from '@ant-design/icons'
const SubMenu = Menu.SubMenu; const SubMenu = Menu.SubMenu
export function getNavItem (user, dispatch) { export function getNavItem (user, dispatch) {
const isshow = user?.userResources?. const isshow = user?.userResources?.
some(i => i.resourceId === 'OVERLOADMANAGE' || some(i => i.resourceId === 'OVERLOADMANAGE' ||
@ -72,6 +72,11 @@ export function getNavItem (user, dispatch) {
<Menu.Item key="fillioninfor"> <Menu.Item key="fillioninfor">
<Link to="/fillion/infor">治超管理</Link> <Link to="/fillion/infor">治超管理</Link>
</Menu.Item> : ''} </Menu.Item> : ''}
{/* {user?.username == 'SuperAdmin' || user?.userResources?.some(i => i.resourceId === 'OVERLOADMANAGE') ?
<Menu.Item key="fillioncarimages">
<Link to="/fillion/carimages">车辆抓拍管理</Link>
</Menu.Item> : ''}*/}
</SubMenu> </SubMenu>
: '' : ''
} }
@ -148,5 +153,5 @@ export function getNavItem (user, dispatch) {
</SubMenu> : null </SubMenu> : null
); )
} }

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

@ -1,21 +1,22 @@
'use strict'; 'use strict'
import { Infor } from './containers'; import { Infor } from './containers'
import { transportation } from './containers'; import { transportation } from './containers'
import { BridgeTable } from './containers'; import { BridgeTable } from './containers'
import { HigHways } from './containers'; import { HigHways } from './containers'
import { OperaTional } from './containers'; import { OperaTional } from './containers'
import { Enforce } from './containers'; import { Enforce } from './containers'
import { Public } from './containers'; import { Public } from './containers'
import { Videois } from './containers'; import { Videois } from './containers'
import { PromoTional } from './containers'; import { PromoTional } from './containers'
import { Maintenance } from './containers' import { Maintenance } from './containers'
import { Patrol } from './containers' import { Patrol } from './containers'
import { File } from './containers'; import { File } from './containers'
import { Jiekouguanli } from './containers' import { Jiekouguanli } from './containers'
import { Task, Assess, VideoCenter, } from './containers' import { Task, Assess, VideoCenter, } from './containers'
import { Building } from './containers' import { Building } from './containers'
import { MaintenanceSpotCheckNew, AdjustLog } from './containers' import { MaintenanceSpotCheckNew, AdjustLog } from './containers'
import Luzheng from './containers/luzheng'; import Carimages from './containers/carimages'
import Luzheng from './containers/luzheng'
export default [{ export default [{
type: 'inner', type: 'inner',
route: { route: {
@ -32,6 +33,14 @@ export default [{
breadcrumb: '治超管理', breadcrumb: '治超管理',
authCode: 'OVERLOADMANAGE' authCode: 'OVERLOADMANAGE'
}, },
// {
// path: '/carimages',
// key: 'fillioncarimages',
// menuSelectKeys: ['fillioncarimages'],
// component: Carimages,
// breadcrumb: '车辆抓拍管理',
// authCode: 'OVERLOADMANAGE'
// },
{ {
path: '/luzheng', path: '/luzheng',
key: 'luzheng', key: 'luzheng',
@ -203,4 +212,4 @@ export default [{
} }
] ]
} }
}]; }]

12
web/client/src/utils/webapi.js

@ -1,7 +1,7 @@
'use strict'; 'use strict'
import { ProxyRequest } from "@peace/utils"; import { ProxyRequest } from "@peace/utils"
export const GodTransRequest = new ProxyRequest("_godTrans"); export const GodTransRequest = new ProxyRequest("_godTrans")
export const ApiTable = { export const ApiTable = {
login: 'login', login: 'login',
@ -314,11 +314,13 @@ export const ApiTable = {
getRoadadministration: '/getRoadadministration', getRoadadministration: '/getRoadadministration',
// 发送短信 // 发送短信
pushAppointSMS: 'pushAppointSMS', pushAppointSMS: 'pushAppointSMS',
}; // 获取图片
getCarImages: '/car/images'
}
export const RouteTable = { export const RouteTable = {
apiRoot: '/api/root', apiRoot: '/api/root',
fileUpload: '/_upload/new', fileUpload: '/_upload/new',
cleanUpUploadTrash: '/_upload/cleanup', cleanUpUploadTrash: '/_upload/cleanup',
}; }

1
web/package.json

@ -89,6 +89,7 @@
"react-color": "^2.19.3", "react-color": "^2.19.3",
"react-router-breadcrumbs-hoc": "^4.0.1", "react-router-breadcrumbs-hoc": "^4.0.1",
"react-sortable-hoc": "^2.0.0", "react-sortable-hoc": "^2.0.0",
"sequelize-automate-freesun": "^1.2.2",
"superagent": "^6.1.0", "superagent": "^6.1.0",
"swiper": "^8.3.1", "swiper": "^8.3.1",
"uuid": "^8.3.1", "uuid": "^8.3.1",

Loading…
Cancel
Save