From 940349af291b2f4196f707bb79b700b8d18685a2 Mon Sep 17 00:00:00 2001 From: Julya Shapaeva Date: Sat, 30 Nov 2024 12:16:27 +0300 Subject: [PATCH] Update stubs DogsittersFinder --- server/routers/dogsitters-finder/index.js | 28 +++++++++++++++++++ .../json/auth/dogsitter.success.json | 12 ++++++++ .../dogsitters-finder/json/auth/error.json | 3 ++ .../json/auth/owner.success.json | 9 ++++++ .../json/register/dogsitter.success.json | 12 ++++++++ .../json/register/error.json | 3 ++ .../json/register/owner.success.json | 9 ++++++ .../routers/dogsitters-finder/json/users.json | 6 +--- 8 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 server/routers/dogsitters-finder/json/auth/dogsitter.success.json create mode 100644 server/routers/dogsitters-finder/json/auth/error.json create mode 100644 server/routers/dogsitters-finder/json/auth/owner.success.json create mode 100644 server/routers/dogsitters-finder/json/register/dogsitter.success.json create mode 100644 server/routers/dogsitters-finder/json/register/error.json create mode 100644 server/routers/dogsitters-finder/json/register/owner.success.json diff --git a/server/routers/dogsitters-finder/index.js b/server/routers/dogsitters-finder/index.js index dc8fc6c..afa0060 100644 --- a/server/routers/dogsitters-finder/index.js +++ b/server/routers/dogsitters-finder/index.js @@ -6,4 +6,32 @@ router.get("/users", (request, response) => { response.send(require("./json/users.json")) }) +router.post("/auth", (request, response) => { + const {phoneNumber, password} = request.body; + console.log(phoneNumber, password); + if (phoneNumber === '89999999999') { + response.send(require("../json/auth/dogsitter.success.json")) + } + else if (phoneNumber === '89555555555') { + response.status(400).send(require("../json/auth/error.json")) + } + else { + response.send(require("../json/auth/owner.success.json")) + } +}) + +router.post("/register", (request, response) => { + const {firstName, secondName, phoneNumber, password, role} = request.body; + console.log(phoneNumber, password, role); + if (phoneNumber === '89283244141' || phoneNumber === '89872855893') { + response.status(400).send(require("../json/register/error.json")) + } + else if (role === 'dogsitter') { + response.send(require("../json/register/dogsitter.success.json")) + } + else { + response.send(require("../json/register/owner.success.json")) + } +}) + module.exports = router; diff --git a/server/routers/dogsitters-finder/json/auth/dogsitter.success.json b/server/routers/dogsitters-finder/json/auth/dogsitter.success.json new file mode 100644 index 0000000..f7b2168 --- /dev/null +++ b/server/routers/dogsitters-finder/json/auth/dogsitter.success.json @@ -0,0 +1,12 @@ +{ + "data": { + "id": 1, + "phoneNumber": 89283244141, + "firstName": "Вася", + "secondName": "Пупкин", + "role": "dogsitter", + "location": "Россия, республика Татарстан, Казань, улица Пушкина, 12", + "price": 1500, + "aboutMe": "Я люблю собак" + } +} \ No newline at end of file diff --git a/server/routers/dogsitters-finder/json/auth/error.json b/server/routers/dogsitters-finder/json/auth/error.json new file mode 100644 index 0000000..4fded6c --- /dev/null +++ b/server/routers/dogsitters-finder/json/auth/error.json @@ -0,0 +1,3 @@ +{ + "error": "Пользователь не найден" +} \ No newline at end of file diff --git a/server/routers/dogsitters-finder/json/auth/owner.success.json b/server/routers/dogsitters-finder/json/auth/owner.success.json new file mode 100644 index 0000000..8939302 --- /dev/null +++ b/server/routers/dogsitters-finder/json/auth/owner.success.json @@ -0,0 +1,9 @@ +{ + "data": { + "id": 3, + "phoneNumber": 89872855893, + "firstName": "Гадий", + "secondName": "Петрович", + "role": "owner" + } +} \ No newline at end of file diff --git a/server/routers/dogsitters-finder/json/register/dogsitter.success.json b/server/routers/dogsitters-finder/json/register/dogsitter.success.json new file mode 100644 index 0000000..1f594e6 --- /dev/null +++ b/server/routers/dogsitters-finder/json/register/dogsitter.success.json @@ -0,0 +1,12 @@ +{ + "data": { + "id": 5, + "phoneNumber": 89555555555, + "firstName": "Масяня", + "secondName": "Карлова", + "role": "dogsitter", + "location": "Россия, республика Татарстан, Казань, улица Пушкина, 12", + "price": 100, + "aboutMe": "Все на свете - собаки" + } +} \ No newline at end of file diff --git a/server/routers/dogsitters-finder/json/register/error.json b/server/routers/dogsitters-finder/json/register/error.json new file mode 100644 index 0000000..2aaf5c9 --- /dev/null +++ b/server/routers/dogsitters-finder/json/register/error.json @@ -0,0 +1,3 @@ +{ + "error": "Пользователь с таким номером телефона уже существует" +} \ No newline at end of file diff --git a/server/routers/dogsitters-finder/json/register/owner.success.json b/server/routers/dogsitters-finder/json/register/owner.success.json new file mode 100644 index 0000000..2193e4d --- /dev/null +++ b/server/routers/dogsitters-finder/json/register/owner.success.json @@ -0,0 +1,9 @@ +{ + "data": { + "id": 6, + "phoneNumber": 89888888888, + "firstName": "Генадий", + "secondName": "Паровозов", + "role": "owner" + } +} \ No newline at end of file diff --git a/server/routers/dogsitters-finder/json/users.json b/server/routers/dogsitters-finder/json/users.json index 17d0259..e85d91f 100644 --- a/server/routers/dogsitters-finder/json/users.json +++ b/server/routers/dogsitters-finder/json/users.json @@ -2,7 +2,6 @@ { "id": 1, "phone_number": 89283244141, - "password": "1234", "first_name": "Вася", "second_name": "Пупкин", "role": "dogsitter", @@ -13,7 +12,6 @@ { "id": 2, "phone_number": 89272844541, - "password": "1234", "first_name": "Ваня", "second_name": "Пуськин", "role": "dogsitter", @@ -24,7 +22,6 @@ { "id": 3, "phone_number": 89872855893, - "password": "12345", "first_name": "Гадий", "second_name": "Петрович", "role": "owner" @@ -32,10 +29,9 @@ { "id": 4, "phone_number": 89872844591, - "password": "12345", "first_name": "Галкин", "second_name": "Максим", - "role": ["owner", "dogsitter"], + "role": "dogsitter", "location": "Россия, республика Татарстан, Казань, проспект Ямашева, 83", "price": 1000000, "about_me": "Миллион алых роз" -- 2.45.2