项目介绍

本项目分为前后台,前台为普通用户角色,后台为管理员角色;
管理员角色包含以下功能:
管理员登录,管理员信息管理,查看用户信息,新闻公告管理,类型管理,管理城市信息,救助中心信息管理,流浪动物信息管理,查看收养信息,查看评价信息,修改密码等功能。

用户角色包含以下功能:
查看首页,查看网站公告,用户登录,查看推荐,查看动物详情,查看领养计划,提交订单,查看我的订单,修改个人信息,修改密码等功能。

由于本程序规模不大,可供课程设计,毕业设计学习演示之用

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目

6.数据库:MySql 5.7/8.0等版本均可;

技术栈

1. 后端:Spring springmvc mybatis

2. 前端:JSP+css+javascript+jQuery

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2.使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat
3. 将项目中springmvc-servlet.xml配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8080/ 登录
用户账号/密码: user/123456

管理员账号/密码:admin/admin

运行截图

前台界面-用户角色

 

宠物领养系统java用户信息管理_java

宠物领养系统java用户信息管理_开发语言_02

 

宠物领养系统java用户信息管理_java_03

 

宠物领养系统java用户信息管理_maven项目_04

 

宠物领养系统java用户信息管理_java_05

 

后台界面-管理员角色

宠物领养系统java用户信息管理_宠物领养系统java用户信息管理_06

 

宠物领养系统java用户信息管理_宠物领养系统java用户信息管理_07

 

宠物领养系统java用户信息管理_开发语言_08

 

宠物领养系统java用户信息管理_spring_09

 

相关代码 

动物管理控制器

@Controller
@RequestMapping("/adopt")
public class AdoptController extends BaseController{

	@Autowired
	private AdoptService adoptService;
	
	@RequestMapping("/showAdoptRecordInfoListPage")
	public String showUserInfoListPage(){
		return "/record/adoptRecordInfoList";
	}

	@RequestMapping("/showAdoptUserInfoPage")
	public String showAdoptUserInfoPage(){
		return "/record/adoptUserInfoList";
	}
	
	@RequestMapping("/getAdoptRecordInfoList")
	@ResponseBody
	public JqGridResult getAdoptRecordInfoList(TUser user,Integer page){
		 if(page == null){
			 page = 1;
		 }
		 JqGridResult jqGridResult = adoptService.queryAllAdoptRecord(page,pageSize);
		 return jqGridResult;
	}
	
	@RequestMapping("/getAdoptUserInfoList")
	@ResponseBody
	public JqGridResult getAdoptUserInfoList(TUser user,Integer page){
		 if(page == null){
			 page = 1;
		 }
		 JqGridResult jqGridResult = adoptService.queryAllAdoptUser(page, pageSize);
		 return jqGridResult;
	}
	
	@RequestMapping("/delete")
	@ResponseBody
	public AdoptJSONResult deleteComment(Integer recordId){
		 adoptService.deleteAdoptRecord(recordId);
		 return AdoptJSONResult.ok();
	}
	
	@RequestMapping("/modifyAdoptRecord")
	@ResponseBody
	public AdoptJSONResult modifyAdoptRecord(TDogUser adoptRecord){
		//修改 status 0:未审核   1:审核通过
		adoptRecord.setStatus(1);
		adoptService.updateAdoptRecord(adoptRecord);
		return AdoptJSONResult.ok();
	}
}

用户管理控制器

@Controller
@RequestMapping("/user")
public class UserController extends BaseController {

	final static Logger log = LoggerFactory.getLogger(UserController.class);

	@Autowired
	private UserService userService;

	@Autowired
	private AdoptService adoptService;

	@RequestMapping("/showUserInfoListPage")
	public String showUserInfoListPage(){
		return "/user/userInfoList";
	}

	@RequestMapping("/showCreateUserPage")
	public ModelAndView showCreateUserPage(HttpServletRequest request){

		ModelAndView mv = new ModelAndView("user/createUser");
		return mv;
	}


	@RequestMapping("/delete")
	@ResponseBody
	public AdoptJSONResult deleteUser(Integer userId){
		 userService.deleteUser(userId);
		 return AdoptJSONResult.ok();
	}

	@RequestMapping("/getUserInfoList")
	@ResponseBody
	public JqGridResult getUserInfoList(TUser user,Integer page){
		 if(page == null){
			 page = 1;
		 }
		 JqGridResult jqGridResult = userService.queryAllUser(user, page, pageSize);
		 return jqGridResult;
	}

	@RequestMapping("/saveOrUpdate")
	@ResponseBody
	public AdoptJSONResult saveOrUpdate(TUser user){

		// 用户id不为空,则修改用户;用户id为空,则新建用户
		Integer userId = user.getId();
		if (userId != null) {
			userService.updateUser(user);
		} else {
			userService.addUser(user);
		}
		return AdoptJSONResult.ok();
	}

	@RequestMapping("/modifyUser")
	public ModelAndView showModifyUser(Integer userId, HttpServletRequest request){

		// 查询用户个人信息
		TUser userInfo = userService.queryUserInfoById(userId);

		ModelAndView mv = new ModelAndView("user/modifyUser");
		mv.addObject("userInfo", userInfo);

		return mv;
	}

	/**
	 * 管理员登陆
	 * @param username
	 * @param password
	 * @param request
	 * @return
	 */
	@PostMapping("/login")
	@ResponseBody
	public AdoptJSONResult userLogin(String username, String password,
			HttpServletRequest request) {

		if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
			return AdoptJSONResult.errorMap("用户名和密码不能为空");
		} else {

			TAdmin admin = new TAdmin(Integer.parseInt(username), password);
			TAdmin currentAdmin =userService.queryAdminByUsernameAndPassword(admin);
			if(currentAdmin != null){
				request.getSession().setAttribute("sessionAdmin", currentAdmin);
				return AdoptJSONResult.ok();
			}else{
				return AdoptJSONResult.errorMsg("登陆失败,请重试...");
			}
		}

	}

	/**
	 * 用户登陆
	 * @param username
	 * @param password
	 * @param request
	 * @return
	 */
	@PostMapping("/customLogin")
	@ResponseBody
	public AdoptJSONResult customLogin(String username, String password,
			HttpServletRequest request) {

		if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
			return AdoptJSONResult.errorMap("用户名和密码不能为空");
		} else {
			TUser user = new TUser(username,password);
			TUser currentUser =userService.queryUserByUsernameAndPassword(user);
			if(currentUser != null){
				request.getSession().setAttribute("sessionUser", currentUser);
				return AdoptJSONResult.ok();
			}else{
				return AdoptJSONResult.errorMsg("登陆失败,请重试...");
			}
		}

	}


	@PostMapping("/customReg")
	@ResponseBody
	public AdoptJSONResult customReg(String username, String password,String tel,
									   HttpServletRequest request) {

		if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
			return AdoptJSONResult.errorMap("用户名和密码不能为空");
		} else {
			TUser user = new TUser(username,password);
			//TUser currentUser =userService.queryUserByUsername(username);
			//if(currentUser != null){
			//	return AdoptJSONResult.errorMsg("用户已存在...");
				//request.getSession().setAttribute("sessionUser", currentUser);
				//return AdoptJSONResult.ok();
			//}else{
				TUser user1 = new TUser();
				user1.setUsername(username);
				user1.setPassword(password);
				user1.setTel(tel);
				userService.addUser(user1);
				request.getSession().setAttribute("sessionUser", user1);
				return AdoptJSONResult.ok();
			//}
		}

	}


	/**
	 * 用户注销
	 * @param request
	 * @return
	 */
	@GetMapping("/logout")
	public String logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return "redirect:/frontPage/login.jsp";
	}

	/**
	 * 用户收养流浪狗
	 * @param dogId
	 * @param request
	 * @return
	 * @throws IOException
	 */
	@PostMapping("/adoptDog")
	@ResponseBody
	public AdoptJSONResult saveOrUpdate(Integer dogId,HttpServletRequest request) throws IOException{

		HttpSession session = request.getSession();

		TDogUser adopt = new TDogUser();


		TUser user = (TUser) session.getAttribute("sessionUser");
		adopt.setUserId(user.getId());
		//type 1:收养  2:送养
		adopt.setType(1);
		adopt.setStatus(0);
		adopt.setDogId(dogId);
		adoptService.addAdoptRecord(adopt);

		return AdoptJSONResult.ok();
	}

}

领养管理控制器

@Controller
@RequestMapping("/comment")
public class CommentController extends BaseController {
	
	final static Logger log = LoggerFactory.getLogger(CommentController.class);
	
	@Autowired
	private CommentService commentService;
	
	@RequestMapping("/showCommentInfoListPage")
	public String showCommentInfoListPage(){
		return "/comment/commentInfoList";
	}
	
	@RequestMapping("/showCreateCommentPage")
	public ModelAndView showCreateCommentPage(HttpServletRequest request){
		
		ModelAndView mv = new ModelAndView("comment/createComment");
		return mv;
	}
	
	
	@RequestMapping("/delete")
	@ResponseBody
	public AdoptJSONResult deleteComment(Integer commentId){
		 commentService.deleteComment(commentId);
		 return AdoptJSONResult.ok();
	}
	
	@RequestMapping("/getCommentInfoList")
	@ResponseBody
	public JqGridResult getCommentInfoList(Integer page){
		 if(page == null){
			 page = 1;
		 }
		 JqGridResult jqGridResult = commentService.queryAllComment(page, pageSize);
		 return jqGridResult;
	}
	
	@RequestMapping("/getFrontCommentInfoList")
	public String getFrontCommentInfoList(Model md){
		
		List<CommentVO> commentList  = commentService.queryAllFrontComment();
		md.addAttribute("commentList", commentList);
		return "forward:/frontPage/comment.jsp";
	}

	@RequestMapping("/saveOrUpdate")
	@ResponseBody
	public AdoptJSONResult saveOrUpdate(TComment comment,HttpServletRequest request){
		
		//id不为空,则回复;id为空,则新建留言
		Integer commentId = comment.getId();
		TAdmin admin = getCurrentUser(request);
		if(admin == null){
			return AdoptJSONResult.errorMsg("请登录...");
		}
		Integer fromUserId = admin.getAdminid();
		if (commentId != null && fromUserId != null) {
			comment.setToUserId(fromUserId);
			
			//添加回复
			TComment toComment = new TComment();
			toComment.setComment(comment.getComment());
			toComment.setFromUserId(fromUserId);
			toComment.setCreateTime(new Date());
			commentService.addComment(toComment);
			
			comment.setComment(null);
			commentService.updateComment(comment);
		} else {
			comment.setFromUserId(fromUserId);
			comment.setCreateTime(new Date());
			commentService.addComment(comment);
		}		
		return AdoptJSONResult.ok();
	}
	
	@RequestMapping("/saveComment")
	@ResponseBody
	public AdoptJSONResult saveComment(TComment comment,HttpServletRequest request){
		
		TUser user = (TUser) request.getSession().getAttribute("sessionUser");
		if(user == null){
			return AdoptJSONResult.errorMsg("请登录...");
		}
		Integer fromUserId = user.getId();
		comment.setFromUserId(fromUserId);
		comment.setCreateTime(new Date());
		commentService.addComment(comment);
		return AdoptJSONResult.ok();
	}
	
	@RequestMapping("/modifyComment")
	public ModelAndView showModifyComment(Integer commentId, HttpServletRequest request){
		
		// 查询用户个人信息
		TComment commentInfo = commentService.queryCommentInfoById(commentId);
		
		ModelAndView mv = new ModelAndView("comment/modifyComment");
		mv.addObject("commentInfo", commentInfo);
		
		return mv;
	}
	
	
}