Java项目:宠物领养管理系统(java+SSM+JSP+JS+JQUERY+Layui+Mysql)

 源码获取:俺的博客首页 "资源" 里下载!

项目介绍

主要功能包括:

本系统分为用户和管理员两个角色,

管理员模块主要功能有:
(1)账号密码注册登录,可修改密码。
(2)用户信息管理,可以查看所有用户信息,并执行删除修改功能。
(3)轮播图、通知公告内容的发布。
(4)发布宠物饲养视频,包括添加视频类别。
(5)领养宠物信息的发布、删除、修改等。
(6)查看用户领养申请,操作同意和拒绝按钮。

用户模块主要功能有:
(1)注册登录,上传个人信息,个人地址。
(2)进入首页,轮播图展示宠物图片,查看通知公告,查看感谢信模块。
(3)宠物教学页面,点击进入宠物教学页面,观看宠物饲养教学视频,视频根据动物类别分类,支持模糊查询搜索视频,用户可以点赞留言。
(4)宠物认领页面,查看所有宠物认领信息列表,点击查看宠物详情,点击认领按钮后,填写宠物丢失详情(时间、地点,宠物特点等)等待发布者查看审核,通过后留下联系方式。
(5)宠物领养页面,查看管理员发布的宠物领养信息列表,点击查看宠物详情,提交领养申请,等待管理员审核,通过后方可领养。
(6)发布宠物认领信息,发布标题图片和文字描述,等待遗失者认领。
(7)写感谢信供其他用户首页查看。
(8)联系网站救助小动物热线以及留言板


环境需要

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等版本均可;


技术栈

后端:SSM(Spring+SpringMVC+Mybatis)

前端:JSP+CSS+JS+JQUERY+Layui


使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目;
3. 将项目中db.xml配置文件中的数据库配置改为自己的配置,然后运行;

 

 

 

用户信息管理控制层: 

/**
 * 用户信息
 * 
 */
@Controller
@RequestMapping("/system/user")
public class UserController extends BaseController
{
    private String prefix = "system/user";

    @Autowired
    private IUserService userService;

    @Autowired
    private IRoleService roleService;

    @Autowired
    private IPostService postService;

    @RequiresPermissions("system:user:view")
    @GetMapping()
    public String user()
    {
        return prefix + "/user";
    }

    @RequiresPermissions("system:user:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(User user)
    {
        startPage();
        List<User> list = userService.selectUserList(user);
        return getDataTable(list);
    }

    @Log(title = "用户管理", businessType = BusinessType.EXPORT)
    @RequiresPermissions("system:user:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(User user)
    {
        List<User> list = userService.selectUserList(user);
        ExcelUtil<User> util = new ExcelUtil<User>(User.class);
        return util.exportExcel(list, "用户数据");
    }

    @Log(title = "用户管理", businessType = BusinessType.IMPORT)
    @RequiresPermissions("system:user:import")
    @PostMapping("/importData")
    @ResponseBody
    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
    {
        ExcelUtil<User> util = new ExcelUtil<User>(User.class);
        List<User> userList = util.importExcel(file.getInputStream());
        String message = userService.importUser(userList, updateSupport);
        return AjaxResult.success(message);
    }

    @RequiresPermissions("system:user:view")
    @GetMapping("/importTemplate")
    @ResponseBody
    public AjaxResult importTemplate()
    {
        ExcelUtil<User> util = new ExcelUtil<User>(User.class);
        return util.importTemplateExcel("用户数据");
    }

    /**
     * 新增用户
     */
    @GetMapping("/add")
    public String add(ModelMap mmap)
    {
        mmap.put("roles", roleService.selectRoleAll());
        mmap.put("posts", postService.selectPostAll());
        return prefix + "/add";
    }

    /**
     * 新增保存用户
     */
    @RequiresPermissions("system:user:add")
    @Log(title = "用户管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(@Validated User user)
    {
        if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName())))
        {
            return error("新增用户'" + user.getLoginName() + "'失败,登录账号已存在");
        }
        else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
        {
            return error("新增用户'" + user.getLoginName() + "'失败,手机号码已存在");
        }
        else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
        {
            return error("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
        }
        return toAjax(userService.insertUser(user));
    }

    /**
     * 修改用户
     */
    @GetMapping("/edit/{userId}")
    public String edit(@PathVariable("userId") Long userId, ModelMap mmap)
    {
        mmap.put("user", userService.selectUserById(userId));
        mmap.put("roles", roleService.selectRolesByUserId(userId));
        mmap.put("posts", postService.selectPostsByUserId(userId));
        return prefix + "/edit";
    }

    /**
     * 修改保存用户
     */
    @RequiresPermissions("system:user:edit")
    @Log(title = "用户管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@Validated User user)
    {
        userService.checkUserAllowed(user);
        if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
        {
            return error("修改用户'" + user.getLoginName() + "'失败,手机号码已存在");
        }
        else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
        {
            return error("修改用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
        }
        return toAjax(userService.updateUser(user));
    }

    @RequiresPermissions("system:user:resetPwd")
    @Log(title = "重置密码", businessType = BusinessType.UPDATE)
    @GetMapping("/resetPwd/{userId}")
    public String resetPwd(@PathVariable("userId") Long userId, ModelMap mmap)
    {
        mmap.put("user", userService.selectUserById(userId));
        return prefix + "/resetPwd";
    }

    @RequiresPermissions("system:user:resetPwd")
    @Log(title = "重置密码", businessType = BusinessType.UPDATE)
    @PostMapping("/resetPwd")
    @ResponseBody
    public AjaxResult resetPwdSave(User user)
    {
        userService.checkUserAllowed(user);
        if (userService.resetUserPwd(user) > 0)
        {
            if (ShiroUtils.getUserId() == user.getUserId())
            {
                setSysUser(userService.selectUserById(user.getUserId()));
            }
            return success();
        }
        return error();
    }

    

    @RequiresPermissions("system:user:remove")
    @Log(title = "用户管理", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        try
        {
            return toAjax(userService.deleteUserByIds(ids));
        }
        catch (Exception e)
        {
            return error(e.getMessage());
        }
    }

    /**
     * 校验用户名
     */
    @PostMapping("/checkLoginNameUnique")
    @ResponseBody
    public String checkLoginNameUnique(User user)
    {
        return userService.checkLoginNameUnique(user.getLoginName());
    }

    /**
     * 校验手机号码
     */
    @PostMapping("/checkPhoneUnique")
    @ResponseBody
    public String checkPhoneUnique(User user)
    {
        return userService.checkPhoneUnique(user);
    }

    /**
     * 校验email邮箱
     */
    @PostMapping("/checkEmailUnique")
    @ResponseBody
    public String checkEmailUnique(User user)
    {
        return userService.checkEmailUnique(user);
    }

    /**
     * 用户状态修改
     */
    @Log(title = "用户管理", businessType = BusinessType.UPDATE)
    @RequiresPermissions("system:user:edit")
    @PostMapping("/changeStatus")
    @ResponseBody
    public AjaxResult changeStatus(User user)
    {
        userService.checkUserAllowed(user);
        return toAjax(userService.changeStatus(user));
    }
}

登录管理控制层:

/**
 * 登录验证
 * 
 */
@Controller
public class LoginController extends BaseController
{
	@Autowired
	public RoleServiceImpl roleService;
	@Autowired
	public UserServiceImpl userService;
	
	
    @GetMapping("/login")
    public String login(HttpServletRequest request, HttpServletResponse response)
    {
        // 如果是Ajax请求,返回Json字符串。
        if (ServletUtils.isAjaxRequest(request))
        {
            return ServletUtils.renderString(response, "{\"code\":\"1\",\"msg\":\"未登录或登录超时。请重新登录\"}");
        }

        return "login";
    }

    @PostMapping("/login")
    @ResponseBody
    public AjaxResult ajaxLogin(String username, String password, Boolean rememberMe)
    {
        UsernamePasswordToken token = new UsernamePasswordToken(username, password, rememberMe);
        Subject subject = SecurityUtils.getSubject();
        try
        {
            subject.login(token);
            return success();
        }
        catch (AuthenticationException e)
        {
            String msg = "用户或密码错误";
            if (StringUtils.isNotEmpty(e.getMessage()))
            {
                msg = e.getMessage();
            }
            return error(msg);
        }
    }
    
    @GetMapping("/regist")
    public String regist(ModelMap mmap){
    	System.out.println("用户注册");
    	mmap.put("roles", roleService.selectGeneralRole());
    	return "regist";
    }
    
    
    @PostMapping("/regist")
    @ResponseBody
    public AjaxResult ajaxRegist(User user)
    {
    	 return toAjax(userService.registUser(user));
    }
    
    
    @GetMapping("/forget")
    public String forget(ModelMap mmap){
        return "/forget";
    }
    
    
    @Log(title = "忘记密码", businessType = BusinessType.UPDATE)
    @PostMapping("/forget")
    @ResponseBody
    public AjaxResult forget(User user)
    {
    	if(StringUtils.isEmpty(user.getLoginName()) || StringUtils.isEmpty(user.getEmail())){
    		return error("请输入用户名和邮箱!");
    	}
    	List<User> userList = userService.selectUserList(user);
    	if(userList == null || userList.size() == 0){
    		return error("输入的用户名/邮箱不匹配!");
    	}else{
    		user.setUserId(userList.get(0).getUserId());
    		user.setPassword("123456");
    		userService.resetUserPwd(user);
    		return success();
    	}
    }
    
    
    

    @GetMapping("/unauth")
    public String unauth()
    {
        return "error/unauth";
    }
}

寄养订单管理控制层: 

/**
 * 寄养订单管理Controller
 * 
 */
@Controller
@RequestMapping("/system/parkPetOrder")
public class SysParkpetOrderController extends BaseController
{
    private String prefix = "system/parkPetOrder";

    @Autowired
    private ISysParkpetOrderService sysParkpetOrderService;

    @Autowired
    private IProductService productService;

    @GetMapping("/parkPetOrderList")
    public String parkPetOrderList(){
        return prefix + "/order";
    }

    @GetMapping("/order")
    public String order(ModelMap mmap)
    {
        User user = ShiroUtils.getSysUser();
        if (user != null) {
            mmap.put("userName", user.getUserName());
        }

        Product product = new Product();
        product.setProductType("宠物信息");
        product.setPetType("售卖");
        List<Product> productList = productService.selectProductList(product);

        mmap.put("productList", productList);

        return "front/parkPetOrder";
    }

    /**
     * 查询寄养订单管理列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysParkpetOrder sysParkpetOrder)
    {
        startPage();

        User user = ShiroUtils.getSysUser();

        if(user.getRoles().get(0).getRoleId() == 2){
            sysParkpetOrder.setUserId(user.getUserId());
        }

        List<SysParkpetOrder> list = sysParkpetOrderService.selectSysParkpetOrderList(sysParkpetOrder);
        return getDataTable(list);
    }

    /**
     * 新增寄养订单管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存寄养订单管理
     */
    @Log(title = "寄养订单管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysParkpetOrder sysParkpetOrder)
    {
        sysParkpetOrder.setStatus("待寄养");

        User user = ShiroUtils.getSysUser();
        sysParkpetOrder.setUserId(user.getUserId());

        SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmsss");
        String number = format.format(new Date());
        sysParkpetOrder.setOrderNumber(number);

        sysParkpetOrderService.insertSysParkpetOrder(sysParkpetOrder);

        return AjaxResult.success(number);
    }

    /**
     * 修改寄养订单管理
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SysParkpetOrder sysParkpetOrder = sysParkpetOrderService.selectSysParkpetOrderById(id);
        mmap.put("sysParkpetOrder", sysParkpetOrder);
        return prefix + "/edit";
    }

    /**
     * 修改保存寄养订单管理
     */
    @Log(title = "寄养订单管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysParkpetOrder sysParkpetOrder)
    {
        return toAjax(sysParkpetOrderService.updateSysParkpetOrder(sysParkpetOrder));
    }

    /**
     * 删除寄养订单管理
     */
    @Log(title = "寄养订单管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysParkpetOrderService.deleteSysParkpetOrderByIds(ids));
    }
}

源码获取:俺的博客首页 "资源" 里下载!

  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

beyondwild

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值