|
@@ -8,6 +8,17 @@ 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, ``)
|
|
|
|
+ )
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+ console.log(`xxx`, util.libObj.mockjs.Random.image2())
|
|
return {
|
|
return {
|
|
plugin: [util.plugin.validate, util.plugin.apiDoc],
|
|
plugin: [util.plugin.validate, util.plugin.apiDoc],
|
|
guard: false,
|
|
guard: false,
|
|
@@ -194,6 +205,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 +350,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 +374,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(运行中, 关机, 故障)`,
|
|
},
|
|
},
|
|
],
|
|
],
|
|
}),
|
|
}),
|