package com.supersavedriving.driver.modular.system.api;
|
|
import com.supersavedriving.driver.core.common.annotion.ServiceLog;
|
import com.supersavedriving.driver.modular.system.service.IDriverService;
|
import com.supersavedriving.driver.modular.system.service.IDriverWorkService;
|
import com.supersavedriving.driver.modular.system.util.ResultUtil;
|
import com.supersavedriving.driver.modular.system.warpper.ResponseWarpper;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
/**
|
* 司机上下班控制器
|
* @author pzb
|
* @Date 2023/2/15 15:39
|
*/
|
@RestController
|
@RequestMapping("")
|
public class DriverWorkController {
|
|
@Autowired
|
private IDriverService driverService;
|
|
@Autowired
|
private IDriverWorkService driverWorkService;
|
|
|
|
|
|
@ResponseBody
|
@PostMapping("/api/home/driverWork")
|
@ServiceLog(name = "司机上班操作", url = "/api/home/driverWork")
|
@ApiOperation(value = "司机上班操作", tags = {"司机端-首页"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper driverWork(HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserByRequset(request);
|
if(null == uid){
|
return ResponseWarpper.success(ResultUtil.tokenErr());
|
}
|
ResultUtil resultUtil = driverWorkService.driverWork(uid);
|
return ResponseWarpper.success(resultUtil);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
@ResponseBody
|
@PostMapping("/api/home/driverOffWork")
|
@ServiceLog(name = "司机下班操作", url = "/api/home/driverOffWork")
|
@ApiOperation(value = "司机下班操作", tags = {"司机端-首页"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "在线时长(秒)", name = "onlineTime", required = true, dataType = "long"),
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper driverOffWork(Long onlineTime, HttpServletRequest request){
|
if(null == onlineTime){
|
return ResponseWarpper.success(ResultUtil.paranErr("onlineTime"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequset(request);
|
if(null == uid){
|
return ResponseWarpper.success(ResultUtil.tokenErr());
|
}
|
ResultUtil resultUtil = driverWorkService.driverOffWork(uid, onlineTime);
|
return ResponseWarpper.success(resultUtil);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
|
}
|