基于javaweb的SpringBoot网上超市线上购物系统(java+springboot+maven+mysql+thymeleaf+html)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

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

功能说明

072223432309

082223432309

092223432309

102223432309

112223432309

122223432309

142223432309

152223432309

162223432309

172223432309

基于javaweb的SpringBoot网上超市线上购物系统(java+springboot+maven+mysql+thymeleaf+html)

管理员:
admin 123456

用户:
13511111111 123456
13511111112 123456
13511111113 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
     * 保存界面
* @param model
* @param id
* @return
* @throws Exception
*/
@RequestMapping("save.htm")
public String save(Model model,String id)throws Exception{
CustomerEntity entity = new CustomerEntity();
if(!StringUtils.isEmpty(id)){
entity = service.selectById(id);
}
model.addAttribute("entity",entity);
return "customer/save";
}

/**
* 保存
* @param model
* @return
* @throws Exception
*/
@RequestMapping("saveData.htm")
@ResponseBody
public Result save(Model model, CustomerEntity entity)throws Exception{
if(StringUtils.isEmpty(entity.getId())){
entity.setId(IdWorkerUtil.getId());
service.insert(entity);
}else{
if(entity.getAuthStatus()==2){
entity.setType(2);
}
service.updateById(entity);
}
return Result.success("保存成功");
}

/**
* 删除
* @param id
* @return
* @throws Exception
*/
@PostMapping("del.htm")
@ResponseBody
public Result del(String id)throws Exception{
service.deleteById(id);
return Result.success("保存成功");
}

}
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
        return Result.success("保存成功");
}

/**
* 删除
* @param id
* @return
* @throws Exception
*/
@PostMapping("del.do")
@ResponseBody
public Result del(String id)throws Exception{
service.deleteById(id);
return Result.success("保存成功");
}
}



/**
* 商品管理
*/
@Controller
@RequestMapping("customer")
public class CustomerController {

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
51
52
53
54
 */
@RequestMapping("save.htm")
public String save(Model model,String id)throws Exception{
EntityWrapper entityWrapper = new EntityWrapper();
entityWrapper.eq(RoleTable.STATUS,true);
List<RoleEntity> entities = roleService.selectList(entityWrapper);
model.addAttribute("roles",entities);

UserEntity userEntity = new UserEntity();
userEntity.setSex(true);
userEntity.setStatus(true);
if(!StringUtils.isEmpty(id)){
userEntity = userService.selectById(id);
}
model.addAttribute("userEntity",userEntity);
return "user/save";
}

/**
* 保存
* @param model
* @return
* @throws Exception
*/
@RequestMapping("saveData.htm")
@ResponseBody
@ImLog(type = "用户",mark = "保存用户 {name}")
public Result save(Model model, UserEntity userEntity)throws Exception{
if(StringUtils.isEmpty(userEntity.getId())){
userEntity.setId(IdWorker.get32UUID());
userEntity.setTime(new Date());
userService.insert(userEntity);
}else{
userService.updateById(userEntity);
}
return Result.success("保存成功");
}

/**
* 保存
* @param model
* @return
* @throws Exception
*/
@RequestMapping("del.htm")
@ResponseBody
@ImLog(type = "用户",mark = "删除用户 {id}")
public Result del(Model model, String id )throws Exception{
userService.deleteById(id);
return Result.success("保存成功");
}



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
51
 * @throws Exception
*/
@RequestMapping("list.htm")
public String list(Model model)throws Exception{
List<UserEntity> list = userDao.list();
model.addAttribute("list",list);
return "user/list";
}

/**
* 保存界面
* @param model
* @param id
* @return
* @throws Exception
*/
@RequestMapping("save.htm")
public String save(Model model,String id)throws Exception{
EntityWrapper entityWrapper = new EntityWrapper();
entityWrapper.eq(RoleTable.STATUS,true);
List<RoleEntity> entities = roleService.selectList(entityWrapper);
model.addAttribute("roles",entities);

UserEntity userEntity = new UserEntity();
userEntity.setSex(true);
userEntity.setStatus(true);
if(!StringUtils.isEmpty(id)){
userEntity = userService.selectById(id);
}
model.addAttribute("userEntity",userEntity);
return "user/save";
}

/**
* 保存
* @param model
* @return
* @throws Exception
*/
@RequestMapping("saveData.htm")
@ResponseBody
@ImLog(type = "用户",mark = "保存用户 {name}")
public Result save(Model model, UserEntity userEntity)throws Exception{
if(StringUtils.isEmpty(userEntity.getId())){
userEntity.setId(IdWorker.get32UUID());
userEntity.setTime(new Date());
userService.insert(userEntity);
}else{
userService.updateById(userEntity);
}
return Result.success("保存成功");
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
public Result uplaod(@RequestParam("file") MultipartFile file)throws Exception {
//用来检测程序运行时间
String fileName = IdWorker.get32UUID() +file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
try {
File file1 = new File(FILE_PATH+"\\"+fileName);
file1.createNewFile();
//获取输出流
OutputStream os=new FileOutputStream(file1.getPath());
//获取输入流 CommonsMultipartFile 中可以直接得到文件的流
InputStream is=file.getInputStream();
int temp;
//一个一个字节的读取并写入
while((temp=is.read())!=(-1))
{
os.write(temp);
}
os.flush();
os.close();
is.close();
InputStream inputStream = new FileInputStream(file1.getPath());
byte[] b = new byte[inputStream.available()];
inputStream.read(b);
} catch (FileNotFoundException e) {
e.printStackTrace();
return Result.error("上传文件失败");
}
return Result.success("/file/pic?pictureName="+fileName,"文件上传成功");
}

/**
* 获取本地图片
* @param pictureName //文件名
* @return
*/
@RequestMapping("/pic")
public void ShowImg(String pictureName, HttpServletRequest request, HttpServletResponse response) throws IOException {
//这里是存放图片的文件夹地址
FileInputStream fileIs=null;
OutputStream outStream = null;
try {
fileIs = new FileInputStream(FILE_PATH+"/"+pictureName);
//得到文件大小
int i=fileIs.available();


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