项目作者: enginoobz-projects
项目描述 :
A simple full-stack web application including RESTful Services to manage customer relationships, integrating database.
高级语言: Java
项目地址: git://github.com/enginoobz-projects/crm2-web-app.git
Customer Relationships Management Web Application - RESTful API (Spring Boot)



Features
General
- Database integration
- AOP Logging support
- Login/logout
CRUD UI/URLs
/customer/list
: shows list of customers/customer/showFormForAdd
: shows form for adding new customer/customer/showFormForUpdate
: shows form for modify existing customer/customer/delete/{id}
: deletes customer by id
CRUD RESTful APIs
- GET
/api/customers
: returns list of customers - GET
/api/customers/{id}
: returns customer by id - GET
/api/customers?page={number}
: returns list of customers at page number - GET
/api/customers?sort=lastName
: returns list of customers, ascending sort by last name - GET
/api/customers?sort=firstName,desc
: returns list of customers, descending sort by first name - POST
/api/customers
: adds new customer - PUT
/api/customers/{id}
: modifies customer by id - DELTE
/api/customers/{id}
: deletes customer by id - GET Actuator APIs
[List of built-in endpoints]
Security
- EMPLOYEE: view customers
- MANAGER: view customers, update customers, add customers
- ADMIN: view customers, update customers, add customers, delete customers
Development Process
Spring Boot
Configuration with dependencies
[Reference]
- Spring Web
- Thymeleaf
- MySQL Driver
- Spring Boot Actuator
- Spring Data JPA
- Rest Repositories (Spring Data REST)
- Spring Security
- Thymeleaf entries for Spring Security
[URL] - Spring Boot DevTools (Optional)
- Lombok (Optional)
Hibernate - Database
- Create MySQL database for Entity
[create-datebase-customer.sql] - Create MySQL database for Security
[create-datebase-security.sql]
[Reference] - Configure database connection (JDBC) in
application.properties - Configure data sources by Java (unnecessary if single data source)
[DataSourceConfig] - Create Entity classes
[Customer]
Spring Data JPA
- Create Repository interfaces extends JpaRepository
[CustomerRepository]
- Create Service interfaces
[CustomerService] - Create Service Implementation classes
[CustomerServiceRepository]
- Inject Repository (prefer by constructor)
Spring Data REST
Configure in
application.properties
[Reference]
Spring Boot Actuator
Configure in
application.properties
[Reference]
Spring MVC - Thymeleaf
- Create Controllers
[CustomerController] - Create HTML view pages
[list-customers.html]
- XML namespace
<html lang="en" xmlns:th="http://www.thymeleaf.org">
supports Thymeleaf.
- Create index file in
/static
to redirect to home page at startup (unnecessary if adding Security)
[index.html]
<meta http-equiv="refresh" content="0; URL='<path>'" />
Spring AOP
- Create an Aspect defining public common pointcuts
[CommonPointcuts] - Create specialized Aspects and define advices
[LoggingAspect]
Spring Security
- Configure Security by Java
[SecurityConfig]
[Reference] - Login page
[fancy-login.html] - Custom Access Denied page
[access-denied.html] - Update HTML view pages
[list-customers.html]
- XML namespace
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
supports Thymeleaf Security. - Attribute
sec:authorize="hasAnyRole('ROLE_<ROLE1>', 'ROLE_<ROLE2>')"
to display tags based on the role.
Notes/Tips