基于javaweb的SpringBoot花店商城系统(java+springboot+maven+mybatis+vue+mysql)

运行环境

Java≥8、MySQL≥5.7、Node.js≥14

开发工具

后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可

❗没学过node.js的不要搞前后端分离项目

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

410123032402

420123032402

430123032402

440123032402

450123032402

460123032402

基于javaweb的SpringBoot花店商城系统(java+springboot+maven+mybatis+vue+mysql)

1
2
3
4
5
管理员:
admin 123456

用户
user 123456

一、项目简述 本系统功能包括: 商品的分类展示,用户的注册登录,购物车,订单结算,购物车加减,后台商品管理,分类管理,订单管理等等功能。

二、项目运行 环境配置:

Jdk1.8 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。

项目技术:

Springboot + Maven + mybatis+ Vue 等等组成,B/S模式 + Maven管理等等。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
    return r.setCode(4000).setMsg(HttpMsg.ADD_FLOWER_FAILED);
}

@RequestMapping("/update")
R update(@RequestBody Flower flower) {
R r = new R();
int ans = flowerService.update(flower);
if (ans >= 0) {
return r.setCode(2000).setMsg(HttpMsg.UPDATE_FLOWER_OK);
}
return r.setCode(4000).setMsg(HttpMsg.UPDATE_FLOWER_FAILED);
}

@RequestMapping("/changeState")
R changeState(@RequestBody Flower flower) {
R r = new R();
flowersDao.changeState(flower);
String msg = flower.getState() == 1?HttpMsg.GOODS_UP_OK:HttpMsg.GOODS_DOWN_OK;
return r.setCode(2000).setMsg(msg);
}

// 保存上传的图片
@RequestMapping("/updateImg")
R updateImg(@RequestParam("file") MultipartFile file) {
R r = new R();
// 只接收 jpg/png 图片
String filename = file.getOriginalFilename();
if (!filename.endsWith(".jpg") && !filename.endsWith(".png")){
return r.setCode(4000).setMsg(HttpMsg.ERROR_FILE_TYPE);
}
String img_guid = UUID.randomUUID().toString().replaceAll("-", "") + ".jpg";
try {
savePic(file.getInputStream(), img_guid);
return r.setCode(2000).setMsg(HttpMsg.UPDATE_PIC_OK).setData(img_guid);
} catch (IOException e) {
return r.setCode(4000).setMsg(HttpMsg.UPDATE_PIC_FAILED);
}
}

@PutMapping("/updateImgGuid")
R updateImgGuid(@RequestParam("guid") String guid, @RequestParam("id") int id) {
R r = new R();
int ans = flowerService.updateImg(guid, id);
if (ans == 1) {
return r.setCode(2000).setMsg(HttpMsg.UPDATE_PIC_OK);
}
return r.setCode(4000).setMsg(HttpMsg.UPDATE_PIC_FAILED);
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
}

package com.hide.backend.config;


/**
*/
@Component
public class ProcessInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
httpServletResponse.setHeader("Access-Control-Allow-Origin", "*");
httpServletResponse.setHeader("Access-Control-Allow-Headers", "Content-Type,Content-Length, Authorization, Accept,X-Requested-With");
httpServletResponse.setHeader("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
httpServletResponse.setHeader("X-Powered-By","Jetty");
String method= httpServletRequest.getMethod();
if (method.equals("OPTIONS")){
httpServletResponse.setStatus(200);
return false;
}
return true;
}

@Override
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
}

@Override
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
}
}
package com.hide.backend.controller;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43



/**
* 用户
**/
@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<Cart> carts = cartService.queryByAccount(account);
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<>();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
        return true;
}

@Override
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
}

@Override
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
}
}
package com.hide.backend.controller;



/**
* 登录
**/
@RestController
@RequestMapping("login")
public class LoginController {
@Autowired
LoginDao loginDao;

@RequestMapping("/doLogin")
R doLogin(@RequestBody LoginForm form) {
R r = new R();
if (!VerifyUtil.verifyLoginForm(form)) {
return r.setCode(4000).setMsg(HttpMsg.ERROR_INPUT);
}
User loginUser = loginDao.login(form);
if (loginUser != null) {
return r.setCode(2000).setMsg("欢迎您:" + loginUser.getName()).setData(loginUser);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
        }
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);
}
}

package com.hide.backend.controller;


项目链接:
https://javayms.github.io?id=251222062008200wx
https://javayms.pages.dev?id=251222062008200wx