feat: 优化

This commit is contained in:
2026-02-22 21:36:47 +08:00
parent 227dd4f78d
commit ff11f04b43
12 changed files with 364 additions and 134 deletions

View File

@@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.tik.muye.aiagent;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.tik.muye.aiagent.dal.AiAgentDO;
import cn.iocoder.yudao.module.tik.muye.aiagent.service.AiAgentService;
import cn.iocoder.yudao.module.tik.muye.aiagent.vo.AiAgentRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* 用户 App - AI智能体
*
* @author 芋道源码
*/
@Tag(name = "用户 App - AI智能体")
@RestController
@RequestMapping("/api/tik/agent")
@Validated
public class AppAiAgentController {
@Resource
private AiAgentService aiAgentService;
@GetMapping("/list")
@Operation(summary = "获取启用的智能体列表")
public CommonResult<List<AiAgentRespVO>> getEnabledAgentList() {
List<AiAgentDO> list = aiAgentService.getEnabledAgentList();
return success(BeanUtils.toBean(list, AiAgentRespVO.class));
}
}

View File

@@ -1,8 +1,6 @@
package cn.iocoder.yudao.module.tik.muye.aiagent.dal;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
@@ -55,6 +53,10 @@ public class AiAgentDO extends BaseDO {
* 备注
*/
private String remark;
/**
* 分类名称(中文)
*/
private String categoryName;
/**
* 操作人用户编号
*/

View File

@@ -33,4 +33,13 @@ public interface AiAgentMapper extends BaseMapperX<AiAgentDO> {
.orderByDesc(AiAgentDO::getId));
}
/**
* 查询启用状态的智能体列表
*/
default List<AiAgentDO> selectEnabledList() {
return selectList(new LambdaQueryWrapperX<AiAgentDO>()
.eq(AiAgentDO::getStatus, 1)
.orderByDesc(AiAgentDO::getId));
}
}

View File

@@ -60,4 +60,11 @@ public interface AiAgentService {
*/
PageResult<AiAgentDO> getAiAgentPage(AiAgentPageReqVO pageReqVO);
/**
* 获取启用状态的智能体列表
*
* @return 启用状态的智能体列表
*/
List<AiAgentDO> getEnabledAgentList();
}

View File

@@ -54,10 +54,9 @@ public class AiAgentServiceImpl implements AiAgentService {
}
@Override
public void deleteAiAgentListByIds(List<Long> ids) {
// 删除
public void deleteAiAgentListByIds(List<Long> ids) {
aiAgentMapper.deleteByIds(ids);
}
}
private void validateAiAgentExists(Long id) {
@@ -76,4 +75,9 @@ public class AiAgentServiceImpl implements AiAgentService {
return aiAgentMapper.selectPage(pageReqVO);
}
@Override
public List<AiAgentDO> getEnabledAgentList() {
return aiAgentMapper.selectEnabledList();
}
}

View File

@@ -44,6 +44,10 @@ public class AiAgentRespVO {
@ExcelProperty("备注")
private String remark;
@Schema(description = "分类名称(中文)", example = "文案创作")
@ExcelProperty("分类名称")
private String categoryName;
@Schema(description = "操作人用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6593")
@ExcelProperty("操作人用户编号")
private Long operatorId;

View File

@@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.tik.muye.aiagent.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import jakarta.validation.constraints.*;
@Schema(description = "管理后台 - AI智能体新增/修改 Request VO")
@@ -36,10 +35,12 @@ public class AiAgentSaveReqVO {
@NotEmpty(message = "预置提示词不能为空")
private String systemPrompt;
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对")
@NotEmpty(message = "备注不能为空")
@Schema(description = "备注", example = "你说的对")
private String remark;
@Schema(description = "分类名称(中文)", example = "文案创作")
private String categoryName;
@Schema(description = "操作人用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6593")
@NotNull(message = "操作人用户编号不能为空")
private Long operatorId;

View File

@@ -36,7 +36,7 @@ public interface PointRecordMapper extends BaseMapperX<PointRecordDO> {
/**
* 取消过期的预扣记录30分钟前
*/
@Update("UPDATE muey_point_record SET status = 'canceled', update_time = NOW() " +
@Update("UPDATE muye_point_record SET status = 'canceled', update_time = NOW() " +
"WHERE status = 'pending' AND create_time < DATE_SUB(NOW(), INTERVAL 30 MINUTE)")
int cancelExpiredPendingRecords();