/*
|
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
*
|
* Redistribution and use in source and binary forms, with or without
|
* modification, are permitted provided that the following conditions are met:
|
*
|
* Redistributions of source code must retain the above copyright notice,
|
* this list of conditions and the following disclaimer.
|
* Redistributions in binary form must reproduce the above copyright
|
* notice, this list of conditions and the following disclaimer in the
|
* documentation and/or other materials provided with the distribution.
|
* Neither the name of the dreamlu.net developer nor the names of its
|
* contributors may be used to endorse or promote products derived from
|
* this software without specific prior written permission.
|
* Author: Chill 庄骞 (smallchill@163.com)
|
*/
|
package org.sxkj.gd.airesults.service.impl;
|
|
import org.springblade.core.tool.utils.StringUtil;
|
import org.sxkj.gd.airesults.entity.GdAiResultsEntity;
|
import org.sxkj.gd.airesults.param.GdAiResultsPageParam;
|
import org.sxkj.gd.airesults.vo.GdAiResultsVO;
|
import org.sxkj.gd.airesults.excel.GdAiResultsExcel;
|
import org.sxkj.gd.airesults.mapper.GdAiResultsMapper;
|
import org.sxkj.gd.airesults.service.IGdAiResultsService;
|
import org.springframework.stereotype.Service;
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import java.util.List;
|
|
/**
|
* AI成果表 服务实现类
|
*
|
* @author lw
|
* @since 2026-02-28
|
*/
|
@Service
|
public class GdAiResultsServiceImpl extends BaseServiceImpl<GdAiResultsMapper, GdAiResultsEntity> implements IGdAiResultsService {
|
|
/**
|
* 自定义分页查询
|
*
|
* @param page 分页对象
|
* @param gdAiResults 查询参数
|
* @return AI成果分页结果
|
*/
|
@Override
|
public IPage<GdAiResultsVO> selectGdAiResultsPage(IPage<GdAiResultsVO> page, GdAiResultsPageParam gdAiResults) {
|
return page.setRecords(baseMapper.selectGdAiResultsPage(page, gdAiResults));
|
}
|
|
/**
|
* 导出数据
|
*
|
* @param queryWrapper 查询条件
|
* @return AI成果Excel列表
|
*/
|
@Override
|
public List<GdAiResultsExcel> exportGdAiResults(Wrapper<GdAiResultsEntity> queryWrapper) {
|
List<GdAiResultsExcel> gdAiResultsList = baseMapper.exportGdAiResults(queryWrapper);
|
return gdAiResultsList;
|
}
|
|
/**
|
* 新增或修改AI成果
|
*
|
* @param entity AI成果实体对象
|
* @return 保存或更新成功返回true,失败返回false
|
*/
|
@Override
|
public boolean saveOrUpdateAiResults(GdAiResultsEntity entity) {
|
// 步骤1:校验AI流请求key是否为空
|
if (StringUtil.isNotBlank(entity.getAiReqKey())) {
|
// 步骤2:查询数据库中是否存在相同AI流请求key的记录
|
Long count = baseMapper.selectCount(
|
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<GdAiResultsEntity>()
|
.eq(GdAiResultsEntity::getAiReqKey, entity.getAiReqKey())
|
.ne(entity.getId() != null, GdAiResultsEntity::getId, entity.getId())
|
);
|
// 步骤3:如果存在重复的AI流请求key,抛出异常
|
if (count > 0) {
|
throw new RuntimeException("AI流请求key已存在,请使用其他key");
|
}
|
}
|
// 步骤4:执行保存或更新操作
|
return saveOrUpdate(entity);
|
}
|
}
|