基于SSM的开心农家乐系统设计与实现

news2024/9/23 23:30:21

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


目录

一、项目简介

二、系统功能

三、系统项目截图

用户信息管理

农庄信息管理

特色菜管理

公告信息管理

四、核心代码

登录相关

文件上传

封装


一、项目简介

现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本开心农家乐系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此开心农家乐系统利用当下成熟完善的SSM框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的Mysql数据库进行程序开发.开心农家乐系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。


二、系统功能



三、系统项目截图

用户信息管理

用户信息管理页面,此页面提供给管理员的功能有:用户信息的查询管理,可以删除用户信息、修改用户信息、新增用户信息,还进行了对用户名称的模糊查询的条件

农庄信息管理

农庄信息管理页面,此页面提供给管理员的功能有:查看已发布的农庄信息数据,修改农庄信息,农庄信息作废,即可删除。

特色菜管理

特色菜管理页面,此页面提供给管理员的功能有:根据特色菜进行条件查询,还可以对特色菜进行新增、修改、查询操作等等。

公告信息管理

公告信息管理页面,此页面提供给管理员的功能有:根据公告信息进行新增、修改、查询操作。

 


四、核心代码

登录相关


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/1075082.html

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

相关文章

Tomcat安装

tomcat.apache.org 下载Tomcat8 根据系统选择安装包 配置JAVA_HOME 解压文件&#xff0c;启动Tomcat 启动成功&#xff0c;默认占用8080端口 MAC版本在bin目录输入./startup.sh启动Tomcat 访问Tomcat&#xff1a;localhost:8080 根据tomcat版本选择servlet版本 tomc…

OpenWRT配置SFTP远程文件传输,实现数据安全保护

文章目录 前言1. openssh-sftp-server 安装2. 安装cpolar工具3.配置SFTP远程访问4.固定远程连接地址 前言 本次教程我们将在OpenWRT上安装SFTP服务&#xff0c;并结合cpolar内网穿透&#xff0c;创建安全隧道映射22端口&#xff0c;实现在公网环境下远程OpenWRT SFTP&#xff…

运算符

目录 算术运算符 比较运算符 逻辑运算符 位运算符 运算符的优先级 MySQL从小白到总裁完整教程目录:https://blog.csdn.net/weixin_67859959/article/details/129334507?spm1001.2014.3001.5502 数据库中的表结构确立后&#xff0c;表中的数据代表的意义就已经确定。而…

[护网杯 2018]easy_tornado 解析

打开网页有三个链接&#xff0c;依次点开之后获得一个fllllllllllllag一个render和一个MD5加密格式 之后尝试去访问/fllllllllllllag 直接跳出报错界面。 但这个报错界面居然是可以改的 试着注入一下 看了师傅的wp发现好像没有&#xff0c;要从框架入手 框架就是标题的torna…

[极客大挑战 2020]Roamphp2-Myblog - 伪协议+文件上传+(LFIZIP)||(LFIPhar)【***】

[极客大挑战 2020]Roamphp2-Myblog 1 解题流程1.1 分析1.2 解题1.3 中场休息——再分析1.3.1 浅层分析1.3.2 难点疑惑1.3.3 深度分析 1.4 重整旗鼓——再战1.4.1 解法一&#xff1a;zip伪协议1.4.2 解法二&#xff1a;phar伪协议 2 总结展望 1 解题流程 1.1 分析 1、点击logi…

OpenCV4(C++)—— 图片的基本尺寸变换

文章目录 一、resize&#xff08;缩放&#xff09;二、filp&#xff08;翻转&#xff09;三、裁剪四、拼接 一、resize&#xff08;缩放&#xff09; void cv::resize(cv::InputArray src, // 输入图像cv::OutputArray dst, // 输出图像cv::Size dsize, …

C++对象模型(6)-- 数据语义学:继承的对象布局(含虚函数)

1、单个类带虚函数的对象布局 当类含有虚函数时&#xff0c;在实例化对象时会产生一个虚函数表指针&#xff0c;这个虚函数表指针通常在对象的开头位置。 class Base { public:int x;int y;virtual void virFunc() { } }; 对象布局如下&#xff1a; 2、单一继承父类带虚函数…

ZYNQ的程序固化

03-ZYNQ学习&#xff08;启动篇&#xff09;之程序的固化_zynq ps网口-CSDN博客 ZYNQ启动之后&#xff0c; PS_POR_B 复位引脚置低后&#xff0c;硬件立即对引导带引脚进行采样&#xff0c;并可选择启用 PS 时钟 PLL。然后&#xff0c;PS开始执行片上ROM中的BootROM代码来引导…

UniApp项目实践HelloUni继续快速小步快跑中,前面是大上海吗

效果镇楼 本来想着稍微刷点课程就完活的&#xff0c;结果还是到这个点了。宝贵的时间啊 直接代码干就是了&#xff0c;参考如下链接&#xff1b; UniApp实践业务项目

使用Resource Hacker编辑DLL文件

Resource Hacker下载 链接&#xff1a;https://pan.quark.cn/s/8e18988d49aa 操作 打开resource hacker软件 打开文件 修改 编译&#xff0c;点击绿色按钮 提示成功 将编译后的文件另存为即可

C语言纳秒级计时

C语言纳秒级计时 文章目录 C语言纳秒级计时函数介绍示例代码参考 函数介绍 C语言中常用的clock()函数只能精确到毫秒级&#xff0c;对应的数据类型是clock_t。 C11标准中提供了纳秒级别定时器&#xff1a;timespec_get()函数与timespec()类型。 struct timespec{time_t tv_s…

找不到msvcp140.dll导致代码无法继续执行 ,8个方法搞定msvcp140.dll文件缺失问题

首先&#xff0c;让我们了解一下 msvcp140.dll 文件。msvcp140.dll 是 Microsoft Visual Studio 2010 编译的程序所使用的动态链接库之一&#xff0c;它包含了一些 C标准库函数的实现&#xff0c;例如 std::vector、std::string 等。这个文件主要被用于支持 C程序的运行&#x…

计算机是如何启动的

一直好奇计算机启动的原理是怎么样的&#xff1f;最近刚好想搞一下操作系统&#xff0c;故此总结一下。 打开电源 对于现代计算机来说&#xff0c;打开电源是开机的第一步&#xff0c;这一点无用质疑&#xff0c;离开了电&#xff0c;现代社会估计就会垮台。 计算机启动 加电…

ctfshow-web9(奇妙的ffifdyop绕过)

尝试万能密码登录&#xff0c;没有任何回显 尝试扫描目录&#xff0c;这里不知道为啥御剑什么都扫不到&#xff0c;使用dirsearch可以扫到robots.txt 查看robots协议 访问下载index.phps 查看index.phps 简单审计一下php代码&#xff1a; $password$_POST[password]; if(strl…

Linux——多线程1

目录 一.理解线程的概念 Linux线程概念 二.线程的优点 三.线程的缺点 四.线程用途 五. Linux进程VS线程 一.理解线程的概念 教材观点&#xff1a; 线程是一种执行分支&#xff0c;执行粒度比进程更细&#xff0c;调度成本更低。线程是进程内部的一个执行流。 内核观点: …

【Python查找算法】二分查找、线性查找、哈希查找

目录 1 二分查找算法 2 线性查找算法 3 哈希查找算法 1 二分查找算法 二分查找&#xff08;Binary Search&#xff09;是一种用于在有序数据集合中查找特定元素的高效算法。它的工作原理基于将数据集合分成两半&#xff0c;然后逐步缩小搜索范围&#xff0c;直到找到目标元素…

python的一些知识点

之前自学过python&#xff0c;学了一些基本语法&#xff0c;但忘得厉害。最近&#xff0c;在努力地写代码&#xff0c;在学代码&#xff0c;写代码中学习python&#xff0c;为此记录一些关于python的知识点。

四、综合——通信系统

文章目录 一、通信系统概述1.1 通信的基本概念1.2 通信系统的组成二、信道的定义和分类三、信源编码四、调制一、通信系统概述 1.1 通信的基本概念 通信是发送者(人或机器)和接收者之间通过某种媒体进行的信息传递。广义来讲。光通信也属于电通信,因为光也是一种电磁波。 …

2023.10.09

#include <iostream>using namespace std;//定义一个类&#xff08;人&#xff09; class Per { private:string name;//姓名int age;//年龄//体重和身高另存堆空间double* height;//身高double* weight;//体重 public://定义构造函数&#xff0c;并且初始化//运用初始化…

【致敬未来的攻城狮计划】第2期 作业汇总贴 + 获奖公布

一、写在前面 时间过得真快&#xff0c;距离 【致敬未来的攻城狮计划】第2期 的发起&#xff0c;已经过去一个多月了&#xff0c;而第2期的真正学习考核期也将在5/13的18点整正式结束。 关于第2期的活动计划&#xff0c;感兴趣的可以参见这里&#xff1a;【重磅推出】《致敬未…