商品类型管理、商品管理、订单管理、会员管理、管理员管理等。前台用户功能有:登录、注册、查看商品、加入购物车、付款、查看订单、个人中心等。该系统总共9张表 运行环境:windows/linux、jdk1.8、mysql5.x、maven3.53.6、tomcat7.0
前端商品控制器:
@RestController @RequestMapping("/goods") public class GoodsController { @Autowired private GoodsService goodsService; @Autowired private ProviderService providerService; @Autowired private CategoryService categoryService; @SysLog("商品查询 *** 作") @RequestMapping("/goodsList") public DataGridViewResult goodsList(GoodsVO goodsVO) { //创建分页信息 参数1 当前页 参数2 每页显示条数 IPage前端销售控制器:page = new Page<>(goodsVO.getPage(), goodsVO.getLimit()); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq(goodsVO.getProviderid() != null && goodsVO.getProviderid() != 0, "providerid", goodsVO.getProviderid()); queryWrapper.like(!StringUtils.isEmpty(goodsVO.getGname()), "gname", goodsVO.getGname()); IPage goodsIPage = goodsService.page(page, queryWrapper); List records = goodsIPage.getRecords(); for (Goods goods : records) { Provider provider = providerService.getById(goods.getProviderid()); if (null != provider) { goods.setProvidername(provider.getProvidername()); } } return new DataGridViewResult(goodsIPage.getTotal(), records); } @SysLog("商品添加 *** 作") @PostMapping("/addgoods") public Result addGoods(Goods goods) { String id = RandomStringUtils.randomAlphanumeric(8); if (goods.getGoodsimg()!=null&&goods.getGoodsimg().endsWith("_temp")){ String newName = AppFileUtils.renameFile(goods.getGoodsimg()); goods.setGoodsimg(newName); } goods.setGnumbering(id); boolean bool = goodsService.save(goods); if (bool) { return Result.success(true, "200", "添加成功!"); } return Result.error(false, null, "添加失败!"); } @SysLog("商品修改 *** 作") @PostMapping("/updategoods") public Result updateGoods(Goods goods) { //商品图片不是默认图片 if (!(goods.getGoodsimg()!=null&&goods.getGoodsimg().equals(Constast.DEFAULT_IMG))){ if (goods.getGoodsimg().endsWith("_temp")){ String newName = AppFileUtils.renameFile(goods.getGoodsimg()); goods.setGoodsimg(newName); //删除原先的图片 String oldPath = goodsService.getById(goods.getGid()).getGoodsimg(); AppFileUtils.removeFileByPath(oldPath); } } boolean bool = goodsService.updateById(goods); if (bool) { return Result.success(true, "200", "修改成功!"); } return Result.error(false, null, "修改失败!"); } @SysLog("商品删除 *** 作") @RequestMapping("/deleteOne") public Result deleteOne(int id) { boolean bool = goodsService.removeById(id); if (bool) { return Result.success(true, "200", "删除成功!"); } return Result.error(false, null, "删除失败!"); } @RequestMapping("/initGoodsByCategoryId") public DataGridViewResult initGoodsByCategoryId(int id) { List
@RestController @RequestMapping("/sale") public class SaleController { @Autowired private SaleService saleService; @Autowired private GoodsService goodsService; @Autowired private CustomerService customerService; @SysLog("销售查询 *** 作") @RequestMapping("/saleList") public DataGridViewResult saleList(SaleVO saleVO) { //创建分页信息 参数1 当前页 参数2 每页显示条数 IPagepage = new Page<>(saleVO.getPage(), saleVO.getLimit()); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.like(!StringUtils.isEmpty(saleVO.getNumbering()),"numbering", saleVO.getNumbering()); queryWrapper.eq(saleVO.getGid() != null && saleVO.getGid() != 0, "gid", saleVO.getGid()); queryWrapper.ge(saleVO.getStartTime() != null, "buytime", saleVO.getStartTime()); queryWrapper.le(saleVO.getEndTime() != null, "buytime", saleVO.getEndTime()); queryWrapper.orderByDesc("buytime"); IPage saleIPage = saleService.page(page, queryWrapper); List records = saleIPage.getRecords(); for (Sale sale : records) { sale.setAllmoney(sale.getMoney()*sale.getBuyquantity()); Customer customer = customerService.getById(sale.getCustid()); if (null != customer) { sale.setCustomervip(customer.getCustvip()); sale.setCustomername(customer.getCustname()); } Goods goods = goodsService.getById(sale.getGid()); if (null != goods) { sale.setGoodsname(goods.getGname()); sale.setGnumbering(goods.getGnumbering()); } } return new DataGridViewResult(saleIPage.getTotal(), records); } @SysLog("销售添加 *** 作") @PostMapping("/addsale") public Result addsale(Sale sale, HttpSession session) { if (sale.getGid()==0){ return Result.error(false, null, "添加失败!未选商品"); } Goods goods = goodsService.getById(sale.getGid()); Integer gquantity = goods.getGquantity(); if(gquantity 前端用户控制器: @RestController @RequestMapping("/user") public class UserController { @Autowired private UserService userService; @Autowired private RoleService roleService; @SysLog("登陆 *** 作") @PostMapping("/login") public Result login(String username, String password, HttpServletRequest request) { try { //获取当前登录主体对象 Subject subject = SecurityUtils.getSubject(); UsernamePasswordToken token = new UsernamePasswordToken(username, password); subject.login(token); LoginUserVO userDTO = (LoginUserVO) subject.getPrincipal(); request.getSession().setAttribute("username", userDTO.getUser()); return Result.success(true, "200", "登录成功"); } catch (UnknownAccountException e) { e.printStackTrace(); return Result.error(false, "400", "登录失败,用户名不存在"); }catch (IncorrectCredentialsException e) { e.printStackTrace(); return Result.error(false, "400", "登录失败,密码错误"); }catch (AuthenticationException e) { e.printStackTrace(); return Result.error(false, "400", "登录失败,账户禁用"); } } @RequestMapping("/getCode") public void getCode(HttpServletResponse response, HttpSession session) throws IOException { //定义图形验证码的长和宽 LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(116, 36,4,5); session.setAttribute("code",lineCaptcha.getCode()); try { ServletOutputStream outputStream = response.getOutputStream(); lineCaptcha.write(outputStream); outputStream.close(); } catch (IOException e) { e.printStackTrace(); } } @SysLog("用户查询 *** 作") @RequestMapping("/userList") public DataGridViewResult userList(UserVO userVO) { //分页构造函数 IPagepage = new Page<>(userVO.getPage(), userVO.getLimit()); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.like(!StringUtils.isEmpty(userVO.getUsername()), "username", userVO.getUsername()); queryWrapper.like(!StringUtils.isEmpty(userVO.getUname()), "uname", userVO.getUname()); IPage userIPage = userService.page(page, queryWrapper); return new DataGridViewResult(userIPage.getTotal(), userIPage.getRecords()); } @SysLog("用户添加 *** 作") @PostMapping("/adduser") public Result addRole(User user) { user.setUcreatetime(new Date()); String salt = UUIDUtil.randomUUID(); user.setPassword(PasswordUtil.md5("000000", salt, 2)); user.setSalt(salt); user.setType(1); boolean bool = userService.save(user); try { if (bool) { return Result.success(true, "200", "添加成功!"); } } catch (Exception e) { e.printStackTrace(); } return Result.error(false, null, "添加失败!"); } @RequestMapping("/checkUserName") public String checkUserName(String username) { Map map = new HashMap<>(); try { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("username", username); User user = userService.getOne(queryWrapper); if (user != null) { map.put("exist", true); map.put("message", "用户名已存在"); } else { map.put("exist", false); map.put("message", "用户名可以使用"); } } catch (Exception e) { e.printStackTrace(); } return JSON.toJSonString(map); } @SysLog("用户修改 *** 作") @PostMapping("/updateuser") public Result updateUser(User user) { boolean bool = userService.updateById(user); try { if (bool) { return Result.success(true, "200", "修改成功!"); } } catch (Exception e) { e.printStackTrace(); } return Result.error(false, null, "修改失败!"); } @SysLog("用户删除 *** 作") @RequestMapping("/deleteOne") public Result deleteOne(int id) { boolean bool = userService.removeById(id); try { if (bool) { return Result.success(true, "200", "删除成功!"); } } catch (Exception e) { e.printStackTrace(); } return Result.error(false, null, "删除失败!"); } @SysLog("用户修改 *** 作") @PostMapping("/resetPwd") public Result resetPwd(int id) { User user = new User(); String salt = UUIDUtil.randomUUID(); user.setUid(id); user.setPassword(PasswordUtil.md5("000000", salt, 2)); user.setSalt(salt); boolean bool = userService.updateById(user); try { if (bool) { return Result.success(true, "200", "重置成功!"); } } catch (Exception e) { e.printStackTrace(); } return Result.error(false, null, "重置失败!"); } @RequestMapping("/initRoleByUserId") public DataGridViewResult initRoleByUserId(int id) { List 欢迎分享,转载请注明来源:内存溢出
评论列表(0条)