首页 > 其他分享 >基于Spring Boot的果蔬种植销售一体化服务平台

基于Spring Boot的果蔬种植销售一体化服务平台

时间:2024-10-12 11:53:28浏览次数:3  
标签:return Spring Boot user import new 果蔬 public

目录

前言

 一、技术栈

二、系统功能介绍

三、核心代码

1、登录模块

 2、文件上传模块

3、代码封装


前言

伴随着我国社会的发展,人民生活质量日益提高。于是对果蔬种植销售一体化服务管理进行规范而严格是十分有必要的,所以许许多多的信息管理系统应运而生。此时单靠人力应对这些事务就显得有些力不从心了。所以本论文将设计一套果蔬种植销售一体化服务平台,帮助商户进行果蔬信息、果蔬入库、商户活动、联系商户、订单等繁琐又重复的工作,提高工作效率的同时,也减轻了管理者的压力。

本论文的主要内容包括:

第一,研究分析当下主流的web技术,结合果蔬种植销售日常管理方式,进行果蔬种植销售一体化服务平台的数据库设计,设计果蔬种植销售一体化服务平台功能,并对每个模块进行说明。

第二,陈列说明该系统实现所采用的架构、系统搭建采用的服务器、系统开发环境和使用的工具,以及系统后台采用的数据库。

最后,对系统进行全面测试,主要包括功能测试、查询性能测试、安全性能测试。

分析系统存在的不足以及将来改进的方向。

 一、技术栈

末尾获取源码
Spring Boot+JS+ jQuery+Ajax...

二、系统功能介绍

网站首页页面主要包括首页、果蔬信息、商户活动、助农信息、通知公告、后台管理、购物车、个人中心等内容,并根据需要进行详细操作;如图5-1所示:

 注册时将进行密码校验,若密码不一致将不能注册,以此来防止用户输入错误密码,影响体验,下面截图是用户注册成功页面,如图5-2所示。

 用户将在此界面进行身份验证和登录,该页面将在前台提交数据给后台之前对表单中的用户名和密码进行格式校验,比如输入的验证信息不能为空,并给予相应的提示信息,下面截图是用户登录成功页面,如图5-3所示。

 用户点击商品信息,在商品信息页面的搜索栏输入果蔬名称、果蔬分类、产地、店铺名、价格,可以查询,也可以查看果蔬名称、果蔬分类、封面、产地、成熟度、上架日期、保质期、商户账号、店铺名、单限、库存、点击次数、价格等内容,并进行添加购物车、立即购买、收藏或者评论等操作;如图5-4所示。

 用户点击商户活动,在商户活动页面的搜索栏输入标题、店铺名,可以查询,也可以查看标题、发布时间、商户账号、店铺名、封面、点击次数等内容,收藏或者评论等操作;如图5-5所示。

 用户点击个人中心,在个人中心页面可以修改个人信息、密码修改,然后可以对我的订单、我的地址、我的收藏进行详细操作,如图5-6所示。

 管理员进行登录,进入系统前在登录页面根据要求填写用户名和密码、验证码等信息,点击登录操作,如图5-7所示。

 管理员登录系统后,可以对系统首页、个人中心、用户管理、商户管理、果蔬分类管理、果蔬信息管理、果蔬入库管理、商户活动管理、助农信息管理、联系商户管理、系统管理、订单管理等进行相应的操作管理,如图5-8所示。

 管理员点击用户管理,在用户管理页面输入账号、姓名、年龄、性别、手机、头像等信息,然后进行查询、新增或删除用户信息等操作,如图5-9所示。

 管理员点击商户管理,在商户管理页面输入商户账号、店铺名、负责人、联系电话、建筑面积、店铺地址、封面、审核回复、审核状态、审核等信息,然后进行查询、新增或删除商户信息等操作,如图5-10所示。

 管理员点击果蔬信息管理,在果蔬信息管理页面输入果蔬名称、果蔬分类、封面、产地、成熟度、上架日期、保质期、商户账号、店铺名、单限、库存、点击次数、价格等信息,然后进行查询或删除果蔬信息等操作,如图5-11所示。

 管理员点击果蔬入库管理,在果蔬入库管理页面对入库单号、果蔬名称、果蔬分类、库存、入库时间、备注等信息,然后进行查询或删除果蔬入库等操作,如图5-12所示。

 管理员点击果蔬入库管理,在果蔬入库管理页面对入库单号、果蔬名称、果蔬分类、库存、入库时间、备注等信息,然后进行查询或删除果蔬入库等操作,如图5-12所示。

 管理员点击助农信息管理,在助农信息管理页面对标题、视频、发布时间、封面、点击次数等信息,然后进行查询、新增或删除助农信息等操作,如图5-14所示。

 在系统上商户点击注册/登录按钮,在注册、登录界面填写信息完成后,单击注册或者登录操作,如图5-16  5-17所示:

 

 商户登录系统后可以对系统首页、个人中心、果蔬信息管理、果蔬入库管理、商户活动管理、联系商户管理、订单管理等功能进行操作。如图5-18所示:

 用户登录到系统后可以对系统首页、个人中心、联系商户管理等功能进行操作。如图5-20所示:

 

三、核心代码

1、登录模块

 
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();
    }
}

 2、文件上传模块

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);
	}
	
}

3、代码封装

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;
	}
}

标签:return,Spring,Boot,user,import,new,果蔬,public
From: https://blog.csdn.net/2301_77541824/article/details/142866479

相关文章

  • springboot+vue基于Web的校园羽毛球馆管理系统【开题+程序+论文】
    系统程序文件列表开题报告内容研究背景在当今信息化快速发展的时代,高校作为知识传播与创新的重要场所,其基础设施的管理与服务水平直接影响到师生的学习与生活体验。羽毛球作为一项广受欢迎的体育运动,不仅能够锻炼身体,还能促进社交互动。然而,传统的高校羽毛球馆管理方式存在......
  • springboot+vue火车订票模拟系统【开题+程序+论文】
    系统程序文件列表开题报告内容研究背景随着信息技术的飞速发展,传统火车订票方式已难以满足现代社会的需求。传统的订票方式往往需要用户亲自前往售票点或通过电话进行预订,这种方式不仅效率低下,还容易出现信息滞后、排队等候等问题。为了解决这些问题,火车订票模拟系统的开发......
  • springboot+vue基于springboot高校毕业生信息管理系统【开题+程序+论文】
    系统程序文件列表开题报告内容研究背景随着高等教育的普及和毕业生就业市场的竞争加剧,高校毕业生信息管理系统成为了各大高校不可或缺的一部分。传统的人工管理方式不仅效率低下,还容易出现信息错漏和更新不及时的问题。近年来,随着信息技术的飞速发展,尤其是SpringBoot等轻......
  • 基于SpringBoot+Vue的体育馆场地预约系统
    作者:计算机学姐开发技术:SpringBoot、SSM、Vue、MySQL、JSP、ElementUI、Python、小程序等,“文末源码”。专栏推荐:前后端分离项目源码、SpringBoot项目源码、Vue项目源码、SSM项目源码、微信小程序源码精品专栏:Java精选实战项目源码、Python精选实战项目源码、大数据精选......
  • 三、Spring Boot集成Spring Security之securityFilterChain过滤器链详解
    二、默认过滤器链1、默认配置系统启动日志2、默认配置的过滤器及顺序如下org.springframework.security.web.session.DisableEncodeUrlFilterorg.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilterorg.springframework.security.web.c......
  • 探索Spring Boot在医疗病历B2B交互中的潜力
    第2章设计技术与开发环境2.1相关技术介绍2.1.1B/S模式分析C/S模式主要由客户应用程序(Client)、服务器管理程序(Server)和中间件(middleware)三个部件组成。客户应用程序是系统中用户与数据组件交互。服务器程序负责系统资源,如管理信息数据库的有效管理,其主要工作是当......
  • Spring Boot在医疗B2B平台中的病历数据安全
    第3章需求分析与可行性分析3.1需求分析伴随着信息行业的蓬勃发展和人们办公自动化意识的增强,学习信息管理部门的工作也越来越繁重,原来的基于B2B平台的医疗病历交互系统已经不能完全满足相关人员使用的需要。为了协助信息开展学习信息管理工作,提高工作效率,充分利用信息行......
  • springboot空巢老人健康管理系统小程序-计算机毕业设计源码29889
    摘 要随着社会老龄化程度不断加剧,空巢老人群体的健康管理问题日益引起人们的关注。为了更好地满足空巢老人群体的健康管理需求,本研究致力于设计并实现一款基于SpringBoot框架的空巢老人健康管理系统。该系统旨在为管理员用户、老人用户和医生用户提供全方位的健康管理服务,......
  • 基于Spring Boot+VUE 大学生租房系统(高分毕设)
    文章目录文章目录一、系统需求分析二、系统设计三、系统页面1系统功能模块2管理员模块3房主功能模块4用户功能模块四、资源下载链接 一、系统需求分析根据大学生租房系统的功能需求,进行系统设计。前台功能:进入系统可以实现首页,房屋信息,房屋评价,公告资讯,个人中心,......
  • Spring Boot 集成 RabbitMQ 多个 Broker 发送、消费消息
    1.SpringBoot集成RabbitMQ多个Broker发送、消费消息1.1.版本说明1.2.概述1.3.RabbitMQ信息1.4.Spring配置1.5.定义常量1.6.定义配置属性1.7.定义两个ConnectionFactory1.8.定义两个RabbitTemplate1.9.定义两个SimpleRabbitListenerContainerFacto......