增加店铺的审核功能
This commit is contained in:
parent
b2cacee61b
commit
7ab55c8556
@ -81,6 +81,19 @@ class ShopController extends BaseController {
|
||||
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'])
|
||||
@router('post /shop/:id/delete')
|
||||
async delete(req: any) {
|
||||
|
@ -63,6 +63,9 @@ class ShopClass extends BaseModule {
|
||||
|
||||
@prop({ type: () => [Number] })
|
||||
public location: number[]
|
||||
|
||||
@prop({default: false})
|
||||
public publish: boolean
|
||||
/**
|
||||
* 是否删除
|
||||
* @type {boolean}
|
||||
@ -120,8 +123,8 @@ class ShopClass extends BaseModule {
|
||||
|
||||
|
||||
public static parseQueryParam(params) {
|
||||
let {key, timeBegin, timeEnd} = params
|
||||
let opt: any = {deleted: false, show: true}
|
||||
let {key, timeBegin, timeEnd, publish} = params
|
||||
let opt: any = {deleted: false, show: true, publish: true}
|
||||
if (key) {
|
||||
opt.name = {$regex: key, $options: 'i'}
|
||||
}
|
||||
@ -132,6 +135,19 @@ class ShopClass extends BaseModule {
|
||||
} else if (!timeBegin && 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}
|
||||
return { opt, sort }
|
||||
|
Loading…
x
Reference in New Issue
Block a user