• SpringBoot+Vue项目线上买菜系统


    文末获取源码

    开发语言:Java

    框架:springboot

    JDK版本:JDK1.8

    服务器:tomcat7

    数据库:mysql 5.7/8.0

    数据库工具:Navicat11

    开发软件:eclipse/myeclipse/idea

    Maven包:Maven3.3.9

    浏览器:谷歌浏览器

    本线上买菜系统采用的数据库是Mysql,使用springboot框架开发。在设计过程中,充分保证了系统代码的良好可读性、实用性、易扩展性、通用性、便于后期维护、操作方便以及页面简洁等特点。 

    本系统主要包括管理员和用户两个角色组成,主要包括以下功能: 

    (1)前台:首页、商品信息、公告信息、个人中心、后台管理、购物车。 

    (2)管理员:首页、个人中心、用户管理、商品分类管理、商品信息管理、系统管理、订单管理。

    (3)用户:首页、个人中心、修改密码、个人信息。

    系统展示

    前台 

    商品信息

     

    购物车

    管理员功能

    登录 

     首页

    用户管理

    商品分类管理

    商品信息管理 

    订单管理 

    部分核心代码

    1. /**
    2. * 购物车表
    3. * 后端接口
    4. * @author
    5. * @email
    6. * @date 2022-04-27 10:29:38
    7. */
    8. @RestController
    9. @RequestMapping("/cart")
    10. public class CartController {
    11. @Autowired
    12. private CartService cartService;
    13. /**
    14. * 后端列表
    15. */
    16. @RequestMapping("/page")
    17. public R page(@RequestParam Map<String, Object> params,CartEntity cart,
    18. HttpServletRequest request){
    19. if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
    20. cart.setUserid((Long)request.getSession().getAttribute("userId"));
    21. }
    22. EntityWrapper<CartEntity> ew = new EntityWrapper<CartEntity>();
    23. PageUtils page = cartService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, cart), params), params));
    24. return R.ok().put("data", page);
    25. }
    26. /**
    27. * 前端列表
    28. */
    29. @IgnoreAuth
    30. @RequestMapping("/list")
    31. public R list(@RequestParam Map<String, Object> params,CartEntity cart,
    32. HttpServletRequest request){
    33. EntityWrapper<CartEntity> ew = new EntityWrapper<CartEntity>();
    34. PageUtils page = cartService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, cart), params), params));
    35. return R.ok().put("data", page);
    36. }
    37. /**
    38. * 列表
    39. */
    40. @RequestMapping("/lists")
    41. public R list( CartEntity cart){
    42. EntityWrapper<CartEntity> ew = new EntityWrapper<CartEntity>();
    43. ew.allEq(MPUtil.allEQMapPre( cart, "cart"));
    44. return R.ok().put("data", cartService.selectListView(ew));
    45. }
    46. /**
    47. * 查询
    48. */
    49. @RequestMapping("/query")
    50. public R query(CartEntity cart){
    51. EntityWrapper< CartEntity> ew = new EntityWrapper< CartEntity>();
    52. ew.allEq(MPUtil.allEQMapPre( cart, "cart"));
    53. CartView cartView = cartService.selectView(ew);
    54. return R.ok("查询购物车表成功").put("data", cartView);
    55. }
    56. /**
    57. * 后端详情
    58. */
    59. @RequestMapping("/info/{id}")
    60. public R info(@PathVariable("id") Long id){
    61. CartEntity cart = cartService.selectById(id);
    62. return R.ok().put("data", cart);
    63. }
    64. /**
    65. * 前端详情
    66. */
    67. @IgnoreAuth
    68. @RequestMapping("/detail/{id}")
    69. public R detail(@PathVariable("id") Long id){
    70. CartEntity cart = cartService.selectById(id);
    71. return R.ok().put("data", cart);
    72. }
    73. /**
    74. * 后端保存
    75. */
    76. @RequestMapping("/save")
    77. public R save(@RequestBody CartEntity cart, HttpServletRequest request){
    78. cart.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    79. //ValidatorUtils.validateEntity(cart);
    80. cart.setUserid((Long)request.getSession().getAttribute("userId"));
    81. cartService.insert(cart);
    82. return R.ok();
    83. }
    84. /**
    85. * 前端保存
    86. */
    87. @RequestMapping("/add")
    88. public R add(@RequestBody CartEntity cart, HttpServletRequest request){
    89. cart.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    90. //ValidatorUtils.validateEntity(cart);
    91. cartService.insert(cart);
    92. return R.ok();
    93. }
    94. /**
    95. * 修改
    96. */
    97. @RequestMapping("/update")
    98. @Transactional
    99. public R update(@RequestBody CartEntity cart, HttpServletRequest request){
    100. //ValidatorUtils.validateEntity(cart);
    101. cartService.updateById(cart);//全部更新
    102. return R.ok();
    103. }
    104. /**
    105. * 删除
    106. */
    107. @RequestMapping("/delete")
    108. public R delete(@RequestBody Long[] ids){
    109. cartService.deleteBatchIds(Arrays.asList(ids));
    110. return R.ok();
    111. }
    112. /**
    113. * 提醒接口
    114. */
    115. @RequestMapping("/remind/{columnName}/{type}")
    116. public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
    117. @PathVariable("type") String type,@RequestParam Map<String, Object> map) {
    118. map.put("column", columnName);
    119. map.put("type", type);
    120. if(type.equals("2")) {
    121. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    122. Calendar c = Calendar.getInstance();
    123. Date remindStartDate = null;
    124. Date remindEndDate = null;
    125. if(map.get("remindstart")!=null) {
    126. Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
    127. c.setTime(new Date());
    128. c.add(Calendar.DAY_OF_MONTH,remindStart);
    129. remindStartDate = c.getTime();
    130. map.put("remindstart", sdf.format(remindStartDate));
    131. }
    132. if(map.get("remindend")!=null) {
    133. Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
    134. c.setTime(new Date());
    135. c.add(Calendar.DAY_OF_MONTH,remindEnd);
    136. remindEndDate = c.getTime();
    137. map.put("remindend", sdf.format(remindEndDate));
    138. }
    139. }
    140. Wrapper<CartEntity> wrapper = new EntityWrapper<CartEntity>();
    141. if(map.get("remindstart")!=null) {
    142. wrapper.ge(columnName, map.get("remindstart"));
    143. }
    144. if(map.get("remindend")!=null) {
    145. wrapper.le(columnName, map.get("remindend"));
    146. }
    147. if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
    148. wrapper.eq("userid", (Long)request.getSession().getAttribute("userId"));
    149. }
    150. int count = cartService.selectCount(wrapper);
    151. return R.ok().put("count", count);
    152. }
    153. }
    1. /**
    2. * 商品信息
    3. * 后端接口
    4. * @author
    5. * @email
    6. * @date 2022-04-27 10:29:38
    7. */
    8. @RestController
    9. @RequestMapping("/shangpinxinxi")
    10. public class ShangpinxinxiController {
    11. @Autowired
    12. private ShangpinxinxiService shangpinxinxiService;
    13. @Autowired
    14. private StoreupService storeupService;
    15. /**
    16. * 后端列表
    17. */
    18. @RequestMapping("/page")
    19. public R page(@RequestParam Map<String, Object> params,ShangpinxinxiEntity shangpinxinxi,
    20. HttpServletRequest request){
    21. EntityWrapper<ShangpinxinxiEntity> ew = new EntityWrapper<ShangpinxinxiEntity>();
    22. PageUtils page = shangpinxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shangpinxinxi), params), params));
    23. return R.ok().put("data", page);
    24. }
    25. /**
    26. * 前端列表
    27. */
    28. @IgnoreAuth
    29. @RequestMapping("/list")
    30. public R list(@RequestParam Map<String, Object> params,ShangpinxinxiEntity shangpinxinxi,
    31. HttpServletRequest request){
    32. EntityWrapper<ShangpinxinxiEntity> ew = new EntityWrapper<ShangpinxinxiEntity>();
    33. PageUtils page = shangpinxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shangpinxinxi), params), params));
    34. return R.ok().put("data", page);
    35. }
    36. /**
    37. * 列表
    38. */
    39. @RequestMapping("/lists")
    40. public R list( ShangpinxinxiEntity shangpinxinxi){
    41. EntityWrapper<ShangpinxinxiEntity> ew = new EntityWrapper<ShangpinxinxiEntity>();
    42. ew.allEq(MPUtil.allEQMapPre( shangpinxinxi, "shangpinxinxi"));
    43. return R.ok().put("data", shangpinxinxiService.selectListView(ew));
    44. }
    45. /**
    46. * 查询
    47. */
    48. @RequestMapping("/query")
    49. public R query(ShangpinxinxiEntity shangpinxinxi){
    50. EntityWrapper< ShangpinxinxiEntity> ew = new EntityWrapper< ShangpinxinxiEntity>();
    51. ew.allEq(MPUtil.allEQMapPre( shangpinxinxi, "shangpinxinxi"));
    52. ShangpinxinxiView shangpinxinxiView = shangpinxinxiService.selectView(ew);
    53. return R.ok("查询商品信息成功").put("data", shangpinxinxiView);
    54. }
    55. /**
    56. * 后端详情
    57. */
    58. @RequestMapping("/info/{id}")
    59. public R info(@PathVariable("id") Long id){
    60. ShangpinxinxiEntity shangpinxinxi = shangpinxinxiService.selectById(id);
    61. shangpinxinxi.setClicknum(shangpinxinxi.getClicknum()+1);
    62. shangpinxinxi.setClicktime(new Date());
    63. shangpinxinxiService.updateById(shangpinxinxi);
    64. return R.ok().put("data", shangpinxinxi);
    65. }
    66. /**
    67. * 前端详情
    68. */
    69. @IgnoreAuth
    70. @RequestMapping("/detail/{id}")
    71. public R detail(@PathVariable("id") Long id){
    72. ShangpinxinxiEntity shangpinxinxi = shangpinxinxiService.selectById(id);
    73. shangpinxinxi.setClicknum(shangpinxinxi.getClicknum()+1);
    74. shangpinxinxi.setClicktime(new Date());
    75. shangpinxinxiService.updateById(shangpinxinxi);
    76. return R.ok().put("data", shangpinxinxi);
    77. }
    78. /**
    79. * 后端保存
    80. */
    81. @RequestMapping("/save")
    82. public R save(@RequestBody ShangpinxinxiEntity shangpinxinxi, HttpServletRequest request){
    83. shangpinxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    84. //ValidatorUtils.validateEntity(shangpinxinxi);
    85. shangpinxinxiService.insert(shangpinxinxi);
    86. return R.ok();
    87. }
    88. /**
    89. * 前端保存
    90. */
    91. @RequestMapping("/add")
    92. public R add(@RequestBody ShangpinxinxiEntity shangpinxinxi, HttpServletRequest request){
    93. shangpinxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    94. //ValidatorUtils.validateEntity(shangpinxinxi);
    95. shangpinxinxiService.insert(shangpinxinxi);
    96. return R.ok();
    97. }
    98. /**
    99. * 修改
    100. */
    101. @RequestMapping("/update")
    102. @Transactional
    103. public R update(@RequestBody ShangpinxinxiEntity shangpinxinxi, HttpServletRequest request){
    104. //ValidatorUtils.validateEntity(shangpinxinxi);
    105. shangpinxinxiService.updateById(shangpinxinxi);//全部更新
    106. return R.ok();
    107. }
    108. /**
    109. * 删除
    110. */
    111. @RequestMapping("/delete")
    112. public R delete(@RequestBody Long[] ids){
    113. shangpinxinxiService.deleteBatchIds(Arrays.asList(ids));
    114. return R.ok();
    115. }
    116. /**
    117. * 提醒接口
    118. */
    119. @RequestMapping("/remind/{columnName}/{type}")
    120. public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
    121. @PathVariable("type") String type,@RequestParam Map<String, Object> map) {
    122. map.put("column", columnName);
    123. map.put("type", type);
    124. if(type.equals("2")) {
    125. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    126. Calendar c = Calendar.getInstance();
    127. Date remindStartDate = null;
    128. Date remindEndDate = null;
    129. if(map.get("remindstart")!=null) {
    130. Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
    131. c.setTime(new Date());
    132. c.add(Calendar.DAY_OF_MONTH,remindStart);
    133. remindStartDate = c.getTime();
    134. map.put("remindstart", sdf.format(remindStartDate));
    135. }
    136. if(map.get("remindend")!=null) {
    137. Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
    138. c.setTime(new Date());
    139. c.add(Calendar.DAY_OF_MONTH,remindEnd);
    140. remindEndDate = c.getTime();
    141. map.put("remindend", sdf.format(remindEndDate));
    142. }
    143. }
    144. Wrapper<ShangpinxinxiEntity> wrapper = new EntityWrapper<ShangpinxinxiEntity>();
    145. if(map.get("remindstart")!=null) {
    146. wrapper.ge(columnName, map.get("remindstart"));
    147. }
    148. if(map.get("remindend")!=null) {
    149. wrapper.le(columnName, map.get("remindend"));
    150. }
    151. int count = shangpinxinxiService.selectCount(wrapper);
    152. return R.ok().put("count", count);
    153. }
    154. /**
    155. * 前端智能排序
    156. */
    157. @IgnoreAuth
    158. @RequestMapping("/autoSort")
    159. public R autoSort(@RequestParam Map<String, Object> params,ShangpinxinxiEntity shangpinxinxi, HttpServletRequest request,String pre){
    160. EntityWrapper<ShangpinxinxiEntity> ew = new EntityWrapper<ShangpinxinxiEntity>();
    161. Map<String, Object> newMap = new HashMap<String, Object>();
    162. Map<String, Object> param = new HashMap<String, Object>();
    163. Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();
    164. while (it.hasNext()) {
    165. Map.Entry<String, Object> entry = it.next();
    166. String key = entry.getKey();
    167. String newKey = entry.getKey();
    168. if (pre.endsWith(".")) {
    169. newMap.put(pre + newKey, entry.getValue());
    170. } else if (StringUtils.isEmpty(pre)) {
    171. newMap.put(newKey, entry.getValue());
    172. } else {
    173. newMap.put(pre + "." + newKey, entry.getValue());
    174. }
    175. }
    176. params.put("sort", "clicknum");
    177. params.put("order", "desc");
    178. PageUtils page = shangpinxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shangpinxinxi), params), params));
    179. return R.ok().put("data", page);
    180. }
    181. }

  • 相关阅读:
    Java如何对一个对象进行深拷贝?
    【ARC与MRC的相互兼容 Objective-C语言】
    Spring Cloud Ablibaba 学习系列文章
    odoo 开发入门教程系列-约束(Constraints)
    2021年上半年软件设计师上午真题及答案解析(二)
    ipsec主模式加密身份信息有什么意义?
    策略+枚举 优雅的消灭 if-else
    如何快速下载微信视频号的视频?简单几步轻松搞定
    排序算法概述
    扬帆际海:shopee本土店的知识分享
  • 原文地址:https://blog.csdn.net/m0_49113107/article/details/126177838