大家好!我是程序员一帆,感谢您阅读本文,欢迎一键三连哦。
💞当前专栏:Java毕业设计
精彩专栏推荐👇🏻👇🏻👇🏻
开发环境
- 开发语言:Java
- 框架:ssm
- JDK版本:JDK1.8
- 服务器:tomcat7
- 数据库:mysql 5.7
- 数据库工具:Navicat12
- 开发软件:eclipse/myeclipse/idea
- Maven包:Maven3.3.9
- 浏览器:谷歌浏览器
源码下载地址:
https://download.csdn.net/download/2301_76953549/89298685
论文目录
【如需全文请按文末获取联系】
一、项目简介
果蔬商品管理系统按照操作主体分为管理员与用户。管理员权限操作的功能包括管理用户资料,管理用户订单,管理商品以及新闻,管理用户反馈信息等。用户权限操作的功能包括关注商品,购买商品,对订单商品进行退款,收货或评价,提交投诉信息,查看新闻。该系统采用了Mysql数据库,Java语言,SSM框架等技术进行编程实现。
二、系统设计
2.1软件功能模块设计
图4.1即为设计的管理员功能结构,管理员权限操作的功能包括管理用户资料,管理用户订单,管理商品以及新闻,管理用户反馈信息等。
图4.2即为设计的用户功能结构,用户权限操作的功能包括关注商品,购买商品,对订单商品进行退款,收货或评价,提交投诉信息,查看新闻。
2.2数据库设计
(1)图4.4即为商品这个实体所拥有的属性值。
(3)图4.6即为订单这个实体所拥有的属性值。
(5)图4.8即为上面介绍的实体中存在的联系。
三、系统项目部分截图
3.1管理员功能实现
用户管理
图5.1 即为编码实现的用户管理界面,管理员在该界面中能够对系统前端已经注册的用户资料进行管理,包括重置密码,更改或删除用户资料等操作。
商品订单管理
图5.2 即为编码实现的商品订单管理界面,管理员在该界面中查询用户订单,查看订单类型,对订单发货。
在线反馈管理
图5.3 即为编码实现的在线反馈管理界面,管理员在该界面中对未回复状态的新消息进行回复。
3.2用户功能实现
商品信息
图5.6 即为编码实现的商品信息界面,用户在该界面中实现对商品的购买,加入购物车以及关注商品等操作。
购物车
图5.7 即为编码实现的购物车界面,用户在该界面中完成对需要购买的商品进行数量更改或删除不需要购买的商品信息。
确认下单
图5.8 即为编码实现的确认下单界面,用户在该界面中查看并确认需要购买商品的清单,选择收货的地址并进行订单提交。
四、部分核心代码
package com.controller;
import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;
/**
* 商品关注
* 后端接口
* @author
* @email
*/
@RestController
@Controller
@RequestMapping("/goodsCollection")
public class GoodsCollectionController {
private static final Logger logger = LoggerFactory.getLogger(GoodsCollectionController.class);
@Autowired
private GoodsCollectionService goodsCollectionService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;
//级联表service
@Autowired
private GoodsService goodsService;
@Autowired
private YonghuService yonghuService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role"));
if(StringUtil.isEmpty(role))
return R.error(511,"权限为空");
else if("用户".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId"));
if(params.get("orderBy")==null || params.get("orderBy")==""){
params.put("orderBy","id");
}
PageUtils page = goodsCollectionService.queryPage(params);
//字典表数据转换
List<GoodsCollectionView> list =(List<GoodsCollectionView>)page.getList();
for(GoodsCollectionView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
}
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
GoodsCollectionEntity goodsCollection = goodsCollectionService.selectById(id);
if(goodsCollection !=null){
//entity转view
GoodsCollectionView view = new GoodsCollectionView();
BeanUtils.copyProperties( goodsCollection , view );//把实体数据重构到view中
//级联表
GoodsEntity goods = goodsService.selectById(goodsCollection.getGoodsId());
if(goods != null){
BeanUtils.copyProperties( goods , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setGoodsId(goods.getId());
}
//级联表
YonghuEntity yonghu = yonghuService.selectById(goodsCollection.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setYonghuId(yonghu.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody GoodsCollectionEntity goodsCollection, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,goodsCollection:{}",this.getClass().getName(),goodsCollection.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(StringUtil.isEmpty(role))
return R.error(511,"权限为空");
else if("用户".equals(role))
goodsCollection.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
Wrapper<GoodsCollectionEntity> queryWrapper = new EntityWrapper<GoodsCollectionEntity>()
.eq("goods_id", goodsCollection.getGoodsId())
.eq("yonghu_id", goodsCollection.getYonghuId())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
GoodsCollectionEntity goodsCollectionEntity = goodsCollectionService.selectOne(queryWrapper);
if(goodsCollectionEntity==null){
goodsCollection.setInsertTime(new Date());
goodsCollection.setCreateTime(new Date());
goodsCollectionService.insert(goodsCollection);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody GoodsCollectionEntity goodsCollection, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,goodsCollection:{}",this.getClass().getName(),goodsCollection.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(StringUtil.isEmpty(role))
return R.error(511,"权限为空");
else if("用户".equals(role))
goodsCollection.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
//根据字段查询是否有相同数据
Wrapper<GoodsCollectionEntity> queryWrapper = new EntityWrapper<GoodsCollectionEntity>()
.notIn("id",goodsCollection.getId())
.andNew()
.eq("goods_id", goodsCollection.getGoodsId())
.eq("yonghu_id", goodsCollection.getYonghuId())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
GoodsCollectionEntity goodsCollectionEntity = goodsCollectionService.selectOne(queryWrapper);
if(goodsCollectionEntity==null){
// String role = String.valueOf(request.getSession().getAttribute("role"));
// if("".equals(role)){
// goodsCollection.set
// }
goodsCollectionService.updateById(goodsCollection);//根据id更新
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
goodsCollectionService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 批量上传
*/
@RequestMapping("/batchInsert")
public R save( String fileName){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
try {
List<GoodsCollectionEntity> goodsCollectionList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
Date date = new Date();
int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀");
}else{
String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){
return R.error(511,"只支持后缀为xls的excel文件");
}else{
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
File file = new File(resource.getFile());
if(!file.exists()){
return R.error(511,"找不到上传文件,请联系管理员");
}else{
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
dataList.remove(0);//删除第一行,因为第一行是提示
for(List<String> data:dataList){
//循环
GoodsCollectionEntity goodsCollectionEntity = new GoodsCollectionEntity();
// goodsCollectionEntity.setGoodsId(Integer.valueOf(data.get(0))); //商品 要改的
// goodsCollectionEntity.setYonghuId(Integer.valueOf(data.get(0))); //用户 要改的
// goodsCollectionEntity.setInsertTime(date);//时间
// goodsCollectionEntity.setCreateTime(date);//时间
goodsCollectionList.add(goodsCollectionEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
goodsCollectionService.insertBatch(goodsCollectionList);
return R.ok();
}
}
}
}catch (Exception e){
return R.error(511,"批量插入数据异常,请联系管理员");
}
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
// 没有指定排序字段就默认id倒序
if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
params.put("orderBy","id");
}
PageUtils page = goodsCollectionService.queryPage(params);
//字典表数据转换
List<GoodsCollectionView> list =(List<GoodsCollectionView>)page.getList();
for(GoodsCollectionView c:list)
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
return R.ok().put("data", page);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
GoodsCollectionEntity goodsCollection = goodsCollectionService.selectById(id);
if(goodsCollection !=null){
//entity转view
GoodsCollectionView view = new GoodsCollectionView();
BeanUtils.copyProperties( goodsCollection , view );//把实体数据重构到view中
//级联表
GoodsEntity goods = goodsService.selectById(goodsCollection.getGoodsId());
if(goods != null){
BeanUtils.copyProperties( goods , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setGoodsId(goods.getId());
}
//级联表
YonghuEntity yonghu = yonghuService.selectById(goodsCollection.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setYonghuId(yonghu.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody GoodsCollectionEntity goodsCollection, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,goodsCollection:{}",this.getClass().getName(),goodsCollection.toString());
Wrapper<GoodsCollectionEntity> queryWrapper = new EntityWrapper<GoodsCollectionEntity>()
.eq("goods_id", goodsCollection.getGoodsId())
.eq("yonghu_id", goodsCollection.getYonghuId())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
GoodsCollectionEntity goodsCollectionEntity = goodsCollectionService.selectOne(queryWrapper);
if(goodsCollectionEntity==null){
goodsCollection.setInsertTime(new Date());
goodsCollection.setCreateTime(new Date());
// String role = String.valueOf(request.getSession().getAttribute("role"));
// if("".equals(role)){
// goodsCollection.set
// }
goodsCollectionService.insert(goodsCollection);
return R.ok();
}else {
return R.error(511,"您已经关注过了");
}
}
}
获取源码或论文
如需对应的论文或源码,以及其他定制需求,也可以下方微❤联系。