Compare commits

...

9 Commits

18 changed files with 323 additions and 31 deletions

View File

@ -19,7 +19,7 @@ import java.util.List;
* @since 2025-12-30 * @since 2025-12-30
*/ */
@Data @Data
@TableName("mp_activity_info_collection") @TableName(value = "mp_activity_info_collection", autoResultMap = true)
@Schema(name = "MpActivityInfoCollectionEntity对象", description = "活动信息收集表") @Schema(name = "MpActivityInfoCollectionEntity对象", description = "活动信息收集表")
public class MpActivityInfoCollectionEntity extends BaseEntity { public class MpActivityInfoCollectionEntity extends BaseEntity {

View File

@ -0,0 +1,63 @@
package com.seer.teach.mp.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.seer.teach.common.entity.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDate;
/**
* <p>
*
* </p>
*
* @author 嘉多宝宝
* @since 2026-01-17
*/
@Getter
@Setter
@TableName("mp_test_child_character")
@Schema(name = "MpTestChildCharacterEntity对象", description = "测试孩子性格")
public class MpTestChildCharacterEntity extends BaseEntity {
@TableField("parent_id")
@Schema(description = "家长ID")
private Integer parentId;
@TableField("grade")
@Schema(description = "年级")
private String grade;
@TableField("constellation")
@Schema(description = "星座")
private String constellation;
@TableField("child_birth_date")
@Schema(description = "出生年月")
private LocalDate childBirthDate;
@TableField("child_gender")
@Schema(description = "孩子性别(男,女)")
private String childGender;
@TableField("character_analysis")
@Schema(description = "性格分析结果")
private String characterAnalysis;
@TableField("character_traits")
@Schema(description = "性格特征")
private String characterTraits;
@TableField("suggestions")
@Schema(description = "建议")
private String suggestions;
@TableField("character_type")
@Schema(description = "性格类型")
private String characterType;
}

View File

@ -0,0 +1,16 @@
package com.seer.teach.mp.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.seer.teach.mp.entity.MpTestChildCharacterEntity;
/**
* <p>
* Mapper 接口
* </p>
*
* @author 嘉多宝宝
* @since 2026-01-17
*/
public interface MpTestChildCharacterMapper extends BaseMapper<MpTestChildCharacterEntity> {
}

View File

@ -0,0 +1,5 @@
<?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="com.seer.teach.mp.mapper.MpTestChildCharacterMapper">
</mapper>

View File

@ -63,7 +63,8 @@ public class AdminAgentEmployeeRelationController {
@Operation(summary = "根据代理商ID获取员工列表") @Operation(summary = "根据代理商ID获取员工列表")
@GetMapping("/by-agent/{agentId}") @GetMapping("/by-agent/{agentId}")
@SaCheckPermission("mp:admin:agent:employee:by-agent") @SaCheckPermission("mp:admin:agent:employee:by-agent")
public ResultBean<java.util.List<AgentEmployeeRelationResp>> getByAgent(@PathVariable Integer agentId) { public ResultBean<PageListBean<AgentEmployeeRelationResp>> getByAgent(@PathVariable Integer agentId,
return ResultBean.success(agentEmployeeRelationService.getEmployeeRelationsByAgentId(agentId)); @RequestBody @Validated AgentEmployeeRelationQueryReq query) {
return ResultBean.success(agentEmployeeRelationService.getEmployeeRelationsByAgentId(agentId, query));
} }
} }

View File

@ -8,9 +8,6 @@ import lombok.Data;
@Data @Data
public class AgentEmployeeRelationQueryReq extends PageRequest { public class AgentEmployeeRelationQueryReq extends PageRequest {
@Schema(description = "代理商名称")
private String agentName;
@Schema(description = "员工名称") @Schema(description = "员工名称")
private String employeeName; private String employeeName;

View File

@ -1,12 +1,10 @@
package com.seer.teach.mp.admin.service; package com.seer.teach.mp.admin.service;
import com.seer.teach.common.PageListBean; import com.seer.teach.common.PageListBean;
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationQueryReq;
import com.seer.teach.mp.admin.controller.req.AgentEmployeeSaveReq; import com.seer.teach.mp.admin.controller.req.AgentEmployeeSaveReq;
import com.seer.teach.mp.admin.controller.req.AgentEmployeeUpdateReq; import com.seer.teach.mp.admin.controller.req.AgentEmployeeUpdateReq;
import com.seer.teach.mp.admin.controller.resp.AgentEmployeeRelationResp; import com.seer.teach.mp.admin.controller.resp.AgentEmployeeRelationResp;
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationQueryReq;
import java.util.List;
/** /**
* <p> * <p>
@ -56,7 +54,7 @@ public interface IAdminAgentEmployeeRelationService {
* @param agentId 代理商ID * @param agentId 代理商ID
* @return 员工关联列表 * @return 员工关联列表
*/ */
List<AgentEmployeeRelationResp> getEmployeeRelationsByAgentId(Integer agentId); PageListBean<AgentEmployeeRelationResp> getEmployeeRelationsByAgentId(Integer agentId,AgentEmployeeRelationQueryReq query);
/** /**
* 新增代理商员工关联管理端 * 新增代理商员工关联管理端

View File

@ -22,7 +22,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects; import java.util.Objects;
/** /**
@ -48,7 +47,6 @@ public class AdminAgentEmployeeRelationServiceImpl implements IAdminAgentEmploye
public PageListBean<AgentEmployeeRelationResp> pageList(AgentEmployeeRelationQueryReq query) { public PageListBean<AgentEmployeeRelationResp> pageList(AgentEmployeeRelationQueryReq query) {
Page<MpAgentEmployeeRelationEntity> pageParm = new Page<>(query.getPageNo(), query.getPageSize()); Page<MpAgentEmployeeRelationEntity> pageParm = new Page<>(query.getPageNo(), query.getPageSize());
var pageResult = agentEmployeeRelationService.page(pageParm, new LambdaQueryWrapper<>(MpAgentEmployeeRelationEntity.class) var pageResult = agentEmployeeRelationService.page(pageParm, new LambdaQueryWrapper<>(MpAgentEmployeeRelationEntity.class)
.like(Objects.nonNull(query.getAgentName()), MpAgentEmployeeRelationEntity::getAgentName, query.getAgentName())
.like(Objects.nonNull(query.getEmployeeName()), MpAgentEmployeeRelationEntity::getEmployeeName, query.getEmployeeName()) .like(Objects.nonNull(query.getEmployeeName()), MpAgentEmployeeRelationEntity::getEmployeeName, query.getEmployeeName())
.eq(Objects.nonNull(query.getStatus()), MpAgentEmployeeRelationEntity::getStatus, query.getStatus())); .eq(Objects.nonNull(query.getStatus()), MpAgentEmployeeRelationEntity::getStatus, query.getStatus()));
@ -97,11 +95,14 @@ public class AdminAgentEmployeeRelationServiceImpl implements IAdminAgentEmploye
} }
@Override @Override
public List<AgentEmployeeRelationResp> getEmployeeRelationsByAgentId(Integer agentId) { public PageListBean<AgentEmployeeRelationResp> getEmployeeRelationsByAgentId(Integer agentId,AgentEmployeeRelationQueryReq query) {
var relations = agentEmployeeRelationService.getEmployeeRelationsByAgentId(agentId); Page<MpAgentEmployeeRelationEntity> page = new Page<>(query.getPageNo(), query.getPageSize());
return relations.stream() LambdaQueryWrapper<MpAgentEmployeeRelationEntity> wrapper = new LambdaQueryWrapper<>();
.map(AdminAgentEmployeeRelationConvert.INSTANCE::convertToResp) wrapper.eq(MpAgentEmployeeRelationEntity::getAgentId, agentId)
.toList(); .like(Objects.nonNull(query.getEmployeeName()), MpAgentEmployeeRelationEntity::getEmployeeName, query.getEmployeeName())
.eq(Objects.nonNull(query.getStatus()), MpAgentEmployeeRelationEntity::getStatus, query.getStatus());
Page<MpAgentEmployeeRelationEntity> pageParm = agentEmployeeRelationService.page(page, wrapper);
return PageConverterUtils.convertPageListBean(pageParm, AdminAgentEmployeeRelationConvert.INSTANCE::convertToRespList);
} }
@Override @Override

View File

@ -0,0 +1,24 @@
--
DROP TABLE IF EXISTS `mp_test_child_character`;
CREATE TABLE `mp_test_child_character`(
`id` int NOT NULL AUTO_INCREMENT,
`parent_id` int NULL DEFAULT NULL COMMENT '家长Id',
`grade` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '年级',
`constellation` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '星座',
`child_birth_date` date NULL DEFAULT NULL COMMENT '出生年月',
`child_gender` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '孩子性别(男,女)',
`character_analysis` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '性格分析结果',
`character_traits` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '性格特征',
`suggestions` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '建议',
`character_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '性格类型',
`deleted` int NOT NULL COMMENT '逻辑删除(0-正常1-已删除)',
`create_time` datetime NOT NULL COMMENT '创建时间',
`create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
`update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
`update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
`tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '租户Id',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_german2_ci ROW_FORMAT = Dynamic;
SET
FOREIGN_KEY_CHECKS = 1;

View File

@ -5,6 +5,7 @@ import cn.dev33.satoken.stp.StpUtil;
import com.seer.teach.common.ResultBean; import com.seer.teach.common.ResultBean;
import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq; import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq;
import com.seer.teach.mp.app.controller.req.TestChildCharacterReq; import com.seer.teach.mp.app.controller.req.TestChildCharacterReq;
import com.seer.teach.mp.app.controller.resp.AppChildCharacterResp;
import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp; import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp;
import com.seer.teach.mp.app.controller.resp.TestChildCharacterResp; import com.seer.teach.mp.app.controller.resp.TestChildCharacterResp;
import com.seer.teach.mp.app.service.AppParentAgentActivityService; import com.seer.teach.mp.app.service.AppParentAgentActivityService;
@ -13,13 +14,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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;
/** /**
* 家长参与代理商活动控制器 - 应用端 * 家长参与代理商活动控制器 - 应用端
@ -66,9 +61,17 @@ public class AppParentAgentActivityController {
@PostMapping("/test-child-character") @PostMapping("/test-child-character")
@SaCheckLogin @SaCheckLogin
@Operation(summary = "测试孩子性格") @Operation(summary = "AI测试孩子性格")
public ResultBean<TestChildCharacterResp> testChildCharacter(@RequestBody @Valid TestChildCharacterReq request) { public ResultBean<TestChildCharacterResp> testChildCharacter(@RequestBody @Valid TestChildCharacterReq request) {
Integer parentId = StpUtil.getLoginIdAsInt(); Integer parentId = StpUtil.getLoginIdAsInt();
return ResultBean.success(appParentAgentActivityService.testChildCharacter(request, parentId)); return ResultBean.success(appParentAgentActivityService.testChildCharacter(request, parentId));
} }
@GetMapping("/get-child-character")
@SaCheckLogin
@Operation(summary = "获取AI测试性格报告")
public ResultBean<AppChildCharacterResp> getChildCharacter() {
Integer parentId = StpUtil.getLoginIdAsInt();
return ResultBean.success(appParentAgentActivityService.getChildCharacter(parentId));
}
} }

View File

@ -1,9 +1,9 @@
package com.seer.teach.mp.app.controller.req; package com.seer.teach.mp.app.controller.req;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDate; import java.time.LocalDate;
@Schema(description = "测试孩子性格请求对象") @Schema(description = "测试孩子性格请求对象")

View File

@ -0,0 +1,35 @@
package com.seer.teach.mp.app.controller.resp;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDate;
@Schema(description = "孩子性格响应对象")
@Data
public class AppChildCharacterResp {
@Schema(description = "性格分析结果")
private String characterAnalysis;
@Schema(description = "性格特征")
private String characterTraits;
@Schema(description = "建议")
private String suggestions;
@Schema(description = "性格类型")
private String characterType;
@Schema(description = "年级")
private String grade;
@Schema(description = "星座")
private String constellation;
@Schema(description = "出生年月")
private LocalDate childBirthDate;
@Schema(description = "孩子性别(男,女)")
private String childGender;
}

View File

@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.List;
@Schema(name = "AppMpSignUpActivityResp", description = "家长报名参加代理商活动信息Resp") @Schema(name = "AppMpSignUpActivityResp", description = "家长报名参加代理商活动信息Resp")
@Data @Data
@ -54,6 +55,12 @@ public class AppMpSignUpActivityResp {
@Schema(description = "薄弱科目") @Schema(description = "薄弱科目")
private String weakSubject; private String weakSubject;
@Schema(description = "薄弱科目")
private List<Integer> weakSubjectIds;
@Schema(description = "优势科目")
private List<Integer> strongSubjectIds;
@Schema(description = "代理商拨打电话联系家长的次数") @Schema(description = "代理商拨打电话联系家长的次数")
private Integer contactCallCount; private Integer contactCallCount;
} }

View File

@ -18,4 +18,7 @@ public class TestChildCharacterResp {
@Schema(description = "性格类型") @Schema(description = "性格类型")
private String characterType; private String characterType;
@Schema(description = "星座")
private String constellation;
} }

View File

@ -1,8 +1,10 @@
package com.seer.teach.mp.app.convert; package com.seer.teach.mp.app.convert;
import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq; import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq;
import com.seer.teach.mp.app.controller.resp.AppChildCharacterResp;
import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp; import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp;
import com.seer.teach.mp.entity.MpActivityInfoCollectionEntity; import com.seer.teach.mp.entity.MpActivityInfoCollectionEntity;
import com.seer.teach.mp.entity.MpTestChildCharacterEntity;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@ -19,6 +21,8 @@ public interface AppMpActivityInfoCollectionConvert {
*/ */
@Mapping(source = "mobile", target = "mobile") @Mapping(source = "mobile", target = "mobile")
@Mapping(source = "contactCallCount", target = "contactCallCount") @Mapping(source = "contactCallCount", target = "contactCallCount")
@Mapping(source = "weakSubjectIds", target = "weakSubjectIds")
@Mapping(source = "strongSubjectIds", target = "strongSubjectIds")
AppMpSignUpActivityResp convert2Resp(MpActivityInfoCollectionEntity entity); AppMpSignUpActivityResp convert2Resp(MpActivityInfoCollectionEntity entity);
@ -28,4 +32,7 @@ public interface AppMpActivityInfoCollectionConvert {
* @return 实体 * @return 实体
*/ */
MpActivityInfoCollectionEntity convertOne2Entity(AppMpSignUpActivityReq request); MpActivityInfoCollectionEntity convertOne2Entity(AppMpSignUpActivityReq request);
AppChildCharacterResp convert2ChildCharacterResp(MpTestChildCharacterEntity entity);
} }

View File

@ -5,6 +5,7 @@ import com.seer.teach.common.enums.ResultCodeEnum;
import com.seer.teach.common.utils.AssertUtils; import com.seer.teach.common.utils.AssertUtils;
import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq; import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq;
import com.seer.teach.mp.app.controller.req.TestChildCharacterReq; import com.seer.teach.mp.app.controller.req.TestChildCharacterReq;
import com.seer.teach.mp.app.controller.resp.AppChildCharacterResp;
import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp; import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp;
import com.seer.teach.mp.app.controller.resp.TestChildCharacterResp; import com.seer.teach.mp.app.controller.resp.TestChildCharacterResp;
import com.seer.teach.mp.app.convert.AppMpActivityInfoCollectionConvert; import com.seer.teach.mp.app.convert.AppMpActivityInfoCollectionConvert;
@ -37,6 +38,8 @@ public class AppParentAgentActivityService implements IAppParentAgentActivitySer
private final AiModelCallService aiModelCallService; private final AiModelCallService aiModelCallService;
private final IMpTestChildCharacterService mpTestChildCharacterService;
/** /**
* 报名活动 * 报名活动
* *
@ -111,25 +114,60 @@ public class AppParentAgentActivityService implements IAppParentAgentActivitySer
entity.setLearningSituation(request.getLearningSituation()); entity.setLearningSituation(request.getLearningSituation());
entity.setWeakSubjectIds(request.getWeakSubjectIds()); entity.setWeakSubjectIds(request.getWeakSubjectIds());
entity.setStrongSubjectIds(request.getStrongSubjectIds()); entity.setStrongSubjectIds(request.getStrongSubjectIds());
return activityInfoCollectionService.updateById(entity); boolean updateResult = activityInfoCollectionService.updateById(entity);
if (updateResult) {
// 查询性格测试记录如果存在则删除
MpTestChildCharacterEntity characterEntity = mpTestChildCharacterService
.lambdaQuery()
.eq(MpTestChildCharacterEntity::getParentId, parentId)
.orderByDesc(MpTestChildCharacterEntity::getCreateTime)
.last("LIMIT 1")
.one();
if (characterEntity != null) {
// 如果存在性格测试记录则删除
boolean removeResult = mpTestChildCharacterService.removeById(characterEntity.getId());
log.info("删除AI测试结果: {}", removeResult);
} else {
log.info("未找到家长 {} 的性格测试记录,无需删除", parentId);
}
}
return updateResult;
} }
/** /**
* 取消报名 * 取消报名
* *
* @param id 报名ID * @param id 报名ID
* @param parentId 家长ID * @param parentId 家长ID
* @return true表示成功false表示失败 * @return true表示成功false表示失败
*/ */
@Transactional(rollbackFor = Exception.class, timeout = 120) @Transactional(rollbackFor = Exception.class, timeout = 120)
public boolean cancelSignUp(Integer id, Integer parentId) { public boolean cancelSignUp(Integer id, Integer parentId) {
MpActivityInfoCollectionEntity entity = activityInfoCollectionService.getById(id); MpActivityInfoCollectionEntity entity = activityInfoCollectionService.getById(id);
if (entity == null) { if (entity == null) {
return false; return false;
} }
boolean activityResult = activityInfoCollectionService.removeById(entity); boolean activityResult = activityInfoCollectionService.removeById(entity);
if (activityResult) { if (activityResult) {
Integer relationId = entity.getRelationId(); Integer relationId = entity.getRelationId();
// 查询性格测试记录如果存在则删除
MpTestChildCharacterEntity characterEntity = mpTestChildCharacterService
.lambdaQuery()
.eq(MpTestChildCharacterEntity::getParentId, parentId)
.orderByDesc(MpTestChildCharacterEntity::getCreateTime)
.last("LIMIT 1")
.one();
if (characterEntity != null) {
// 如果存在性格测试记录则删除
boolean removeResult = mpTestChildCharacterService.removeById(characterEntity.getId());
log.info("删除AI测试结果: {}", removeResult);
} else {
log.info("未找到家长 {} 的性格测试记录,无需删除", parentId);
}
return parentAgentActivityRelationService.removeById(relationId); return parentAgentActivityRelationService.removeById(relationId);
} }
return false; return false;
@ -181,6 +219,34 @@ public class AppParentAgentActivityService implements IAppParentAgentActivitySer
// 获取AI返回的内容 // 获取AI返回的内容
String content = response.getChoices().get(0).getMessage().getContent(); String content = response.getChoices().get(0).getMessage().getContent();
result = parseAiResponse(content); result = parseAiResponse(content);
result.setConstellation(request.getConstellation());
// 先查询该家长是否已有性格测试记录有则更新无则新增
MpTestChildCharacterEntity existingEntity = mpTestChildCharacterService
.lambdaQuery()
.eq(MpTestChildCharacterEntity::getParentId, parentId)
.orderByDesc(MpTestChildCharacterEntity::getCreateTime)
.last("LIMIT 1")
.one();
// 如果AI调用成功则将测试结果保存到数据库中
MpTestChildCharacterEntity entity = getCharacterEntity(request, parentId, result);
boolean saveOrUpdateResult;
if (existingEntity != null) {
// 如果存在记录则更新
entity.setId(existingEntity.getId());
saveOrUpdateResult = mpTestChildCharacterService.updateById(entity);
log.info("更新性格测试结果成功家长ID: {}", parentId);
} else {
// 如果不存在记录则新增
saveOrUpdateResult = mpTestChildCharacterService.save(entity);
log.info("保存性格测试结果成功家长ID: {}", parentId);
}
if (!saveOrUpdateResult) {
log.error("保存或更新性格测试结果失败家长ID: {}", parentId);
}
} else { } else {
// 如果AI调用失败返回默认响应 // 如果AI调用失败返回默认响应
result.setCharacterAnalysis("暂时无法分析孩子的性格,请稍后重试。"); result.setCharacterAnalysis("暂时无法分析孩子的性格,请稍后重试。");
@ -193,6 +259,20 @@ public class AppParentAgentActivityService implements IAppParentAgentActivitySer
return result; return result;
} }
private MpTestChildCharacterEntity getCharacterEntity(TestChildCharacterReq request, Integer parentId, TestChildCharacterResp result) {
MpTestChildCharacterEntity entity = new MpTestChildCharacterEntity();
entity.setParentId(parentId);
entity.setConstellation(request.getConstellation());
entity.setGrade(request.getGrade());
entity.setChildBirthDate(request.getChildBirthDate());
entity.setChildGender(request.getChildGender());
entity.setCharacterType(result.getCharacterType());
entity.setCharacterAnalysis(result.getCharacterAnalysis());
entity.setCharacterTraits(result.getCharacterTraits());
entity.setSuggestions(result.getSuggestions());
return entity;
}
/** /**
* 构建性格测试的提示词 * 构建性格测试的提示词
* *
@ -281,5 +361,21 @@ public class AppParentAgentActivityService implements IAppParentAgentActivitySer
} }
/**
* 获取孩子性格返回结果
*
* @param parentId 家长ID
* @return 孩子性格返回结果
*/
public AppChildCharacterResp getChildCharacter(Integer parentId) {
MpTestChildCharacterEntity one = mpTestChildCharacterService.lambdaQuery()
.eq(MpTestChildCharacterEntity::getParentId, parentId)
.orderByDesc(MpTestChildCharacterEntity::getCreateTime)
.last("limit 1") // 获取最新的一条数据
.one();
if (one == null) {
return new AppChildCharacterResp();
}
return AppMpActivityInfoCollectionConvert.INSTANCE.convert2ChildCharacterResp(one);
}
} }

View File

@ -0,0 +1,16 @@
package com.seer.teach.mp.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.seer.teach.mp.entity.MpTestChildCharacterEntity;
/**
* <p>
* 服务类
* </p>
*
* @author 嘉多宝宝
* @since 2026-01-17
*/
public interface IMpTestChildCharacterService extends IService<MpTestChildCharacterEntity> {
}

View File

@ -0,0 +1,20 @@
package com.seer.teach.mp.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.seer.teach.mp.entity.MpTestChildCharacterEntity;
import com.seer.teach.mp.mapper.MpTestChildCharacterMapper;
import com.seer.teach.mp.service.IMpTestChildCharacterService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author 嘉多宝宝
* @since 2026-01-17
*/
@Service
public class MpTestChildCharacterServiceImpl extends ServiceImpl<MpTestChildCharacterMapper, MpTestChildCharacterEntity> implements IMpTestChildCharacterService {
}