提交 55ea9bef 编写于 作者: nengyuangzhang's avatar nengyuangzhang

Merge branch 'develop'

......@@ -17,24 +17,24 @@ app.factory('MicrogridArchitectureTypeService', function($http) {
callback(response);
});
},
addMicrogridArchitectureType: function(store_type, headers, callback) {
$http.post(getAPI()+'microgridarchitecturetypes',{data:store}, {headers})
addMicrogridArchitectureType: function(microgrid_architecture_type, headers, callback) {
$http.post(getAPI()+'microgridarchitecturetypes',{data:microgrid_architecture_type}, {headers})
.then(function (response) {
callback(response);
}, function (response) {
callback(response);
});
},
editMicrogridArchitectureType: function(store_type, headers, callback) {
$http.put(getAPI()+'microgridarchitecturetypes/'+store_type.id,{data:store_type}, {headers})
editMicrogridArchitectureType: function(microgrid_architecture_type, headers, callback) {
$http.put(getAPI()+'microgridarchitecturetypes/'+microgrid_architecture_type.id,{data:microgrid_architecture_type}, {headers})
.then(function (response) {
callback(response);
}, function (response) {
callback(response);
});
},
deleteMicrogridArchitectureType: function(store_type, headers, callback) {
$http.delete(getAPI()+'microgridarchitecturetypes/'+store_type.id, {headers})
deleteMicrogridArchitectureType: function(microgrid_architecture_type, headers, callback) {
$http.delete(getAPI()+'microgridarchitecturetypes/'+microgrid_architecture_type.id, {headers})
.then(function (response) {
callback(response);
}, function (response) {
......
......@@ -17,24 +17,24 @@ app.factory('MicrogridOwnerTypeService', function($http) {
callback(response);
});
},
addMicrogridOwnerType: function(store_type, headers, callback) {
$http.post(getAPI()+'microgridownertypes',{data:store}, {headers})
addMicrogridOwnerType: function(microgrid_owner_type, headers, callback) {
$http.post(getAPI()+'microgridownertypes',{data:microgrid_owner_type}, {headers})
.then(function (response) {
callback(response);
}, function (response) {
callback(response);
});
},
editMicrogridOwnerType: function(store_type, headers, callback) {
$http.put(getAPI()+'microgridownertypes/'+store_type.id,{data:store_type}, {headers})
editMicrogridOwnerType: function(microgrid_owner_type, headers, callback) {
$http.put(getAPI()+'microgridownertypes/'+microgrid_owner_type.id,{data:microgrid_owner_type}, {headers})
.then(function (response) {
callback(response);
}, function (response) {
callback(response);
});
},
deleteMicrogridOwnerType: function(store_type, headers, callback) {
$http.delete(getAPI()+'microgridownertypes/'+store_type.id, {headers})
deleteMicrogridOwnerType: function(microgrid_owner_type, headers, callback) {
$http.delete(getAPI()+'microgridownertypes/'+microgrid_owner_type.id, {headers})
.then(function (response) {
callback(response);
}, function (response) {
......
......@@ -1011,14 +1011,12 @@ function config($translateProvider) {
MICROGRID_ARCHITECTURE_TYPE_NOT_FOUND: 'Microgrid Architecture Type Not Found',
MICROGRID_ARCHITECTURE_TYPE_SIMPLIFIED_CODE_IS_ALREADY_IN_USE: 'Microgrid Architecture Type Simplified Code Is Already In Use',
MICROGRID_ARCHITECTURE_TYPE_USED_IN_MICROGRID: 'Microgrid Architecture Type Used In Microgrid',
MICROGRID_ARCHITECTURE_TYPE_USED_IN_STORE: 'Microgrid Architecture Type Used In Store',
MICROGRID_NAME_IS_ALREADY_IN_USE: 'Microgrid Name Is Already In Use',
MICROGRID_NOT_FOUND: 'Microgrid Not Found',
MICROGRID_OWNER_TYPE_NAME_IS_ALREADY_IN_USE: 'Microgrid Owner Type Name Is Already In Use',
MICROGRID_OWNER_TYPE_NOT_FOUND: 'Microgrid Owner Type Not Found',
MICROGRID_OWNER_TYPE_SIMPLIFIED_CODE_IS_ALREADY_IN_USE: 'Microgrid Owner Type Simplified Code Is Already In Use',
MICROGRID_OWNER_TYPE_USED_IN_MICROGRID: 'Microgrid Owner Type Used In Store',
MICROGRID_OWNER_TYPE_USED_IN_STORE: 'Microgrid Owner Type Used In Store',
MICROGRID_OWNER_TYPE_USED_IN_MICROGRID: 'Microgrid Owner Type Used In Microgrid',
MICROGRID_SENSOR_RELATION_EXISTS: 'Microgrid Sensor Relation Exists',
MICROGRID_SENSOR_RELATION_NOT_FOUND: 'Microgrid Sensor Relation Not Found',
NEW_PASSWORD_LENGTH_CANNOT_EXCEED_100_CHARACTERS: 'New password length cannot exceed 100 characters',
......@@ -2193,14 +2191,12 @@ function config($translateProvider) {
MICROGRID_ARCHITECTURE_TYPE_NOT_FOUND: 'Microgrid Architecture Type Not Found',
MICROGRID_ARCHITECTURE_TYPE_SIMPLIFIED_CODE_IS_ALREADY_IN_USE: 'Microgrid Architecture Type Simplified Code Is Already In Use',
MICROGRID_ARCHITECTURE_TYPE_USED_IN_MICROGRID: 'Microgrid Architecture Type Used In Microgrid',
MICROGRID_ARCHITECTURE_TYPE_USED_IN_STORE: 'Microgrid Architecture Type Used In Store',
MICROGRID_NAME_IS_ALREADY_IN_USE: 'Microgrid Name Is Already In Use',
MICROGRID_NOT_FOUND: 'Microgrid Not Found',
MICROGRID_OWNER_TYPE_NAME_IS_ALREADY_IN_USE: 'Microgrid Owner Type Name Is Already In Use',
MICROGRID_OWNER_TYPE_NOT_FOUND: 'Microgrid Owner Type Not Found',
MICROGRID_OWNER_TYPE_SIMPLIFIED_CODE_IS_ALREADY_IN_USE: 'Microgrid Owner Type Simplified Code Is Already In Use',
MICROGRID_OWNER_TYPE_USED_IN_MICROGRID: 'Microgrid Owner Type Used In Store',
MICROGRID_OWNER_TYPE_USED_IN_STORE: 'Microgrid Owner Type Used In Store',
MICROGRID_OWNER_TYPE_USED_IN_MICROGRID: 'Microgrid Owner Type Used In Microgrid',
MICROGRID_SENSOR_RELATION_EXISTS: 'Microgrid Sensor Relation Exists',
MICROGRID_SENSOR_RELATION_NOT_FOUND: 'Microgrid Sensor Relation Not Found',
NEW_PASSWORD_LENGTH_CANNOT_EXCEED_100_CHARACTERS: 'New password length cannot exceed 100 characters',
......@@ -3349,14 +3345,12 @@ function config($translateProvider) {
MICROGRID_ARCHITECTURE_TYPE_NOT_FOUND: 'Microgrid Architecture Type Not Found',
MICROGRID_ARCHITECTURE_TYPE_SIMPLIFIED_CODE_IS_ALREADY_IN_USE: 'Microgrid Architecture Type Simplified Code Is Already In Use',
MICROGRID_ARCHITECTURE_TYPE_USED_IN_MICROGRID: 'Microgrid Architecture Type Used In Microgrid',
MICROGRID_ARCHITECTURE_TYPE_USED_IN_STORE: 'Microgrid Architecture Type Used In Store',
MICROGRID_NAME_IS_ALREADY_IN_USE: 'Microgrid Name Is Already In Use',
MICROGRID_NOT_FOUND: 'Microgrid Not Found',
MICROGRID_OWNER_TYPE_NAME_IS_ALREADY_IN_USE: 'Microgrid Owner Type Name Is Already In Use',
MICROGRID_OWNER_TYPE_NOT_FOUND: 'Microgrid Owner Type Not Found',
MICROGRID_OWNER_TYPE_SIMPLIFIED_CODE_IS_ALREADY_IN_USE: 'Microgrid Owner Type Simplified Code Is Already In Use',
MICROGRID_OWNER_TYPE_USED_IN_MICROGRID: 'Microgrid Owner Type Used In Store',
MICROGRID_OWNER_TYPE_USED_IN_STORE: 'Microgrid Owner Type Used In Store',
MICROGRID_OWNER_TYPE_USED_IN_MICROGRID: 'Microgrid Owner Type Used In Microgrid',
MICROGRID_SENSOR_RELATION_EXISTS: 'Microgrid Sensor Relation Exists',
MICROGRID_SENSOR_RELATION_NOT_FOUND: 'Microgrid Sensor Relation Not Found',
NEW_PASSWORD_LENGTH_CANNOT_EXCEED_100_CHARACTERS: 'New password length cannot exceed 100 characters',
......
......@@ -1202,7 +1202,7 @@
},
{
"key": "Token",
"value": "49338f0c8b985ac7bf9ee8d53c2bdf1d51d0ab98da6835bd6b8a814e1f703e308a703e9273e6376532f7f03e11bb92dcbe24f7fc99ef3c9b0d57c608b5f7ff04",
"value": "bdf165755fdd709153b2496a876f1382fc83808ba8cb63144359fadfe58c64fb0f318687052c342b882753a4d360fe2a75ac2928a71521ad59433d06f8d31643",
"type": "default"
}
],
......@@ -5055,6 +5055,274 @@
}
]
},
{
"name": "MicrogridArchitectureType",
"item": [
{
"name": "GET All Architecture Types",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{base_url}}/microgridarchitecturetypes",
"host": [
"{{base_url}}"
],
"path": [
"microgridarchitecturetypes"
]
}
},
"response": []
},
{
"name": "GET an Architecture Type by ID",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{base_url}}/microgridarchitecturetypes/1",
"host": [
"{{base_url}}"
],
"path": [
"microgridarchitecturetypes",
"1"
]
}
},
"response": []
},
{
"name": "POST Create New Architecture Type",
"request": {
"method": "POST",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "text"
},
{
"key": "Token",
"value": "11111aa4be0fc56698faeb6f634f66b3ffec7f69ea58f32826c38b456109d8174b9a4f8537d1ffe111b83ffadf7b96639314e47bb79fd3e9ce4c7694d5334885",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\"data\":{\"name\": \"Battery+PV+Load+Grid1\", \"description\":\"Battery+PV+Load+Grid\", \"simplified_code\":\"BPLG1\"}}"
},
"url": {
"raw": "{{base_url}}/microgridarchitecturetypes",
"host": [
"{{base_url}}"
],
"path": [
"microgridarchitecturetypes"
]
}
},
"response": []
},
{
"name": "PUT Update an Architecture Type",
"request": {
"method": "PUT",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "text"
},
{
"key": "Token",
"value": "11111aa4be0fc56698faeb6f634f66b3ffec7f69ea58f32826c38b456109d8174b9a4f8537d1ffe111b83ffadf7b96639314e47bb79fd3e9ce4c7694d5334885",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\"data\":{\"name\": \"Battery+PV+Load+Grid2\", \"description\":\"Battery+PV+Load+Grid\", \"simplified_code\":\"BPLG2\"}}"
},
"url": {
"raw": "{{base_url}}/microgridarchitecturetypes/4",
"host": [
"{{base_url}}"
],
"path": [
"microgridarchitecturetypes",
"4"
]
}
},
"response": []
},
{
"name": "DELETE an Architecture Type by ID",
"request": {
"method": "DELETE",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "text"
},
{
"key": "Token",
"value": "11111aa4be0fc56698faeb6f634f66b3ffec7f69ea58f32826c38b456109d8174b9a4f8537d1ffe111b83ffadf7b96639314e47bb79fd3e9ce4c7694d5334885",
"type": "text"
}
],
"url": {
"raw": "{{base_url}}/microgridarchitecturetypes/5",
"host": [
"{{base_url}}"
],
"path": [
"microgridarchitecturetypes",
"5"
]
}
},
"response": []
}
]
},
{
"name": "MicrogridOwnerType",
"item": [
{
"name": "GET All Microgrid Owner Types",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{base_url}}/microgridownertypes",
"host": [
"{{base_url}}"
],
"path": [
"microgridownertypes"
]
}
},
"response": []
},
{
"name": "GET a Microgrid Owner Type by ID",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{base_url}}/microgridownertypes/1",
"host": [
"{{base_url}}"
],
"path": [
"microgridownertypes",
"1"
]
}
},
"response": []
},
{
"name": "POST Create New Microgrid Owner Type",
"request": {
"method": "POST",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "text"
},
{
"key": "Token",
"value": "1111582b84e3973da97819e522e75d65005b053de2ddecc71d8adbc8d0b5a285c7f74d025f626c56cb1d9718a8b2083cb81e03f1c97ebccf440b10a25cf53a44",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\"data\":{\"name\": \"New Type\", \"description\":\"New Type\", \"simplified_code\":\"NT\"}}"
},
"url": {
"raw": "{{base_url}}/microgridownertypes",
"host": [
"{{base_url}}"
],
"path": [
"microgridownertypes"
]
}
},
"response": []
},
{
"name": "PUT Update a Microgrid Owner Type",
"request": {
"method": "PUT",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "text"
},
{
"key": "Token",
"value": "1111582b84e3973da97819e522e75d65005b053de2ddecc71d8adbc8d0b5a285c7f74d025f626c56cb1d9718a8b2083cb81e03f1c97ebccf440b10a25cf53a44",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\"data\":{\"name\": \"New Type2\", \"description\":\"New Type2\", \"simplified_code\":\"NT2\"}}"
},
"url": {
"raw": "{{base_url}}/microgridownertypes/4",
"host": [
"{{base_url}}"
],
"path": [
"microgridownertypes",
"4"
]
}
},
"response": []
},
{
"name": "DELETE a Microgrid Owner Type by ID",
"request": {
"method": "DELETE",
"header": [
{
"key": "User-UUID",
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
"type": "text"
},
{
"key": "Token",
"value": "1111582b84e3973da97819e522e75d65005b053de2ddecc71d8adbc8d0b5a285c7f74d025f626c56cb1d9718a8b2083cb81e03f1c97ebccf440b10a25cf53a44",
"type": "text"
}
],
"url": {
"raw": "{{base_url}}/microgridownertypes/4",
"host": [
"{{base_url}}"
],
"path": [
"microgridownertypes",
"4"
]
}
},
"response": []
}
]
},
{
"name": "Notification",
"item": [
......
......@@ -58,7 +58,7 @@ class MicrogridArchitectureTypeCollection:
not isinstance(new_values['data']['name'], str) or \
len(str.strip(new_values['data']['name'])) == 0:
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_microgrid_architecture_type_NAME')
description='API.INVALID_MICROGRID_ARCHITECTURE_TYPE_NAME')
name = str.strip(new_values['data']['name'])
......@@ -66,7 +66,7 @@ class MicrogridArchitectureTypeCollection:
not isinstance(new_values['data']['description'], str) or \
len(str.strip(new_values['data']['description'])) == 0:
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_microgrid_architecture_type_DESCRIPTION')
description='API.INVALID_MICROGRID_ARCHITECTURE_TYPE_DESCRIPTION')
description = str.strip(new_values['data']['description'])
......@@ -74,7 +74,7 @@ class MicrogridArchitectureTypeCollection:
not isinstance(new_values['data']['simplified_code'], str) or \
len(str.strip(new_values['data']['simplified_code'])) == 0:
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_microgrid_architecture_type_SIMPLIFIED_CODE')
description='API.INVALID_MICROGRID_ARCHITECTURE_TYPE_SIMPLIFIED_CODE')
simplified_code = str.strip(new_values['data']['simplified_code'])
......@@ -88,7 +88,7 @@ class MicrogridArchitectureTypeCollection:
cursor.close()
cnx.close()
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.microgrid_architecture_type_NAME_IS_ALREADY_IN_USE')
description='API.MICROGRID_ARCHITECTURE_TYPE_NAME_IS_ALREADY_IN_USE')
cursor.execute(" SELECT simplified_code "
" FROM tbl_microgrid_architecture_types "
......@@ -97,7 +97,7 @@ class MicrogridArchitectureTypeCollection:
cursor.close()
cnx.close()
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.microgrid_architecture_type_SIMPLIFIED_CODE_IS_ALREADY_IN_USE')
description='API.MICROGRID_ARCHITECTURE_TYPE_SIMPLIFIED_CODE_IS_ALREADY_IN_USE')
add_value = (" INSERT INTO tbl_microgrid_architecture_types "
" (name, uuid, description, simplified_code) "
......@@ -129,7 +129,7 @@ class MicrogridArchitectureTypeItem:
def on_get(req, resp, id_):
if not id_.isdigit() or int(id_) <= 0:
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_microgrid_architecture_type_ID')
description='API.INVALID_MICROGRID_ARCHITECTURE_TYPE_ID')
cnx = mysql.connector.connect(**config.myems_system_db)
cursor = cnx.cursor()
......@@ -174,15 +174,15 @@ class MicrogridArchitectureTypeItem:
description='API.MICROGRID_ARCHITECTURE_TYPE_NOT_FOUND')
cursor.execute(" SELECT id "
" FROM tbl_stores "
" WHERE microgrid_architecture_type_id = %s ", (id_,))
rows_stores = cursor.fetchall()
if rows_stores is not None and len(rows_stores) > 0:
" FROM tbl_microgrids "
" WHERE architecture_type_id = %s ", (id_,))
rows_microgrids = cursor.fetchall()
if rows_microgrids is not None and len(rows_microgrids) > 0:
cursor.close()
cnx.close()
raise falcon.HTTPError(status=falcon.HTTP_400,
title='API.BAD_REQUEST',
description='API.MICROGRID_ARCHITECTURE_TYPE_USED_IN_STORE')
description='API.MICROGRID_ARCHITECTURE_TYPE_USED_IN_MICROGRID')
cursor.execute(" DELETE FROM tbl_microgrid_architecture_types WHERE id = %s ", (id_,))
cnx.commit()
......
......@@ -174,15 +174,15 @@ class MicrogridOwnerTypeItem:
description='API.MICROGRID_OWNER_TYPE_NOT_FOUND')
cursor.execute(" SELECT id "
" FROM tbl_stores "
" WHERE microgrid_owner_type_id = %s ", (id_,))
rows_stores = cursor.fetchall()
if rows_stores is not None and len(rows_stores) > 0:
" FROM tbl_microgrids "
" WHERE owner_type_id = %s ", (id_,))
rows_microgrids = cursor.fetchall()
if rows_microgrids is not None and len(rows_microgrids) > 0:
cursor.close()
cnx.close()
raise falcon.HTTPError(status=falcon.HTTP_400,
title='API.BAD_REQUEST',
description='API.MICROGRID_OWNER_TYPE_USED_IN_STORE')
description='API.MICROGRID_OWNER_TYPE_USED_IN_microgrid')
cursor.execute(" DELETE FROM tbl_microgrid_owner_types WHERE id = %s ", (id_,))
cnx.commit()
......@@ -254,7 +254,7 @@ class MicrogridOwnerTypeItem:
description='API.MICROGRID_OWNER_TYPE_NAME_IS_ALREADY_IN_USE')
cursor.execute(" SELECT simplified_code "
" FROM tbl_microgrid_Owner_types "
" FROM tbl_microgrid_owner_types "
" WHERE simplified_code = %s AND id != %s ", (simplified_code, id_))
if cursor.fetchone() is not None:
cursor.close()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册