10 changed files with 522 additions and 0 deletions
@ -0,0 +1,89 @@ |
|||
package cn.iocoder.yudao.module.interphone.controller.admin.recordaudio; |
|||
|
|||
import org.springframework.web.bind.annotation.*; |
|||
import jakarta.annotation.Resource; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.security.access.prepost.PreAuthorize; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import io.swagger.v3.oas.annotations.Parameter; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
|
|||
import jakarta.validation.constraints.*; |
|||
import jakarta.validation.*; |
|||
import jakarta.servlet.http.*; |
|||
import java.util.*; |
|||
import java.io.IOException; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
|||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
|||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
|||
|
|||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; |
|||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; |
|||
|
|||
import cn.iocoder.yudao.module.interphone.controller.admin.recordaudio.vo.*; |
|||
import cn.iocoder.yudao.module.interphone.dal.dataobject.recordaudio.RecordAudioDO; |
|||
import cn.iocoder.yudao.module.interphone.service.recordaudio.RecordAudioService; |
|||
|
|||
@Tag(name = "管理后台 - 实时录音记录") |
|||
@RestController |
|||
@RequestMapping("/interphone/record-audio") |
|||
@Validated |
|||
public class RecordAudioController { |
|||
|
|||
@Resource |
|||
private RecordAudioService recordAudioService; |
|||
|
|||
@PostMapping("/create") |
|||
@Operation(summary = "创建实时录音记录") |
|||
@PreAuthorize("@ss.hasPermission('interphone:record-audio:create')") |
|||
public CommonResult<Long> createRecordAudio(@Valid @RequestBody RecordAudioSaveReqVO createReqVO) { |
|||
return success(recordAudioService.createRecordAudio(createReqVO)); |
|||
} |
|||
|
|||
@PutMapping("/update") |
|||
@Operation(summary = "更新实时录音记录") |
|||
@PreAuthorize("@ss.hasPermission('interphone:record-audio:update')") |
|||
public CommonResult<Boolean> updateRecordAudio(@Valid @RequestBody RecordAudioSaveReqVO updateReqVO) { |
|||
recordAudioService.updateRecordAudio(updateReqVO); |
|||
return success(true); |
|||
} |
|||
|
|||
@DeleteMapping("/delete") |
|||
@Operation(summary = "删除实时录音记录") |
|||
@Parameter(name = "id", description = "编号", required = true) |
|||
@PreAuthorize("@ss.hasPermission('interphone:record-audio:delete')") |
|||
public CommonResult<Boolean> deleteRecordAudio(@RequestParam("id") Long id) { |
|||
recordAudioService.deleteRecordAudio(id); |
|||
return success(true); |
|||
} |
|||
|
|||
@DeleteMapping("/delete-list") |
|||
@Parameter(name = "ids", description = "编号", required = true) |
|||
@Operation(summary = "批量删除实时录音记录") |
|||
@PreAuthorize("@ss.hasPermission('interphone:record-audio:delete')") |
|||
public CommonResult<Boolean> deleteRecordAudioList(@RequestParam("ids") List<Long> ids) { |
|||
recordAudioService.deleteRecordAudioListByIds(ids); |
|||
return success(true); |
|||
} |
|||
|
|||
@GetMapping("/get") |
|||
@Operation(summary = "获得实时录音记录") |
|||
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
|||
@PreAuthorize("@ss.hasPermission('interphone:record-audio:query')") |
|||
public CommonResult<RecordAudioRespVO> getRecordAudio(@RequestParam("id") Long id) { |
|||
RecordAudioDO recordAudio = recordAudioService.getRecordAudio(id); |
|||
return success(BeanUtils.toBean(recordAudio, RecordAudioRespVO.class)); |
|||
} |
|||
|
|||
@GetMapping("/page") |
|||
@Operation(summary = "获得实时录音记录分页") |
|||
@PreAuthorize("@ss.hasPermission('interphone:record-audio:query')") |
|||
public CommonResult<PageResult<RecordAudioRespVO>> getRecordAudioPage(@Valid RecordAudioPageReqVO pageReqVO) { |
|||
PageResult<RecordAudioDO> pageResult = recordAudioService.getRecordAudioPage(pageReqVO); |
|||
return success(BeanUtils.toBean(pageResult, RecordAudioRespVO.class)); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,66 @@ |
|||
package cn.iocoder.yudao.module.interphone.controller.admin.recordaudio.vo; |
|||
|
|||
import lombok.*; |
|||
import java.util.*; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
import java.time.LocalDateTime; |
|||
|
|||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
|||
|
|||
@Schema(description = "管理后台 - 实时录音记录分页 Request VO") |
|||
@Data |
|||
public class RecordAudioPageReqVO extends PageParam { |
|||
|
|||
@Schema(description = "第三方录音ID", example = "29527") |
|||
private String thirdId; |
|||
|
|||
@Schema(description = "终端ID", example = "13888") |
|||
private Integer tId; |
|||
|
|||
@Schema(description = "用户ID", example = "5926") |
|||
private Long userId; |
|||
|
|||
@Schema(description = "用户名", example = "芋艿") |
|||
private String userName; |
|||
|
|||
@Schema(description = "群组ID", example = "4378") |
|||
private Long groupId; |
|||
|
|||
@Schema(description = "群组名称", example = "张三") |
|||
private String groupName; |
|||
|
|||
@Schema(description = "群组类型", example = "2") |
|||
private Integer groupType; |
|||
|
|||
@Schema(description = "组织ID", example = "12968") |
|||
private Long orgId; |
|||
|
|||
@Schema(description = "录音时长毫秒") |
|||
private Integer durationMs; |
|||
|
|||
@Schema(description = "音频路径") |
|||
private String audioPath; |
|||
|
|||
@Schema(description = "完整音频OSS URL", example = "https://www.iocoder.cn") |
|||
private String audioOssUrl; |
|||
|
|||
@Schema(description = "编码格式") |
|||
private String codeFormat; |
|||
|
|||
@Schema(description = "录音时间") |
|||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
|||
private LocalDateTime[] audioTime; |
|||
|
|||
@Schema(description = "ASR状态 0未处理 1处理中 2完成 3失败", example = "2") |
|||
private Integer asrStatus; |
|||
|
|||
@Schema(description = "语音识别结果") |
|||
private String asrText; |
|||
|
|||
@Schema(description = "创建时间") |
|||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
|||
private LocalDateTime[] createTime; |
|||
|
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
package cn.iocoder.yudao.module.interphone.controller.admin.recordaudio.vo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.*; |
|||
import java.util.*; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
import java.time.LocalDateTime; |
|||
import com.alibaba.excel.annotation.*; |
|||
|
|||
@Schema(description = "管理后台 - 实时录音记录 Response VO") |
|||
@Data |
|||
@ExcelIgnoreUnannotated |
|||
public class RecordAudioRespVO { |
|||
|
|||
@Schema(description = "用户名", example = "芋艿") |
|||
@ExcelProperty("用户名") |
|||
private String userName; |
|||
|
|||
@Schema(description = "群组名称", example = "张三") |
|||
@ExcelProperty("群组名称") |
|||
private String groupName; |
|||
|
|||
@Schema(description = "群组类型", example = "2") |
|||
@ExcelProperty("群组类型") |
|||
private Integer groupType; |
|||
|
|||
@Schema(description = "录音时长毫秒") |
|||
@ExcelProperty("录音时长毫秒") |
|||
private Integer durationMs; |
|||
|
|||
@Schema(description = "音频路径") |
|||
@ExcelProperty("音频路径") |
|||
private String audioPath; |
|||
|
|||
@Schema(description = "完整音频OSS URL", example = "https://www.iocoder.cn") |
|||
@ExcelProperty("完整音频OSS URL") |
|||
private String audioOssUrl; |
|||
|
|||
@Schema(description = "编码格式") |
|||
@ExcelProperty("编码格式") |
|||
private String codeFormat; |
|||
|
|||
@Schema(description = "录音时间") |
|||
@ExcelProperty("录音时间") |
|||
private LocalDateTime audioTime; |
|||
|
|||
@Schema(description = "ASR状态 0未处理 1处理中 2完成 3失败", example = "2") |
|||
@ExcelProperty("ASR状态 0未处理 1处理中 2完成 3失败") |
|||
private Integer asrStatus; |
|||
|
|||
@Schema(description = "语音识别结果") |
|||
@ExcelProperty("语音识别结果") |
|||
private String asrText; |
|||
|
|||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
|||
@ExcelProperty("创建时间") |
|||
private LocalDateTime createTime; |
|||
|
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
package cn.iocoder.yudao.module.interphone.controller.admin.recordaudio.vo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.*; |
|||
import java.util.*; |
|||
import jakarta.validation.constraints.*; |
|||
|
|||
@Schema(description = "管理后台 - 实时录音记录新增/修改 Request VO") |
|||
@Data |
|||
public class RecordAudioSaveReqVO { |
|||
|
|||
} |
|||
@ -0,0 +1,93 @@ |
|||
package cn.iocoder.yudao.module.interphone.dal.dataobject.recordaudio; |
|||
|
|||
import lombok.*; |
|||
import java.util.*; |
|||
import java.time.LocalDateTime; |
|||
import java.time.LocalDateTime; |
|||
import java.time.LocalDateTime; |
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
|||
|
|||
/** |
|||
* 实时录音记录 DO |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@TableName("interphone_record_audio") |
|||
@KeySequence("interphone_record_audio_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@ToString(callSuper = true) |
|||
@Builder |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class RecordAudioDO extends BaseDO { |
|||
|
|||
/** |
|||
* 本地ID |
|||
*/ |
|||
@TableId |
|||
private Long id; |
|||
/** |
|||
* 第三方录音ID |
|||
*/ |
|||
private String thirdId; |
|||
/** |
|||
* 终端ID |
|||
*/ |
|||
private Integer tId; |
|||
/** |
|||
* 用户ID |
|||
*/ |
|||
private Long userId; |
|||
/** |
|||
* 用户名 |
|||
*/ |
|||
private String userName; |
|||
/** |
|||
* 群组ID |
|||
*/ |
|||
private Long groupId; |
|||
/** |
|||
* 群组名称 |
|||
*/ |
|||
private String groupName; |
|||
/** |
|||
* 群组类型 |
|||
*/ |
|||
private Integer groupType; |
|||
/** |
|||
* 组织ID |
|||
*/ |
|||
private Long orgId; |
|||
/** |
|||
* 录音时长毫秒 |
|||
*/ |
|||
private Integer durationMs; |
|||
/** |
|||
* 音频路径 |
|||
*/ |
|||
private String audioPath; |
|||
/** |
|||
* 完整音频OSS URL |
|||
*/ |
|||
private String audioOssUrl; |
|||
/** |
|||
* 编码格式 |
|||
*/ |
|||
private String codeFormat; |
|||
/** |
|||
* 录音时间 |
|||
*/ |
|||
private LocalDateTime audioTime; |
|||
/** |
|||
* ASR状态 0未处理 1处理中 2完成 3失败 |
|||
*/ |
|||
private Integer asrStatus; |
|||
/** |
|||
* 语音识别结果 |
|||
*/ |
|||
private String asrText; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
package cn.iocoder.yudao.module.interphone.dal.mysql.recordaudio; |
|||
|
|||
import java.util.*; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
|||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
|||
import cn.iocoder.yudao.module.interphone.dal.dataobject.recordaudio.RecordAudioDO; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import cn.iocoder.yudao.module.interphone.controller.admin.recordaudio.vo.*; |
|||
|
|||
/** |
|||
* 实时录音记录 Mapper |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Mapper |
|||
public interface RecordAudioMapper extends BaseMapperX<RecordAudioDO> { |
|||
|
|||
default PageResult<RecordAudioDO> selectPage(RecordAudioPageReqVO reqVO) { |
|||
return selectPage(reqVO, new LambdaQueryWrapperX<RecordAudioDO>() |
|||
.eqIfPresent(RecordAudioDO::getThirdId, reqVO.getThirdId()) |
|||
.eqIfPresent(RecordAudioDO::getTId, reqVO.getTId()) |
|||
.eqIfPresent(RecordAudioDO::getUserId, reqVO.getUserId()) |
|||
.likeIfPresent(RecordAudioDO::getUserName, reqVO.getUserName()) |
|||
.eqIfPresent(RecordAudioDO::getGroupId, reqVO.getGroupId()) |
|||
.likeIfPresent(RecordAudioDO::getGroupName, reqVO.getGroupName()) |
|||
.eqIfPresent(RecordAudioDO::getGroupType, reqVO.getGroupType()) |
|||
.eqIfPresent(RecordAudioDO::getOrgId, reqVO.getOrgId()) |
|||
.eqIfPresent(RecordAudioDO::getDurationMs, reqVO.getDurationMs()) |
|||
.eqIfPresent(RecordAudioDO::getAudioPath, reqVO.getAudioPath()) |
|||
.eqIfPresent(RecordAudioDO::getAudioOssUrl, reqVO.getAudioOssUrl()) |
|||
.eqIfPresent(RecordAudioDO::getCodeFormat, reqVO.getCodeFormat()) |
|||
.betweenIfPresent(RecordAudioDO::getAudioTime, reqVO.getAudioTime()) |
|||
.eqIfPresent(RecordAudioDO::getAsrStatus, reqVO.getAsrStatus()) |
|||
.eqIfPresent(RecordAudioDO::getAsrText, reqVO.getAsrText()) |
|||
.betweenIfPresent(RecordAudioDO::getCreateTime, reqVO.getCreateTime()) |
|||
.orderByDesc(RecordAudioDO::getId)); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
package cn.iocoder.yudao.module.interphone.enums; |
|||
|
|||
import cn.iocoder.yudao.framework.common.exception.ErrorCode; |
|||
|
|||
public interface ErrorCodeConstants { |
|||
ErrorCode RECORD_AUDIO_NOT_EXISTS = new ErrorCode(1000101, "实时录音记录不存在"); |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
package cn.iocoder.yudao.module.interphone.service.recordaudio; |
|||
|
|||
import java.util.*; |
|||
import jakarta.validation.*; |
|||
import cn.iocoder.yudao.module.interphone.controller.admin.recordaudio.vo.*; |
|||
import cn.iocoder.yudao.module.interphone.dal.dataobject.recordaudio.RecordAudioDO; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
|||
|
|||
/** |
|||
* 实时录音记录 Service 接口 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
public interface RecordAudioService { |
|||
|
|||
/** |
|||
* 创建实时录音记录 |
|||
* |
|||
* @param createReqVO 创建信息 |
|||
* @return 编号 |
|||
*/ |
|||
Long createRecordAudio(@Valid RecordAudioSaveReqVO createReqVO); |
|||
|
|||
/** |
|||
* 更新实时录音记录 |
|||
* |
|||
* @param updateReqVO 更新信息 |
|||
*/ |
|||
void updateRecordAudio(@Valid RecordAudioSaveReqVO updateReqVO); |
|||
|
|||
/** |
|||
* 删除实时录音记录 |
|||
* |
|||
* @param id 编号 |
|||
*/ |
|||
void deleteRecordAudio(Long id); |
|||
|
|||
/** |
|||
* 批量删除实时录音记录 |
|||
* |
|||
* @param ids 编号 |
|||
*/ |
|||
void deleteRecordAudioListByIds(List<Long> ids); |
|||
|
|||
/** |
|||
* 获得实时录音记录 |
|||
* |
|||
* @param id 编号 |
|||
* @return 实时录音记录 |
|||
*/ |
|||
RecordAudioDO getRecordAudio(Long id); |
|||
|
|||
/** |
|||
* 获得实时录音记录分页 |
|||
* |
|||
* @param pageReqVO 分页查询 |
|||
* @return 实时录音记录分页 |
|||
*/ |
|||
PageResult<RecordAudioDO> getRecordAudioPage(RecordAudioPageReqVO pageReqVO); |
|||
|
|||
} |
|||
@ -0,0 +1,81 @@ |
|||
package cn.iocoder.yudao.module.interphone.service.recordaudio; |
|||
|
|||
import cn.hutool.core.collection.CollUtil; |
|||
import org.springframework.stereotype.Service; |
|||
import jakarta.annotation.Resource; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.*; |
|||
import cn.iocoder.yudao.module.interphone.controller.admin.recordaudio.vo.*; |
|||
import cn.iocoder.yudao.module.interphone.dal.dataobject.recordaudio.RecordAudioDO; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
|||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
|||
|
|||
import cn.iocoder.yudao.module.interphone.dal.mysql.recordaudio.RecordAudioMapper; |
|||
|
|||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
|||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; |
|||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList; |
|||
import static cn.iocoder.yudao.module.interphone.enums.ErrorCodeConstants.*; |
|||
|
|||
/** |
|||
* 实时录音记录 Service 实现类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Service |
|||
@Validated |
|||
public class RecordAudioServiceImpl implements RecordAudioService { |
|||
|
|||
@Resource |
|||
private RecordAudioMapper recordAudioMapper; |
|||
|
|||
@Override |
|||
public Long createRecordAudio(RecordAudioSaveReqVO createReqVO) { |
|||
// 插入
|
|||
RecordAudioDO recordAudio = BeanUtils.toBean(createReqVO, RecordAudioDO.class); |
|||
recordAudioMapper.insert(recordAudio); |
|||
|
|||
// 返回
|
|||
return recordAudio.getId(); |
|||
} |
|||
|
|||
@Override |
|||
public void updateRecordAudio(RecordAudioSaveReqVO updateReqVO) { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void deleteRecordAudio(Long id) { |
|||
// 校验存在
|
|||
validateRecordAudioExists(id); |
|||
// 删除
|
|||
recordAudioMapper.deleteById(id); |
|||
} |
|||
|
|||
@Override |
|||
public void deleteRecordAudioListByIds(List<Long> ids) { |
|||
// 删除
|
|||
recordAudioMapper.deleteByIds(ids); |
|||
} |
|||
|
|||
|
|||
private void validateRecordAudioExists(Long id) { |
|||
if (recordAudioMapper.selectById(id) == null) { |
|||
throw exception(RECORD_AUDIO_NOT_EXISTS); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public RecordAudioDO getRecordAudio(Long id) { |
|||
return recordAudioMapper.selectById(id); |
|||
} |
|||
|
|||
@Override |
|||
public PageResult<RecordAudioDO> getRecordAudioPage(RecordAudioPageReqVO pageReqVO) { |
|||
return recordAudioMapper.selectPage(pageReqVO); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="cn.iocoder.yudao.module.interphone.dal.mysql.recordaudio.RecordAudioMapper"> |
|||
|
|||
<!-- |
|||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 |
|||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 |
|||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 |
|||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ |
|||
--> |
|||
|
|||
</mapper> |
|||
Loading…
Reference in new issue