Tải bản đầy đủ (.pdf) (92 trang)

spring store software design specification mentor quách luyl đa

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (4.17 MB, 92 trang )

<span class="text_page_counter">Trang 1</span><div class="page_container" data-page="1">

<b>SPRING_STORESoftware Design Specification</b>

<b>Mentor - Quách Luyl Đa</b>

<b>Trần Trọng Nguyễn - CE170134Hồng Bảo Bảo - CE170912Đoàn Quốc Kiệt – CE171400</b>

–CanTho, January 2022 –

</div><span class="text_page_counter">Trang 2</span><div class="page_container" data-page="2">

<b>RECORD OF CHANGES</b>

<b>M, D</b>

<b>In chargeChange Description</b>

*A - Added M - Modified D - Deleted

</div><span class="text_page_counter">Trang 3</span><div class="page_container" data-page="3">

II. Code Designs...11

1. Login for user...11

</div><span class="text_page_counter">Trang 6</span><div class="page_container" data-page="6">

c. Sequence diagram(s)...

d. Database queries 26. Show list product ...

a. Class diagram b. Class specification...69

c. Sequence diagrams(s) d. Database queries 27. Monthly Revenue Manager a. Class diagram b. Class Specification...71

C. Sequence Diagram(s) d. Database queries 28. Order Approval a. Class diagram b. Class Specification...74

</div><span class="text_page_counter">Trang 8</span><div class="page_container" data-page="8">

<b>I. Overview1. Code Packages</b>

etc with detailed functions that can interact directly with the database for data processing to which the Controller can load data for the user.

04 Controller Includes Servlets with a responsibility to process, transfer the datacollected by user on web page(view) to DAO and Model in the database to JSP pages.

05 DBContext This package helps connect database.

06 Ultis This package contains Helper class with functions for sending

</div><span class="text_page_counter">Trang 9</span><div class="page_container" data-page="9">

<b>2. Database Designa. Database Schema</b>

<b>b. Table Description</b>

01 Admin Stores information about administrators in the system.- Primary keys: adminID

- Foreign keys: None

02 User Stores information about registered users.- Primary keys: userID

- Foreign keys: None

03 Staff Stores information about staff members.- Primary keys: staffID

- Foreign keys: None

04 Product Stores information about products available in the system.- Primary keys: productID

- Foreign keys: None

</div><span class="text_page_counter">Trang 10</span><div class="page_container" data-page="10">

- Primary keys: commentID

- Foreign keys: productID (references Product), userID (references User)

06 Cart Stores information about user shopping carts.- Primary keys: cartID

- Foreign keys: userID (references User), productID (references Product)

07 Order Stores information about user orders.- Primary keys: orderID

- Foreign keys: userID (references User)

08 OrderDetail Stores detailed information about products in each order.- Primary keys: orderID, productID

- Foreign keys: orderID , productID

09 Size Stores information about product sizes.- Primary keys: productSize, productID- Foreign keys: productID

10 Import Stores information about product imports.- Primary keys: importID

- Foreign keys: staffID

</div><span class="text_page_counter">Trang 11</span><div class="page_container" data-page="11">

<b>II. Code Designs1. Login for user</b>

a. Class Diagram

b. Class SpecificationsLoginController

01 doPost() After the user presses the "login" button and submits the necessary information to log in, this function processes and forwards the request from the user. First, it checks if the person logging in has the "user" role, and if so, it calls the login() function in UserDAO to verify the username and password against the stored data.

UserDAO

</div><span class="text_page_counter">Trang 12</span><div class="page_container" data-page="12">

01 login() First, Establish a connection to the database.

Second, it sends the email address and password to select an account in the database. If the account is returned, it displays successful login information or incorrect login information.

+ Input:

email(String), password(String): verified data.query(string): to select data from the database.+ Output: acc(Account) or null.

02 getUser() After login into the system successfully, save user session information.

01 User () We must add the data to an Account entity with each attribute by progressively supplying arguments to the constructor after loading the data to a result table so that it can be added to the list collection.+Input: userID(int), userEmail(String), userPassword(String), userName(String), userDOB(date), userPhone(String), userAddress(String).

+ Output: user (User)

DBContext

</div><span class="text_page_counter">Trang 14</span><div class="page_container" data-page="14">

<b>2. Login for staff</b>

a. Class Diagram

b. Class SpecificationsLoginController

01 doPost() After the user presses the "login" button and submits the necessary information to log in, this function processes and forwards the request from the user. First, it checks if the person logging in has the "staff" role, and if so, it calls the login() function in StaffDAO to

</div><span class="text_page_counter">Trang 15</span><div class="page_container" data-page="15">

in the database. If the account is returned, it displays successful login information or incorrect login information.

+ Input:

email(String), password(String): verified data.query(string): to select data from the database.+ Output: acc(Account) or null.

02 getStaff() After login into the system successfully, save user session information.

01 Staff () We must add the data to an Account entity with each attribute by progressively supplying arguments to the constructor after loading the data to a result table so that it can be added to the list collection.+Input: staffID(int), staffEmail(String), staffsPassword(String), staffName(String), staffDOB(date), staffPhone(String), staffAddress(String).

+ Output: staff (Staff)

01 getConnection() Create a connection using a few of the provided parameters. Next, establish a database connection to begin processing data. + Input: dbPrefix(String), dbPort(String), dbName(String), instance(String), user(String), and password(String)—passed data is formatted for validation.

+ Output: Conn (connection), which connects to the database.

</div><span class="text_page_counter">Trang 16</span><div class="page_container" data-page="16">

c. Sequence Diagram(s)

Figure 1. Sequence diagram login for staffd. Database Queries

String query: Select * from [Staff] where staffEmail = ? and staffPassword=?

<b>3 . Add Product By Staff</b>

</div><span class="text_page_counter">Trang 17</span><div class="page_container" data-page="17">

a.Class Diagram

b.Class SpecificationsProduct Controller

Add new product

+ Input: name(String),Price(string), description(String),Quantity(String),img(string), category(string).+ Output: true/false

</div><span class="text_page_counter">Trang 18</span><div class="page_container" data-page="18">

specific methods such as doGet, doPost, doHead, doTrace. This class provide by Java Servlet framework.

c.Sequence Diagram(s)

<b>4. Update Product By Staff</b>

a.Class Diagram

</div><span class="text_page_counter">Trang 19</span><div class="page_container" data-page="19">

b.Class SpecificationsProduct Controller

No Method Description

01 doGet() Call getProductByID() in ProductDAO then load on web

02 doPost <sup>Get parameter in form update product then pass into</sup>updateProduct() in ProductDAO class

Product DAO

No Method Description

01 <sup>getProductByI</sup>D()

Method that take sanintegerproduct Idasaparameter. Insidethemethod,youwouldtypicallyhavecodeto locateandupdatetheproductinyourdatastore,such as a database.

02 <sup>updateProduct(</sup>)

+ Update product by parameter

+productId(int),productName(String),productPrice(double),productQuantity(int),productImg(string),productCategory(string),productDis(string).

</div><span class="text_page_counter">Trang 20</span><div class="page_container" data-page="20">

No Method Description

01 Product()

After loading data to a result table to have the data for adding to list collection weneed to add them into a Product entity with each attribute by passing parametersto the constructor sequentially. + Input:productId(int),

- passed data is validated format.+ Output: None

c. Sequence Diagram(s)

</div><span class="text_page_counter">Trang 22</span><div class="page_container" data-page="22">

WHERE productID = ?

<b>5. Add An Order</b>

a. Class Diagram

b. Class SpecificationsAddAnOrderController

</div><span class="text_page_counter">Trang 23</span><div class="page_container" data-page="23">

will return to the registration interface and display a message indicating that the email already exists.

03 addNew(user) Firstly, this method calls the class DBcontext to create a connection with the database.

Secondly, add new user account to database.

+Input:email(String),password(String),name(String), phone(String), address(String).

+ Ouput : NoneDBContext

01 getConnection() Create a connection using a few of the provided parameters. Next, establish a database connection to begin processing data. + Input: dbPrefix(String), dbPort(String), dbName(String), instance(String), user(String), and password(String)—passed data is formatted for validation.

+ Output: Conn (connection), which connects to the database.

</div><span class="text_page_counter">Trang 24</span><div class="page_container" data-page="24">

c. Sequence Diagram(s)

Figure 1. Sequence diagram register for userd. Database Queries

String query: INSERT INTO ORDER VALUES (UserID,TotalPrice,purchaseDate);

<b>6 .List Product category by Users</b>

Class Diagram

</div><span class="text_page_counter">Trang 26</span><div class="page_container" data-page="26">

specific methods such as doGet, doPost, doHead, doTrace. This class provide by Java Servlet framework

</div><span class="text_page_counter">Trang 27</span><div class="page_container" data-page="27">

Class SpecificationsProduc Controller

No Method Description

01 doGet()

This method extends HttpServlet with responsibility to handleand transfer requests from users. It gets txtSearch entered by theuser in jsp page then call function in ProductDAO to process dataand respond to the result to home page lists products matchedwith keywords and messages not found otherwise.Product DAO

No Method Description

01

searchProduct(inkeyword:String): ListProduct

This function is responsible for searching for informationabout a product based on the provided product ID. TheThe search process can be related to queries in gadatabaseorThe system stores product data and returns detailsinformation about the respective product

product code. This information may include the productname, price, description, images and other related details.

No Method Description

01 Product() After loading data to a result table to have the data for adding to the list collectionwe need to add them into a Product entity with each attribute by passing

</div><span class="text_page_counter">Trang 28</span><div class="page_container" data-page="28">

+ Input:productId(int), productName(String),product

Price(double),productQuantity(int),productImg(string),productCategory(string),productDis(string).passed data is validated format.

+ Output: Nonec. Sequence Diagram(s)

Database queries

select * from Product where userId like '%?%'

<b>8.Delete list product in cart</b>

</div><span class="text_page_counter">Trang 29</span><div class="page_container" data-page="29">

a.Class Diagramb.Class Specifications

01 +DelateProductFormCart() +Delete product by ID of product

No. Method Description

getconnection() <b>getconnection so that when adding a product it will be put into thedboCart field</b>

c.Sequence Diagram(s)

</div><span class="text_page_counter">Trang 60</span><div class="page_container" data-page="60">

to

the list collection we need to add them into a staff entity with each attribute by passing parameters to the constructor sequentially.

+ Input: staffID(int), staffEmail(String), staffPassword(String), staffName(String), staffDOB(date),

staffPhone(String), staffAddress(String) – validated data. + Output: none

01 getconnection() Create a connection with some of the passed parameters as below. Then

create a connection with database for data processing. + Input: dbPrefix(String), dbPort(String), dbName(String), instance(String), user(String), and password(String) - passed data is

validated format.

+ Output: conn(Connection) - to connect with database.

c.Sequence Diagram(s)

</div><span class="text_page_counter">Trang 61</span><div class="page_container" data-page="61">

d.Database queries UPDATE [dbo].[Staff]" + " SET [staffEmail] = ?" + " ,[staffPassword] = ?" + " ,[staffName] = ?" + " ,[staffDayOfBirth] = ?" + " ,[staffPhone] = ?" + " ,[staffAddress] = ?" + " WHERE staffID = ?

<b>22.Add new staff </b>

a.Class Diagram

</div><span class="text_page_counter">Trang 62</span><div class="page_container" data-page="62">

b..Class Specifications AddStaffController

01 doPost() +Call addStaff() and getStaff() in StaffDAO class then upload to web

StaffDAO

01 addStaff() +Add a new staff member to the database

02 getStaff() +Check to see if the imported email already exists in the database.

</div><span class="text_page_counter">Trang 63</span><div class="page_container" data-page="63">

each attribute by passing parameters to the constructor sequentially.

+ Input: id (int), email(String), password(String), staffID(int), staffName(String), staffPhone(String),staffAddress(String) - validated data.

+ Output: None

01 getConnection() Create a connection with some of the passed parameters as below. Then

create a connection with database for data processing. + Input: dbPrefix(String), dbPort(String), dbName(String), instance(String), user(String), and password(String) - passed data is

</div><span class="text_page_counter">Trang 64</span><div class="page_container" data-page="64">

+ " ,[staffPassword]" + " ,[staffName]" + " ,[staffDayOfBirth]" + " ,[staffPhone]" + " ,[staffAddress])" + " VALUES" + " (?,?,?,?,?,?)

SELECT * from Staff where staffEmail=?

<b>23.Change user password</b>

a. Class Diagram

</div><span class="text_page_counter">Trang 65</span><div class="page_container" data-page="65">

in UserDAO class.

No. Method Description

01 User() After loading data to a result table to have the data for adding to the list collection we need to add them into an Account entity with each attribute by passing parameters to the constructor sequentially.

+ Input: userID (int), userEmail(String), userName(String),

userPassword(String), userDOB(Date), userPhone(String), userAddress(String) . + Output: None

02 UpdatePassword(user)

+ Update user password

No. Method Description

01 User() After loading data to a result table to have the data for adding to the list collection we need to add them into an Account entity with each attribute by passing parameters to the constructor sequentially.

+ Input: id (int), userEmail(String), userPassword(String), userID(int),

userName(String), userDateOfBirth(date),

userPhone(String), userAddress(String) . + Output: none

No. Method Description

01 getConnection() Create a connection with some of the passed parameters as below. Then create a connection with database for data processing.

+ Input: dbPrefix(String), dbPort(String), dbName(String), instance(String), user(String), and password(String) - passed data is validated format.

+ Output: conn(Connection) - to connect with database.

</div><span class="text_page_counter">Trang 66</span><div class="page_container" data-page="66">

c.Sequence Diagram(s)

d.Database queries

- String query: update [User] set userPassword=? where userID=?

<b>24.Show Detail Product </b>

a.Class Diagram

</div><span class="text_page_counter">Trang 67</span><div class="page_container" data-page="67">

b. Class Specifications Produc Controller

No. Method Description

01 doGet() + doGet()is a method within the ClassSpecifications of the Product Controller,used to handle HTTP GET

requests from clients or web browsers..This method is primarily associated with displaying detailed information abou ta specific product and relies on the GetProducbytId method from the Product DAO to access and retrieve product details from the database.

No. Method Description

01 GetProductbyId It employs the productId parameter to invoke the

method of the Product DAO, facilitating access to the database and the retriev a lof comprehensive product information.

No. Method Description

01 Product() After load data to a result table to have the data for adding to list collection we need to add them into a

Product entity with each attribute by passing parameters to the constructor sequentially.

+ Input:productId(int), productName(String),product

Price(double),productQuantity(int),productImg(string),productCategory(string),productDis(string).passed data is validated format. + Output: None

c. Sequence Diagram(s)

</div><span class="text_page_counter">Trang 69</span><div class="page_container" data-page="69">

ProductDAOs which calls the deleteProduct() function to proceed with deleting the productProductDAOs

1 deleteProduct() connection to database call delete method with productID then Set the value of the productID parameter in the SQL statement.

</div><span class="text_page_counter">Trang 70</span><div class="page_container" data-page="70">

HTTPServlet: Extends the GenericServlet class and implements Serializable interface. It provides http specific methods such as doGet, doPost, doHead, doTrace. This class provide by Java Servlet framework.

</div><span class="text_page_counter">Trang 71</span><div class="page_container" data-page="71">

b. Class specificationProduct Controller

1 doGet() doGet()is a method within the ClassSpecifications of the Product Controller,used to handle HTTP GET requests from clients or web browsers.This method is primarily associated with displaying list product and relies on the getAllProducts(productId:int) method from the ProductDAOs To access and retrieve list products from the database.

1 getAllProduct() Firstly, this method calls class DBcontext to create a connection with a database then load data in the database to a result list of product in a collection list Java.

+ Input: query(String) - for query data.

+ Output: List Product - list all of product in database

1 Product() After load data to a result table to have the data for adding to list collection we need to add them into a Product entity with each attribute by passing parameters to the constructor sequentially.

+ Input:productId(int), productName(String),product Price(double),productQuantity(int),productImg(string),productCategory(string),prod uctDis(string).passed data is validated format.

+ Output: Non

</div>

×