phpcjl
2024-11-26 ca8a3cff66f9820aeac841a85b118935fdb3e990
1.完成技师预约接口开发
1个文件已添加
3个文件已修改
45 ■■■■■ 已修改文件
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/GoodsStatus.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/PhoneType.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/TechnicianErrorCode.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/GoodsStatus.java
@@ -1,22 +1,18 @@
package com.ruoyi.other.enums;
import lombok.Getter;
@Getter
public enum GoodsStatus {
    DOWN(0, "下架"),
    UP(1, "上架");
    private Integer code;
    private String desc;
    private final Integer code;
    private final String desc;
    GoodsStatus(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }
    public Integer getCode() {
        return code;
    }
    public String getDesc() {
        return desc;
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/PhoneType.java
@@ -4,8 +4,8 @@
    PLATFORM(1, "平台"),
    SHOP(2, "门店");
    private Integer code;
    private String desc;
    private final Integer code;
    private final String desc;
    PhoneType(Integer code, String desc) {
        this.code = code;
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/TechnicianErrorCode.java
New file
@@ -0,0 +1,18 @@
package com.ruoyi.other.enums;
import lombok.Getter;
@Getter
public enum TechnicianErrorCode {
    TECHNICIAN_ALREADY_SUBSCRIBED(1001, "该技师已被预约"),
    ;
    private final int code;
    private final String message;
    TechnicianErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java
@@ -1,15 +1,14 @@
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;
import com.ruoyi.other.api.domain.Technician;
import com.ruoyi.other.api.domain.TechnicianSubscribe;
import com.ruoyi.other.enums.TechnicianErrorCode;
import com.ruoyi.other.mapper.TechnicianMapper;
import com.ruoyi.other.mapper.TechnicianSubscribeMapper;
import com.ruoyi.other.api.domain.TechnicianSubscribe;
import com.ruoyi.other.service.TechnicianSubscribeService;
import com.ruoyi.other.vo.TechnicianSubscribeVO;
import org.springframework.stereotype.Service;
@@ -42,6 +41,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void subscribe(TechnicianSubscribe technicianSubscribe) {
        // 创建技师预约单
        Long technicianId = technicianSubscribe.getTechnicianId();
        Long userId = SecurityUtils.getUserId();
        TechnicianSubscribe subscribe = new TechnicianSubscribe();
@@ -49,6 +49,7 @@
        subscribe.setDelFlag(0);
        subscribe.setCreateTime(LocalDateTime.now());
        technicianSubscribeMapper.insert(subscribe);
        // 更新技师状态
        UpdateWrapper<Technician> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("id", technicianId);
        updateWrapper.eq("subscribe_status", 1);
@@ -57,7 +58,7 @@
        updateWrapper.set("create_time", LocalDateTime.now());
        int update = technicianMapper.update(null, updateWrapper);
        if (update == 0){
            throw new ServiceException("改技师已预约");
            throw new ServiceException("该技师已被预约", TechnicianErrorCode.TECHNICIAN_ALREADY_SUBSCRIBED.getCode());
        }
    }
}