Design and implementation of large shopping mall membership management system based on SSM

Get the source code at the end
Development language: Java
Java development tool: JDK1.8
Back-end framework: SSM
Front-end: developed using JSP technology
Database: MySQL5.7 combined with Navicat management tools
Server: Tomcat8.5
Development software: IDEA/Eclipse
Whether it is a Maven project: yes


Table of contents

1. Project Introduction

2. System design

Layout design principles

3. System project screenshots

Employee management

Member information management

Product management

Member information query

Add new order

View purchase order details

4. Core code

4.1 Login related

4.2 File upload

4.3 Packaging


1. Project Introduction

Since entering the information age, a lot of data needs supporting software to assist in processing, which can solve the management problems caused by traditional methods. For example, it is time-consuming, high cost, difficult to maintain data, and easy to lose data. This large-scale shopping mall member management system developed using the database tool MySQL and the programming framework SSM can achieve the functions required by the target user group, including member information management, product information management, purchase order management, purchase order details management and other functions.

In short, the membership management system of large shopping malls is based on computer-based data processing, so it can complete data management in batches in a short time. Even basic data entry, changing wrong data, statistical data and other operational requirements can be easily completed. The use of the system can reduce a lot of tedious workload, allow data managers to improve efficiency, and save money and time invested in data processing. At the same time, the membership management system of large shopping malls itself has a supporting database to save the background data of the system. The capacity of data storage is incomparable to the traditional model. In terms of data security, there are also corresponding encryption technologies to provide protection. So data breaches and being stolen are not easy.


2. System design

When designing, user needs are usually considered as the focus of system functions and database design. However, when designing systems, focusing on user experience is also a key design content. For example, a system has implemented the functions that users need, but its interface layout is relatively confusing, and the combination of various elements in the interface is also unreasonable. In this way, once visitors access the system, they will not be able to find the required information in a short period of time, which will easily cause visual confusion. Fatigue directly affects the user's use of the system. Therefore, when designing the system, we also need to pay attention to the user experience. Due to differences between users, such as education level, occupation, region and other factors, there will also be differences in the behavior of users. Therefore, designers must consider both the behavioral differences between users and the commonalities between them. Design and layout the page on the basis of respecting user habits. This enables users to access the system multiple times.

Layout design principles

To lay out the page, we need to divide the various modules of the system, and then lay out the modules according to their importance. We also need to pay attention to the key information that users care about, and use reasonable layout methods to convey the information content that the system wants to express, and also Allow users to obtain the information they need quickly and efficiently. Although layout is the core of page design, we must also pay attention to the coordination, unity and balance of page content.

Layout design should also consider basic principles, which will be explained in the following content.

The first point: refer to the system requirements, divide the system content, lay it out according to different levels of importance, and display similar or similar information content in the same area, so that visitors can read the information more smoothly;

Second point: The more important area in the page is the top and left position, so this area should be placed with the more important modules in the system. After all, this area can attract the user's attention, allowing users to enter the page and find their needs. Information. For some minor modules, they can be placed at the bottom and right of the page. Only with this design arrangement can the practical features of page design be brought into play;

The third point: Design the page based on user habits. Although most users have common operating characteristics, there are still differences between them. Common factors that affect user operating habits include: age, education, occupation, gender, etc. Therefore, when considering the common characteristics of users during design, it is also necessary to try to respect the different habits of users.



3. System project screenshots

Employee management

Managing employees is the function of the administrator. Its operation effect diagram is as follows. Administrators can add employees, query employees, delete employees, and modify employee information on this page.

Member information management

Managing member information is the function of the administrator. Its operation effect diagram is as follows. Administrators can view members' points, points levels and usage status information. Administrators can add members, delete members, and modify member information.

 

Product management

Managing products is the function of the administrator. Its operation effect diagram is as follows. Administrators can modify the unit price, quantity and type information of products, delete products, and query product information.

 

Member information query

Querying member information is a function of employees. Its operation effect diagram is as follows. Employees can search for members and view member details on the current page.

 

Add new order

Adding new orders is a function of employees. Its operation effect diagram is as follows. The employee adds the goods that the member needs to purchase, and finally selects the membership card to submit the order and check out.

 

View purchase order details

The employee views the purchase order details in the current module, and its operation effect is as follows. Employees query the details of the purchase order and view the details of the purchase order, including the operator, purchased goods and quantity.

 


4. Core code

4.1 Login related


package com.controller;


import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;

/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UserController{
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private TokenService tokenService;

	/**
	 * 登录
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
		if(user==null || !user.getPassword().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		return R.ok().put("token", token);
	}
	
	/**
	 * 注册
	 */
	@IgnoreAuth
	@PostMapping(value = "/register")
	public R register(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

	/**
	 * 退出
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
    	user.setPassword("123456");
        userService.update(user,null);
        return R.ok("密码已重置为:123456");
    }
	
	/**
     * 列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,UserEntity user){
        EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
    	PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/list")
    public R list( UserEntity user){
       	EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
      	ew.allEq(MPUtil.allEQMapPre( user, "user")); 
        return R.ok().put("data", userService.selectListView(ew));
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);
        userService.updateById(user);//全部更新
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        userService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

4.2 File upload

package com.controller;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;

/**
 * 上传文件映射表
 */
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
	@Autowired
    private ConfigService configService;
	/**
	 * 上传文件
	 */
	@RequestMapping("/upload")
	public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
		if (file.isEmpty()) {
			throw new EIException("上传文件不能为空");
		}
		String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
		File path = new File(ResourceUtils.getURL("classpath:static").getPath());
		if(!path.exists()) {
		    path = new File("");
		}
		File upload = new File(path.getAbsolutePath(),"/upload/");
		if(!upload.exists()) {
		    upload.mkdirs();
		}
		String fileName = new Date().getTime()+"."+fileExt;
		File dest = new File(upload.getAbsolutePath()+"/"+fileName);
		file.transferTo(dest);
		FileUtils.copyFile(dest, new File("C:\\Users\\Desktop\\jiadian\\springbootl7own\\src\\main\\resources\\static\\upload"+"/"+fileName));
		if(StringUtils.isNotBlank(type) && type.equals("1")) {
			ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
			if(configEntity==null) {
				configEntity = new ConfigEntity();
				configEntity.setName("faceFile");
				configEntity.setValue(fileName);
			} else {
				configEntity.setValue(fileName);
			}
			configService.insertOrUpdate(configEntity);
		}
		return R.ok().put("file", fileName);
	}
	
	/**
	 * 下载文件
	 */
	@IgnoreAuth
	@RequestMapping("/download")
	public ResponseEntity<byte[]> download(@RequestParam String fileName) {
		try {
			File path = new File(ResourceUtils.getURL("classpath:static").getPath());
			if(!path.exists()) {
			    path = new File("");
			}
			File upload = new File(path.getAbsolutePath(),"/upload/");
			if(!upload.exists()) {
			    upload.mkdirs();
			}
			File file = new File(upload.getAbsolutePath()+"/"+fileName);
			if(file.exists()){
				/*if(!fileService.canRead(file, SessionManager.getSessionUser())){
					getResponse().sendError(403);
				}*/
				HttpHeaders headers = new HttpHeaders();
			    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);    
			    headers.setContentDispositionFormData("attachment", fileName);    
			    return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
	}
	
}

4.3 Packaging

package com.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 */
public class R extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	
	public R() {
		put("code", 0);
	}
	
	public static R error() {
		return error(500, "未知异常,请联系管理员");
	}
	
	public static R error(String msg) {
		return error(500, msg);
	}
	
	public static R error(int code, String msg) {
		R r = new R();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}

	public static R ok(String msg) {
		R r = new R();
		r.put("msg", msg);
		return r;
	}
	
	public static R ok(Map<String, Object> map) {
		R r = new R();
		r.putAll(map);
		return r;
	}
	
	public static R ok() {
		return new R();
	}

	public R put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}

Guess you like

Origin blog.csdn.net/weixin_52721608/article/details/132899775