84 lines
3.0 KiB
Java
84 lines
3.0 KiB
Java
package com.cdzy.ebikeoperate.controller;
|
|
|
|
import com.cdzy.common.model.JsonResult;
|
|
import com.cdzy.ebikeoperate.model.dto.response.EbikeSysRdispatchsetDto;
|
|
import com.cdzy.ebikeoperate.service.EbikeSysDistanceIncentiveService;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import com.cdzy.ebikeoperate.model.pojo.EbikeSysRdispatchset;
|
|
import com.cdzy.ebikeoperate.service.EbikeSysRdispatchsetService;
|
|
|
|
/**
|
|
* 区域调度配置 控制层。
|
|
*
|
|
* @author dingchao
|
|
* @since 2025-04-15
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/ebikeSysRdispatchset")
|
|
public class EbikeSysRdispatchsetController {
|
|
|
|
@Autowired
|
|
private EbikeSysRdispatchsetService ebikeSysRdispatchsetService;
|
|
@Autowired
|
|
private EbikeSysDistanceIncentiveService ebikeSysDistanceIncentiveService;
|
|
|
|
|
|
/**
|
|
* 添加区域调度配置。
|
|
*
|
|
* @param ebikeSysRdispatchset 区域调度配置
|
|
* @return {@code true} 添加成功,{@code false} 添加失败
|
|
*/
|
|
@PostMapping("save")
|
|
public JsonResult<?> save(@RequestBody EbikeSysRdispatchset ebikeSysRdispatchset) {
|
|
boolean r = ebikeSysRdispatchsetService.save(ebikeSysRdispatchset);
|
|
return r? JsonResult.success() : JsonResult.failed("添加区域调度配置失败");
|
|
}
|
|
|
|
/**
|
|
* 根据区域ID删除区域调度配置。
|
|
*
|
|
* @param regionId 区域ID
|
|
* @return {@code true} 删除成功,{@code false} 删除失败
|
|
*/
|
|
@PostMapping("remove")
|
|
public JsonResult<?> remove(@RequestParam(name = "regionId") String regionId) {
|
|
boolean r = ebikeSysRdispatchsetService.deleteByRegionId(regionId);
|
|
return r? JsonResult.success() : JsonResult.failed("删除区域调度配置失败");
|
|
}
|
|
|
|
/**
|
|
* 根据主键更新区域调度配置。
|
|
*
|
|
* @param ebikeSysRdispatchset 区域调度配置
|
|
* @return {@code true} 更新成功,{@code false} 更新失败
|
|
*/
|
|
@PostMapping("update")
|
|
public JsonResult<?> update(@RequestBody EbikeSysRdispatchset ebikeSysRdispatchset) {
|
|
boolean r = ebikeSysRdispatchsetService.updateById(ebikeSysRdispatchset);
|
|
return r? JsonResult.success() : JsonResult.failed("更新区域调度配置失败");
|
|
}
|
|
|
|
/**
|
|
* 根据区域ID获取调度配置详细信息。
|
|
*
|
|
* @param regionId 区域ID
|
|
* @return 区域调度配置详情
|
|
*/
|
|
@GetMapping("getInfo")
|
|
public JsonResult<?> getInfo(@RequestParam(name = "regionId") String regionId) {
|
|
EbikeSysRdispatchset r = ebikeSysRdispatchsetService.getByRegionId(regionId);
|
|
if (r == null) {
|
|
return JsonResult.failed("获取区域调度配置详情失败");
|
|
}
|
|
EbikeSysRdispatchsetDto dto = new EbikeSysRdispatchsetDto();
|
|
BeanUtils.copyProperties(r, dto);
|
|
// 调度距离激励
|
|
dto.setDistanceIncentiveList(ebikeSysDistanceIncentiveService.getListByReginId(regionId));
|
|
return JsonResult.success(dto);
|
|
}
|
|
|
|
}
|