diff --git a/seer-common/common-enums/src/main/java/com/seer/teach/common/enums/ResultCodeEnum.java b/seer-common/common-enums/src/main/java/com/seer/teach/common/enums/ResultCodeEnum.java index d4444a2..aaedb35 100644 --- a/seer-common/common-enums/src/main/java/com/seer/teach/common/enums/ResultCodeEnum.java +++ b/seer-common/common-enums/src/main/java/com/seer/teach/common/enums/ResultCodeEnum.java @@ -319,7 +319,23 @@ public enum ResultCodeEnum { RICH_TEXT_TEMPLATE_CONVERT_FAILED(1100419, "转换失败"), - AI_MODEL_NOT_FOUND(12000, "未找到模型"); + AI_MODEL_NOT_FOUND(12000, "未找到模型"), + + PARENT_ALREADY_SIGNED_UP(13000, "家长已报名参加该活动"), + RELATION_NOT_FOUND(13001, "关系记录不存在"), + PARENT_NOT_SIGNED_UP(13002, "家长未报名参加该活动"), + INVALID_ACTIVITY(13003, "活动不存在或已失效"), + INVALID_AGENT(13004, "代理商不存在或已失效"), + AGENT_STATUS_INVALID(13005, "代理商状态无效"), + AGENT_NON_PARTICIPANT_ACTIVE(130061, "代理商没有参与该活动"), + AGENT_CONTACT_INFO_INVALID(13006, "联系信息无效"), + ACTIVITY_NOT_FOUND(13007, "活动不存在"), + ACTIVITY_ALREADY_EXISTS(13008, "活动已存在"), + ACTIVITY_NOT_ACTIVE(13009, "活动未开始或已结束"), + PARTICIPATION_FAILED(13010, "参与活动失败"), + PARENT_NOT_FOUND(13011, "家长不存在"), + INVALID_ACTIVITY_STATUS(13012, "无效的活动状态"), + PARENT_ALREADY_SIGN_UP(130121, "已经报名参加该活动"); private int code; private String msg; diff --git a/seer-mp/seer-mp-data-module/src/main/java/com/seer/teach/mp/entity/MpActivityInfoCollectionEntity.java b/seer-mp/seer-mp-data-module/src/main/java/com/seer/teach/mp/entity/MpActivityInfoCollectionEntity.java new file mode 100644 index 0000000..3339512 --- /dev/null +++ b/seer-mp/seer-mp-data-module/src/main/java/com/seer/teach/mp/entity/MpActivityInfoCollectionEntity.java @@ -0,0 +1,113 @@ +package com.seer.teach.mp.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.seer.teach.common.config.mybatis.hanler.IntegerListTypeHandler; +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; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Set; + +/** + *

+ * 活动信息收集表 + *

+ * + * @author Lingma + * @since 2025-12-30 + */ +@Getter +@Setter +@TableName("mp_activity_info_collection") +@Schema(name = "MpActivityInfoCollectionEntity对象", description = "活动信息收集表") +public class MpActivityInfoCollectionEntity extends BaseEntity { + + /** + * 关联的家长参与代理商活动关系ID + */ + @TableField("relation_id") + private Integer relationId; + + /** + * 活动ID + */ + @TableField("activity_id") + private Integer activityId; + + /** + * 代理商ID + */ + @TableField("agent_id") + private Integer agentId; + + /** + * 家长ID + */ + @TableField("parent_id") + private Integer parentId; + + /** + * 孩子姓名 + */ + @TableField("child_name") + private String childName; + + /** + * 孩子性别(M-男,F-女) + */ + @TableField("child_gender") + private String childGender; + + /** + * 出生年月 + */ + @TableField("child_birth_date") + private LocalDate childBirthDate; + + /** + * 年级 + */ + @TableField("grade") + private String grade; + + /** + * 学校 + */ + @TableField("school") + private String school; + + /** + * 地区 + */ + @TableField("region") + private String region; + + /** + * 家长身份(爸爸,妈妈) + */ + @TableField("parent_identity") + private String parentIdentity; + + /** + * 学习情况(优、良、中、差) + */ + @TableField("learning_situation") + private String learningSituation; + + /** + * 优势学科(数学、英语等) + */ + @TableField(value = "strong_subject_ids",typeHandler = IntegerListTypeHandler.class) + private List strongSubjectIds; + + /** + * 劣势学科(数学、英语等) + */ + @TableField(value = "weak_subject_ids",typeHandler = IntegerListTypeHandler.class) + private List weakSubjectIds; +} \ No newline at end of file diff --git a/seer-mp/seer-mp-data-module/src/main/java/com/seer/teach/mp/entity/MpParentAgentActivityRelationEntity.java b/seer-mp/seer-mp-data-module/src/main/java/com/seer/teach/mp/entity/MpParentAgentActivityRelationEntity.java new file mode 100644 index 0000000..e477fcd --- /dev/null +++ b/seer-mp/seer-mp-data-module/src/main/java/com/seer/teach/mp/entity/MpParentAgentActivityRelationEntity.java @@ -0,0 +1,68 @@ +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.LocalDateTime; + +/** + *

+ * 家长参与代理商活动关系表 + *

+ * + * @author Lingma + * @since 2025-12-30 + */ +@Getter +@Setter +@TableName("mp_parent_agent_activity_relations") +@Schema(name = "MpParentAgentActivityRelationEntity对象", description = "家长参与代理商活动关系表") +public class MpParentAgentActivityRelationEntity extends BaseEntity { + + /** + * 活动ID + */ + @TableField("activity_id") + private Integer activityId; + + /** + * 代理商ID + */ + @TableField("agent_id") + private Integer agentId; + + /** + * 家长ID + */ + @TableField("parent_id") + private Integer parentId; + + /** + * 活动名称(冗余字段) + */ + @TableField("activity_name") + private String activityName; + + /** + * 代理商名称(冗余字段) + */ + @TableField("agent_name") + private String agentName; + + /** + * 参与状态:0-取消参与,1-正常参与 + */ + @TableField("status") + private Integer status; + + /** + * 报名时间 + */ + @TableField("sign_up_time") + private LocalDateTime signUpTime; + +} diff --git a/seer-mp/seer-mp-data-module/src/main/java/com/seer/teach/mp/mapper/MpActivityInfoCollectionMapper.java b/seer-mp/seer-mp-data-module/src/main/java/com/seer/teach/mp/mapper/MpActivityInfoCollectionMapper.java new file mode 100644 index 0000000..21ac3dd --- /dev/null +++ b/seer-mp/seer-mp-data-module/src/main/java/com/seer/teach/mp/mapper/MpActivityInfoCollectionMapper.java @@ -0,0 +1,18 @@ +package com.seer.teach.mp.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.seer.teach.mp.entity.MpActivityInfoCollectionEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + *

+ * 活动信息收集表 Mapper 接口 + *

+ * + * @author Lingma + * @since 2025-12-30 + */ +@Mapper +public interface MpActivityInfoCollectionMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/seer-mp/seer-mp-data-module/src/main/java/com/seer/teach/mp/mapper/MpParentAgentActivityRelationMapper.java b/seer-mp/seer-mp-data-module/src/main/java/com/seer/teach/mp/mapper/MpParentAgentActivityRelationMapper.java new file mode 100644 index 0000000..9d3b2f1 --- /dev/null +++ b/seer-mp/seer-mp-data-module/src/main/java/com/seer/teach/mp/mapper/MpParentAgentActivityRelationMapper.java @@ -0,0 +1,18 @@ +package com.seer.teach.mp.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.seer.teach.mp.entity.MpParentAgentActivityRelationEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + *

+ * 家长参与代理商活动关系表 Mapper 接口 + *

+ * + * @author Lingma + * @since 2025-12-30 + */ +@Mapper +public interface MpParentAgentActivityRelationMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/controller/AdminParentAgentActivityController.java b/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/controller/AdminParentAgentActivityController.java new file mode 100644 index 0000000..83205dd --- /dev/null +++ b/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/controller/AdminParentAgentActivityController.java @@ -0,0 +1,48 @@ +package com.seer.teach.mp.admin.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.seer.teach.common.PageListBean; +import com.seer.teach.common.ResultBean; +import com.seer.teach.common.annotation.LogPrint; +import com.seer.teach.common.utils.PageConverterUtils; +import com.seer.teach.mp.admin.controller.req.ParentAgentActivityQueryReq; +import com.seer.teach.mp.admin.controller.resp.AdminParentAgentActivityResp; +import com.seer.teach.mp.admin.controller.resp.MpParentAgentActivityResp; +import com.seer.teach.mp.admin.service.AdminParentAgentActivityService; +import com.seer.teach.mp.entity.MpParentAgentActivityRelationEntity; +import com.seer.teach.mp.service.IMpParentAgentActivityRelationService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +/** + * 家长参与代理商活动控制器 - 管理端 + */ +@Tag(name = "管理端 - 家长参与代理商活动管理") +@AllArgsConstructor +@RestController +@RequestMapping("/mp/admin/parent/agent/activity") +public class AdminParentAgentActivityController { + + private final AdminParentAgentActivityService adminParentAgentActivityService; + + @PostMapping("/page") + @SaCheckPermission("admin:parent:agent:activity:page") + @Operation(summary = "分页查询家长参与代理商活动记录") + @LogPrint + public ResultBean> pageList( + @RequestBody ParentAgentActivityQueryReq queryReq) { + return ResultBean.success(adminParentAgentActivityService.pageList(queryReq)); + } + + @GetMapping("/{id}") + @SaCheckPermission("admin:parent:agent:activity:detail") + @Operation(summary = "获取家长参与代理商活动记录详情") + @LogPrint + public ResultBean detail(@PathVariable Integer id) { + return ResultBean.success(adminParentAgentActivityService.getDetail(id)); + } +} \ No newline at end of file diff --git a/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/controller/req/ParentAgentActivityQueryReq.java b/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/controller/req/ParentAgentActivityQueryReq.java new file mode 100644 index 0000000..4903a19 --- /dev/null +++ b/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/controller/req/ParentAgentActivityQueryReq.java @@ -0,0 +1,51 @@ +package com.seer.teach.mp.admin.controller.req; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.seer.teach.common.request.PageRequest; +import com.seer.teach.mp.entity.MpParentAgentActivityRelationEntity; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 家长参与代理商活动查询请求类 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@Schema(description = "家长参与代理商活动查询请求") +public class ParentAgentActivityQueryReq extends PageRequest { + + @Schema(description = "活动ID") + private Integer activityId; + + @Schema(description = "代理商ID") + private Integer agentId; + + @Schema(description = "家长ID") + private Integer parentId; + + @Schema(description = "活动名称") + private String activityName; + + @Schema(description = "代理商名称") + private String agentName; + + @Schema(description = "参与状态:0-取消参与,1-正常参与") + private Integer status; + + /** + * 转换为查询条件 + * @return 查询条件 + */ + public LambdaQueryWrapper toQueryWrapper() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(activityId != null, MpParentAgentActivityRelationEntity::getActivityId, activityId) + .eq(agentId != null, MpParentAgentActivityRelationEntity::getAgentId, agentId) + .eq(parentId != null, MpParentAgentActivityRelationEntity::getParentId, parentId) + .like(activityName != null && !activityName.isEmpty(), MpParentAgentActivityRelationEntity::getActivityName, activityName) + .like(agentName != null && !agentName.isEmpty(), MpParentAgentActivityRelationEntity::getAgentName, agentName) + .eq(status != null, MpParentAgentActivityRelationEntity::getStatus, status) + .orderByDesc(MpParentAgentActivityRelationEntity::getSignUpTime); // 按报名时间倒序排列 + return wrapper; + } +} \ No newline at end of file diff --git a/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/controller/resp/AdminParentAgentActivityResp.java b/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/controller/resp/AdminParentAgentActivityResp.java new file mode 100644 index 0000000..0a7b152 --- /dev/null +++ b/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/controller/resp/AdminParentAgentActivityResp.java @@ -0,0 +1,45 @@ +package com.seer.teach.mp.admin.controller.resp; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * 管理端家长参与代理商活动响应类 + */ +@Data +@Schema(description = "管理端家长参与代理商活动响应") +public class AdminParentAgentActivityResp { + + @Schema(description = "关系ID") + private Integer id; + + @Schema(description = "活动ID") + private Integer activityId; + + @Schema(description = "活动名称") + private String activityName; + + @Schema(description = "代理商ID") + private Integer agentId; + + @Schema(description = "代理商名称") + private String agentName; + + @Schema(description = "家长ID") + private Integer parentId; + + @Schema(description = "参与状态:0-取消参与,1-正常参与") + private Integer status; + + @Schema(description = "报名时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime signUpTime; + + @Schema(description = "创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/controller/resp/MpParentAgentActivityResp.java b/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/controller/resp/MpParentAgentActivityResp.java new file mode 100644 index 0000000..2246665 --- /dev/null +++ b/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/controller/resp/MpParentAgentActivityResp.java @@ -0,0 +1,40 @@ +package com.seer.teach.mp.admin.controller.resp; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * 家长参与代理商活动Resp + */ +@Data +@Schema(description = "家长参与代理商活动Resp") +public class MpParentAgentActivityResp { + + @Schema(description = "关系ID") + private Integer id; + + @Schema(description = "活动ID") + private Integer activityId; + + @Schema(description = "活动名称") + private String activityName; + + @Schema(description = "代理商ID") + private Integer agentId; + + @Schema(description = "代理商名称") + private String agentName; + + @Schema(description = "家长ID") + private Integer parentId; + + @Schema(description = "参与状态:0-取消参与,1-正常参与") + private Integer status; + + @Schema(description = "报名时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime signUpTime; +} \ No newline at end of file diff --git a/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/convert/AdminParentAgentActivityConvert.java b/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/convert/AdminParentAgentActivityConvert.java new file mode 100644 index 0000000..ff236ad --- /dev/null +++ b/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/convert/AdminParentAgentActivityConvert.java @@ -0,0 +1,18 @@ +package com.seer.teach.mp.admin.convert; + +import com.seer.teach.mp.admin.controller.resp.AdminParentAgentActivityResp; +import com.seer.teach.mp.entity.MpParentAgentActivityRelationEntity; +import org.apache.ibatis.annotations.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +@Mapper +public interface AdminParentAgentActivityConvert { + + AdminParentAgentActivityConvert INSTANCE = Mappers.getMapper(AdminParentAgentActivityConvert.class); + + AdminParentAgentActivityResp convertToResp(MpParentAgentActivityRelationEntity entity); + + List convertToRespList(List entityList); +} diff --git a/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/service/AdminParentAgentActivityService.java b/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/service/AdminParentAgentActivityService.java new file mode 100644 index 0000000..175e5c5 --- /dev/null +++ b/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/service/AdminParentAgentActivityService.java @@ -0,0 +1,50 @@ +package com.seer.teach.mp.admin.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.seer.teach.common.PageListBean; +import com.seer.teach.common.ResultBean; +import com.seer.teach.common.utils.PageConverterUtils; +import com.seer.teach.mp.admin.controller.req.ParentAgentActivityQueryReq; +import com.seer.teach.mp.admin.controller.resp.AdminParentAgentActivityResp; +import com.seer.teach.mp.admin.controller.resp.MpParentAgentActivityResp; +import com.seer.teach.mp.admin.convert.AdminParentAgentActivityConvert; +import com.seer.teach.mp.entity.MpParentAgentActivityRelationEntity; +import com.seer.teach.mp.service.IMpParentAgentActivityRelationService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.Objects; + +@RequiredArgsConstructor +@Service +@Slf4j +public class AdminParentAgentActivityService { + + private final IMpParentAgentActivityRelationService parentAgentActivityRelationService; + + public PageListBean pageList(ParentAgentActivityQueryReq query) { + + IPage pageParam = new Page<>(query.getPageNo(),query.getPageSize()); + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(Objects.nonNull(query.getActivityId()), MpParentAgentActivityRelationEntity::getActivityId, query.getActivityId()) + .eq(Objects.nonNull(query.getAgentId()), MpParentAgentActivityRelationEntity::getAgentId, query.getAgentId()) + .eq(Objects.nonNull(query.getAgentId()), MpParentAgentActivityRelationEntity::getParentId, query.getAgentId()) + .like(Objects.nonNull(query.getActivityName()) && !query.getActivityName().isEmpty(), MpParentAgentActivityRelationEntity::getActivityName, query.getActivityName()) + .like(Objects.nonNull(query.getAgentName()) && !query.getAgentName().isEmpty(), MpParentAgentActivityRelationEntity::getAgentName, query.getAgentName()) + .eq(Objects.nonNull(query.getStatus()), MpParentAgentActivityRelationEntity::getStatus, query.getStatus()) + .orderByDesc(MpParentAgentActivityRelationEntity::getSignUpTime); + + IPage pageResult = parentAgentActivityRelationService.page(pageParam, wrapper); + + return PageConverterUtils.convertPageListBean(pageResult, AdminParentAgentActivityConvert.INSTANCE::convertToRespList); + } + + public AdminParentAgentActivityResp getDetail(Integer id) { + MpParentAgentActivityRelationEntity entity = parentAgentActivityRelationService.getById(id); + return AdminParentAgentActivityConvert.INSTANCE.convertToResp(entity); + } +} diff --git a/seer-mp/seer-mp-service-app-bootstrap/src/main/resources/db/mysql/V1.0.2__add_agent_activity_tables.sql b/seer-mp/seer-mp-service-app-bootstrap/src/main/resources/db/mysql/V1.0.2__add_agent_activity_tables.sql index 60c7c3f..43e468a 100644 --- a/seer-mp/seer-mp-service-app-bootstrap/src/main/resources/db/mysql/V1.0.2__add_agent_activity_tables.sql +++ b/seer-mp/seer-mp-service-app-bootstrap/src/main/resources/db/mysql/V1.0.2__add_agent_activity_tables.sql @@ -89,4 +89,55 @@ CREATE TABLE `mp_agent_activity_log` ( KEY `idx_activity_id` (`activity_id`), KEY `idx_operator_id` (`operator_id`), KEY `idx_create_time` (`create_time`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='代理商活动操作日志表'; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='代理商活动操作日志表'; + + +CREATE TABLE `mp_parent_agent_activity_relation` ( + `id` int NOT NULL AUTO_INCREMENT COMMENT '关系ID', + `activity_id` int NOT NULL COMMENT '活动ID', + `agent_id` int NOT NULL COMMENT '代理商ID', + `parent_id` int NOT NULL COMMENT '家长ID', + `activity_name` varchar(255) NOT NULL COMMENT '活动名称(冗余字段)', + `agent_name` varchar(255) NOT NULL COMMENT '代理商名称(冗余字段)', + `status` tinyint NOT NULL DEFAULT '1' COMMENT '参与状态:0-取消参与,1-正常参与', + `sign_up_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '报名时间', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人', + `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', + `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + `tenant_id` varchar(20) DEFAULT 'Default' COMMENT '租户id', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_activity_id` (`activity_id`), + KEY `idx_agent_id` (`agent_id`), + KEY `idx_parent_id` (`parent_id`), + KEY `idx_sign_up_time` (`sign_up_time`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='家长参与代理商活动关系表'; + + +CREATE TABLE `mp_activity_info_collection` ( + `id` int NOT NULL AUTO_INCREMENT COMMENT '信息收集ID', + `relation_id` int NOT NULL COMMENT '关系ID', + `activity_id` int NOT NULL COMMENT '活动ID', + `parent_id` int NOT NULL COMMENT '家长ID', + `relation_id` int COMMENT '关联的家长参与代理商活动关系ID', + `child_name` varchar(100) COMMENT '孩子姓名', + `child_gender` varchar(10) COMMENT '孩子性别(M-男,F-女)', + `child_birth_date` date COMMENT '出生年月', + `grade` varchar(20) COMMENT '年级', + `school` varchar(255) COMMENT '学校', + `region` varchar(255) COMMENT '地区', + `parent_identity` varchar(20) COMMENT '家长身份(爸爸,妈妈)', + `learning_situation` varchar(20) COMMENT '学习情况(优、良、中、差)', + `weak_subject` varchar(50) COMMENT '偏科(数学、英语等)', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人', + `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', + `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + `tenant_id` varchar(20) DEFAULT 'Default' COMMENT '租户id', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_activity_id` (`activity_id`), + KEY `idx_parent_id` (`parent_id`), + KEY `idx_relation_id` (`relation_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='活动信息收集表'; \ No newline at end of file diff --git a/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/controller/AppAgentActivityController.java b/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/controller/AppAgentActivityController.java index 1b7a910..e417baf 100644 --- a/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/controller/AppAgentActivityController.java +++ b/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/controller/AppAgentActivityController.java @@ -1,6 +1,7 @@ package com.seer.teach.mp.app.controller; import cn.dev33.satoken.annotation.SaCheckPermission; +import cn.dev33.satoken.stp.StpUtil; import com.seer.teach.common.PageListBean; import com.seer.teach.common.ResultBean; import com.seer.teach.common.annotation.DecryptionAnnotation; @@ -37,13 +38,14 @@ public class AppAgentActivityController { @GetMapping("/page-list") @SaCheckPermission("mp:app:agent:activity:list") public ResultBean> pageList(AppAgentActivityQueryReq query) { - return ResultBean.success(agentActivityService.pageList(query)); + Integer agentId = StpUtil.getLoginIdAsInt(); + return ResultBean.success(agentActivityService.pageList(query,agentId)); } @Operation(summary = "查看活动详情") @GetMapping("/{id}") - @SaCheckPermission("mp:app:agent:activity:get") - public ResultBean get(@PathVariable Integer id) { + @SaCheckPermission("mp:app:agent:activity:detail") + public ResultBean getDetail(@PathVariable Integer id) { return ResultBean.success(agentActivityService.getById(id)); } } \ No newline at end of file diff --git a/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/controller/AppParentAgentActivityController.java b/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/controller/AppParentAgentActivityController.java new file mode 100644 index 0000000..0eabe28 --- /dev/null +++ b/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/controller/AppParentAgentActivityController.java @@ -0,0 +1,63 @@ +package com.seer.teach.mp.app.controller; + +import cn.dev33.satoken.annotation.SaCheckLogin; +import cn.dev33.satoken.stp.StpUtil; +import com.seer.teach.common.ResultBean; +import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp; +import com.seer.teach.mp.app.service.AppParentAgentActivityService; +import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.DeleteMapping; +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.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * 家长参与代理商活动控制器 - 应用端 + */ +@Tag(name = "应用端 - 家长参与代理商活动管理") +@AllArgsConstructor +@RestController +@RequestMapping("/app/parent/agent/activity") +public class AppParentAgentActivityController { + + private final AppParentAgentActivityService appParentAgentActivityService; + + @PostMapping("/sign-up") + @SaCheckLogin + @Operation(summary = "家长报名参加代理商活动") + public ResultBean signUpForActivity(@RequestBody AppMpSignUpActivityReq request) { + Integer parentId = StpUtil.getLoginIdAsInt(); + return ResultBean.success(appParentAgentActivityService.signUpForActivityWithInfo(request, parentId)); + } + + @PostMapping("/update-info") + @SaCheckLogin + @Operation(summary = "家长更新活动信息") + public ResultBean updateActivityInfo(@RequestBody AppMpSignUpActivityReq request) { + Integer parentId = StpUtil.getLoginIdAsInt(); + return ResultBean.success(appParentAgentActivityService.updateActivityInfo(request, parentId)); + } + + @DeleteMapping("/cancel/{id}") + @SaCheckLogin + @Operation(summary = "取消报名参加代理商活动") + public ResultBean cancelSignUp(@PathVariable("id") Integer id) { + Integer parentId = StpUtil.getLoginIdAsInt(); + return ResultBean.success(appParentAgentActivityService.cancelSignUp(id,parentId)); + } + + @GetMapping("/{agentId}/{activityId}/info") + @SaCheckLogin + @Operation(summary = "获取家长参与代理商活动详情") + public ResultBean getRelationById(@PathVariable("agentId") Integer agentId,@PathVariable("activityId") Integer activityId) { + Integer parentId = StpUtil.getLoginIdAsInt(); + return ResultBean.success(appParentAgentActivityService.getByActivityIdAndParentId(agentId,activityId,parentId)); + } +} \ No newline at end of file diff --git a/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/controller/req/AppMpSignUpActivityReq.java b/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/controller/req/AppMpSignUpActivityReq.java new file mode 100644 index 0000000..f9065a2 --- /dev/null +++ b/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/controller/req/AppMpSignUpActivityReq.java @@ -0,0 +1,49 @@ +package com.seer.teach.mp.app.controller.req; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDate; +import java.util.List; +import java.util.Set; + +@Schema(name = "AppMpSignUpActivityReq", description = "家长报名参加代理商活动Req") +@Data +public class AppMpSignUpActivityReq { + + @Schema(description = "活动ID") + private Integer activityId; + + @Schema(description = "代理商ID") + private Integer agentId; + + @Schema(description = "孩子姓名") + private String childName; + + @Schema(description = "孩子性别") + private String childGender; + + @Schema(description = "孩子出生日期") + private LocalDate childBirthDate; + + @Schema(description = "年级") + private String grade; + + @Schema(description = "学校") + private String school; + + @Schema(description = "地区") + private String region; + + @Schema(description = "家长身份") + private String parentIdentity; + + @Schema(description = "学习情况") + private String learningSituation; + + @Schema(description = "薄弱科目") + private List weakSubjectIds; + + @Schema(description = "优势科目") + private List strongSubjectIds; +} \ No newline at end of file diff --git a/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/controller/resp/AppMpSignUpActivityResp.java b/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/controller/resp/AppMpSignUpActivityResp.java new file mode 100644 index 0000000..940737a --- /dev/null +++ b/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/controller/resp/AppMpSignUpActivityResp.java @@ -0,0 +1,53 @@ +package com.seer.teach.mp.app.controller.resp; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDate; + +@Schema(name = "AppMpSignUpActivityResp", description = "家长报名参加代理商活动信息Resp") +@Data +public class AppMpSignUpActivityResp { + + @Schema(description = "id") + private Integer id; + + @Schema(description = "活动ID") + private Integer activityId; + + @Schema(description = "代理商ID") + private Integer agentId; + + @Schema(description = "活动名称") + private String activityName; + + @Schema(description = "代理商名称") + private String agentName; + + @Schema(description = "孩子姓名") + private String childName; + + @Schema(description = "孩子性别") + private String childGender; + + @Schema(description = "孩子出生日期") + private LocalDate childBirthDate; + + @Schema(description = "年级") + private String grade; + + @Schema(description = "学校") + private String school; + + @Schema(description = "地区") + private String region; + + @Schema(description = "家长身份") + private String parentIdentity; + + @Schema(description = "学习情况") + private String learningSituation; + + @Schema(description = "薄弱科目") + private String weakSubject; +} \ No newline at end of file diff --git a/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/convert/AppMpActivityInfoCollectionConvert.java b/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/convert/AppMpActivityInfoCollectionConvert.java new file mode 100644 index 0000000..228987a --- /dev/null +++ b/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/convert/AppMpActivityInfoCollectionConvert.java @@ -0,0 +1,18 @@ +package com.seer.teach.mp.app.convert; + +import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq; +import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp; +import com.seer.teach.mp.entity.MpActivityInfoCollectionEntity; +import org.apache.ibatis.annotations.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface AppMpActivityInfoCollectionConvert { + + AppMpActivityInfoCollectionConvert INSTANCE = Mappers.getMapper(AppMpActivityInfoCollectionConvert.class); + + AppMpSignUpActivityResp convert2Resp(MpActivityInfoCollectionEntity entity); + + + MpActivityInfoCollectionEntity convert2Entity(AppMpSignUpActivityReq request); +} diff --git a/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/service/AppParentAgentActivityService.java b/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/service/AppParentAgentActivityService.java new file mode 100644 index 0000000..2c3c5d7 --- /dev/null +++ b/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/service/AppParentAgentActivityService.java @@ -0,0 +1,136 @@ +package com.seer.teach.mp.app.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.seer.teach.common.enums.ResultCodeEnum; +import com.seer.teach.common.utils.AssertUtils; +import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq; +import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp; +import com.seer.teach.mp.app.convert.AppMpActivityInfoCollectionConvert; +import com.seer.teach.mp.entity.MpActivityEntity; +import com.seer.teach.mp.entity.MpActivityInfoCollectionEntity; +import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity; +import com.seer.teach.mp.entity.MpAgentEntity; +import com.seer.teach.mp.entity.MpParentAgentActivityRelationEntity; +import com.seer.teach.mp.service.IMpActivityInfoCollectionService; +import com.seer.teach.mp.service.IMpActivityService; +import com.seer.teach.mp.service.IMpAgentActivityParticipantService; +import com.seer.teach.mp.service.IMpAgentService; +import com.seer.teach.mp.service.IMpParentAgentActivityRelationService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.util.Objects; + +@RequiredArgsConstructor +@Slf4j +@Service +public class AppParentAgentActivityService { + + private final IMpParentAgentActivityRelationService parentAgentActivityRelationService; + private final IMpActivityInfoCollectionService activityInfoCollectionService; + private final IMpActivityService activityService; + private final IMpAgentService agentService; + private final IMpAgentActivityParticipantService mpAgentActivityParticipantService; + + /** + * 报名活动 + * + * @param request 报名信息 + * @param parentId 家长ID + * @return true表示成功,false表示失败 + */ + public boolean signUpForActivityWithInfo(AppMpSignUpActivityReq request, Integer parentId) { + Integer agentId = request.getAgentId(); + Integer activityId = request.getActivityId(); + MpActivityEntity activity = activityService.getById(activityId); + AssertUtils.notNull(activity, ResultCodeEnum.INVALID_ACTIVITY); + + MpAgentEntity agent = agentService.getById(agentId); + AssertUtils.notNull(agent, ResultCodeEnum.INVALID_AGENT); + + MpAgentActivityParticipantEntity participants = mpAgentActivityParticipantService.getParticipantsByActivityAndAgent(request.getActivityId(), request.getAgentId()); + AssertUtils.notNull(participants, ResultCodeEnum.AGENT_NON_PARTICIPANT_ACTIVE); + + MpParentAgentActivityRelationEntity relation = parentAgentActivityRelationService.getByAgentIdAndActivityIdAndParentId(agentId, activityId, parentId); + AssertUtils.isNull(relation, ResultCodeEnum.PARENT_ALREADY_SIGN_UP); + + relation = new MpParentAgentActivityRelationEntity(); + relation.setActivityId(activityId); + relation.setAgentId(agentId); + relation.setParentId(parentId); + relation.setActivityName(activity.getActivityName()); + relation.setAgentName(agent.getAgentName()); + relation.setStatus(1); + relation.setSignUpTime(LocalDateTime.now()); + boolean saved = parentAgentActivityRelationService.save(relation); + log.info("报名结果:{},关系ID:{}", saved, relation.getId()); + + if(saved){ + MpActivityInfoCollectionEntity mpActivityInfoCollectionEntity = AppMpActivityInfoCollectionConvert.INSTANCE.convert2Entity(request); + mpActivityInfoCollectionEntity.setRelationId(relation.getId()); + boolean activityInfoCollectionResult = activityInfoCollectionService.save(mpActivityInfoCollectionEntity); + log.info("活动信息收集结果:{}", activityInfoCollectionResult); + return activityInfoCollectionResult; + } + return false; + } + + /** + * 更新活动信息 + * + * @param request 活动信息 + * @param parentId 家长ID + * @return true表示成功,false表示失败 + */ + public boolean updateActivityInfo(AppMpSignUpActivityReq request, Integer parentId) { + Integer agentId = request.getAgentId(); + Integer activityId = request.getActivityId(); + MpParentAgentActivityRelationEntity relation = parentAgentActivityRelationService.getByAgentIdAndActivityIdAndParentId(agentId, activityId, parentId); + AssertUtils.notNull(relation, ResultCodeEnum.PARENT_NOT_SIGNED_UP); + + MpActivityInfoCollectionEntity mpActivityInfoCollectionEntity = AppMpActivityInfoCollectionConvert.INSTANCE.convert2Entity(request); + mpActivityInfoCollectionEntity.setRelationId(relation.getId()); + return activityInfoCollectionService.updateById(mpActivityInfoCollectionEntity); + } + + /** + * 取消报名 + * + * @param relationId 关系ID + * @param parentId 家长ID + * @return true表示成功,false表示失败 + */ + public boolean cancelSignUp(Integer relationId, Integer parentId) { + MpParentAgentActivityRelationEntity relation = parentAgentActivityRelationService.getById(relationId); + if (Objects.nonNull(relation) && relation.getParentId().equals(parentId)) { + relation.setStatus(0); + boolean result = parentAgentActivityRelationService.updateById(relation); + log.info("取消报名结果:{}", result); + return result; + } + return false; + } + + + /** + * 获取报名信息 + * + * @param agentId 代理商ID + * @param activityId 活动ID + * @param parentId 家长ID + * @return 报名信息 + */ + public AppMpSignUpActivityResp getByActivityIdAndParentId(Integer agentId, Integer activityId, Integer parentId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(MpParentAgentActivityRelationEntity::getActivityId, activityId) + .eq(MpParentAgentActivityRelationEntity::getParentId, parentId) + .eq(MpParentAgentActivityRelationEntity::getAgentId, agentId); + MpParentAgentActivityRelationEntity one = parentAgentActivityRelationService.getOne(wrapper); + AssertUtils.notNull(one, ResultCodeEnum.INVALID_ACTIVITY); + MpActivityInfoCollectionEntity activityInfoCollection = activityInfoCollectionService.getByActivityIdAndParentId(agentId, activityId, parentId); + return AppMpActivityInfoCollectionConvert.INSTANCE.convert2Resp(activityInfoCollection); + } + +} \ No newline at end of file diff --git a/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/service/IAppAgentActivityService.java b/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/service/IAppAgentActivityService.java index 7f15766..82aaa9e 100644 --- a/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/service/IAppAgentActivityService.java +++ b/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/service/IAppAgentActivityService.java @@ -18,9 +18,10 @@ public interface IAppAgentActivityService { * 分页查询代理商活动列表 * * @param query 查询条件 + * @param agentId 代理商ID * @return 代理商活动分页列表 */ - PageListBean pageList(AppAgentActivityQueryReq query); + PageListBean pageList(AppAgentActivityQueryReq query,Integer agentId); /** * 根据ID获取活动详情 diff --git a/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/service/impl/AppAgentActivityServiceImpl.java b/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/service/impl/AppAgentActivityServiceImpl.java index f53ab8a..bfb14db 100644 --- a/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/service/impl/AppAgentActivityServiceImpl.java +++ b/seer-mp/seer-mp-service-app/src/main/java/com/seer/teach/mp/app/service/impl/AppAgentActivityServiceImpl.java @@ -32,13 +32,13 @@ import java.util.Objects; @RequiredArgsConstructor public class AppAgentActivityServiceImpl implements IAppAgentActivityService { - private final IMpActivityService agentActivityService; + private final IMpActivityService activityService; @Override - public PageListBean pageList(AppAgentActivityQueryReq query) { + public PageListBean pageList(AppAgentActivityQueryReq query,Integer agentId) { log.info("查询参数:{}", query); IPage page = new Page<>(query.getPageNo(), query.getPageSize()); - var pageResult = agentActivityService.page(page, new LambdaQueryWrapper<>(MpActivityEntity.class) + var pageResult = activityService.page(page, new LambdaQueryWrapper<>(MpActivityEntity.class) .like(StringUtils.isNotBlank(query.getActivityName()), MpActivityEntity::getActivityName, query.getActivityName()) .eq(Objects.nonNull(query.getStatus()), MpActivityEntity::getStatus, query.getStatus())); if(Objects.isNull(pageResult) || CollectionUtil.isEmpty(pageResult.getRecords())){ @@ -50,7 +50,7 @@ public class AppAgentActivityServiceImpl implements IAppAgentActivityService { @Override public AppAgentActivityResp getById(Integer id) { - MpActivityEntity entity = agentActivityService.getById(id); + MpActivityEntity entity = activityService.getById(id); return AppAgentActivityConvert.INSTANCE.convertToResp(entity); } } \ No newline at end of file diff --git a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/api/impl/MpAgentServiceApiImpl.java b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/api/impl/MpAgentServiceApiImpl.java deleted file mode 100644 index 2a59844..0000000 --- a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/api/impl/MpAgentServiceApiImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.seer.teach.mp.api.impl; - -import com.seer.teach.common.ResultBean; -import com.seer.teach.mp.api.dto.AgentActivityParticipantDTO; -import com.seer.teach.mp.service.IMpAgentActivityParticipantService; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; -import java.util.stream.Collectors; - -@RestController -@RequiredArgsConstructor -public class MpAgentServiceApiImpl implements MpAgentServiceApi { - - private final IMpAgentActivityParticipantService agentActivityParticipantService; - - @Override - public ResultBean> getParticipantParents(Integer activityId, Integer agentId) { - var participants = agentActivityParticipantService.getParticipantsByActivityAndAgent(activityId, agentId); - List result = participants.stream() - .map(participant -> { - AgentActivityParticipantDTO dto = new AgentActivityParticipantDTO(); - dto.setId(participant.getId()); - dto.setActivityId(participant.getActivityId()); - dto.setAgentId(participant.getAgentId()); - dto.setParentId(participant.getParentId()); - dto.setCreateTime(participant.getCreateTime()); - dto.setUpdateTime(participant.getUpdateTime()); - return dto; - }) - .collect(Collectors.toList()); - - return ResultBean.success(result); - } -} \ No newline at end of file diff --git a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/cache/MpAgentActivityCache.java b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/cache/MpAgentActivityCache.java deleted file mode 100644 index a55d554..0000000 --- a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/cache/MpAgentActivityCache.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.seer.teach.mp.cache; - -import com.seer.teach.common.utils.RedisUtil; -import com.seer.teach.mp.entity.MpActivityEntity; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.time.Duration; -import java.util.List; - -/** - * 代理商活动缓存服务 - */ -@Slf4j -@Component -@RequiredArgsConstructor -public class MpAgentActivityCache { - - private final RedisUtil redisUtil; - - private static final String AGENT_ACTIVITY_PREFIX = "mp:agent:activity:"; - private static final String AGENT_ACTIVITY_LIST_PREFIX = "mp:agent:activity:list:"; - private static final Duration CACHE_TTL = Duration.ofMinutes(30); - - /** - * 获取活动详情缓存 - */ - public MpActivityEntity getActivityById(Integer id) { - String key = AGENT_ACTIVITY_PREFIX + id; - String value = redisUtil.get(key); - if (value != null) { - try { - return cn.hutool.json.JSONUtil.toBean(value, MpActivityEntity.class); - } catch (Exception e) { - log.error("从缓存获取活动详情失败, id: {}", id, e); - } - } - return null; - } - - /** - * 设置活动详情缓存 - */ - public void setActivityById(Integer id, MpActivityEntity entity) { - String key = AGENT_ACTIVITY_PREFIX + id; - try { - String value = cn.hutool.json.JSONUtil.toJsonStr(entity); - redisUtil.set(key, value, CACHE_TTL.toSeconds()); - } catch (Exception e) { - log.error("设置活动详情缓存失败, id: {}", id, e); - } - } - - /** - * 删除活动详情缓存 - */ - public void deleteActivityById(Integer id) { - String key = AGENT_ACTIVITY_PREFIX + id; - redisUtil.del(key); - } - - /** - * 获取活动列表缓存 - */ - public List getActivityList(String keySuffix) { - String key = AGENT_ACTIVITY_LIST_PREFIX + keySuffix; - String value = redisUtil.get(key); - if (value != null) { - try { - return cn.hutool.json.JSONUtil.toList(value, MpActivityEntity.class); - } catch (Exception e) { - log.error("从缓存获取活动列表失败, key: {}", key, e); - } - } - return null; - } - - /** - * 设置活动列表缓存 - */ - public void setActivityList(String keySuffix, List entities) { - String key = AGENT_ACTIVITY_LIST_PREFIX + keySuffix; - try { - String value = cn.hutool.json.JSONUtil.toJsonStr(entities); - redisUtil.set(key, value, CACHE_TTL.toSeconds()); - } catch (Exception e) { - log.error("设置活动列表缓存失败, key: {}", key, e); - } - } - - /** - * 删除活动列表缓存 - */ - public void deleteActivityList(String keySuffix) { - String key = AGENT_ACTIVITY_LIST_PREFIX + keySuffix; - redisUtil.del(key); - } - - /** - * 清除所有活动相关缓存 - */ - public void clearAllActivityCache() { - // 可以通过通配符删除,但这里简单地提供一个清理方法 - log.info("清除所有代理商活动缓存"); - } -} \ No newline at end of file diff --git a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/exception/AgentActivityErrorCodeEnum.java b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/exception/AgentActivityErrorCodeEnum.java deleted file mode 100644 index eb4aacf..0000000 --- a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/exception/AgentActivityErrorCodeEnum.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.seer.teach.mp.exception; - -import com.seer.teach.common.enums.ResultCodeEnum; -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 代理商活动错误码枚举 - */ -@Getter -@AllArgsConstructor -public enum AgentActivityErrorCodeEnum implements ResultCodeEnum { - - ACTIVITY_NOT_FOUND(404, "活动不存在"), - ACTIVITY_ALREADY_EXISTS(409, "活动已存在"), - ACTIVITY_NOT_ACTIVE(400, "活动未开始或已结束"), - PARTICIPATION_FAILED(500, "参与活动失败"), - INVALID_AGENT(403, "无效的代理商"), - AGENT_NOT_FOUND(404, "代理商不存在"), - PARENT_NOT_FOUND(404, "家长不存在"), - INVALID_ACTIVITY_STATUS(400, "无效的活动状态"); - - private final Integer code; - private final String message; -} \ No newline at end of file diff --git a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/exception/AgentActivityException.java b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/exception/AgentActivityException.java deleted file mode 100644 index 8c323fb..0000000 --- a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/exception/AgentActivityException.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.seer.teach.mp.exception; - -import com.seer.teach.common.enums.ResultCodeEnum; -import com.seer.teach.common.exception.CommonException; -import lombok.Getter; - -/** - * 代理商活动相关异常 - */ -@Getter -public class AgentActivityException extends CommonException { - - public AgentActivityException(ResultCodeEnum resultCodeEnum) { - super(resultCodeEnum); - } - - public AgentActivityException(ResultCodeEnum resultCodeEnum, String message) { - super(resultCodeEnum, message); - } - - public AgentActivityException(String message) { - super(message); - } -} \ No newline at end of file diff --git a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/exception/AgentErrorCodeEnum.java b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/exception/AgentErrorCodeEnum.java deleted file mode 100644 index ee1ef03..0000000 --- a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/exception/AgentErrorCodeEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.seer.teach.mp.exception; - -import com.seer.teach.common.exception.ErrorCode; - -/** - * 代理商相关错误码枚举 - */ -public enum AgentErrorCodeEnum implements ErrorCode { - - AGENT_NOT_FOUND(40001, "代理商不存在"), - AGENT_CODE_EXISTS(40002, "代理商编码已存在"), - AGENT_STATUS_INVALID(40003, "代理商状态无效"), - AGENT_CONTACT_INFO_INVALID(40004, "联系信息无效"); - - private final int code; - private final String message; - - AgentErrorCodeEnum(int code, String message) { - this.code = code; - this.message = message; - } - - @Override - public int getCode() { - return code; - } - - @Override - public String getMessage() { - return message; - } -} \ No newline at end of file diff --git a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/exception/AgentException.java b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/exception/AgentException.java deleted file mode 100644 index c79eee8..0000000 --- a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/exception/AgentException.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.seer.teach.mp.exception; - -import com.seer.teach.common.exception.BusinessException; -import com.seer.teach.common.exception.ErrorCode; - -/** - * 代理商业务异常类 - */ -public class AgentException extends BusinessException { - - public AgentException(ErrorCode errorCode) { - super(errorCode); - } - - public AgentException(ErrorCode errorCode, String detailMessage) { - super(errorCode, detailMessage); - } - - public AgentException(String message, Throwable cause) { - super(message, cause); - } - - public AgentException(ErrorCode errorCode, String detailMessage, Throwable cause) { - super(errorCode, detailMessage, cause); - } -} \ No newline at end of file diff --git a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpActivityInfoCollectionService.java b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpActivityInfoCollectionService.java new file mode 100644 index 0000000..8dc2c41 --- /dev/null +++ b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpActivityInfoCollectionService.java @@ -0,0 +1,23 @@ +package com.seer.teach.mp.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.seer.teach.mp.entity.MpActivityInfoCollectionEntity; + +/** + *

+ * 活动信息收集表 服务类 + *

+ * + * @author Lingma + * @since 2025-12-30 + */ +public interface IMpActivityInfoCollectionService extends IService { + + /** + * 根据活动ID和家长ID获取信息收集记录 + * @param agentId 活动ID + * @param parentId 家长ID + * @return 信息收集记录 + */ + MpActivityInfoCollectionEntity getByActivityIdAndParentId(Integer agentId,Integer activityId, Integer parentId); +} \ No newline at end of file diff --git a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpAgentActivityParticipantService.java b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpAgentActivityParticipantService.java index f371f00..4fddc20 100644 --- a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpAgentActivityParticipantService.java +++ b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpAgentActivityParticipantService.java @@ -1,11 +1,8 @@ package com.seer.teach.mp.service; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity; -import java.util.List; - /** *

* 代理商活动参与记录表 服务类 @@ -16,23 +13,6 @@ import java.util.List; */ public interface IMpAgentActivityParticipantService extends IService { - /** - * 分页查询活动参与记录列表 - * - * @param pageParm 分页参数 - * @param query 查询条件 - * @return 活动参与记录分页列表 - */ - IPage pageList(com.baomidou.mybatisplus.extension.plugins.pagination.Page pageParm, MpAgentActivityParticipantEntity query); - - /** - * 添加活动参与记录 - * - * @param entity 参与记录实体 - * @return 操作是否成功 - */ - boolean addParticipant(MpAgentActivityParticipantEntity entity); - /** * 根据活动ID和代理商ID获取参与记录 * @@ -40,5 +20,5 @@ public interface IMpAgentActivityParticipantService extends IService getParticipantsByActivityAndAgent(Integer activityId, Integer agentId); + MpAgentActivityParticipantEntity getParticipantsByActivityAndAgent(Integer activityId, Integer agentId); } \ No newline at end of file diff --git a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpAgentService.java b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpAgentService.java index 50dd2d2..f9ed795 100644 --- a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpAgentService.java +++ b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpAgentService.java @@ -12,47 +12,5 @@ import java.util.Map; */ public interface IMpAgentService extends IService { - /** - * 分页查询代理商列表 - * @param params 查询参数 - * @return 分页结果 - */ - PageUtils queryPage(Map params); - /** - * 分页查询代理商列表 - * @param page 分页参数 - * @param query 查询条件 - * @return 分页结果 - */ - IPage pageList(Page page, MpAgentEntity query); - - /** - * 根据ID获取代理商信息 - * @param id 代理商ID - * @return 代理商实体 - * @throws AgentException 当代理商不存在时抛出异常 - */ - MpAgentEntity getAgentById(Integer id); - - /** - * 保存代理商信息 - * @param agentEntity 代理商实体 - * @throws AgentException 当代理商信息验证失败或编码已存在时抛出异常 - */ - boolean saveAgent(MpAgentEntity agentEntity); - - /** - * 更新代理商信息 - * @param agentEntity 代理商实体 - * @throws AgentException 当代理商不存在、信息验证失败或编码已存在时抛出异常 - */ - boolean updateAgent(MpAgentEntity agentEntity); - - /** - * 删除代理商 - * @param id 代理商ID - * @throws AgentException 当代理商不存在时抛出异常 - */ - void deleteAgent(Integer id); } \ No newline at end of file diff --git a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpParentAgentActivityRelationService.java b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpParentAgentActivityRelationService.java new file mode 100644 index 0000000..47eef6b --- /dev/null +++ b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpParentAgentActivityRelationService.java @@ -0,0 +1,33 @@ +package com.seer.teach.mp.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.seer.teach.mp.entity.MpParentAgentActivityRelationEntity; + +/** + *

+ * 家长参与代理商活动关系表 服务类 + *

+ * + * @author Lingma + * @since 2025-12-30 + */ +public interface IMpParentAgentActivityRelationService extends IService { + + /** + * 根据活动ID和家长ID获取关系记录 + * + * @param agentId 代理商ID + * @param activityId 活动ID + * @param parentId 家长ID + * @return 关系记录 + */ + MpParentAgentActivityRelationEntity getByAgentIdAndActivityIdAndParentId(Integer agentId, Integer activityId, Integer parentId); + + /** + * 根据活动ID和家长ID获取关系记录 + * @param activityId 活动ID + * @param parentId 家长ID + * @return 关系记录 + */ + MpParentAgentActivityRelationEntity getByAgentIdAndActivityIdAndParentId(Integer activityId, Integer parentId); +} \ No newline at end of file diff --git a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpActivityInfoCollectionServiceImpl.java b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpActivityInfoCollectionServiceImpl.java new file mode 100644 index 0000000..16da709 --- /dev/null +++ b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpActivityInfoCollectionServiceImpl.java @@ -0,0 +1,31 @@ +package com.seer.teach.mp.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.seer.teach.mp.entity.MpActivityInfoCollectionEntity; +import com.seer.teach.mp.mapper.MpActivityInfoCollectionMapper; +import com.seer.teach.mp.service.IMpActivityInfoCollectionService; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +/** + *

+ * 活动信息收集表 服务实现类 + *

+ * + * @author Lingma + * @since 2025-12-30 + */ +@Service +@AllArgsConstructor +public class MpActivityInfoCollectionServiceImpl extends ServiceImpl implements IMpActivityInfoCollectionService { + + @Override + public MpActivityInfoCollectionEntity getByActivityIdAndParentId(Integer agentId, Integer activityId, Integer parentId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(MpActivityInfoCollectionEntity::getAgentId, agentId) + .eq(MpActivityInfoCollectionEntity::getActivityId, activityId) + .eq(MpActivityInfoCollectionEntity::getParentId, parentId); + return getOne(queryWrapper, false); + } +} \ No newline at end of file diff --git a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpAgentActivityParticipantServiceImpl.java b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpAgentActivityParticipantServiceImpl.java index e309570..ae0b59a 100644 --- a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpAgentActivityParticipantServiceImpl.java +++ b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpAgentActivityParticipantServiceImpl.java @@ -34,87 +34,12 @@ public class MpAgentActivityParticipantServiceImpl extends ServiceImpl pageList(Page pageParm, MpAgentActivityParticipantEntity query) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - - if (query != null) { - if (query.getActivityId() != null) { - queryWrapper.eq(MpAgentActivityParticipantEntity::getActivityId, query.getActivityId()); - } - if (query.getAgentId() != null) { - queryWrapper.eq(MpAgentActivityParticipantEntity::getAgentId, query.getAgentId()); - } - if (query.getParentId() != null) { - queryWrapper.eq(MpAgentActivityParticipantEntity::getParentId, query.getParentId()); - } - } - - queryWrapper.orderByDesc(MpAgentActivityParticipantEntity::getCreateTime); - - return baseMapper.selectPage(pageParm, queryWrapper); - } - - @Override - public boolean addParticipant(MpAgentActivityParticipantEntity entity) { - // 验证参与记录数据 - validateParticipant(entity); - - // 检查是否已存在相同的参与记录 - LambdaQueryWrapper queryWrapper = - new LambdaQueryWrapper() - .eq(MpAgentActivityParticipantEntity::getActivityId, entity.getActivityId()) - .eq(MpAgentActivityParticipantEntity::getAgentId, entity.getAgentId()) - .eq(MpAgentActivityParticipantEntity::getParentId, entity.getParentId()); - - long count = this.count(queryWrapper); - if (count > 0) { - // 如果已存在,则不重复添加 - throw new com.seer.teach.mp.exception.AgentActivityException(AgentActivityErrorCodeEnum.PARTICIPATION_FAILED, "已参与该活动"); - } - - entity.setCreateTime(LocalDateTime.now()); - entity.setUpdateTime(LocalDateTime.now()); - - boolean result = this.save(entity); - - // 记录操作日志 - if (result) { - String beforeData = ""; - String afterData = JSONUtil.toJsonStr(entity); - String description = "代理商参与活动,代理商ID: " + entity.getAgentId() + ", 家长ID: " + entity.getParentId(); - - agentActivityLogService.logOperation( - entity.getActivityId(), - entity.getAgentId(), - "参与活动", - description, - beforeData, - afterData - ); - } - - return result; - } - - /** - * 验证参与记录数据 - */ - private void validateParticipant(MpAgentActivityParticipantEntity entity) { - AssertUtils.notNull(entity.getActivityId(), AgentActivityErrorCodeEnum.ACTIVITY_NOT_FOUND, "活动ID不能为空"); - AssertUtils.notNull(entity.getAgentId(), AgentActivityErrorCodeEnum.INVALID_AGENT, "代理商ID不能为空"); - AssertUtils.notNull(entity.getParentId(), AgentActivityErrorCodeEnum.PARENT_NOT_FOUND, "家长ID不能为空"); - - // 检查活动是否存在 - // 这里可以调用活动服务检查活动是否存在,暂时跳过 - } - - @Override - public List getParticipantsByActivityAndAgent(Integer activityId, Integer agentId) { + public MpAgentActivityParticipantEntity getParticipantsByActivityAndAgent(Integer activityId, Integer agentId) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() .eq(MpAgentActivityParticipantEntity::getActivityId, activityId) .eq(MpAgentActivityParticipantEntity::getAgentId, agentId); - return this.list(queryWrapper); + return super.getOne(queryWrapper); } } \ No newline at end of file diff --git a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpAgentServiceImpl.java b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpAgentServiceImpl.java index c63f341..f6b540e 100644 --- a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpAgentServiceImpl.java +++ b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpAgentServiceImpl.java @@ -1,20 +1,10 @@ package com.seer.teach.mp.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.seer.teach.common.utils.PageUtils; import com.seer.teach.mp.entity.MpAgentEntity; -import com.seer.teach.mp.exception.AgentErrorCodeEnum; -import com.seer.teach.mp.exception.AgentException; import com.seer.teach.mp.mapper.MpAgentMapper; import com.seer.teach.mp.service.IMpAgentService; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.util.Map; /** * 代理商服务实现类 @@ -22,147 +12,4 @@ import java.util.Map; @Service public class MpAgentServiceImpl extends ServiceImpl implements IMpAgentService { - @Override - public PageUtils queryPage(Map params) { - IPage page = this.page( - new Page(Long.parseLong(params.getOrDefault("current", "1").toString()), - Long.parseLong(params.getOrDefault("size", "10").toString())) - ); - return new PageUtils(page); - } - - @Override - public IPage pageList(Page page, MpAgentEntity query) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - - if (query != null) { - if (query.getAgentName() != null && !query.getAgentName().trim().isEmpty()) { - queryWrapper.like("agent_name", query.getAgentName()); - } - if (query.getAgentCode() != null && !query.getAgentCode().trim().isEmpty()) { - queryWrapper.eq("agent_code", query.getAgentCode()); - } - if (query.getAgentLevel() != null && !query.getAgentLevel().trim().isEmpty()) { - queryWrapper.eq("agent_level", query.getAgentLevel()); - } - if (query.getContactName() != null && !query.getContactName().trim().isEmpty()) { - queryWrapper.like("contact_name", query.getContactName()); - } - if (query.getContactPhone() != null && !query.getContactPhone().trim().isEmpty()) { - queryWrapper.eq("contact_phone", query.getContactPhone()); - } - if (query.getStatus() != null) { - queryWrapper.eq("status", query.getStatus()); - } - } - - queryWrapper.orderByDesc("create_time"); - - return this.page(page, queryWrapper); - } - - @Override - public MpAgentEntity getAgentById(Integer id) { - if (id == null || id <= 0) { - throw new AgentException(AgentErrorCodeEnum.AGENT_NOT_FOUND, "代理商ID不能为空"); - } - MpAgentEntity agent = this.getById(id); - if (agent == null) { - throw new AgentException(AgentErrorCodeEnum.AGENT_NOT_FOUND); - } - return agent; - } - - @Override - @Transactional - public boolean saveAgent(MpAgentEntity agentEntity) { - validateAgent(agentEntity); - - // 检查代理商编码是否已存在 - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("agent_code", agentEntity.getAgentCode()); - int count = this.count(queryWrapper); - if (count > 0) { - throw new AgentException(AgentErrorCodeEnum.AGENT_CODE_EXISTS); - } - - agentEntity.setCreateTime(LocalDateTime.now()); - agentEntity.setUpdateTime(LocalDateTime.now()); - - boolean result = this.save(agentEntity); - return result; - } - - @Override - @Transactional - public boolean updateAgent(MpAgentEntity agentEntity) { - validateAgent(agentEntity); - - if (agentEntity.getId() == null || agentEntity.getId() <= 0) { - throw new AgentException(AgentErrorCodeEnum.AGENT_NOT_FOUND, "代理商ID不能为空"); - } - - // 检查代理商是否存在 - MpAgentEntity existingAgent = this.getById(agentEntity.getId()); - if (existingAgent == null) { - throw new AgentException(AgentErrorCodeEnum.AGENT_NOT_FOUND); - } - - // 检查代理商编码是否被其他代理商使用 - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("agent_code", agentEntity.getAgentCode()); - queryWrapper.ne("id", agentEntity.getId()); - int count = this.count(queryWrapper); - if (count > 0) { - throw new AgentException(AgentErrorCodeEnum.AGENT_CODE_EXISTS); - } - - agentEntity.setUpdateTime(LocalDateTime.now()); - - boolean result = this.updateById(agentEntity); - return result; - } - - @Override - @Transactional - public void deleteAgent(Integer id) { - if (id == null || id <= 0) { - throw new AgentException(AgentErrorCodeEnum.AGENT_NOT_FOUND, "代理商ID不能为空"); - } - - MpAgentEntity agent = this.getById(id); - if (agent == null) { - throw new AgentException(AgentErrorCodeEnum.AGENT_NOT_FOUND); - } - - this.removeById(id); - } - - /** - * 验证代理商实体 - */ - private void validateAgent(MpAgentEntity agentEntity) { - if (agentEntity == null) { - throw new AgentException(AgentErrorCodeEnum.AGENT_NOT_FOUND, "代理商信息不能为空"); - } - - if (agentEntity.getAgentName() == null || agentEntity.getAgentName().trim().isEmpty()) { - throw new AgentException(AgentErrorCodeEnum.AGENT_NOT_FOUND, "代理商名称不能为空"); - } - - if (agentEntity.getAgentCode() == null || agentEntity.getAgentCode().trim().isEmpty()) { - throw new AgentException(AgentErrorCodeEnum.AGENT_NOT_FOUND, "代理商编码不能为空"); - } - - if (agentEntity.getStatus() != null && (agentEntity.getStatus() != 0 && agentEntity.getStatus() != 1)) { - throw new AgentException(AgentErrorCodeEnum.AGENT_STATUS_INVALID, "代理商状态必须为0或1"); - } - - if (agentEntity.getContactPhone() != null && !agentEntity.getContactPhone().trim().isEmpty()) { - // 简单验证手机号格式 - if (!agentEntity.getContactPhone().matches("^1[3-9]\d{9}$")) { - throw new AgentException(AgentErrorCodeEnum.AGENT_CONTACT_INFO_INVALID, "联系电话格式不正确"); - } - } - } } \ No newline at end of file diff --git a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpParentAgentActivityRelationServiceImpl.java b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpParentAgentActivityRelationServiceImpl.java new file mode 100644 index 0000000..4e705e3 --- /dev/null +++ b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpParentAgentActivityRelationServiceImpl.java @@ -0,0 +1,41 @@ +package com.seer.teach.mp.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.seer.teach.mp.entity.MpParentAgentActivityRelationEntity; +import com.seer.teach.mp.mapper.MpParentAgentActivityRelationMapper; +import com.seer.teach.mp.service.IMpParentAgentActivityRelationService; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; + +/** + *

+ * 家长参与代理商活动关系表 服务实现类 + *

+ * + * @author Lingma + * @since 2025-12-30 + */ +@Service +@AllArgsConstructor +public class MpParentAgentActivityRelationServiceImpl extends ServiceImpl implements IMpParentAgentActivityRelationService { + + @Override + public MpParentAgentActivityRelationEntity getByAgentIdAndActivityIdAndParentId(Integer agentId, Integer activityId, Integer parentId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(MpParentAgentActivityRelationEntity::getActivityId, activityId) + .eq(MpParentAgentActivityRelationEntity::getAgentId, agentId) + .eq(MpParentAgentActivityRelationEntity::getParentId, parentId); + return getOne(queryWrapper); + } + + @Override + public MpParentAgentActivityRelationEntity getByAgentIdAndActivityIdAndParentId(Integer activityId, Integer parentId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(MpParentAgentActivityRelationEntity::getActivityId, activityId) + .eq(MpParentAgentActivityRelationEntity::getParentId, parentId); + return getOne(queryWrapper); + } +} \ No newline at end of file