一、项目简介
本项目是一套基于springboot社区团购系统,主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的Java学习者。
包含:项目源码、数据库脚本等,该项目附带全部源码可作为毕设使用。
项目都经过严格调试,eclipse或者idea 确保可以运行!
该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值
二、技术实现
springboot+mybatis+mysql+maven+vue+html
三、开发运行环境
jdk1.8
Mysql5.5及以上
maven
idea或者eclipse
四、系统功能
系统登录用户角色分为:管理员,用户
前台包括:
用户登录
用户注册
首页
商品信息推荐
公告资讯
点我收藏
取消收藏
发表评论
添加购物车
立即购买
我要开团
购物车列表
个人中心
我的订单
我的收藏
我的地址
充值
后台包括:
个人中心
修改密码
个人信息
用户管理
商品分类管理
商品信息管理
订单管理:包括未支付、已支付、已取消、已退款、已完成、已发货订单等
系统管理
轮播图管理
公告资讯等
五、页面展示
前台
后台
六、数据库
一共12张表
七、项目结构
八、部分代码展示
上传文件功能
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); /** * 如果使用idea或者eclipse重启项目,发现之前上传的图片或者文件丢失,将下面一行代码注释打开 * 请将以下的"D:\\springbootq33sd\\src\\main\\resources\\static\\upload"替换成你本地项目的upload路径, * 并且项目路径不能存在中文、空格等特殊字符 */ // FileUtils.copyFile(dest, new File("D:\\springbootq33sd\\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.controller; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Map; import java.util.HashMap; import java.util.Iterator; import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletRequest; import com.utils.ValidatorUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.format.annotation.DateTimeFormat; 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 com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.Wrapper; import com.annotation.IgnoreAuth; import com.entity.StoreupEntity; import com.entity.view.StoreupView; import com.service.StoreupService; import com.service.TokenService; import com.utils.PageUtils; import com.utils.R; import com.utils.MD5Util; import com.utils.MPUtil; import com.utils.CommonUtil; import java.io.IOException; /** * 收藏表 * 后端接口 * @author * @email * @date 2022-05-03 22:35:02 */ @RestController @RequestMapping("/storeup") public class StoreupController { @Autowired private StoreupService storeupService; /** * 后端列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,StoreupEntity storeup, HttpServletRequest request){ if(!request.getSession().getAttribute("role").toString().equals("管理员")) { storeup.setUserid((Long)request.getSession().getAttribute("userId")); } EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>(); PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params)); return R.ok().put("data", page); } /** * 前端列表 */ @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,StoreupEntity storeup, HttpServletRequest request){ if(!request.getSession().getAttribute("role").toString().equals("管理员")) { storeup.setUserid((Long)request.getSession().getAttribute("userId")); } EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>(); PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params)); return R.ok().put("data", page); } /** * 列表 */ @RequestMapping("/lists") public R list( StoreupEntity storeup){ EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>(); ew.allEq(MPUtil.allEQMapPre( storeup, "storeup")); return R.ok().put("data", storeupService.selectListView(ew)); } /** * 查询 */ @RequestMapping("/query") public R query(StoreupEntity storeup){ EntityWrapper< StoreupEntity> ew = new EntityWrapper< StoreupEntity>(); ew.allEq(MPUtil.allEQMapPre( storeup, "storeup")); StoreupView storeupView = storeupService.selectView(ew); return R.ok("查询收藏表成功").put("data", storeupView); } /** * 后端详情 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") Long id){ StoreupEntity storeup = storeupService.selectById(id); return R.ok().put("data", storeup); } /** * 前端详情 */ @IgnoreAuth @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") Long id){ StoreupEntity storeup = storeupService.selectById(id); return R.ok().put("data", storeup); } /** * 后端保存 */ @RequestMapping("/save") public R save(@RequestBody StoreupEntity storeup, HttpServletRequest request){ storeup.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(storeup); storeup.setUserid((Long)request.getSession().getAttribute("userId")); storeupService.insert(storeup); return R.ok(); } /** * 前端保存 */ @RequestMapping("/add") public R add(@RequestBody StoreupEntity storeup, HttpServletRequest request){ storeup.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(storeup); storeup.setUserid((Long)request.getSession().getAttribute("userId")); storeupService.insert(storeup); return R.ok(); } /** * 修改 */ @RequestMapping("/update") @Transactional public R update(@RequestBody StoreupEntity storeup, HttpServletRequest request){ //ValidatorUtils.validateEntity(storeup); storeupService.updateById(storeup);//全部更新 return R.ok(); } /** * 删除 */ @RequestMapping("/delete") public R delete(@RequestBody Long[] ids){ storeupService.deleteBatchIds(Arrays.asList(ids)); return R.ok(); } /** * 提醒接口 */ @RequestMapping("/remind/{columnName}/{type}") public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, @PathVariable("type") String type,@RequestParam Map<String, Object> map) { map.put("column", columnName); map.put("type", type); if(type.equals("2")) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); Date remindStartDate = null; Date remindEndDate = null; if(map.get("remindstart")!=null) { Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindStart); remindStartDate = c.getTime(); map.put("remindstart", sdf.format(remindStartDate)); } if(map.get("remindend")!=null) { Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindEnd); remindEndDate = c.getTime(); map.put("remindend", sdf.format(remindEndDate)); } } Wrapper<StoreupEntity> wrapper = new EntityWrapper<StoreupEntity>(); if(map.get("remindstart")!=null) { wrapper.ge(columnName, map.get("remindstart")); } if(map.get("remindend")!=null) { wrapper.le(columnName, map.get("remindend")); } if(!request.getSession().getAttribute("role").toString().equals("管理员")) { wrapper.eq("userid", (Long)request.getSession().getAttribute("userId")); } int count = storeupService.selectCount(wrapper); return R.ok().put("count", count); } }
公告资讯功能
package com.controller; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Map; import java.util.HashMap; import java.util.Iterator; import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletRequest; import com.utils.ValidatorUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.format.annotation.DateTimeFormat; 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 com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.Wrapper; import com.annotation.IgnoreAuth; import com.entity.NewsEntity; import com.entity.view.NewsView; import com.service.NewsService; import com.service.TokenService; import com.utils.PageUtils; import com.utils.R; import com.utils.MD5Util; import com.utils.MPUtil; import com.utils.CommonUtil; import java.io.IOException; /** * 公告资讯 * 后端接口 * @author * @email * @date 2022-05-03 22:35:02 */ @RestController @RequestMapping("/news") public class NewsController { @Autowired private NewsService newsService; /** * 后端列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,NewsEntity news, HttpServletRequest request){ EntityWrapper<NewsEntity> ew = new EntityWrapper<NewsEntity>(); PageUtils page = newsService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, news), params), params)); return R.ok().put("data", page); } /** * 前端列表 */ @IgnoreAuth @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,NewsEntity news, HttpServletRequest request){ EntityWrapper<NewsEntity> ew = new EntityWrapper<NewsEntity>(); PageUtils page = newsService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, news), params), params)); return R.ok().put("data", page); } /** * 列表 */ @RequestMapping("/lists") public R list( NewsEntity news){ EntityWrapper<NewsEntity> ew = new EntityWrapper<NewsEntity>(); ew.allEq(MPUtil.allEQMapPre( news, "news")); return R.ok().put("data", newsService.selectListView(ew)); } /** * 查询 */ @RequestMapping("/query") public R query(NewsEntity news){ EntityWrapper< NewsEntity> ew = new EntityWrapper< NewsEntity>(); ew.allEq(MPUtil.allEQMapPre( news, "news")); NewsView newsView = newsService.selectView(ew); return R.ok("查询公告资讯成功").put("data", newsView); } /** * 后端详情 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") Long id){ NewsEntity news = newsService.selectById(id); return R.ok().put("data", news); } /** * 前端详情 */ @IgnoreAuth @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") Long id){ NewsEntity news = newsService.selectById(id); return R.ok().put("data", news); } /** * 后端保存 */ @RequestMapping("/save") public R save(@RequestBody NewsEntity news, HttpServletRequest request){ news.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(news); newsService.insert(news); return R.ok(); } /** * 前端保存 */ @RequestMapping("/add") public R add(@RequestBody NewsEntity news, HttpServletRequest request){ news.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(news); newsService.insert(news); return R.ok(); } /** * 修改 */ @RequestMapping("/update") @Transactional public R update(@RequestBody NewsEntity news, HttpServletRequest request){ //ValidatorUtils.validateEntity(news); newsService.updateById(news);//全部更新 return R.ok(); } /** * 删除 */ @RequestMapping("/delete") public R delete(@RequestBody Long[] ids){ newsService.deleteBatchIds(Arrays.asList(ids)); return R.ok(); } /** * 提醒接口 */ @RequestMapping("/remind/{columnName}/{type}") public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, @PathVariable("type") String type,@RequestParam Map<String, Object> map) { map.put("column", columnName); map.put("type", type); if(type.equals("2")) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); Date remindStartDate = null; Date remindEndDate = null; if(map.get("remindstart")!=null) { Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindStart); remindStartDate = c.getTime(); map.put("remindstart", sdf.format(remindStartDate)); } if(map.get("remindend")!=null) { Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindEnd); remindEndDate = c.getTime(); map.put("remindend", sdf.format(remindEndDate)); } } Wrapper<NewsEntity> wrapper = new EntityWrapper<NewsEntity>(); if(map.get("remindstart")!=null) { wrapper.ge(columnName, map.get("remindstart")); } if(map.get("remindend")!=null) { wrapper.le(columnName, map.get("remindend")); } int count = newsService.selectCount(wrapper); return R.ok().put("count", count); } }
我的地址功能
package com.controller; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Map; import java.util.HashMap; import java.util.Iterator; import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletRequest; import com.utils.ValidatorUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.format.annotation.DateTimeFormat; 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 com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.Wrapper; import com.annotation.IgnoreAuth; import com.entity.AddressEntity; import com.entity.view.AddressView; import com.service.AddressService; import com.service.TokenService; import com.utils.PageUtils; import com.utils.R; import com.utils.MD5Util; import com.utils.MPUtil; import com.utils.CommonUtil; import java.io.IOException; /** * 地址 * 后端接口 * @author * @email * @date 2022-05-03 22:35:02 */ @RestController @RequestMapping("/address") public class AddressController { @Autowired private AddressService addressService; /** * 后端列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,AddressEntity address, HttpServletRequest request){ if(!request.getSession().getAttribute("role").toString().equals("管理员")) { address.setUserid((Long)request.getSession().getAttribute("userId")); } EntityWrapper<AddressEntity> ew = new EntityWrapper<AddressEntity>(); PageUtils page = addressService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, address), params), params)); return R.ok().put("data", page); } /** * 前端列表 */ @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,AddressEntity address, HttpServletRequest request){ if(!request.getSession().getAttribute("role").toString().equals("管理员")) { address.setUserid((Long)request.getSession().getAttribute("userId")); } EntityWrapper<AddressEntity> ew = new EntityWrapper<AddressEntity>(); PageUtils page = addressService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, address), params), params)); return R.ok().put("data", page); } /** * 列表 */ @RequestMapping("/lists") public R list( AddressEntity address){ EntityWrapper<AddressEntity> ew = new EntityWrapper<AddressEntity>(); ew.allEq(MPUtil.allEQMapPre( address, "address")); return R.ok().put("data", addressService.selectListView(ew)); } /** * 查询 */ @RequestMapping("/query") public R query(AddressEntity address){ EntityWrapper< AddressEntity> ew = new EntityWrapper< AddressEntity>(); ew.allEq(MPUtil.allEQMapPre( address, "address")); AddressView addressView = addressService.selectView(ew); return R.ok("查询地址成功").put("data", addressView); } /** * 后端详情 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") Long id){ AddressEntity address = addressService.selectById(id); return R.ok().put("data", address); } /** * 前端详情 */ @IgnoreAuth @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") Long id){ AddressEntity address = addressService.selectById(id); return R.ok().put("data", address); } /** * 后端保存 */ @RequestMapping("/save") public R save(@RequestBody AddressEntity address, HttpServletRequest request){ address.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(address); address.setUserid((Long)request.getSession().getAttribute("userId")); Long userId = (Long)request.getSession().getAttribute("userId"); if(address.getIsdefault().equals("是")) { addressService.updateForSet("isdefault='否'", new EntityWrapper<AddressEntity>().eq("userid", userId)); } address.setUserid(userId); addressService.insert(address); return R.ok(); } /** * 前端保存 */ @RequestMapping("/add") public R add(@RequestBody AddressEntity address, HttpServletRequest request){ address.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(address); address.setUserid((Long)request.getSession().getAttribute("userId")); Long userId = (Long)request.getSession().getAttribute("userId"); if(address.getIsdefault().equals("是")) { addressService.updateForSet("isdefault='否'", new EntityWrapper<AddressEntity>().eq("userid", userId)); } address.setUserid(userId); addressService.insert(address); return R.ok(); } /** * 修改 */ @RequestMapping("/update") @Transactional public R update(@RequestBody AddressEntity address, HttpServletRequest request){ //ValidatorUtils.validateEntity(address); if(address.getIsdefault().equals("是")) { addressService.updateForSet("isdefault='否'", new EntityWrapper<AddressEntity>().eq("userid", request.getSession().getAttribute("userId"))); } addressService.updateById(address);//全部更新 return R.ok(); } /** * 获取默认地址 */ @RequestMapping("/default") public R defaultAddress(HttpServletRequest request){ Wrapper<AddressEntity> wrapper = new EntityWrapper<AddressEntity>().eq("isdefault", "是").eq("userid", request.getSession().getAttribute("userId")); AddressEntity address = addressService.selectOne(wrapper); return R.ok().put("data", address); } /** * 删除 */ @RequestMapping("/delete") public R delete(@RequestBody Long[] ids){ addressService.deleteBatchIds(Arrays.asList(ids)); return R.ok(); } /** * 提醒接口 */ @RequestMapping("/remind/{columnName}/{type}") public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, @PathVariable("type") String type,@RequestParam Map<String, Object> map) { map.put("column", columnName); map.put("type", type); if(type.equals("2")) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); Date remindStartDate = null; Date remindEndDate = null; if(map.get("remindstart")!=null) { Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindStart); remindStartDate = c.getTime(); map.put("remindstart", sdf.format(remindStartDate)); } if(map.get("remindend")!=null) { Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindEnd); remindEndDate = c.getTime(); map.put("remindend", sdf.format(remindEndDate)); } } Wrapper<AddressEntity> wrapper = new EntityWrapper<AddressEntity>(); if(map.get("remindstart")!=null) { wrapper.ge(columnName, map.get("remindstart")); } if(map.get("remindend")!=null) { wrapper.le(columnName, map.get("remindend")); } if(!request.getSession().getAttribute("role").toString().equals("管理员")) { wrapper.eq("userid", (Long)request.getSession().getAttribute("userId")); } int count = addressService.selectCount(wrapper); return R.ok().put("count", count); } }
九、源码地址
https://download.csdn.net/download/weixin_43860634/87815001