基于SSM的网上宠物店

news2024/10/7 10:16:57

末尾获取源码
开发语言:Java
Java开发工具:JDK1.8
后端框架:SSM
前端:采用JSP技术开发
数据库:MySQL5.7和Navicat管理工具结合
服务器:Tomcat8.5
开发软件:IDEA / Eclipse
是否Maven项目:是


前言

基于SSM的网上宠物店有三大角色:

管理员:个人中心、用户管理、培养师管理、宠物种类管理、宠物信息管理、食品类型管理、宠物粮食管理、用品类型管理、宠物用品管理、宠物疫苗管理、宠物疫苗预约管理、宠物美容管理、美容预约管理、宠物培养管理、培养订单管理、系统管理、订单管理。

培养师:个人中心、宠物培养管理、培养订单管理;

用户前台:首页、宠物信息、宠物粮食、宠物用品、宠物疫苗、宠物美容、宠物培养、个人中心、后台管理、购物车等功能。

前台首页

 输入网址我们可以看到前台首页有首页、宠物信息、宠物粮食、宠物用品、宠物疫苗、宠物美容、宠物培养、个人中心、后台管理、购物车等功能。

 在宠物信息中,用户可以查看当前宠物店的宠物信息。

 在宠物粮食中,用户可以查看宠物的粮食并且选择购买。

 用户登录页面。

 宠物用品,用户可以在该模块中,查看商品并且选择购买。

 在宠物疫苗中,用户可以为自己的宠物预约疫苗。

 在宠物美容中,用户可以选择为自己的宠物进行美容并且进行美容预约。

 宠物培养,用户可以为自己的宠物选择报名一些课程。

 个人中心,用户可以在个人中心修改自己的信息并且充值金额。

 在购物车中,用户可以查看自己添加到购物车的商品并且选择支付金额。

培养师功能模块

培养师登录页面

培养师进入后台功能有个人中心、宠物培养管理、培养订单管理。 

 管理员功能模块

 管理员登录后台系统功能有个人中心、用户管理、培养师管理、宠物种类管理、宠物信息管理、食品类型管理、宠物粮食管理、用品类型管理、宠物用品管理、宠物疫苗管理、宠物疫苗预约管理、宠物美容管理、美容预约管理、宠物培养管理、培养订单管理、系统管理、订单管理。

 

登录模块核心代码


package com.controller;


import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;

/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UserController{
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private TokenService tokenService;

	/**
	 * 登录
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
		if(user==null || !user.getPassword().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		return R.ok().put("token", token);
	}
	
	/**
	 * 注册
	 */
	@IgnoreAuth
	@PostMapping(value = "/register")
	public R register(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

	/**
	 * 退出
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
    	user.setPassword("123456");
        userService.update(user,null);
        return R.ok("密码已重置为:123456");
    }
	
	/**
     * 列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,UserEntity user){
        EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
    	PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/list")
    public R list( UserEntity user){
       	EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
      	ew.allEq(MPUtil.allEQMapPre( user, "user")); 
        return R.ok().put("data", userService.selectListView(ew));
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);
        userService.updateById(user);//全部更新
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        userService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

文件上传核心代码

package com.controller;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;

/**
 * 上传文件映射表
 */
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
	@Autowired
    private ConfigService configService;
	/**
	 * 上传文件
	 */
	@RequestMapping("/upload")
	public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
		if (file.isEmpty()) {
			throw new EIException("上传文件不能为空");
		}
		String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
		File path = new File(ResourceUtils.getURL("classpath:static").getPath());
		if(!path.exists()) {
		    path = new File("");
		}
		File upload = new File(path.getAbsolutePath(),"/upload/");
		if(!upload.exists()) {
		    upload.mkdirs();
		}
		String fileName = new Date().getTime()+"."+fileExt;
		File dest = new File(upload.getAbsolutePath()+"/"+fileName);
		file.transferTo(dest);
		FileUtils.copyFile(dest, new File("C:\\Users\\Desktop\\jiadian\\springbootl7own\\src\\main\\resources\\static\\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);
	}
	
	/**
	 * 下载文件
	 */
	@IgnoreAuth
	@RequestMapping("/download")
	public ResponseEntity<byte[]> download(@RequestParam String fileName) {
		try {
			File path = new File(ResourceUtils.getURL("classpath:static").getPath());
			if(!path.exists()) {
			    path = new File("");
			}
			File upload = new File(path.getAbsolutePath(),"/upload/");
			if(!upload.exists()) {
			    upload.mkdirs();
			}
			File file = new File(upload.getAbsolutePath()+"/"+fileName);
			if(file.exists()){
				/*if(!fileService.canRead(file, SessionManager.getSessionUser())){
					getResponse().sendError(403);
				}*/
				HttpHeaders headers = new HttpHeaders();
			    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);    
			    headers.setContentDispositionFormData("attachment", fileName);    
			    return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
	}
	
}

 封装代码

package com.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 */
public class R extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	
	public R() {
		put("code", 0);
	}
	
	public static R error() {
		return error(500, "未知异常,请联系管理员");
	}
	
	public static R error(String msg) {
		return error(500, msg);
	}
	
	public static R error(int code, String msg) {
		R r = new R();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}

	public static R ok(String msg) {
		R r = new R();
		r.put("msg", msg);
		return r;
	}
	
	public static R ok(Map<String, Object> map) {
		R r = new R();
		r.putAll(map);
		return r;
	}
	
	public static R ok() {
		return new R();
	}

	public R put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/539406.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

低代码赋能生物药企数字化

一、关于复宏汉霖 汉霖是复星在2010年投资孵化的一家生物医药公司&#xff0c;经过这十几年的发展&#xff0c;2019年在港股上市&#xff0c;是生物药企18A企业之一。 经过这些年的发展&#xff0c;我们在管线方面布局了肿瘤、肢体、免疫、眼科类&#xff0c;从早研阶段到临床…

Midjourney|文心一格prompt教程[Text Prompt(下篇)]:游戏、实物、人物、风景、动漫、邮票、海报等生成,终极模板教学

Midjourney|文心一格prompt教程[Text Prompt&#xff08;下篇&#xff09;]&#xff1a;游戏、实物、人物、风景、动漫、邮票、海报等生成&#xff0c;终极模板教学 场景6&#xff1a;游戏 Prompt 真的越长越好吗&#xff1f; 按照 Midjourney 的官方文档里的说法&#xff0…

基于html+css的图展示76

准备项目 项目开发工具 Visual Studio Code 1.44.2 版本: 1.44.2 提交: ff915844119ce9485abfe8aa9076ec76b5300ddd 日期: 2020-04-16T16:36:23.138Z Electron: 7.1.11 Chrome: 78.0.3904.130 Node.js: 12.8.1 V8: 7.8.279.23-electron.0 OS: Windows_NT x64 10.0.19044 项目…

人类禁止进入的“微博”,我的AI机器人在那里吹牛,“勾搭”AI小姑娘

最近球友推荐了一个非常有趣的网站&#xff0c;叫“奇鸟”&#xff08;https://chirper.ai/zh&#xff09;。 简单来说&#xff0c;这是一个AI专属的微博&#xff0c;人类禁止发言&#xff0c;但是你可以创建一个叫“奇鸟”的机器人代理&#xff0c;让它在里边发帖&#xff0c;…

扫眼球换“世界币” ChatGPT之父“剥削穷人”?

ChatGPT火爆全球后&#xff0c; 山姆奥特曼&#xff08;Sam Altman&#xff09;创立的加密项目Worldcoin&#xff08;世界币&#xff09;重回大众视野。这个项目诞生于2年前。那时&#xff0c;埋头迭代GPT模型的OpenAI还未如此知名&#xff0c;该公司的CEO 山姆奥特曼也位列科技…

【计算机视觉】CLIP实战:Zero-Shot Prediction(含源代码)

一、代码实战 下面的代码使用 CLIP 执行零样本预测。 此示例从 CIFAR-100 数据集中获取图像&#xff0c;并预测数据集中 100 个文本标签中最可能的标签。 import os import clip import torch from torchvision.datasets import CIFAR100# Load the model device "cuda…

Android Parceable 使用和原理

简介 在 Android 开发中&#xff0c;我们经常需要在不同的组件之间传递数据&#xff0c;比如在 Activity 之间传递数据、在 Service 和 Activity 之间传递数据等。为了实现数据的传递&#xff0c;Android 提供了两种常用的方式&#xff0c;一种是使用 Intent&#xff0c;另一种…

opencv_c++学习(十)

一、图像尺寸变化 图像插值原理 在图像变换的过程中往往需要对像素进行相关的操作。如上图&#xff08;左&#xff09;所示&#xff0c;我们会遇到两个相邻的像素块需要映射到同样的位置中&#xff0c;或者两个相邻的位置的像素中间需要映射出一个位置的像素块。这时候我们就需…

JavaEE(系列7) -- 多线程(wait 和 notify 的使用)

首先对上一章节的指令重排序,在进行解释一下; 假设现在有连个线程 t1 和 t2 t1频繁(速度特别快)读取主内存&#xff0c;效率比较低&#xff0c;就被优化成直接读自己的工作内存。 t2修改了主内存的结果&#xff0c;由于t1没有读主内存&#xff0c;导致修改不能被识别到。 1.什么…

全网最全最细的【设计模式】总目录,收藏起来慢慢啃,看完不懂砍我

文章目录 一、设计模式七大原则1、单一职责原则2、接口隔离原则3、依赖倒置原则4、里氏替换原则5、开闭原则6、迪米特法则7、合成复用原则 二、UML类图三、设计模式1、创建型模式&#xff08;1&#xff09;单例模式&#xff08;常用&#xff09;&#xff08;2&#xff09;原型模…

mybatis-config.xml文件中的mappers标签

前言 在MyBatis中&#xff0c;< mapper >标签非常重要&#xff0c;因为它对应着我们存放sql语句的xml文件&#xff0c;在之前的使用中我们都是使用resource来指定路径&#xff0c;但其实除了resource可以指定路径的还有url和class但路径形式有所不同&#xff0c;下面来讨…

用「明道云+ChatGPT+Weaviate」挑战零代码1小时实现ChatPDF

ChatGPT流行起来之后&#xff0c;快速的出现了一批基于ChatGPT的工具应用&#xff0c;ChatPDF就是其中比较受欢迎的一款。它是一个可以让你与PDF文件进行对话的工具&#xff0c;既可以帮助你快速提取PDF文件中的信息&#xff0c;例如手册、论文、合同、书籍等&#xff1b;也可以…

【计算机视觉】最后显示的CIFAR-100数据集照片很模糊怎么解决?

文章目录 一、前言二、如何解决2.1 使用图像增强技术2.2 使用插值方法2.3 使用更高分辨率的图像数据集2.4 手动调整图像尺寸 三、总结 一、前言 如果从CIFAR-100数据集加载的图像显示模糊&#xff0c;可能有几个可能的原因&#xff1a; 分辨率较低&#xff1a;CIFAR-100数据集…

全力押注预制菜,叮咚买菜或错失即时零售红利

实际上&#xff0c;叮咚买菜相比于美团、京东更适合抢分即时零售的市场红利。 目前美团进入即时零售的逻辑是&#xff0c;拥有几百万骑手的履约软硬件可以复用&#xff0c;同时从外卖场景延伸到其他消费场景比较丝滑&#xff0c;从平台几千万用户的温饱满足&#xff0c;延展到多…

计算机网络实验(ensp)-实验10:三层交换机实现VLAN间路由

目录 实验报告&#xff1a; 实验操作 1.建立网络拓扑图并开启设备 2.配置主机 1.打开PC机 配置IP地址和子网掩码 2.配置完成后点击“应用”退出 3.重复步骤1和2配置每台PC 3.配置交换机VLAN 1.点开交换机 2.输入命名&#xff1a;sys 从用户视图切换到系统视图…

网络工程师精选习题详解(一)

请点击↑关注、收藏&#xff0c;本博客免费为你获取精彩知识分享&#xff01;有惊喜哟&#xff01;&#xff01; 1.在IPv4地址192.168.2.0/24中&#xff0c;表示主机的二进制位数是&#xff08; &#xff09;位。 A.8 B.16 C.24 D.32 答案&#xff1a;A /24示网络…

面对职业焦虑,我们能做些什么?

目录 大环境分析&#xff1a;AI 发展汹涌而上温水煮青蛙&#xff1a;那些“被替代”的“我们”码农分类&#xff1a;程序员都在做些什么码农黑暗季&#xff1a;失业潮原因分析程序员短期真的可替代吗&#xff1f;AI 发展来势汹汹&#xff0c;如何顺势而为最后&#xff1a;纵观全…

SpringBoot整合Swagger2,让接口文档管理变得更简单

在软件开发的过程中&#xff0c;接口文档的编写往往是一个非常重要的环节&#xff0c;因为它是前端和后端沟通的桥梁&#xff0c;帮助团队更好地协作。然而&#xff0c;手动编写接口文档不仅耗费时间&#xff0c;还容易出错&#xff0c;因此我们需要一种简单的方法来管理接口文…

宝武中南钢铁借助飞桨让钢筋超限监控有了“火眼金睛”

现代钢铁工业生产过程是一个复杂而庞大的生产体系&#xff0c;涵盖数百道工序。 在70多年的发展历程中&#xff0c;炼钢、轧钢、连铸以及节能减排等各项技术不断进化&#xff0c;无一不印证了中国钢铁在技术创新之路上获得的持续性突破。如今&#xff0c;宝武中南钢铁&#xff…

Java websocket 使用

简介 WebSocket 是一种基于 TCP 协议的全双工通信协议&#xff0c;可以在浏览器和服务器之间建立实时、双向的数据通信。在 Java 中&#xff0c;我们可以使用 Java API for WebSocket&#xff08;JSR 356&#xff09;来实现 WebSocket。 WebSocket 的作用是在 Web 应用程序中…