基于javaweb的SpringBoot农资商城购物商城(java+springboot+vue+mybatis+mysql+maven)

运行环境

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

开发工具

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

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

适用

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

功能说明

001923592708

011923592708

541923582708

561923582708

571923582708

581923582708

591923582708

基于javaweb的SpringBoot农资商城购物商城(java+springboot+vue+mybatis+mysql+maven)

启动步骤:

1 双击打开【Redis-64bit/redis-server.exe】

2 启动后端:com.alex.shopping.StartApplication

3 启动前端:npm run serve

1
2
3
4
5
6
7
8
9
管理员
admin@qq.com 123456

卖家
business@qq.com 123456
business1@qq.com 123456

买家
buyer@qq.com 123456

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

@PutMapping("/password")
public Result updatePassword(@RequestBody String password){
return userService.updatePassword(password);
}
}



@Service
@Transactional
public class ImageServiceImpl implements ImageService {
public static SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy_MM_dd");

@Value("${shopping.image.savePath}")
private String IMAGE_PATH;
@Value("${shopping.image.maxSize}")
private long IMAGE_MAXSIZE;
@Autowired
private ImageMapper imageMapper;

@Autowired
private UserService userService;
/**
* 图片文件上传
* @param file
* @return
*/
@Override
public Result uploadImage(MultipartFile file) {
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
/**
* 设置cookie 有效期默认365day
* @param key
* @param value
* @param response
*/
public static void setCookie(String key, String value, HttpServletResponse response){
setCookie(key,value,DEFAULT_AGE,response);
}

/**
* 设置cookie
* @param key 关键字
* @param value 值
* @param age 有效期
* @param response
*/
public static void setCookie(String key, String value, int age,HttpServletResponse response){
Cookie cookie = new Cookie(key,value);
cookie.setDomain(DOMAIN);
cookie.setPath("/");
cookie.setMaxAge(age);
response.addCookie(cookie);
}

/**
* 获取cookie
* @param key
* @param request
* @return
*/
public static Cookie getCookie(String key, HttpServletRequest request){
if (request.getCookies()==null){
return null;
}
for (Cookie cookie : request.getCookies()) {
if (cookie.getName().equals(key)){
return cookie;
}
}

return null;
}
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
50
 * 审核通过
* @param productId
* @return
*/
@PostMapping("/examine_on/{productId}")
public Result examineOn(@PathVariable("productId")String productId){
return productService.examineOn(productId);
}

/**
* 审核失败
* @param productId
* @return
*/
@PostMapping("/examine_off/{productId}")
public Result examineOff(@PathVariable("productId")String productId){
return productService.examineOff(productId);
}
/**
* 添加产品
* @param product
* @return
*/
@PostMapping("/add")
public Result addProduct(@RequestBody Product product){
return productService.addProduct(product);

}

/**
* 更新产品信息
* @param product
* @return
*/
@PostMapping("/update")
public Result updateProduct(@RequestBody Product product){
return productService.updateProduct(product);
}

/**
* 删除产品
* @param productId
* @return
*/
@DeleteMapping("/delete/{productId}")
public Result deleteProduct(@PathVariable("productId") String productId){
return productService.deleteProductById(productId);
}

/**
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
            }
os.flush();
}catch (Exception e){
e.printStackTrace();
}finally {
if (os!=null){
os.close();
}
if (fis!=null){
fis.close();
}
}
}
}


@RestController
@RequestMapping("/product")
public class ProductController {
@Autowired
private ProductService productService;

/**
* 获取商品
* @return
*/
@GetMapping("/list")
public Result list(){
return productService.list();
}


/**
* 管理员获取商品信息
* @param page
* @param size
* @param name
* @return
*/
@GetMapping("/list/admin/{page}/{size}")
public Result listAdmin(@PathVariable("page") int page,@PathVariable("size")int size,
@RequestParam(value = "name",required = false)String name,
@RequestParam(value="email",required=false)String email){
return productService.listAdmin(page,size,name,email);
}
/**
* 管理员获取审核商品信息
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
    QueryWrapper<User> wrapper = new QueryWrapper<>();
//条件查询
if (userName!=null){
wrapper.like("user_name",userName);
}
if (email!=null) {
wrapper.like("email",email);
}
IPage<User> userPage = userMapper.selectPage(pageDB, wrapper);
if (userPage.getRecords().size()==0){
return Result.FAILED("无数据");
}

return Result.SUCCESS("获取成功").setData(userPage);
}

@Override
public Result banUserByEmail(String email) {
User user = getUserByEmail(email);
if (user==null||user.getRoles()==0){
return Result.FAILED("封禁失败");
}

user.setStatus(Constants.User.STATUS_ABNORMAL);
userMapper.updateById(user);
return Result.SUCCESS("封禁成功");
}

@Override
public Result removeBanUserByEmail(String email) {
User user = getUserByEmail(email);
if (user==null){
return Result.FAILED("解禁失败");
}
user.setStatus(Constants.User.STATUS_NORMAL);
userMapper.updateById(user);
return Result.SUCCESS("解禁成功");
}

@Override
public Result resetPassword(String email) {
User user = getUserByEmail(email);
if (user==null){
return Result.FAILED("重置失败");
}

user.setPassword(resetPassword);//需要加密
userMapper.updateById(user);
return Result.SUCCESS("重置成功!重置密码为"+resetPassword);


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