diff --git a/api/app/lib/controllers/images/index.js b/api/app/lib/controllers/images/index.js new file mode 100644 index 00000000..bad53b91 --- /dev/null +++ b/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 +} \ No newline at end of file diff --git a/api/app/lib/models/car_images.js b/api/app/lib/models/car_images.js new file mode 100644 index 00000000..f14ba4cc --- /dev/null +++ b/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; +}; \ No newline at end of file diff --git a/api/app/lib/routes/images/index.js b/api/app/lib/routes/images/index.js new file mode 100644 index 00000000..2db06525 --- /dev/null +++ b/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)) + + +} \ No newline at end of file diff --git a/api/package.json b/api/package.json index 747055b6..f757ff54 100644 --- a/api/package.json +++ b/api/package.json @@ -36,6 +36,7 @@ "redis": "^3.1.2", "request": "^2.88.2", "rimraf": "^3.0.2", + "sequelize-automate-freesun": "^1.2.2", "superagent": "^3.5.2", "swagger-jsdoc": "^6.1.0", "uuid": "^3.3.2", diff --git a/api/sequelize-automate.config.js b/api/sequelize-automate.config.js index 00839eee..6fa0051b 100644 --- a/api/sequelize-automate.config.js +++ b/api/sequelize-automate.config.js @@ -35,7 +35,7 @@ module.exports = { dir: './app/lib/models', // 指定输出 models 文件的目录 typesDir: 'models', // 指定输出 TypeScript 类型定义的文件目录,只有 TypeScript / Midway 等会有类型定义 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,则忽略改属性 tsNoCheck: false, // 是否添加 `@ts-nocheck` 注释到 models 文件中 ignorePrefix: [], // 生成的模型名称忽略的前缀,因为 项目中有以下表名是以 t_ 开头的,在实际模型中不需要, 可以添加多个 [ 't_data_', 't_',] ,长度较长的 前缀放前面 diff --git a/scripts/1.4.2/1.create_car_images.sql b/scripts/1.4.2/1.create_car_images.sql new file mode 100644 index 00000000..516f1b0e --- /dev/null +++ b/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); + diff --git a/web/client/src/sections/fillion/actions/carimages.js b/web/client/src/sections/fillion/actions/carimages.js new file mode 100644 index 00000000..8e5001c5 --- /dev/null +++ b/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' } + }) +} \ No newline at end of file diff --git a/web/client/src/sections/fillion/containers/carimages.js b/web/client/src/sections/fillion/containers/carimages.js new file mode 100644 index 00000000..4e85fee9 --- /dev/null +++ b/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 ( +//