用户上报记录
This commit is contained in:
parent
57afca9034
commit
b631863497
@ -0,0 +1,36 @@
|
|||||||
|
package com.cdzy.user.controller;
|
||||||
|
|
||||||
|
import com.cdzy.common.model.response.JsonResult;
|
||||||
|
import com.cdzy.user.model.dto.EbikeReportRecordDto;
|
||||||
|
import com.cdzy.user.service.EbikeReportRecordService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
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.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户上报记录 控制层
|
||||||
|
*
|
||||||
|
* @author yanglei
|
||||||
|
* @since 2025-12-23 16:51
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ebikeReportRecord")
|
||||||
|
public class EbikeReportRecordController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EbikeReportRecordService reportRecordService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存用户上报记录
|
||||||
|
*
|
||||||
|
* @param reportRecordDto 用户上报记录参数
|
||||||
|
*/
|
||||||
|
@PostMapping("/saveReportRecord")
|
||||||
|
public JsonResult<?> saveReportRecord(@RequestBody EbikeReportRecordDto reportRecordDto) {
|
||||||
|
reportRecordService.saveReportRecord(reportRecordDto);
|
||||||
|
return JsonResult.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.cdzy.user.mapper;
|
||||||
|
|
||||||
|
import com.cdzy.user.model.entity.EbikeReportRecordFile;
|
||||||
|
import com.mybatisflex.core.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yanglei
|
||||||
|
* @since 2025-12-23 16:50
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface EbikeReportRecordFileMapper extends BaseMapper<EbikeReportRecordFile> {
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.cdzy.user.mapper;
|
||||||
|
|
||||||
|
import com.cdzy.user.model.entity.EbikeReportRecord;
|
||||||
|
import com.mybatisflex.core.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yanglei
|
||||||
|
* @since 2025-12-23 16:50
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface EbikeReportRecordMapper extends BaseMapper<EbikeReportRecord> {
|
||||||
|
}
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
package com.cdzy.user.model.dto;
|
||||||
|
|
||||||
|
import com.cdzy.user.handler.PGpointDeserializer;
|
||||||
|
import com.cdzy.user.handler.PGpointSerializer;
|
||||||
|
import com.cdzy.user.handler.PGpointTypeHandler;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.mybatisflex.annotation.Column;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.postgresql.geometric.PGpoint;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户上报请求参数
|
||||||
|
*
|
||||||
|
* @author yanglei
|
||||||
|
* @since 2025-12-23 16:55
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class EbikeReportRecordDto {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
@NotNull(message = "用户id不能为空")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 骑行起始点
|
||||||
|
*/
|
||||||
|
@Column(typeHandler = PGpointTypeHandler.class)
|
||||||
|
@JsonSerialize(using = PGpointSerializer.class)
|
||||||
|
@JsonDeserialize(using = PGpointDeserializer.class)
|
||||||
|
@NotNull(message = "上报位置")
|
||||||
|
private PGpoint location;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户上报文件
|
||||||
|
*/
|
||||||
|
private List<EbikeReportRecordFileDto> recordFiles;
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.cdzy.user.model.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户上报文件请求参数
|
||||||
|
*
|
||||||
|
* @author yanglei
|
||||||
|
* @since 2025-11-18 11:26
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class EbikeReportRecordFileDto {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户上报文件主键id
|
||||||
|
*/
|
||||||
|
private Long recordFileId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件名称
|
||||||
|
*/
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件地址
|
||||||
|
*/
|
||||||
|
private String fileUrl;
|
||||||
|
}
|
||||||
@ -0,0 +1,82 @@
|
|||||||
|
package com.cdzy.user.model.entity;
|
||||||
|
|
||||||
|
import com.cdzy.user.handler.PGpointDeserializer;
|
||||||
|
import com.cdzy.user.handler.PGpointSerializer;
|
||||||
|
import com.cdzy.user.handler.PGpointTypeHandler;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.mybatisflex.annotation.Column;
|
||||||
|
import com.mybatisflex.annotation.Id;
|
||||||
|
import com.mybatisflex.annotation.Table;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.postgresql.geometric.PGpoint;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yanglei
|
||||||
|
* @since 2025-12-23 16:44
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Table("ebike_report_record")
|
||||||
|
public class EbikeReportRecord implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
@Id
|
||||||
|
private Long recordId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上报位置
|
||||||
|
*/
|
||||||
|
@Column(typeHandler = PGpointTypeHandler.class)
|
||||||
|
@JsonSerialize(using = PGpointSerializer.class)
|
||||||
|
@JsonDeserialize(using = PGpointDeserializer.class)
|
||||||
|
private PGpoint location;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理状态 0-未处理 1-已处理
|
||||||
|
*/
|
||||||
|
private Integer recordStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
private Long createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@Column(onInsertValue = "now()")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新人
|
||||||
|
*/
|
||||||
|
private Long updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@Column(onUpdateValue = "now()")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除状态(true表示已删除)
|
||||||
|
*/
|
||||||
|
private Boolean isDeleted;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,76 @@
|
|||||||
|
package com.cdzy.user.model.entity;
|
||||||
|
|
||||||
|
import com.mybatisflex.annotation.Column;
|
||||||
|
import com.mybatisflex.annotation.Id;
|
||||||
|
import com.mybatisflex.annotation.Table;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yanglei
|
||||||
|
* @since 2025-12-23 16:44
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Table("ebike_report_record_file")
|
||||||
|
public class EbikeReportRecordFile implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
@Id
|
||||||
|
private Long recordFileId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户退款主键id
|
||||||
|
*/
|
||||||
|
private Long recordId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件名称
|
||||||
|
*/
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件地址
|
||||||
|
*/
|
||||||
|
private String fileUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
private Long createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@Column(onInsertValue = "now()")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新人
|
||||||
|
*/
|
||||||
|
private Long updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@Column(onUpdateValue = "now()")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除状态(true表示已删除)
|
||||||
|
*/
|
||||||
|
private Boolean isDeleted;
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package com.cdzy.user.service;
|
||||||
|
|
||||||
|
import com.cdzy.user.model.dto.EbikeReportRecordDto;
|
||||||
|
import com.cdzy.user.model.entity.EbikeReportRecord;
|
||||||
|
import com.mybatisflex.core.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yanglei
|
||||||
|
* @since 2025-12-23 16:53
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface EbikeReportRecordService extends IService<EbikeReportRecord> {
|
||||||
|
|
||||||
|
void saveReportRecord(EbikeReportRecordDto reportRecordDto);
|
||||||
|
}
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
package com.cdzy.user.service.impl;
|
||||||
|
|
||||||
|
import com.cdzy.common.enums.GlobalConstants;
|
||||||
|
import com.cdzy.user.mapper.EbikeReportRecordFileMapper;
|
||||||
|
import com.cdzy.user.mapper.EbikeReportRecordMapper;
|
||||||
|
import com.cdzy.user.model.dto.EbikeFaultFileDto;
|
||||||
|
import com.cdzy.user.model.dto.EbikeReportRecordDto;
|
||||||
|
import com.cdzy.user.model.dto.EbikeReportRecordFileDto;
|
||||||
|
import com.cdzy.user.model.entity.EbikeFaultFile;
|
||||||
|
import com.cdzy.user.model.entity.EbikeReportRecord;
|
||||||
|
import com.cdzy.user.model.entity.EbikeReportRecordFile;
|
||||||
|
import com.cdzy.user.service.EbikeReportRecordService;
|
||||||
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yanglei
|
||||||
|
* @since 2025-12-23 16:53
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class EbikeReportRecordServiceImpl extends ServiceImpl<EbikeReportRecordMapper, EbikeReportRecord> implements EbikeReportRecordService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EbikeReportRecordFileMapper reportRecordFileMapper;
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public void saveReportRecord(EbikeReportRecordDto reportRecordDto) {
|
||||||
|
EbikeReportRecord ebikeReportRecord = EbikeReportRecord.builder()
|
||||||
|
.location(reportRecordDto.getLocation())
|
||||||
|
.recordStatus(GlobalConstants.NUMBER_ZERO)
|
||||||
|
.createBy(reportRecordDto.getUserId())
|
||||||
|
.build();
|
||||||
|
this.save(ebikeReportRecord);
|
||||||
|
Long recordId = ebikeReportRecord.getRecordId();
|
||||||
|
List<EbikeReportRecordFileDto> recordFiles = reportRecordDto.getRecordFiles();
|
||||||
|
if (Objects.nonNull(recordFiles)) {
|
||||||
|
List<EbikeReportRecordFile> fileEntities = recordFiles.stream()
|
||||||
|
.map(dto -> EbikeReportRecordFile.builder()
|
||||||
|
.recordId(recordId)
|
||||||
|
.fileName(dto.getFileName())
|
||||||
|
.fileUrl(dto.getFileUrl())
|
||||||
|
.createBy(reportRecordDto.getUserId())
|
||||||
|
.build())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
reportRecordFileMapper.insertBatch(fileEntities);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user