diff --git a/online-taxi-public/internal-common/src/main/java/com/internal/dto/DriverUserWorkStatus.java b/online-taxi-public/internal-common/src/main/java/com/internal/dto/DriverUserWorkStatus.java new file mode 100644 index 0000000..a7a02b4 --- /dev/null +++ b/online-taxi-public/internal-common/src/main/java/com/internal/dto/DriverUserWorkStatus.java @@ -0,0 +1,41 @@ +package com.internal.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + *

+ * + *

+ * + * @author author + * @since 2023-05-05 + */ +@Data +public class DriverUserWorkStatus implements Serializable { + + private static final long serialVersionUID = 1L; + + private Long id; + + private Long driverId; + + /** + * 收车:0;出车:1,暂停:2 + */ + private Integer workStatus; + + /** + * 创建时间 + */ + private LocalDateTime gmtCreate; + + /** + * 修改时间 + */ + private LocalDateTime gmtModified; + + +} diff --git a/online-taxi-public/service-driver-user/src/main/java/com/taxi/servicedriveruser/controller/DriverUserWorkStatusController.java b/online-taxi-public/service-driver-user/src/main/java/com/taxi/servicedriveruser/controller/DriverUserWorkStatusController.java new file mode 100644 index 0000000..4ce03d5 --- /dev/null +++ b/online-taxi-public/service-driver-user/src/main/java/com/taxi/servicedriveruser/controller/DriverUserWorkStatusController.java @@ -0,0 +1,35 @@ +package com.taxi.servicedriveruser.controller; + + +import com.internal.dto.DriverUserWorkStatus; +import com.internal.dto.ResponseResult; +import com.taxi.servicedriveruser.service.DriverUserWorkStatusService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; + +import org.springframework.web.bind.annotation.RestController; + +/** + *

+ * 前端控制器 + *

+ * + * @author author + * @since 2023-05-05 + */ +@RestController +public class DriverUserWorkStatusController { + + + @Autowired + private DriverUserWorkStatusService driverUserWorkStatusService; + + @RequestMapping("/driver-user-work-status") + public ResponseResult changeWorkStatus(@RequestBody DriverUserWorkStatus driverUserWorkStatus){ + Long driverId = driverUserWorkStatus.getDriverId(); + Integer workStatus = driverUserWorkStatus.getWorkStatus(); + return driverUserWorkStatusService.changeWorkStatus(driverId,workStatus); + } + +} diff --git a/online-taxi-public/service-driver-user/src/main/java/com/taxi/servicedriveruser/generator/MysqlGenerator.java b/online-taxi-public/service-driver-user/src/main/java/com/taxi/servicedriveruser/generator/MysqlGenerator.java index 5ea029f..02d931a 100644 --- a/online-taxi-public/service-driver-user/src/main/java/com/taxi/servicedriveruser/generator/MysqlGenerator.java +++ b/online-taxi-public/service-driver-user/src/main/java/com/taxi/servicedriveruser/generator/MysqlGenerator.java @@ -17,7 +17,7 @@ public class MysqlGenerator { builder.parent("com.taxi.servicedriveruser").pathInfo(Collections.singletonMap(OutputFile.mapperXml, "/Users/topsun/Documents/workSpce/gitlab-projectTest/online-taxi-public/service-driver-user/src/main/java/com/taxi/servicedriveruser/mapper")); }).strategyConfig(builder -> { - builder.addInclude("driver_car_binding_relationship "); + builder.addInclude("driver_user_work_status"); }).templateEngine(new FreemarkerTemplateEngine()).execute(); } diff --git a/online-taxi-public/service-driver-user/src/main/java/com/taxi/servicedriveruser/mapper/DriverUserWorkStatusMapper.java b/online-taxi-public/service-driver-user/src/main/java/com/taxi/servicedriveruser/mapper/DriverUserWorkStatusMapper.java new file mode 100644 index 0000000..2930c64 --- /dev/null +++ b/online-taxi-public/service-driver-user/src/main/java/com/taxi/servicedriveruser/mapper/DriverUserWorkStatusMapper.java @@ -0,0 +1,18 @@ +package com.taxi.servicedriveruser.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.internal.dto.DriverUserWorkStatus; +import org.springframework.stereotype.Repository; + +/** + *

+ * Mapper 接口 + *

+ * + * @author author + * @since 2023-05-05 + */ +@Repository +public interface DriverUserWorkStatusMapper extends BaseMapper { + +} diff --git a/online-taxi-public/service-driver-user/src/main/java/com/taxi/servicedriveruser/service/DriverUserWorkStatusService.java b/online-taxi-public/service-driver-user/src/main/java/com/taxi/servicedriveruser/service/DriverUserWorkStatusService.java new file mode 100644 index 0000000..6955fe5 --- /dev/null +++ b/online-taxi-public/service-driver-user/src/main/java/com/taxi/servicedriveruser/service/DriverUserWorkStatusService.java @@ -0,0 +1,41 @@ +package com.taxi.servicedriveruser.service; + +import com.internal.dto.DriverUserWorkStatus; +import com.internal.dto.ResponseResult; +import com.taxi.servicedriveruser.mapper.DriverUserWorkStatusMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + *

+ * 服务类 + *

+ * + * @author author + * @since 2023-05-05 + */ +@Service +public class DriverUserWorkStatusService { + + @Autowired + private DriverUserWorkStatusMapper driverUserWorkStatusMapper; + + public ResponseResult changeWorkStatus(Long driverId,Integer workStatus){ + + Map selectMap = new HashMap<>(); + selectMap.put("driver_id",driverId); + List list = driverUserWorkStatusMapper.selectByMap(selectMap); + + DriverUserWorkStatus driverUserWorkStatus = list.get(0); + + driverUserWorkStatus.setWorkStatus(workStatus); + driverUserWorkStatusMapper.updateById(driverUserWorkStatus); + + return ResponseResult.success(); + } +}