增加店铺的审核功能
This commit is contained in:
parent
b2cacee61b
commit
7ab55c8556
@ -81,6 +81,19 @@ class ShopController extends BaseController {
|
|||||||
return record.toJson()
|
return record.toJson()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@permission(['shopman:review'])
|
||||||
|
@router('post /shop/publish')
|
||||||
|
async publish(req: any) {
|
||||||
|
let { id, publish } = req.params
|
||||||
|
let record = await Shop.findById(id)
|
||||||
|
if (!record) {
|
||||||
|
throw new ZError(11, 'record not found')
|
||||||
|
}
|
||||||
|
record.publish = publish
|
||||||
|
await record.save()
|
||||||
|
return record.toJson()
|
||||||
|
}
|
||||||
|
|
||||||
@permission(['shop:delete','shopman:delete'])
|
@permission(['shop:delete','shopman:delete'])
|
||||||
@router('post /shop/:id/delete')
|
@router('post /shop/:id/delete')
|
||||||
async delete(req: any) {
|
async delete(req: any) {
|
||||||
|
@ -63,6 +63,9 @@ class ShopClass extends BaseModule {
|
|||||||
|
|
||||||
@prop({ type: () => [Number] })
|
@prop({ type: () => [Number] })
|
||||||
public location: number[]
|
public location: number[]
|
||||||
|
|
||||||
|
@prop({default: false})
|
||||||
|
public publish: boolean
|
||||||
/**
|
/**
|
||||||
* 是否删除
|
* 是否删除
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
@ -120,8 +123,8 @@ class ShopClass extends BaseModule {
|
|||||||
|
|
||||||
|
|
||||||
public static parseQueryParam(params) {
|
public static parseQueryParam(params) {
|
||||||
let {key, timeBegin, timeEnd} = params
|
let {key, timeBegin, timeEnd, publish} = params
|
||||||
let opt: any = {deleted: false, show: true}
|
let opt: any = {deleted: false, show: true, publish: true}
|
||||||
if (key) {
|
if (key) {
|
||||||
opt.name = {$regex: key, $options: 'i'}
|
opt.name = {$regex: key, $options: 'i'}
|
||||||
}
|
}
|
||||||
@ -132,6 +135,19 @@ class ShopClass extends BaseModule {
|
|||||||
} else if (!timeBegin && timeEnd) {
|
} else if (!timeBegin && timeEnd) {
|
||||||
opt.createdAt = {$lte: timeEnd};
|
opt.createdAt = {$lte: timeEnd};
|
||||||
}
|
}
|
||||||
|
if (publish !== undefined) {
|
||||||
|
if (typeof publish === 'boolean') {
|
||||||
|
opt.publish = publish
|
||||||
|
} else {
|
||||||
|
if (publish === 'all') {
|
||||||
|
delete opt.publish
|
||||||
|
} else if (publish === 'true') {
|
||||||
|
opt.publish = true
|
||||||
|
} else if (publish === 'false') {
|
||||||
|
opt.publish = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let sort = {_id: -1}
|
let sort = {_id: -1}
|
||||||
return { opt, sort }
|
return { opt, sort }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user