This is the 17th day of my participation in the Gwen Challenge in November. Check out the details: The last Gwen Challenge in 2021″

🍅 author home page: Java Li Yangyong access to source code contact

Preface:

Human will enter the information age, the network is more and more strongly involved in our life, more and more close to us. This is an era of knowledge economy, information is expanding and exploding at an unprecedented speed, the world of the future is the world of the network, to let our country keep pace with The Times in this information world, as the main force of the 21st century, we must be able to adapt to the high-tech society faster, The ability to acquire effective scientific information quickly and timely from the outside world and to disseminate scientific information is the quality of science. And the network just meets this requirement. Therefore, the network sales and e-commerce arises at the historic moment, which leads to the network cake sales system, the main purpose of the network egg cake sales system is to let people all over the country can buy their own egg cake at home. Traditional cake sales are mainly storefront based, to choose the right facade, a waste of money, sales are not optimistic. And the network cake sales system can not worry about the facade problem, the range of consumer groups is also expanded. You can save a lot of money and increase turnover. It is easy to be accepted and adopted because of its directness and unique characteristics. It is a practical software tool.

Main Functions

User role: Contains the following functions: View all cakes, user login and registration, view cake details, submit orders, view my order, view my shopping cart, confirm receipt, evaluation and other functions.

Administrator: administrator login, cake classification management, cake management, user management, order management.

Function screenshots:

Login and registration:

Home page function: cake browse purchase add shopping cart, etc

Main code implementation:

package com.smzy.controller;
 
import com.smzy.pojo.User;
import com.smzy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@Controller
@RequestMapping("/admin")
public class UserController {
    @Autowired
    private UserService userService;
 
    @RequestMapping("/listUser")
    public String findAll(Model model) {
        List<User> users = userService.findAll();
        model.addAttribute("users",users);
        return "admin/listUser";
    }
    @RequestMapping("/editUser")
    public String edit(Model model ,Integer id) {
        User user = userService.get(id);
        model.addAttribute("user",user);
        return "admin/editUser";
    }
 
    @RequestMapping("/updateUser")
    public String update(Integer id,String password) {
        userService.updatePassword(id,password);
        return "redirect:listUser"; }}Copy the code
package com.smzy.service;
 
import com.smzy.pojo.User;
 
import java.util.List;
 
public interface UserService {
 
    List<User> findAll(a);
 
    User get(Integer id);
 
    void updatePassword (Integer id ,String password);
 
    User get(String name,String password);
 
    boolean isExist(String name);
 
    void add(User user);
}
Copy the code

      
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
 
    <context:component-scan base-package="com.smzy.controller"/>
    <mvc:annotation-driven/>
    <mvc:default-servlet-handler/>
 
    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
        <property name="prefix" value="/WEB-INF/views/"/>
        <property name="suffix" value=".jsp"/>
    </bean>
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
 
    <mvc:interceptors>
        <mvc:interceptor>
            <mvc:mapping path="/ *"/>
            <bean class="com.smzy.interceptor.LoginInterceptor"/>
        </mvc:interceptor>
        <mvc:interceptor>
            <mvc:mapping path="/ *"/>
            <bean class="com.smzy.interceptor.OtherInterceptor"/>
        </mvc:interceptor>
 
    </mvc:interceptors>
</beans>
Copy the code

Database table design:

** Database name: ** sSM_dangAO_shop

** Issue: **V1.0.0

** Database table design description

Table admin

Serial number The name of the The data type The length of the Decimal places Allows null values A primary key The default value instructions
1 id int 10 0 N Y Administrator id
2 name varchar 255 0 N N Administrator username
3 password varchar 255 0 N N Administrator password

Table category

Serial number The name of the The data type The length of the Decimal places Allows null values A primary key The default value instructions
1 id int 10 0 N Y Unique index ID
2 name varchar 255 0 N N Classification of
3 img_url varchar 255 0 N N Classification detail map address

List the orders

Serial number The name of the The data type The length of the Decimal places Allows null values A primary key The default value instructions
1 id int 10 0 N Y Unique index ID
2 order_code varchar 255 0 N N The order number
3 address varchar 255 0 N N Shipping address
4 receiver varchar 255 0 N N Name of consignee
5 phone varchar 255 0 N N Mobile phone number
6 user_message varchar 255 0 N N User remarks
7 create_date datetime 19 0 N N Order Creation time
8 pay_date datetime 19 0 Y N Order payment time
9 delivery_date datetime 19 0 Y N The delivery date
10 confirm_date datetime 19 0 Y N Confirm receipt date
11 user_id int 10 0 Y N The corresponding user ID
12 status varchar 255 0 N N The order status

Order_item table

Serial number The name of the The data type The length of the Decimal places Allows null values A primary key The default value instructions
1 id int 10 0 N Y Unique index ID
2 product_id int 10 0 N N Corresponding Product ID
3 order_id int 10 0 Y N Corresponding order ID
4 user_id int 10 0 N N User ID
5 number int 10 0 Y N Quantity of the product to be purchased

The product table

Serial number The name of the The data type The length of the Decimal places Allows null values A primary key The default value instructions
1 id int 10 0 N Y Unique index ID
2 name varchar 255 0 N N Product name
3 sub_title varchar 255 0 Y N headings
4 price float 13 0 Y N The price
5 sale int 10 0 Y N sales
6 stock int 10 0 Y N inventory
7 description varchar 2000 0 N N Commodity description
8 brand varchar 255 0 N N brand
9 category_id int 10 0 Y N Id of the corresponding category

Table product_image

Serial number The name of the The data type The length of the Decimal places Allows null values A primary key The default value instructions
1 id int 10 0 N Y Unique index ID
2 product_id int 10 0 Y N Product ID

Table property

Serial number The name of the The data type The length of the Decimal places Allows null values A primary key The default value instructions
1 id int 10 0 N Y Unique index ID
2 name varchar 255 0 Y N The attribute name
3 category_id int 10 0 N N Id of the corresponding category

Table property_value

Serial number The name of the The data type The length of the Decimal places Allows null values A primary key The default value instructions
1 id int 10 0 N Y Unique index ID
2 product_id int 10 0 N N Corresponding Product ID
3 property_id int 10 0 N N Corresponding attribute ID
4 value varchar 255 0 Y N The value of the specific attribute

Chart review

Serial number The name of the The data type The length of the Decimal places Allows null values A primary key The default value instructions
1 id int 10 0 N Y Unique index ID
2 content varchar 4000 0 Y N Evaluation content
3 user_id int 10 0 N N The corresponding user ID
4 product_id int 10 0 N N The corresponding product ID
5 createDate datetime 19 0 Y N Evaluation of time

Watch the user

Serial number The name of the The data type The length of the Decimal places Allows null values A primary key The default value instructions
1 id int 10 0 N Y Unique index ID
2 name varchar 255 0 N N The user name
3 password varchar 255 0 N N The user password
4 email varchar 255 0 N N email
5 registTime timestamp 19 0 N N CURRENT_TIMESTAMP Registration time

To obtain source code contact:

Everyone likes, favorites, follows, comments, check the author’s homepage: Java Li Yangyong to get contact

Clocked articles updated 104/365 days

** 👇🏻👇🏻 🏻👇 👇

Excellent practical case of Java Project 100 Sets