司机工作状态接口设计及代码实现

main
topsun 2 years ago
parent d1785b5dbb
commit e0aba138ac

@ -0,0 +1,41 @@
package com.internal.dto;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
*
* </p>
*
* @author author
* @since 2023-05-05
*/
@Data
public class DriverUserWorkStatus implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
private Long driverId;
/**
* 012
*/
private Integer workStatus;
/**
*
*/
private LocalDateTime gmtCreate;
/**
*
*/
private LocalDateTime gmtModified;
}

@ -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;
/**
* <p>
*
* </p>
*
* @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);
}
}

@ -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();
}

@ -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;
/**
* <p>
* Mapper
* </p>
*
* @author author
* @since 2023-05-05
*/
@Repository
public interface DriverUserWorkStatusMapper extends BaseMapper<DriverUserWorkStatus> {
}

@ -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;
/**
* <p>
*
* </p>
*
* @author author
* @since 2023-05-05
*/
@Service
public class DriverUserWorkStatusService {
@Autowired
private DriverUserWorkStatusMapper driverUserWorkStatusMapper;
public ResponseResult changeWorkStatus(Long driverId,Integer workStatus){
Map<String,Object> selectMap = new HashMap<>();
selectMap.put("driver_id",driverId);
List<DriverUserWorkStatus> list = driverUserWorkStatusMapper.selectByMap(selectMap);
DriverUserWorkStatus driverUserWorkStatus = list.get(0);
driverUserWorkStatus.setWorkStatus(workStatus);
driverUserWorkStatusMapper.updateById(driverUserWorkStatus);
return ResponseResult.success();
}
}
Loading…
Cancel
Save