✨作者主页:IT毕设梦工厂✨
个人简介:曾从事计算机专业培训教学,擅长Java、Python、微信小程序、Golang、安卓Android等项目实战。接项目定制开发、代码讲解、答辩教学、文档编写、降重等。
☑文末获取源码☑
精彩专栏推荐⬇⬇⬇
Java项目
Python项目
安卓项目
微信小程序项目
一、前言
随着互联网的普及和电子商务的快速发展,网上蛋糕销售系统作为一种新型的商业模式,为蛋糕销售提供了新的渠道和机遇。
现有的网上蛋糕销售系统普遍存在一些问题,例如用户界面不够直观、操作复杂,导致用户体验不佳;系统对蛋糕种类和库存的管理不够灵活,难以满足市场的多样化需求;支付和物流等配套服务不够完善,影响了用户的购买决策。此外,系统的安全性和数据保护措施也有待加强。
本课题旨在设计并实现一个功能齐全、操作简便、用户友好的网上蛋糕销售系统。系统将提供蛋糕展示、分类浏览、购物车管理、订单处理、在线支付、物流追踪等功能,同时加强数据安全和隐私保护,提升用户体验和满意度。
本课题的研究具有重要的理论意义和实际意义。从理论角度来看,它为电子商务领域提供了新的研究思路,即如何利用现代信息技术提升网上购物的便捷性和安全性。从实际角度来看,该系统的应用将有助于拓宽蛋糕销售渠道,提高销售效率,降低运营成本,增强企业的市场竞争力,同时也为消费者提供了更加便捷、个性化的购物体验 。
在网上蛋糕销售系统中,管理人员负责用户账户的管理、蛋糕信息的维护、订单处理、支付和物流管理;用户可以浏览蛋糕信息、进行分类筛选、管理购物车、提交订单、在线支付、查看订单状态。系统通过这些功能模块的整合,旨在提供一个便捷的网上蛋糕购买平台 。
二、开发环境
- 开发语言:Java/Python
- 数据库:MySQL
- 系统架构:B/S
- 后端:SpringBoot/SSM/Django/Flask
- 前端:Vue
三、系统界面展示
- 网上蛋糕销售系统-网上蛋糕商城界面展示:
用户-查看蛋糕信息:
用户-领取优惠券:
用户-购物车管理:
用户-订单管理:
管理员-首页统计:
管理员-订单管理:
管理员-蛋糕信息管理:
管理员-材料信息管理(库存预警):
管理员-优惠券管理:
四、部分代码设计
- 项目实战-代码参考:
@RestController
@Controller
@RequestMapping("/dangao")
public class DangaoController {
private static final Logger logger = LoggerFactory.getLogger(DangaoController.class);
private static final String TABLE_NAME = "dangao";
@Autowired
private DangaoService dangaoService;
@Autowired
private TokenService tokenService;
@Autowired
private AddressService addressService;//收货地址
@Autowired
private CartService cartService;//购物车
@Autowired
private DangaoCollectionService dangaoCollectionService;//商品收藏
@Autowired
private DangaoCommentbackService dangaoCommentbackService;//商品评价
@Autowired
private DangaoOrderService dangaoOrderService;//商品订单
@Autowired
private DianyuanService dianyuanService;//店员
@Autowired
private DictionaryService dictionaryService;//字典
@Autowired
private ForumService forumService;//论坛
@Autowired
private NewsService newsService;//公告信息
@Autowired
private YonghuService yonghuService;//用户
@Autowired
private UsersService usersService;//管理员
/**
* 后端列表
*/
@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(false)
return R.error(511,"永不会进入");
else if("用户".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId"));
else if("店员".equals(role))
params.put("dianyuanId",request.getSession().getAttribute("userId"));
params.put("dangaoDeleteStart",1);params.put("dangaoDeleteEnd",1);
CommonUtil.checkMap(params);
PageUtils page = dangaoService.queryPage(params);
//字典表数据转换
List<DangaoView> list =(List<DangaoView>)page.getList();
for(DangaoView 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);
DangaoEntity dangao = dangaoService.selectById(id);
if(dangao !=null){
//entity转view
DangaoView view = new DangaoView();
BeanUtils.copyProperties( dangao , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody DangaoEntity dangao, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,dangao:{}",this.getClass().getName(),dangao.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
Wrapper<DangaoEntity> queryWrapper = new EntityWrapper<DangaoEntity>()
.eq("dangao_name", dangao.getDangaoName())
.eq("dangao_types", dangao.getDangaoTypes())
.eq("dangao_kucun_number", dangao.getDangaoKucunNumber())
.eq("dangao_price", dangao.getDangaoPrice())
.eq("shangxia_types", dangao.getShangxiaTypes())
.eq("dangao_delete", 1)
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
DangaoEntity dangaoEntity = dangaoService.selectOne(queryWrapper);
if(dangaoEntity==null){
dangao.setDangaoClicknum(1);
dangao.setShangxiaTypes(1);
dangao.setDangaoDelete(1);
dangao.setInsertTime(new Date());
dangao.setCreateTime(new Date());
dangaoService.insert(dangao);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody DangaoEntity dangao, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,dangao:{}",this.getClass().getName(),dangao.toString());
DangaoEntity oldDangaoEntity = dangaoService.selectById(dangao.getId());//查询原先数据
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
if("".equals(dangao.getDangaoPhoto()) || "null".equals(dangao.getDangaoPhoto())){
dangao.setDangaoPhoto(null);
}
dangaoService.updateById(dangao);//根据id更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<DangaoEntity> oldDangaoList =dangaoService.selectBatchIds(Arrays.asList(ids));//要删除的数据
ArrayList<DangaoEntity> list = new ArrayList<>();
for(Integer id:ids){
DangaoEntity dangaoEntity = new DangaoEntity();
dangaoEntity.setId(id);
dangaoEntity.setDangaoDelete(2);
list.add(dangaoEntity);
}
if(list != null && list.size() >0){
dangaoService.updateBatchById(list);
}
return R.ok();
}
/**
* 批量上传
*/
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
try {
List<DangaoEntity> dangaoList = 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){
//循环
DangaoEntity dangaoEntity = new DangaoEntity();
// dangaoEntity.setDangaoName(data.get(0)); //商品名称 要改的
// dangaoEntity.setDangaoUuidNumber(data.get(0)); //商品编号 要改的
// dangaoEntity.setDangaoPhoto("");//详情和图片
// dangaoEntity.setDangaoTypes(Integer.valueOf(data.get(0))); //商品类型 要改的
// dangaoEntity.setDangaoKucunNumber(Integer.valueOf(data.get(0))); //商品库存 要改的
// dangaoEntity.setDangaoPrice(Integer.valueOf(data.get(0))); //购买获得积分 要改的
// dangaoEntity.setDangaoOldMoney(data.get(0)); //商品原价 要改的
// dangaoEntity.setDangaoNewMoney(data.get(0)); //现价 要改的
// dangaoEntity.setDangaoClicknum(Integer.valueOf(data.get(0))); //商品热度 要改的
// dangaoEntity.setDangaoContent("");//详情和图片
// dangaoEntity.setShangxiaTypes(Integer.valueOf(data.get(0))); //是否上架 要改的
// dangaoEntity.setDangaoDelete(1);//逻辑删除字段
// dangaoEntity.setInsertTime(date);//时间
// dangaoEntity.setCreateTime(date);//时间
dangaoList.add(dangaoEntity);
//把要查询是否重复的字段放入map中
//商品编号
if(seachFields.containsKey("dangaoUuidNumber")){
List<String> dangaoUuidNumber = seachFields.get("dangaoUuidNumber");
dangaoUuidNumber.add(data.get(0));//要改的
}else{
List<String> dangaoUuidNumber = new ArrayList<>();
dangaoUuidNumber.add(data.get(0));//要改的
seachFields.put("dangaoUuidNumber",dangaoUuidNumber);
}
}
//查询是否重复
//商品编号
List<DangaoEntity> dangaoEntities_dangaoUuidNumber = dangaoService.selectList(new EntityWrapper<DangaoEntity>().in("dangao_uuid_number", seachFields.get("dangaoUuidNumber")).eq("dangao_delete", 1));
if(dangaoEntities_dangaoUuidNumber.size() >0 ){
ArrayList<String> repeatFields = new ArrayList<>();
for(DangaoEntity s:dangaoEntities_dangaoUuidNumber){
repeatFields.add(s.getDangaoUuidNumber());
}
return R.error(511,"数据库的该表中的 [商品编号] 字段已经存在 存在数据为:"+repeatFields.toString());
}
dangaoService.insertBatch(dangaoList);
return R.ok();
}
}
}
}catch (Exception e){
e.printStackTrace();
return R.error(511,"批量插入数据异常,请联系管理员");
}
}
/**
* 个性推荐
*/
@IgnoreAuth
@RequestMapping("/gexingtuijian")
public R gexingtuijian(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("gexingtuijian方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
CommonUtil.checkMap(params);
List<DangaoView> returnDangaoViewList = new ArrayList<>();
//查询订单
Map<String, Object> params1 = new HashMap<>(params);params1.put("sort","id");params1.put("yonghuId",request.getSession().getAttribute("userId"));
PageUtils pageUtils = dangaoOrderService.queryPage(params1);
List<DangaoOrderView> orderViewsList =(List<DangaoOrderView>)pageUtils.getList();
Map<Integer,Integer> typeMap=new HashMap<>();//购买的类型list
for(DangaoOrderView orderView:orderViewsList){
Integer dangaoTypes = orderView.getDangaoTypes();
if(typeMap.containsKey(dangaoTypes)){
typeMap.put(dangaoTypes,typeMap.get(dangaoTypes)+1);
}else{
typeMap.put(dangaoTypes,1);
}
}
List<Integer> typeList = new ArrayList<>();//排序后的有序的类型 按最多到最少
typeMap.entrySet().stream().sorted((o1, o2) -> o2.getValue() - o1.getValue()).forEach(e -> typeList.add(e.getKey()));//排序
Integer limit = Integer.valueOf(String.valueOf(params.get("limit")));
for(Integer type:typeList){
Map<String, Object> params2 = new HashMap<>(params);params2.put("dangaoTypes",type);
PageUtils pageUtils1 = dangaoService.queryPage(params2);
List<DangaoView> dangaoViewList =(List<DangaoView>)pageUtils1.getList();
returnDangaoViewList.addAll(dangaoViewList);
if(returnDangaoViewList.size()>= limit) break;//返回的推荐数量大于要的数量 跳出循环
}
//正常查询出来商品,用于补全推荐缺少的数据
PageUtils page = dangaoService.queryPage(params);
if(returnDangaoViewList.size()<limit){//返回数量还是小于要求数量
int toAddNum = limit - returnDangaoViewList.size();//要添加的数量
List<DangaoView> dangaoViewList =(List<DangaoView>)page.getList();
for(DangaoView dangaoView:dangaoViewList){
Boolean addFlag = true;
for(DangaoView returnDangaoView:returnDangaoViewList){
if(returnDangaoView.getId().intValue() ==dangaoView.getId().intValue()) addFlag=false;//返回的数据中已存在此商品
}
if(addFlag){
toAddNum=toAddNum-1;
returnDangaoViewList.add(dangaoView);
if(toAddNum==0) break;//够数量了
}
}
}else {
returnDangaoViewList = returnDangaoViewList.subList(0, limit);
}
for(DangaoView c:returnDangaoViewList)
dictionaryService.dictionaryConvert(c, request);
page.setList(returnDangaoViewList);
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
CommonUtil.checkMap(params);
PageUtils page = dangaoService.queryPage(params);
//字典表数据转换
List<DangaoView> list =(List<DangaoView>)page.getList();
for(DangaoView 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);
DangaoEntity dangao = dangaoService.selectById(id);
if(dangao !=null){
//点击数量加1
dangao.setDangaoClicknum(dangao.getDangaoClicknum()+1);
dangaoService.updateById(dangao);
//entity转view
DangaoView view = new DangaoView();
BeanUtils.copyProperties( dangao , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody DangaoEntity dangao, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,dangao:{}",this.getClass().getName(),dangao.toString());
Wrapper<DangaoEntity> queryWrapper = new EntityWrapper<DangaoEntity>()
.eq("dangao_name", dangao.getDangaoName())
.eq("dangao_uuid_number", dangao.getDangaoUuidNumber())
.eq("dangao_types", dangao.getDangaoTypes())
.eq("dangao_kucun_number", dangao.getDangaoKucunNumber())
.eq("dangao_price", dangao.getDangaoPrice())
.eq("dangao_clicknum", dangao.getDangaoClicknum())
.eq("shangxia_types", dangao.getShangxiaTypes())
.eq("dangao_delete", dangao.getDangaoDelete())
// .notIn("dangao_types", new Integer[]{102})
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
DangaoEntity dangaoEntity = dangaoService.selectOne(queryWrapper);
if(dangaoEntity==null){
dangao.setDangaoClicknum(1);
dangao.setDangaoDelete(1);
dangao.setInsertTime(new Date());
dangao.setCreateTime(new Date());
dangaoService.insert(dangao);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
}
@RestController
@Controller
@RequestMapping("/cart")
public class CartController {
private static final Logger logger = LoggerFactory.getLogger(CartController.class);
private static final String TABLE_NAME = "cart";
@Autowired
private CartService cartService;
@Autowired
private TokenService tokenService;
@Autowired
private AddressService addressService;//收货地址
@Autowired
private DangaoService dangaoService;//商品
@Autowired
private DangaoCollectionService dangaoCollectionService;//商品收藏
@Autowired
private DangaoCommentbackService dangaoCommentbackService;//商品评价
@Autowired
private DangaoOrderService dangaoOrderService;//商品订单
@Autowired
private DianyuanService dianyuanService;//店员
@Autowired
private DictionaryService dictionaryService;//字典
@Autowired
private ForumService forumService;//论坛
@Autowired
private NewsService newsService;//公告信息
@Autowired
private YonghuService yonghuService;//用户
@Autowired
private UsersService usersService;//管理员
/**
* 后端列表
*/
@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(false)
return R.error(511,"永不会进入");
else if("用户".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId"));
else if("店员".equals(role))
params.put("dianyuanId",request.getSession().getAttribute("userId"));
CommonUtil.checkMap(params);
PageUtils page = cartService.queryPage(params);
//字典表数据转换
List<CartView> list =(List<CartView>)page.getList();
for(CartView 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);
CartEntity cart = cartService.selectById(id);
if(cart !=null){
//entity转view
CartView view = new CartView();
BeanUtils.copyProperties( cart , view );//把实体数据重构到view中
//级联表 用户
//级联表
YonghuEntity yonghu = yonghuService.selectById(cart.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
view.setYonghuId(yonghu.getId());
}
//级联表 商品
//级联表
DangaoEntity dangao = dangaoService.selectById(cart.getDangaoId());
if(dangao != null){
BeanUtils.copyProperties( dangao , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
view.setDangaoId(dangao.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody CartEntity cart, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,cart:{}",this.getClass().getName(),cart.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
else if("用户".equals(role))
cart.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
Wrapper<CartEntity> queryWrapper = new EntityWrapper<CartEntity>()
.eq("yonghu_id", cart.getYonghuId())
.eq("dangao_id", cart.getDangaoId())
.eq("buy_number", cart.getBuyNumber())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
CartEntity cartEntity = cartService.selectOne(queryWrapper);
if(cartEntity==null){
cart.setCreateTime(new Date());
cart.setInsertTime(new Date());
cartService.insert(cart);
return R.ok();
}else {
return R.error(511,"商品已添加到购物车");
}
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody CartEntity cart, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,cart:{}",this.getClass().getName(),cart.toString());
CartEntity oldCartEntity = cartService.selectById(cart.getId());//查询原先数据
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
// else if("用户".equals(role))
// cart.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
cart.setUpdateTime(new Date());
cartService.updateById(cart);//根据id更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<CartEntity> oldCartList =cartService.selectBatchIds(Arrays.asList(ids));//要删除的数据
cartService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 批量上传
*/
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
try {
List<CartEntity> cartList = 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){
//循环
CartEntity cartEntity = new CartEntity();
// cartEntity.setYonghuId(Integer.valueOf(data.get(0))); //所属用户 要改的
// cartEntity.setDangaoId(Integer.valueOf(data.get(0))); //商品 要改的
// cartEntity.setBuyNumber(Integer.valueOf(data.get(0))); //购买数量 要改的
// cartEntity.setCreateTime(date);//时间
// cartEntity.setUpdateTime(sdf.parse(data.get(0))); //更新时间 要改的
// cartEntity.setInsertTime(date);//时间
cartList.add(cartEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
cartService.insertBatch(cartList);
return R.ok();
}
}
}
}catch (Exception e){
e.printStackTrace();
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));
CommonUtil.checkMap(params);
PageUtils page = cartService.queryPage(params);
//字典表数据转换
List<CartView> list =(List<CartView>)page.getList();
for(CartView 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);
CartEntity cart = cartService.selectById(id);
if(cart !=null){
//entity转view
CartView view = new CartView();
BeanUtils.copyProperties( cart , view );//把实体数据重构到view中
//级联表
YonghuEntity yonghu = yonghuService.selectById(cart.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setYonghuId(yonghu.getId());
}
//级联表
DangaoEntity dangao = dangaoService.selectById(cart.getDangaoId());
if(dangao != null){
BeanUtils.copyProperties( dangao , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setDangaoId(dangao.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody CartEntity cart, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,cart:{}",this.getClass().getName(),cart.toString());
Wrapper<CartEntity> queryWrapper = new EntityWrapper<CartEntity>()
.eq("yonghu_id", cart.getYonghuId())
.eq("dangao_id", cart.getDangaoId())
.eq("buy_number", cart.getBuyNumber())
// .notIn("cart_types", new Integer[]{102})
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
CartEntity cartEntity = cartService.selectOne(queryWrapper);
if(cartEntity==null){
cart.setCreateTime(new Date());
cart.setInsertTime(new Date());
cartService.insert(cart);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
}
五、论文参考
- 计算机毕业设计选题推荐-网上蛋糕销售系统-网上蛋糕商城-论文参考:
六、系统视频
- 网上蛋糕销售系统-网上蛋糕商城-项目视频:
计算机毕业设计选题推荐-网上蛋糕销售系统-网上蛋糕商城
结语
计算机毕业设计选题推荐-网上蛋糕销售系统-网上蛋糕商城-Java/Python项目实战
大家可以帮忙点赞、收藏、关注、评论啦~
源码获取:⬇⬇⬇