文末获取源码
项目背景
随着社会的发展,社会的各行各业都在利用信息化时代的优势。计算机的优势和普及使得各种信息系统的开发成为必需。
生鲜食品o2o商城系统,主要的模块包括查看管理员;首页、个人中心、用户管理、商品分类管理、商品细类管理、商品类型管理、商品信息管理、折扣商品管理、新品上市管理、商品评价管理、系统管理、订单管理等等。前台;首页、商品信息、折扣商品、新品上市、新闻资讯、我的个人中心、后台管理、购物车、客服等等。用户后台:个人中心、个人信息、商品信息管理、商品评价管理、我的收藏管理、订单管理等等。系统中管理员主要是为了安全有效地存储和管理各类信息,还可以对系统进行管理与更新维护等操作,并且对后台有相应的操作权限。
要想实现生鲜食品o2o商城系统的各项功能,需要后台数据库的大力支持。管理员验证注册信息,收集的用户信息,并由此分析得出的关联信息等大量的数据都由数据库。本文中数据库服务器端采用了Mysql作为后台数据库,使Web与数据库紧密联系起来。在设计过程中,充分保证了系统代码的良好可读性、实用性、易扩展性、通用性、便于后期维护、操作方便以及页面简洁等特点。
本系统的开发使获取生鲜食品o2o商城系统 信息能够更加方便快捷,同时也使生鲜食品o2o商城系统管理信息变的更加系统化、有序化。系统界面较友好,易于操作。
功能设计
功能模块图
系统业务流程图
功能截图
用户进入生鲜食品o2o商城系统注册页面填写用户名、密码、姓名、手机、邮箱操作等等。并可以进行登录。
用户在登录填写账号、密码、等信息
用户进入个人信息页面可以修改用户名、密码、姓名、手机、邮箱、充值金额等等。
用户前台可以对商品信息浏览并查看价格、类型、分类、价格、细化、规格、产地、购买等信息进行操作
用户进入折扣商品界面查看价格、单次购买、库存、类型、购买、活动时间等操作。
用户进入购物车界面填写购买商品、价格、数量、总价可以进行点击购买等操作。程序效果图
用户进入商品信息查看商品名称、类型、分类、细类、规格、产地、品牌、倒计结束、价格、单限、库存、详情、评论查看等操作。
用户进入我的收藏界面查看我的前台收藏信息查看等操作。
用户进入我的订单界面查看我的订单信息查看订单编号、商品编号、商品名称、购买数量、价格/积分、总价格/总积分、折扣总价格、支付类型、状态、地址等操作。
管理员通过输入用户名,密码,权限,等信息进行系统登录
进入生鲜食品o2o商城系统查看首页、个人中心、用户管理、商品分类管理、商品细类管理、商品类型管理、商品信息管理、折扣商品管理、新品上市管理、商品评价管理、系统管理、订单管理等等等内容
管理员对个人中心进行操作填写原密码、新密码、确认密码并进行添加、删除、修改以及查看
在用户管理页面可以查看用户名、密码、姓名、性别、头像、手机、邮箱等内容,并可根据需要对用户管理进行添加,修改或删除等操作
类型、分类、细类、规格、产地、品牌、倒计结束、价格、单限、库存、详情等等进行添加,修改,删除或查看详细内容等操作
在新品上市管理页面可以查看名称、类型、分类、细类、规格、产地、品牌价格等内容,并可根据需要对新品上市管理信息进行添加,修改,删除或详细内容等操作
该页面为轮播图/新闻资讯管理界面。管理员可以在此页面进行首页轮播图/新闻资讯的管理进行添加,修改,删除或详细内容等操作
在订单信息管理页面可以查看通过列表可以查看订单编号、商品编号、商品名称、购买数量、价格/积分、总价格/总积分、折扣总价格、支付类型、状态、地址、支付等信息进行操作或修改删除等内容
相关代码
数据库配置
# Tomcat
server:
tomcat:
uri-encoding: UTF-8
port: 8080
servlet:
context-path: /springbootr1tjf
spring:
datasource:
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/springbootr1tjf?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
username: root
password: 123456
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=springbootr1tjf
# username: sa
# password: 123456
servlet:
multipart:
max-file-size: 10MB
max-request-size: 10MB
resources:
static-locations: classpath:static/,file:static/
#mybatis
mybatis-plus:
mapper-locations: classpath*:mapper/*.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.entity
global-config:
#主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
id-type: 1
#字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
field-strategy: 2
#驼峰下划线转换
db-column-underline: true
#刷新mapper 调试神器
refresh-mapper: true
#逻辑删除配置
logic-delete-value: -1
logic-not-delete-value: 0
#自定义SQL注入器
sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true
#springboot 项目mybatis plus 设置 jdbcTypeForNull (oracle数据库需配置JdbcType.NULL, 默认是Other)
jdbc-type-for-null: 'null'
控制层(controller)
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.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);
UserEntity u = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername()));
if(u!=null && u.getId()!=user.getId() && u.getUsername().equals(user.getUsername())) {
return R.error("用户名已存在。");
}
userService.updateById(user);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
userService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
}
业务层(Service)
package com.service;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.IService;
import com.entity.UserEntity;
import com.utils.PageUtils;
/**
* 系统用户
*/
public interface UserService extends IService<UserEntity> {
PageUtils queryPage(Map<String, Object> params);
List<UserEntity> selectListView(Wrapper<UserEntity> wrapper);
PageUtils queryPage(Map<String, Object> params,Wrapper<UserEntity> wrapper);
}
数据访问层(Dao)
package com.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.entity.UserEntity;
/**
* 用户
*/
public interface UserDao extends BaseMapper<UserEntity> {
List<UserEntity> selectListView(@Param("ew") Wrapper<UserEntity> wrapper);
List<UserEntity> selectListView(Pagination page,@Param("ew") Wrapper<UserEntity> wrapper);
}