giakhangnguyenlam / WebsiteTangQua

MIT License
0 stars 0 forks source link

Đề tài môn công nghệ phần mềm


Tên đề tài: Website tặng quà

Nhóm thực hiện: 15


Giới thiệu

Hệ thống cung cấp các API cho các cửa hàng quà tặng có thể sử dụng để nâng cấp hoặc tích hợp vào hệ thống của cửa hàng.

Hướng dẫn sử dụng

Thông tin chi tiết cho từng API đã được cập nhật tại các document cho từng phiên bản.

Hệ thống sẽ liên tục được cập nhật và bổ sung những tính năng mới.

Khi hệ thống sử dụng API mà phát sinh lỗi bạn có thể liên lạc qua email: giakhangnguyen115@gmail.com để được khắc phục sớm nhất.

U can replace localhost to tonydomain.ddns.net, maybe has app name follow the domain. Ex: tonydomain.ddns.net:8080/giftapp

Hỗ trợ thử nghiệm hệ thống

Thử nghiệm hệ thống giftapp bằng cách thực hiện những bước sau đây:

Bước 1: Clone project về máy

Bước 2: vào thư mục supporting test postman để kiểm tra thử có file CNPM postman_collection.json hay không.

Bước 3: Vào postman

Bước 4: Chọn file -> import

Bước 5: chọn tới đường dẫn file CNPM.postman_collection.json

Sau khi thực hiện xong có thể test thử tất cả các chức năng của hệ thống.

Note: nếu không thực hiện được có thể cho host đã bị tắt (host của nhóm em). Để có thể test tiếp thay đổi tonydomain.ddns.net thành localhost

Mô tả phiên bản 1.0

Account

Link: http://localhost:8080/api/accounts/signup

Or: http://localhost:8080/giftapp/api/accounts/signup

POST:

Request

Body:

{
    "username": "catuser",
    "password": "123meow"
}

Response

Status code:


Link: http://localhost:8080/api/accounts/signin

Or: http://localhost:8080/giftapp/api/accounts/signin

POST

Request

Body:

{
    "username": "catuser",
    "password": "123meow",
        "accountType": 1
}

accountType

Response

Status code:

Nhóm 15

Mô tả phiên bản 1.1

API: AccountInfos

link: http://localhost:8080/api/accountinfos

POST

link: http://localhost:8080/api/accountinfos

Request

{
    "uname" : "khangtest2",
    "disname" : "khangtest2",
    "uaddress" : "daylaaddresss",
    "phonenum" : 919910266,
    "email" : "mailjcungdc"
}

Response

Successes

Status: 201 Lưu thành công accountInforService

Failure

Status: 404

PUT

link: http://localhost:8080/api/accountinfos/khangtest1

Request

{
    "disname" : "khangtest3",
    "uaddress" : "daylaaddresss",
    "phonenum" : 919910266,
    "email" : "mailjcungdc"
}

Response

Successes

Status:200 AccountInfo đã được update

Failure

Status:404

GET

Request

link: http://localhost:8080/api/accountinfos

Response

Successes

[
    {
        "uname": "khangtest1",
        "disname": "khangtest",
        "uaddress": "daylaaddress",
        "phonenum": 919910266,
        "email" : "mailjcungdc"
    }
]

Failure

Status:404

GET

link: http://localhost:8080/api/accountinfos/khangtest1

Request

Response

Successes

Status:200

{
    "uname": "khangtest2",
    "disname": "khangtest2",
    "uaddress": "daylaaddresss",
    "phonenum": 919910266
}

Failure

Status: 404

DELETE

link: http://localhost:8080/api/accountinfos/khangtest1

Request

Response

Successes:

Status:200 Xóa accountInfo thành công

Failure:

Status:404

API: GOrderAddOnUserRest

link: http://localhost:8080/api/gorderaddon

POST

Request

{

    "gorderId": 2,
    "addonId": 2,
    "content":"day la lan thu dau hai"

}

Response

Successes

Status: 201 Lưu thành công gOrderAddOn

Failure

Status: 404

PUT

link: http://localhost:8080/api/gorderaddon/2

Request

{
    "gorderId": 15,
    "addonId": 3,
    "content":"Muon sua thanh addon thu ba"
}

Response

Successes

Status: 200 GOrderAddOn update thành công

Failure

Status: 400

GET

link: http://localhost:8080/api/gorderaddon

Request

Response

Successes

[
    {
        "cid": 1,
        "gorderId": null,
        "addonId": 2,
        "content": "sua cai content khac",
        "aname": null,
        "adescription": null,
        "price": null
    },
    {
        "cid": 2,
        "gorderId": null,
        "addonId": 2,
        "content": "sua cai content khac",
        "aname": null,
        "adescription": null,
        "price": null
    },
    {
        "cid": 3,
        "gorderId": null,
        "addonId": 2,
        "content": "sua cai content khac",
        "aname": null,
        "adescription": null,
        "price": null
    },
    {
        "cid": 5,
        "gorderId": 2,
        "addonId": 2,
        "content": "day la lan thu dau hai",
        "aname": null,
        "adescription": null,
        "price": null
    }
]

Failure

Status: 404

GET

link: http://localhost:8080/api/gorderaddon/15

Request

Response

Successes

Status:200

[
    {
        "cid": 17,
        "gorderId": 15,
        "addonId": 1,
        "content": "cái nơ màu xanh",
        "aname": "test1",
        "adescription": "dung de test",
        "price": 10000
    },
    {
        "cid": 18,
        "gorderId": 15,
        "addonId": 5,
        "content": "Muon sua thanh addon thu ba",
        "aname": "fakeAddOn1",
        "adescription": "Đây là addOnFake",
        "price": 30000
    }
]

Failure

Status: 404

DELETE

link: http://localhost:8080/api/gorderaddon/2

Request

Response

Successes

Status: 200 Ğã xóa thành công addon

Failure

Status: 404

Mô tả phiên bản 2.0

API: Order

POST

link: http://localhost:8080/api/user/order

Request

{
    "uname" : "khangtest1",
    "giftpackId": 1,
    "receiveAddress" : "123/dada/tp.HCM",
    "phoneNumber" : 919910266,
    "dateArrive" : "23-05-2021",
    "greetingCardContent" : "Happy birthday",
    "addonId": [1,2],
    "content" : ["cái nơ màu xanh", "cái thiệp màu hồng"]
}

Response

Success

Status: 200 Đã tạo đơn hàng thành công Location: /api/user/order/id/16

Failure

Status: 404

GET

link: http://localhost:8080/api/user/order/id/16

Request

Response

{
    "cid": 16,
    "uname": "khangtest1",
    "giftpackId": 1,
    "receiveAddress": "123/dada/tp.HCM",
    "phoneNumber": 919910266,
    "dateOrder": "17-05-2021",
    "dateArrive": "23-05-2021",
    "greetingCardContent": "Happy birthday",
    "addonId": [
        1,
        2
    ],
    "content": [
        "cái nơ màu xanh",
        "cái thiệp màu hồng"
    ],
    "status": "Đang xử lý",
    "cost": 140000
}

GET

link: http://localhost:8080/api/user/order/uname/khangtest1

Request

Response

Success

Status: 200

[
    {
        "cid": 1,
        "uname": "khangtest1",
        "giftpackId": 1,
        "receiveAddress": "123/dada/tp.HCM",
        "phoneNumber": 919910266,
        "dateOrder": "17-05-2021",
        "dateArrive": "23-05-2021",
        "greetingCardContent": "Happy birthday",
        "addonId": [
            1
        ],
        "content": [
            "cái nơ màu xanh"
        ],
        "status": "Đang chờ xử lý",
        "cost": 110000
    },
    {
        "cid": 4,
        "uname": "khangtest1",
        "giftpackId": 1,
        "receiveAddress": "123/dada/tp.HCM",
        "phoneNumber": 919910266,
        "dateOrder": "17-05-2021",
        "dateArrive": "23-05-2021",
        "greetingCardContent": "Happy birthday",
        "addonId": null,
        "content": null,
        "status": "Đang chờ xử lý",
        "cost": 100000
    },
    {
        "cid": 12,
        "uname": "khangtest1",
        "giftpackId": 1,
        "receiveAddress": "123/dada/tp.HCM",
        "phoneNumber": 919910266,
        "dateOrder": "17-05-2021",
        "dateArrive": "23-05-2021",
        "greetingCardContent": "Happy birthday",
        "addonId": [
            1,
            2
        ],
        "content": [
            "cái nơ màu xanh",
            "cai thiep mau hong"
        ],
        "status": "Đang chờ xử lý",
        "cost": 140000
    },
    {
        "cid": 13,
        "uname": "khangtest1",
        "giftpackId": 1,
        "receiveAddress": "123/dada/tp.HCM",
        "phoneNumber": 919910266,
        "dateOrder": "17-05-2021",
        "dateArrive": "23-05-2021",
        "greetingCardContent": "Happy birthday",
        "addonId": [
            2
        ],
        "content": [
            "cai thiep mau hong"
        ],
        "status": "Đang chờ xử lý",
        "cost": 130000
    },
    {
        "cid": 14,
        "uname": "khangtest1",
        "giftpackId": 1,
        "receiveAddress": "123/dada/tp.HCM",
        "phoneNumber": 919910266,
        "dateOrder": "17-05-2021",
        "dateArrive": "23-05-2021",
        "greetingCardContent": "Happy birthday",
        "addonId": [
            1,
            2
        ],
        "content": [
            "cái nơ màu xanh",
            "cai thiep mau hong"
        ],
        "status": "Đang chờ xử lý",
        "cost": 140000
    }
]

Failure

Status: 404

GET

link: http://localhost:8080/api/user/order

Request

Response

Status: 200

[
    {
        "cid": 1,
        "uname": "khangtest1",
        "giftpackId": 1,
        "receiveAddress": "123/dada/tp.HCM",
        "phoneNumber": 919910266,
        "dateOrder": "17-05-2021",
        "dateArrive": "23-05-2021",
        "greetingCardContent": "Happy birthday",
        "addonId": [
            1
        ],
        "content": [
            "cái nơ màu xanh"
        ],
        "status": "Đang chờ xử lý",
        "cost": 110000
    },
    {
        "cid": 4,
        "uname": "khangtest1",
        "giftpackId": 1,
        "receiveAddress": "123/dada/tp.HCM",
        "phoneNumber": 919910266,
        "dateOrder": "17-05-2021",
        "dateArrive": "23-05-2021",
        "greetingCardContent": "Happy birthday",
        "addonId": null,
        "content": null,
        "status": "Đang chờ xử lý",
        "cost": 100000
    }
]

API OrdeProcess

GET

link:http://localhost:8080/api/delivery

Request:

Response:

Status.200

[
    {
        "gorderId": 5,
        "pstate": "Canceled",
        "pdelivered": 1,
        "pcanceled": 1
    },
    {
        "gorderId": 8,
        "pstate": "done",
        "pdelivered": 1,
        "pcanceled": 0
    },
    {
        "gorderId": 10,
        "pstate": "cancel",
        "pdelivered": 0,
        "pcanceled": 1
    }
]

Fail:

Status.400

GET

link:http://localhost:8080/api/delivery/Listdeliveried

Request

Response

Status.200

[
    {
        "gorderId": 5,
        "pstate": "Canceled",
        "pdelivered": 1,
        "pcanceled": 1
    },
    {
        "gorderId": 8,
        "pstate": "done",
        "pdelivered": 1,
        "pcanceled": 0
    }
]

Fail:

Status.400

POST

link:http://localhost:8080/api/delivery/addOrderProcess

Request

    {
        "gorderId": 5,
        "pstate": "process",
        "pdelivered": 0,
        "pcanceled": 0
    }

Response

Status.200 Add success

PUT

link:http://localhost:8080/api/delivery/update/5

Request

    {
        "gorderId": 5,
        "pstate": "done",
        "pdelivered": 1,
        "pcanceled": 0
    }

Response

Status.200 Update success

DELETE

link:http://localhost:8080/api/delivery/delete/5

Request

Response

Status.200 Delete success

API GiftPackComments

GET

link:http://localhost:8080/comments/listComments

Request

Response

Success

Status.200

[
    {
        "cid": 4,
        "giftpackId": 2,
        "uname": "catuser",
        "content": "Fail"
    }
]

Fail:

Status.400

GET

link:http://localhost:8080/comments/getCommentsByUname/catuser

Request

Response

Success

Status.200

[
    {
        "cid": 4,
        "giftpackId": 2,
        "uname": "catuser",
        "content": "Fail"
    }
]

Fail:

Status.400

GET

link: http://localhost:8080/comments/getCommentsBygiftID/1

Request

Response

Success

Status.200

 {
    "cid": 10,
    "giftpackId": 1,
    "uname": "catuser",
    "content": "Failed"
}

Fail:

Status.400

POST

Request

 {
    "cid": 10,
    "giftpackId": 1,
    "uname": "catuser",
    "content": "Failed"
}

Response

Success

Add Comment sucess

Fail:

Status.400

PUT

Request

     {
        "giftpackId": 2,
        "uname": "catuser",
        "content": "Fail"
    }

Response

Status.200 Update success

Fail:

Status.400 Update unsuccess

DELETE

link:http://localhost:8080/comments/delete/10

Request

Response

Sucess:

Status.200 Delete success

Fail:

Status.400 Delete unsuccess

POST

link:http://localhost:8080/comments/resolveComment

Request:

{
    "email":"18110092@student.hcmute.edu.vn",
    "content":"Gift very good",
    "commentResolve":"Thanks you for buy Gift",
    "giftpackId":2

}

Response

Success

Status.200 Mail sent.

Fail

Mail unsent

Mô tả phiên bản 3.0

API: Items

Link: http://localhost:8080/api/items

GET

Response

Status code: 200

[
  {
    "cid": 1,
    "itemName": "keo",
    "itemDescription": "2 bich keo",
    "thumbnailimg": "https://www.apple.com/ac/structured-data/images/open_graph_logo.png?201810040211",
    "price": 250,
    "activeState": 1
  },
  {
    "cid": 2,
    "itemName": "keo",
    "itemDescription": "2 bich keo",
    "thumbnailimg": "https://www.apple.com/ac/structured-data/images/open_graph_logo.png?201810040211",
    "price": 200,
    "activeState": 1
  }
]

GET

Link: http://localhost:8080/api/items/1

Get an item with id (this link for id = 1)

Response

Status code: 200

{
  "cid": 1,
  "itemName": "keo",
  "itemDescription": "2 bich keo",
  "thumbnailimg": "https://www.apple.com/ac/structured-data/images/open_graph_logo.png?201810040211",
  "price": 250,
  "activeState": 1
}

POST

Create new item

Request

{
  "itemName": "gau bong",
  "itemDescription": "1 co gau bong mau tin",
  "thumbnailimg": "https://www.apple.com/ac/structured-data/images/open_graph_logo.png?201810040211",
  "price": 450,
  "activeState": 1
}

Response

Status code: 201

Created new item.

PUT

Link: http://localhost:8080/api/items/1

Update an item with id (this link for item has id = 1)

Request

{
  "itemName": "gau bong",
  "itemDescription": "Con gau bong mau tim to dung",
  "thumbnailimg": "https://www.apple.com/ac/structured-data/images/open_graph_logo.png?201810040211",
  "price": 350,
  "activeState": 1
}

Response

Status code: 200

Update item.

GET

Link: http://localhost:8080/api/items/noitemtypes

Get a number of item's types

Response

Status code: 200

{
  "numberofitemtypes": 3
}

API: giftpack

Link: http://localhost:8080/api/giftpacks

GET

Get all giftpack

Response

Status code: 200

[
  {
    "cid": 1,
    "gname": "qua valentine",
    "gdescription": "sicola va hoa hong",
    "thumbnailimg": "https://www.apple.com/ac/structured-data/images/open_graph_logo.png?201810040211",
    "price": 570,
    "averageStar": 0,
    "activeState": 1
  },
  {
    "cid": 10,
    "gname": "qua sinh nhat",
    "gdescription": "banh kem",
    "thumbnailimg": "https://www.apple.com/ac/structured-data/images/open_graph_logo.png?201810040211",
    "price": 270,
    "averageStar": 0,
    "activeState": 1
  }
]

GET

Link:http://localhost:8080/api/giftpacks/1

Get a giftpack has id = 1

Response

Status code: 200

{
  "cid": 1,
  "gname": "qua valentine",
  "gdescription": "sicola va hoa hong",
  "thumbnailimg": "https://www.apple.com/ac/structured-data/images/open_graph_logo.png?201810040211",
  "price": 570,
  "averageStar": 0,
  "activeState": 1
}

POST

Create new giftpack

Request

{
    "gname": "qua xin loi",
    "gdescription": "hoa cuc",
    "thumbnailimg": "https://www.apple.com/ac/structured-data/images/open_graph_logo.png?201810040211",
    "price": 130,
    "averageStar": 0,
    "activeState": 1
}

Response

Status code: 201

Created new giftpack

PUT

Link: http://localhost:8080/api/giftpacks/10

Update an existed gitfpack has id = 10

Request

{
    "gname": "qua chia tay",
    "gdescription": "hoa hong trang",
    "thumbnailimg": "https://www.apple.com/ac/structured-data/images/open_graph_logo.png?201810040211",
    "price": 1300,
    "averageStar": 0,
    "activeState": 1
}

Response

Status code: 200

Updated giftpack

GET

Link: http://localhost:8080/api/giftpacks/nogiftpacktypes

Get the number of giftpack's types

Response

{
  "numberofgiftpacktypes": 3
}

API: Addon

Link: http://localhost:8080/api/addons

GET

Get all of addon

Response

Status code: 200

[
  {
    "cid": 1,
    "aname": "loi chuc",
    "adescription": "mot loi chuc den nhung ai ...",
    "price": 25
  },
  {
    "cid": 2,
    "aname": "phat nhac",
    "adescription": "O noi dau do nhin ve qua khu cua hai ta lieu em co tiec?",
    "price": 25
  },
  {
    "cid": 3,
    "aname": "choi nhac",
    "adescription": "O noi dau do nhin ve qua khu cua hai ta lieu em co tiec?",
    "price": 25
  }
]

GET

Link: http://localhost:8080/api/addons/1

Get an addon has id = 1

Response

Status code: 200

{
  "cid": 1,
  "aname": "loi chuc",
  "adescription": "mot loi chuc den nhung ai ...",
  "price": 25
}

POST

Create new addon

Request

{
  "aname": "dance",
  "adescription": "999 doa hoa hong",
  "price": 99
}

Response

Status code: 201

Created new addon

PUT

Link: http://localhost:8080/api/addons/1

Update addon has id = 1

Request

{
  "aname": "dance and nu.de",
  "adescription": "999 doa hoa hong, thoi doi",
  "price": 199
}

Response

Status code: 200

Updated addon!

GET

Link: http://localhost:8080/api/addons/noaddontypes

Get the number of addon's types

Response

Status code: 200

{
  "noaddontypes": 4
}

API : GiftpackItems

link: http://localhost:8080/api/giftpackitems

GET

Get all giftpackItems

Link : http://localhost:8080/api/giftpackitems

Request

Response

[
    {
        "cid": 3,
        "giftpackId": 1,
        "itemId": 2
    }
]

GET

Get giftpacksItem by id=1 link: http://localhost:8080/api/giftpackitems/1

Request

Response

[
    {
        "cid": 3,
        "giftpackId": 1,
        "itemId": 2
    }
]

POST

Add one giftpack has many items

Request

{
    "giftpackid": 1,
    "itemid" : [1, 2]
}

Response

Success: 201

PUT

Update by id in database of giftpackItems

link: http://localhost:8080/api/giftpackitems/2

Request

{
    "giftpackId": 1,
    "itemId": 2
}

Response

Success: 200

DELETE

Delete by id in database of giftpackItems

link: http://localhost:8080/api/giftpackitems/2

Request

Response

Success: 200