五、核心代码
5.1 查询瑜伽课程
@RequestMapping(value = "/getByPage", method = RequestMethod.GET) @ApiOperation(value = "查询瑜伽课程") public Result<IPage<YogaCurriculum>> getByPage(@ModelAttribute YogaCurriculum yogaCurriculum ,@ModelAttribute PageVo page){ QueryWrapper<YogaCurriculum> qw = new QueryWrapper<>(); if(!ZwzNullUtils.isNull(yogaCurriculum.getTitle())) { qw.like("title",yogaCurriculum.getTitle()); } if(!ZwzNullUtils.isNull(yogaCurriculum.getType())) { qw.eq("type",yogaCurriculum.getType()); } if(!ZwzNullUtils.isNull(yogaCurriculum.getUserName())) { qw.like("user_name",yogaCurriculum.getUserName()); } User currUser = securityUtil.getCurrUser(); IPage<YogaCurriculum> data = iYogaCurriculumService.page(PageUtil.initMpPage(page),qw); for (YogaCurriculum vo : data.getRecords()) { QueryWrapper<YogaOrder> orderQw = new QueryWrapper<>(); orderQw.eq("curriculum_id",vo.getId()); orderQw.eq("order_id",currUser.getId()); vo.setOrderFlag(iYogaOrderService.count(orderQw)); } return new ResultUtil<IPage<YogaCurriculum>>().setData(data); }
5.2 瑜伽课程预约
@RequestMapping(value = "/addOne", method = RequestMethod.GET) @ApiOperation(value = "新增预约") public Result<Object> addOne(@RequestParam String id){ YogaCurriculum c = iYogaCurriculumService.getById(id); if(c == null) { return ResultUtil.error("瑜伽课程不存在"); } YogaOrder o = new YogaOrder(); o.setCurriculumId(c.getId()); o.setCurriculumName(c.getTitle()); o.setContent(c.getContent()); o.setType(c.getType()); o.setUserId(c.getUserId()); o.setUserName(c.getUserName()); o.setImage(c.getImage()); o.setPrice(c.getPrice()); User currUser = securityUtil.getCurrUser(); o.setOrderId(currUser.getId()); o.setOrderName(currUser.getNickname()); o.setOrderTime(DateUtil.now()); // 扣除费用 User user = iUserService.getById(currUser.getId()); if(o.getPrice().compareTo(user.getMoney()) > 0) { return ResultUtil.error("余额不足"); } user.setMoney(user.getMoney().subtract(o.getPrice())); iUserService.saveOrUpdate(user); iYogaOrderService.saveOrUpdate(o); return ResultUtil.success(); }
5.3 瑜伽课程评价
@RequestMapping(value = "/addAppraise", method = RequestMethod.GET) @ApiOperation(value = "新增评价") public Result<YogaArrange> addAppraise(@RequestParam String id,@RequestParam String level,@RequestParam String content){ YogaCurriculum c = iYogaCurriculumService.getById(id); if(c == null) { return ResultUtil.error("瑜伽课程不存在"); } User currUser = securityUtil.getCurrUser(); YogaAppraise a = new YogaAppraise(); a.setCurriculumId(c.getId()); a.setCurriculumName(c.getTitle()); a.setLevel(level); a.setContent(content); a.setOrderId(currUser.getId()); a.setOrderName(currUser.getNickname()); a.setOrderTime(DateUtil.now()); iYogaAppraiseService.saveOrUpdate(a); return ResultUtil.success(); }
5.4 查询瑜伽器械
@RequestMapping(value = "/getByPage", method = RequestMethod.GET) @ApiOperation(value = "查询瑜伽器械") public Result<IPage<YogaApparatus>> getByPage(@ModelAttribute YogaApparatus yogaApparatus ,@ModelAttribute PageVo page){ QueryWrapper<YogaApparatus> qw = new QueryWrapper<>(); if(!ZwzNullUtils.isNull(yogaApparatus.getTitle())) { qw.like("title",yogaApparatus.getTitle()); } if(!ZwzNullUtils.isNull(yogaApparatus.getBrand())) { qw.like("brand",yogaApparatus.getBrand()); } if(!ZwzNullUtils.isNull(yogaApparatus.getPurpose())) { qw.like("purpose",yogaApparatus.getPurpose()); } IPage<YogaApparatus> data = iYogaApparatusService.page(PageUtil.initMpPage(page),qw); return new ResultUtil<IPage<YogaApparatus>>().setData(data); }
5.5 新增公告
@RequestMapping(value = "/insert", method = RequestMethod.POST) @ApiOperation(value = "新增公告") public Result<Announcement> insert(Announcement announcement){ if(Objects.equals(0,announcement.getSortOrder().compareTo(BigDecimal.ZERO))) { announcement.setSortOrder(BigDecimal.valueOf(iAnnouncementService.count() + 1L)); } User currUser = securityUtil.getCurrUser(); announcement.setPublisher(currUser.getNickname()); iAnnouncementService.saveOrUpdate(announcement); return new ResultUtil<Announcement>().setData(announcement); }
六、免责说明
- 本项目仅供个人学习使用,商用授权请联系博主,否则后果自负。
- 博主拥有本软件构建后的应用系统全部内容所有权及独立的知识产权,拥有最终解释权。
- 如有问题,欢迎在仓库 Issue 留言,看到后会第一时间回复,相关意见会酌情考虑,但没有一定被采纳的承诺或保证。
下载本系统代码或使用本系统的用户,必须同意以下内容,否则请勿下载!
- 出于自愿而使用/开发本软件,了解使用本软件的风险,且同意自己承担使用本软件的风险。
- 利用本软件构建的网站的任何信息内容以及导致的任何版权纠纷和法律争议及后果和博主无关,博主对此不承担任何责任。
- 在任何情况下,对于因使用或无法使用本软件而导致的任何难以合理预估的损失(包括但不仅限于商业利润损失、业务中断与业务信息丢失),博主概不承担任何责任。
- 必须了解使用本软件的风险,博主不承诺提供一对一的技术支持、使用担保,也不承担任何因本软件而产生的难以预料的问题的相关责任。