增加代理商,活动,代理商员工关,代理商活动参与者相关功能
This commit is contained in:
parent
7bc6b9f2a8
commit
a1ed3f5b06
@ -1,48 +0,0 @@
|
||||
package com.seer.teach.filter.cors;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.server.RequestPath;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.reactive.CorsUtils;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.WebFilter;
|
||||
import org.springframework.web.server.WebFilterChain;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Slf4j
|
||||
// @Component
|
||||
public class CorsFilter implements WebFilter {
|
||||
|
||||
private static final String MAX_AGE = String.valueOf(1000 * 60 * 60 * 24);
|
||||
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
if (!CorsUtils.isCorsRequest(request)) {
|
||||
log.info("Not a CORS request");
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
RequestPath path = exchange.getRequest().getPath();
|
||||
log.info("request path: {},method : {}", path, request.getMethod());
|
||||
ServerHttpResponse response = exchange.getResponse();
|
||||
HttpHeaders headers = response.getHeaders();
|
||||
headers.add(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, CorsConfiguration.ALL);
|
||||
headers.add(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, CorsConfiguration.ALL);
|
||||
headers.add(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS, CorsConfiguration.ALL);
|
||||
headers.add(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, CorsConfiguration.ALL);
|
||||
headers.add(HttpHeaders.ACCESS_CONTROL_MAX_AGE, MAX_AGE);
|
||||
if (request.getMethod() == HttpMethod.OPTIONS) {
|
||||
response.setStatusCode(HttpStatus.OK);
|
||||
log.info("CORS preflight request,OK");
|
||||
return Mono.empty();
|
||||
}
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,13 +5,10 @@ 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 lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -21,8 +18,7 @@ import java.util.Set;
|
||||
* @author Lingma
|
||||
* @since 2025-12-30
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Data
|
||||
@TableName("mp_activity_info_collection")
|
||||
@Schema(name = "MpActivityInfoCollectionEntity对象", description = "活动信息收集表")
|
||||
public class MpActivityInfoCollectionEntity extends BaseEntity {
|
||||
|
||||
@ -19,7 +19,7 @@ import java.time.LocalDateTime;
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("mp_parent_agent_activity_relations")
|
||||
@TableName("mp_parent_agent_activity_relation")
|
||||
@Schema(name = "MpParentAgentActivityRelationEntity对象", description = "家长参与代理商活动关系表")
|
||||
public class MpParentAgentActivityRelationEntity extends BaseEntity {
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ spring:
|
||||
- optional:nacos:shared-database.yaml
|
||||
- optional:nacos:shared-redis.yaml
|
||||
- optional:nacos:shared-sa-token.yaml
|
||||
- optional:nacos:shared-minio.yaml
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
|
||||
@ -2,21 +2,23 @@ package com.seer.teach.mp.app.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
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;
|
||||
import com.seer.teach.common.annotation.EncryptionAnnotation;
|
||||
import com.seer.teach.common.annotation.LogPrint;
|
||||
import com.seer.teach.mp.app.controller.req.AgentActivityParentQueryReq;
|
||||
import com.seer.teach.mp.app.controller.resp.AgentActivityParentInfoResp;
|
||||
import com.seer.teach.mp.app.service.IAppAgentActivityParentInfoService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -38,12 +40,10 @@ public class AppAgentActivityParentInfoController {
|
||||
private final IAppAgentActivityParentInfoService agentActivityParentInfoService;
|
||||
|
||||
@Operation(summary = "获取参加指定活动的家长列表")
|
||||
@GetMapping("/getActivityParents")
|
||||
@PostMapping("/page-list")
|
||||
@SaCheckLogin
|
||||
public ResultBean<List<AgentActivityParentInfoResp>> getActivityParents(
|
||||
@RequestParam("activityId") Integer activityId,
|
||||
@RequestParam("agentId") Integer agentId) {
|
||||
public ResultBean<PageListBean<AgentActivityParentInfoResp>> getActivityParents(@RequestBody @Valid AgentActivityParentQueryReq queryReq) {
|
||||
Integer userId = StpUtil.getLoginIdAsInt();
|
||||
return ResultBean.success(agentActivityParentInfoService.getParentsByActivityAndAgent(activityId, agentId,userId));
|
||||
return ResultBean.success(agentActivityParentInfoService.getParentsByActivityAndAgent(userId, queryReq));
|
||||
}
|
||||
}
|
||||
@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
/**
|
||||
* 家长参与代理商活动控制器 - 应用端
|
||||
*/
|
||||
@Tag(name = "应用端 - 家长参与代理商活动管理")
|
||||
@Tag(name = "App - 家长参与代理商活动管理")
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/app/parent/agent/activity")
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
package com.seer.teach.mp.app.controller.req;
|
||||
|
||||
import com.seer.teach.common.request.PageRequest;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(name = "AgentActivityParentQueryReq", description = "代理商活动家长查询请求参数")
|
||||
@Data
|
||||
public class AgentActivityParentQueryReq extends PageRequest {
|
||||
|
||||
@Schema(description = "活动ID")
|
||||
private Integer activityId;
|
||||
|
||||
@Schema(description = "代理商ID")
|
||||
private Integer agentId;
|
||||
}
|
||||
@ -5,7 +5,6 @@ import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(name = "AppMpSignUpActivityReq", description = "家长报名参加代理商活动Req")
|
||||
@Data
|
||||
|
||||
@ -3,7 +3,7 @@ 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.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
@ -11,7 +11,18 @@ public interface AppMpActivityInfoCollectionConvert {
|
||||
|
||||
AppMpActivityInfoCollectionConvert INSTANCE = Mappers.getMapper(AppMpActivityInfoCollectionConvert.class);
|
||||
|
||||
/**
|
||||
* 实体转换成响应参数
|
||||
* @param entity 实体
|
||||
* @return 响应参数
|
||||
*/
|
||||
AppMpSignUpActivityResp convert2Resp(MpActivityInfoCollectionEntity entity);
|
||||
|
||||
MpActivityInfoCollectionEntity convert2Entity(AppMpSignUpActivityReq request);
|
||||
|
||||
/**
|
||||
* 请求参数转换成实体
|
||||
* @param request 请求参数
|
||||
* @return 实体
|
||||
*/
|
||||
MpActivityInfoCollectionEntity convertOne2Entity(AppMpSignUpActivityReq request);
|
||||
}
|
||||
@ -19,6 +19,7 @@ import com.seer.teach.mp.service.IMpParentAgentActivityRelationService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
@ -41,6 +42,7 @@ public class AppParentAgentActivityService {
|
||||
* @param parentId 家长ID
|
||||
* @return true表示成功,false表示失败
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class,timeout = 120)
|
||||
public boolean signUpForActivityWithInfo(AppMpSignUpActivityReq request, Integer parentId) {
|
||||
Integer agentId = request.getAgentId();
|
||||
Integer activityId = request.getActivityId();
|
||||
@ -68,7 +70,7 @@ public class AppParentAgentActivityService {
|
||||
log.info("报名结果:{},关系ID:{}", saved, relation.getId());
|
||||
|
||||
if(saved){
|
||||
MpActivityInfoCollectionEntity mpActivityInfoCollectionEntity = AppMpActivityInfoCollectionConvert.INSTANCE.convert2Entity(request);
|
||||
MpActivityInfoCollectionEntity mpActivityInfoCollectionEntity = AppMpActivityInfoCollectionConvert.INSTANCE.convertOne2Entity(request);
|
||||
mpActivityInfoCollectionEntity.setRelationId(relation.getId());
|
||||
boolean activityInfoCollectionResult = activityInfoCollectionService.save(mpActivityInfoCollectionEntity);
|
||||
log.info("活动信息收集结果:{}", activityInfoCollectionResult);
|
||||
@ -89,8 +91,7 @@ public class AppParentAgentActivityService {
|
||||
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 mpActivityInfoCollectionEntity = AppMpActivityInfoCollectionConvert.INSTANCE.convertOne2Entity(request);
|
||||
mpActivityInfoCollectionEntity.setRelationId(relation.getId());
|
||||
return activityInfoCollectionService.updateById(mpActivityInfoCollectionEntity);
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.seer.teach.mp.app.service;
|
||||
|
||||
import com.seer.teach.common.PageListBean;
|
||||
import com.seer.teach.mp.app.controller.req.AgentActivityParentQueryReq;
|
||||
import com.seer.teach.mp.app.controller.resp.AgentActivityParentInfoResp;
|
||||
|
||||
import java.util.List;
|
||||
@ -23,4 +25,12 @@ public interface IAppAgentActivityParentInfoService {
|
||||
* @return 参与活动的家长信息列表
|
||||
*/
|
||||
List<AgentActivityParentInfoResp> getParentsByActivityAndAgent(Integer activityId, Integer agentId,Integer userId);
|
||||
|
||||
/**
|
||||
* 分页获取参加指定活动的家长信息列表
|
||||
*
|
||||
* @param queryReq 查询请求参数
|
||||
* @return 分页的家长信息列表
|
||||
*/
|
||||
PageListBean<AgentActivityParentInfoResp> getParentsByActivityAndAgent(Integer userId,AgentActivityParentQueryReq queryReq);
|
||||
}
|
||||
@ -1,8 +1,12 @@
|
||||
package com.seer.teach.mp.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.seer.teach.common.PageListBean;
|
||||
import com.seer.teach.common.enums.ResultCodeEnum;
|
||||
import com.seer.teach.common.exception.CommonException;
|
||||
import com.seer.teach.common.utils.PageConverterUtils;
|
||||
import com.seer.teach.mp.app.controller.req.AgentActivityParentQueryReq;
|
||||
import com.seer.teach.mp.app.controller.resp.AgentActivityParentInfoResp;
|
||||
import com.seer.teach.mp.app.service.IAppAgentActivityParentInfoService;
|
||||
import com.seer.teach.mp.app.service.IAppAgentService;
|
||||
@ -55,6 +59,31 @@ public class AppAgentActivityParentInfoServiceImpl implements IAppAgentActivityP
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageListBean<AgentActivityParentInfoResp> getParentsByActivityAndAgent(Integer userId,AgentActivityParentQueryReq queryReq) {
|
||||
var userAgentId = appAgentService.getAgentIdByUserId(userId);
|
||||
if (Objects.isNull(userAgentId)) {
|
||||
return new PageListBean<>();
|
||||
}
|
||||
log.info("userAgentId:{}", userAgentId);
|
||||
if(userAgentId.intValue() != queryReq.getAgentId()){
|
||||
throw new CommonException(ResultCodeEnum.RELATION_NOT_FOUND);
|
||||
}
|
||||
// 创建分页对象
|
||||
Page<MpActivityInfoCollectionEntity> page = new Page<>(queryReq.getPageNo(), queryReq.getPageSize());
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<MpActivityInfoCollectionEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MpActivityInfoCollectionEntity::getActivityId, queryReq.getActivityId())
|
||||
.eq(MpActivityInfoCollectionEntity::getAgentId, userAgentId);
|
||||
|
||||
// 执行分页查询
|
||||
Page<MpActivityInfoCollectionEntity> pageResult = activityInfoCollectionService.page(page, queryWrapper);
|
||||
|
||||
// 返回分页结果
|
||||
return PageConverterUtils.convertPageList(pageResult,this::convertToResp);
|
||||
}
|
||||
|
||||
private AgentActivityParentInfoResp convertToResp(MpActivityInfoCollectionEntity entity) {
|
||||
AgentActivityParentInfoResp resp = new AgentActivityParentInfoResp();
|
||||
resp.setId(entity.getId());
|
||||
|
||||
@ -22,6 +22,7 @@ spring:
|
||||
- optional:nacos:shared-database.yaml
|
||||
- optional:nacos:shared-redis.yaml
|
||||
- optional:nacos:shared-sa-token.yaml
|
||||
- optional:nacos:shared-minio.yaml
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user