Compare commits
11 Commits
54728dec3e
...
29da542823
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29da542823 | ||
| e2fdadae2f | |||
| 6b9b01d6e5 | |||
| 7ccea276e8 | |||
| 461b830d33 | |||
| dbe8e28237 | |||
| 543f972c5c | |||
| 9e733f71ff | |||
| 935c4cd828 | |||
| a1ed3f5b06 | |||
| 7bc6b9f2a8 |
@ -1,4 +1,4 @@
|
|||||||
package com.seer.teach.common.config;
|
package com.seer.teach.admin.config;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
@ -24,6 +24,8 @@ spring:
|
|||||||
- optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml
|
- optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml
|
||||||
- optional:nacos:shared-database.yaml
|
- optional:nacos:shared-database.yaml
|
||||||
- optional:nacos:shared-redis.yaml
|
- optional:nacos:shared-redis.yaml
|
||||||
|
- optional:nacos:shared-sa-token.yaml
|
||||||
|
- optional:nacos:shared-minio.yaml
|
||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
|
|||||||
@ -58,5 +58,10 @@
|
|||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-redis</artifactId>
|
<artifactId>spring-data-redis</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.dev33</groupId>
|
||||||
|
<artifactId>sa-token-redis-template</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@ -30,6 +30,7 @@ public enum ResultCodeEnum {
|
|||||||
USER_MOBILE_EXIST(1002, "该账号号已经被注册"),
|
USER_MOBILE_EXIST(1002, "该账号号已经被注册"),
|
||||||
PHONE_IS_REPEAT(1009, "账号已被注册,请重新输入"),
|
PHONE_IS_REPEAT(1009, "账号已被注册,请重新输入"),
|
||||||
USER_NOT_FOUND(1003, "用户不存在"),
|
USER_NOT_FOUND(1003, "用户不存在"),
|
||||||
|
USER_SAVE_ERROR(10031, "用户保存失败"),
|
||||||
USER_PERMISSION_DENIED_ERROR(1004, "用户权限不足"),
|
USER_PERMISSION_DENIED_ERROR(1004, "用户权限不足"),
|
||||||
PLEASE_LOGIN(1005, "请先登录"),
|
PLEASE_LOGIN(1005, "请先登录"),
|
||||||
USERNAME_IS_REPEAT(1006, "用户名重复"),
|
USERNAME_IS_REPEAT(1006, "用户名重复"),
|
||||||
@ -328,6 +329,7 @@ public enum ResultCodeEnum {
|
|||||||
INVALID_AGENT(13004, "代理商不存在或已失效"),
|
INVALID_AGENT(13004, "代理商不存在或已失效"),
|
||||||
AGENT_STATUS_INVALID(13005, "代理商状态无效"),
|
AGENT_STATUS_INVALID(13005, "代理商状态无效"),
|
||||||
AGENT_EMPLOYEE_ALREADY_EXISTS(130051, "代理商员工已存在"),
|
AGENT_EMPLOYEE_ALREADY_EXISTS(130051, "代理商员工已存在"),
|
||||||
|
AGENT_EMPLOYEE_NOT_FOUND(130052, "代理商员工不存在"),
|
||||||
AGENT_CONTACT_INFO_INVALID(13006, "联系信息无效"),
|
AGENT_CONTACT_INFO_INVALID(13006, "联系信息无效"),
|
||||||
AGENT_NON_PARTICIPANT_ACTIVE(130061, "代理商没有参与该活动"),
|
AGENT_NON_PARTICIPANT_ACTIVE(130061, "代理商没有参与该活动"),
|
||||||
ACTIVITY_NOT_FOUND(13007, "活动不存在"),
|
ACTIVITY_NOT_FOUND(13007, "活动不存在"),
|
||||||
@ -337,7 +339,11 @@ public enum ResultCodeEnum {
|
|||||||
PARENT_NOT_FOUND(13011, "家长不存在"),
|
PARENT_NOT_FOUND(13011, "家长不存在"),
|
||||||
INVALID_ACTIVITY_STATUS(13012, "无效的活动状态"),
|
INVALID_ACTIVITY_STATUS(13012, "无效的活动状态"),
|
||||||
AGENT_NOT_FOUND(13013, "代理商不存在"),
|
AGENT_NOT_FOUND(13013, "代理商不存在"),
|
||||||
PARENT_ALREADY_SIGN_UP(130121, "已经报名参加该活动");
|
AGENT_IS_EXISTS(13014, "代理商已存在"),
|
||||||
|
PARENT_ALREADY_SIGN_UP(130121, "已经报名参加该活动"),
|
||||||
|
UNAUTHORIZED_UPDATE_EMPLOYEE(13013, "无权限更新员工信息"),
|
||||||
|
DATA_REPEAT_ERROR(130014, "数据重复"),
|
||||||
|
DATA_NOT_EXIST(130015, "数据不存在");
|
||||||
|
|
||||||
private int code;
|
private int code;
|
||||||
private String msg;
|
private String msg;
|
||||||
|
|||||||
@ -45,7 +45,12 @@ public enum RoleEnum implements ArrayValuable<String> {
|
|||||||
/**
|
/**
|
||||||
* 访客
|
* 访客
|
||||||
*/
|
*/
|
||||||
GUEST("GUEST", "GUEST", "访客"),;
|
GUEST("GUEST", "GUEST", "访客"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理商
|
||||||
|
*/
|
||||||
|
AGENT("AGENT", "代理商", "代理商角色");
|
||||||
|
|
||||||
public static final String[] ARRAYS = Arrays.stream(values()).map(RoleEnum::getCode).toArray(String[]::new);
|
public static final String[] ARRAYS = Arrays.stream(values()).map(RoleEnum::getCode).toArray(String[]::new);
|
||||||
|
|
||||||
|
|||||||
@ -115,14 +115,23 @@ public interface CommonFileService {
|
|||||||
String uploadTextBook(InputStream inputStream, String fileName, String folderName, String contentType);
|
String uploadTextBook(InputStream inputStream, String fileName, String folderName, String contentType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过输入流上传视频
|
* 通过输入流上传
|
||||||
*
|
*
|
||||||
* @param inputStream 要上传视频的输入流
|
* @param inputStream 要上传的输入流
|
||||||
* @param folderName 文件夹名称
|
* @param folderName 文件夹名称
|
||||||
* @return 视频在OSS上的访问地址
|
* @return 文件在OSS上的访问地址
|
||||||
*/
|
*/
|
||||||
String upload(InputStream inputStream,String bucketName, String folderName,String fileName,String contentType);
|
String upload(InputStream inputStream,String bucketName, String folderName,String fileName,String contentType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过输入流上传
|
||||||
|
*
|
||||||
|
* @param inputStream 要上传的输入流
|
||||||
|
* @param folderName 文件夹名称
|
||||||
|
* @return 文件在OSS上的访问地址
|
||||||
|
*/
|
||||||
|
String upload(InputStream inputStream,String bucketName, String folderName,String contentType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从MinIO下载文件
|
* 从MinIO下载文件
|
||||||
*
|
*
|
||||||
|
|||||||
@ -304,6 +304,13 @@ public class CommonFileServiceImpl implements CommonFileService {
|
|||||||
return MinioConfig.URL + "/" + bucketName + "/" + folderName + "/" + originalFilename;
|
return MinioConfig.URL + "/" + bucketName + "/" + folderName + "/" + originalFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String upload(InputStream inputStream, String bucketName, String folderName, String contentType) {
|
||||||
|
String originalFilename = CommonUtils.generateUniqueFileName();
|
||||||
|
minioService.upload(bucketName, folderName, originalFilename, inputStream, contentType);
|
||||||
|
return MinioConfig.URL + "/" + bucketName + "/" + folderName + "/" + originalFilename;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从MinIO下载文件
|
* 从MinIO下载文件
|
||||||
*
|
*
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -287,7 +287,7 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.dev33</groupId>
|
<groupId>cn.dev33</groupId>
|
||||||
<artifactId>sa-token-redis</artifactId>
|
<artifactId>sa-token-redis-template</artifactId>
|
||||||
<version>${sa-token-version}</version>
|
<version>${sa-token-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|||||||
@ -46,7 +46,7 @@ public class LoadBalancerConfig {
|
|||||||
String ip = Optional.ofNullable(exchange.getRequest().getRemoteAddress())
|
String ip = Optional.ofNullable(exchange.getRequest().getRemoteAddress())
|
||||||
.map(addr -> addr.getAddress().getHostAddress())
|
.map(addr -> addr.getAddress().getHostAddress())
|
||||||
.orElse("unknown");
|
.orElse("unknown");
|
||||||
log.info("请求来自客户端: {}", ip);
|
log.info("ipForwardFilter 请求来自客户端: {}", ip);
|
||||||
ServerHttpRequest mutatedRequest = exchange.getRequest().mutate()
|
ServerHttpRequest mutatedRequest = exchange.getRequest().mutate()
|
||||||
.header("X-Forwarded-For", ip)
|
.header("X-Forwarded-For", ip)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -47,6 +47,8 @@ public class MpActivityEntity extends BaseEntity {
|
|||||||
@TableField("end_time")
|
@TableField("end_time")
|
||||||
private LocalDateTime endTime;
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 活动状态:0-禁用,1-启用
|
* 活动状态:0-禁用,1-启用
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -2,10 +2,10 @@ package com.seer.teach.mp.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||||
import com.seer.teach.common.entity.BaseEntity;
|
import com.seer.teach.common.entity.BaseEntity;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Getter;
|
import lombok.Data;
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -18,8 +18,7 @@ import java.util.List;
|
|||||||
* @author Lingma
|
* @author Lingma
|
||||||
* @since 2025-12-30
|
* @since 2025-12-30
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Data
|
||||||
@Setter
|
|
||||||
@TableName("mp_activity_info_collection")
|
@TableName("mp_activity_info_collection")
|
||||||
@Schema(name = "MpActivityInfoCollectionEntity对象", description = "活动信息收集表")
|
@Schema(name = "MpActivityInfoCollectionEntity对象", description = "活动信息收集表")
|
||||||
public class MpActivityInfoCollectionEntity extends BaseEntity {
|
public class MpActivityInfoCollectionEntity extends BaseEntity {
|
||||||
@ -58,7 +57,7 @@ public class MpActivityInfoCollectionEntity extends BaseEntity {
|
|||||||
* 孩子性别(M-男,F-女)
|
* 孩子性别(M-男,F-女)
|
||||||
*/
|
*/
|
||||||
@TableField("child_gender")
|
@TableField("child_gender")
|
||||||
private String childGender;
|
private Integer childGender;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 出生年月
|
* 出生年月
|
||||||
@ -70,7 +69,7 @@ public class MpActivityInfoCollectionEntity extends BaseEntity {
|
|||||||
* 年级
|
* 年级
|
||||||
*/
|
*/
|
||||||
@TableField("grade")
|
@TableField("grade")
|
||||||
private String grade;
|
private Integer grade;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 学校
|
* 学校
|
||||||
@ -78,6 +77,12 @@ public class MpActivityInfoCollectionEntity extends BaseEntity {
|
|||||||
@TableField("school")
|
@TableField("school")
|
||||||
private String school;
|
private String school;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
@TableField("mobile")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 地区
|
* 地区
|
||||||
*/
|
*/
|
||||||
@ -105,13 +110,20 @@ public class MpActivityInfoCollectionEntity extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 薄弱科目
|
* 薄弱科目
|
||||||
*/
|
*/
|
||||||
@TableField("weak_subject_ids")
|
@TableField(value = "weak_subject_ids",typeHandler = JacksonTypeHandler.class)
|
||||||
private List<Integer> weakSubjectIds;
|
private List<Integer> weakSubjectIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 优势科目
|
* 优势科目
|
||||||
*/
|
*/
|
||||||
@TableField("strong_subject_ids")
|
@TableField(value = "strong_subject_ids",typeHandler = JacksonTypeHandler.class)
|
||||||
private List<Integer> strongSubjectIds;
|
private List<Integer> strongSubjectIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理商拨打电话联系家长的次数
|
||||||
|
*/
|
||||||
|
@TableField("contact_call_count")
|
||||||
|
private Integer contactCallCount = 0;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -44,4 +44,10 @@ public class MpAgentActivityParticipantEntity extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
@TableField("agent_name")
|
@TableField("agent_name")
|
||||||
private String agentName;
|
private String agentName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动二维码 url
|
||||||
|
*/
|
||||||
|
@TableField("qr_code_url")
|
||||||
|
private String qrCodeUrl;
|
||||||
}
|
}
|
||||||
@ -40,6 +40,9 @@ public class MpAgentEmployeeRelationEntity extends BaseEntity {
|
|||||||
@TableField("employee_name")
|
@TableField("employee_name")
|
||||||
private String employeeName;
|
private String employeeName;
|
||||||
|
|
||||||
|
@TableField("contact_phone")
|
||||||
|
private String contactPhone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工职位
|
* 员工职位
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.seer.teach.mp.entity;
|
package com.seer.teach.mp.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.seer.teach.common.entity.BaseEntity;
|
import com.seer.teach.common.entity.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -31,6 +32,9 @@ public class MpAgentEntity extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String contactName;
|
private String contactName;
|
||||||
|
|
||||||
|
@TableField("contact_user_id")
|
||||||
|
private Integer contactUserId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 联系电话
|
* 联系电话
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -5,11 +5,12 @@ 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.AgentQueryReq;
|
import com.seer.teach.mp.admin.controller.req.AgentQueryReq;
|
||||||
|
import com.seer.teach.mp.admin.controller.req.MpAgentReq;
|
||||||
|
import com.seer.teach.mp.admin.controller.req.MpAgentSaveReq;
|
||||||
import com.seer.teach.mp.admin.controller.resp.AgentResp;
|
import com.seer.teach.mp.admin.controller.resp.AgentResp;
|
||||||
import com.seer.teach.mp.admin.service.AdminAgentService;
|
import com.seer.teach.mp.admin.service.AdminAgentService;
|
||||||
import com.seer.teach.mp.entity.MpAgentEntity;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -42,15 +43,15 @@ public class AdminAgentController {
|
|||||||
@Operation(summary = "新增")
|
@Operation(summary = "新增")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@SaCheckPermission("mp:admin:agent:save")
|
@SaCheckPermission("mp:admin:agent:save")
|
||||||
public ResultBean<Boolean> save(@RequestBody MpAgentEntity agentEntity) {
|
public ResultBean<Boolean> save(@RequestBody @Validated MpAgentSaveReq req) {
|
||||||
return ResultBean.success(adminAgentService.saveAgent(agentEntity));
|
return ResultBean.success(adminAgentService.saveAgent(req));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "更新")
|
@Operation(summary = "更新")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@SaCheckPermission("mp:admin:agent:update")
|
@SaCheckPermission("mp:admin:agent:update")
|
||||||
public ResultBean<Boolean> update(@RequestBody MpAgentEntity agentEntity) {
|
public ResultBean<Boolean> update(@RequestBody @Validated MpAgentReq req) {
|
||||||
return ResultBean.success(adminAgentService.updateAgent(agentEntity));
|
return ResultBean.success(adminAgentService.updateAgent(req));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "删除")
|
@Operation(summary = "删除")
|
||||||
|
|||||||
@ -5,7 +5,7 @@ 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.AgentEmployeeRelationQueryReq;
|
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationQueryReq;
|
||||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationReq;
|
import com.seer.teach.mp.admin.controller.req.AgentEmployeeUpdateReq;
|
||||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeSaveReq;
|
import com.seer.teach.mp.admin.controller.req.AgentEmployeeSaveReq;
|
||||||
import com.seer.teach.mp.admin.controller.resp.AgentEmployeeRelationResp;
|
import com.seer.teach.mp.admin.controller.resp.AgentEmployeeRelationResp;
|
||||||
import com.seer.teach.mp.admin.service.IAdminAgentEmployeeRelationService;
|
import com.seer.teach.mp.admin.service.IAdminAgentEmployeeRelationService;
|
||||||
@ -41,8 +41,8 @@ public class AdminAgentEmployeeRelationController {
|
|||||||
@Operation(summary = "更新代理商员工关联")
|
@Operation(summary = "更新代理商员工关联")
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
@SaCheckPermission("mp:admin:agent:employee:update")
|
@SaCheckPermission("mp:admin:agent:employee:update")
|
||||||
public ResultBean<Boolean> update(@RequestBody @Validated AgentEmployeeRelationReq request) {
|
public ResultBean<Boolean> update(@RequestBody @Validated AgentEmployeeUpdateReq request) {
|
||||||
return ResultBean.success(agentEmployeeRelationService.saveOrUpdateRelation(request));
|
return ResultBean.success(agentEmployeeRelationService.update(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "删除代理商员工关联")
|
@Operation(summary = "删除代理商员工关联")
|
||||||
|
|||||||
@ -1,24 +0,0 @@
|
|||||||
package com.seer.teach.mp.admin.controller.req;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Schema(name = "AgentEmployeeRelationReq", description = "代理商员工关联请求参数")
|
|
||||||
@Data
|
|
||||||
public class AgentEmployeeRelationReq {
|
|
||||||
|
|
||||||
@Schema(description = "关联ID")
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
@Schema(description = "代理商ID")
|
|
||||||
private Integer agentId;
|
|
||||||
|
|
||||||
@Schema(description = "员工用户ID")
|
|
||||||
private Integer employeeUserId;
|
|
||||||
|
|
||||||
@Schema(description = "员工职位")
|
|
||||||
private String position;
|
|
||||||
|
|
||||||
@Schema(description = "员工状态:0-禁用,1-启用")
|
|
||||||
private Integer status = 1;
|
|
||||||
}
|
|
||||||
@ -1,7 +1,9 @@
|
|||||||
package com.seer.teach.mp.admin.controller.req;
|
package com.seer.teach.mp.admin.controller.req;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import jakarta.validation.constraints.Pattern;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ -9,17 +11,27 @@ import lombok.Data;
|
|||||||
public class AgentEmployeeSaveReq {
|
public class AgentEmployeeSaveReq {
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "代理商名称")
|
@Schema(description = "代理商Id")
|
||||||
@NotNull(message = "代理商名称不能为空")
|
@NotNull(message = "代理商Id不能为空")
|
||||||
private String agentName;
|
private Integer agentId;
|
||||||
|
|
||||||
@Schema(description = "员工名称")
|
@Schema(description = "员工名称")
|
||||||
@NotNull(message = "员工名称不能为空")
|
@NotBlank(message = "员工名称不能为空")
|
||||||
private String employeeName;
|
private String employeeName;
|
||||||
|
|
||||||
|
@Schema(description = "员工密码")
|
||||||
|
@NotBlank(message = "员工密码不能为空")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@Schema(description = "员工手机号")
|
||||||
|
@NotBlank(message = "员工手机号不能为空")
|
||||||
|
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "请输入正确的手机号")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
@Schema(description = "员工职位")
|
@Schema(description = "员工职位")
|
||||||
private String position;
|
private String position;
|
||||||
|
|
||||||
@Schema(description = "员工状态:0-禁用,1-启用")
|
@Schema(description = "员工状态:0-禁用,1-启用")
|
||||||
private Integer status = 1;
|
private Integer status = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,31 @@
|
|||||||
|
package com.seer.teach.mp.admin.controller.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import jakarta.validation.constraints.Pattern;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(name = "AgentEmployeeRelationReq", description = "代理商员工关联请求参数")
|
||||||
|
@Data
|
||||||
|
public class AgentEmployeeUpdateReq {
|
||||||
|
|
||||||
|
@Schema(description = "关联ID")
|
||||||
|
@NotNull(message = "关联ID不能为空")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Schema(description = "员工名称")
|
||||||
|
private String employeeName;
|
||||||
|
|
||||||
|
@Schema(description = "员工职位")
|
||||||
|
private String position;
|
||||||
|
|
||||||
|
@Schema(description = "员工密码")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@Schema(description = "员工手机号")
|
||||||
|
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "请输入正确的手机号")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
@Schema(description = "员工状态:0-禁用,1-启用")
|
||||||
|
private Integer status = 1;
|
||||||
|
}
|
||||||
@ -0,0 +1,62 @@
|
|||||||
|
package com.seer.teach.mp.admin.controller.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.Pattern;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(name = "MpAgentReq", description = "代理商请求参数")
|
||||||
|
@Data
|
||||||
|
public class MpAgentReq {
|
||||||
|
|
||||||
|
@Schema(description = "代理商ID")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理商名称
|
||||||
|
*/
|
||||||
|
@Schema(description = "代理商名称")
|
||||||
|
private String agentName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理商编码
|
||||||
|
*/
|
||||||
|
@Schema(description = "代理商编码")
|
||||||
|
private String agentCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理商等级
|
||||||
|
*/
|
||||||
|
@Schema(description = "代理商等级")
|
||||||
|
private String agentLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 联系人姓名
|
||||||
|
*/
|
||||||
|
@Schema(description = "联系人姓名")
|
||||||
|
private String contactName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 联系电话
|
||||||
|
*/
|
||||||
|
@Schema(description = "联系电话")
|
||||||
|
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "请输入正确的手机号")
|
||||||
|
private String contactPhone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录密码
|
||||||
|
*/
|
||||||
|
@Schema(description = "登录密码")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理商地址
|
||||||
|
*/
|
||||||
|
@Schema(description = "代理商地址")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理商状态:0-禁用,1-启用
|
||||||
|
*/
|
||||||
|
@Schema(description = "代理商状态:0-禁用,1-启用")
|
||||||
|
private Integer status;
|
||||||
|
}
|
||||||
@ -0,0 +1,64 @@
|
|||||||
|
package com.seer.teach.mp.admin.controller.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.Pattern;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(name = "MpAgentSaveReq", description = "新增代理商请求参数")
|
||||||
|
public class MpAgentSaveReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理商名称
|
||||||
|
*/
|
||||||
|
@Schema(description = "代理商名称")
|
||||||
|
@NotBlank(message = "代理商名称不能为空")
|
||||||
|
private String agentName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理商编码
|
||||||
|
*/
|
||||||
|
@Schema(description = "代理商编码")
|
||||||
|
private String agentCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理商等级
|
||||||
|
*/
|
||||||
|
@Schema(description = "代理商等级")
|
||||||
|
private String agentLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 联系人姓名
|
||||||
|
*/
|
||||||
|
@Schema(description = "联系人姓名")
|
||||||
|
@NotBlank(message = "联系人姓名不能为空")
|
||||||
|
private String contactName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 联系电话
|
||||||
|
*/
|
||||||
|
@Schema(description = "联系电话")
|
||||||
|
@NotBlank(message = "联系电话不能为空")
|
||||||
|
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "请输入正确的手机号")
|
||||||
|
private String contactPhone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录密码
|
||||||
|
*/
|
||||||
|
@Schema(description = "登录密码")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理商地址
|
||||||
|
*/
|
||||||
|
@Schema(description = "代理商地址")
|
||||||
|
@NotBlank(message = "代理商地址不能为空")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理商状态:0-禁用,1-启用
|
||||||
|
*/
|
||||||
|
@Schema(description = "代理商状态:0-禁用,1-启用")
|
||||||
|
private Integer status;
|
||||||
|
}
|
||||||
@ -23,6 +23,9 @@ public class AgentEmployeeRelationResp {
|
|||||||
@Schema(description = "员工名称")
|
@Schema(description = "员工名称")
|
||||||
private String employeeName;
|
private String employeeName;
|
||||||
|
|
||||||
|
@Schema(description = "员工手机号")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
@Schema(description = "员工职位")
|
@Schema(description = "员工职位")
|
||||||
private String position;
|
private String position;
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
package com.seer.teach.mp.admin.convert;
|
package com.seer.teach.mp.admin.convert;
|
||||||
|
|
||||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationQueryReq;
|
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationQueryReq;
|
||||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationReq;
|
|
||||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeSaveReq;
|
import com.seer.teach.mp.admin.controller.req.AgentEmployeeSaveReq;
|
||||||
|
import com.seer.teach.mp.admin.controller.req.AgentEmployeeUpdateReq;
|
||||||
import com.seer.teach.mp.admin.controller.resp.AgentEmployeeRelationResp;
|
import com.seer.teach.mp.admin.controller.resp.AgentEmployeeRelationResp;
|
||||||
import com.seer.teach.mp.entity.MpAgentEmployeeRelationEntity;
|
import com.seer.teach.mp.entity.MpAgentEmployeeRelationEntity;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -15,10 +16,11 @@ public interface AdminAgentEmployeeRelationConvert {
|
|||||||
|
|
||||||
AdminAgentEmployeeRelationConvert INSTANCE = Mappers.getMapper(AdminAgentEmployeeRelationConvert.class);
|
AdminAgentEmployeeRelationConvert INSTANCE = Mappers.getMapper(AdminAgentEmployeeRelationConvert.class);
|
||||||
|
|
||||||
MpAgentEmployeeRelationEntity convert(AgentEmployeeRelationReq req);
|
MpAgentEmployeeRelationEntity convert(AgentEmployeeUpdateReq req);
|
||||||
|
|
||||||
MpAgentEmployeeRelationEntity convert(AgentEmployeeRelationQueryReq req);
|
MpAgentEmployeeRelationEntity convert(AgentEmployeeRelationQueryReq req);
|
||||||
|
|
||||||
|
@Mapping(source = "contactPhone", target = "mobile")
|
||||||
AgentEmployeeRelationResp convertToResp(MpAgentEmployeeRelationEntity entity);
|
AgentEmployeeRelationResp convertToResp(MpAgentEmployeeRelationEntity entity);
|
||||||
|
|
||||||
List<AgentEmployeeRelationResp> convertToRespList(List<MpAgentEmployeeRelationEntity> mpAgentEmployeeRelationEntities);
|
List<AgentEmployeeRelationResp> convertToRespList(List<MpAgentEmployeeRelationEntity> mpAgentEmployeeRelationEntities);
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package com.seer.teach.mp.admin.convert;
|
package com.seer.teach.mp.admin.convert;
|
||||||
|
|
||||||
import com.seer.teach.mp.admin.controller.req.AgentQueryReq;
|
import com.seer.teach.mp.admin.controller.req.AgentQueryReq;
|
||||||
|
import com.seer.teach.mp.admin.controller.req.MpAgentReq;
|
||||||
|
import com.seer.teach.mp.admin.controller.req.MpAgentSaveReq;
|
||||||
import com.seer.teach.mp.admin.controller.resp.AgentResp;
|
import com.seer.teach.mp.admin.controller.resp.AgentResp;
|
||||||
import com.seer.teach.mp.entity.MpAgentEntity;
|
import com.seer.teach.mp.entity.MpAgentEntity;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
@ -19,5 +21,9 @@ public interface AgentConvert {
|
|||||||
|
|
||||||
MpAgentEntity convertOne(AgentQueryReq req);
|
MpAgentEntity convertOne(AgentQueryReq req);
|
||||||
|
|
||||||
|
MpAgentEntity convertOne2Entity(MpAgentReq req);
|
||||||
|
|
||||||
|
MpAgentEntity convertOneSave(MpAgentSaveReq req);
|
||||||
|
|
||||||
AgentQueryReq convertToReq(MpAgentEntity entity);
|
AgentQueryReq convertToReq(MpAgentEntity entity);
|
||||||
}
|
}
|
||||||
@ -4,12 +4,18 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
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.enums.ResultCodeEnum;
|
||||||
|
import com.seer.teach.common.utils.AssertUtils;
|
||||||
import com.seer.teach.common.utils.PageConverterUtils;
|
import com.seer.teach.common.utils.PageConverterUtils;
|
||||||
import com.seer.teach.mp.admin.controller.req.AgentQueryReq;
|
import com.seer.teach.mp.admin.controller.req.AgentQueryReq;
|
||||||
|
import com.seer.teach.mp.admin.controller.req.MpAgentReq;
|
||||||
|
import com.seer.teach.mp.admin.controller.req.MpAgentSaveReq;
|
||||||
import com.seer.teach.mp.admin.controller.resp.AgentResp;
|
import com.seer.teach.mp.admin.controller.resp.AgentResp;
|
||||||
import com.seer.teach.mp.admin.convert.AgentConvert;
|
import com.seer.teach.mp.admin.convert.AgentConvert;
|
||||||
import com.seer.teach.mp.entity.MpAgentEntity;
|
import com.seer.teach.mp.entity.MpAgentEntity;
|
||||||
import com.seer.teach.mp.service.IMpAgentService;
|
import com.seer.teach.mp.service.IMpAgentService;
|
||||||
|
import com.seer.teach.user.api.UserInfoServiceApi;
|
||||||
|
import com.seer.teach.user.api.dto.UserInfoDTO;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -24,6 +30,8 @@ public class AdminAgentService {
|
|||||||
|
|
||||||
private final IMpAgentService mpAgentService;
|
private final IMpAgentService mpAgentService;
|
||||||
|
|
||||||
|
private final UserInfoServiceApi userInfoServiceApi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取代理商列表
|
* 获取代理商列表
|
||||||
*
|
*
|
||||||
@ -59,11 +67,14 @@ public class AdminAgentService {
|
|||||||
/**
|
/**
|
||||||
* 保存代理商
|
* 保存代理商
|
||||||
*
|
*
|
||||||
* @param agentEntity 代理商实体
|
* @param req 代理商
|
||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
*/
|
*/
|
||||||
public Boolean saveAgent(MpAgentEntity agentEntity) {
|
public Boolean saveAgent(MpAgentSaveReq req) {
|
||||||
boolean result = mpAgentService.saveAgent(agentEntity);
|
boolean userIdByMobile = userInfoServiceApi.getUserIdByMobile(req.getContactPhone());
|
||||||
|
AssertUtils.isTrue(userIdByMobile, ResultCodeEnum.AGENT_IS_EXISTS);
|
||||||
|
MpAgentEntity agentEntity = AgentConvert.INSTANCE.convertOneSave(req);
|
||||||
|
boolean result = mpAgentService.saveAgent(agentEntity,req.getPassword());
|
||||||
log.info("保存代理商结果: {}", result);
|
log.info("保存代理商结果: {}", result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -71,13 +82,35 @@ public class AdminAgentService {
|
|||||||
/**
|
/**
|
||||||
* 更新代理商
|
* 更新代理商
|
||||||
*
|
*
|
||||||
* @param agentEntity 代理商实体
|
* @param req 代理商
|
||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
*/
|
*/
|
||||||
public Boolean updateAgent(MpAgentEntity agentEntity) {
|
public Boolean updateAgent(MpAgentReq req) {
|
||||||
boolean result = mpAgentService.updateAgent(agentEntity);
|
MpAgentEntity agent = mpAgentService.getById(req.getId());
|
||||||
|
AssertUtils.notNull(agent, ResultCodeEnum.AGENT_NOT_FOUND);
|
||||||
|
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||||
|
userInfoDTO.setId(agent.getContactUserId());
|
||||||
|
userInfoDTO.setUserName(req.getContactName());
|
||||||
|
userInfoDTO.setMobile(req.getContactPhone());
|
||||||
|
if (StringUtils.isNotBlank(req.getPassword())) {
|
||||||
|
userInfoDTO.setPassword(req.getPassword());
|
||||||
|
}
|
||||||
|
boolean updateUserResult = userInfoServiceApi.updateUserInfo(userInfoDTO);
|
||||||
|
log.info("更新用户结果: {}", updateUserResult);
|
||||||
|
|
||||||
|
agent.setId(req.getId());
|
||||||
|
agent.setAgentName(req.getAgentName());
|
||||||
|
agent.setAgentCode(req.getAgentCode());
|
||||||
|
agent.setAgentLevel(req.getAgentLevel());
|
||||||
|
agent.setContactName(req.getContactName());
|
||||||
|
Integer contactUserId = userInfoServiceApi.getUserIdByUserName(agent.getContactName());
|
||||||
|
agent.setContactUserId(contactUserId);
|
||||||
|
agent.setContactPhone(req.getContactPhone());
|
||||||
|
agent.setAddress(req.getAddress());
|
||||||
|
agent.setStatus(req.getStatus());
|
||||||
|
boolean result = mpAgentService.updateAgent(agent);
|
||||||
log.info("更新代理商结果: {}", result);
|
log.info("更新代理商结果: {}", result);
|
||||||
return result;
|
return result && updateUserResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -76,7 +76,7 @@ public class AdminDealerApplicationsService {
|
|||||||
userInfoDTO.setRealName(application.getApplicantName());
|
userInfoDTO.setRealName(application.getApplicantName());
|
||||||
userInfoDTO.setMobile(application.getPhone());
|
userInfoDTO.setMobile(application.getPhone());
|
||||||
userInfoDTO.setIdCardNumber(application.getIdCardNumber());
|
userInfoDTO.setIdCardNumber(application.getIdCardNumber());
|
||||||
userInfoDTO.setRoleCode(RoleEnum.DISTRIBUTOR.getCode());
|
userInfoDTO.setRoleCode(RoleEnum.DISTRIBUTOR);
|
||||||
boolean updated = userInfoServiceApi.updateUserInfoAndAssignRole(userInfoDTO);
|
boolean updated = userInfoServiceApi.updateUserInfoAndAssignRole(userInfoDTO);
|
||||||
log.info("更新用户[{}]信息结果: {}",application.getApplicantUserId(), updated);
|
log.info("更新用户[{}]信息结果: {}",application.getApplicantUserId(), updated);
|
||||||
if(updated){
|
if(updated){
|
||||||
|
|||||||
@ -2,9 +2,9 @@ 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.AgentEmployeeSaveReq;
|
import com.seer.teach.mp.admin.controller.req.AgentEmployeeSaveReq;
|
||||||
|
import com.seer.teach.mp.admin.controller.req.AgentEmployeeUpdateReq;
|
||||||
import com.seer.teach.mp.admin.controller.resp.AgentEmployeeRelationResp;
|
import com.seer.teach.mp.admin.controller.resp.AgentEmployeeRelationResp;
|
||||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationQueryReq;
|
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationQueryReq;
|
||||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationReq;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ public interface IAdminAgentEmployeeRelationService {
|
|||||||
* @param request 关联请求对象
|
* @param request 关联请求对象
|
||||||
* @return 操作是否成功
|
* @return 操作是否成功
|
||||||
*/
|
*/
|
||||||
boolean saveOrUpdateRelation(AgentEmployeeRelationReq request);
|
boolean update(AgentEmployeeUpdateReq request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除代理商员工关联(管理端)
|
* 删除代理商员工关联(管理端)
|
||||||
|
|||||||
@ -4,20 +4,22 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
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.enums.ResultCodeEnum;
|
import com.seer.teach.common.enums.ResultCodeEnum;
|
||||||
|
import com.seer.teach.common.enums.RoleEnum;
|
||||||
import com.seer.teach.common.utils.AssertUtils;
|
import com.seer.teach.common.utils.AssertUtils;
|
||||||
import com.seer.teach.common.utils.PageConverterUtils;
|
import com.seer.teach.common.utils.PageConverterUtils;
|
||||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationQueryReq;
|
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationQueryReq;
|
||||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationReq;
|
|
||||||
import com.seer.teach.mp.admin.controller.req.AgentEmployeeSaveReq;
|
import com.seer.teach.mp.admin.controller.req.AgentEmployeeSaveReq;
|
||||||
|
import com.seer.teach.mp.admin.controller.req.AgentEmployeeUpdateReq;
|
||||||
import com.seer.teach.mp.admin.controller.resp.AgentEmployeeRelationResp;
|
import com.seer.teach.mp.admin.controller.resp.AgentEmployeeRelationResp;
|
||||||
import com.seer.teach.mp.admin.convert.AdminAgentEmployeeRelationConvert;
|
import com.seer.teach.mp.admin.convert.AdminAgentEmployeeRelationConvert;
|
||||||
import com.seer.teach.mp.admin.service.IAdminAgentEmployeeRelationService;
|
import com.seer.teach.mp.admin.service.IAdminAgentEmployeeRelationService;
|
||||||
import com.seer.teach.mp.entity.MpAgentEmployeeRelationEntity;
|
import com.seer.teach.mp.entity.MpAgentEmployeeRelationEntity;
|
||||||
import com.seer.teach.mp.entity.MpAgentEntity;
|
|
||||||
import com.seer.teach.mp.service.IMpAgentEmployeeRelationService;
|
import com.seer.teach.mp.service.IMpAgentEmployeeRelationService;
|
||||||
import com.seer.teach.mp.service.IMpAgentService;
|
import com.seer.teach.mp.service.IMpAgentService;
|
||||||
import com.seer.teach.user.api.UserInfoServiceApi;
|
import com.seer.teach.user.api.UserInfoServiceApi;
|
||||||
|
import com.seer.teach.user.api.dto.UserInfoDTO;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -32,6 +34,7 @@ import java.util.Objects;
|
|||||||
* @since 2025-12-30
|
* @since 2025-12-30
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class AdminAgentEmployeeRelationServiceImpl implements IAdminAgentEmployeeRelationService {
|
public class AdminAgentEmployeeRelationServiceImpl implements IAdminAgentEmployeeRelationService {
|
||||||
|
|
||||||
@ -53,9 +56,33 @@ public class AdminAgentEmployeeRelationServiceImpl implements IAdminAgentEmploye
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveOrUpdateRelation(AgentEmployeeRelationReq request) {
|
public boolean update(AgentEmployeeUpdateReq request) {
|
||||||
MpAgentEmployeeRelationEntity entity = AdminAgentEmployeeRelationConvert.INSTANCE.convert(request);
|
log.info("更新代理商员工关系,参数: {}", request);
|
||||||
return agentEmployeeRelationService.saveOrUpdateRelation(entity);
|
MpAgentEmployeeRelationEntity existingRelation = agentEmployeeRelationService.getById(request.getId());
|
||||||
|
AssertUtils.notNull(existingRelation, ResultCodeEnum.AGENT_EMPLOYEE_NOT_FOUND);
|
||||||
|
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||||
|
userInfoDTO.setId(existingRelation.getEmployeeUserId());
|
||||||
|
userInfoDTO.setUserName(request.getEmployeeName());
|
||||||
|
userInfoDTO.setMobile(request.getMobile());
|
||||||
|
if (request.getPassword() != null) {
|
||||||
|
userInfoDTO.setPassword(request.getPassword());
|
||||||
|
}
|
||||||
|
userInfoServiceApi.updateUserInfo(userInfoDTO);
|
||||||
|
// 更新关联表中的用户信息
|
||||||
|
MpAgentEmployeeRelationEntity updateEntity = getUpdateEntity(request, existingRelation);
|
||||||
|
return agentEmployeeRelationService.updateById(updateEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MpAgentEmployeeRelationEntity getUpdateEntity(AgentEmployeeUpdateReq request, MpAgentEmployeeRelationEntity existingRelation) {
|
||||||
|
MpAgentEmployeeRelationEntity updateEntity = new MpAgentEmployeeRelationEntity();
|
||||||
|
updateEntity.setId(request.getId());
|
||||||
|
updateEntity.setAgentId(existingRelation.getAgentId());
|
||||||
|
updateEntity.setEmployeeUserId(existingRelation.getEmployeeUserId());
|
||||||
|
updateEntity.setStatus(request.getStatus());
|
||||||
|
updateEntity.setPosition(request.getPosition());
|
||||||
|
updateEntity.setEmployeeName(request.getEmployeeName());
|
||||||
|
updateEntity.setContactPhone(request.getMobile());
|
||||||
|
return updateEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -82,15 +109,20 @@ public class AdminAgentEmployeeRelationServiceImpl implements IAdminAgentEmploye
|
|||||||
MpAgentEmployeeRelationEntity one = agentEmployeeRelationService.lambdaQuery()
|
MpAgentEmployeeRelationEntity one = agentEmployeeRelationService.lambdaQuery()
|
||||||
.eq(MpAgentEmployeeRelationEntity::getEmployeeName, request.getEmployeeName()).one();
|
.eq(MpAgentEmployeeRelationEntity::getEmployeeName, request.getEmployeeName()).one();
|
||||||
AssertUtils.isNull(one, ResultCodeEnum.AGENT_EMPLOYEE_ALREADY_EXISTS);
|
AssertUtils.isNull(one, ResultCodeEnum.AGENT_EMPLOYEE_ALREADY_EXISTS);
|
||||||
Integer agentId = mpAgentService.lambdaQuery().eq(MpAgentEntity::getAgentName, request.getAgentName()).one().getId();
|
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||||
Integer employeeId = userInfoServiceApi.getUserIdByUserName(request.getEmployeeName());
|
userInfoDTO.setUserName(request.getEmployeeName());
|
||||||
|
userInfoDTO.setPassword(request.getPassword());
|
||||||
|
userInfoDTO.setMobile(request.getMobile());
|
||||||
|
userInfoDTO.setRoleCode(RoleEnum.AGENT);
|
||||||
|
Integer userId = userInfoServiceApi.addUserInfoAndAssignRole(userInfoDTO);
|
||||||
MpAgentEmployeeRelationEntity entity = new MpAgentEmployeeRelationEntity();
|
MpAgentEmployeeRelationEntity entity = new MpAgentEmployeeRelationEntity();
|
||||||
entity.setAgentId(agentId);
|
entity.setAgentId(request.getAgentId());
|
||||||
entity.setEmployeeUserId(employeeId);
|
entity.setAgentName(mpAgentService.getById(request.getAgentId()).getAgentName());
|
||||||
|
entity.setEmployeeUserId(userId);
|
||||||
entity.setEmployeeName(request.getEmployeeName());
|
entity.setEmployeeName(request.getEmployeeName());
|
||||||
entity.setAgentName(request.getAgentName());
|
|
||||||
entity.setPosition(request.getPosition());
|
entity.setPosition(request.getPosition());
|
||||||
entity.setStatus(request.getStatus());
|
entity.setStatus(request.getStatus());
|
||||||
|
entity.setContactPhone(request.getMobile());
|
||||||
agentEmployeeRelationService.save(entity);
|
agentEmployeeRelationService.save(entity);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,8 @@ spring:
|
|||||||
- optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml
|
- optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml
|
||||||
- optional:nacos:shared-database.yaml
|
- optional:nacos:shared-database.yaml
|
||||||
- optional:nacos:shared-redis.yaml
|
- optional:nacos:shared-redis.yaml
|
||||||
|
- optional:nacos:shared-sa-token.yaml
|
||||||
|
- optional:nacos:shared-minio.yaml
|
||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
|
|||||||
@ -67,6 +67,7 @@ CREATE TABLE `mp_agent_activity_participant` (
|
|||||||
`activity_id` int DEFAULT NULL COMMENT '活动ID',
|
`activity_id` int DEFAULT NULL COMMENT '活动ID',
|
||||||
`activity_name` varchar(100) NOT NULL COMMENT '活动名称',
|
`activity_name` varchar(100) NOT NULL COMMENT '活动名称',
|
||||||
`agent_name` varchar(100) NOT NULL COMMENT '代理商名称',
|
`agent_name` varchar(100) NOT NULL COMMENT '代理商名称',
|
||||||
|
`qr_code_url` varchar(255) NOT NULL COMMENT '二维码url',
|
||||||
`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 '修改时间',
|
||||||
@ -130,15 +131,16 @@ CREATE TABLE `mp_activity_info_collection` (
|
|||||||
`activity_id` int NOT NULL COMMENT '活动ID',
|
`activity_id` int NOT NULL COMMENT '活动ID',
|
||||||
`parent_id` int NOT NULL COMMENT '家长ID',
|
`parent_id` int NOT NULL COMMENT '家长ID',
|
||||||
`child_name` varchar(100) COMMENT '孩子姓名',
|
`child_name` varchar(100) COMMENT '孩子姓名',
|
||||||
`child_gender` varchar(10) COMMENT '孩子性别(M-男,F-女)',
|
`child_gender` int COMMENT '孩子性别(1-男,0-女)',
|
||||||
`child_birth_date` date COMMENT '出生年月',
|
`child_birth_date` date COMMENT '出生年月',
|
||||||
`grade` varchar(20) COMMENT '年级',
|
`grade` int COMMENT '年级',
|
||||||
`school` varchar(255) COMMENT '学校',
|
`school` varchar(255) COMMENT '学校',
|
||||||
|
`mobile` varchar(20) COMMENT '手机号',
|
||||||
`region` varchar(255) COMMENT '地区',
|
`region` varchar(255) COMMENT '地区',
|
||||||
`parent_identity` varchar(20) COMMENT '家长身份(爸爸,妈妈)',
|
`parent_identity` varchar(20) COMMENT '家长身份(爸爸,妈妈)',
|
||||||
`learning_situation` varchar(20) COMMENT '学习情况(优、良、中、差)',
|
`learning_situation` varchar(20) COMMENT '学习情况(优、良、中、差)',
|
||||||
`weak_subject_ids` varchar(50) COMMENT '薄弱科目',
|
`weak_subject_ids` json COMMENT '薄弱科目',
|
||||||
`strong_subject_ids` varchar(50) COMMENT '优势科目',
|
`strong_subject_ids` json COMMENT '优势科目',
|
||||||
`weak_subject` varchar(50) COMMENT '偏科(数学、英语等)',
|
`weak_subject` varchar(50) 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 '创建人',
|
||||||
|
|||||||
@ -25,6 +25,12 @@
|
|||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>seer-user-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springdoc</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
@ -46,6 +52,16 @@
|
|||||||
<artifactId>lombok-mapstruct-binding</artifactId>
|
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>seer-teacher-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>seer-teacher-service</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@ -2,22 +2,24 @@ package com.seer.teach.mp.app.controller;
|
|||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
|
import com.seer.teach.common.PageListBean;
|
||||||
import com.seer.teach.common.ResultBean;
|
import com.seer.teach.common.ResultBean;
|
||||||
import com.seer.teach.common.annotation.DecryptionAnnotation;
|
import com.seer.teach.common.annotation.DecryptionAnnotation;
|
||||||
import com.seer.teach.common.annotation.EncryptionAnnotation;
|
import com.seer.teach.common.annotation.EncryptionAnnotation;
|
||||||
import com.seer.teach.common.annotation.LogPrint;
|
import com.seer.teach.common.annotation.LogPrint;
|
||||||
|
import com.seer.teach.mp.app.controller.req.AgentActivityParentQueryReq;
|
||||||
|
import com.seer.teach.mp.app.controller.req.RecordContactCallReq;
|
||||||
import com.seer.teach.mp.app.controller.resp.AgentActivityParentInfoResp;
|
import com.seer.teach.mp.app.controller.resp.AgentActivityParentInfoResp;
|
||||||
import com.seer.teach.mp.app.service.IAppAgentActivityParentInfoService;
|
import com.seer.teach.mp.app.service.IAppAgentActivityParentInfoService;
|
||||||
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 jakarta.validation.Valid;
|
||||||
import lombok.RequiredArgsConstructor;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 代理商活动参与家长信息App控制器
|
* 代理商活动参与家长信息App控制器
|
||||||
@ -38,12 +40,18 @@ public class AppAgentActivityParentInfoController {
|
|||||||
private final IAppAgentActivityParentInfoService agentActivityParentInfoService;
|
private final IAppAgentActivityParentInfoService agentActivityParentInfoService;
|
||||||
|
|
||||||
@Operation(summary = "获取参加指定活动的家长列表")
|
@Operation(summary = "获取参加指定活动的家长列表")
|
||||||
@GetMapping("/getActivityParents")
|
@PostMapping("/page-list")
|
||||||
@SaCheckLogin
|
@SaCheckLogin
|
||||||
public ResultBean<List<AgentActivityParentInfoResp>> getActivityParents(
|
public ResultBean<PageListBean<AgentActivityParentInfoResp>> getActivityParents(@RequestBody @Valid AgentActivityParentQueryReq queryReq) {
|
||||||
@RequestParam("activityId") Integer activityId,
|
|
||||||
@RequestParam("agentId") Integer agentId) {
|
|
||||||
Integer userId = StpUtil.getLoginIdAsInt();
|
Integer userId = StpUtil.getLoginIdAsInt();
|
||||||
return ResultBean.success(agentActivityParentInfoService.getParentsByActivityAndAgent(activityId, agentId,userId));
|
return ResultBean.success(agentActivityParentInfoService.getParentsByActivityAndAgent(userId, queryReq));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "记录代理商拨打电话联系家长的次数")
|
||||||
|
@PostMapping("/record-contact-call")
|
||||||
|
@SaCheckLogin
|
||||||
|
public ResultBean<Boolean> recordContactCall(@RequestBody @Valid RecordContactCallReq req) {
|
||||||
|
Integer userId = StpUtil.getLoginIdAsInt();
|
||||||
|
return ResultBean.success(agentActivityParentInfoService.recordContactCall(req.getCollectionId(), req.getIncrementCount(),userId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6,12 +6,15 @@ import com.seer.teach.common.ResultBean;
|
|||||||
import com.seer.teach.common.annotation.DecryptionAnnotation;
|
import com.seer.teach.common.annotation.DecryptionAnnotation;
|
||||||
import com.seer.teach.common.annotation.EncryptionAnnotation;
|
import com.seer.teach.common.annotation.EncryptionAnnotation;
|
||||||
import com.seer.teach.common.annotation.LogPrint;
|
import com.seer.teach.common.annotation.LogPrint;
|
||||||
|
import com.seer.teach.mp.app.controller.req.AppMpAgentActivityQrCodeQueryReq;
|
||||||
import com.seer.teach.mp.app.controller.resp.AgentActivityParticipantResp;
|
import com.seer.teach.mp.app.controller.resp.AgentActivityParticipantResp;
|
||||||
import com.seer.teach.mp.app.service.IAppAgentActivityParticipantService;
|
import com.seer.teach.mp.app.service.IAppAgentActivityParticipantService;
|
||||||
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.web.bind.annotation.GetMapping;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@ -26,7 +29,7 @@ import java.util.List;
|
|||||||
* @author Lingma
|
* @author Lingma
|
||||||
* @since 2025-12-29
|
* @since 2025-12-29
|
||||||
*/
|
*/
|
||||||
@Tag(name = "APP - 代理商参与活动记录")
|
@Tag(name = "APP - 代理商参与活动")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/app/agent/activity/participant")
|
@RequestMapping("/app/agent/activity/participant")
|
||||||
@LogPrint
|
@LogPrint
|
||||||
@ -44,4 +47,12 @@ public class AppAgentActivityParticipantController {
|
|||||||
Integer userId = StpUtil.getLoginIdAsInt();
|
Integer userId = StpUtil.getLoginIdAsInt();
|
||||||
return ResultBean.success(agentActivityParticipantService.getParticipantsByActivityAndAgent(agentId,userId));
|
return ResultBean.success(agentActivityParticipantService.getParticipantsByActivityAndAgent(agentId,userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取代理参与活动的二维码")
|
||||||
|
@PostMapping("/qrcode")
|
||||||
|
@SaCheckPermission("mp:app:agent:activity:qrcode")
|
||||||
|
public ResultBean<String> getQrCode(@RequestBody AppMpAgentActivityQrCodeQueryReq req) {
|
||||||
|
Integer userId = StpUtil.getLoginIdAsInt();
|
||||||
|
return ResultBean.success(agentActivityParticipantService.getQrCode(req,userId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
package com.seer.teach.mp.app.controller;
|
package com.seer.teach.mp.app.controller;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import com.seer.teach.common.ResultBean;
|
import com.seer.teach.common.ResultBean;
|
||||||
import com.seer.teach.common.annotation.DecryptionAnnotation;
|
import com.seer.teach.common.annotation.DecryptionAnnotation;
|
||||||
@ -37,6 +38,7 @@ public class AppAgentController {
|
|||||||
|
|
||||||
@Operation(summary = "获取代理商详情")
|
@Operation(summary = "获取代理商详情")
|
||||||
@GetMapping("/detail")
|
@GetMapping("/detail")
|
||||||
|
@SaCheckPermission("mp:app:agent:detail")
|
||||||
public ResultBean<AppMpAgentResp> getAgent() {
|
public ResultBean<AppMpAgentResp> getAgent() {
|
||||||
Integer userId = StpUtil.getLoginIdAsInt();
|
Integer userId = StpUtil.getLoginIdAsInt();
|
||||||
return ResultBean.success(appAgentService.getAgentRespByUserId(userId));
|
return ResultBean.success(appAgentService.getAgentRespByUserId(userId));
|
||||||
|
|||||||
@ -0,0 +1,83 @@
|
|||||||
|
package com.seer.teach.mp.app.controller;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||||
|
import com.seer.teach.common.PageListBean;
|
||||||
|
import com.seer.teach.common.ResultBean;
|
||||||
|
import com.seer.teach.common.annotation.LogPrint;
|
||||||
|
import com.seer.teach.common.enums.ResultCodeEnum;
|
||||||
|
import com.seer.teach.mp.app.controller.req.AppAgentEmployeeRelationQueryReq;
|
||||||
|
import com.seer.teach.mp.app.controller.req.AppAgentEmployeeRelationReq;
|
||||||
|
import com.seer.teach.mp.app.controller.resp.AppAgentEmployeeRelationResp;
|
||||||
|
import com.seer.teach.mp.app.service.IAppAgentEmployeeRelationService;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@LogPrint
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@Tag(name = "App - 代理商员工管理")
|
||||||
|
@RequestMapping("/app/agent/employee")
|
||||||
|
public class AppAgentEmployeeRelationController {
|
||||||
|
|
||||||
|
private final IAppAgentEmployeeRelationService agentEmployeeRelationService;
|
||||||
|
|
||||||
|
@Operation(summary = "我的员工列表")
|
||||||
|
@PostMapping("/page-list")
|
||||||
|
@SaCheckLogin
|
||||||
|
public ResultBean<PageListBean<AppAgentEmployeeRelationResp>> pageList(@RequestBody @Validated AppAgentEmployeeRelationQueryReq query) {
|
||||||
|
return ResultBean.success(agentEmployeeRelationService.pageList(query));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "新增员工")
|
||||||
|
@PostMapping("/add")
|
||||||
|
@SaCheckLogin
|
||||||
|
public ResultBean<Boolean> addEmployee(@RequestBody @Validated AppAgentEmployeeRelationReq request) {
|
||||||
|
return ResultBean.success(agentEmployeeRelationService.addEmployee(request));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新员工信息")
|
||||||
|
@PostMapping("/update")
|
||||||
|
@SaCheckLogin
|
||||||
|
public ResultBean<Boolean> updateEmployee(@RequestBody @Validated AppAgentEmployeeRelationReq request) {
|
||||||
|
boolean belongsToAgent = agentEmployeeRelationService.isEmployeeBelongsToAgent(request.getId(),request.getAgentId());
|
||||||
|
if (!belongsToAgent) {
|
||||||
|
return ResultBean.error(ResultCodeEnum.UNAUTHORIZED_UPDATE_EMPLOYEE);
|
||||||
|
}
|
||||||
|
return ResultBean.success(agentEmployeeRelationService.updateEmployee(request));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除员工")
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
@SaCheckLogin
|
||||||
|
public ResultBean<Boolean> deleteEmployee(@PathVariable Integer id, @RequestParam Integer agentId) {
|
||||||
|
boolean belongsToAgent = agentEmployeeRelationService.isEmployeeBelongsToAgent(id,agentId);
|
||||||
|
if (!belongsToAgent) {
|
||||||
|
return ResultBean.error(ResultCodeEnum.UNAUTHORIZED_UPDATE_EMPLOYEE);
|
||||||
|
}
|
||||||
|
return ResultBean.success(agentEmployeeRelationService.deleteEmployee(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "员工详情")
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
@SaCheckLogin
|
||||||
|
public ResultBean<AppAgentEmployeeRelationResp> getEmployee(@PathVariable Integer id,@RequestParam Integer agentId) {
|
||||||
|
boolean belongsToAgent = agentEmployeeRelationService.isEmployeeBelongsToAgent(id,agentId);
|
||||||
|
if (!belongsToAgent) {
|
||||||
|
return ResultBean.error(ResultCodeEnum.UNAUTHORIZED_UPDATE_EMPLOYEE);
|
||||||
|
}
|
||||||
|
AppAgentEmployeeRelationResp result = agentEmployeeRelationService.getById(id);
|
||||||
|
return ResultBean.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取所有员工列表")
|
||||||
|
@GetMapping("/all")
|
||||||
|
@SaCheckLogin
|
||||||
|
public ResultBean<List<AppAgentEmployeeRelationResp>> getAllEmployees(@RequestParam Integer agentId) {
|
||||||
|
return ResultBean.success(agentEmployeeRelationService.getAllEmployeesByAgentId(agentId));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -16,6 +16,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,7 +34,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@EncryptionAnnotation
|
@EncryptionAnnotation
|
||||||
@DecryptionAnnotation
|
@DecryptionAnnotation
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class AppAgentActivityController {
|
public class AppMpActivityController {
|
||||||
|
|
||||||
private final IAppActivityService agentActivityService;
|
private final IAppActivityService agentActivityService;
|
||||||
|
|
||||||
@ -51,4 +52,12 @@ public class AppAgentActivityController {
|
|||||||
public ResultBean<AppActivityResp> getDetail(@PathVariable Integer id) {
|
public ResultBean<AppActivityResp> getDetail(@PathVariable Integer id) {
|
||||||
return ResultBean.success(agentActivityService.getById(id));
|
return ResultBean.success(agentActivityService.getById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "活动二维码")
|
||||||
|
@GetMapping("/{agentId}/{activityId}/qrcode")
|
||||||
|
@SaCheckPermission("mp:app:agent:activity:qrcode")
|
||||||
|
public ResultBean<String> getQrCode(@PathVariable("agentId") Integer agentId, @PathVariable("activityId") Integer activityId, @RequestParam("appId") String appId) {
|
||||||
|
Integer userId = StpUtil.getLoginIdAsInt();
|
||||||
|
return ResultBean.success(agentActivityService.getQrCode(userId,agentId,activityId,appId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
package com.seer.teach.mp.app.controller;
|
package com.seer.teach.mp.app.controller;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import com.seer.teach.common.ResultBean;
|
import com.seer.teach.common.ResultBean;
|
||||||
import com.seer.teach.common.annotation.DecryptionAnnotation;
|
import com.seer.teach.common.annotation.DecryptionAnnotation;
|
||||||
import com.seer.teach.common.annotation.EncryptionAnnotation;
|
import com.seer.teach.common.annotation.EncryptionAnnotation;
|
||||||
@ -38,6 +39,7 @@ public class AppMpQrCodeController {
|
|||||||
*/
|
*/
|
||||||
@Operation(summary = "生成微信服务号二维码")
|
@Operation(summary = "生成微信服务号二维码")
|
||||||
@PostMapping("/official/generate")
|
@PostMapping("/official/generate")
|
||||||
|
@SaCheckPermission("mp:app:qrcode:generate")
|
||||||
public ResultBean<MpQrCodeResp> generateOfficialQrCode(@Valid @RequestBody MpGenerateQrCodeReq req) {
|
public ResultBean<MpQrCodeResp> generateOfficialQrCode(@Valid @RequestBody MpGenerateQrCodeReq req) {
|
||||||
return ResultBean.success(appOfficialQrCodeService.generateQrCode(req));
|
return ResultBean.success(appOfficialQrCodeService.generateQrCode(req));
|
||||||
}
|
}
|
||||||
@ -48,8 +50,9 @@ public class AppMpQrCodeController {
|
|||||||
*/
|
*/
|
||||||
@Operation(summary = "生成微信小程序二维码")
|
@Operation(summary = "生成微信小程序二维码")
|
||||||
@PostMapping("/mini/generate")
|
@PostMapping("/mini/generate")
|
||||||
|
@SaCheckPermission("mp:app:qrcode:mini-generate")
|
||||||
public ResultBean<String> generateQrCode(@Valid @RequestBody GetQrCodeReq reqParams) {
|
public ResultBean<String> generateQrCode(@Valid @RequestBody GetQrCodeReq reqParams) {
|
||||||
OssImageUploadResp resp = wechatMiniProgramService.createQrcode(reqParams);
|
OssImageUploadResp resp = wechatMiniProgramService.createQrcode(reqParams);
|
||||||
return ResultBean.success(resp.getUrl());
|
return ResultBean.success(resp.getUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
package com.seer.teach.mp.app.controller;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
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.JsapiSignatureReq;
|
||||||
|
import com.seer.teach.mp.app.controller.resp.JsapiSignatureResp;
|
||||||
|
import com.seer.teach.mp.app.service.IAppMpSignatureService;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
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.RestController;
|
||||||
|
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
@EncryptionAnnotation
|
||||||
|
@DecryptionAnnotation
|
||||||
|
@Tag(name = "APP - 微信JS-SDK签名")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/app/signature")
|
||||||
|
@LogPrint
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AppMpSignatureController {
|
||||||
|
|
||||||
|
private final IAppMpSignatureService appMpSignatureService;
|
||||||
|
|
||||||
|
@Operation(summary = "生成JS-SDK签名")
|
||||||
|
@PostMapping("/jsapi")
|
||||||
|
@SaCheckPermission("mp:app:signature:jsapi")
|
||||||
|
public ResultBean<JsapiSignatureResp> generateJsapiSignature(@Valid @RequestBody JsapiSignatureReq req) {
|
||||||
|
JsapiSignatureResp resp = appMpSignatureService.generateJsapiSignature(req);
|
||||||
|
return ResultBean.success(resp);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,11 +4,15 @@ import cn.dev33.satoken.annotation.SaCheckLogin;
|
|||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import com.seer.teach.common.ResultBean;
|
import com.seer.teach.common.ResultBean;
|
||||||
import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq;
|
import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq;
|
||||||
|
import com.seer.teach.mp.app.controller.req.TestChildCharacterReq;
|
||||||
import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp;
|
import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp;
|
||||||
|
import com.seer.teach.mp.app.controller.resp.TestChildCharacterResp;
|
||||||
import com.seer.teach.mp.app.service.AppParentAgentActivityService;
|
import com.seer.teach.mp.app.service.AppParentAgentActivityService;
|
||||||
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 jakarta.validation.Valid;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@ -20,7 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
/**
|
/**
|
||||||
* 家长参与代理商活动控制器 - 应用端
|
* 家长参与代理商活动控制器 - 应用端
|
||||||
*/
|
*/
|
||||||
@Tag(name = "应用端 - 家长参与代理商活动管理")
|
@Tag(name = "App - 家长参与代理商活动管理")
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/app/parent/agent/activity")
|
@RequestMapping("/app/parent/agent/activity")
|
||||||
@ -31,7 +35,7 @@ public class AppParentAgentActivityController {
|
|||||||
@PostMapping("/sign-up")
|
@PostMapping("/sign-up")
|
||||||
@SaCheckLogin
|
@SaCheckLogin
|
||||||
@Operation(summary = "家长报名参加代理商活动")
|
@Operation(summary = "家长报名参加代理商活动")
|
||||||
public ResultBean<Boolean> signUpForActivity(@RequestBody AppMpSignUpActivityReq request) {
|
public ResultBean<Boolean> signUpForActivity(@RequestBody @Validated AppMpSignUpActivityReq request) {
|
||||||
Integer parentId = StpUtil.getLoginIdAsInt();
|
Integer parentId = StpUtil.getLoginIdAsInt();
|
||||||
return ResultBean.success(appParentAgentActivityService.signUpForActivityWithInfo(request, parentId));
|
return ResultBean.success(appParentAgentActivityService.signUpForActivityWithInfo(request, parentId));
|
||||||
}
|
}
|
||||||
@ -39,7 +43,7 @@ public class AppParentAgentActivityController {
|
|||||||
@PostMapping("/update-info")
|
@PostMapping("/update-info")
|
||||||
@SaCheckLogin
|
@SaCheckLogin
|
||||||
@Operation(summary = "家长更新活动信息")
|
@Operation(summary = "家长更新活动信息")
|
||||||
public ResultBean<Boolean> updateActivityInfo(@RequestBody AppMpSignUpActivityReq request) {
|
public ResultBean<Boolean> updateActivityInfo(@RequestBody @Validated AppMpSignUpActivityReq request) {
|
||||||
Integer parentId = StpUtil.getLoginIdAsInt();
|
Integer parentId = StpUtil.getLoginIdAsInt();
|
||||||
return ResultBean.success(appParentAgentActivityService.updateActivityInfo(request, parentId));
|
return ResultBean.success(appParentAgentActivityService.updateActivityInfo(request, parentId));
|
||||||
}
|
}
|
||||||
@ -59,4 +63,12 @@ public class AppParentAgentActivityController {
|
|||||||
Integer parentId = StpUtil.getLoginIdAsInt();
|
Integer parentId = StpUtil.getLoginIdAsInt();
|
||||||
return ResultBean.success(appParentAgentActivityService.getByActivityIdAndParentId(agentId,activityId,parentId));
|
return ResultBean.success(appParentAgentActivityService.getByActivityIdAndParentId(agentId,activityId,parentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/test-child-character")
|
||||||
|
@SaCheckLogin
|
||||||
|
@Operation(summary = "测试孩子性格")
|
||||||
|
public ResultBean<TestChildCharacterResp> testChildCharacter(@RequestBody @Valid TestChildCharacterReq request) {
|
||||||
|
Integer parentId = StpUtil.getLoginIdAsInt();
|
||||||
|
return ResultBean.success(appParentAgentActivityService.testChildCharacter(request, parentId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -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;
|
||||||
|
}
|
||||||
@ -4,13 +4,17 @@ import com.seer.teach.common.request.PageRequest;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Schema(name = "AppAgentEmployeeRelationQueryReq", description = "代理商员工关联查询请求参数")
|
|
||||||
@Data
|
@Data
|
||||||
|
@Schema(name = "AppAgentEmployeeRelationQueryReq", description = "代理商员工关联查询请求参数")
|
||||||
public class AppAgentEmployeeRelationQueryReq extends PageRequest {
|
public class AppAgentEmployeeRelationQueryReq extends PageRequest {
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "员工职位")
|
@Schema(description = "员工职位")
|
||||||
private String position;
|
private String position;
|
||||||
|
|
||||||
@Schema(description = "员工状态:0-禁用,1-启用")
|
@Schema(description = "员工状态:0-禁用,1-启用")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "员工名称")
|
||||||
|
private String employeeName;
|
||||||
}
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package com.seer.teach.mp.app.controller.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.Pattern;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(name = "AppAgentEmployeeRelationReq", description = "App端代理商员工关联请求参数")
|
||||||
|
@Data
|
||||||
|
public class AppAgentEmployeeRelationReq {
|
||||||
|
|
||||||
|
@Schema(description = "关联ID")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Schema(description = "代理商ID")
|
||||||
|
private Integer agentId;
|
||||||
|
|
||||||
|
@Schema(description = "员工名称")
|
||||||
|
private String employeeName;
|
||||||
|
|
||||||
|
@Schema(description = "员工密码")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@Schema(description = "员工手机号")
|
||||||
|
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "请输入正确的手机号")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
@Schema(description = "员工职位")
|
||||||
|
private String position;
|
||||||
|
|
||||||
|
@Schema(description = "员工状态:0-禁用,1-启用")
|
||||||
|
private Integer status = 1;
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.seer.teach.mp.app.controller.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "App 代理商活动二维码查询请求参数")
|
||||||
|
public class AppMpAgentActivityQrCodeQueryReq {
|
||||||
|
|
||||||
|
@Schema(description = "代理商id",example = "1")
|
||||||
|
private Integer agentId;
|
||||||
|
|
||||||
|
@Schema(description = "活动id",example = "1")
|
||||||
|
private Integer activityId;
|
||||||
|
|
||||||
|
@Schema(description = "公众号appId",example = "wx1234567890")
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
@Schema(description = "二维码类型 1:临时 2:永久",example = "1")
|
||||||
|
private Integer qrCodeType;
|
||||||
|
}
|
||||||
@ -1,16 +1,19 @@
|
|||||||
package com.seer.teach.mp.app.controller.req;
|
package com.seer.teach.mp.app.controller.req;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.Pattern;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Schema(name = "AppMpSignUpActivityReq", description = "家长报名参加代理商活动Req")
|
@Schema(name = "AppMpSignUpActivityReq", description = "家长报名参加代理商活动Req")
|
||||||
@Data
|
@Data
|
||||||
public class AppMpSignUpActivityReq {
|
public class AppMpSignUpActivityReq {
|
||||||
|
|
||||||
|
@Schema (description = "ID")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
@Schema(description = "活动ID")
|
@Schema(description = "活动ID")
|
||||||
private Integer activityId;
|
private Integer activityId;
|
||||||
|
|
||||||
@ -18,6 +21,7 @@ public class AppMpSignUpActivityReq {
|
|||||||
private Integer agentId;
|
private Integer agentId;
|
||||||
|
|
||||||
@Schema(description = "手机号码")
|
@Schema(description = "手机号码")
|
||||||
|
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "请输入正确的手机号")
|
||||||
private String mobile;
|
private String mobile;
|
||||||
|
|
||||||
@Schema(description = "孩子姓名")
|
@Schema(description = "孩子姓名")
|
||||||
|
|||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.seer.teach.mp.app.controller.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JS-SDK签名请求参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "JS-SDK签名请求参数")
|
||||||
|
public class JsapiSignatureReq {
|
||||||
|
|
||||||
|
@NotEmpty(message = "URL不能为空")
|
||||||
|
@Schema(description = "当前网页的URL,不包含#及其后面部分")
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
@NotEmpty(message = "appId不能为空")
|
||||||
|
@Schema(description = "公众号的唯一标识")
|
||||||
|
private String appId;
|
||||||
|
}
|
||||||
@ -14,5 +14,8 @@ public class MpGenerateQrCodeReq {
|
|||||||
private String appId;
|
private String appId;
|
||||||
|
|
||||||
@Schema(description = "二维码类型 1-临时 2-永久")
|
@Schema(description = "二维码类型 1-临时 2-永久")
|
||||||
private Integer type;
|
private Integer type = 2;
|
||||||
|
|
||||||
|
@Schema(description = "二维码有效期")
|
||||||
|
private Integer expireSeconds;
|
||||||
}
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package com.seer.teach.mp.app.controller.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Schema(description = "记录代理商拨打电话联系家长次数请求对象")
|
||||||
|
@Data
|
||||||
|
public class RecordContactCallReq {
|
||||||
|
|
||||||
|
@NotNull(message = "活动信息收集记录ID不能为空")
|
||||||
|
@Schema(description = "活动信息收集记录ID")
|
||||||
|
private Integer collectionId;
|
||||||
|
|
||||||
|
@Schema(description = "增加的联系次数,默认为1")
|
||||||
|
private Integer incrementCount = 1;
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.seer.teach.mp.app.controller.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
@Schema(description = "测试孩子性格请求对象")
|
||||||
|
@Data
|
||||||
|
public class TestChildCharacterReq {
|
||||||
|
|
||||||
|
@NotNull(message = "孩子性别不能为空")
|
||||||
|
@Schema(description = "孩子性别(男,女)")
|
||||||
|
private String childGender;
|
||||||
|
|
||||||
|
@NotNull(message = "出生年月不能为空")
|
||||||
|
@Schema(description = "出生年月")
|
||||||
|
private LocalDate childBirthDate;
|
||||||
|
|
||||||
|
@Schema(description = "星座")
|
||||||
|
private String constellation;
|
||||||
|
|
||||||
|
@NotNull(message = "年级不能为空")
|
||||||
|
@Schema(description = "年级")
|
||||||
|
private String grade;
|
||||||
|
|
||||||
|
@NotNull(message = "学习情况不能为空")
|
||||||
|
@Schema(description = "学习情况(优、良、中、差)")
|
||||||
|
private String learningSituation;
|
||||||
|
|
||||||
|
@NotNull(message = "偏科情况不能为空")
|
||||||
|
@Schema(description = "偏科(数学、英语等)")
|
||||||
|
private String weakSubject;
|
||||||
|
}
|
||||||
@ -28,18 +28,21 @@ public class AgentActivityParentInfoResp {
|
|||||||
@Schema(description = "孩子姓名")
|
@Schema(description = "孩子姓名")
|
||||||
private String childName;
|
private String childName;
|
||||||
|
|
||||||
@Schema(description = "孩子性别(M-男,F-女)")
|
@Schema(description = "孩子性别(1-男,0-女)")
|
||||||
private String childGender;
|
private Integer childGender;
|
||||||
|
|
||||||
@Schema(description = "出生年月")
|
@Schema(description = "出生年月")
|
||||||
private LocalDate childBirthDate;
|
private LocalDate childBirthDate;
|
||||||
|
|
||||||
@Schema(description = "年级")
|
@Schema(description = "年级")
|
||||||
private String grade;
|
private Integer grade;
|
||||||
|
|
||||||
@Schema(description = "学校")
|
@Schema(description = "学校")
|
||||||
private String school;
|
private String school;
|
||||||
|
|
||||||
|
@Schema(description = "手机号")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
@Schema(description = "地区")
|
@Schema(description = "地区")
|
||||||
private String region;
|
private String region;
|
||||||
|
|
||||||
@ -55,5 +58,8 @@ public class AgentActivityParentInfoResp {
|
|||||||
@Schema(description = "劣势学科ID列表")
|
@Schema(description = "劣势学科ID列表")
|
||||||
private List<Integer> weakSubjectIds;
|
private List<Integer> weakSubjectIds;
|
||||||
|
|
||||||
|
@Schema(description = "代理商拨打电话联系家长的次数")
|
||||||
|
private Integer contactCallCount;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -27,4 +27,7 @@ public class AppMpAgentResp {
|
|||||||
|
|
||||||
@Schema(description = "代理商地址")
|
@Schema(description = "代理商地址")
|
||||||
private String address;
|
private String address;
|
||||||
|
|
||||||
|
@Schema(description = "是否是代理商联系人")
|
||||||
|
private Boolean isContactPerson;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,9 @@ public class AppMpSignUpActivityResp {
|
|||||||
@Schema(description = "学校")
|
@Schema(description = "学校")
|
||||||
private String school;
|
private String school;
|
||||||
|
|
||||||
|
@Schema(description = "手机号码")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
@Schema(description = "地区")
|
@Schema(description = "地区")
|
||||||
private String region;
|
private String region;
|
||||||
|
|
||||||
@ -50,4 +53,7 @@ public class AppMpSignUpActivityResp {
|
|||||||
|
|
||||||
@Schema(description = "薄弱科目")
|
@Schema(description = "薄弱科目")
|
||||||
private String weakSubject;
|
private String weakSubject;
|
||||||
|
|
||||||
|
@Schema(description = "代理商拨打电话联系家长的次数")
|
||||||
|
private Integer contactCallCount;
|
||||||
}
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package com.seer.teach.mp.app.controller.resp;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JS-SDK签名响应参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "JS-SDK签名响应参数")
|
||||||
|
public class JsapiSignatureResp {
|
||||||
|
|
||||||
|
@Schema(description = "生成签名的时间戳")
|
||||||
|
private Long timestamp;
|
||||||
|
|
||||||
|
@Schema(description = "生成签名的随机串")
|
||||||
|
private String nonceStr;
|
||||||
|
|
||||||
|
@Schema(description = "签名")
|
||||||
|
private String signature;
|
||||||
|
|
||||||
|
@Schema(description = "公众号的唯一标识")
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
public JsapiSignatureResp() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsapiSignatureResp(Long timestamp, String nonceStr, String signature, String appId) {
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
this.nonceStr = nonceStr;
|
||||||
|
this.signature = signature;
|
||||||
|
this.appId = appId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.seer.teach.mp.app.controller.resp;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(description = "测试孩子性格响应对象")
|
||||||
|
@Data
|
||||||
|
public class TestChildCharacterResp {
|
||||||
|
|
||||||
|
@Schema(description = "性格分析结果")
|
||||||
|
private String characterAnalysis;
|
||||||
|
|
||||||
|
@Schema(description = "性格特征")
|
||||||
|
private String characterTraits;
|
||||||
|
|
||||||
|
@Schema(description = "建议")
|
||||||
|
private String suggestions;
|
||||||
|
|
||||||
|
@Schema(description = "性格类型")
|
||||||
|
private String characterType;
|
||||||
|
}
|
||||||
@ -3,7 +3,8 @@ package com.seer.teach.mp.app.convert;
|
|||||||
import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq;
|
import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq;
|
||||||
import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp;
|
import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp;
|
||||||
import com.seer.teach.mp.entity.MpActivityInfoCollectionEntity;
|
import com.seer.teach.mp.entity.MpActivityInfoCollectionEntity;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
@ -11,7 +12,20 @@ public interface AppMpActivityInfoCollectionConvert {
|
|||||||
|
|
||||||
AppMpActivityInfoCollectionConvert INSTANCE = Mappers.getMapper(AppMpActivityInfoCollectionConvert.class);
|
AppMpActivityInfoCollectionConvert INSTANCE = Mappers.getMapper(AppMpActivityInfoCollectionConvert.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实体转换成响应参数
|
||||||
|
* @param entity 实体
|
||||||
|
* @return 响应参数
|
||||||
|
*/
|
||||||
|
@Mapping(source = "mobile", target = "mobile")
|
||||||
|
@Mapping(source = "contactCallCount", target = "contactCallCount")
|
||||||
AppMpSignUpActivityResp convert2Resp(MpActivityInfoCollectionEntity entity);
|
AppMpSignUpActivityResp convert2Resp(MpActivityInfoCollectionEntity entity);
|
||||||
|
|
||||||
MpActivityInfoCollectionEntity convert2Entity(AppMpSignUpActivityReq request);
|
|
||||||
|
/**
|
||||||
|
* 请求参数转换成实体
|
||||||
|
* @param request 请求参数
|
||||||
|
* @return 实体
|
||||||
|
*/
|
||||||
|
MpActivityInfoCollectionEntity convertOne2Entity(AppMpSignUpActivityReq request);
|
||||||
}
|
}
|
||||||
@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.seer.teach.common.enums.ResultCodeEnum;
|
import com.seer.teach.common.enums.ResultCodeEnum;
|
||||||
import com.seer.teach.common.utils.AssertUtils;
|
import com.seer.teach.common.utils.AssertUtils;
|
||||||
import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq;
|
import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq;
|
||||||
|
import com.seer.teach.mp.app.controller.req.TestChildCharacterReq;
|
||||||
import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp;
|
import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp;
|
||||||
|
import com.seer.teach.mp.app.controller.resp.TestChildCharacterResp;
|
||||||
import com.seer.teach.mp.app.convert.AppMpActivityInfoCollectionConvert;
|
import com.seer.teach.mp.app.convert.AppMpActivityInfoCollectionConvert;
|
||||||
import com.seer.teach.mp.entity.MpActivityEntity;
|
import com.seer.teach.mp.entity.MpActivityEntity;
|
||||||
import com.seer.teach.mp.entity.MpActivityInfoCollectionEntity;
|
import com.seer.teach.mp.entity.MpActivityInfoCollectionEntity;
|
||||||
@ -16,31 +18,42 @@ 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;
|
||||||
import com.seer.teach.mp.service.IMpParentAgentActivityRelationService;
|
import com.seer.teach.mp.service.IMpParentAgentActivityRelationService;
|
||||||
|
import com.seer.teach.teacher.service.AiModelCallService;
|
||||||
|
import com.seer.teach.teacher.service.platform.LlmResponse;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class AppParentAgentActivityService {
|
public class AppParentAgentActivityService implements IAppParentAgentActivityService {
|
||||||
|
|
||||||
private final IMpParentAgentActivityRelationService parentAgentActivityRelationService;
|
private final IMpParentAgentActivityRelationService parentAgentActivityRelationService;
|
||||||
|
|
||||||
private final IMpActivityInfoCollectionService activityInfoCollectionService;
|
private final IMpActivityInfoCollectionService activityInfoCollectionService;
|
||||||
|
|
||||||
private final IMpActivityService activityService;
|
private final IMpActivityService activityService;
|
||||||
|
|
||||||
private final IMpAgentService agentService;
|
private final IMpAgentService agentService;
|
||||||
|
|
||||||
private final IMpAgentActivityParticipantService mpAgentActivityParticipantService;
|
private final IMpAgentActivityParticipantService mpAgentActivityParticipantService;
|
||||||
|
|
||||||
|
private final AiModelCallService aiModelCallService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报名活动
|
* 报名活动
|
||||||
*
|
*
|
||||||
* @param request 报名信息
|
* @param request 报名信息
|
||||||
* @param parentId 家长ID
|
* @param parentId 家长ID
|
||||||
* @return true表示成功,false表示失败
|
* @return true表示成功,false表示失败
|
||||||
*/
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class, timeout = 120)
|
||||||
public boolean signUpForActivityWithInfo(AppMpSignUpActivityReq request, Integer parentId) {
|
public boolean signUpForActivityWithInfo(AppMpSignUpActivityReq request, Integer parentId) {
|
||||||
Integer agentId = request.getAgentId();
|
Integer agentId = request.getAgentId();
|
||||||
Integer activityId = request.getActivityId();
|
Integer activityId = request.getActivityId();
|
||||||
@ -67,9 +80,10 @@ public class AppParentAgentActivityService {
|
|||||||
boolean saved = parentAgentActivityRelationService.save(relation);
|
boolean saved = parentAgentActivityRelationService.save(relation);
|
||||||
log.info("报名结果:{},关系ID:{}", saved, relation.getId());
|
log.info("报名结果:{},关系ID:{}", saved, relation.getId());
|
||||||
|
|
||||||
if(saved){
|
if (saved) {
|
||||||
MpActivityInfoCollectionEntity mpActivityInfoCollectionEntity = AppMpActivityInfoCollectionConvert.INSTANCE.convert2Entity(request);
|
MpActivityInfoCollectionEntity mpActivityInfoCollectionEntity = AppMpActivityInfoCollectionConvert.INSTANCE.convertOne2Entity(request);
|
||||||
mpActivityInfoCollectionEntity.setRelationId(relation.getId());
|
mpActivityInfoCollectionEntity.setRelationId(relation.getId());
|
||||||
|
mpActivityInfoCollectionEntity.setParentId(parentId);
|
||||||
boolean activityInfoCollectionResult = activityInfoCollectionService.save(mpActivityInfoCollectionEntity);
|
boolean activityInfoCollectionResult = activityInfoCollectionService.save(mpActivityInfoCollectionEntity);
|
||||||
log.info("活动信息收集结果:{}", activityInfoCollectionResult);
|
log.info("活动信息收集结果:{}", activityInfoCollectionResult);
|
||||||
return activityInfoCollectionResult;
|
return activityInfoCollectionResult;
|
||||||
@ -80,19 +94,33 @@ public class AppParentAgentActivityService {
|
|||||||
/**
|
/**
|
||||||
* 更新活动信息
|
* 更新活动信息
|
||||||
*
|
*
|
||||||
* @param request 活动信息
|
* @param request 活动信息
|
||||||
* @param parentId 家长ID
|
* @param parentId 家长ID
|
||||||
* @return true表示成功,false表示失败
|
* @return true表示成功,false表示失败
|
||||||
*/
|
*/
|
||||||
public boolean updateActivityInfo(AppMpSignUpActivityReq request, Integer parentId) {
|
public boolean updateActivityInfo(AppMpSignUpActivityReq request, Integer parentId) {
|
||||||
|
MpActivityInfoCollectionEntity entity = activityInfoCollectionService.getById(request.getId());
|
||||||
|
if (entity == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Integer agentId = request.getAgentId();
|
Integer agentId = request.getAgentId();
|
||||||
Integer activityId = request.getActivityId();
|
Integer activityId = request.getActivityId();
|
||||||
MpParentAgentActivityRelationEntity relation = parentAgentActivityRelationService.getByAgentIdAndActivityIdAndParentId(agentId, activityId, parentId);
|
MpParentAgentActivityRelationEntity relation = parentAgentActivityRelationService.getByAgentIdAndActivityIdAndParentId(agentId, activityId, parentId);
|
||||||
AssertUtils.notNull(relation, ResultCodeEnum.PARENT_NOT_SIGNED_UP);
|
AssertUtils.notNull(relation, ResultCodeEnum.PARENT_NOT_SIGNED_UP);
|
||||||
|
entity.setRelationId(relation.getId());
|
||||||
MpActivityInfoCollectionEntity mpActivityInfoCollectionEntity = AppMpActivityInfoCollectionConvert.INSTANCE.convert2Entity(request);
|
entity.setParentId(parentId);
|
||||||
mpActivityInfoCollectionEntity.setRelationId(relation.getId());
|
entity.setMobile(request.getMobile());
|
||||||
return activityInfoCollectionService.updateById(mpActivityInfoCollectionEntity);
|
entity.setChildName(request.getChildName());
|
||||||
|
entity.setChildGender(request.getChildGender());
|
||||||
|
entity.setChildBirthDate(request.getChildBirthDate());
|
||||||
|
entity.setGrade(request.getGrade());
|
||||||
|
entity.setSchool(request.getSchool());
|
||||||
|
entity.setRegion(request.getRegion());
|
||||||
|
entity.setParentIdentity(request.getParentIdentity());
|
||||||
|
entity.setLearningSituation(request.getLearningSituation());
|
||||||
|
entity.setWeakSubjectIds(request.getWeakSubjectIds());
|
||||||
|
entity.setStrongSubjectIds(request.getStrongSubjectIds());
|
||||||
|
return activityInfoCollectionService.updateById(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,4 +161,92 @@ public class AppParentAgentActivityService {
|
|||||||
return AppMpActivityInfoCollectionConvert.INSTANCE.convert2Resp(activityInfoCollection);
|
return AppMpActivityInfoCollectionConvert.INSTANCE.convert2Resp(activityInfoCollection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试孩子性格
|
||||||
|
*
|
||||||
|
* @param request 测试请求对象
|
||||||
|
* @param parentId 家长ID
|
||||||
|
* @return 性格测试结果
|
||||||
|
*/
|
||||||
|
public TestChildCharacterResp testChildCharacter(TestChildCharacterReq request, Integer parentId) {
|
||||||
|
log.info("开始测试孩子性格,家长ID: {},请求参数: {}", parentId, request);
|
||||||
|
|
||||||
|
// 构建AI模型的提示词
|
||||||
|
String prompt = buildCharacterTestPrompt(request);
|
||||||
|
|
||||||
|
// 调用AI模型获取性格分析
|
||||||
|
LlmResponse response = aiModelCallService.callModel("child_character_analysis", prompt, new HashMap<>(), parentId);
|
||||||
|
|
||||||
|
TestChildCharacterResp result = new TestChildCharacterResp();
|
||||||
|
|
||||||
|
if (response != null && response.getChoices() != null && !response.getChoices().isEmpty()) {
|
||||||
|
// 获取AI返回的内容
|
||||||
|
String content = response.getChoices().get(0).getMessage().getContent();
|
||||||
|
result = parseAiResponse(content);
|
||||||
|
} else {
|
||||||
|
// 如果AI调用失败,返回默认响应
|
||||||
|
result.setCharacterAnalysis("暂时无法分析孩子的性格,请稍后重试。");
|
||||||
|
result.setCharacterTraits("未知");
|
||||||
|
result.setSuggestions("请尝试重新分析或咨询专业教育专家。");
|
||||||
|
result.setCharacterType("待定");
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("性格测试完成,返回结果: {}", result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建性格测试的提示词
|
||||||
|
*
|
||||||
|
* @param request 请求参数
|
||||||
|
* @return 提示词内容
|
||||||
|
*/
|
||||||
|
private String buildCharacterTestPrompt(TestChildCharacterReq request) {
|
||||||
|
StringBuilder prompt = new StringBuilder();
|
||||||
|
prompt.append("请根据以下孩子信息分析其性格特点,并给出教育建议:\n");
|
||||||
|
prompt.append("- 性别: ").append(request.getChildGender()).append("\n");
|
||||||
|
prompt.append("- 出生日期: ").append(request.getChildBirthDate()).append("\n");
|
||||||
|
prompt.append("- 星座: ").append(request.getConstellation() != null ? request.getConstellation() : "未知").append("\n");
|
||||||
|
prompt.append("- 年级: ").append(request.getGrade()).append("\n");
|
||||||
|
prompt.append("- 学习情况: ").append(request.getLearningSituation()).append("\n");
|
||||||
|
prompt.append("- 偏科情况: ").append(request.getWeakSubject()).append("\n");
|
||||||
|
prompt.append("\n请按照以下格式返回分析结果:\n");
|
||||||
|
prompt.append("1. 性格分析:[具体分析内容]\n");
|
||||||
|
prompt.append("2. 性格特征:[关键特征]\n");
|
||||||
|
prompt.append("3. 教育建议:[针对性建议]\n");
|
||||||
|
prompt.append("4. 性格类型:[简要分类]");
|
||||||
|
|
||||||
|
return prompt.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析AI返回的结果
|
||||||
|
*
|
||||||
|
* @param aiResponse AI返回的原始内容
|
||||||
|
* @return 解析后的响应对象
|
||||||
|
*/
|
||||||
|
private TestChildCharacterResp parseAiResponse(String aiResponse) {
|
||||||
|
TestChildCharacterResp resp = new TestChildCharacterResp();
|
||||||
|
|
||||||
|
// 简单解析AI返回的内容
|
||||||
|
String[] parts = aiResponse.split("\n");
|
||||||
|
for (String part : parts) {
|
||||||
|
if (part.startsWith("1. 性格分析:") || part.contains("性格分析")) {
|
||||||
|
resp.setCharacterAnalysis(part.replaceFirst("^[0-9]+\\.\\s*", "").replace("性格分析:", "").trim());
|
||||||
|
} else if (part.startsWith("2. 性格特征:") || part.contains("性格特征")) {
|
||||||
|
resp.setCharacterTraits(part.replaceFirst("^[0-9]+\\.\\s*", "").replace("性格特征:", "").trim());
|
||||||
|
} else if (part.startsWith("3. 教育建议:") || part.contains("教育建议")) {
|
||||||
|
resp.setSuggestions(part.replaceFirst("^[0-9]+\\.\\s*", "").replace("教育建议:", "").trim());
|
||||||
|
} else if (part.startsWith("4. 性格类型:") || part.contains("性格类型")) {
|
||||||
|
resp.setCharacterType(part.replaceFirst("^[0-9]+\\.\\s*", "").replace("性格类型:", "").trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果解析失败,将整个内容作为性格分析
|
||||||
|
if (resp.getCharacterAnalysis() == null || resp.getCharacterAnalysis().isEmpty()) {
|
||||||
|
resp.setCharacterAnalysis(aiResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -30,4 +30,14 @@ public interface IAppActivityService {
|
|||||||
* @return 活动详情
|
* @return 活动详情
|
||||||
*/
|
*/
|
||||||
AppActivityResp getById(Integer id);
|
AppActivityResp getById(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取活动二维码
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param agentId 代理商ID
|
||||||
|
* @param activityId 活动ID
|
||||||
|
* @return 活动二维码
|
||||||
|
*/
|
||||||
|
String getQrCode(Integer userId,Integer agentId,Integer activityId,String appId);
|
||||||
}
|
}
|
||||||
@ -1,5 +1,7 @@
|
|||||||
package com.seer.teach.mp.app.service;
|
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 com.seer.teach.mp.app.controller.resp.AgentActivityParentInfoResp;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -23,4 +25,22 @@ public interface IAppAgentActivityParentInfoService {
|
|||||||
* @return 参与活动的家长信息列表
|
* @return 参与活动的家长信息列表
|
||||||
*/
|
*/
|
||||||
List<AgentActivityParentInfoResp> getParentsByActivityAndAgent(Integer activityId, Integer agentId,Integer userId);
|
List<AgentActivityParentInfoResp> getParentsByActivityAndAgent(Integer activityId, Integer agentId,Integer userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页获取参加指定活动的家长信息列表
|
||||||
|
*
|
||||||
|
* @param queryReq 查询请求参数
|
||||||
|
* @return 分页的家长信息列表
|
||||||
|
*/
|
||||||
|
PageListBean<AgentActivityParentInfoResp> getParentsByActivityAndAgent(Integer userId,AgentActivityParentQueryReq queryReq);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录代理商拨打电话联系家长的次数
|
||||||
|
*
|
||||||
|
* @param collectionId 活动信息收集记录ID
|
||||||
|
* @param incrementCount 增加的联系次数
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 更新后的联系次数
|
||||||
|
*/
|
||||||
|
boolean recordContactCall(Integer collectionId, Integer incrementCount,Integer userId);
|
||||||
}
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
package com.seer.teach.mp.app.service;
|
package com.seer.teach.mp.app.service;
|
||||||
|
|
||||||
|
import com.seer.teach.mp.app.controller.req.AppMpAgentActivityQrCodeQueryReq;
|
||||||
import com.seer.teach.mp.app.controller.resp.AgentActivityParticipantResp;
|
import com.seer.teach.mp.app.controller.resp.AgentActivityParticipantResp;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -23,4 +24,12 @@ public interface IAppAgentActivityParticipantService {
|
|||||||
*/
|
*/
|
||||||
List<AgentActivityParticipantResp> getParticipantsByActivityAndAgent(Integer agentId,Integer userId);
|
List<AgentActivityParticipantResp> getParticipantsByActivityAndAgent(Integer agentId,Integer userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取二维码
|
||||||
|
*
|
||||||
|
* @param req 请求参数
|
||||||
|
* @param userId 用户Id
|
||||||
|
* @return 二维码的url
|
||||||
|
*/
|
||||||
|
String getQrCode(AppMpAgentActivityQrCodeQueryReq req, Integer userId);
|
||||||
}
|
}
|
||||||
@ -0,0 +1,76 @@
|
|||||||
|
package com.seer.teach.mp.app.service;
|
||||||
|
|
||||||
|
import com.seer.teach.common.PageListBean;
|
||||||
|
import com.seer.teach.mp.app.controller.req.AppAgentEmployeeRelationQueryReq;
|
||||||
|
import com.seer.teach.mp.app.controller.req.AppAgentEmployeeRelationReq;
|
||||||
|
import com.seer.teach.mp.app.controller.resp.AppAgentEmployeeRelationResp;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* App端代理商员工关系服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Lingma
|
||||||
|
* @since 2025-12-30
|
||||||
|
*/
|
||||||
|
public interface IAppAgentEmployeeRelationService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询我的员工列表
|
||||||
|
*
|
||||||
|
* @param query 查询条件
|
||||||
|
* @return 员工关联分页列表
|
||||||
|
*/
|
||||||
|
PageListBean<AppAgentEmployeeRelationResp> pageList(AppAgentEmployeeRelationQueryReq query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增员工
|
||||||
|
*
|
||||||
|
* @param request 员工关联请求对象
|
||||||
|
* @return 操作是否成功
|
||||||
|
*/
|
||||||
|
boolean addEmployee(AppAgentEmployeeRelationReq request);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新员工信息
|
||||||
|
*
|
||||||
|
* @param request 员工关联请求对象
|
||||||
|
* @return 操作是否成功
|
||||||
|
*/
|
||||||
|
boolean updateEmployee(AppAgentEmployeeRelationReq request);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除员工
|
||||||
|
*
|
||||||
|
* @param id 关联ID
|
||||||
|
* @return 操作是否成功
|
||||||
|
*/
|
||||||
|
boolean deleteEmployee(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID获取详情
|
||||||
|
*
|
||||||
|
* @param id 关联ID
|
||||||
|
* @return 关联详情
|
||||||
|
*/
|
||||||
|
AppAgentEmployeeRelationResp getById(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据代理商ID获取所有员工列表
|
||||||
|
*
|
||||||
|
* @param agentId 代理商ID
|
||||||
|
* @return 员工关联列表
|
||||||
|
*/
|
||||||
|
List<AppAgentEmployeeRelationResp> getAllEmployeesByAgentId(Integer agentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证员工是否属于指定代理商
|
||||||
|
*
|
||||||
|
* @param relationId 关联ID
|
||||||
|
* @param employeeUserId 代理商ID
|
||||||
|
* @return 是否属于
|
||||||
|
*/
|
||||||
|
boolean isEmployeeBelongsToAgent(Integer relationId, Integer agentId);
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package com.seer.teach.mp.app.service;
|
||||||
|
|
||||||
|
import com.seer.teach.mp.app.controller.resp.JsapiSignatureResp;
|
||||||
|
import com.seer.teach.mp.app.controller.req.JsapiSignatureReq;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信公众号JS-SDK签名服务接口
|
||||||
|
*/
|
||||||
|
public interface IAppMpSignatureService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成JS-SDK签名
|
||||||
|
*
|
||||||
|
* @param req 签名请求参数
|
||||||
|
* @return JS-SDK签名响应参数
|
||||||
|
*/
|
||||||
|
JsapiSignatureResp generateJsapiSignature(JsapiSignatureReq req);
|
||||||
|
}
|
||||||
@ -0,0 +1,63 @@
|
|||||||
|
package com.seer.teach.mp.app.service;
|
||||||
|
|
||||||
|
import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq;
|
||||||
|
import com.seer.teach.mp.app.controller.req.TestChildCharacterReq;
|
||||||
|
import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp;
|
||||||
|
import com.seer.teach.mp.app.controller.resp.TestChildCharacterResp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 家长参与代理商活动服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Lingma
|
||||||
|
* @since 2025-12-30
|
||||||
|
*/
|
||||||
|
public interface IAppParentAgentActivityService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报名活动
|
||||||
|
*
|
||||||
|
* @param request 报名信息
|
||||||
|
* @param parentId 家长ID
|
||||||
|
* @return true表示成功,false表示失败
|
||||||
|
*/
|
||||||
|
boolean signUpForActivityWithInfo(AppMpSignUpActivityReq request, Integer parentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新活动信息
|
||||||
|
*
|
||||||
|
* @param request 活动信息
|
||||||
|
* @param parentId 家长ID
|
||||||
|
* @return true表示成功,false表示失败
|
||||||
|
*/
|
||||||
|
boolean updateActivityInfo(AppMpSignUpActivityReq request, Integer parentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消报名
|
||||||
|
*
|
||||||
|
* @param id 关系ID
|
||||||
|
* @param parentId 家长ID
|
||||||
|
* @return true表示成功,false表示失败
|
||||||
|
*/
|
||||||
|
boolean cancelSignUp(Integer id, Integer parentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取报名信息
|
||||||
|
*
|
||||||
|
* @param agentId 代理商ID
|
||||||
|
* @param activityId 活动ID
|
||||||
|
* @param parentId 家长ID
|
||||||
|
* @return 报名信息
|
||||||
|
*/
|
||||||
|
AppMpSignUpActivityResp getByActivityIdAndParentId(Integer agentId, Integer activityId, Integer parentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试孩子性格
|
||||||
|
*
|
||||||
|
* @param request 测试请求对象
|
||||||
|
* @param parentId 家长ID
|
||||||
|
* @return 性格测试结果
|
||||||
|
*/
|
||||||
|
TestChildCharacterResp testChildCharacter(TestChildCharacterReq request, Integer parentId);
|
||||||
|
}
|
||||||
@ -5,13 +5,22 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
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.enums.ResultCodeEnum;
|
||||||
|
import com.seer.teach.common.exception.CommonException;
|
||||||
|
import com.seer.teach.common.utils.AssertUtils;
|
||||||
import com.seer.teach.common.utils.PageConverterUtils;
|
import com.seer.teach.common.utils.PageConverterUtils;
|
||||||
import com.seer.teach.mp.app.controller.req.AppAgentActivityQueryReq;
|
import com.seer.teach.mp.app.controller.req.AppAgentActivityQueryReq;
|
||||||
|
import com.seer.teach.mp.app.controller.req.MpGenerateQrCodeReq;
|
||||||
import com.seer.teach.mp.app.controller.resp.AppActivityResp;
|
import com.seer.teach.mp.app.controller.resp.AppActivityResp;
|
||||||
|
import com.seer.teach.mp.app.controller.resp.MpQrCodeResp;
|
||||||
import com.seer.teach.mp.app.convert.AppAgentActivityConvert;
|
import com.seer.teach.mp.app.convert.AppAgentActivityConvert;
|
||||||
|
import com.seer.teach.mp.app.service.AppOfficialQrCodeService;
|
||||||
import com.seer.teach.mp.app.service.IAppActivityService;
|
import com.seer.teach.mp.app.service.IAppActivityService;
|
||||||
import com.seer.teach.mp.entity.MpActivityEntity;
|
import com.seer.teach.mp.entity.MpActivityEntity;
|
||||||
|
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
|
||||||
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.IMpAgentService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -34,6 +43,10 @@ public class AppActivityServiceImpl implements IAppActivityService {
|
|||||||
|
|
||||||
private final IMpActivityService activityService;
|
private final IMpActivityService activityService;
|
||||||
|
|
||||||
|
private final AppOfficialQrCodeService officialQrCodeService;
|
||||||
|
|
||||||
|
private final IMpAgentActivityParticipantService agentActivityParticipantService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageListBean<AppActivityResp> pageList(AppAgentActivityQueryReq query, Integer agentId) {
|
public PageListBean<AppActivityResp> pageList(AppAgentActivityQueryReq query, Integer agentId) {
|
||||||
log.info("查询参数:{}", query);
|
log.info("查询参数:{}", query);
|
||||||
@ -53,4 +66,27 @@ public class AppActivityServiceImpl implements IAppActivityService {
|
|||||||
MpActivityEntity entity = activityService.getById(id);
|
MpActivityEntity entity = activityService.getById(id);
|
||||||
return AppAgentActivityConvert.INSTANCE.convertToResp(entity);
|
return AppAgentActivityConvert.INSTANCE.convertToResp(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQrCode(Integer userId,Integer agentId,Integer activityId,String appId) {
|
||||||
|
MpActivityEntity activity = activityService.getById(activityId);
|
||||||
|
AssertUtils.notNull(activity, ResultCodeEnum.INVALID_ACTIVITY);
|
||||||
|
|
||||||
|
if(activity.getStatus() != 1){
|
||||||
|
throw new CommonException(ResultCodeEnum.INVALID_ACTIVITY);
|
||||||
|
}
|
||||||
|
MpAgentActivityParticipantEntity relation = agentActivityParticipantService.getParticipantsByActivityAndAgent(activityId, agentId);
|
||||||
|
AssertUtils.notNull(relation, ResultCodeEnum.INVALID_ACTIVITY);
|
||||||
|
if(StringUtils.isNotBlank(relation.getQrCodeUrl())){
|
||||||
|
return relation.getQrCodeUrl();
|
||||||
|
}
|
||||||
|
MpGenerateQrCodeReq req = new MpGenerateQrCodeReq();
|
||||||
|
req.setSceneStr("agentId=" + agentId + "&activityId=" + activityId);
|
||||||
|
req.setAppId(appId);
|
||||||
|
req.setType(2);
|
||||||
|
MpQrCodeResp mpQrCodeResp = officialQrCodeService.generateQrCode(req);
|
||||||
|
relation.setQrCodeUrl(mpQrCodeResp.getQrCodeUrl());
|
||||||
|
agentActivityParticipantService.updateById(relation);
|
||||||
|
return mpQrCodeResp.getQrCodeUrl();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,8 +1,12 @@
|
|||||||
package com.seer.teach.mp.app.service.impl;
|
package com.seer.teach.mp.app.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
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.enums.ResultCodeEnum;
|
||||||
import com.seer.teach.common.exception.CommonException;
|
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.controller.resp.AgentActivityParentInfoResp;
|
||||||
import com.seer.teach.mp.app.service.IAppAgentActivityParentInfoService;
|
import com.seer.teach.mp.app.service.IAppAgentActivityParentInfoService;
|
||||||
import com.seer.teach.mp.app.service.IAppAgentService;
|
import com.seer.teach.mp.app.service.IAppAgentService;
|
||||||
@ -38,7 +42,7 @@ public class AppAgentActivityParentInfoServiceImpl implements IAppAgentActivityP
|
|||||||
if (Objects.isNull(userAgentId)) {
|
if (Objects.isNull(userAgentId)) {
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
log.info("userAgentId:{}", userAgentId);
|
log.info("getParentsByActivityAndAgent userAgentId:{}", userAgentId);
|
||||||
if(userAgentId.intValue() != agentId){
|
if(userAgentId.intValue() != agentId){
|
||||||
throw new CommonException(ResultCodeEnum.RELATION_NOT_FOUND);
|
throw new CommonException(ResultCodeEnum.RELATION_NOT_FOUND);
|
||||||
}
|
}
|
||||||
@ -55,6 +59,48 @@ public class AppAgentActivityParentInfoServiceImpl implements IAppAgentActivityP
|
|||||||
.collect(Collectors.toList());
|
.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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean recordContactCall(Integer collectionId, Integer incrementCount,Integer userId) {
|
||||||
|
// 查询指定的活动信息收集记录
|
||||||
|
MpActivityInfoCollectionEntity entity = activityInfoCollectionService.getById(collectionId);
|
||||||
|
if (entity == null) {
|
||||||
|
throw new CommonException(ResultCodeEnum.ACTIVITY_NOT_FOUND);
|
||||||
|
}
|
||||||
|
// 更新联系次数
|
||||||
|
Integer currentCount = entity.getContactCallCount();
|
||||||
|
if (currentCount == null) {
|
||||||
|
currentCount = 0;
|
||||||
|
}
|
||||||
|
Integer newCount = currentCount + incrementCount;
|
||||||
|
entity.setContactCallCount(newCount);
|
||||||
|
return activityInfoCollectionService.updateById(entity);
|
||||||
|
}
|
||||||
|
|
||||||
private AgentActivityParentInfoResp convertToResp(MpActivityInfoCollectionEntity entity) {
|
private AgentActivityParentInfoResp convertToResp(MpActivityInfoCollectionEntity entity) {
|
||||||
AgentActivityParentInfoResp resp = new AgentActivityParentInfoResp();
|
AgentActivityParentInfoResp resp = new AgentActivityParentInfoResp();
|
||||||
resp.setId(entity.getId());
|
resp.setId(entity.getId());
|
||||||
@ -67,6 +113,8 @@ public class AppAgentActivityParentInfoServiceImpl implements IAppAgentActivityP
|
|||||||
resp.setChildBirthDate(entity.getChildBirthDate());
|
resp.setChildBirthDate(entity.getChildBirthDate());
|
||||||
resp.setGrade(entity.getGrade());
|
resp.setGrade(entity.getGrade());
|
||||||
resp.setSchool(entity.getSchool());
|
resp.setSchool(entity.getSchool());
|
||||||
|
resp.setMobile(entity.getMobile());
|
||||||
|
resp.setContactCallCount(entity.getContactCallCount());
|
||||||
resp.setRegion(entity.getRegion());
|
resp.setRegion(entity.getRegion());
|
||||||
resp.setParentIdentity(entity.getParentIdentity());
|
resp.setParentIdentity(entity.getParentIdentity());
|
||||||
resp.setLearningSituation(entity.getLearningSituation());
|
resp.setLearningSituation(entity.getLearningSituation());
|
||||||
|
|||||||
@ -1,20 +1,30 @@
|
|||||||
package com.seer.teach.mp.app.service.impl;
|
package com.seer.teach.mp.app.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.http.HttpDownloader;
|
||||||
import com.seer.teach.common.enums.ResultCodeEnum;
|
import com.seer.teach.common.enums.ResultCodeEnum;
|
||||||
import com.seer.teach.common.exception.CommonException;
|
import com.seer.teach.common.exception.CommonException;
|
||||||
|
import com.seer.teach.common.service.CommonFileService;
|
||||||
|
import com.seer.teach.common.utils.AssertUtils;
|
||||||
|
import com.seer.teach.mp.app.controller.req.AppMpAgentActivityQrCodeQueryReq;
|
||||||
|
import com.seer.teach.mp.app.controller.req.MpGenerateQrCodeReq;
|
||||||
import com.seer.teach.mp.app.controller.resp.AgentActivityParticipantResp;
|
import com.seer.teach.mp.app.controller.resp.AgentActivityParticipantResp;
|
||||||
|
import com.seer.teach.mp.app.controller.resp.MpQrCodeResp;
|
||||||
|
import com.seer.teach.mp.app.service.AppOfficialQrCodeService;
|
||||||
import com.seer.teach.mp.app.service.IAppAgentActivityParticipantService;
|
import com.seer.teach.mp.app.service.IAppAgentActivityParticipantService;
|
||||||
import com.seer.teach.mp.app.service.IAppAgentService;
|
import com.seer.teach.mp.app.service.IAppAgentService;
|
||||||
import com.seer.teach.mp.entity.MpActivityEntity;
|
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.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.user.api.UserInfoServiceApi;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -36,12 +46,14 @@ public class AppAgentActivityParticipantServiceImpl implements IAppAgentActivity
|
|||||||
|
|
||||||
private final IMpAgentActivityParticipantService agentActivityParticipantService;
|
private final IMpAgentActivityParticipantService agentActivityParticipantService;
|
||||||
|
|
||||||
private final UserInfoServiceApi userInfoServiceApi;
|
|
||||||
|
|
||||||
private final IAppAgentService appAgentService;
|
private final IAppAgentService appAgentService;
|
||||||
|
|
||||||
private final IMpActivityService mpActivityService;
|
private final IMpActivityService mpActivityService;
|
||||||
|
|
||||||
|
private final AppOfficialQrCodeService officialQrCodeService;
|
||||||
|
|
||||||
|
private final CommonFileService commonFileService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AgentActivityParticipantResp> getParticipantsByActivityAndAgent(Integer agentId, Integer userId) {
|
public List<AgentActivityParticipantResp> getParticipantsByActivityAndAgent(Integer agentId, Integer userId) {
|
||||||
var userAgentId = appAgentService.getAgentIdByUserId(userId);
|
var userAgentId = appAgentService.getAgentIdByUserId(userId);
|
||||||
@ -68,6 +80,42 @@ public class AppAgentActivityParticipantServiceImpl implements IAppAgentActivity
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQrCode(AppMpAgentActivityQrCodeQueryReq req, Integer userId) {
|
||||||
|
Integer activityId = req.getActivityId();
|
||||||
|
Integer agentId = req.getAgentId();
|
||||||
|
log.info("getQrCode param activityId:{},agentId:{}", activityId, agentId);
|
||||||
|
MpActivityEntity activity = mpActivityService.getById(activityId);
|
||||||
|
AssertUtils.notNull(activity, ResultCodeEnum.INVALID_ACTIVITY);
|
||||||
|
|
||||||
|
if(activity.getStatus() != 1){
|
||||||
|
throw new CommonException(ResultCodeEnum.INVALID_ACTIVITY);
|
||||||
|
}
|
||||||
|
MpAgentActivityParticipantEntity relation = agentActivityParticipantService.getParticipantsByActivityAndAgent(activityId, agentId);
|
||||||
|
AssertUtils.notNull(relation, ResultCodeEnum.INVALID_ACTIVITY);
|
||||||
|
if(StringUtils.isNotBlank(relation.getQrCodeUrl())){
|
||||||
|
return relation.getQrCodeUrl();
|
||||||
|
}
|
||||||
|
MpGenerateQrCodeReq generateQrCodeReq = new MpGenerateQrCodeReq();
|
||||||
|
generateQrCodeReq.setSceneStr("agentId=" + agentId + "&activityId=" + activityId);
|
||||||
|
generateQrCodeReq.setAppId(req.getAppId());
|
||||||
|
generateQrCodeReq.setType(2);
|
||||||
|
MpQrCodeResp mpQrCodeResp = officialQrCodeService.generateQrCode(generateQrCodeReq);
|
||||||
|
if(StringUtils.isNotEmpty(mpQrCodeResp.getQrCodeUrl())){
|
||||||
|
try {
|
||||||
|
byte[] bytes = HttpDownloader.downloadBytes(mpQrCodeResp.getQrCodeUrl());
|
||||||
|
InputStream inputStream = new ByteArrayInputStream(bytes);
|
||||||
|
String url = commonFileService.upload(inputStream,"qrcode", "agent_activity", MediaType.IMAGE_PNG_VALUE);
|
||||||
|
relation.setQrCodeUrl(url);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("download qrcode error", e);
|
||||||
|
relation.setQrCodeUrl(mpQrCodeResp.getQrCodeUrl());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
agentActivityParticipantService.updateById(relation);
|
||||||
|
return mpQrCodeResp.getQrCodeUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private AgentActivityParticipantResp convertToDto(MpAgentActivityParticipantEntity entity, Map<Integer, MpActivityEntity> activityInfoMap) {
|
private AgentActivityParticipantResp convertToDto(MpAgentActivityParticipantEntity entity, Map<Integer, MpActivityEntity> activityInfoMap) {
|
||||||
AgentActivityParticipantResp resp = new AgentActivityParticipantResp();
|
AgentActivityParticipantResp resp = new AgentActivityParticipantResp();
|
||||||
|
|||||||
@ -0,0 +1,221 @@
|
|||||||
|
package com.seer.teach.mp.app.service.impl;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
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.enums.ResultCodeEnum;
|
||||||
|
import com.seer.teach.common.enums.RoleEnum;
|
||||||
|
import com.seer.teach.common.exception.CommonException;
|
||||||
|
import com.seer.teach.common.utils.AssertUtils;
|
||||||
|
import com.seer.teach.common.utils.PageConverterUtils;
|
||||||
|
import com.seer.teach.mp.app.controller.req.AppAgentEmployeeRelationQueryReq;
|
||||||
|
import com.seer.teach.mp.app.controller.req.AppAgentEmployeeRelationReq;
|
||||||
|
import com.seer.teach.mp.app.controller.resp.AppAgentEmployeeRelationResp;
|
||||||
|
import com.seer.teach.mp.app.service.IAppAgentEmployeeRelationService;
|
||||||
|
import com.seer.teach.mp.entity.MpAgentEmployeeRelationEntity;
|
||||||
|
import com.seer.teach.mp.service.IMpAgentEmployeeRelationService;
|
||||||
|
import com.seer.teach.mp.service.IMpAgentService;
|
||||||
|
import com.seer.teach.user.api.UserInfoServiceApi;
|
||||||
|
import com.seer.teach.user.api.dto.UserInfoDTO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* App端代理商员工关系服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Lingma
|
||||||
|
* @since 2025-12-30
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AppAgentEmployeeRelationServiceImpl implements IAppAgentEmployeeRelationService {
|
||||||
|
|
||||||
|
private final IMpAgentEmployeeRelationService mpAgentEmployeeRelationService;
|
||||||
|
|
||||||
|
private final IMpAgentService mpAgentService;
|
||||||
|
|
||||||
|
private final UserInfoServiceApi userInfoServiceApi;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageListBean<AppAgentEmployeeRelationResp> pageList(AppAgentEmployeeRelationQueryReq query) {
|
||||||
|
Integer employeeUserId = StpUtil.getLoginIdAsInt();
|
||||||
|
Integer agentId = mpAgentEmployeeRelationService.lambdaQuery().eq(MpAgentEmployeeRelationEntity::getEmployeeUserId, employeeUserId).one().getAgentId();
|
||||||
|
AssertUtils.notNull(agentId, ResultCodeEnum.AGENT_EMPLOYEE_NOT_FOUND);
|
||||||
|
log.info("查询参数:{}", query);
|
||||||
|
IPage<MpAgentEmployeeRelationEntity> page = new Page<>(query.getPageNo(), query.getPageSize());
|
||||||
|
LambdaQueryWrapper<MpAgentEmployeeRelationEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(MpAgentEmployeeRelationEntity::getAgentId, agentId)
|
||||||
|
.like(StringUtils.isNotBlank(query.getPosition()), MpAgentEmployeeRelationEntity::getPosition, query.getPosition())
|
||||||
|
.eq(query.getStatus() != null, MpAgentEmployeeRelationEntity::getStatus, query.getStatus());
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(query.getEmployeeName())) {
|
||||||
|
List<Integer> matchUserIds = userInfoServiceApi.getUserIdsByUserNameLike(query.getEmployeeName());
|
||||||
|
if (CollectionUtil.isEmpty(matchUserIds)) {
|
||||||
|
log.info("无匹配员工");
|
||||||
|
return PageConverterUtils.convertPageListBean(page, null);
|
||||||
|
}
|
||||||
|
wrapper.in(MpAgentEmployeeRelationEntity::getEmployeeUserId, matchUserIds);
|
||||||
|
}
|
||||||
|
IPage<MpAgentEmployeeRelationEntity> pageResult = mpAgentEmployeeRelationService.page(page, wrapper);
|
||||||
|
|
||||||
|
if (CollectionUtil.isEmpty(pageResult.getRecords())) {
|
||||||
|
log.info("查询结果为空");
|
||||||
|
}
|
||||||
|
log.info("查询代理商员工数量:{}", pageResult.getTotal());
|
||||||
|
|
||||||
|
return PageConverterUtils.convertPageListBean(pageResult, this::convertToRespList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addEmployee(AppAgentEmployeeRelationReq request) {
|
||||||
|
log.info("新增员工参数:{}", request);
|
||||||
|
LambdaQueryWrapper<MpAgentEmployeeRelationEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(MpAgentEmployeeRelationEntity::getAgentId, request.getAgentId())
|
||||||
|
.eq(MpAgentEmployeeRelationEntity::getContactPhone, request.getMobile());
|
||||||
|
|
||||||
|
MpAgentEmployeeRelationEntity existing = mpAgentEmployeeRelationService.getOne(wrapper);
|
||||||
|
if (existing != null) {
|
||||||
|
throw new CommonException(ResultCodeEnum.DATA_REPEAT_ERROR, "该员工已属于当前代理商");
|
||||||
|
}
|
||||||
|
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||||
|
userInfoDTO.setUserName(request.getEmployeeName());
|
||||||
|
userInfoDTO.setMobile(request.getMobile());
|
||||||
|
userInfoDTO.setPassword(request.getPassword());
|
||||||
|
userInfoDTO.setRoleCode(RoleEnum.AGENT);
|
||||||
|
Integer userId = userInfoServiceApi.addUserInfoAndAssignRole(userInfoDTO);
|
||||||
|
|
||||||
|
MpAgentEmployeeRelationEntity entity = new MpAgentEmployeeRelationEntity();
|
||||||
|
entity.setAgentId(request.getAgentId());
|
||||||
|
entity.setEmployeeName(request.getEmployeeName());
|
||||||
|
entity.setContactPhone(request.getMobile());
|
||||||
|
entity.setAgentName(mpAgentService.getById(request.getAgentId()).getAgentName());
|
||||||
|
entity.setEmployeeUserId(userId);
|
||||||
|
entity.setPosition(request.getPosition());
|
||||||
|
entity.setStatus(request.getStatus());
|
||||||
|
|
||||||
|
boolean result = mpAgentEmployeeRelationService.save(entity);
|
||||||
|
log.info("新增员工结果:{}", result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateEmployee(AppAgentEmployeeRelationReq request) {
|
||||||
|
// 验证员工是否属于当前代理商(通过ID查询并验证)
|
||||||
|
MpAgentEmployeeRelationEntity existing = mpAgentEmployeeRelationService.getById(request.getId());
|
||||||
|
AssertUtils.notNull(existing, ResultCodeEnum.DATA_NOT_EXIST);
|
||||||
|
|
||||||
|
if (!existing.getAgentId().equals(request.getAgentId())) {
|
||||||
|
throw new CommonException(ResultCodeEnum.PERMISSION_DENIED, "无权限操作此员工");
|
||||||
|
}
|
||||||
|
|
||||||
|
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||||
|
userInfoDTO.setUserName(request.getEmployeeName());
|
||||||
|
userInfoDTO.setMobile(request.getMobile());
|
||||||
|
userInfoDTO.setId(existing.getEmployeeUserId());
|
||||||
|
if (StringUtils.isNotBlank(request.getPassword())) {
|
||||||
|
userInfoDTO.setPassword(request.getPassword());
|
||||||
|
log.info("更新员工密码");
|
||||||
|
}
|
||||||
|
boolean updateUserResult = userInfoServiceApi.updateUserInfo(userInfoDTO);
|
||||||
|
log.info("更新员工结果:{}", updateUserResult);
|
||||||
|
|
||||||
|
MpAgentEmployeeRelationEntity updateEntity = new MpAgentEmployeeRelationEntity();
|
||||||
|
updateEntity.setId(request.getId());
|
||||||
|
updateEntity.setPosition(request.getPosition());
|
||||||
|
updateEntity.setStatus(request.getStatus());
|
||||||
|
updateEntity.setEmployeeName(request.getEmployeeName());
|
||||||
|
updateEntity.setContactPhone(request.getMobile());
|
||||||
|
updateEntity.setAgentName(mpAgentService.getById(request.getAgentId()).getAgentName());
|
||||||
|
updateEntity.setAgentId(request.getAgentId());
|
||||||
|
updateEntity.setEmployeeUserId(existing.getEmployeeUserId());
|
||||||
|
boolean result = mpAgentEmployeeRelationService.updateById(updateEntity);
|
||||||
|
log.info("更新员工结果:{}", result);
|
||||||
|
return result && updateUserResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteEmployee(Integer id) {
|
||||||
|
MpAgentEmployeeRelationEntity existing = mpAgentEmployeeRelationService.getById(id);
|
||||||
|
AssertUtils.notNull(existing, ResultCodeEnum.DATA_NOT_EXIST);
|
||||||
|
boolean result = mpAgentEmployeeRelationService.removeById(id);
|
||||||
|
log.info("删除员工结果:{}", result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AppAgentEmployeeRelationResp getById(Integer id) {
|
||||||
|
MpAgentEmployeeRelationEntity entity = mpAgentEmployeeRelationService.getById(id);
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return convertToResp(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AppAgentEmployeeRelationResp> getAllEmployeesByAgentId(Integer agentId) {
|
||||||
|
List<MpAgentEmployeeRelationEntity> entities = mpAgentEmployeeRelationService.list(
|
||||||
|
new LambdaQueryWrapper<MpAgentEmployeeRelationEntity>()
|
||||||
|
.eq(MpAgentEmployeeRelationEntity::getAgentId, agentId)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (CollectionUtil.isEmpty(entities)) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
return entities.stream()
|
||||||
|
.map(this::convertToResp)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmployeeBelongsToAgent(Integer relationId, Integer agentId) {
|
||||||
|
MpAgentEmployeeRelationEntity entity = mpAgentEmployeeRelationService.lambdaQuery()
|
||||||
|
.eq(MpAgentEmployeeRelationEntity::getId, relationId)
|
||||||
|
.eq(MpAgentEmployeeRelationEntity::getAgentId, agentId)
|
||||||
|
.one();
|
||||||
|
return entity != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将实体转换为响应对象
|
||||||
|
*/
|
||||||
|
private AppAgentEmployeeRelationResp convertToResp(MpAgentEmployeeRelationEntity entity) {
|
||||||
|
AppAgentEmployeeRelationResp resp = new AppAgentEmployeeRelationResp();
|
||||||
|
resp.setId(entity.getId());
|
||||||
|
resp.setAgentId(entity.getAgentId());
|
||||||
|
resp.setPosition(entity.getPosition());
|
||||||
|
resp.setStatus(entity.getStatus());
|
||||||
|
resp.setCreateTime(entity.getCreateTime());
|
||||||
|
resp.setUpdateTime(entity.getUpdateTime());
|
||||||
|
|
||||||
|
// 通过用户服务获取员工的详细信息
|
||||||
|
if (entity.getEmployeeUserId() != null) {
|
||||||
|
UserInfoDTO userInfo = userInfoServiceApi.getByUserId(entity.getEmployeeUserId());
|
||||||
|
resp.setEmployeeUserInfo(userInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量转换实体为响应对象
|
||||||
|
*/
|
||||||
|
private List<AppAgentEmployeeRelationResp> convertToRespList(List<MpAgentEmployeeRelationEntity> entities) {
|
||||||
|
if (CollectionUtil.isEmpty(entities)) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
return entities.stream()
|
||||||
|
.map(this::convertToResp)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -10,6 +10,8 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import com.seer.teach.mp.app.convert.AppAgentConvert;
|
import com.seer.teach.mp.app.convert.AppAgentConvert;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* App端代理商服务实现类
|
* App端代理商服务实现类
|
||||||
*/
|
*/
|
||||||
@ -27,10 +29,13 @@ public class AppAgentServiceImpl implements IAppAgentService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
MpAgentEntity agentEntity = mpAgentService.getAgentById(mpAgentEmployeeRelationEntity.getAgentId());
|
MpAgentEntity agentEntity = mpAgentService.getAgentById(mpAgentEmployeeRelationEntity.getAgentId());
|
||||||
if (agentEntity == null) {
|
if (Objects.isNull(agentEntity)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return AppAgentConvert.INSTANCE.entityToResp(agentEntity);
|
AppMpAgentResp appMpAgentResp = AppAgentConvert.INSTANCE.entityToResp(agentEntity);
|
||||||
|
Boolean isContactPerson = Objects.nonNull(agentEntity.getContactUserId()) && agentEntity.getContactUserId().equals(userId);
|
||||||
|
appMpAgentResp.setIsContactPerson(isContactPerson);
|
||||||
|
return appMpAgentResp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -0,0 +1,37 @@
|
|||||||
|
package com.seer.teach.mp.app.service.impl;
|
||||||
|
|
||||||
|
import com.seer.teach.mp.app.controller.req.JsapiSignatureReq;
|
||||||
|
import com.seer.teach.mp.app.controller.resp.JsapiSignatureResp;
|
||||||
|
import com.seer.teach.mp.app.service.IAppMpSignatureService;
|
||||||
|
import com.seer.teach.mp.factory.MpServiceFactory;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
||||||
|
import me.chanjar.weixin.common.error.WxErrorException;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信公众号JS-SDK签名服务实现类
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AppMpSignatureServiceImpl implements IAppMpSignatureService {
|
||||||
|
|
||||||
|
private final MpServiceFactory mpServiceFactory;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsapiSignatureResp generateJsapiSignature(JsapiSignatureReq req) {
|
||||||
|
try {
|
||||||
|
// 获取WxMpService实例
|
||||||
|
var mpService = mpServiceFactory.getRequiredMpService(req.getAppId());
|
||||||
|
|
||||||
|
WxJsapiSignature wxJsapiSignature = mpService.createJsapiSignature(req.getUrl());
|
||||||
|
|
||||||
|
return new JsapiSignatureResp(wxJsapiSignature.getTimestamp(), wxJsapiSignature.getNonceStr(), wxJsapiSignature.getSignature(), req.getAppId());
|
||||||
|
} catch (WxErrorException e) {
|
||||||
|
log.error("生成JS-SDK签名失败,appId: {}, url: {}", req.getAppId(), req.getUrl(), e);
|
||||||
|
throw new RuntimeException("生成JS-SDK签名失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -31,4 +31,12 @@ public interface IMpAgentActivityParticipantService extends IService<MpAgentActi
|
|||||||
* @return 参与记录列表
|
* @return 参与记录列表
|
||||||
*/
|
*/
|
||||||
List<MpAgentActivityParticipantEntity> getListByAgentId(Integer agentId);
|
List<MpAgentActivityParticipantEntity> getListByAgentId(Integer agentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据活动ID获取所有参与记录
|
||||||
|
*
|
||||||
|
* @param activityId 活动ID
|
||||||
|
* @return 参与记录列表
|
||||||
|
*/
|
||||||
|
List<MpAgentActivityParticipantEntity> getOneByActivityId(Integer activityId);
|
||||||
}
|
}
|
||||||
@ -22,9 +22,10 @@ public interface IMpAgentService extends IService<MpAgentEntity> {
|
|||||||
* 保存代理商
|
* 保存代理商
|
||||||
*
|
*
|
||||||
* @param agentEntity 代理商实体
|
* @param agentEntity 代理商实体
|
||||||
|
* @param password m密码
|
||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
*/
|
*/
|
||||||
Boolean saveAgent(MpAgentEntity agentEntity);
|
Boolean saveAgent(MpAgentEntity agentEntity,String password);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新代理商
|
* 更新代理商
|
||||||
|
|||||||
@ -42,4 +42,9 @@ public class MpAgentActivityParticipantServiceImpl extends ServiceImpl<MpAgentAc
|
|||||||
return super.list(new LambdaQueryWrapper<MpAgentActivityParticipantEntity>()
|
return super.list(new LambdaQueryWrapper<MpAgentActivityParticipantEntity>()
|
||||||
.eq(MpAgentActivityParticipantEntity::getAgentId, agentId));
|
.eq(MpAgentActivityParticipantEntity::getAgentId, agentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MpAgentActivityParticipantEntity> getOneByActivityId(Integer activityId) {
|
||||||
|
return super.list(new LambdaQueryWrapper<MpAgentActivityParticipantEntity>().eq(MpAgentActivityParticipantEntity::getActivityId, activityId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,9 +1,14 @@
|
|||||||
package com.seer.teach.mp.service.impl;
|
package com.seer.teach.mp.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.seer.teach.common.enums.RoleEnum;
|
||||||
import com.seer.teach.mp.entity.MpAgentEntity;
|
import com.seer.teach.mp.entity.MpAgentEntity;
|
||||||
import com.seer.teach.mp.mapper.MpAgentMapper;
|
import com.seer.teach.mp.mapper.MpAgentMapper;
|
||||||
import com.seer.teach.mp.service.IMpAgentService;
|
import com.seer.teach.mp.service.IMpAgentService;
|
||||||
|
import com.seer.teach.user.api.UserInfoServiceApi;
|
||||||
|
import com.seer.teach.user.api.dto.UserInfoDTO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -11,16 +16,28 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* 代理商服务实现类
|
* 代理商服务实现类
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class MpAgentServiceImpl extends ServiceImpl<MpAgentMapper, MpAgentEntity> implements IMpAgentService {
|
public class MpAgentServiceImpl extends ServiceImpl<MpAgentMapper, MpAgentEntity> implements IMpAgentService {
|
||||||
|
|
||||||
|
private final UserInfoServiceApi userInfoServiceApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MpAgentEntity getAgentById(Integer id) {
|
public MpAgentEntity getAgentById(Integer id) {
|
||||||
return this.getById(id);
|
return this.getById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean saveAgent(MpAgentEntity agentEntity) {
|
public Boolean saveAgent(MpAgentEntity agentEntity,String password) {
|
||||||
|
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||||
|
userInfoDTO.setUserName(agentEntity.getContactName());
|
||||||
|
userInfoDTO.setPassword(password);
|
||||||
|
userInfoDTO.setMobile(agentEntity.getContactPhone());
|
||||||
|
userInfoDTO.setRoleCode(RoleEnum.AGENT);
|
||||||
|
Integer userId = userInfoServiceApi.addUserInfoAndAssignRole(userInfoDTO);
|
||||||
|
log.info("用户id:{}", userId);
|
||||||
|
agentEntity.setContactUserId(userId);
|
||||||
return this.save(agentEntity);
|
return this.save(agentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -47,12 +47,6 @@ public interface GradeServiceApi {
|
|||||||
@PostMapping("/addGrade")
|
@PostMapping("/addGrade")
|
||||||
ResultBean addGrade(@RequestParam("status") Integer status, @RequestParam("grade") String grade);
|
ResultBean addGrade(@RequestParam("status") Integer status, @RequestParam("grade") String grade);
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除年级
|
|
||||||
* @param ids
|
|
||||||
*/
|
|
||||||
@DeleteMapping("/delete")
|
|
||||||
void deleteGrade(@RequestBody List<Integer> ids);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改年级状态
|
* 修改年级状态
|
||||||
|
|||||||
@ -2,10 +2,7 @@ package com.seer.teach.user.api;
|
|||||||
|
|
||||||
import com.seer.teach.user.api.dto.*;
|
import com.seer.teach.user.api.dto.*;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -124,6 +121,24 @@ public interface UserInfoServiceApi {
|
|||||||
@PostMapping("/update-user-assign-role")
|
@PostMapping("/update-user-assign-role")
|
||||||
boolean updateUserInfoAndAssignRole(@RequestBody UserInfoDTO userInfoDTO);
|
boolean updateUserInfoAndAssignRole(@RequestBody UserInfoDTO userInfoDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跟新用户信息
|
||||||
|
*
|
||||||
|
* @param userInfoDTO 用户信息
|
||||||
|
* @return 用户ID
|
||||||
|
*/
|
||||||
|
@PutMapping("/update")
|
||||||
|
boolean updateUserInfo(@RequestBody UserInfoDTO userInfoDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户信息并分配角色
|
||||||
|
*
|
||||||
|
* @param userInfoDTO 用户信息
|
||||||
|
* @return 用户ID
|
||||||
|
*/
|
||||||
|
@PostMapping("/add-user-assign-role")
|
||||||
|
Integer addUserInfoAndAssignRole(@RequestBody UserInfoDTO userInfoDTO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据孩子Id获取家长信息
|
* 根据孩子Id获取家长信息
|
||||||
*
|
*
|
||||||
@ -174,6 +189,10 @@ public interface UserInfoServiceApi {
|
|||||||
@GetMapping("/getUserIdByUserName")
|
@GetMapping("/getUserIdByUserName")
|
||||||
Integer getUserIdByUserName(@RequestParam("userName") String userName);
|
Integer getUserIdByUserName(@RequestParam("userName") String userName);
|
||||||
|
|
||||||
@PostMapping("/save-agentInfo")
|
@GetMapping("/getUserIdsByUserNameLike")
|
||||||
boolean saveAgentInfo(@RequestBody UserInfoDTO userInfoDTO);
|
List< Integer> getUserIdsByUserNameLike(@RequestParam("userName") String userName);
|
||||||
|
|
||||||
|
@GetMapping("/getUserIdByMobile")
|
||||||
|
boolean getUserIdByMobile(@RequestParam("mobile") String mobile);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2,12 +2,28 @@ package com.seer.teach.user.api;
|
|||||||
|
|
||||||
import com.seer.teach.user.api.dto.UserRelationDTO;
|
import com.seer.teach.user.api.dto.UserRelationDTO;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
@FeignClient(name = ApiConstants.SERVER_NAME, contextId = "userRelationServiceApi", path = "/seer/user/internal")
|
@FeignClient(name = ApiConstants.SERVER_NAME, contextId = "userRelationServiceApi", path = "/seer/user/internal")
|
||||||
public interface UserRelationServiceApi {
|
public interface UserRelationServiceApi {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存用户关系
|
||||||
|
*
|
||||||
|
* @param userRelationDTO 用户关系信息
|
||||||
|
* @return 保存结果
|
||||||
|
*/
|
||||||
@PostMapping("/save-relation")
|
@PostMapping("/save-relation")
|
||||||
boolean saveUserRelation(@RequestBody UserRelationDTO userRelationDTO);
|
boolean saveUserRelation(@RequestBody UserRelationDTO userRelationDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户关系
|
||||||
|
*
|
||||||
|
* @param userRelationDTO 用户关系信息
|
||||||
|
* @return 删除结果
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
boolean deleteUserRelation(@RequestBody UserRelationDTO userRelationDTO);
|
||||||
}
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
package com.seer.teach.user.api.dto;
|
package com.seer.teach.user.api.dto;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.seer.teach.common.enums.RoleEnum;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -62,5 +63,5 @@ public class UserInfoDTO {
|
|||||||
private Integer experience;
|
private Integer experience;
|
||||||
|
|
||||||
@Schema(description = "角色编码")
|
@Schema(description = "角色编码")
|
||||||
private String roleCode;
|
private RoleEnum roleCode;
|
||||||
}
|
}
|
||||||
@ -1,18 +1,23 @@
|
|||||||
package com.seer.teach.user.api.dto;
|
package com.seer.teach.user.api.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(description = "用户关系DTO")
|
||||||
@Data
|
@Data
|
||||||
public class UserRelationDTO {
|
public class UserRelationDTO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户ID
|
* 用户ID
|
||||||
*/
|
*/
|
||||||
|
@NotNull(message = "用户ID不能为空")
|
||||||
private Integer userId;
|
private Integer userId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关联的用户ID
|
* 关联的用户ID
|
||||||
*/
|
*/
|
||||||
|
@NotNull(message = "关联的用户ID不能为空")
|
||||||
private Integer relationId;
|
private Integer relationId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -21,6 +21,8 @@ spring:
|
|||||||
- optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml
|
- optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml
|
||||||
- optional:nacos:shared-database.yaml
|
- optional:nacos:shared-database.yaml
|
||||||
- optional:nacos:shared-redis.yaml
|
- optional:nacos:shared-redis.yaml
|
||||||
|
- optional:nacos:shared-sa-token.yaml
|
||||||
|
- optional:nacos:shared-minio.yaml
|
||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
|
|||||||
@ -45,6 +45,9 @@ public class OfficialOauthWithAccountLoginStrategy extends AbstractLoginStrategy
|
|||||||
UserEntity accountUser = null;
|
UserEntity accountUser = null;
|
||||||
if (request.getUserName() != null && !request.getUserName().isEmpty()) {
|
if (request.getUserName() != null && !request.getUserName().isEmpty()) {
|
||||||
accountUser = userService.getOneByUserName(request.getUserName());
|
accountUser = userService.getOneByUserName(request.getUserName());
|
||||||
|
if (accountUser == null) {
|
||||||
|
accountUser = userService.getOneByMobile(request.getUserName());
|
||||||
|
}
|
||||||
} else if (request.getPhoneNumber() != null && !request.getPhoneNumber().isEmpty()) {
|
} else if (request.getPhoneNumber() != null && !request.getPhoneNumber().isEmpty()) {
|
||||||
accountUser = userService.getOneByMobile(request.getPhoneNumber());
|
accountUser = userService.getOneByMobile(request.getPhoneNumber());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,19 +95,6 @@ public class GradeServiceApiImpl implements GradeServiceApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除年级
|
|
||||||
* @param ids
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void deleteGrade(List<Integer> ids) {
|
|
||||||
AssertUtils.notEmpty(ids, ResultCodeEnum.PLEASE_SELECT_THE_GRADE_TO_DELETED);
|
|
||||||
List<Integer> distinctIds = ids.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
||||||
gradeService.removeByIds(distinctIds);
|
|
||||||
log.info("删除年级成功,ids={}", distinctIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultBean updateGradeStatus(GradeUpdateDTO params) {
|
public ResultBean updateGradeStatus(GradeUpdateDTO params) {
|
||||||
GradeEntity grade = gradeService.getById(params.getId());
|
GradeEntity grade = gradeService.getById(params.getId());
|
||||||
|
|||||||
@ -3,11 +3,12 @@ package com.seer.teach.user.admin.api;
|
|||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.seer.teach.common.dto.mq.im.MqUserInfoDTO;
|
import com.seer.teach.common.dto.mq.im.MqUserInfoDTO;
|
||||||
import com.seer.teach.common.enums.im.ImMqTopicEnum;
|
|
||||||
import com.seer.teach.common.enums.ResultCodeEnum;
|
import com.seer.teach.common.enums.ResultCodeEnum;
|
||||||
import com.seer.teach.common.enums.RoleEnum;
|
import com.seer.teach.common.enums.RoleEnum;
|
||||||
|
import com.seer.teach.common.enums.im.ImMqTopicEnum;
|
||||||
import com.seer.teach.common.enums.im.UserInfoTopiTagEnum;
|
import com.seer.teach.common.enums.im.UserInfoTopiTagEnum;
|
||||||
import com.seer.teach.common.enums.iot.IsInfoEnum;
|
import com.seer.teach.common.enums.iot.IsInfoEnum;
|
||||||
|
import com.seer.teach.common.exception.CommonException;
|
||||||
import com.seer.teach.common.utils.AssertUtils;
|
import com.seer.teach.common.utils.AssertUtils;
|
||||||
import com.seer.teach.common.utils.CommonUtils;
|
import com.seer.teach.common.utils.CommonUtils;
|
||||||
import com.seer.teach.iot.api.UserDeviceServiceApi;
|
import com.seer.teach.iot.api.UserDeviceServiceApi;
|
||||||
@ -215,10 +216,37 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
|||||||
@Override
|
@Override
|
||||||
public boolean updateUserInfoAndAssignRole(UserInfoDTO userInfoDTO) {
|
public boolean updateUserInfoAndAssignRole(UserInfoDTO userInfoDTO) {
|
||||||
UserEntity UserEntity = UserInfoConvert.INSTANCE.convertOne(userInfoDTO);
|
UserEntity UserEntity = UserInfoConvert.INSTANCE.convertOne(userInfoDTO);
|
||||||
userRoleService.assignUserRoleByRoleCode(UserEntity.getId(), userInfoDTO.getRoleCode());
|
userRoleService.assignUserRoleByRoleCode(UserEntity.getId(), userInfoDTO.getRoleCode().getCode());
|
||||||
return userService.updateById(UserEntity);
|
return userService.updateById(UserEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateUserInfo(UserInfoDTO userInfoDTO) {
|
||||||
|
UserEntity oldUser = userService.getById(userInfoDTO.getId());
|
||||||
|
UserEntity userEntity = UserInfoConvert.INSTANCE.convertOne(userInfoDTO);
|
||||||
|
// 密码加密(只有传入的密码不为空时,才加密并更新,否则保留原密码)
|
||||||
|
if (StringUtils.hasText(userInfoDTO.getPassword())) {
|
||||||
|
userEntity.setPassword(CommonUtils.encryptPassword(userInfoDTO.getPassword()));
|
||||||
|
} else {
|
||||||
|
// 保留原密码
|
||||||
|
userEntity.setPassword(oldUser.getPassword());
|
||||||
|
}
|
||||||
|
return userService.updateById(userEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer addUserInfoAndAssignRole(UserInfoDTO userInfoDTO) {
|
||||||
|
UserEntity userEntity = UserInfoConvert.INSTANCE.convertOne(userInfoDTO);
|
||||||
|
userEntity.setPassword(CommonUtils.encryptPassword(userInfoDTO.getPassword()));
|
||||||
|
boolean saved = userService.save(userEntity);
|
||||||
|
log.info("保存用户信息:{}", saved);
|
||||||
|
if(saved){
|
||||||
|
userRoleService.assignUserRoleByRoleCode(userEntity.getId(), userInfoDTO.getRoleCode().getCode());
|
||||||
|
return userEntity.getId();
|
||||||
|
}
|
||||||
|
throw new CommonException(ResultCodeEnum.USER_SAVE_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getParentIdByChildrenId(Integer childrenId) {
|
public Integer getParentIdByChildrenId(Integer childrenId) {
|
||||||
return userRelationService.getParentIdByChildrenId(childrenId);
|
return userRelationService.getParentIdByChildrenId(childrenId);
|
||||||
@ -270,7 +298,6 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
|||||||
log.info("注册默认Children User:{}", userEntity);
|
log.info("注册默认Children User:{}", userEntity);
|
||||||
return userEntity.getId();
|
return userEntity.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer checkUserInfo(Integer userId) {
|
public Integer checkUserInfo(Integer userId) {
|
||||||
UserExtendEntity byUserId = userExtendService.getByUserId(userId);
|
UserExtendEntity byUserId = userExtendService.getByUserId(userId);
|
||||||
@ -289,15 +316,15 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveAgentInfo(UserInfoDTO userInfoDTO) {
|
public List<Integer> getUserIdsByUserNameLike(String userName) {
|
||||||
UserEntity one = userService.getOne(new LambdaQueryWrapper<UserEntity>()
|
return userService.lambdaQuery().select(UserEntity::getId).like(UserEntity::getUserName, userName)
|
||||||
.eq(UserEntity::getUserName, userInfoDTO.getUserName()));
|
.list().stream().map(UserEntity::getId).toList();
|
||||||
AssertUtils.isNull(one, ResultCodeEnum.USERNAME_IS_EXIST);
|
}
|
||||||
UserEntity user = new UserEntity();
|
|
||||||
user.setUserName(userInfoDTO.getUserName());
|
@Override
|
||||||
String password = CommonUtils.encryptPassword(userInfoDTO.getPassword());
|
public boolean getUserIdByMobile(String mobile) {
|
||||||
user.setPassword(password);
|
UserEntity one = userService.lambdaQuery().eq(UserEntity::getMobile, mobile).one();
|
||||||
return userService.save(user);
|
return one == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -22,4 +22,11 @@ public class UserRelationServiceApiImpl implements UserRelationServiceApi {
|
|||||||
UserRelationEntity userRelation = UserRelationConvert.INSTANCE.convertOne(userRelationDTO);
|
UserRelationEntity userRelation = UserRelationConvert.INSTANCE.convertOne(userRelationDTO);
|
||||||
return userRelationService.save(userRelation);
|
return userRelationService.save(userRelation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteUserRelation(UserRelationDTO userRelationDTO) {
|
||||||
|
log.info("删除用户关系:{}", userRelationDTO);
|
||||||
|
UserRelationEntity userRelation = UserRelationConvert.INSTANCE.convertOne(userRelationDTO);
|
||||||
|
return userRelationService.deleteUserRelation(userRelation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -117,4 +117,12 @@ public interface IUserRelationService extends IService<UserRelationEntity> {
|
|||||||
* @return 用户关系列表
|
* @return 用户关系列表
|
||||||
*/
|
*/
|
||||||
List<UserRelationEntity> getUserRelationByUserIdAndFamilyId(Integer userId, Integer familyId);
|
List<UserRelationEntity> getUserRelationByUserIdAndFamilyId(Integer userId, Integer familyId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户关系
|
||||||
|
*
|
||||||
|
* @param userRelation 用户关系
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
boolean deleteUserRelation(UserRelationEntity userRelation);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,7 +40,7 @@ public interface IUserRoleService extends IService<UserRoleEntity> {
|
|||||||
* @param userId 角色编号
|
* @param userId 角色编号
|
||||||
* @param roleIds 角色编号集合
|
* @param roleIds 角色编号集合
|
||||||
*/
|
*/
|
||||||
void assignUserRole(Integer userId, Set<Integer> roleIds);
|
boolean assignUserRole(Integer userId, Set<Integer> roleIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 为用户分配角色
|
* 为用户分配角色
|
||||||
@ -48,7 +48,7 @@ public interface IUserRoleService extends IService<UserRoleEntity> {
|
|||||||
* @param userId 角色编号
|
* @param userId 角色编号
|
||||||
* @param roleId 角色编号集合
|
* @param roleId 角色编号集合
|
||||||
*/
|
*/
|
||||||
void assignUserRole(Integer userId, Integer roleId);
|
boolean assignUserRole(Integer userId, Integer roleId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 为用户分配角色
|
* 为用户分配角色
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -105,4 +106,12 @@ public class UserRelationServiceImpl extends ServiceImpl<UserRelationMapper, Use
|
|||||||
.eq(UserRelationEntity::getFamilyId, familyId)
|
.eq(UserRelationEntity::getFamilyId, familyId)
|
||||||
.eq(UserRelationEntity::getUserId, userId));
|
.eq(UserRelationEntity::getUserId, userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteUserRelation(UserRelationEntity userRelation) {
|
||||||
|
return super.remove(new LambdaQueryWrapper<>(UserRelationEntity.class)
|
||||||
|
.eq(UserRelationEntity::getUserId, userRelation.getUserId())
|
||||||
|
.eq(UserRelationEntity::getRelationId, userRelation.getRelationId())
|
||||||
|
.eq(Objects.nonNull(userRelation.getType()),UserRelationEntity::getType, userRelation.getType()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,42 +58,38 @@ public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRoleEnt
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void assignUserRole(Integer userId, Set<Integer> roleIds) {
|
public boolean assignUserRole(Integer userId, Set<Integer> roleIds) {
|
||||||
List<UserRoleEntity> userRoleList = this.getListByUserId(userId);
|
List<UserRoleEntity> userRoleList = this.getListByUserId(userId);
|
||||||
if(CollectionUtils.isEmpty(userRoleList)){
|
if(CollectionUtils.isEmpty(userRoleList)){
|
||||||
List<UserRoleEntity> userRoles = roleIds.stream().map(roleId -> UserRoleEntity.builder().userId(userId).roleId(roleId.intValue()).build()).collect(Collectors.toList());
|
List<UserRoleEntity> userRoles = roleIds.stream().map(roleId -> UserRoleEntity.builder().userId(userId).roleId(roleId.intValue()).build()).collect(Collectors.toList());
|
||||||
boolean savedBatch = super.saveBatch(userRoles);
|
boolean savedBatch = super.saveBatch(userRoles);
|
||||||
log.info("分配角色[{}] result:{}", userRoles, savedBatch);
|
log.info("分配角色[{}] result:{}", userRoles, savedBatch);
|
||||||
return;
|
return savedBatch;
|
||||||
}
|
}
|
||||||
Set<Integer> roleIdSet = userRoleList.stream().map(UserRoleEntity::getRoleId).collect(Collectors.toSet());
|
Set<Integer> roleIdSet = userRoleList.stream().map(UserRoleEntity::getRoleId).collect(Collectors.toSet());
|
||||||
Collection<Integer> createRoleIds = CollUtil.subtract(roleIds, roleIdSet);
|
Collection<Integer> createRoleIds = CollUtil.subtract(roleIds, roleIdSet);
|
||||||
Collection<Integer> deleteRoleIds = CollUtil.subtract(roleIdSet, roleIds);
|
|
||||||
if (CollUtil.isNotEmpty(createRoleIds)) {
|
if (CollUtil.isNotEmpty(createRoleIds)) {
|
||||||
List<UserRoleEntity> userRoles = createRoleIds.stream().map(roleId -> UserRoleEntity.builder().userId(userId).roleId(roleId.intValue()).build()).collect(Collectors.toList());
|
List<UserRoleEntity> userRoles = createRoleIds.stream().map(roleId -> UserRoleEntity.builder().userId(userId).roleId(roleId.intValue()).build()).collect(Collectors.toList());
|
||||||
boolean savedBatch = super.saveBatch(userRoles);
|
boolean savedBatch = super.saveBatch(userRoles);
|
||||||
log.info("新增角色[{}] result:{}", userRoles, savedBatch);
|
log.info("新增角色[{}] result:{}", userRoles, savedBatch);
|
||||||
|
return savedBatch;
|
||||||
}
|
}
|
||||||
if (CollUtil.isNotEmpty(deleteRoleIds)) {
|
return true;
|
||||||
super.remove(new LambdaQueryWrapper<>(UserRoleEntity.class).eq(UserRoleEntity::getUserId, userId).in(UserRoleEntity::getRoleId, deleteRoleIds));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void assignUserRole(Integer userId, Integer roleId) {
|
public boolean assignUserRole(Integer userId, Integer roleId) {
|
||||||
Set<Integer> roleIds = new HashSet<>();
|
Set<Integer> roleIds = new HashSet<>();
|
||||||
roleIds.add(roleId);
|
roleIds.add(roleId);
|
||||||
assignUserRole(userId, roleIds);
|
return assignUserRole(userId, roleIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean assignUserRoleByRoleCode(Integer userId, String roleCode) {
|
public boolean assignUserRoleByRoleCode(Integer userId, String roleCode) {
|
||||||
Optional<RoleEntity> role = roleService.getRoleByCode(roleCode);
|
Optional<RoleEntity> role = roleService.getRoleByCode(roleCode);
|
||||||
if(!role.isPresent()){
|
if(role.isPresent()){
|
||||||
return false;
|
return assignUserRole(userId, role.get().getId());
|
||||||
}
|
}
|
||||||
assignUserRole(userId, role.get().getId());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user