fix:修改活动参与管理的新增和修改详情接口更改

This commit is contained in:
嘉多宝宝 2026-01-06 18:25:05 +08:00
parent 067dbdd58c
commit 1a33d1cef2
13 changed files with 157 additions and 86 deletions

View File

@ -109,6 +109,10 @@
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -28,8 +28,20 @@ public class MpAgentActivityParticipantEntity extends BaseEntity {
private Integer activityId; private Integer activityId;
/** /**
* 代理商ID对应user表的ID * 代理商ID
*/ */
@TableField("agent_id") @TableField("agent_id")
private Integer agentId; private Integer agentId;
/**
* 活动名称
*/
@TableField("activity_name")
private String activityName;
/**
* 代理商名称
*/
@TableField("agent_name")
private String agentName;
} }

View File

@ -5,12 +5,16 @@ import com.seer.teach.common.PageListBean;
import com.seer.teach.common.ResultBean; import com.seer.teach.common.ResultBean;
import com.seer.teach.common.annotation.LogPrint; import com.seer.teach.common.annotation.LogPrint;
import com.seer.teach.mp.admin.controller.req.AgentActivityParticipantQueryReq; 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.controller.resp.AdminAgentActivityParticipantResp;
import com.seer.teach.mp.admin.service.IAdminAgentActivityParticipantService; import com.seer.teach.mp.admin.service.IAdminAgentActivityParticipantService;
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity; import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
import com.seer.teach.mp.service.IMpActivityService;
import com.seer.teach.mp.service.IMpAgentService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
@ -24,6 +28,10 @@ public class AdminAgentActivityParticipantController {
private final IAdminAgentActivityParticipantService adminAgentActivityParticipantService; private final IAdminAgentActivityParticipantService adminAgentActivityParticipantService;
private final IMpAgentService mpAgentService;
private final IMpActivityService mpActivityService;
@Operation(summary = "代理商活动参与记录列表") @Operation(summary = "代理商活动参与记录列表")
@GetMapping("/page-list") @GetMapping("/page-list")
@SaCheckPermission("mp:admin:agent:activity:participant:list") @SaCheckPermission("mp:admin:agent:activity:participant:list")
@ -41,8 +49,8 @@ public class AdminAgentActivityParticipantController {
@Operation(summary = "新增") @Operation(summary = "新增")
@PostMapping @PostMapping
@SaCheckPermission("mp:admin:agent:activity:participant:save") @SaCheckPermission("mp:admin:agent:activity:participant:save")
public ResultBean<Boolean> save(@RequestBody MpAgentActivityParticipantEntity participantEntity) { public ResultBean<Boolean> save(@RequestBody @Validated AgentActivityParticipantReq req) {
return ResultBean.success(adminAgentActivityParticipantService.saveParticipant(participantEntity)); return ResultBean.success(adminAgentActivityParticipantService.saveParticipant(req));
} }
@Operation(summary = "更新") @Operation(summary = "更新")
@ -58,4 +66,17 @@ public class AdminAgentActivityParticipantController {
public ResultBean<Boolean> delete(@RequestBody List<Integer> ids) { public ResultBean<Boolean> delete(@RequestBody List<Integer> ids) {
return ResultBean.success(adminAgentActivityParticipantService.deleteById(ids)); return ResultBean.success(adminAgentActivityParticipantService.deleteById(ids));
} }
@Operation(summary = "查询代理商名称")
@GetMapping("/agent-name")
public ResultBean<List<String>> getAgentName() {
return ResultBean.success(mpAgentService.getAgentName());
}
@Operation(summary = "查询活动名称")
@GetMapping("/activity-name")
public ResultBean<List<String>> getActivityName() {
return ResultBean.success(mpActivityService.getActivityName());
}
} }

View File

@ -22,9 +22,9 @@ public class AgentActivityParticipantQueryReq {
@Schema(description = "每页数量") @Schema(description = "每页数量")
private Integer pageSize = 10; private Integer pageSize = 10;
@Schema(description = "活动ID") @Schema(description = "活动名称")
private Integer activityId; private String activityName;
@Schema(description = "代理商ID") @Schema(description = "代理商名称")
private Integer agentId; private String agentName;
} }

View File

@ -0,0 +1,18 @@
package com.seer.teach.mp.admin.controller.req;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
@Data
@Schema(name = "代理商活动参与请求对象")
public class AgentActivityParticipantReq {
@Schema(description = "代理商名称")
@NotBlank(message = "代理商名称不能为空")
private String agentName;
@Schema(description = "活动名称")
@NotBlank(message = "活动名称不能为空")
private String activityName;
}

View File

@ -1,5 +1,6 @@
package com.seer.teach.mp.admin.convert; package com.seer.teach.mp.admin.convert;
import com.seer.teach.mp.admin.controller.req.AgentActivityParticipantReq;
import com.seer.teach.mp.admin.controller.resp.AdminAgentActivityParticipantResp; import com.seer.teach.mp.admin.controller.resp.AdminAgentActivityParticipantResp;
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity; import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
@ -15,4 +16,7 @@ public interface AdminAgentActivityParticipantConvert {
AdminAgentActivityParticipantResp convertToResp(MpAgentActivityParticipantEntity entity); AdminAgentActivityParticipantResp convertToResp(MpAgentActivityParticipantEntity entity);
List<AdminAgentActivityParticipantResp> convertToRespList(List<MpAgentActivityParticipantEntity> entity); List<AdminAgentActivityParticipantResp> convertToRespList(List<MpAgentActivityParticipantEntity> entity);
MpAgentActivityParticipantEntity convertToEntity(AgentActivityParticipantReq entity);
} }

View File

@ -2,6 +2,7 @@ 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.AgentActivityParticipantQueryReq; 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.controller.resp.AdminAgentActivityParticipantResp;
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity; import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
@ -31,7 +32,7 @@ public interface IAdminAgentActivityParticipantService {
* @param entity 参与记录实体 * @param entity 参与记录实体
* @return 操作是否成功 * @return 操作是否成功
*/ */
boolean saveParticipant(MpAgentActivityParticipantEntity entity); boolean saveParticipant(AgentActivityParticipantReq entity);
/** /**
* 更新代理商活动参与记录管理端 * 更新代理商活动参与记录管理端

View File

@ -1,14 +1,17 @@
package com.seer.teach.mp.admin.service.impl; package com.seer.teach.mp.admin.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.seer.teach.common.PageListBean; 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.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.controller.resp.AdminAgentActivityParticipantResp;
import com.seer.teach.mp.admin.convert.AdminAgentActivityParticipantConvert; import com.seer.teach.mp.admin.convert.AdminAgentActivityParticipantConvert;
import com.seer.teach.mp.admin.service.IAdminAgentActivityParticipantService; 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.MpAgentActivityParticipantEntity;
import com.seer.teach.mp.entity.MpAgentEntity;
import com.seer.teach.mp.service.IMpActivityService; import com.seer.teach.mp.service.IMpActivityService;
import com.seer.teach.mp.service.IMpAgentActivityParticipantService; import com.seer.teach.mp.service.IMpAgentActivityParticipantService;
import com.seer.teach.mp.service.IMpAgentService; import com.seer.teach.mp.service.IMpAgentService;
@ -16,7 +19,6 @@ import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
@ -42,77 +44,53 @@ public class AdminAgentActivityParticipantServiceImpl implements IAdminAgentActi
LambdaQueryWrapper<MpAgentActivityParticipantEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<MpAgentActivityParticipantEntity> wrapper = new LambdaQueryWrapper<>();
// 根据活动ID查询 // 根据活动ID查询
if (query.getActivityId() != null) { if (query.getActivityName() != null) {
wrapper.eq(MpAgentActivityParticipantEntity::getActivityId, query.getActivityId()); wrapper.like(MpAgentActivityParticipantEntity::getActivityName, query.getActivityName());
} }
// 根据代理商ID查询 // 根据代理商ID查询
if (query.getAgentId() != null) { if (query.getAgentName() != null) {
wrapper.eq(MpAgentActivityParticipantEntity::getAgentId, query.getAgentId()); wrapper.like(MpAgentActivityParticipantEntity::getAgentName, query.getAgentName());
} }
IPage<MpAgentActivityParticipantEntity> result = mpAgentActivityParticipantService.page(page, wrapper); Page<MpAgentActivityParticipantEntity> result = mpAgentActivityParticipantService.page(page, wrapper);
return PageConverterUtils.convertPageListBean(result, AdminAgentActivityParticipantConvert.INSTANCE::convertToRespList);
// 转换为响应对象列表
List<AdminAgentActivityParticipantResp> 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<AdminAgentActivityParticipantResp> pageResult = new PageListBean<>();
pageResult.setList(respList);
pageResult.setTotalPage(result.getCurrent());
pageResult.setPageSize(result.getSize());
pageResult.setTotal(result.getTotal());
pageResult.setPage(result.getPages());
return pageResult;
} }
@Override @Override
public boolean saveParticipant(MpAgentActivityParticipantEntity entity) { public boolean saveParticipant(AgentActivityParticipantReq entity) {
// 检查是否已存在相同的活动代理商和家长记录 // 检查是否已存在相同的活动代理商和家长记录
LambdaQueryWrapper<MpAgentActivityParticipantEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<MpAgentActivityParticipantEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MpAgentActivityParticipantEntity::getActivityId, entity.getActivityId()) wrapper.eq(MpAgentActivityParticipantEntity::getActivityName, entity.getActivityName())
.eq(MpAgentActivityParticipantEntity::getAgentId, entity.getAgentId()); .eq(MpAgentActivityParticipantEntity::getAgentName, entity.getAgentName());
long count = mpAgentActivityParticipantService.count(wrapper); long count = mpAgentActivityParticipantService.count(wrapper);
if (count > 0) { if (count > 0) {
throw new RuntimeException("该代理商活动参与记录已存在"); throw new RuntimeException("该代理商活动参与记录已存在");
} }
Integer agentId = mpAgentService.lambdaQuery().eq(MpAgentEntity::getAgentName, entity.getAgentName()).one().getId();
return mpAgentActivityParticipantService.save(entity); 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 @Override
public boolean updateParticipant(MpAgentActivityParticipantEntity entity) { public boolean updateParticipant(MpAgentActivityParticipantEntity entity) {
// 检查是否存在相同的活动代理商和家长记录排除当前记录 // 检查是否存在相同的活动代理商和家长记录排除当前记录
LambdaQueryWrapper<MpAgentActivityParticipantEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<MpAgentActivityParticipantEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MpAgentActivityParticipantEntity::getActivityId, entity.getActivityId()) wrapper.eq(MpAgentActivityParticipantEntity::getActivityName, entity.getActivityName())
.eq(MpAgentActivityParticipantEntity::getAgentId, entity.getAgentId()) .eq(MpAgentActivityParticipantEntity::getAgentName, entity.getAgentName())
.ne(MpAgentActivityParticipantEntity::getId, entity.getId()); .ne(MpAgentActivityParticipantEntity::getId, entity.getId());
long count = mpAgentActivityParticipantService.count(wrapper); long count = mpAgentActivityParticipantService.count(wrapper);
if (count > 0) { if (count > 0) {
throw new RuntimeException("该代理商活动参与记录已存在"); 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); return mpAgentActivityParticipantService.updateById(entity);
} }
@ -125,7 +103,7 @@ public class AdminAgentActivityParticipantServiceImpl implements IAdminAgentActi
@Override @Override
public Boolean deleteById(List<Integer> ids) { public Boolean deleteById(List<Integer> ids) {
if (ids == null || ids.isEmpty()) { if (ids == null || ids.isEmpty()) {
return false; return false;
} }
return mpAgentActivityParticipantService.removeByIds(ids); return mpAgentActivityParticipantService.removeByIds(ids);
} }

View File

@ -61,8 +61,10 @@ CREATE TABLE `mp_activity` (
DROP TABLE IF EXISTS `mp_agent_activity_participant`; DROP TABLE IF EXISTS `mp_agent_activity_participant`;
CREATE TABLE `mp_agent_activity_participant` ( CREATE TABLE `mp_agent_activity_participant` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '参与记录ID', `id` int NOT NULL AUTO_INCREMENT COMMENT '参与记录ID',
`activity_id` int NOT NULL COMMENT '活动ID', `agent_id` int DEFAULT NULL COMMENT '代理商ID对应user表的ID',
`agent_id` int NOT NULL COMMENT '代理商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_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL 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_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',

View File

@ -3,6 +3,8 @@ package com.seer.teach.mp.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.seer.teach.mp.entity.MpActivityEntity; import com.seer.teach.mp.entity.MpActivityEntity;
import java.util.List;
/** /**
* <p> * <p>
* 代理商活动表 服务类 * 代理商活动表 服务类
@ -29,4 +31,10 @@ public interface IMpActivityService extends IService<MpActivityEntity> {
* @return 操作是否成功 * @return 操作是否成功
*/ */
boolean deleteActivity(Integer id); boolean deleteActivity(Integer id);
/**
* 获取代理商活动名称列表
* @return 代理商活动名称列表
*/
List<String> getActivityName();
} }

View File

@ -3,6 +3,8 @@ package com.seer.teach.mp.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.seer.teach.mp.entity.MpAgentEntity; import com.seer.teach.mp.entity.MpAgentEntity;
import java.util.List;
/** /**
* 代理商服务接口 * 代理商服务接口
*/ */
@ -31,4 +33,10 @@ public interface IMpAgentService extends IService<MpAgentEntity> {
* @return 是否成功 * @return 是否成功
*/ */
Boolean updateAgent(MpAgentEntity agentEntity); Boolean updateAgent(MpAgentEntity agentEntity);
/**
* 获取代理商名称列表
* @return 代理商名称列表
*/
List<String> getAgentName();
} }

View File

@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
/** /**
* <p> * <p>
@ -59,12 +60,12 @@ public class MpActivityServiceImpl extends ServiceImpl<MpAgentActivityMapper, Mp
String description = operationType + "代理商活动: " + entity.getActivityName(); String description = operationType + "代理商活动: " + entity.getActivityName();
agentActivityLogService.logOperation( agentActivityLogService.logOperation(
entity.getId(), entity.getId(),
entity.getCreateBy(), entity.getCreateBy(),
operationType, operationType,
description, description,
beforeData, beforeData,
afterData afterData
); );
} }
@ -79,8 +80,8 @@ public class MpActivityServiceImpl extends ServiceImpl<MpAgentActivityMapper, Mp
// 删除活动前先删除相关的参与记录 // 删除活动前先删除相关的参与记录
LambdaQueryWrapper<MpAgentActivityParticipantEntity> participantWrapper = LambdaQueryWrapper<MpAgentActivityParticipantEntity> participantWrapper =
new LambdaQueryWrapper<MpAgentActivityParticipantEntity>() new LambdaQueryWrapper<MpAgentActivityParticipantEntity>()
.eq(MpAgentActivityParticipantEntity::getActivityId, id); .eq(MpAgentActivityParticipantEntity::getActivityId, id);
agentActivityParticipantService.remove(participantWrapper); agentActivityParticipantService.remove(participantWrapper);
boolean result = this.removeById(id); boolean result = this.removeById(id);
@ -92,18 +93,24 @@ public class MpActivityServiceImpl extends ServiceImpl<MpAgentActivityMapper, Mp
String description = "删除代理商活动: " + existing.getActivityName(); String description = "删除代理商活动: " + existing.getActivityName();
agentActivityLogService.logOperation( agentActivityLogService.logOperation(
id, id,
existing.getCreateBy(), existing.getCreateBy(),
"删除", "删除",
description, description,
beforeData, beforeData,
afterData afterData
); );
} }
return result; return result;
} }
@Override
public List<String> getActivityName() {
return this.list().stream()
.map(MpActivityEntity::getActivityName).toList();
}
@Override @Override
public boolean saveOrUpdate(MpActivityEntity entity) { public boolean saveOrUpdate(MpActivityEntity entity) {
boolean result = super.saveOrUpdate(entity); boolean result = super.saveOrUpdate(entity);

View File

@ -6,6 +6,8 @@ import com.seer.teach.mp.mapper.MpAgentMapper;
import com.seer.teach.mp.service.IMpAgentService; import com.seer.teach.mp.service.IMpAgentService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* 代理商服务实现类 * 代理商服务实现类
*/ */
@ -26,4 +28,10 @@ public class MpAgentServiceImpl extends ServiceImpl<MpAgentMapper, MpAgentEntity
public Boolean updateAgent(MpAgentEntity agentEntity) { public Boolean updateAgent(MpAgentEntity agentEntity) {
return this.updateById(agentEntity); return this.updateById(agentEntity);
} }
@Override
public List<String> getAgentName() {
List<MpAgentEntity> list = this.list();
return list.stream().map(MpAgentEntity::getAgentName).toList();
}
} }