|
@@ -31,22 +31,26 @@ class index_path(Load):
|
|
@apiSuccess {String} page.totalNum 总数据条数
|
|
@apiSuccess {String} page.totalNum 总数据条数
|
|
|
|
|
|
@apiErrorExample 操作成功
|
|
@apiErrorExample 操作成功
|
|
- {"status": 1, "msg": "yes", "code": 0, "data": {"setting": {"farm": 1, "user": 0, "name": "\u519c\u5c0f\u76d2", "copyright": "2017 nongxiaohe.com v1.0.0", "site": "http://www.nongxiaohe.com/"}, "list": [{"pic": "http://192.168.15.10:8087/upload/2017/08/30/455f9d6c26b5c989b32eda1809e58d5f.jpg", "method_id": null, "land_id": "249be20d-5759-5af0-9859-b770d9f44e2a", "farm_id": 1, "state": true, "amount": "100ml", "workdate": 1504105397, "category_id": "9365ea66-be55-56f7-a511-059fc85a9478", "cdate": 1504076614, "id": "19e05f00-ae55-5605-be12-86dcd2866df9"}], "page": {"current": 1, "ajax": false, "total": 1.0, "num": 15, "totalNum": 1}}}
|
|
|
|
|
|
+
|
|
|
|
+ {"status": 1, "msg": "yes", "code": 0, "data": {"setting": {"farm": 1, "user": "229cfd36-9399-5599-b2b5-c53174c3de19", "name": "\u519c\u5c0f\u76d2", "copyright": "2017 nongxiaohe.com v1.0.0", "site": "http://www.nongxiaohe.com/"}, "list": [{"category": "\u7528\u836f", "workdates": "2017-10-11", "pic": "http://www.xinnongbaohe.com:8087/upload/2017/10/10/36083979c0984547320137e5f01f7e52.jpg", "name": "2017-10-11 - \u5730\u57572\u53f7/\u7528\u836f", "land_id": "6b18f8b5-c9e5-5600-8808-dad30fa4ea93", "farm_id": 1, "state": true, "content": "22222", "amount": "30L222", "workdate": 1507680000, "category_id": "fcd8899a-a3a5-52ee-a2a8-2d5c30160044", "cdate": 1509347365, "id": "ee57691d-d4e7-533c-9111-3fc059120a7b", "land": "\u5730\u57572\u53f7"}], "page": {"current": 1, "ajax": false, "total": 1, "num": 15, "totalNum": 1}, "base": {}}}
|
|
@apiErrorExample 操作失败
|
|
@apiErrorExample 操作失败
|
|
{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
|
|
{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
|
|
"""
|
|
"""
|
|
@auth
|
|
@auth
|
|
@Web.setting
|
|
@Web.setting
|
|
def get(self):
|
|
def get(self):
|
|
- self.data['list'] = self.service('common').list('farm_work', state=True, page=True)
|
|
|
|
|
|
+ self.data['list'] = self.service('common').list('farm_work', state=True)
|
|
if self.data['list']:
|
|
if self.data['list']:
|
|
for key, value in enumerate(self.data['list']):
|
|
for key, value in enumerate(self.data['list']):
|
|
self.data['list'][key]['workdates'] = Demeter.date(value['workdate'], '%Y-%m-%d')
|
|
self.data['list'][key]['workdates'] = Demeter.date(value['workdate'], '%Y-%m-%d')
|
|
category = self.service('common').one('farm_work_category', id=value['category_id'])
|
|
category = self.service('common').one('farm_work_category', id=value['category_id'])
|
|
self.data['list'][key]['category'] = category['name']
|
|
self.data['list'][key]['category'] = category['name']
|
|
land = self.service('common').one('farm_work_land', id=value['land_id'])
|
|
land = self.service('common').one('farm_work_land', id=value['land_id'])
|
|
- self.data['list'][key]['land'] = land['name']
|
|
|
|
- self.data['list'][key]['name'] = self.data['list'][key]['workdates'] + ' - ' + land['name'] + '/' + category['name']
|
|
|
|
|
|
+ if land:
|
|
|
|
+ self.data['list'][key]['land'] = land['name']
|
|
|
|
+ self.data['list'][key]['name'] = self.data['list'][key]['workdates'] + ' - ' + land['name'] + '/' + category['name']
|
|
|
|
+ else:
|
|
|
|
+ self.data['list'][key]['name'] = self.data['list'][key]['workdates'] + '/' + category['name']
|
|
self.out('yes', self.data)
|
|
self.out('yes', self.data)
|
|
|
|
|
|
"""
|
|
"""
|
|
@@ -76,20 +80,17 @@ class index_path(Load):
|
|
@Web.setting
|
|
@Web.setting
|
|
def post(self):
|
|
def post(self):
|
|
id = self.input('id', None)
|
|
id = self.input('id', None)
|
|
- if not id:
|
|
|
|
- self.out('no')
|
|
|
|
- return
|
|
|
|
update = {}
|
|
update = {}
|
|
update['pic'] = self.input('update_pic')
|
|
update['pic'] = self.input('update_pic')
|
|
- update['category'] = self.input('update_category')
|
|
|
|
- update['land'] = self.input('update_land')
|
|
|
|
|
|
+ update['category_id'] = self.input('update_category')
|
|
|
|
+ update['land_id'] = self.input('update_land')
|
|
update['workdate'] = self.input('update_workdate')
|
|
update['workdate'] = self.input('update_workdate')
|
|
update['content'] = self.input('update_content')
|
|
update['content'] = self.input('update_content')
|
|
update['amount'] = self.input('update_amount')
|
|
update['amount'] = self.input('update_amount')
|
|
- if not update['category']:
|
|
|
|
|
|
+ if not update['category_id']:
|
|
self.out(u'请选择农事方式')
|
|
self.out(u'请选择农事方式')
|
|
return
|
|
return
|
|
- if not update['land']:
|
|
|
|
|
|
+ if not update['land_id']:
|
|
self.out(u'请选择地块')
|
|
self.out(u'请选择地块')
|
|
return
|
|
return
|
|
if not update['workdate']:
|
|
if not update['workdate']:
|
|
@@ -101,7 +102,7 @@ class index_path(Load):
|
|
if not update['amount']:
|
|
if not update['amount']:
|
|
self.out(u'请输入劳作数量')
|
|
self.out(u'请输入劳作数量')
|
|
return
|
|
return
|
|
- update['workdate'] = Demeter.mktime(update['workdate'], '%Y-%m-%d')
|
|
|
|
|
|
+ #update['workdate'] = Demeter.mktime(update['workdate'], '%Y-%m-%d')
|
|
state = self.service('common').update('farm_work', id, update)
|
|
state = self.service('common').update('farm_work', id, update)
|
|
self.out('yes', {'id':state})
|
|
self.out('yes', {'id':state})
|
|
|
|
|
|
@@ -109,9 +110,11 @@ class info_path(Load):
|
|
"""
|
|
"""
|
|
@api {get} /work/info 获取农事信息
|
|
@api {get} /work/info 获取农事信息
|
|
@apiVersion 1.0.0
|
|
@apiVersion 1.0.0
|
|
- @apiName getWork
|
|
|
|
|
|
+ @apiName getWorkInfo
|
|
@apiGroup Farm
|
|
@apiGroup Farm
|
|
|
|
|
|
|
|
+ @apiParam {String} id 农事ID
|
|
|
|
+
|
|
@apiSuccess {Object[]} setting 基本信息
|
|
@apiSuccess {Object[]} setting 基本信息
|
|
@apiSuccess {String} setting.name 站点名
|
|
@apiSuccess {String} setting.name 站点名
|
|
@apiSuccess {Number} setting.farm 当前的农场ID
|
|
@apiSuccess {Number} setting.farm 当前的农场ID
|
|
@@ -129,7 +132,7 @@ class info_path(Load):
|
|
def get(self):
|
|
def get(self):
|
|
id = self.input('id', None)
|
|
id = self.input('id', None)
|
|
if id:
|
|
if id:
|
|
- self.data['info'] = self.service('common').one('farm_work', {id:id})
|
|
|
|
|
|
+ self.data['info'] = self.service('common').one('farm_work', id=id)
|
|
if self.data['info']:
|
|
if self.data['info']:
|
|
self.data['info']['workdates'] = Demeter.date(self.data['info']['workdate'], '%Y-%m-%d')
|
|
self.data['info']['workdates'] = Demeter.date(self.data['info']['workdate'], '%Y-%m-%d')
|
|
|
|
|
|
@@ -152,7 +155,7 @@ class land_path(Load):
|
|
@apiSuccess {String} list.name 名称
|
|
@apiSuccess {String} list.name 名称
|
|
@apiSuccess {String} list.id ID
|
|
@apiSuccess {String} list.id ID
|
|
@apiErrorExample 操作成功
|
|
@apiErrorExample 操作成功
|
|
- {"status": 1, "msg": "yes", "code": 0, "data": {"setting": {"farm": 1, "user": 0, "name": "\u519c\u5c0f\u76d2", "copyright": "2017 nongxiaohe.com v1.0.0", "site": "http://www.nongxiaohe.com/"}, "list": [{"state": true, "farm_id": 1, "cdate": 1504074548, "id": "249be20d-5759-5af0-9859-b770d9f44e2a", "name": "test"}]}}
|
|
|
|
|
|
+ {"status": 1, "msg": "yes", "code": 0, "data": {"setting": {"farm": 1, "user": "229cfd36-9399-5599-b2b5-c53174c3de19", "name": "\u519c\u5c0f\u76d2", "copyright": "2017 nongxiaohe.com v1.0.0", "site": "http://www.nongxiaohe.com/"}, "list": [{"state": true, "farm_id": 1, "cdate": 1509344166, "id": "6b18f8b5-c9e5-5600-8808-dad30fa4ea93", "name": "\u5730\u57572\u53f7"}, {"state": true, "farm_id": 1, "cdate": 1509344164, "id": "17b881d4-ea79-5968-8328-4d7587cf3e39", "name": "\u5730\u57571\u53f7"}], "base": {}}}
|
|
@apiErrorExample 操作失败
|
|
@apiErrorExample 操作失败
|
|
{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
|
|
{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
|
|
"""
|
|
"""
|
|
@@ -192,6 +195,98 @@ class land_path(Load):
|
|
state = self.service('common').update('farm_work_land', id, update)
|
|
state = self.service('common').update('farm_work_land', id, update)
|
|
self.out('yes', {'id':state})
|
|
self.out('yes', {'id':state})
|
|
|
|
|
|
|
|
+ """
|
|
|
|
+ @api {delete} /work/land 删除地块
|
|
|
|
+ @apiVersion 1.0.0
|
|
|
|
+ @apiName updateWorkLand
|
|
|
|
+ @apiGroup Farm
|
|
|
|
+
|
|
|
|
+ @apiParam {String} id 地块ID,为空则插入新记录
|
|
|
|
+
|
|
|
|
+ @apiSuccess {Bool} status 状态
|
|
|
|
+ @apiSuccess {String} msg 描述
|
|
|
|
+ @apiSuccess {Number} code 状态码
|
|
|
|
+
|
|
|
|
+ @apiErrorExample 操作成功
|
|
|
|
+ {"status": 1, "msg": "操作成功", "code": 0, "data": {}}
|
|
|
|
+ @apiErrorExample 操作失败
|
|
|
|
+ {"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
|
|
|
|
+ """
|
|
|
|
+ @auth
|
|
|
|
+ @Web.setting
|
|
|
|
+ def delete(self):
|
|
|
|
+ id = self.input('id')
|
|
|
|
+ if id:
|
|
|
|
+ model = Demeter.model('farm_work_land')
|
|
|
|
+ model.id = id
|
|
|
|
+ model.delete()
|
|
|
|
+ self.out('yes', {'id':id})
|
|
|
|
+
|
|
|
|
+class land_pic_path(Load):
|
|
|
|
+ """
|
|
|
|
+ @api {get} /work/land_pic 获取农事地块图片列表
|
|
|
|
+ @apiVersion 1.0.0
|
|
|
|
+ @apiName getWorkLandPicList
|
|
|
|
+ @apiGroup Farm
|
|
|
|
+
|
|
|
|
+ @apiSuccess {Object[]} setting 基本信息
|
|
|
|
+ @apiSuccess {String} setting.name 站点名
|
|
|
|
+ @apiSuccess {Number} setting.farm 当前的农场ID
|
|
|
|
+
|
|
|
|
+ @apiSuccess {Object[]} list 地块列表信息
|
|
|
|
+ @apiSuccess {String} list.name 名称
|
|
|
|
+ @apiSuccess {String} list.id ID
|
|
|
|
+ @apiSuccess {Object[]} list.pic 图片
|
|
|
|
+
|
|
|
|
+ @apiErrorExample 操作成功
|
|
|
|
+ {"status": 1, "msg": "yes", "code": 0, "data": {"setting": {"farm": 1, "user": "229cfd36-9399-5599-b2b5-c53174c3de19", "name": "\u519c\u5c0f\u76d2", "copyright": "2017 nongxiaohe.com v1.0.0", "site": "http://www.nongxiaohe.com/"}, "list": [{"farm_id": 1, "name": "222", "pic": [{"pic": "http://192.168.15.10:8088/upload/2017/11/01/a7164193b56a074d72e4f94e4a4d145c.jpg", "land_id": "d508f554-db86-52dc-ba20-fbb476c60abc", "farm_id": 1, "state": true, "cdate": 1509519631, "id": "0d11d5ee-990e-52d5-ae55-09a212834f0d"}], "cdate": 1509519537, "state": true, "id": "d508f554-db86-52dc-ba20-fbb476c60abc"}, {"farm_id": 1, "name": "111", "pic": [], "cdate": 1509519533, "state": true, "id": "03679a19-f619-55d3-959c-bbc0a22dc072"}], "base": {}}}
|
|
|
|
+ @apiErrorExample 操作失败
|
|
|
|
+ {"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
|
|
|
|
+ """
|
|
|
|
+ @auth
|
|
|
|
+ @Web.setting
|
|
|
|
+ def get(self):
|
|
|
|
+ self.data['list'] = self.service('common').list('farm_work_land', state=True)
|
|
|
|
+ #self.data['list'] = self.service('common').list('farm_work_land_pic', state=True)
|
|
|
|
+ if self.data['list']:
|
|
|
|
+ for key, value in enumerate(self.data['list']):
|
|
|
|
+ self.data['list'][key]['pic'] = self.service('common').list('farm_work_land_pic', search={'land_id':value['id']}, state=True)
|
|
|
|
+ self.out('yes', self.data)
|
|
|
|
+
|
|
|
|
+ """
|
|
|
|
+ @api {post} /work/land_pic 更新地块图片
|
|
|
|
+ @apiVersion 1.0.0
|
|
|
|
+ @apiName updateWorkLandPic
|
|
|
|
+ @apiGroup Farm
|
|
|
|
+
|
|
|
|
+ @apiParam {String} update_land_id 地块ID,为空则插入新记录
|
|
|
|
+ @apiParam {String} update_pic 地块图片地址
|
|
|
|
+
|
|
|
|
+ @apiSuccess {Bool} status 状态
|
|
|
|
+ @apiSuccess {String} msg 描述
|
|
|
|
+ @apiSuccess {Number} code 状态码
|
|
|
|
+
|
|
|
|
+ @apiErrorExample 操作成功
|
|
|
|
+ {"status": 1, "msg": "操作成功", "code": 0, "data": {}}
|
|
|
|
+ @apiErrorExample 操作失败
|
|
|
|
+ {"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
|
|
|
|
+ """
|
|
|
|
+ @auth
|
|
|
|
+ @Web.setting
|
|
|
|
+ def post(self):
|
|
|
|
+ id = self.input('id', None)
|
|
|
|
+ update = {}
|
|
|
|
+ update['land_id'] = self.input('update_land_id')
|
|
|
|
+ update['pic'] = self.input('update_pic')
|
|
|
|
+ if not update['land_id']:
|
|
|
|
+ self.out(u'请选择地块')
|
|
|
|
+ return
|
|
|
|
+ if not update['pic']:
|
|
|
|
+ self.out(u'请上传地块图片')
|
|
|
|
+ return
|
|
|
|
+ state = self.service('common').update('farm_work_land_pic', id, update)
|
|
|
|
+ self.out('yes', {'id':state})
|
|
|
|
+
|
|
class category_path(Load):
|
|
class category_path(Load):
|
|
"""
|
|
"""
|
|
@api {get} /work/category 获取农事分类列表
|
|
@api {get} /work/category 获取农事分类列表
|
|
@@ -207,7 +302,7 @@ class category_path(Load):
|
|
@apiSuccess {String} list.name 名称
|
|
@apiSuccess {String} list.name 名称
|
|
@apiSuccess {String} list.id ID
|
|
@apiSuccess {String} list.id ID
|
|
@apiErrorExample 操作成功
|
|
@apiErrorExample 操作成功
|
|
- {"status": 1, "msg": "yes", "code": 0, "data": {"setting": {"farm": 1, "user": 0, "name": "\u519c\u5c0f\u76d2", "copyright": "2017 nongxiaohe.com v1.0.0", "site": "http://www.nongxiaohe.com/"}, "list": [{"state": true, "farm_id": 1, "cdate": 1504074837, "id": "9365ea66-be55-56f7-a511-059fc85a9478", "name": "\u65bd\u80a5"}]}}
|
|
|
|
|
|
+ {"status": 1, "msg": "yes", "code": 0, "data": {"setting": {"farm": 1, "user": "229cfd36-9399-5599-b2b5-c53174c3de19", "name": "\u519c\u5c0f\u76d2", "copyright": "2017 nongxiaohe.com v1.0.0", "site": "http://www.nongxiaohe.com/"}, "list": [{"state": true, "farm_id": 1, "cdate": 1509344125, "id": "fcd8899a-a3a5-52ee-a2a8-2d5c30160044", "name": "\u7528\u836f"}, {"state": true, "farm_id": 1, "cdate": 1509344107, "id": "6f955928-9724-5cb7-acd0-a81d482d9883", "name": "\u65bd\u80a5"}], "base": {}}}
|
|
@apiErrorExample 操作失败
|
|
@apiErrorExample 操作失败
|
|
{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
|
|
{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
|
|
"""
|
|
"""
|
|
@@ -215,4 +310,34 @@ class category_path(Load):
|
|
@Web.setting
|
|
@Web.setting
|
|
def get(self):
|
|
def get(self):
|
|
self.data['list'] = self.service('common').list('farm_work_category', state=True)
|
|
self.data['list'] = self.service('common').list('farm_work_category', state=True)
|
|
- self.out('yes', self.data)
|
|
|
|
|
|
+ self.out('yes', self.data)
|
|
|
|
+
|
|
|
|
+ """
|
|
|
|
+ @api {post} /work/category 更新农事分类
|
|
|
|
+ @apiVersion 1.0.0
|
|
|
|
+ @apiName updateWorkCategory
|
|
|
|
+ @apiGroup Farm
|
|
|
|
+
|
|
|
|
+ @apiParam {String} id 分类ID,为空则插入新记录
|
|
|
|
+ @apiParam {String} update_name 分类名称
|
|
|
|
+
|
|
|
|
+ @apiSuccess {Bool} status 状态
|
|
|
|
+ @apiSuccess {String} msg 描述
|
|
|
|
+ @apiSuccess {Number} code 状态码
|
|
|
|
+
|
|
|
|
+ @apiErrorExample 操作成功
|
|
|
|
+ {"status": 1, "msg": "操作成功", "code": 0, "data": {}}
|
|
|
|
+ @apiErrorExample 操作失败
|
|
|
|
+ {"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
|
|
|
|
+ """
|
|
|
|
+ @auth
|
|
|
|
+ @Web.setting
|
|
|
|
+ def post(self):
|
|
|
|
+ id = self.input('id', None)
|
|
|
|
+ update = {}
|
|
|
|
+ update['name'] = self.input('update_name')
|
|
|
|
+ if not update['name']:
|
|
|
|
+ self.out(u'请输入分类名称')
|
|
|
|
+ return
|
|
|
|
+ state = self.service('common').update('farm_work_category', id, update)
|
|
|
|
+ self.out('yes', {'id':state})
|