entity);
+
+
+ MpAgentActivityParticipantEntity convertToEntity(AgentActivityParticipantReq entity);
}
diff --git a/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/service/IAdminAgentActivityParticipantService.java b/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/service/IAdminAgentActivityParticipantService.java
index 75e900d..55499f1 100644
--- a/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/service/IAdminAgentActivityParticipantService.java
+++ b/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/service/IAdminAgentActivityParticipantService.java
@@ -2,6 +2,7 @@ package com.seer.teach.mp.admin.service;
import com.seer.teach.common.PageListBean;
import com.seer.teach.mp.admin.controller.req.AgentActivityParticipantQueryReq;
+import com.seer.teach.mp.admin.controller.req.AgentActivityParticipantReq;
import com.seer.teach.mp.admin.controller.resp.AdminAgentActivityParticipantResp;
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
@@ -31,7 +32,7 @@ public interface IAdminAgentActivityParticipantService {
* @param entity 参与记录实体
* @return 操作是否成功
*/
- boolean saveParticipant(MpAgentActivityParticipantEntity entity);
+ boolean saveParticipant(AgentActivityParticipantReq entity);
/**
* 更新代理商活动参与记录(管理端)
diff --git a/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/service/impl/AdminAgentActivityParticipantServiceImpl.java b/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/service/impl/AdminAgentActivityParticipantServiceImpl.java
index 103a7ea..a199344 100644
--- a/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/service/impl/AdminAgentActivityParticipantServiceImpl.java
+++ b/seer-mp/seer-mp-service-admin/src/main/java/com/seer/teach/mp/admin/service/impl/AdminAgentActivityParticipantServiceImpl.java
@@ -1,14 +1,17 @@
package com.seer.teach.mp.admin.service.impl;
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.utils.PageConverterUtils;
import com.seer.teach.mp.admin.controller.req.AgentActivityParticipantQueryReq;
+import com.seer.teach.mp.admin.controller.req.AgentActivityParticipantReq;
import com.seer.teach.mp.admin.controller.resp.AdminAgentActivityParticipantResp;
import com.seer.teach.mp.admin.convert.AdminAgentActivityParticipantConvert;
import com.seer.teach.mp.admin.service.IAdminAgentActivityParticipantService;
+import com.seer.teach.mp.entity.MpActivityEntity;
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
+import com.seer.teach.mp.entity.MpAgentEntity;
import com.seer.teach.mp.service.IMpActivityService;
import com.seer.teach.mp.service.IMpAgentActivityParticipantService;
import com.seer.teach.mp.service.IMpAgentService;
@@ -16,7 +19,6 @@ import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
-import java.util.stream.Collectors;
/**
*
@@ -42,77 +44,53 @@ public class AdminAgentActivityParticipantServiceImpl implements IAdminAgentActi
LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
// 根据活动ID查询
- if (query.getActivityId() != null) {
- wrapper.eq(MpAgentActivityParticipantEntity::getActivityId, query.getActivityId());
+ if (query.getActivityName() != null) {
+ wrapper.like(MpAgentActivityParticipantEntity::getActivityName, query.getActivityName());
}
// 根据代理商ID查询
- if (query.getAgentId() != null) {
- wrapper.eq(MpAgentActivityParticipantEntity::getAgentId, query.getAgentId());
+ if (query.getAgentName() != null) {
+ wrapper.like(MpAgentActivityParticipantEntity::getAgentName, query.getAgentName());
}
- IPage result = mpAgentActivityParticipantService.page(page, wrapper);
-
- // 转换为响应对象列表
- List respList = result.getRecords().stream()
- .map(entity -> {
- AdminAgentActivityParticipantResp resp = AdminAgentActivityParticipantConvert.INSTANCE.convertToResp(entity);
-
- // 设置代理商名称
- if (entity.getAgentId() != null) {
- var agent = mpAgentService.getAgentById(entity.getAgentId());
- if (agent != null) {
- resp.setAgentName(agent.getAgentName());
- }
- }
- // 设置活动名称
- if (entity.getActivityId() != null) {
- var activity = mpActivityService.getById(entity.getActivityId());
- if (activity != null) {
- resp.setActivityName(activity.getActivityName());
- }
- }
- return resp;
- })
- .collect(Collectors.toList());
-
- // 构建分页结果
- PageListBean pageResult = new PageListBean<>();
- pageResult.setList(respList);
- pageResult.setTotalPage(result.getCurrent());
- pageResult.setPageSize(result.getSize());
- pageResult.setTotal(result.getTotal());
- pageResult.setPage(result.getPages());
- return pageResult;
+ Page result = mpAgentActivityParticipantService.page(page, wrapper);
+ return PageConverterUtils.convertPageListBean(result, AdminAgentActivityParticipantConvert.INSTANCE::convertToRespList);
}
@Override
- public boolean saveParticipant(MpAgentActivityParticipantEntity entity) {
+ public boolean saveParticipant(AgentActivityParticipantReq entity) {
// 检查是否已存在相同的活动、代理商和家长记录
LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
- wrapper.eq(MpAgentActivityParticipantEntity::getActivityId, entity.getActivityId())
- .eq(MpAgentActivityParticipantEntity::getAgentId, entity.getAgentId());
+ wrapper.eq(MpAgentActivityParticipantEntity::getActivityName, entity.getActivityName())
+ .eq(MpAgentActivityParticipantEntity::getAgentName, entity.getAgentName());
long count = mpAgentActivityParticipantService.count(wrapper);
if (count > 0) {
throw new RuntimeException("该代理商活动参与记录已存在");
}
-
- return mpAgentActivityParticipantService.save(entity);
+ Integer agentId = mpAgentService.lambdaQuery().eq(MpAgentEntity::getAgentName, entity.getAgentName()).one().getId();
+ Integer activityId = mpActivityService.lambdaQuery().eq(MpActivityEntity::getActivityName, entity.getActivityName()).one().getId();
+ MpAgentActivityParticipantEntity result = AdminAgentActivityParticipantConvert.INSTANCE.convertToEntity(entity);
+ result.setActivityId(activityId);
+ result.setAgentId(agentId);
+ return mpAgentActivityParticipantService.save(result);
}
@Override
public boolean updateParticipant(MpAgentActivityParticipantEntity entity) {
// 检查是否存在相同的活动、代理商和家长记录(排除当前记录)
LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
- wrapper.eq(MpAgentActivityParticipantEntity::getActivityId, entity.getActivityId())
- .eq(MpAgentActivityParticipantEntity::getAgentId, entity.getAgentId())
+ wrapper.eq(MpAgentActivityParticipantEntity::getActivityName, entity.getActivityName())
+ .eq(MpAgentActivityParticipantEntity::getAgentName, entity.getAgentName())
.ne(MpAgentActivityParticipantEntity::getId, entity.getId());
long count = mpAgentActivityParticipantService.count(wrapper);
if (count > 0) {
throw new RuntimeException("该代理商活动参与记录已存在");
}
-
+ Integer agentId = mpAgentService.lambdaQuery().eq(MpAgentEntity::getAgentName, entity.getAgentName()).one().getId();
+ Integer activityId = mpActivityService.lambdaQuery().eq(MpActivityEntity::getActivityName, entity.getActivityName()).one().getId();
+ entity.setActivityId(activityId);
+ entity.setAgentId(agentId);
return mpAgentActivityParticipantService.updateById(entity);
}
@@ -125,7 +103,7 @@ public class AdminAgentActivityParticipantServiceImpl implements IAdminAgentActi
@Override
public Boolean deleteById(List ids) {
if (ids == null || ids.isEmpty()) {
- return false;
+ return false;
}
return mpAgentActivityParticipantService.removeByIds(ids);
}
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 78ca768..d19fbab 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
@@ -61,8 +61,10 @@ CREATE TABLE `mp_activity` (
DROP TABLE IF EXISTS `mp_agent_activity_participant`;
CREATE TABLE `mp_agent_activity_participant` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '参与记录ID',
- `activity_id` int NOT NULL COMMENT '活动ID',
- `agent_id` int NOT NULL COMMENT '代理商ID',
+ `agent_id` int DEFAULT NULL COMMENT '代理商ID(对应user表的ID)',
+ `activity_id` int DEFAULT NULL COMMENT '活动ID',
+ `activity_name` varchar(100) NOT NULL COMMENT '活动名称',
+ `agent_name` varchar(100) NOT NULL 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 '修改时间',
diff --git a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpActivityService.java b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpActivityService.java
index d3cef0c..a08a9ef 100644
--- a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpActivityService.java
+++ b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/IMpActivityService.java
@@ -3,6 +3,8 @@ package com.seer.teach.mp.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.seer.teach.mp.entity.MpActivityEntity;
+import java.util.List;
+
/**
*
* 代理商活动表 服务类
@@ -29,4 +31,10 @@ public interface IMpActivityService extends IService {
* @return 操作是否成功
*/
boolean deleteActivity(Integer id);
+
+ /**
+ * 获取代理商活动名称列表
+ * @return 代理商活动名称列表
+ */
+ List getActivityName();
}
\ 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 73b229f..0ac7664 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
@@ -3,6 +3,8 @@ package com.seer.teach.mp.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.seer.teach.mp.entity.MpAgentEntity;
+import java.util.List;
+
/**
* 代理商服务接口
*/
@@ -31,4 +33,10 @@ public interface IMpAgentService extends IService {
* @return 是否成功
*/
Boolean updateAgent(MpAgentEntity agentEntity);
+
+ /**
+ * 获取代理商名称列表
+ * @return 代理商名称列表
+ */
+ List getAgentName();
}
\ No newline at end of file
diff --git a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpActivityServiceImpl.java b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpActivityServiceImpl.java
index c465d6c..32af7de 100644
--- a/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpActivityServiceImpl.java
+++ b/seer-mp/seer-mp-service/src/main/java/com/seer/teach/mp/service/impl/MpActivityServiceImpl.java
@@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
+import java.util.List;
/**
*
@@ -37,73 +38,79 @@ public class MpActivityServiceImpl extends ServiceImpl participantWrapper =
- new LambdaQueryWrapper()
- .eq(MpAgentActivityParticipantEntity::getActivityId, id);
+ LambdaQueryWrapper participantWrapper =
+ new LambdaQueryWrapper()
+ .eq(MpAgentActivityParticipantEntity::getActivityId, id);
agentActivityParticipantService.remove(participantWrapper);
-
+
boolean result = this.removeById(id);
-
+
// 记录操作日志
if (result) {
String beforeData = JSONUtil.toJsonStr(existing);
String afterData = "";
String description = "删除代理商活动: " + existing.getActivityName();
-
+
agentActivityLogService.logOperation(
- id,
- existing.getCreateBy(),
- "删除",
- description,
- beforeData,
- afterData
+ id,
+ existing.getCreateBy(),
+ "删除",
+ description,
+ beforeData,
+ afterData
);
}
-
+
return result;
}
-
+
+ @Override
+ public List getActivityName() {
+ return this.list().stream()
+ .map(MpActivityEntity::getActivityName).toList();
+ }
+
@Override
public boolean saveOrUpdate(MpActivityEntity entity) {
boolean result = super.saveOrUpdate(entity);
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 50ac091..5bc4bec 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
@@ -6,6 +6,8 @@ import com.seer.teach.mp.mapper.MpAgentMapper;
import com.seer.teach.mp.service.IMpAgentService;
import org.springframework.stereotype.Service;
+import java.util.List;
+
/**
* 代理商服务实现类
*/
@@ -26,4 +28,10 @@ public class MpAgentServiceImpl extends ServiceImpl getAgentName() {
+ List list = this.list();
+ return list.stream().map(MpAgentEntity::getAgentName).toList();
+ }
}
\ No newline at end of file