summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal
diff options
context:
space:
mode:
authorcyuamber <xuranyjy@chinamobile.com>2019-09-11 17:19:46 +0800
committercyuamber <xuranyjy@chinamobile.com>2019-09-11 17:19:57 +0800
commitfa426eee7abcb1a509b263585f4556f661a99d38 (patch)
tree8c407df60c15ca1847267b2d4302e6629f8006a9 /usecaseui-portal
parent364ae06e60c429a92d33985ed6016159ab49d495 (diff)
feat: add post and put mock method
Change-Id: Ibe85c6deacb9f38795f33a4379c33a891bb3ef28 Issue-ID: USECASEUI-306 Signed-off-by: cyuamber <xuranyjy@chinamobile.com>
Diffstat (limited to 'usecaseui-portal')
-rw-r--r--usecaseui-portal/src/app/core/services/managemencs.service.ts13
-rw-r--r--usecaseui-portal/src/app/mock/json/PUT_uui-lcm_customers.json6
-rw-r--r--usecaseui-portal/src/app/mock/json/PUT_uui-lcm_customers_service-subscriptions.json6
-rw-r--r--usecaseui-portal/src/app/mock/routes.js6
-rw-r--r--usecaseui-portal/src/app/mock/server.js26
5 files changed, 46 insertions, 11 deletions
diff --git a/usecaseui-portal/src/app/core/services/managemencs.service.ts b/usecaseui-portal/src/app/core/services/managemencs.service.ts
index b7aff872..cd293d40 100644
--- a/usecaseui-portal/src/app/core/services/managemencs.service.ts
+++ b/usecaseui-portal/src/app/core/services/managemencs.service.ts
@@ -20,10 +20,11 @@ export class ManagemencsService {
//mock Currently unadjustable api interface
deleteCustomer: this.baseUrl + "/uui-lcm/customers", /* delete */
createCustomer: this.baseUrl + "/uui-lcm/customers/", /* put */
- createServiceType: this.baseUrl + "/uui-lcm/customers/*_*/service-subscriptions/*+*", /* put */
getCustomerresourceVersion: this.baseUrl + "/uui-lcm/customers/*_*", /* get */
- getServiceTypeResourceVersion: this.baseUrl + "/uui-lcm/customers/*_*/service-subscriptions/*+*",
- deleteServiceType: this.baseUrl + "/uui-lcm/customers/*_*/service-subscriptions/*+*",
+
+ createServiceType: this.baseUrl + "/uui-lcm/customers/*_*/service-subscriptions/*+*", /* put */
+ getServiceTypeResourceVersion: this.baseUrl + "/uui-lcm/customers/*_*/service-subscriptions/*+*", /* get */
+ deleteServiceType: this.baseUrl + "/uui-lcm/customers/*_*/service-subscriptions/*+*", /* delete */
};
//The following APIs are optimizable ----------------------------------
@@ -41,7 +42,7 @@ export class ManagemencsService {
deleteSelectCustomer(paramsObj) {
let url = this.url.deleteCustomer;
let params = new HttpParams({ fromObject: paramsObj });
- return this.http.delete(url,{params});
+ return this.http.delete(url, { params });
}
//The following APIs are not optimizable ---------------------------------
@@ -84,10 +85,10 @@ export class ManagemencsService {
let customerId = paramsObj.customerId.id,
ServiceType = paramsObj.ServiceType,
version = {
- "resourceVersion":paramsObj.version
+ "resourceVersion": paramsObj.version
};
let url = this.url.deleteServiceType.replace("*_*", customerId).replace("*+*", ServiceType);
let params = new HttpParams({ fromObject: version });
- return this.http.delete(url,{params});
+ return this.http.delete(url, { params });
}
}
diff --git a/usecaseui-portal/src/app/mock/json/PUT_uui-lcm_customers.json b/usecaseui-portal/src/app/mock/json/PUT_uui-lcm_customers.json
new file mode 100644
index 00000000..c014187e
--- /dev/null
+++ b/usecaseui-portal/src/app/mock/json/PUT_uui-lcm_customers.json
@@ -0,0 +1,6 @@
+{
+ "global-customer-id": "Democcy",
+ "subscriber-name": "Democcy",
+ "subscriber-type": "INFRA",
+ "resource-version": "1535601196964"
+} \ No newline at end of file
diff --git a/usecaseui-portal/src/app/mock/json/PUT_uui-lcm_customers_service-subscriptions.json b/usecaseui-portal/src/app/mock/json/PUT_uui-lcm_customers_service-subscriptions.json
new file mode 100644
index 00000000..c014187e
--- /dev/null
+++ b/usecaseui-portal/src/app/mock/json/PUT_uui-lcm_customers_service-subscriptions.json
@@ -0,0 +1,6 @@
+{
+ "global-customer-id": "Democcy",
+ "subscriber-name": "Democcy",
+ "subscriber-type": "INFRA",
+ "resource-version": "1535601196964"
+} \ No newline at end of file
diff --git a/usecaseui-portal/src/app/mock/routes.js b/usecaseui-portal/src/app/mock/routes.js
index 4a4b4057..7e148e9f 100644
--- a/usecaseui-portal/src/app/mock/routes.js
+++ b/usecaseui-portal/src/app/mock/routes.js
@@ -35,8 +35,12 @@ module.exports =
/////////////////////////
///////<-------------managemence services--------->/////
+ "/uui-lcm/customers/:customer": "/serviceType",
+ "/PUT/uui-lcm/customers/:name/service-subscriptions/:id": "/PUT_uui-lcm_customers_service-subscriptions",
+ "/PUT/uui-lcm/customers/:customer": "/PUT_uui-lcm_customers",
+ "/uui-lcm/customers/:customer/service-subscriptions/:id": "/language",
"/uui-lcm/customers/:customer/service-subscriptions": "/serviceType",
- "/uui-lcm/serviceNumByServiceType/:customer":"/CustomersColumn",
+ "/uui-lcm/serviceNumByServiceType/:customer": "/CustomersColumn",
/////////////////////////
diff --git a/usecaseui-portal/src/app/mock/server.js b/usecaseui-portal/src/app/mock/server.js
index 726992d5..b603523f 100644
--- a/usecaseui-portal/src/app/mock/server.js
+++ b/usecaseui-portal/src/app/mock/server.js
@@ -18,13 +18,14 @@ const jsonServer = require('json-server');
const server = jsonServer.create();
const middlewares = jsonServer.defaults();
const customersRouters = require('./routes');
+const baseUrl = "/usecaseui-server/v1";
// Set default middlewares (logger, static, cors and no-cache)
server.use(middlewares);
-server.use((requset,response,next) => {
- requset.method = 'GET';
- next()
-})
+// server.use((req, res, next) => {
+// req.method = "GET";
+// next();
+// })
// Get mock data
const fs = require('fs');
@@ -72,6 +73,7 @@ function fileDisplay(filePath) {
runServer(localJsonDb);
}, 100)
}
+
function getjsonContent(path) {
let newpath = `./src/app/mock/json/${path}.json`;
let result = JSON.parse(fs.readFileSync(newpath));
@@ -86,6 +88,22 @@ function serverRewrite() {
function runServer(db) {
server.use(jsonServer.router(db));
}
+server.post(`${baseUrl}/*`, (req, res, next) => {
+ const prefix = req.url.replace(baseUrl, "");
+ req.url = `${baseUrl}/POST${prefix}`;
+ req.method = 'GET';
+ next();
+})
+server.put(`${baseUrl}/*`, (req, res, next) => {
+ const prefix = req.url.replace(baseUrl, "");
+ req.url = `${baseUrl}/PUT${prefix}`;
+ req.method = 'GET';
+ next();
+})
+server.delete(`${baseUrl}/*`, (req, res, next) => {
+ console.log("===delete😑")
+ next();
+})
server.listen(3002, () => {
console.log('Mock Server is successfully running on port 3002 😁')