首页 > 编程语言 >基于微信小程序UNIAPP+Spring Boot的涪陵区特色农产品交易系统

基于微信小程序UNIAPP+Spring Boot的涪陵区特色农产品交易系统

时间:2024-09-18 12:20:47浏览次数:3  
标签:UNIAPP return 微信 org user new 涪陵区 import public

目录

前言

 一、技术栈

二、系统功能介绍

三、核心代码

1、登录模块

 2、文件上传模块

3、代码封装


前言

相比于以前的传统手工管理方式,智能化的管理方式可以大幅降低特色农产品交易的运营人员成本,实现了涪陵区特色农产品交易的标准化、制度化、程序化的管理,有效地防止了涪陵区特色农产品交易的随意管理,提高了信息的处理速度和精确度,能够及时、准确地查询和修正商品信息、购物车、公告资讯等信息。

课题主要采用Uni-weixin、springboot架构技术,前端以小程序页面呈现给用户,结合后台java语言使页面更加完善,后台使用MySQL数据库进行数据存储。微信小程序主要包括商品信息、购物车、公告资讯等功能,从而实现智能化的管理方式,提高工作效率。 

 一、技术栈

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

二、系统功能介绍

注册界面,第一次使用本小程序的使用者,首先是要进行注册,点击“注册”,然后就会进入到注册的页面里面,将用户信息录入注册表,确认信息正确后,页面才会跳转到登录界面,用户登录成功后可使用本小程序所提供的所有功能,如图5-1所示。

 

 登录界面,首先双击打开微信小程序端系统,连上网络之后会显示出本系统的登录界面,这是进入小程序的第初始页面“登录”,能成功进入到该登录界面则代表小程序的开启是成功的,接下来就可以操作本系统所带有的其他所有的功能,如图5-2所示。

 

 系统首页是用户注册登录后进入的第一个界面,用户可通过小程序端首页进入对应的页面或者通过小程序最下面的那一行导航栏中的“首页、商品信息、购物车、公告资讯、我的”,如图5-3所示。

 

 用户点击商品信息,在商品信息页面的搜索栏输入商品名称、商品分类、价格,进行查询,还可以查看商品名称、商品分类、商品图片、商品规格、商品品牌、上架日期、商品产地、单次限购、商品库存、价格等详情,按照提示加入购物车、立即购买或者收藏、评论等。如图5-4所示。

 

 管理员的登陆界面包括管理员的账号、密码,其中就是已有的账号,还有需要注册的账号。只要管理员在账号上注册,注册信息就会被录入 MySQL数据库,有一个资料库,只要输入成功,就可以登陆,然后进入主页的管理。管理员登录界面如图5-5所示。

 

 管理员登录到涪陵区特色农产品交易系统可以查看首页、个人中心、用户管理、商品分类管理、商品信息管理、系统管理、订单管理等功能进行详细操作,如图5-6所示。

 管理员点击用户管理;在用户管理页面输入用户名、姓名、性别、年龄、头像、手机、邮箱、密保问题、密保答案等信息,进行查询,新增或删除用户信息等操作;如图5-7所示。

 管理员点击商品分类管理;在商品分类管理页面对商品分类等信息,进行查询或删除商品分类等操作;如图5-8所示。

 管理员点击商品信息管理;在商品信息管理页面输入商品名称、商品分类、商品图片、商品规格、商品品牌、上架日期、商品产地、单次限购、商品库存、价格等信息,进行查询、新增或删除商品信息等操作;如图5-9所示。

 管理员点击系统管理;在系统管理页面对关于我们、轮播图管理、系统简介、公告资讯、客服中心等信息,进行查询或删除系统信息等操作;如图5-10所示。

 管理员点击订单管理;在订单管理页面对订单编号、商品名称、商品图片、购买数量、价格、折扣价格、总价格、折扣总价格、支付类型、状态、地址、电话、收货人、备注、商品类型、下单时间等信息,进行查询或删除订单信息等操作;如图5-11所示。

 

三、核心代码

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

标签:UNIAPP,return,微信,org,user,new,涪陵区,import,public
From: https://blog.csdn.net/2301_77541824/article/details/142329931

相关文章

  • 基于微信小程序的电影订票系统-计算机毕业设计源码+LW文档
    一、立题意义及国内外的研究现状与存在问题,主要研究内容及拟解决的关键性问题立题意义现在中国大部分的家庭都喜欢在家里置办属于自己风格的家庭影院。但是仍然有很人喜欢到电影院去看电影。因为家里的气氛毕竟不如影院好。所以现代家庭影院的出现并不会让电影院没有生路。电影种......
  • 基于微信小程序的校园外卖平台设计与实现-计算机毕业设计源码+LW文档
    校园外卖平台设计与实现摘要随着信息技术在管理上越来越深入而广泛的应用,管理信息系统的实施在技术上已逐步成熟。本文介绍了校园外卖平台的开发全过程。通过分析校园外卖平台管理的不足,创建了一个计算机管理校园外卖平台的方案。文章介绍了校园外卖平台的系统分析部分,包括可行性......
  • 【开题报告】基于Springboot+vue基于微信小程序的手机点餐软件(程序+源码+论文) 计算机
    本系统(程序+源码)带文档lw万字以上文末可获取一份本项目的java源码和数据库参考。系统程序文件列表开题报告内容研究背景随着移动互联网技术的飞速发展和智能手机普及率的不断提高,人们的生活方式正经历着深刻的变革。餐饮行业作为传统服务业的重要组成部分,也迎来了数字化......
  • 基于微信小程序的云上考场-计算机毕业设计源码+LW文档
    微信小程序现已成为人们日常生活中必不可少的应用小程序,我们的设计则是介于小程序上的云上考试及刷题系统,通过微信开发工具的和mysql数据库的实现完成,使用者可以在我们的小程序中找到自己需要的题库进行练习和模拟考试,题库我们将分为三大板块,1常规题目,2中级难度,3特难大题,所有刷题......
  • 基于微信小程序居住证申报系统-计算机毕业设计源码+LW文档
    .1题目背景  随着时代的发展,人口流动越来越频繁,离开常住户口所在地到外地工作生活的人越来越多,确保城市出租房内的租住人员和行业单位从业人员情况的准确性、真实性,是流动人口管理的一大难点,随之而来的就是大量的居住证申报,而居住证申报是一件很繁琐的事情,并且有很多人不了解......
  • 微信小程序wx.request请求封装
    config.js//请求地址constBASE_URL="https://localhost:8080"constTIMEOUT=10000export{BASE_URL,TIMEOUT}server.js假设这里返回的数据结构为{"code":0,"msg":"提示信息","data":"返回数据"}当cod......
  • 微信小程序身份证识别
    微信小程序项目中用户注册到了证件识别,获取身份证号码和姓名等,一开始想直接有第三方的证件识别,后面发现微信就有自带的证件识别,免费一天100次(免费使用的也必须0元购买),注册用户没有那么频繁使用,已经足够,就研究了一番。逻辑如下,先用小程序的appId和APP_SECRET获取accesstoken,然后再......
  • 微信小程序全局使用分享
    最近使用UniApp开发微信小程序,需要用到微信分享功能,但是小程序测试的时候分享图标是灰色,无法完成分享功能,如果是单页面分享,可以直接在页面写方法中写onShareAppMessage(){return{title:"欢迎体验",p......
  • Java基于微信小程序的个人财务理财系统App+Vue[毕业设计]
    文末获取资源,收藏关注不迷路文章目录项目介绍技术介绍项目界面关键代码目录项目介绍时代在飞速进步,每个行业都在努力发展现在先进技术,通过这些先进的技术来提高自己的水平和优势,个人财务系统APP当然不能排除在外。个人财务系统APP是在实际应用和软件工程的开发原......
  • 微信授权登录接口开发
    微信登陆过程在项目开发中,难免会遇到微信授权登录这一操作,本讲来讲一下微信登陆是如何实现的?关于校验登录,有诸多方法,记录方法如下:使用SpringMVC提供的拦截器网关服务全局过滤器使用AOP面向横切面实现对于使用SpringMVC提供的拦截器来实现,其大致的思路如下:注意:用户......