From 6e63c56896844d2753c432e24301b8eafee2938a Mon Sep 17 00:00:00 2001 From: phpcjl <phpcjl@gmail.com> Date: 星期二, 26 十一月 2024 17:50:22 +0800 Subject: [PATCH] 1.完成技师预约接口开发 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java index 6fb0962..6190ea4 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java @@ -1,6 +1,8 @@ package com.ruoyi.other.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.security.utils.SecurityUtils; @@ -41,20 +43,20 @@ @Transactional(rollbackFor = Exception.class) public void subscribe(TechnicianSubscribe technicianSubscribe) { Long technicianId = technicianSubscribe.getTechnicianId(); - Technician technician = technicianMapper.selectOne(new LambdaQueryWrapper<Technician>() - .eq(Technician::getId, technicianId) - .eq(Technician::getStatus, 1) - .eq(Technician::getSubscribeStatus, 1)); - if (null == technician) { - throw new ServiceException("不满足预约条件"); - } Long userId = SecurityUtils.getUserId(); TechnicianSubscribe subscribe = new TechnicianSubscribe(); subscribe.setAppUserId(userId); subscribe.setDelFlag(0); subscribe.setCreateTime(LocalDateTime.now()); technicianSubscribeMapper.insert(subscribe); - technician.setSubscribeStatus(2); - technicianMapper.updateById(technician); + UpdateWrapper<Technician> updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("id", technicianId); + updateWrapper.eq("subscribe_status", 1); + updateWrapper.eq("status", 2); + updateWrapper.set("subscribe_status", 2); + int update = technicianMapper.update(null, updateWrapper); + if (update == 0){ + throw new ServiceException("改技师已预约"); + } } } -- Gitblit v1.7.1