——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明










基于javaweb的SpringBoot网上超市线上购物系统(java+springboot+maven+mysql+thymeleaf+html)
管理员:
admin 123456
用户:
13511111111 123456
13511111112 123456
13511111113 123456
——————————CodeStart——————————
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"; }
@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("保存成功"); }
@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("保存成功"); }
@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"; }
@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("保存成功"); }
@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"; }
@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"; }
@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()); 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,"文件上传成功"); }
@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();
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=062223432309201fp
https://javayms.pages.dev?id=062223432309201fp