开发语言:Java
框架:SSM
技术:Jsp
JDK版本:JDK1.8
服务器:tomcat7
数据库:mysql 5.7/8.0
数据库工具:Navicat11
开发软件:eclipse/myeclipse/idea
Maven包:Maven3.3.9
浏览器:谷歌浏览器
一、前言介绍
随着我国经济的快速发展,人民生活水平的不断提高,宠物逐渐成为许多宠物爱好者的一种生活方式。
宠物的品种也越来越多样化,宠物不仅能给生活带来乐趣还可以成为空巢老人,独生子女很好的精神陪伴,养宠物是许多小伙伴的选择,宠物通常是宠物店购买的,带给它们一个温暖的家。
本论文系统地描绘了整个网上宠物店管理系统的设计与实现,主要实现的功能有以下几点:(1)管理员;个人中心、用户管理、培养师管理、宠物种类管理、宠物信息管理、食品类型管理、宠物粮食管理、用品类型管理、宠物用品管理、宠物疫苗管理、宠物疫苗预约管理、宠物美容管理、美容预约管理、宠物培养管理、培养订单管理、系统管理、订单管理 。 (2)前台首页;首页、宠物信息、宠物粮食、宠物用品、宠物疫苗、宠物美容、宠物培养、个人中心、后台管理、购物车。其具有简单的接口,方便的应用,强大的互动,完全基于互联网的特点。
现代社会的网络和信息技术不断提高,人们的生活水平达到另一个新的发展。但是由于工作和生活越来越忙,再让用户去宠物管理中心,显然是不太合理的。一个充分利用碎片化时间,简化去实体店过程的程序,正是我们所需要的。这篇文章研究了基于SSM框架的网上宠物店系统的开发和实现,从需求分析、总体设计到具体实现,最终完成了整个在线宠物管理系统,从而方便了用户和提高了管理员的管理水平。
二、 系统需求分析
宠物管理系统需要满足的需求有以下几个:
1. 信息获取方便,用户可在网页上快速浏览到新的信息。
2.宠物领养管理,符合用户需要的宠物可以在线支付。
3. 查看宠物详情,单独查看某一个宠物的详细信息,获取好评等。
4. 修改用户信息,可以修改用户密码或者用户名等一些个性化操作。
5.管理员功能,管理员可以对用户信息进行管理。
6. 系统安全,操作简便,不过于复杂。
7. 系统可以稳定运行,不存在卡顿等问题造成用户反感。
三、系统展示
宠物信息
宠物疫苗
宠物美容
管理员功能模块
宠物信息管理
宠物疫苗预约管理
四、部分核心代码
宠物信息
/** * 宠物信息 * 后端接口 * @author * @email * @date 2022-05-07 12:53:35 */ @RestController @RequestMapping("/chongwuxinxi") public class ChongwuxinxiController { @Autowired private ChongwuxinxiService chongwuxinxiService; @Autowired private StoreupService storeupService; /** * 后端列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,ChongwuxinxiEntity chongwuxinxi, HttpServletRequest request){ EntityWrapper<ChongwuxinxiEntity> ew = new EntityWrapper<ChongwuxinxiEntity>(); PageUtils page = chongwuxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, chongwuxinxi), params), params)); request.setAttribute("data", page); return R.ok().put("data", page); } /** * 前端列表 */ @IgnoreAuth @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,ChongwuxinxiEntity chongwuxinxi, HttpServletRequest request){ EntityWrapper<ChongwuxinxiEntity> ew = new EntityWrapper<ChongwuxinxiEntity>(); PageUtils page = chongwuxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, chongwuxinxi), params), params)); request.setAttribute("data", page); return R.ok().put("data", page); } /** * 列表 */ @RequestMapping("/lists") public R list( ChongwuxinxiEntity chongwuxinxi){ EntityWrapper<ChongwuxinxiEntity> ew = new EntityWrapper<ChongwuxinxiEntity>(); ew.allEq(MPUtil.allEQMapPre( chongwuxinxi, "chongwuxinxi")); return R.ok().put("data", chongwuxinxiService.selectListView(ew)); } /** * 查询 */ @RequestMapping("/query") public R query(ChongwuxinxiEntity chongwuxinxi){ EntityWrapper< ChongwuxinxiEntity> ew = new EntityWrapper< ChongwuxinxiEntity>(); ew.allEq(MPUtil.allEQMapPre( chongwuxinxi, "chongwuxinxi")); ChongwuxinxiView chongwuxinxiView = chongwuxinxiService.selectView(ew); return R.ok("查询宠物信息成功").put("data", chongwuxinxiView); } /** * 后端详情 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") Long id){ ChongwuxinxiEntity chongwuxinxi = chongwuxinxiService.selectById(id); chongwuxinxi.setClicktime(new Date()); chongwuxinxiService.updateById(chongwuxinxi); return R.ok().put("data", chongwuxinxi); } /** * 前端详情 */ @IgnoreAuth @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") Long id){ ChongwuxinxiEntity chongwuxinxi = chongwuxinxiService.selectById(id); chongwuxinxi.setClicktime(new Date()); chongwuxinxiService.updateById(chongwuxinxi); return R.ok().put("data", chongwuxinxi); } /** * 后端保存 */ @RequestMapping("/save") public R save(@RequestBody ChongwuxinxiEntity chongwuxinxi, HttpServletRequest request){ chongwuxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(chongwuxinxi); chongwuxinxiService.insert(chongwuxinxi); return R.ok(); } /** * 前端保存 */ @RequestMapping("/add") public R add(@RequestBody ChongwuxinxiEntity chongwuxinxi, HttpServletRequest request){ chongwuxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(chongwuxinxi); chongwuxinxiService.insert(chongwuxinxi); return R.ok(); } /** * 修改 */ @RequestMapping("/update") @Transactional public R update(@RequestBody ChongwuxinxiEntity chongwuxinxi, HttpServletRequest request){ //ValidatorUtils.validateEntity(chongwuxinxi); chongwuxinxiService.updateById(chongwuxinxi);//全部更新 return R.ok(); } /** * 删除 */ @RequestMapping("/delete") public R delete(@RequestBody Long[] ids){ chongwuxinxiService.deleteBatchIds(Arrays.asList(ids)); return R.ok(); } /** * 提醒接口 */ @RequestMapping("/remind/{columnName}/{type}") public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, @PathVariable("type") String type,@RequestParam Map<String, Object> map) { map.put("column", columnName); map.put("type", type); if(type.equals("2")) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); Date remindStartDate = null; Date remindEndDate = null; if(map.get("remindstart")!=null) { Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindStart); remindStartDate = c.getTime(); map.put("remindstart", sdf.format(remindStartDate)); } if(map.get("remindend")!=null) { Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindEnd); remindEndDate = c.getTime(); map.put("remindend", sdf.format(remindEndDate)); } } Wrapper<ChongwuxinxiEntity> wrapper = new EntityWrapper<ChongwuxinxiEntity>(); if(map.get("remindstart")!=null) { wrapper.ge(columnName, map.get("remindstart")); } if(map.get("remindend")!=null) { wrapper.le(columnName, map.get("remindend")); } int count = chongwuxinxiService.selectCount(wrapper); return R.ok().put("count", count); } /** * 前端智能排序 */ @IgnoreAuth @RequestMapping("/autoSort") public R autoSort(@RequestParam Map<String, Object> params,ChongwuxinxiEntity chongwuxinxi, HttpServletRequest request,String pre){ EntityWrapper<ChongwuxinxiEntity> ew = new EntityWrapper<ChongwuxinxiEntity>(); Map<String, Object> newMap = new HashMap<String, Object>(); Map<String, Object> param = new HashMap<String, Object>(); Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Object> entry = it.next(); String key = entry.getKey(); String newKey = entry.getKey(); if (pre.endsWith(".")) { newMap.put(pre + newKey, entry.getValue()); } else if (StringUtils.isEmpty(pre)) { newMap.put(newKey, entry.getValue()); } else { newMap.put(pre + "." + newKey, entry.getValue()); } } params.put("sort", "clicktime"); params.put("order", "desc"); PageUtils page = chongwuxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, chongwuxinxi), params), params)); return R.ok().put("data", page); } }
用户登录
@IgnoreAuth @RequestMapping(value = "/login") public R login(String username, String password, String captcha, HttpServletRequest request) { YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", username)); if(user==null || !user.getMima().equals(password)) { return R.error("账号或密码不正确"); } String token = tokenService.generateToken(user.getId(), username,"yonghu", "用户" ); return R.ok().put("token", token); }
用户注册
@IgnoreAuth @RequestMapping("/register") public R register(@RequestBody YonghuEntity yonghu){ //ValidatorUtils.validateEntity(yonghu); YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", yonghu.getZhanghao())); if(user!=null) { return R.error("注册用户已存在"); } Long uId = new Date().getTime(); yonghu.setId(uId); yonghuService.insert(yonghu); return R.ok(); }
上传文件
/** * 上传文件 */ @RequestMapping("/upload") public R upload(@RequestParam("file") MultipartFile file, String type,HttpServletRequest request) throws Exception { if (file.isEmpty()) { throw new EIException("上传文件不能为空"); } String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1); String fileName = new Date().getTime()+"."+fileExt; File dest = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+fileName); file.transferTo(dest); /** * 如果使用idea或者eclipse重启项目,发现之前上传的图片或者文件丢失,将下面一行代码注释打开 * 请将以下的"D:\\ssmpiv99\\src\\main\\webapp\\upload"替换成你本地项目的upload路径, * 并且项目路径不能存在中文、空格等特殊字符 */ //FileUtils.copyFile(dest, new File("D:\\ssmpiv99\\src\\main\\webapp\\upload"+"/"+fileName)); /**修改了路径以后请将该行最前面的//注释去掉**/ if(StringUtils.isNotBlank(type) && type.equals("1")) { ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); if(configEntity==null) { configEntity = new ConfigEntity(); configEntity.setName("faceFile"); configEntity.setValue(fileName); } else { configEntity.setValue(fileName); } configService.insertOrUpdate(configEntity); } return R.ok().put("file", fileName); }