运营商配置添加或更新

This commit is contained in:
yanglei 2026-03-04 10:23:15 +08:00
parent ba6b471523
commit f6af6dcf91
2 changed files with 33 additions and 14 deletions

View File

@ -21,7 +21,7 @@ import static com.cdzy.operations.model.entity.table.EbikeCarrierConfigurationTa
/** /**
* 运营商配置配置 控制层 * 运营商配置 控制层
* *
* @author yanglei * @author yanglei
* @since 2026-01-08 17:08 * @since 2026-01-08 17:08
@ -34,12 +34,12 @@ public class EbikeCarrierConfigurationController {
private EbikeCarrierConfigurationService carrierConfigurationService; private EbikeCarrierConfigurationService carrierConfigurationService;
/** /**
* 添加 * 添加更新
* *
* @param dto 配置实体类 * @param dto 配置实体类
* @return 主键id * @return 主键id
*/ */
@PostMapping("save") @PostMapping("saveOrUpdate")
public JsonResult<?> save(@RequestBody @Validated EbikeSaveConfigurationDto dto) { public JsonResult<?> save(@RequestBody @Validated EbikeSaveConfigurationDto dto) {
carrierConfigurationService.saveConfiguration(dto); carrierConfigurationService.saveConfiguration(dto);
return JsonResult.success(); return JsonResult.success();

View File

@ -35,21 +35,40 @@ public class EbikeCarrierConfigurationServiceImpl extends ServiceImpl<EbikeCarri
return this.mapper.selectOneByQuery(queryWrapper); return this.mapper.selectOneByQuery(queryWrapper);
} }
/**
* 保存更新运营商配置
*
* @param dto 配置项参数
*/
@Transactional @Transactional
@Override @Override
public void saveConfiguration(EbikeSaveConfigurationDto dto) { public void saveConfiguration(EbikeSaveConfigurationDto dto) {
if (dto.getOperatorId() == null) { Long staffId = StpUtil.getLoginIdAsLong();
throw new EbikeException("保存配置时运营商id不能为空"); QueryWrapper queryWrapper = QueryWrapper.create()
} .select(EBIKE_CARRIER_CONFIGURATION.ALL_COLUMNS)
.and(EBIKE_CARRIER_CONFIGURATION.OPERATOR_ID.eq(dto.getOperatorId()));
EbikeCarrierConfiguration config = this.mapper.selectOneByQuery(queryWrapper);
// 保存
if (config == null) {
EbikeCarrierConfiguration configuration = EbikeCarrierConfiguration.builder() EbikeCarrierConfiguration configuration = EbikeCarrierConfiguration.builder()
.operatorId(dto.getOperatorId()) .operatorId(dto.getOperatorId())
.dispatchDuration(dto.getDispatchDuration()) .dispatchDuration(dto.getDispatchDuration())
.rideDuration(dto.getRideDuration()) .rideDuration(dto.getRideDuration())
.inspectionIntervalDuration(dto.getInspectionIntervalDuration()) .inspectionIntervalDuration(dto.getInspectionIntervalDuration())
.operatorPhone(dto.getOperatorPhone()) .operatorPhone(dto.getOperatorPhone())
.createdBy(StpUtil.getLoginIdAsLong()) .createdBy(staffId)
.build(); .build();
this.mapper.insert(configuration); this.mapper.insert(configuration);
} else {
// 更新
config.setOperatorId(dto.getOperatorId());
config.setDispatchDuration(dto.getDispatchDuration());
config.setRideDuration(dto.getRideDuration());
config.setInspectionIntervalDuration(dto.getInspectionIntervalDuration());
config.setOperatorPhone(dto.getOperatorPhone());
config.setUpdatedBy(staffId);
this.mapper.update(config);
}
} }
@Transactional @Transactional