——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Node.js≥14
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
❗没学过node.js的不要搞前后端分离项目
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot飘香水果购物平台(java+springboot+mybaits+vue+elementui+mysql)
环境需要
1.运行环境:最好是javajdk1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows7/8/101G内存以上;或者MacOS;
4.数据库:MySql5.7/8.0版本均可;
5.是否Maven项目:是;
技术栈
后端:SpringBoot+Mybaits
前端:Vue+elementui
使用说明
项目运行:
1.使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2.使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行mavenclean;maveninstall命令;
3.将项目中application.yml配置文件中的数据库配置改为自己的配置;
4.运行项目,在浏览器中输入地址:
前台地址:http://localhost:8080/springbootrpj39/front/index.html
后台地址
http://localhost:8080/springbootrpj39/admin/dist/index.html
管理员abo密码abo
用户:用户1密码:123456
注意项目文件路径中不能含有中文、空格、特殊字符等,否则图片会上传不成功。
——————————CodeStart——————————
用户管理控制层:
/**
- 用户
**/
@RestController
@RequestMapping(“user”)
public class UserController {
@Autowired
UserService userService;
@Autowired
UserDao dao;
@RequestMapping(“/test”)
R test() {
R r = new R();
return r.setCode(4000).setMsg(Constant.IMG_PATH).setData(dao.findAll());
@RequestMapping(“/queryInfoByAccount”)
R queryInfoByAccount(@RequestParam(“account”) String account) {
R r = new R();
if (StringUtil.isEmpty(account)){
return r.setCode(4000).setMsg(HttpMsg.INVALID_PARAM);
User loginUser = userService.queryInfo(account);
if (loginUser == null){
return r.setCode(4000).setMsg(HttpMsg.INVALID_USER);
return r.setCode(2000).setData(loginUser);
@RequestMapping(“/find”)
R find(@RequestParam(“page”) int page, @RequestParam(“searchKey”) String searchKey) {
R r = new R();
Map<String, Object> map = new HashMap<>();
List
if (users == null) {
return r.setCode(2000);
List
users.subList((page - 1) * Constant.PAGE_SIZE, page * Constant.PAGE_SIZE)
: users.subList((page - 1) * Constant.PAGE_SIZE, users.size());
int len = users.size() % Constant.PAGE_SIZE == 0 ? users.size() / Constant.PAGE_SIZE
: (users.size() / Constant.PAGE_SIZE + 1);
map.put(“items”, items);
map.put(“len”, len);
return r.setCode(2000).setData(map);
@RequestMapping(“/create”)
R create(@RequestBody User user) {
R r = new R();
int ans = userService.add(user);
if (ans == 1) {
return r.setCode(2000).setMsg(HttpMsg.ADD_USER_OK);
return r.setCode(4000).setMsg(HttpMsg.ADD_USER_FAILED);
@RequestMapping(“/update”)
R update(@RequestBody User user) {
R r = new R();
int ans = userService.update(user);
if (ans >= 0) {
return r.setCode(2000).setMsg(HttpMsg.UPDATE_USER_OK);
return r.setCode(4000).setMsg(HttpMsg.UPDATE_USER_FAILED);
@DeleteMapping(“/delete”)
R delete(@RequestParam(“id”) int id) {
R r = new R();
int ans = userService.delete(id);
if (ans == 1) {
return r.setCode(2000).setMsg(HttpMsg.DELETE_USER_OK);
return r.setCode(4000).setMsg(HttpMsg.DELETE_USER_FAILED);
订单管理控制层:
@RestController
@RequestMapping(“order”)
public class OrderController {
@Autowired
OrderService orderService;
@Autowired
UserDao userDao;
@Autowired
OrderDao orderDao;
@Autowired
FlowersDao flowersDao;
@RequestMapping(“/test”)
R test() {
R r = new R();
return r.setCode(4000).setMsg(Constant.IMG_PATH).setData(orderDao.findAll(null));
@RequestMapping(“/queryByAccount”)
R queryByAccount(@RequestParam(“account”) String account) {
R r = new R();
if (StringUtil.isEmpty(account)) {
return r.setCode(4000).setMsg(HttpMsg.INVALID_PARAM);
List
return r.setCode(2000).setData(orders);
@RequestMapping(“/find”)
R find(@RequestParam(“page”) int page, @RequestParam(“searchKey”) String searchKey, @RequestParam(“account”) String account) {
R r = new R();
Map<String, Object> map = new HashMap<>();
List
if (orders == null) {
return r.setCode(2000);
map.put(“items”, orders);
map.put(“len”, orders.size());
return r.setCode(2000).setData(map);
@RequestMapping(“/findAll”)
R findAll(@RequestParam(“page”) int page, @RequestParam(“searchKey”) String searchKey) {
R r = new R();
Map<String, Object> map = new HashMap<>();
List
if (orders == null) {
return r.setCode(2000);
List
orders.subList((page - 1) * Constant.PAGE_SIZE, page * Constant.PAGE_SIZE)
: orders.subList((page - 1) * Constant.PAGE_SIZE, orders.size());
int len = orders.size() % Constant.PAGE_SIZE == 0 ? orders.size() / Constant.PAGE_SIZE
: (orders.size() / Constant.PAGE_SIZE + 1);
List
for (Order item : items) {
User user = userDao.queryById(item.getUid());
OrderVo vo = new OrderVo();
vo.setAddress(user.getAddress()).setPhone(user.getPhone()).setUsername(user.getName())
.setAmount(item.getAmount()).setFlower(item.getFlower()).setId(item.getId())
.setUid(item.getUid()).setOrder_guid(item.getOrder_guid()).setPrice(item.getPrice())
.setState(item.getState());
vos.add(vo);
map.put(“items”, vos);
map.put(“len”, len);
return r.setCode(2000).setData(map);
@RequestMapping(“/update”)
R update(@RequestBody Order order) {
R r = new R();
int ans = orderService.update(order);
if (ans >= 0) {
return r.setCode(2000).setMsg(HttpMsg.UPDATE_USER_OK);
return r.setCode(4000).setMsg(HttpMsg.UPDATE_USER_FAILED);
@RequestMapping(“/changeState”)
R changeState(@RequestBody Order order) {
orderDao.changeState(order);
return new R().setCode(2000).setMsg(HttpMsg.UPDATE_ORDER_OK);
@DeleteMapping(“/delete”)
R delete(@RequestParam(“id”) int id) {
R r = new R();
int ans = orderService.delete(id);
if (ans == 1) {
return r.setCode(2000).setMsg(HttpMsg.DELETE_USER_OK);
return r.setCode(4000).setMsg(HttpMsg.DELETE_USER_FAILED);
购物车管理控制层:
@RestController
@RequestMapping(“cart”)
public class CartController {
@Autowired
CartService cartService;
@Autowired
OrderService orderService;
@Autowired
CartDao dao;
@Autowired
FlowersDao flowersDao;
@RequestMapping(“/test”)
R test() {
R r = new R();
return r.setCode(4000).setMsg(Constant.IMG_PATH).setData(dao.findAll());
@RequestMapping(“/queryByAccount”)
R queryByAccount(@RequestParam(“account”) String account) {
R r = new R();
if (StringUtil.isEmpty(account)) {
return r.setCode(4000).setMsg(HttpMsg.INVALID_PARAM);
List
for (Cart cart : carts) {
float price = flowersDao.queryPrice(cart.getFid());
cart.setPrice(cart.getAmount() * price);
return r.setCode(2000).setData(carts);
@RequestMapping(“/find”)
R find(@RequestParam(“page”) int page, @RequestParam(“searchKey”) String searchKey, @RequestParam(“account”) String account) {
R r = new R();
Map<String, Object> map = new HashMap<>();
List
if (carts == null) {
return r.setCode(2000);
List
carts.subList((page - 1) * Constant.PAGE_SIZE, page * Constant.PAGE_SIZE)
: carts.subList((page - 1) * Constant.PAGE_SIZE, carts.size());
int len = carts.size() % Constant.PAGE_SIZE == 0 ? carts.size() / Constant.PAGE_SIZE
: (carts.size() / Constant.PAGE_SIZE + 1);
map.put(“items”, items);
map.put(“len”, len);
return r.setCode(2000).setData(map);
@RequestMapping(“/buy”)
R buy(@RequestParam(“account”) String account) {
R r = new R();
// 查该用户的购物车
List
for (Cart cart : carts) {
// 增加订单数据
orderService.add(cart);
// 删除购物车数据
cartService.delete(cart.getId());
return r.setCode(2000).setMsg(HttpMsg.BUY_OK);
@RequestMapping(“/create”)
R create(@RequestBody Cart cart) {
R r = new R();
int ans = cartService.add(cart);
if (ans == 1) {
return r.setCode(2000).setMsg(HttpMsg.ADD_CART_OK);
return r.setCode(4000).setMsg(HttpMsg.ADD_CART_FAILED);
@RequestMapping(“/update”)
R update(@RequestBody Cart cart) {
R r = new R();
int ans = cartService.update(cart);
if (ans >= 0) {
return r.setCode(2000).setMsg(HttpMsg.UPDATE_USER_OK);
return r.setCode(4000).setMsg(HttpMsg.UPDATE_USER_FAILED);
@DeleteMapping(“/delete”)
R delete(@RequestParam(“id”) int id) {
R r = new R();
int ans = cartService.delete(id);
if (ans == 1) {
return r.setCode(2000).setMsg(HttpMsg.DELETE_USER_OK);
return r.setCode(4000).setMsg(HttpMsg.DELETE_USER_FAILED);
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=381125140706201st
https://javayms.pages.dev?id=381125140706201st