|
@@ -8,6 +8,16 @@ const { wrapApiData } = require(`./util.js`)
|
|
*/
|
|
*/
|
|
module.exports = async (util) => {
|
|
module.exports = async (util) => {
|
|
const joi = await util.tool.generate.initPackge(`joi`)
|
|
const joi = await util.tool.generate.initPackge(`joi`)
|
|
|
|
+ util.libObj.mockjs.Random.extend({
|
|
|
|
+ image2: function () {
|
|
|
|
+ return this.pick(
|
|
|
|
+ `https://dummyimage.com/${this.integer(100, 1000)}x${this.integer(
|
|
|
|
+ 100,
|
|
|
|
+ 1000
|
|
|
|
+ )}/${this.hex()}/${this.hex()}.jpg`.replace(/#/g, ``)
|
|
|
|
+ )
|
|
|
|
+ },
|
|
|
|
+ })
|
|
return {
|
|
return {
|
|
plugin: [util.plugin.validate, util.plugin.apiDoc],
|
|
plugin: [util.plugin.validate, util.plugin.apiDoc],
|
|
guard: false,
|
|
guard: false,
|
|
@@ -18,7 +28,6 @@ module.exports = async (util) => {
|
|
proxy: {
|
|
proxy: {
|
|
'/': `http://www.httpbin.org/`, // 后端接口主域
|
|
'/': `http://www.httpbin.org/`, // 后端接口主域
|
|
'/anything/intercept': [`origin`, `127.0.0.1`], // 修改接口返回的数据
|
|
'/anything/intercept': [`origin`, `127.0.0.1`], // 修改接口返回的数据
|
|
- '/datav/': `https://geo.datav.aliyun.com/`, // 修改接口返回的数据
|
|
|
|
},
|
|
},
|
|
api: {
|
|
api: {
|
|
// 在其他文件里的 api
|
|
// 在其他文件里的 api
|
|
@@ -40,6 +49,25 @@ module.exports = async (util) => {
|
|
)
|
|
)
|
|
},
|
|
},
|
|
}),
|
|
}),
|
|
|
|
+ 'get /api/mapOfTongren': util.side({
|
|
|
|
+ tags: [`公用`],
|
|
|
|
+ summary: `铜仁地图数据`,
|
|
|
|
+ async action(req, res) {
|
|
|
|
+ const data = await util.libObj.axios
|
|
|
|
+ .get(
|
|
|
|
+ `https://geo.datav.aliyun.com/areas_v3/bound/geojson?code=520600_full`
|
|
|
|
+ )
|
|
|
|
+ .then((res) => res.data)
|
|
|
|
+ console.log(`data`, data)
|
|
|
|
+ res.json(
|
|
|
|
+ wrapApiData(
|
|
|
|
+ util.libObj.mockjs.mock({
|
|
|
|
+ data,
|
|
|
|
+ })
|
|
|
|
+ )
|
|
|
|
+ )
|
|
|
|
+ },
|
|
|
|
+ }),
|
|
'get /api/realTimeStatistics': util.side({
|
|
'get /api/realTimeStatistics': util.side({
|
|
tags: [`综合总览`],
|
|
tags: [`综合总览`],
|
|
summary: `实时统计`,
|
|
summary: `实时统计`,
|
|
@@ -194,6 +222,7 @@ module.exports = async (util) => {
|
|
.object({
|
|
.object({
|
|
q: joi.string().description(`模糊搜索`),
|
|
q: joi.string().description(`模糊搜索`),
|
|
})
|
|
})
|
|
|
|
+ .unknown(true)
|
|
.description(`搜索项`),
|
|
.description(`搜索项`),
|
|
},
|
|
},
|
|
async action(req, res, next) {
|
|
async action(req, res, next) {
|
|
@@ -338,17 +367,17 @@ module.exports = async (util) => {
|
|
{
|
|
{
|
|
'id|+1': 1,
|
|
'id|+1': 1,
|
|
名称: `@county()@ctitle()基地`,
|
|
名称: `@county()@ctitle()基地`,
|
|
- 温度: `@integer(0, 40)`,
|
|
|
|
|
|
+ 温度: [`@integer(0, 20)`, `@integer(20, 40)`],
|
|
|
|
+ 天气: `@pick(多云, 少云, 晴, 雨, 雪, 雾, 暴雨)`,
|
|
管理人员: `@cname`,
|
|
管理人员: `@cname`,
|
|
联系电话: `@phone`,
|
|
联系电话: `@phone`,
|
|
简介: `<p>@cparagraph()</p><p>@cparagraph()</p><p>@cparagraph()</p><p>@cparagraph()</p><p>@cparagraph()</p><p>@cparagraph()</p>`,
|
|
简介: `<p>@cparagraph()</p><p>@cparagraph()</p><p>@cparagraph()</p><p>@cparagraph()</p><p>@cparagraph()</p><p>@cparagraph()</p>`,
|
|
面积: `@integer(9e3, 9e4)`,
|
|
面积: `@integer(9e3, 9e4)`,
|
|
烟农数量: `@integer(10, 999)`,
|
|
烟农数量: `@integer(10, 999)`,
|
|
- 天气: `@pick(多云, 少云, 晴, 雨, 雪, 雾, 暴雨)`,
|
|
|
|
已种植: `@integer(9, 9e4)`,
|
|
已种植: `@integer(9, 9e4)`,
|
|
未种植: `@integer(9, 9e4)`,
|
|
未种植: `@integer(9, 9e4)`,
|
|
地址: `@county()@ctitle()`,
|
|
地址: `@county()@ctitle()`,
|
|
- '图片|1-5': [`@image`],
|
|
|
|
|
|
+ '图片|3-5': [`@image2()`],
|
|
完成率() {
|
|
完成率() {
|
|
return (this.已种植 / (this.已种植 + this.未种植)) * 100
|
|
return (this.已种植 / (this.已种植 + this.未种植)) * 100
|
|
},
|
|
},
|
|
@@ -362,11 +391,8 @@ module.exports = async (util) => {
|
|
ip: `@ip`,
|
|
ip: `@ip`,
|
|
投入时间: `@date`,
|
|
投入时间: `@date`,
|
|
联系电话: `@phone`,
|
|
联系电话: `@phone`,
|
|
- '图片|1-5': [`@image`],
|
|
|
|
- 状态: `@pick(运行中, 待机, 故障)`,
|
|
|
|
- 完成率() {
|
|
|
|
- return (this.已种植 / (this.已种植 + this.未种植)) * 100
|
|
|
|
- },
|
|
|
|
|
|
+ '图片|1-5': [`@image2()`],
|
|
|
|
+ 状态: `@pick(运行中, 关机, 故障)`,
|
|
},
|
|
},
|
|
],
|
|
],
|
|
}),
|
|
}),
|