Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions app/controller/catering/desk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
const Response = require('../../util/response')
const ServiceDesk = require('../../services/catering/desk')

module.exports = {
/**
* @api {get} /api/catering/v1/stores/:storeId/desks desk列表
* @apiGroup desk
* @apiPermission store
* @apiVersion 1.0.0
* @apiParam {String} param 参数
* @apiSuccess {String} data 返回数据
* @apiSuccessExample {json} Visual Preview:
* {
"success": true,
"code": 200,
"data": [
{
"id": 2,
"store_id": 1,
"name": "江边1",
"sort": 0,
"status": 1,
"created_at": "2018-07-12T06:50:27.000Z",
"updated_at": "2018-07-12T06:50:27.000Z"
}
],
"message": "请求成功"
}
*/
index: async function (ctx) {
let data = await ServiceDesk.list(ctx.params.storeId)

return Response.output(ctx, data)
},

/**
* @api {get} /api/catering/v1/stores/:storeId/desks/:deskId desk详情
* @apiGroup desk
* @apiPermission store
* @apiVersion 1.0.0
* @apiParam {String} param 参数
* @apiSuccess {String} data 返回数据
* @apiSuccessExample {json} Visual Preview:
* {
"success": true,
"code": 200,
"data": {
"id": 2,
"store_id": 1,
"name": "江边1",
"sort": 0,
"status": 1,
"created_at": "2018-07-12T06:50:27.000Z",
"updated_at": "2018-07-12T06:50:27.000Z"
},
"message": "请求成功"
}
*/
detail: async function (ctx) {
let data = await ServiceDesk.detail(ctx.params.storeId, ctx.params.deskId)

return Response.output(ctx, data)
},

/**
* @api {post} /api/catering/v1/stores/:storeId/desks 新增desk
* @apiGroup desk
* @apiPermission store
* @apiVersion 1.0.0
* @apiParam {String} param 参数
* @apiSuccess {String} data 返回数据
* @apiSuccessExample {json} Visual Preview:
* {
"success": true,
"code": 200,
"data": {
"store_id": "1",
"name": "江边1",
"id": 2
},
"message": "请求成功"
}
*/
add: async function (ctx) {
let result = await ServiceDesk.add(ctx.params.storeId, ctx.input)

return Response.output(ctx, result)
},

/**
* @api {put} /api/catering/v1/stores/:storeId/desks/:deskId 编辑desk
* @apiGroup desk
* @apiPermission store
* @apiVersion 1.0.0
*
* @apiParam {String} param 参数
* @apiSuccess {String} data 返回数据
*
* @apiSuccessExample {json} Visual Preview:
* {
"success": true,
"code": 200,
"data": {
"name": "haibian",
"status": 1
},
"message": "请求成功"
}
*/
edit: async function (ctx) {
let result = await ServiceDesk.edit(ctx.params.storeId, ctx.params.deskId, ctx.input)

return Response.output(ctx, result)
},

/**
* @api {delete} /api/catering/v1/stores/:storeId/desks/:deskId 删除desk
* @apiGroup desk
* @apiPermission store
* @apiVersion 1.0.0
* @apiSuccessExample {json} Visual Preview:
* {
"success": true,
"code": 200,
"message": "请求成功",
"data": {}
}
*/
delete: async function (ctx) {
let data = {
status: -1
}
let result = await ServiceDesk.edit(ctx.params.storeId, ctx.params.deskId, data)
return Response.output(ctx)
},

}
179 changes: 179 additions & 0 deletions app/controller/catering/product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
const Response = require('../../util/response')
const ServiceProduct = require('../../services/catering/product')

module.exports = {
/**
* @api {get} /api/catering/v1/stores/:storeId/products product列表
* @apiGroup product
* @apiPermission store
* @apiVersion 1.0.0
* @apiParam {String} param 参数
* @apiSuccess {String} data 返回数据
* @apiSuccessExample {json} Visual Preview:
* {
"success": true,
"code": 200,
"data": [
{
"id": 1,
"store_id": 1,
"title": "123",
"thumb": "products/1/sda",
"description": "ddd",
"price": 5,
"online_time": "2018-07-12T07:04:42.000Z",
"sort": 0,
"set_top": 0,
"product_type_id": 0,
"status": 1,
"approved_id": 1,
"viewed": 0,
"sales_volume": 0,
"created_at": "2018-07-12T07:04:42.000Z",
"updated_at": "2018-07-12T07:06:51.000Z"
},
{
"id": 2,
"store_id": 1,
"title": "炒螺",
"thumb": "products/1/sda",
"description": "ddd",
"price": 15,
"online_time": "2018-07-12T07:06:57.000Z",
"sort": 0,
"set_top": 0,
"product_type_id": 0,
"status": 0,
"approved_id": 1,
"viewed": 0,
"sales_volume": 0,
"created_at": "2018-07-12T07:06:57.000Z",
"updated_at": "2018-07-12T07:06:57.000Z"
}
],
"message": "请求成功"
}
*/
index: async function (ctx) {
let data = await ServiceProduct.list(ctx.params.storeId)

return Response.output(ctx, data)
},

/**
* @api {get} /api/catering/v1/stores/:storeId/products/:productId product详情
* @apiGroup product
* @apiPermission store
* @apiVersion 1.0.0
* @apiParam {String} param 参数
* @apiSuccess {String} data 返回数据
* @apiSuccessExample {json} Visual Preview:
* {
"success": true,
"code": 200,
"data": {
"id": 1,
"store_id": 1,
"title": "炒螺",
"thumb": "products/1/sda",
"description": "ddd",
"price": 5,
"online_time": "2018-07-12T07:04:42.000Z",
"sort": 0,
"set_top": 0,
"product_type_id": 0,
"status": 0,
"approved_id": 1,
"viewed": 0,
"sales_volume": 0,
"created_at": "2018-07-12T07:04:42.000Z",
"updated_at": "2018-07-12T07:04:42.000Z"
},
"message": "请求成功"
}
*/
detail: async function (ctx) {
let data = await ServiceProduct.detail(ctx.params.storeId, ctx.params.productId)

return Response.output(ctx, data)
},

/**
* @api {post} /api/catering/v1/stores/:storeId/products 新增product
* @apiGroup product
* @apiPermission store
* @apiVersion 1.0.0
* @apiParam {String} param 参数
* @apiSuccess {String} data 返回数据
* @apiSuccessExample {json} Visual Preview:
* {
"success": true,
"code": 200,
"data": {
"title": "炒螺",
"thumb": "products/1/sda",
"description": "ddd",
"price": "15",
"store_id": "1",
"id": 2
},
"message": "请求成功"
}
*/
add: async function (ctx) {
let result = await ServiceProduct.add(ctx.params.storeId, ctx.input)

return Response.output(ctx, result)
},

/**
* @api {put} /api/catering/v1/stores/:storeId/products/:productId 编辑product
* @apiGroup product
* @apiPermission store
* @apiVersion 1.0.0
*
* @apiParam {String} param 参数
* @apiSuccess {String} data 返回数据
*
* @apiSuccessExample {json} Visual Preview:
* {
"success": true,
"code": 200,
"data": {
"title": "123",
"thumb": "products/1/sda",
"description": "ddd",
"price": 5,
"status": "1"
},
"message": "请求成功"
}
*/
edit: async function (ctx) {
let result = await ServiceProduct.edit(ctx.params.storeId, ctx.params.productId, ctx.input)

return Response.output(ctx, result)
},

/**
* @api {delete} /api/catering/v1/stores/:storeId/products/:productId 删除product
* @apiGroup product
* @apiPermission store
* @apiVersion 1.0.0
* @apiSuccessExample {json} Visual Preview:
* {
"success": true,
"code": 200,
"message": "请求成功",
"data": {}
}
*/
delete: async function (ctx) {
let data = {
status: -1
}
let result = await ServiceProduct.edit(ctx.params.storeId, ctx.params.productId, data)
return Response.output(ctx)
},

}
43 changes: 43 additions & 0 deletions app/model/catering/desk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const DB = require('../../libraries/db')
const ModelBase = require('../../model/base')

const table = 'mist_desk'

module.exports = {
add: async function (data) {
let res = await ModelBase.execInsert(table, data)
return res;
},

list: async function (storeId) {

let result = DB.readMysql.select(
'*'
)
.from(table)
.where('store_id', storeId)
.where('status', '!=', -1)

return await result

},

first: async function (id) {

let result = DB.readMysql.first(
'*'
)
.from(table)
.where('id', id)

return await result

},

edit: async function (data, where, notWhere = {}) {
let result = await ModelBase.execUpdate(table, data, where, notWhere)

return await result
}

}
Loading