基于javaweb+mysql的springboot网上商城系统设计和实现(java+springboot+ssm+mysql+thymeleaf+html+maven)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot网上商城系统设计和实现(java+springboot+ssm+mysql+thymeleaf+html+maven)
一、项目简述
本系统主要实现的功能有: OnlineMall项目是一套电商系统,包括OnlineMall商城系 统及OnlineMall商城后台管理^统,基于Spring Boot 2.X 及相关技术栈开发。前台商城系统包含首页门户、商品分 类、新品上线、首页轮播、商品推荐、商品搜索、商品展 示、购物车、订单结算、订单流程、个人订单管理、会员 中心、帮助中心等模块。后台管理系统包含数据面板、轮 播图管理、商品管理、订单管理、会员管理、分类管理、 设置等模块。
二、项目运行
环境配置: Jdk1.8 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: Springboot+ SpringMVC + MyBatis + ThymeLeaf + JavaScript + JQuery + Ajax + maven等等
@Controller
public class GoodsController {
@Resource
private NewBeeMallGoodsService newBeeMallGoodsService;
@Resource
private NewBeeMallCategoryService newBeeMallCategoryService;
@GetMapping({"/search", "/search.html"})
public String searchPage(@RequestParam Map<String, Object> params, HttpServletRequest request) {
if (StringUtils.isEmpty(params.get("page"))) {
params.put("page", 1);
}
params.put("limit", Constants.GOODS_SEARCH_PAGE_LIMIT);
//封装分类数据
if (params.containsKey("goodsCategoryId") && !StringUtils.isEmpty(params.get("goodsCategoryId") + "")) {
Long categoryId = Long.valueOf(params.get("goodsCategoryId") + "");
SearchPageCategoryVO searchPageCategoryVO = newBeeMallCategoryService.getCategoriesForSearch(categoryId);
if (searchPageCategoryVO != null) {
request.setAttribute("goodsCategoryId", categoryId);
request.setAttribute("searchPageCategoryVO", searchPageCategoryVO);
if (Objects.isNull(indexConfig.getConfigType())
|| Objects.isNull(indexConfig.getConfigId())
|| StringUtils.isEmpty(indexConfig.getConfigName())
|| Objects.isNull(indexConfig.getConfigRank())) {
return ResultGenerator.genFailResult("参数异常!");
}
String result = newBeeMallIndexConfigService.updateIndexConfig(indexConfig);
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(result);
}
}
/**
* 详情
*/
@GetMapping("/indexConfigs/info/{id}")
@ResponseBody
public Result info(@PathVariable("id") Long id) {
IndexConfig config = newBeeMallIndexConfigService.getIndexConfigById(id);
if (config == null) {
return ResultGenerator.genFailResult("未查询到数据");
}
return ResultGenerator.genSuccessResult(config);
}
/**
* 删除
*/
@RequestMapping(value = "/indexConfigs/delete", method = RequestMethod.POST)
@ResponseBody
public Result delete(@RequestBody Long[] ids) {
if (ids.length < 1) {
return ResultGenerator.genFailResult("参数异常!");
}
if (newBeeMallIndexConfigService.deleteBatch(ids)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult("删除失败");
}
}
}
if (StringUtils.isEmpty(newBeeMallGoods.getGoodsName())
|| StringUtils.isEmpty(newBeeMallGoods.getGoodsIntro())
|| StringUtils.isEmpty(newBeeMallGoods.getTag())
|| Objects.isNull(newBeeMallGoods.getOriginalPrice())
|| Objects.isNull(newBeeMallGoods.getGoodsCategoryId())
|| Objects.isNull(newBeeMallGoods.getSellingPrice())
|| Objects.isNull(newBeeMallGoods.getStockNum())
|| Objects.isNull(newBeeMallGoods.getGoodsSellStatus())
|| StringUtils.isEmpty(newBeeMallGoods.getGoodsCoverImg())
|| StringUtils.isEmpty(newBeeMallGoods.getGoodsDetailContent())) {
return ResultGenerator.genFailResult("参数异常!");
}
String result = newBeeMallGoodsService.saveNewBeeMallGoods(newBeeMallGoods);
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(result);
}
}
/**
* 修改
*/
@RequestMapping(value = "/goods/update", method = RequestMethod.POST)
@ResponseBody
public Result update(@RequestBody NewBeeMallGoods newBeeMallGoods) {
if (Objects.isNull(newBeeMallGoods.getGoodsId())
|| StringUtils.isEmpty(newBeeMallGoods.getGoodsName())
|| StringUtils.isEmpty(newBeeMallGoods.getGoodsIntro())
|| StringUtils.isEmpty(newBeeMallGoods.getTag())
|| Objects.isNull(newBeeMallGoods.getOriginalPrice())
|| Objects.isNull(newBeeMallGoods.getSellingPrice())
|| Objects.isNull(newBeeMallGoods.getGoodsCategoryId())
|| Objects.isNull(newBeeMallGoods.getStockNum())
|| Objects.isNull(newBeeMallGoods.getGoodsSellStatus())
|| StringUtils.isEmpty(newBeeMallGoods.getGoodsCoverImg())
|| StringUtils.isEmpty(newBeeMallGoods.getGoodsDetailContent())) {
return ResultGenerator.genFailResult("参数异常!");
}
String result = newBeeMallGoodsService.updateNewBeeMallGoods(newBeeMallGoods);
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
@Controller
public class OrderController {
@Resource
private NewBeeMallShoppingCartService newBeeMallShoppingCartService;
@Resource
private NewBeeMallOrderService newBeeMallOrderService;
@GetMapping("/orders/{orderNo}")
public String orderDetailPage(HttpServletRequest request, @PathVariable("orderNo") String orderNo, HttpSession httpSession) {
NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
NewBeeMallOrderDetailVO orderDetailVO = newBeeMallOrderService.getOrderDetailByOrderNo(orderNo, user.getUserId());
if (orderDetailVO == null) {
return "error/error_5xx";
}
request.setAttribute("orderDetailVO", orderDetailVO);
return "mall/order-detail";
}
@GetMapping("/orders")
public String orderListPage(@RequestParam Map<String, Object> params, HttpServletRequest request, HttpSession httpSession) {
NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
params.put("userId", user.getUserId());
if (StringUtils.isEmpty(params.get("page"))) {
params.put("page", 1);
}
params.put("limit", Constants.ORDER_SEARCH_PAGE_LIMIT);
//封装我的订单数据
PageQueryUtil pageUtil = new PageQueryUtil(params);
request.setAttribute("orderPageResult", newBeeMallOrderService.getMyOrders(pageUtil));
request.setAttribute("path", "orders");
return "mall/my-orders";
@Controller
public class GoodsController {
@Resource
private NewBeeMallGoodsService newBeeMallGoodsService;
@Resource
private NewBeeMallCategoryService newBeeMallCategoryService;
@GetMapping({"/search", "/search.html"})
public String searchPage(@RequestParam Map<String, Object> params, HttpServletRequest request) {
if (StringUtils.isEmpty(params.get("page"))) {
params.put("page", 1);
}
params.put("limit", Constants.GOODS_SEARCH_PAGE_LIMIT);
//封装分类数据
if (params.containsKey("goodsCategoryId") && !StringUtils.isEmpty(params.get("goodsCategoryId") + "")) {
Long categoryId = Long.valueOf(params.get("goodsCategoryId") + "");
SearchPageCategoryVO searchPageCategoryVO = newBeeMallCategoryService.getCategoriesForSearch(categoryId);
if (searchPageCategoryVO != null) {
request.setAttribute("goodsCategoryId", categoryId);
request.setAttribute("searchPageCategoryVO", searchPageCategoryVO);
}
}
//封装参数供前端回显
if (params.containsKey("orderBy") && !StringUtils.isEmpty(params.get("orderBy") + "")) {
request.setAttribute("orderBy", params.get("orderBy") + "");
}
String keyword = "";
//对keyword做过滤 去掉空格
if (params.containsKey("keyword") && !StringUtils.isEmpty((params.get("keyword") + "").trim())) {
keyword = params.get("keyword") + "";
}
request.setAttribute("keyword", keyword);
params.put("keyword", keyword);
//封装商品数据
PageQueryUtil pageUtil = new PageQueryUtil(params);
request.setAttribute("pageResult", newBeeMallGoodsService.searchNewBeeMallGoods(pageUtil));
return "mall/search";
}
@GetMapping("/goods/detail/{goodsId}")
public String detailPage(@PathVariable("goodsId") Long goodsId, HttpServletRequest request) {
if (goodsId < 1) {
return "error/error_5xx";
}
NewBeeMallGoods goods = newBeeMallGoodsService.getNewBeeMallGoodsById(goodsId);
if (goods == null) {
return "error/error_404";
}
NewBeeMallGoodsDetailVO goodsDetailVO = new NewBeeMallGoodsDetailVO();
BeanUtil.copyProperties(goods, goodsDetailVO);
goodsDetailVO.setGoodsCarouselList(goods.getGoodsCarousel().split(","));
request.setAttribute("goodsDetail", goodsDetailVO);
}
@Override
public String login(String loginName, String passwordMD5, HttpSession httpSession) {
MallUser user = mallUserMapper.selectByLoginNameAndPasswd(loginName, passwordMD5);
if (user != null && httpSession != null) {
if (user.getLockedFlag() == 1) {
return ServiceResultEnum.LOGIN_USER_LOCKED.getResult();
}
//昵称太长 影响页面展示
if (user.getNickName() != null && user.getNickName().length() > 7) {
String tempNickName = user.getNickName().substring(0, 7) + "..";
user.setNickName(tempNickName);
}
NewBeeMallUserVO newBeeMallUserVO = new NewBeeMallUserVO();
BeanUtil.copyProperties(user, newBeeMallUserVO);
//设置购物车中的数量
httpSession.setAttribute(Constants.MALL_USER_SESSION_KEY, newBeeMallUserVO);
return ServiceResultEnum.SUCCESS.getResult();
}
return ServiceResultEnum.LOGIN_ERROR.getResult();
}
@Override
public NewBeeMallUserVO updateUserInfo(MallUser mallUser, HttpSession httpSession) {
MallUser user = mallUserMapper.selectByPrimaryKey(mallUser.getUserId());
if (user != null) {
user.setNickName(mallUser.getNickName());
user.setAddress(mallUser.getAddress());
user.setIntroduceSign(mallUser.getIntroduceSign());
if (mallUserMapper.updateByPrimaryKeySelective(user) > 0) {
NewBeeMallUserVO newBeeMallUserVO = new NewBeeMallUserVO();
user = mallUserMapper.selectByPrimaryKey(mallUser.getUserId());
BeanUtil.copyProperties(user, newBeeMallUserVO);
httpSession.setAttribute(Constants.MALL_USER_SESSION_KEY, newBeeMallUserVO);
return newBeeMallUserVO;
}
}
return null;
}
@Override
public Boolean lockUsers(Integer[] ids, int lockStatus) {
if (ids.length < 1) {
return false;
}
return mallUserMapper.lockUserBatch(ids, lockStatus) > 0;
}
}
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(result);
}
}
/**
* 关闭订单
*/
@RequestMapping(value = "/orders/close", method = RequestMethod.POST)
@ResponseBody
public Result closeOrder(@RequestBody Long[] ids) {
if (ids.length < 1) {
return ResultGenerator.genFailResult("参数异常!");
}
String result = newBeeMallOrderService.closeOrder(ids);
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(result);
}
}
}
/**
}
}
@Controller
public class PersonalController {
@Resource
private NewBeeMallUserService newBeeMallUserService;
@GetMapping("/personal")
public String personalPage(HttpServletRequest request,
HttpSession httpSession) {
request.setAttribute("path", "personal");
return "mall/personal";
}
@GetMapping("/logout")
public String logout(HttpSession httpSession) {
httpSession.removeAttribute(Constants.MALL_USER_SESSION_KEY);
return "mall/login";
}
@GetMapping({"/login", "login.html"})
public String loginPage() {
return "mall/login";
}
@GetMapping({"/register", "register.html"})
public String registerPage() {
return "mall/register";
}
@GetMapping("/personal/addresses")
public String addressesPage() {
return "mall/addresses";
}
String result = newBeeMallCategoryService.updateGoodsCategory(goodsCategory);
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(result);
}
}
/**
* 详情
*/
@GetMapping("/categories/info/{id}")
@ResponseBody
public Result info(@PathVariable("id") Long id) {
GoodsCategory goodsCategory = newBeeMallCategoryService.getGoodsCategoryById(id);
if (goodsCategory == null) {
return ResultGenerator.genFailResult("未查询到数据");
}
return ResultGenerator.genSuccessResult(goodsCategory);
}
/**
* 分类删除
*/
@RequestMapping(value = "/categories/delete", method = RequestMethod.POST)
@ResponseBody
public Result delete(@RequestBody Integer[] ids) {
if (ids.length < 1) {
return ResultGenerator.genFailResult("参数异常!");
}
if (newBeeMallCategoryService.deleteBatch(ids)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult("删除失败");
}
}
}
}
@Controller
public class ErrorPageController implements ErrorController {
private static ErrorPageController errorPageController;
@Autowired
private ErrorAttributes errorAttributes;
private final static String ERROR_PATH = "/error";
public ErrorPageController(ErrorAttributes errorAttributes) {
this.errorAttributes = errorAttributes;
}
public ErrorPageController() {
if (errorPageController == null) {
errorPageController = new ErrorPageController(errorAttributes);
}
}
@RequestMapping(value = ERROR_PATH, produces = "text/html")
public ModelAndView errorHtml(HttpServletRequest request) {
//todo 判断订单userId
//todo 判断订单状态
request.setAttribute("orderNo", orderNo);
request.setAttribute("totalPrice", newBeeMallOrder.getTotalPrice());
return "mall/pay-select";
}
@GetMapping("/payPage")
public String payOrder(HttpServletRequest request, @RequestParam("orderNo") String orderNo, HttpSession httpSession, @RequestParam("payType") int payType) {
NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
NewBeeMallOrder newBeeMallOrder = newBeeMallOrderService.getNewBeeMallOrderByOrderNo(orderNo);
//todo 判断订单userId
//todo 判断订单状态
request.setAttribute("orderNo", orderNo);
request.setAttribute("totalPrice", newBeeMallOrder.getTotalPrice());
if (payType == 1) {
return "mall/alipay";
} else {
return "mall/wxpay";
}
}
@GetMapping("/paySuccess")
@ResponseBody
public Result paySuccess(@RequestParam("orderNo") String orderNo, @RequestParam("payType") int payType) {
String payResult = newBeeMallOrderService.paySuccess(orderNo, payType);
if (ServiceResultEnum.SUCCESS.getResult().equals(payResult)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(payResult);
}
}
}
/**
*/
@Controller
@RequestMapping("/admin")
public class NewBeeMallCarouselController {
@Resource
NewBeeMallCarouselService newBeeMallCarouselService;
@GetMapping("/carousels")
public String carouselPage(HttpServletRequest request) {
request.setAttribute("path", "newbee_mall_carousel");
return "admin/newbee_mall_carousel";
}
/**
* 列表
*/
@RequestMapping(value = "/carousels/list", method = RequestMethod.GET)
@ResponseBody
public Result list(@RequestParam Map<String, Object> params) {
if (StringUtils.isEmpty(params.get("page")) || StringUtils.isEmpty(params.get("limit"))) {
return ResultGenerator.genFailResult("参数异常!");
}
PageQueryUtil pageUtil = new PageQueryUtil(params);
return ResultGenerator.genSuccessResult(newBeeMallCarouselService.getCarouselPage(pageUtil));
}
/**
* 添加
*/
@RequestMapping(value = "/carousels/save", method = RequestMethod.POST)
@ResponseBody
public Result save(@RequestBody Carousel carousel) {
if (StringUtils.isEmpty(carousel.getCarouselUrl())
|| Objects.isNull(carousel.getCarouselRank())) {
return ResultGenerator.genFailResult("参数异常!");
}
String result = newBeeMallCarouselService.saveCarousel(carousel);
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
public class NewBeeMallUserServiceImpl implements NewBeeMallUserService {
@Autowired
private MallUserMapper mallUserMapper;
@Override
public PageResult getNewBeeMallUsersPage(PageQueryUtil pageUtil) {
List<MallUser> mallUsers = mallUserMapper.findMallUserList(pageUtil);
int total = mallUserMapper.getTotalMallUsers(pageUtil);
PageResult pageResult = new PageResult(mallUsers, total, pageUtil.getLimit(), pageUtil.getPage());
return pageResult;
}
@Override
public String register(String loginName, String password) {
if (mallUserMapper.selectByLoginName(loginName) != null) {
return ServiceResultEnum.SAME_LOGIN_NAME_EXIST.getResult();
}
MallUser registerUser = new MallUser();
registerUser.setLoginName(loginName);
registerUser.setNickName(loginName);
String passwordMD5 = MD5Util.MD5Encode(password, "UTF-8");
registerUser.setPasswordMd5(passwordMD5);
if (mallUserMapper.insertSelective(registerUser) > 0) {
return ServiceResultEnum.SUCCESS.getResult();
}
return ServiceResultEnum.DB_ERROR.getResult();
}
@Override
public String login(String loginName, String passwordMD5, HttpSession httpSession) {
MallUser user = mallUserMapper.selectByLoginNameAndPasswd(loginName, passwordMD5);
if (user != null && httpSession != null) {
if (user.getLockedFlag() == 1) {
return ServiceResultEnum.LOGIN_USER_LOCKED.getResult();
}
//昵称太长 影响页面展示
if (user.getNickName() != null && user.getNickName().length() > 7) {
String tempNickName = user.getNickName().substring(0, 7) + "..";
user.setNickName(tempNickName);
}
NewBeeMallUserVO newBeeMallUserVO = new NewBeeMallUserVO();
BeanUtil.copyProperties(user, newBeeMallUserVO);
//设置购物车中的数量
httpSession.setAttribute(Constants.MALL_USER_SESSION_KEY, newBeeMallUserVO);
return ServiceResultEnum.SUCCESS.getResult();
}
return ServiceResultEnum.LOGIN_ERROR.getResult();
}
@Override
public NewBeeMallUserVO updateUserInfo(MallUser mallUser, HttpSession httpSession) {
MallUser user = mallUserMapper.selectByPrimaryKey(mallUser.getUserId());
if (user != null) {
}
request.setAttribute("goods", newBeeMallGoods);
request.setAttribute("path", "goods-edit");
return "admin/newbee_mall_goods_edit";
}
/**
* 列表
*/
@RequestMapping(value = "/goods/list", method = RequestMethod.GET)
@ResponseBody
public Result list(@RequestParam Map<String, Object> params) {
if (StringUtils.isEmpty(params.get("page")) || StringUtils.isEmpty(params.get("limit"))) {
return ResultGenerator.genFailResult("参数异常!");
}
PageQueryUtil pageUtil = new PageQueryUtil(params);
return ResultGenerator.genSuccessResult(newBeeMallGoodsService.getNewBeeMallGoodsPage(pageUtil));
}
/**
* 添加
*/
@RequestMapping(value = "/goods/save", method = RequestMethod.POST)
@ResponseBody
public Result save(@RequestBody NewBeeMallGoods newBeeMallGoods) {
if (StringUtils.isEmpty(newBeeMallGoods.getGoodsName())
|| StringUtils.isEmpty(newBeeMallGoods.getGoodsIntro())
|| StringUtils.isEmpty(newBeeMallGoods.getTag())
|| Objects.isNull(newBeeMallGoods.getOriginalPrice())
|| Objects.isNull(newBeeMallGoods.getGoodsCategoryId())
|| Objects.isNull(newBeeMallGoods.getSellingPrice())
|| Objects.isNull(newBeeMallGoods.getStockNum())
|| Objects.isNull(newBeeMallGoods.getGoodsSellStatus())
|| StringUtils.isEmpty(newBeeMallGoods.getGoodsCoverImg())
|| StringUtils.isEmpty(newBeeMallGoods.getGoodsDetailContent())) {
return ResultGenerator.genFailResult("参数异常!");
}
String result = newBeeMallGoodsService.saveNewBeeMallGoods(newBeeMallGoods);
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
return "admin/login";
}
}
@GetMapping("/profile")
public String profile(HttpServletRequest request) {
Integer loginUserId = (int) request.getSession().getAttribute("loginUserId");
AdminUser adminUser = adminUserService.getUserDetailById(loginUserId);
if (adminUser == null) {
return "admin/login";
}
request.setAttribute("path", "profile");
request.setAttribute("loginUserName", adminUser.getLoginUserName());
request.setAttribute("nickName", adminUser.getNickName());
return "admin/profile";
}
@PostMapping("/profile/password")
@ResponseBody
public String passwordUpdate(HttpServletRequest request, @RequestParam("originalPassword") String originalPassword,
@RequestParam("newPassword") String newPassword) {
if (StringUtils.isEmpty(originalPassword) || StringUtils.isEmpty(newPassword)) {
return "参数不能为空";
}
Integer loginUserId = (int) request.getSession().getAttribute("loginUserId");
if (adminUserService.updatePassword(loginUserId, originalPassword, newPassword)) {
//修改成功后清空session中的数据,前端控制跳转至登录页
request.getSession().removeAttribute("loginUserId");
request.getSession().removeAttribute("loginUser");
request.getSession().removeAttribute("errorMsg");
return ServiceResultEnum.SUCCESS.getResult();
} else {
return "修改失败";
}
}
@PostMapping("/profile/name")
@ResponseBody
public String nameUpdate(HttpServletRequest request, @RequestParam("loginUserName") String loginUserName,
@RequestParam("nickName") String nickName) {
if (StringUtils.isEmpty(loginUserName) || StringUtils.isEmpty(nickName)) {
return "参数不能为空";
}
Integer loginUserId = (int) request.getSession().getAttribute("loginUserId");
if (adminUserService.updateName(loginUserId, loginUserName, nickName)) {
return ServiceResultEnum.SUCCESS.getResult();
} else {
return "修改失败";
}
}
PageQueryUtil pageUtil = new PageQueryUtil(params);
return ResultGenerator.genSuccessResult(newBeeMallUserService.getNewBeeMallUsersPage(pageUtil));
}
/**
* 用户禁用与解除禁用(0-未锁定 1-已锁定)
*/
@RequestMapping(value = "/users/lock/{lockStatus}", method = RequestMethod.POST)
@ResponseBody
public Result delete(@RequestBody Integer[] ids, @PathVariable int lockStatus) {
if (ids.length < 1) {
return ResultGenerator.genFailResult("参数异常!");
}
if (lockStatus != 0 && lockStatus != 1) {
return ResultGenerator.genFailResult("操作非法!");
}
if (newBeeMallUserService.lockUsers(ids, lockStatus)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult("禁用失败");
}
}
}
/**
* 购物车数量处理
*
*/
@Component
public class NewBeeMallCartNumberInterceptor implements HandlerInterceptor {
@Autowired
private NewBeeMallShoppingCartItemMapper newBeeMallShoppingCartItemMapper;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
//购物车中的数量会更改,但是在这些接口中并没有对session中的数据做修改,这里统一处理一下
if (null != request.getSession() && null != request.getSession().getAttribute(Constants.MALL_USER_SESSION_KEY)) {
//如果当前为登陆状态,就查询数据库并设置购物车中的数量值
@ResponseBody
public Result delete(@RequestBody Long[] ids, @PathVariable("sellStatus") int sellStatus) {
if (ids.length < 1) {
return ResultGenerator.genFailResult("参数异常!");
}
if (sellStatus != Constants.SELL_STATUS_UP && sellStatus != Constants.SELL_STATUS_DOWN) {
return ResultGenerator.genFailResult("状态异常!");
}
if (newBeeMallGoodsService.batchUpdateSellStatus(ids, sellStatus)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult("修改失败");
}
}
}
/**
*/
@Controller
@RequestMapping("/admin")
public class NewBeeMallGoodsCategoryController {
@Resource
private NewBeeMallCategoryService newBeeMallCategoryService;