车辆调度配置
This commit is contained in:
parent
e37b14fa45
commit
4c2d731d51
@ -0,0 +1,95 @@
|
||||
package com.cdzy.operations.controller;
|
||||
|
||||
import com.cdzy.common.model.request.PageParam;
|
||||
import com.cdzy.common.model.response.JsonResult;
|
||||
import com.cdzy.operations.model.dto.EbikeSaveConfigurationDto;
|
||||
import com.cdzy.operations.model.dto.EbikeUpdateConfigurationDto;
|
||||
import com.cdzy.operations.model.entity.EbikeDispatchConfiguration;
|
||||
import com.cdzy.operations.service.EbikeDispatchConfigurationService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static com.cdzy.operations.model.entity.table.EbikeDispatchConfigurationTableDef.EBIKE_DISPATCH_CONFIGURATION;
|
||||
|
||||
/**
|
||||
* 调度配置 控制层
|
||||
*
|
||||
* @author yanglei
|
||||
* @since 2026-01-08 17:08
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ebikeDispatchConfiguration")
|
||||
public class EbikeDispatchConfigurationController {
|
||||
|
||||
@Resource
|
||||
private EbikeDispatchConfigurationService dispatchConfigurationService;
|
||||
|
||||
/**
|
||||
* 添加。
|
||||
*
|
||||
* @param dto 配置实体类
|
||||
* @return 主键id
|
||||
*/
|
||||
@PostMapping("save")
|
||||
public JsonResult<?> save(@RequestBody EbikeSaveConfigurationDto dto) {
|
||||
dispatchConfigurationService.saveConfiguration(dto);
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主键删除。
|
||||
*
|
||||
* @param configurationId 主键
|
||||
* @return {@code true} 删除成功,{@code false} 删除失败
|
||||
*/
|
||||
@GetMapping("remove")
|
||||
public JsonResult<?> remove(@RequestParam("configurationId") Long configurationId) {
|
||||
dispatchConfigurationService.removeById(configurationId);
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主键更新。
|
||||
*
|
||||
* @param dto 配置实体类信息
|
||||
* @return {@code true} 更新成功,{@code false} 更新失败
|
||||
*/
|
||||
@PostMapping("update")
|
||||
public JsonResult<?> update(@RequestBody EbikeUpdateConfigurationDto dto) {
|
||||
dispatchConfigurationService.updateConfiguration(dto);
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主键id查询
|
||||
*
|
||||
* @param configurationId 主键id
|
||||
* @return 配置信息
|
||||
*/
|
||||
@GetMapping("getById")
|
||||
public JsonResult<?> getById(@RequestParam("configurationId") Long configurationId) {
|
||||
EbikeDispatchConfiguration result = dispatchConfigurationService.getById(configurationId);
|
||||
return JsonResult.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @return 配置信息
|
||||
*/
|
||||
@GetMapping("page")
|
||||
public JsonResult<?> page(PageParam page) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(EBIKE_DISPATCH_CONFIGURATION.ALL_COLUMNS);
|
||||
Page<EbikeDispatchConfiguration> orderPage = dispatchConfigurationService.pageAs(page.getPage(), queryWrapper, EbikeDispatchConfiguration.class);
|
||||
return JsonResult.success(orderPage);
|
||||
}
|
||||
}
|
||||
@ -7,20 +7,13 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 配置项 实体类
|
||||
*
|
||||
* @author yanglei
|
||||
* @since 2025-12-03 16:31
|
||||
* @since 2026-01-09 09:36
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class EbikeDispatchConfigurationDto {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long configurationId;
|
||||
public class EbikeSaveConfigurationDto {
|
||||
|
||||
/**
|
||||
* 运营商id
|
||||
@ -35,7 +28,7 @@ public class EbikeDispatchConfigurationDto {
|
||||
private Integer dispatchDuration;
|
||||
|
||||
/**
|
||||
* 配置项描述
|
||||
* 配置项骑行时长
|
||||
*/
|
||||
@NotBlank(message = "调度完成后多长时间内骑行是有效的不能为空")
|
||||
private Integer rideDuration;
|
||||
@ -0,0 +1,35 @@
|
||||
package com.cdzy.operations.model.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 配置项 实体类
|
||||
*
|
||||
* @author yanglei
|
||||
* @since 2025-12-03 16:31
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class EbikeUpdateConfigurationDto {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@NotNull(message = "主键不能为空")
|
||||
private Long configurationId;
|
||||
|
||||
/**
|
||||
* 配置项时长
|
||||
*/
|
||||
private Integer dispatchDuration;
|
||||
|
||||
/**
|
||||
* 配置项骑行时长
|
||||
*/
|
||||
private Integer rideDuration;
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package com.cdzy.operations.service;
|
||||
|
||||
import com.cdzy.operations.model.dto.EbikeDispatchConfigurationDto;
|
||||
import com.cdzy.operations.model.dto.EbikeSaveConfigurationDto;
|
||||
import com.cdzy.operations.model.dto.EbikeUpdateConfigurationDto;
|
||||
import com.cdzy.operations.model.entity.EbikeDispatchConfiguration;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
@ -21,9 +22,16 @@ public interface EbikeDispatchConfigurationService extends IService<EbikeDispatc
|
||||
EbikeDispatchConfiguration getConfigurationByOperationId(Long operationId);
|
||||
|
||||
/**
|
||||
* 配置项保存
|
||||
* 保存配置项
|
||||
*
|
||||
* @param configurationDto 配置项参数
|
||||
* @param dto 配置项参数
|
||||
*/
|
||||
void saveOrUpdateConfiguration(EbikeDispatchConfigurationDto configurationDto);
|
||||
void saveConfiguration(EbikeSaveConfigurationDto dto);
|
||||
|
||||
/**
|
||||
* 根据主键更新
|
||||
*
|
||||
* @param dto 配置项参数
|
||||
*/
|
||||
void updateConfiguration(EbikeUpdateConfigurationDto dto);
|
||||
}
|
||||
|
||||
@ -1,15 +1,17 @@
|
||||
package com.cdzy.operations.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.cdzy.common.ex.EbikeException;
|
||||
import com.cdzy.operations.mapper.EbikeDispatchConfigurationMapper;
|
||||
import com.cdzy.operations.model.dto.EbikeDispatchConfigurationDto;
|
||||
import com.cdzy.operations.model.dto.EbikeSaveConfigurationDto;
|
||||
import com.cdzy.operations.model.dto.EbikeUpdateConfigurationDto;
|
||||
import com.cdzy.operations.model.entity.EbikeDispatchConfiguration;
|
||||
import com.cdzy.operations.service.EbikeDispatchConfigurationService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.cdzy.operations.model.entity.table.EbikeDispatchConfigurationTableDef.EBIKE_DISPATCH_CONFIGURATION;
|
||||
@ -32,24 +34,33 @@ public class EbikeDispatchConfigurationServiceImpl extends ServiceImpl<EbikeDisp
|
||||
return this.mapper.selectOneByQuery(queryWrapper);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void saveOrUpdateConfiguration(EbikeDispatchConfigurationDto configurationDto) {
|
||||
if (configurationDto.getConfigurationId() != null) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_DISPATCH_CONFIGURATION.CONFIGURATION_ID.eq(configurationDto.getConfigurationId()));
|
||||
EbikeDispatchConfiguration ebikeDispatchConfiguration = this.mapper.selectOneByQuery(queryWrapper);
|
||||
ebikeDispatchConfiguration.setDispatchDuration(configurationDto.getDispatchDuration());
|
||||
ebikeDispatchConfiguration.setRideDuration(configurationDto.getRideDuration());
|
||||
ebikeDispatchConfiguration.setUpdatedBy(StpUtil.getLoginIdAsLong());
|
||||
this.mapper.update(ebikeDispatchConfiguration);
|
||||
} else {
|
||||
EbikeDispatchConfiguration configuration = EbikeDispatchConfiguration.builder()
|
||||
.operatorId(configurationDto.getOperatorId())
|
||||
.dispatchDuration(configurationDto.getDispatchDuration())
|
||||
.rideDuration(configurationDto.getRideDuration())
|
||||
.createdBy(StpUtil.getLoginIdAsLong())
|
||||
.build();
|
||||
this.mapper.insert(configuration);
|
||||
public void saveConfiguration(EbikeSaveConfigurationDto dto) {
|
||||
if (dto.getOperatorId() == null) {
|
||||
throw new EbikeException("保存配置时运营商id不能为空");
|
||||
}
|
||||
EbikeDispatchConfiguration configuration = EbikeDispatchConfiguration.builder()
|
||||
.operatorId(dto.getOperatorId())
|
||||
.dispatchDuration(dto.getDispatchDuration())
|
||||
.rideDuration(dto.getRideDuration())
|
||||
.createdBy(StpUtil.getLoginIdAsLong())
|
||||
.build();
|
||||
this.mapper.insert(configuration);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void updateConfiguration(EbikeUpdateConfigurationDto dto) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(EBIKE_DISPATCH_CONFIGURATION.ALL_COLUMNS)
|
||||
.where(EBIKE_DISPATCH_CONFIGURATION.CONFIGURATION_ID.eq(dto.getConfigurationId()));
|
||||
EbikeDispatchConfiguration configuration = this.mapper.selectOneByQuery(queryWrapper);
|
||||
if (Objects.isNull(configuration)) {
|
||||
throw new EbikeException("配置项不存在");
|
||||
}
|
||||
configuration.setDispatchDuration(dto.getDispatchDuration());
|
||||
configuration.setRideDuration(dto.getRideDuration());
|
||||
this.mapper.update(configuration);
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ public class VerifyUtil {
|
||||
if (!"10000".equals(code)) {
|
||||
String message = result.has("message") ? result.get("message").asText() : "未知错误";
|
||||
log.error("验证用户实名失败, code: {}, message: {}", code, message);
|
||||
throw new EbikeException("验证用户实名失败: " + message);
|
||||
throw new EbikeException("验证用户实名失败");
|
||||
}
|
||||
// 3. 解密并解析结果
|
||||
String data = securityContext.decrypt(result.get("data").asText(), realNameVerifyConfig.getClientPrivateKey());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user