This repository has been archived by the owner on Dec 31, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c0a47c
commit 0f3bd82
Showing
16 changed files
with
1,276 additions
and
1 deletion.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/main/java/io/hardingadonis/miu/controller/admin/ListCategoryServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.hardingadonis.miu.controller.admin; | ||
|
||
import io.hardingadonis.miu.dao.impl.mysql.CategoryDAOMySQLImpl; | ||
import io.hardingadonis.miu.model.Category; | ||
import io.hardingadonis.miu.services.Singleton; | ||
import java.io.*; | ||
import java.util.*; | ||
import javax.servlet.*; | ||
import javax.servlet.annotation.MultipartConfig; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.*; | ||
|
||
@WebServlet(name = "ListCategoryServlet", urlPatterns = {"/listCategory"}) | ||
@MultipartConfig | ||
public class ListCategoryServlet extends HttpServlet { | ||
|
||
@Override | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
request.setCharacterEncoding("UTF-8"); | ||
response.setContentType("text/html; charset=UTF-8"); | ||
|
||
request.getRequestDispatcher("/view/admin/list_category.jsp").forward(request, response); | ||
|
||
} | ||
|
||
@Override | ||
protected void doPost(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
request.setCharacterEncoding("UTF-8"); | ||
response.setContentType("text/html; charset=UTF-8"); | ||
|
||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/io/hardingadonis/miu/controller/admin/LoginAdmin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package io.hardingadonis.miu.controller.admin; | ||
|
||
import io.hardingadonis.miu.model.Admin; | ||
import io.hardingadonis.miu.services.Hash; | ||
import io.hardingadonis.miu.services.Singleton; | ||
import java.io.*; | ||
import javax.servlet.*; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.*; | ||
|
||
@WebServlet(name = "LoginAdmin", urlPatterns = {"/admin/login"}) | ||
public class LoginAdmin extends HttpServlet { | ||
|
||
@Override | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
request.setCharacterEncoding("UTF-8"); | ||
response.setContentType("text/html; charset=UTF-8"); | ||
request.getRequestDispatcher("/view/admin/login-admin.jsp").forward(request, response); | ||
|
||
} | ||
|
||
@Override | ||
protected void doPost(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
request.setCharacterEncoding("UTF-8"); | ||
response.setContentType("text/html; charset=UTF-8"); | ||
|
||
String username = request.getParameter("username"); | ||
String password = request.getParameter("password"); | ||
|
||
Admin ad = Singleton.adminDAO.get(username); | ||
|
||
if (ad != null && ad.getHashedPassword().equals(Hash.SHA256(password))) { | ||
HttpSession session = request.getSession(); | ||
session.setAttribute("admin", ad); | ||
response.sendRedirect(request.getContextPath() + "/admin"); | ||
return; | ||
} | ||
|
||
String errorMsg = "Sai mật khẩu!"; | ||
|
||
if (ad == null) { | ||
errorMsg = "Tài khoản không tồn tại!"; | ||
username = null; | ||
} | ||
|
||
request.setAttribute("username", username); | ||
request.setAttribute("errorMsg", errorMsg); | ||
|
||
this.doGet(request, response); | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/io/hardingadonis/miu/controller/admin/ProductManagement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package io.hardingadonis.miu.controller.admin; | ||
|
||
import io.hardingadonis.miu.services.Singleton; | ||
import java.io.*; | ||
import javax.servlet.*; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.*; | ||
import org.json.simple.JSONObject; | ||
|
||
@WebServlet(name = "ProductManagement", urlPatterns = {"/productmanagement"}) | ||
public class ProductManagement extends HttpServlet { | ||
|
||
@Override | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
request.setCharacterEncoding("UTF-8"); | ||
response.setContentType("text/html; charset=UTF-8"); | ||
|
||
request.getRequestDispatcher("/view/admin/product-management.jsp").forward(request, response); | ||
} | ||
|
||
@Override | ||
protected void doPost(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
// Handle form submission here | ||
} | ||
|
||
@Override | ||
protected void doDelete(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
try { | ||
int ID = Integer.parseInt(request.getParameter("id")); | ||
|
||
Singleton.productDAO.delete(ID); | ||
|
||
JSONObject jsonResponse = new JSONObject(); | ||
jsonResponse.put("status", "success"); | ||
jsonResponse.put("message", "User canceled successfully"); | ||
|
||
response.setContentType("application/json"); | ||
response.getWriter().write(jsonResponse.toString()); | ||
|
||
response.setStatus(HttpServletResponse.SC_OK); | ||
|
||
} catch (NumberFormatException ex) { | ||
System.err.println(ex.getMessage()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
* { | ||
font-family: 'Poppins', sans-serif; | ||
} | ||
|
||
.wrapper { | ||
background-color: #ececec; | ||
padding: 0 20px | ||
} | ||
|
||
.main { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
min-height: 100vh; | ||
} | ||
|
||
.row { | ||
width: 900px; | ||
height: 550px; | ||
border-radius: 5px; | ||
background: #ffffff; | ||
box-shadow: 5px 5px 10px 1px rgba(0, 0, 0, 0.2); | ||
} | ||
|
||
.side-image { | ||
background-image: url('../../images/covers/c6419bc9eefa9633ddf424d5ea8f077c928fc477e02ed34eda6f26be1ac5f195.jpg'); | ||
background-position: center center; | ||
background-size: cover; | ||
background-repeat: no-repeat; | ||
position: relative; | ||
border-radius: 5px 0 0 5px; | ||
} | ||
|
||
.right { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
position: relative; | ||
} | ||
|
||
.input-box { | ||
width: 330px; | ||
box-sizing: border-box; | ||
} | ||
|
||
.input-box header { | ||
font-weight: 700; | ||
font-size: 25px; | ||
text-align: center; | ||
margin-bottom: 45px; | ||
} | ||
|
||
.input-field { | ||
display: flex; | ||
flex-direction: column; | ||
position: relative; | ||
padding: 0 10px; | ||
} | ||
|
||
.eye { | ||
flex-direction: row; | ||
} | ||
|
||
.show-password-toggle{ | ||
padding-top: 20px; | ||
height: 45px; | ||
border: none; | ||
border-bottom: 1px solid rgba(0, 0, 0, 0.2); | ||
} | ||
|
||
.input { | ||
height: 45px; | ||
width: 100%; | ||
background: transparent; | ||
border: none; | ||
border-bottom: 1px solid rgba(0, 0, 0, 0.2); | ||
outline: none; | ||
margin-bottom: 20px; | ||
color: #40414a; | ||
} | ||
|
||
.input-box .input-field label { | ||
position: absolute; | ||
top: 10px; | ||
left: 10px; | ||
pointer-events: none; | ||
transition: .3s; | ||
} | ||
|
||
.input-field .input:focus ~ label { | ||
top: -10px; | ||
font-size: 13px; | ||
} | ||
|
||
.input-field .input:valid ~ label { | ||
top: -10px; | ||
font-size: 13px; | ||
color: rgb(33, 37, 41); | ||
} | ||
|
||
.input-field .input:focus, .input-field .input:valid { | ||
border-bottom: 1px solid rgb(33, 37, 41); | ||
} | ||
|
||
.submit { | ||
border: none; | ||
outline: none; | ||
height: 45px; | ||
background: #ececec; | ||
border-radius: 5px; | ||
transition: .2s; | ||
} | ||
|
||
.submit:hover { | ||
background: rgba(33, 37, 41, 0.9); | ||
color: #ffffff; | ||
} | ||
|
||
.register { | ||
text-align: center; | ||
font-size: small; | ||
margin-top: 25px; | ||
} | ||
|
||
span a { | ||
text-decoration: none; | ||
font-weight: 700; | ||
color: #000000; | ||
transition: .5s; | ||
} | ||
|
||
span a:hover { | ||
text-decoration: underline; | ||
color: #000000; | ||
} | ||
|
||
@media only screen and (max-width: 768px) { | ||
.side-image { | ||
border-radius: 5px 5px 0 0; | ||
} | ||
|
||
.row { | ||
max-width: 420px; | ||
width: 100%; | ||
} | ||
} |
Oops, something went wrong.