fix:修改活动参与管理的新增和修改详情接口更改
This commit is contained in:
parent
067dbdd58c
commit
1a33d1cef2
@ -109,6 +109,10 @@
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -28,8 +28,20 @@ public class MpAgentActivityParticipantEntity extends BaseEntity {
|
||||
private Integer activityId;
|
||||
|
||||
/**
|
||||
* 代理商ID(对应user表的ID)
|
||||
* 代理商ID
|
||||
*/
|
||||
@TableField("agent_id")
|
||||
private Integer agentId;
|
||||
|
||||
/**
|
||||
* 活动名称
|
||||
*/
|
||||
@TableField("activity_name")
|
||||
private String activityName;
|
||||
|
||||
/**
|
||||
* 代理商名称
|
||||
*/
|
||||
@TableField("agent_name")
|
||||
private String agentName;
|
||||
}
|
||||
@ -5,12 +5,16 @@ import com.seer.teach.common.PageListBean;
|
||||
import com.seer.teach.common.ResultBean;
|
||||
import com.seer.teach.common.annotation.LogPrint;
|
||||
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.service.IAdminAgentActivityParticipantService;
|
||||
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.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@ -24,6 +28,10 @@ public class AdminAgentActivityParticipantController {
|
||||
|
||||
private final IAdminAgentActivityParticipantService adminAgentActivityParticipantService;
|
||||
|
||||
private final IMpAgentService mpAgentService;
|
||||
|
||||
private final IMpActivityService mpActivityService;
|
||||
|
||||
@Operation(summary = "代理商活动参与记录列表")
|
||||
@GetMapping("/page-list")
|
||||
@SaCheckPermission("mp:admin:agent:activity:participant:list")
|
||||
@ -41,8 +49,8 @@ public class AdminAgentActivityParticipantController {
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping
|
||||
@SaCheckPermission("mp:admin:agent:activity:participant:save")
|
||||
public ResultBean<Boolean> save(@RequestBody MpAgentActivityParticipantEntity participantEntity) {
|
||||
return ResultBean.success(adminAgentActivityParticipantService.saveParticipant(participantEntity));
|
||||
public ResultBean<Boolean> save(@RequestBody @Validated AgentActivityParticipantReq req) {
|
||||
return ResultBean.success(adminAgentActivityParticipantService.saveParticipant(req));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新")
|
||||
@ -58,4 +66,17 @@ public class AdminAgentActivityParticipantController {
|
||||
public ResultBean<Boolean> delete(@RequestBody List<Integer> 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());
|
||||
}
|
||||
}
|
||||
@ -22,9 +22,9 @@ public class AgentActivityParticipantQueryReq {
|
||||
@Schema(description = "每页数量")
|
||||
private Integer pageSize = 10;
|
||||
|
||||
@Schema(description = "活动ID")
|
||||
private Integer activityId;
|
||||
@Schema(description = "活动名称")
|
||||
private String activityName;
|
||||
|
||||
@Schema(description = "代理商ID")
|
||||
private Integer agentId;
|
||||
@Schema(description = "代理商名称")
|
||||
private String agentName;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
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.entity.MpAgentActivityParticipantEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
@ -15,4 +16,7 @@ public interface AdminAgentActivityParticipantConvert {
|
||||
AdminAgentActivityParticipantResp convertToResp(MpAgentActivityParticipantEntity entity);
|
||||
|
||||
List<AdminAgentActivityParticipantResp> convertToRespList(List<MpAgentActivityParticipantEntity> entity);
|
||||
|
||||
|
||||
MpAgentActivityParticipantEntity convertToEntity(AgentActivityParticipantReq entity);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
/**
|
||||
* 更新代理商活动参与记录(管理端)
|
||||
|
||||
@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -42,77 +44,53 @@ public class AdminAgentActivityParticipantServiceImpl implements IAdminAgentActi
|
||||
|
||||
LambdaQueryWrapper<MpAgentActivityParticipantEntity> 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<MpAgentActivityParticipantEntity> result = mpAgentActivityParticipantService.page(page, wrapper);
|
||||
|
||||
// 转换为响应对象列表
|
||||
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;
|
||||
Page<MpAgentActivityParticipantEntity> result = mpAgentActivityParticipantService.page(page, wrapper);
|
||||
return PageConverterUtils.convertPageListBean(result, AdminAgentActivityParticipantConvert.INSTANCE::convertToRespList);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean saveParticipant(MpAgentActivityParticipantEntity entity) {
|
||||
public boolean saveParticipant(AgentActivityParticipantReq entity) {
|
||||
// 检查是否已存在相同的活动、代理商和家长记录
|
||||
LambdaQueryWrapper<MpAgentActivityParticipantEntity> 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<MpAgentActivityParticipantEntity> 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);
|
||||
}
|
||||
|
||||
|
||||
@ -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 '修改时间',
|
||||
|
||||
@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代理商活动表 服务类
|
||||
@ -29,4 +31,10 @@ public interface IMpActivityService extends IService<MpActivityEntity> {
|
||||
* @return 操作是否成功
|
||||
*/
|
||||
boolean deleteActivity(Integer id);
|
||||
|
||||
/**
|
||||
* 获取代理商活动名称列表
|
||||
* @return 代理商活动名称列表
|
||||
*/
|
||||
List<String> getActivityName();
|
||||
}
|
||||
@ -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<MpAgentEntity> {
|
||||
* @return 是否成功
|
||||
*/
|
||||
Boolean updateAgent(MpAgentEntity agentEntity);
|
||||
|
||||
/**
|
||||
* 获取代理商名称列表
|
||||
* @return 代理商名称列表
|
||||
*/
|
||||
List<String> getAgentName();
|
||||
}
|
||||
@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -104,6 +105,12 @@ public class MpActivityServiceImpl extends ServiceImpl<MpAgentActivityMapper, Mp
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getActivityName() {
|
||||
return this.list().stream()
|
||||
.map(MpActivityEntity::getActivityName).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveOrUpdate(MpActivityEntity entity) {
|
||||
boolean result = super.saveOrUpdate(entity);
|
||||
|
||||
@ -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<MpAgentMapper, MpAgentEntity
|
||||
public Boolean updateAgent(MpAgentEntity agentEntity) {
|
||||
return this.updateById(agentEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAgentName() {
|
||||
List<MpAgentEntity> list = this.list();
|
||||
return list.stream().map(MpAgentEntity::getAgentName).toList();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user